@resolveio/server-lib 22.3.204 → 22.3.206
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.d.ts +8 -0
- package/methods/ai-terminal.js +967 -274
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -1888,7 +1888,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1888
1888
|
insertResult = _d.sent();
|
|
1889
1889
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1890
1890
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1891
|
-
var runStart, fastModeEnabled, alwaysAllowProbeEnabled, plannerEnabled, runBudgetMs, assistantMongoMaxTimeMs, assistantSystemPrompt, runDeadlineMs, steps, recordStep, requestClassification, dataQuestion, progressTracker, streamProgress, remainingRunBudgetMs, hasRunBudget, applyCodexStageBudget, assistantContent, toolResult, assistantDebug, directiveSource, lastDirective, heuristicDirectivePrecomputed, usedDeterministicHeuristicFastPath, requestedTimeGrain, requestedBreakdownDimensions, enforceDatedDirective, enforceGroupedDirective, datedDirectiveRetryUsed, datedDirectiveResolved, toolResponseDebug, toolError, toolTelemetry, termHints, collectionHints, fieldHints, schemaHints, methodHints, publicationHints, collectionTokenization, collectionRanking, collectionSelection, collectionOverride, collectionNames, plannerUsed, plannerSkipReason, plannerOutput, plannerRaw, appDataRequestClassifierDebug, appDataRequestClassifierIntent, appDataRequestClassifierUnderstanding, timingBreakdown, codexUsage, accumulateCodexUsage, contextRoute, contextMode, hintSeed, termExpansion, hintText, baseTokens, expandedTokens, baseWeights, expandedWeights, dbName, db, surfaceHints, _a, allowedRoutes, rankedAllowedRoutes, routeHints, appCollectionHints, rankedCollectionHints, rankedCollections, hintCollections, schemaHintCollections, assistantContext, scoredAppDataIntentCandidates, shouldAttemptAppDataClassifier, classifierResult, classifierUsageClientId, usageError_1, hasDeterministicHeuristicFastPath, prompt_1, workspaceRoot, codexConfig, runOptions, plannerRunOptions, shouldRunPlanner, plannerBudgetAvailable, plannerPrompt, plannerStart, _b, preferListDirective, directiveStyleHint, directivePromptMode, responseText, directiveText, directive, heuristicDirectiveFastPath, directivePrompt, directiveStart, forcedDirective, error_2, initialStart, extractedDirective, error_3, directivePrompt, forcedStart, forcedDirective, error_4, strictDirectivePrompt, strictStart, strictDirectiveText, strictDirective, strictDirectiveIsDated, shouldUseStrictDirective, error_5, guardDirectivePrompt, guardStart, guardDirectiveText, guardDirective, error_6, groupedDirectivePrompt, groupedStart, groupedDirectiveText, groupedDirective, error_7, heuristicDirective, requestedCollection, allowCollectionOverride, cleanedResponseText, deniedModuleByIntent, permissionLabel, effectiveDirective, effectiveDirectiveMetadata, directiveAcknowledgementText, directiveProgressMessages, deterministicDataIntentDirective, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, executionDirective, probeFieldHints, aggregateProbeDisabled, probeEnabled, probeBudgetAllowed, probeDirective, probeRequest, probeStart, probeResponse, _c, probeDurationMs, probeRowCount, probeRewrite, probeError_1, probeDurationMs, probeErrorMessage, toolRequest, requestedToolCollection, toolStart, toolResponse, _d, toolDurationMs, toolPayload, resolvedToolCollection, zeroRowResult, followupCodexEnabled, skipFollowupCodex, followupPrompt, followupStart, followupText, _e, error_8, errorMessage, existingFinal, error_9, runBudgetExceeded, includeToolExecutionTelemetry, toolExecutionTelemetry, finishedAt, finalNow, finishedAt, codexMs, draftingMs, answerQualityEvidence, finalMetadata, finalUsage, finalUsageLedgerEntry, usageClientId, usageError_2, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _f;
|
|
1891
|
+
var runStart, fastModeEnabled, alwaysAllowProbeEnabled, plannerEnabled, runBudgetMs, assistantMongoMaxTimeMs, assistantSystemPrompt, runDeadlineMs, steps, recordStep, requestClassification, dataQuestion, progressTracker, finalProgress, streamProgress, remainingRunBudgetMs, hasRunBudget, applyCodexStageBudget, assistantContent, toolResult, assistantDebug, directiveSource, lastDirective, heuristicDirectivePrecomputed, usedDeterministicHeuristicFastPath, requestedTimeGrain, requestedBreakdownDimensions, enforceDatedDirective, enforceGroupedDirective, datedDirectiveRetryUsed, datedDirectiveResolved, toolResponseDebug, toolError, toolTelemetry, termHints, collectionHints, fieldHints, schemaHints, methodHints, publicationHints, collectionTokenization, collectionRanking, collectionSelection, collectionOverride, collectionNames, plannerUsed, plannerSkipReason, plannerOutput, plannerRaw, appDataRequestClassifierDebug, appDataRequestClassifierIntent, appDataRequestClassifierUnderstanding, timingBreakdown, codexUsage, accumulateCodexUsage, contextRoute, contextMode, hintSeed, termExpansion, hintText, baseTokens, expandedTokens, baseWeights, expandedWeights, dbName, db, surfaceHints, _a, allowedRoutes, rankedAllowedRoutes, routeHints, appCollectionHints, rankedCollectionHints, rankedCollections, hintCollections, schemaHintCollections, assistantContext, scoredAppDataIntentCandidates, shouldAttemptAppDataClassifier, classifierResult, classifierUsageClientId, usageError_1, hasDeterministicHeuristicFastPath, prompt_1, workspaceRoot, codexConfig, runOptions, plannerRunOptions, shouldRunPlanner, plannerBudgetAvailable, plannerPrompt, plannerStart, _b, preferListDirective, directiveStyleHint, directivePromptMode, responseText, directiveText, directive, heuristicDirectiveFastPath, directivePrompt, directiveStart, forcedDirective, error_2, initialStart, extractedDirective, error_3, directivePrompt, forcedStart, forcedDirective, error_4, strictDirectivePrompt, strictStart, strictDirectiveText, strictDirective, strictDirectiveIsDated, shouldUseStrictDirective, error_5, guardDirectivePrompt, guardStart, guardDirectiveText, guardDirective, error_6, groupedDirectivePrompt, groupedStart, groupedDirectiveText, groupedDirective, error_7, heuristicDirective, requestedCollection, allowCollectionOverride, cleanedResponseText, deniedModuleByIntent, permissionLabel, effectiveDirective, effectiveDirectiveMetadata, directiveAcknowledgementText, directiveProgressMessages, deterministicDataIntentDirective, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, breakdownProgress, executionDirective, probeFieldHints, aggregateProbeDisabled, probeEnabled, probeBudgetAllowed, probeDirective, probeRequest, probeStart, probeResponse, _c, probeDurationMs, probeRowCount, probeRewrite, probeError_1, probeDurationMs, probeErrorMessage, toolRequest, requestedToolCollection, toolStart, toolResponse, _d, toolDurationMs, toolPayload, resolvedToolCollection, zeroRowResult, followupCodexEnabled, skipFollowupCodex, followupPrompt, followupStart, followupText, _e, error_8, errorMessage, existingFinal, error_9, runBudgetExceeded, includeToolExecutionTelemetry, toolExecutionTelemetry, finishedAt, finalNow, finishedAt, codexMs, draftingMs, answerQualityEvidence, finalMetadata, finalUsage, finalUsageLedgerEntry, usageClientId, usageError_2, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _f;
|
|
1892
1892
|
var _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
|
|
1893
1893
|
return __generator(this, function (_21) {
|
|
1894
1894
|
switch (_21.label) {
|
|
@@ -1931,6 +1931,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1931
1931
|
requestClassification = classifyAssistantRequestType(message);
|
|
1932
1932
|
dataQuestion = requestClassification.dataQuestion;
|
|
1933
1933
|
progressTracker = createAssistantProgressTracker(assistantMessageId, initialProgress);
|
|
1934
|
+
finalProgress = initialProgress;
|
|
1934
1935
|
streamProgress = createAssistantStreamProgressHandler(progressTracker, function () { return dataQuestion; });
|
|
1935
1936
|
remainingRunBudgetMs = function () {
|
|
1936
1937
|
if (!runDeadlineMs) {
|
|
@@ -2037,7 +2038,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2037
2038
|
});
|
|
2038
2039
|
_21.label = 1;
|
|
2039
2040
|
case 1:
|
|
2040
|
-
_21.trys.push([1, 76, 77,
|
|
2041
|
+
_21.trys.push([1, 76, 77, 79]);
|
|
2041
2042
|
hintSeed = [message, contextRoute].filter(Boolean).join(' ');
|
|
2042
2043
|
termExpansion = expandAssistantTermSynonyms(hintSeed);
|
|
2043
2044
|
hintText = termExpansion.expanded || hintSeed;
|
|
@@ -2753,6 +2754,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2753
2754
|
else {
|
|
2754
2755
|
progressTracker.push(deterministicDataIntentDirective ? AI_ASSISTANT_PROGRESS_DATA_RUNNING : AI_ASSISTANT_PROGRESS_DATA_LOOKUP);
|
|
2755
2756
|
}
|
|
2757
|
+
breakdownProgress = buildAssistantBreakdownProgressMessage(effectiveDirectiveMetadata.requestContract);
|
|
2758
|
+
if (breakdownProgress) {
|
|
2759
|
+
progressTracker.push(breakdownProgress);
|
|
2760
|
+
}
|
|
2756
2761
|
directiveProgressMessages.slice(0, 2).forEach(function (messageText) { return progressTracker.push(messageText); });
|
|
2757
2762
|
executionDirective = effectiveDirective;
|
|
2758
2763
|
probeFieldHints = [];
|
|
@@ -2992,16 +2997,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2992
2997
|
progressTracker.push(AI_ASSISTANT_PROGRESS_DRAFT);
|
|
2993
2998
|
recordStep('Drafting response');
|
|
2994
2999
|
_21.label = 75;
|
|
2995
|
-
case 75: return [3 /*break*/,
|
|
3000
|
+
case 75: return [3 /*break*/, 79];
|
|
2996
3001
|
case 76:
|
|
2997
3002
|
error_9 = _21.sent();
|
|
2998
3003
|
assistantContent = buildAssistantCodexErrorMessage(error_9);
|
|
2999
3004
|
recordStep('Error', { message: normalizeOptionalString(error_9 === null || error_9 === void 0 ? void 0 : error_9.message) || 'Unknown error' });
|
|
3000
|
-
return [3 /*break*/,
|
|
3001
|
-
case 77:
|
|
3002
|
-
progressTracker.stop();
|
|
3003
|
-
return [7 /*endfinally*/];
|
|
3005
|
+
return [3 /*break*/, 79];
|
|
3006
|
+
case 77: return [4 /*yield*/, progressTracker.stop()];
|
|
3004
3007
|
case 78:
|
|
3008
|
+
finalProgress = _21.sent();
|
|
3009
|
+
return [7 /*endfinally*/];
|
|
3010
|
+
case 79:
|
|
3005
3011
|
runBudgetExceeded = runDeadlineMs ? Date.now() > runDeadlineMs : false;
|
|
3006
3012
|
if (!assistantContent) {
|
|
3007
3013
|
assistantContent = runBudgetExceeded
|
|
@@ -3045,9 +3051,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3045
3051
|
});
|
|
3046
3052
|
}
|
|
3047
3053
|
finalNow = new Date();
|
|
3048
|
-
_21.label =
|
|
3049
|
-
case
|
|
3050
|
-
_21.trys.push([
|
|
3054
|
+
_21.label = 80;
|
|
3055
|
+
case 80:
|
|
3056
|
+
_21.trys.push([80, 92, , 103]);
|
|
3051
3057
|
if (canViewDebug) {
|
|
3052
3058
|
finishedAt = Date.now();
|
|
3053
3059
|
codexMs = timingBreakdown.directiveMs
|
|
@@ -3134,7 +3140,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3134
3140
|
toolError: toolError,
|
|
3135
3141
|
now: finalNow
|
|
3136
3142
|
});
|
|
3137
|
-
finalMetadata = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false }), (fastModeEnabled ? {
|
|
3143
|
+
finalMetadata = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false, progress: finalProgress }), (fastModeEnabled ? {
|
|
3138
3144
|
fast_mode: true,
|
|
3139
3145
|
run_budget_ms: runBudgetMs,
|
|
3140
3146
|
run_budget_exhausted: runBudgetExceeded
|
|
@@ -3148,13 +3154,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3148
3154
|
total_tokens: codexUsage.total_tokens
|
|
3149
3155
|
} : null;
|
|
3150
3156
|
finalUsageLedgerEntry = null;
|
|
3151
|
-
if (!finalUsage) return [3 /*break*/,
|
|
3157
|
+
if (!finalUsage) return [3 /*break*/, 85];
|
|
3152
3158
|
return [4 /*yield*/, resolveClientId(conversation, input.id_client, context === null || context === void 0 ? void 0 : context.id_user)];
|
|
3153
|
-
case 80:
|
|
3154
|
-
usageClientId = _21.sent();
|
|
3155
|
-
_21.label = 81;
|
|
3156
3159
|
case 81:
|
|
3157
|
-
_21.
|
|
3160
|
+
usageClientId = _21.sent();
|
|
3161
|
+
_21.label = 82;
|
|
3162
|
+
case 82:
|
|
3163
|
+
_21.trys.push([82, 84, , 85]);
|
|
3158
3164
|
finalUsageLedgerEntry = buildAssistantAIRunUsageLedgerEntry({
|
|
3159
3165
|
idClient: usageClientId || '',
|
|
3160
3166
|
model: finalUsage.model,
|
|
@@ -3174,16 +3180,16 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3174
3180
|
}
|
|
3175
3181
|
});
|
|
3176
3182
|
return [4 /*yield*/, (0, openai_usage_ledger_manager_1.recordOpenAIUsage)(finalUsageLedgerEntry)];
|
|
3177
|
-
case 82:
|
|
3178
|
-
_21.sent();
|
|
3179
|
-
return [3 /*break*/, 84];
|
|
3180
3183
|
case 83:
|
|
3184
|
+
_21.sent();
|
|
3185
|
+
return [3 /*break*/, 85];
|
|
3186
|
+
case 84:
|
|
3181
3187
|
usageError_2 = _21.sent();
|
|
3182
3188
|
console.error(new Date(), 'Failed to record AI usage', usageError_2);
|
|
3183
|
-
return [3 /*break*/,
|
|
3184
|
-
case
|
|
3189
|
+
return [3 /*break*/, 85];
|
|
3190
|
+
case 85:
|
|
3185
3191
|
finalAssistantDoc = __assign(__assign(__assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: assistantContent, metadata: finalMetadata }), (finalUsage ? { usage: finalUsage } : {})), { updatedAt: finalNow });
|
|
3186
|
-
if (!assistantMessageId) return [3 /*break*/,
|
|
3192
|
+
if (!assistantMessageId) return [3 /*break*/, 87];
|
|
3187
3193
|
setPayload = {
|
|
3188
3194
|
content: assistantContent,
|
|
3189
3195
|
metadata: finalMetadata,
|
|
@@ -3193,11 +3199,11 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3193
3199
|
setPayload.usage = finalUsage;
|
|
3194
3200
|
}
|
|
3195
3201
|
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, setPayload)];
|
|
3196
|
-
case
|
|
3202
|
+
case 86:
|
|
3197
3203
|
_21.sent();
|
|
3198
|
-
_21.label =
|
|
3199
|
-
case
|
|
3200
|
-
case
|
|
3204
|
+
_21.label = 87;
|
|
3205
|
+
case 87: return [4 /*yield*/, touchConversation(conversation._id, finalNow, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
3206
|
+
case 88:
|
|
3201
3207
|
_21.sent();
|
|
3202
3208
|
return [4 /*yield*/, recordAssistantAnswerAIRun({
|
|
3203
3209
|
runId: buildAssistantAIRunId('codex_query', [conversation._id, assistantMessageId || requestId]),
|
|
@@ -3216,55 +3222,55 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3216
3222
|
answerQuality: answerQualityEvidence,
|
|
3217
3223
|
now: finalNow
|
|
3218
3224
|
})];
|
|
3219
|
-
case
|
|
3225
|
+
case 89:
|
|
3220
3226
|
_21.sent();
|
|
3221
|
-
if (!(input.delete_files_after_run !== false)) return [3 /*break*/,
|
|
3227
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 91];
|
|
3222
3228
|
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
3223
|
-
case
|
|
3229
|
+
case 90:
|
|
3224
3230
|
_21.sent();
|
|
3225
|
-
_21.label =
|
|
3226
|
-
case
|
|
3227
|
-
case
|
|
3231
|
+
_21.label = 91;
|
|
3232
|
+
case 91: return [2 /*return*/, finalAssistantDoc];
|
|
3233
|
+
case 92:
|
|
3228
3234
|
finalizeError_1 = _21.sent();
|
|
3229
3235
|
failedAt = new Date();
|
|
3230
3236
|
fallbackContent = assistantContent || buildAssistantCodexErrorMessage(finalizeError_1);
|
|
3231
3237
|
failureMetadata = __assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false, failed: true }), (toolExecutionTelemetry ? { tool_execution: toolExecutionTelemetry } : {})), { error_message: normalizeOptionalString(finalizeError_1 === null || finalizeError_1 === void 0 ? void 0 : finalizeError_1.message) || 'Unknown error' });
|
|
3232
|
-
_21.label =
|
|
3233
|
-
case
|
|
3234
|
-
_21.trys.push([
|
|
3235
|
-
if (!assistantMessageId) return [3 /*break*/,
|
|
3238
|
+
_21.label = 93;
|
|
3239
|
+
case 93:
|
|
3240
|
+
_21.trys.push([93, 97, , 98]);
|
|
3241
|
+
if (!assistantMessageId) return [3 /*break*/, 95];
|
|
3236
3242
|
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, {
|
|
3237
3243
|
content: fallbackContent,
|
|
3238
3244
|
metadata: failureMetadata,
|
|
3239
3245
|
updatedAt: failedAt
|
|
3240
3246
|
})];
|
|
3241
|
-
case
|
|
3247
|
+
case 94:
|
|
3242
3248
|
_21.sent();
|
|
3243
|
-
_21.label =
|
|
3244
|
-
case
|
|
3245
|
-
case 95:
|
|
3246
|
-
_21.sent();
|
|
3247
|
-
return [3 /*break*/, 97];
|
|
3249
|
+
_21.label = 95;
|
|
3250
|
+
case 95: return [4 /*yield*/, touchConversation(conversation._id, failedAt, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
3248
3251
|
case 96:
|
|
3252
|
+
_21.sent();
|
|
3253
|
+
return [3 /*break*/, 98];
|
|
3254
|
+
case 97:
|
|
3249
3255
|
persistError_1 = _21.sent();
|
|
3250
3256
|
console.error(new Date(), 'AI assistant finalize fallback update failed', persistError_1);
|
|
3251
|
-
return [3 /*break*/,
|
|
3252
|
-
case 97:
|
|
3253
|
-
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 101];
|
|
3254
|
-
_21.label = 98;
|
|
3257
|
+
return [3 /*break*/, 98];
|
|
3255
3258
|
case 98:
|
|
3256
|
-
|
|
3257
|
-
|
|
3259
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 102];
|
|
3260
|
+
_21.label = 99;
|
|
3258
3261
|
case 99:
|
|
3259
|
-
_21.
|
|
3260
|
-
return [
|
|
3262
|
+
_21.trys.push([99, 101, , 102]);
|
|
3263
|
+
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
3261
3264
|
case 100:
|
|
3262
|
-
|
|
3263
|
-
return [3 /*break*/,
|
|
3265
|
+
_21.sent();
|
|
3266
|
+
return [3 /*break*/, 102];
|
|
3264
3267
|
case 101:
|
|
3268
|
+
_f = _21.sent();
|
|
3269
|
+
return [3 /*break*/, 102];
|
|
3270
|
+
case 102:
|
|
3265
3271
|
console.error(new Date(), 'AI assistant run finalize failed:', finalizeError_1);
|
|
3266
3272
|
return [2 /*return*/, __assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: fallbackContent, metadata: failureMetadata, updatedAt: failedAt })];
|
|
3267
|
-
case
|
|
3273
|
+
case 103: return [2 /*return*/];
|
|
3268
3274
|
}
|
|
3269
3275
|
});
|
|
3270
3276
|
}); });
|
|
@@ -7010,6 +7016,18 @@ function extractAssistantDataIntentCustomerText(message) {
|
|
|
7010
7016
|
value = value.replace(/[^a-z0-9&.' -]+/gi, ' ');
|
|
7011
7017
|
return normalizeOptionalString(value.replace(/\s+/g, ' '));
|
|
7012
7018
|
}
|
|
7019
|
+
function doesAssistantDataIntentUseCustomerText(intent) {
|
|
7020
|
+
if (!Array.isArray(intent.pipeline) || !intent.pipeline.length) {
|
|
7021
|
+
return true;
|
|
7022
|
+
}
|
|
7023
|
+
var serialized = JSON.stringify([
|
|
7024
|
+
intent.pipeline,
|
|
7025
|
+
intent.acknowledgement,
|
|
7026
|
+
intent.progress,
|
|
7027
|
+
intent.dimensions
|
|
7028
|
+
]);
|
|
7029
|
+
return serialized.includes('{{customer}}');
|
|
7030
|
+
}
|
|
7013
7031
|
function resolveAssistantDataIntentDateWindow(message) {
|
|
7014
7032
|
var text = normalizeOptionalString(message).toLowerCase();
|
|
7015
7033
|
var now = new Date();
|
|
@@ -7045,22 +7063,37 @@ function resolveAssistantDataIntentDateWindow(message) {
|
|
|
7045
7063
|
var year_1 = Number(boundedEndMatch[3]) || now.getUTCFullYear();
|
|
7046
7064
|
var start = /\b(?:this|current)\s+month\b/.test(text)
|
|
7047
7065
|
? new Date(Date.UTC(year_1, endMonth, 1, 0, 0, 0, 0)).toISOString()
|
|
7048
|
-
:
|
|
7066
|
+
: /\b(?:this|current)\s+year\b|\bytd\b|\byear\s+to\s+date\b/.test(text)
|
|
7067
|
+
? new Date(Date.UTC(year_1, 0, 1, 0, 0, 0, 0)).toISOString()
|
|
7068
|
+
: undefined;
|
|
7049
7069
|
return {
|
|
7050
7070
|
start: start,
|
|
7051
7071
|
end: new Date(Date.UTC(year_1, endMonth, endDay, 23, 59, 59, 999)).toISOString(),
|
|
7052
7072
|
year: year_1
|
|
7053
7073
|
};
|
|
7054
7074
|
}
|
|
7075
|
+
var boundedEndMonthMatch = text.match(/\b(?:until|through|thru|to)\s+(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/);
|
|
7076
|
+
if (boundedEndMonthMatch) {
|
|
7077
|
+
var endMonth = monthNames[boundedEndMonthMatch[1]];
|
|
7078
|
+
var year_2 = Number(boundedEndMonthMatch[2]) || now.getUTCFullYear();
|
|
7079
|
+
var start = /\b(?:this|current)\s+year\b|\bytd\b|\byear\s+to\s+date\b/.test(text)
|
|
7080
|
+
? new Date(Date.UTC(year_2, 0, 1, 0, 0, 0, 0)).toISOString()
|
|
7081
|
+
: undefined;
|
|
7082
|
+
return {
|
|
7083
|
+
start: start,
|
|
7084
|
+
end: new Date(Date.UTC(year_2, endMonth + 1, 0, 23, 59, 59, 999)).toISOString(),
|
|
7085
|
+
year: year_2
|
|
7086
|
+
};
|
|
7087
|
+
}
|
|
7055
7088
|
var monthMatch = text.match(/\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/);
|
|
7056
7089
|
if (monthMatch) {
|
|
7057
7090
|
var month = monthNames[monthMatch[1]];
|
|
7058
|
-
var
|
|
7059
|
-
if (Number.isFinite(
|
|
7091
|
+
var year_3 = Number(monthMatch[2]);
|
|
7092
|
+
if (Number.isFinite(year_3) && month >= 0) {
|
|
7060
7093
|
return {
|
|
7061
|
-
start: new Date(Date.UTC(
|
|
7062
|
-
end: new Date(Date.UTC(
|
|
7063
|
-
year:
|
|
7094
|
+
start: new Date(Date.UTC(year_3, month, 1, 0, 0, 0, 0)).toISOString(),
|
|
7095
|
+
end: new Date(Date.UTC(year_3, month + 1, 0, 23, 59, 59, 999)).toISOString(),
|
|
7096
|
+
year: year_3
|
|
7064
7097
|
};
|
|
7065
7098
|
}
|
|
7066
7099
|
}
|
|
@@ -7608,6 +7641,17 @@ function normalizeAssistantDataRequestContract(value, intent, dateWindow, source
|
|
|
7608
7641
|
source: source
|
|
7609
7642
|
};
|
|
7610
7643
|
}
|
|
7644
|
+
function normalizeAssistantBreakdownCandidateKey(value) {
|
|
7645
|
+
return cleanAssistantRequestedDimensionText(value).replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
7646
|
+
}
|
|
7647
|
+
function resolveAssistantBreakdownCandidateKey(text, breakdown) {
|
|
7648
|
+
var granularity = normalizeAssistantBreakdownCandidateKey((breakdown === null || breakdown === void 0 ? void 0 : breakdown.granularity) || resolveAssistantTimeBreakdownGranularity(text));
|
|
7649
|
+
if (granularity) {
|
|
7650
|
+
return "time:".concat(granularity);
|
|
7651
|
+
}
|
|
7652
|
+
var dimension = normalizeAssistantBreakdownCandidateKey((breakdown === null || breakdown === void 0 ? void 0 : breakdown.dimension) || text);
|
|
7653
|
+
return dimension ? "entity:".concat(dimension) : '';
|
|
7654
|
+
}
|
|
7611
7655
|
function buildAssistantRequestedBreakdownCandidates(message, classifierContract) {
|
|
7612
7656
|
var candidates = [];
|
|
7613
7657
|
var seen = new Set();
|
|
@@ -7616,12 +7660,7 @@ function buildAssistantRequestedBreakdownCandidates(message, classifierContract)
|
|
|
7616
7660
|
if (!normalized) {
|
|
7617
7661
|
return;
|
|
7618
7662
|
}
|
|
7619
|
-
var key =
|
|
7620
|
-
(breakdown === null || breakdown === void 0 ? void 0 : breakdown.type) || '',
|
|
7621
|
-
(breakdown === null || breakdown === void 0 ? void 0 : breakdown.granularity) || '',
|
|
7622
|
-
(breakdown === null || breakdown === void 0 ? void 0 : breakdown.dimension) || '',
|
|
7623
|
-
normalized
|
|
7624
|
-
].join(':');
|
|
7663
|
+
var key = resolveAssistantBreakdownCandidateKey(normalized, breakdown);
|
|
7625
7664
|
if (seen.has(key)) {
|
|
7626
7665
|
return;
|
|
7627
7666
|
}
|
|
@@ -7653,6 +7692,13 @@ function buildAssistantDataRequestClassifierCandidatePayload(candidate) {
|
|
|
7653
7692
|
granularity: dimension.granularity || undefined,
|
|
7654
7693
|
terms: (dimension.terms || []).slice(0, 12),
|
|
7655
7694
|
field_hints: extractAssistantDataIntentExpressionFieldHints(dimension.groupId).slice(0, 8)
|
|
7695
|
+
}); }),
|
|
7696
|
+
filter_fields: buildAssistantAppDataFilterCandidates(intent).map(function (filterField) { return ({
|
|
7697
|
+
id: filterField.id,
|
|
7698
|
+
terms: filterField.terms.slice(0, 12),
|
|
7699
|
+
fields: filterField.fields.slice(0, 8),
|
|
7700
|
+
type: filterField.type || undefined,
|
|
7701
|
+
operators: filterField.operators.slice(0, 8)
|
|
7656
7702
|
}); })
|
|
7657
7703
|
};
|
|
7658
7704
|
}
|
|
@@ -7663,9 +7709,10 @@ function buildAssistantDataRequestClassifierMessages(params) {
|
|
|
7663
7709
|
'Do not create MongoDB pipelines, queries, field paths, or collections.',
|
|
7664
7710
|
'Preserve every explicit grouping phrase: "by month by chemical" must produce two requested_breakdowns, one for month and one for chemical.',
|
|
7665
7711
|
'Interpret "by", "per", "break down by", and "group by" as requested_breakdowns.',
|
|
7666
|
-
'Interpret date phrases like "this month", "last month", "until June 12", and "last 6 months" as date_range or filters when clear.',
|
|
7712
|
+
'Interpret date phrases like "this month", "last month", "until June 12", "through May", "past 30 days", and "last 6 months" as date_range or filters when clear.',
|
|
7667
7713
|
'For time breakdowns, set type="time" and granularity to one of year, quarter, month, week, day, date.',
|
|
7668
7714
|
'For configured dimensions, set type="entity" and dimension to the candidate dimension id.',
|
|
7715
|
+
'For filters, use only candidate filter_fields or configured dimension ids; include field/value/operator but do not invent fields.',
|
|
7669
7716
|
'If unsure, include an ambiguity instead of guessing.',
|
|
7670
7717
|
'Always set output_format to "collapse_table".',
|
|
7671
7718
|
'Return JSON only with keys: intent_id, domain, collection, operation, requested_breakdowns, date_range, measures, filters, output_format, ambiguities, confidence.'
|
|
@@ -7716,7 +7763,7 @@ function resolveAssistantDataRequestClassifierTimeoutMs(config) {
|
|
|
7716
7763
|
if (raw && raw > 0) {
|
|
7717
7764
|
return Math.max(250, Math.min((0, common_1.round)(raw), 5000));
|
|
7718
7765
|
}
|
|
7719
|
-
return
|
|
7766
|
+
return 500;
|
|
7720
7767
|
}
|
|
7721
7768
|
function resolveAssistantDataRequestClassifierMaxTokens() {
|
|
7722
7769
|
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
@@ -7875,13 +7922,11 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, cla
|
|
|
7875
7922
|
var addDimension = function (dimension) {
|
|
7876
7923
|
var id = normalizeOptionalString(dimension.id);
|
|
7877
7924
|
if (!id || seenDimensionIds.has(id)) {
|
|
7878
|
-
return;
|
|
7879
|
-
}
|
|
7880
|
-
if ((dimension.type || '') === 'time' && dimensions.some(function (entry) { return (entry.type || '') === 'time'; })) {
|
|
7881
|
-
return;
|
|
7925
|
+
return false;
|
|
7882
7926
|
}
|
|
7883
7927
|
seenDimensionIds.add(id);
|
|
7884
7928
|
dimensions.push(dimension);
|
|
7929
|
+
return true;
|
|
7885
7930
|
};
|
|
7886
7931
|
requestedBreakdownCandidates.forEach(function (candidate) {
|
|
7887
7932
|
var _a;
|
|
@@ -7924,6 +7969,9 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, cla
|
|
|
7924
7969
|
}
|
|
7925
7970
|
});
|
|
7926
7971
|
if (selected) {
|
|
7972
|
+
if (!selected.dimension.groupId) {
|
|
7973
|
+
ambiguities.push("Requested ".concat(requestedDimensionText, " breakdown matched ").concat(selected.dimension.id, ", but the app dimension has no group expression."));
|
|
7974
|
+
}
|
|
7927
7975
|
var dimension = __assign(__assign({}, selected.dimension), { type: selected.dimension.type || 'entity', requestedText: requestedDimensionText });
|
|
7928
7976
|
addDimension(dimension);
|
|
7929
7977
|
requestedBreakdowns.push({
|
|
@@ -7964,12 +8012,518 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, cla
|
|
|
7964
8012
|
}
|
|
7965
8013
|
};
|
|
7966
8014
|
}
|
|
8015
|
+
function inferAssistantDateWindowYear(value) {
|
|
8016
|
+
var e_6, _a;
|
|
8017
|
+
if (!value) {
|
|
8018
|
+
return undefined;
|
|
8019
|
+
}
|
|
8020
|
+
if (value.year) {
|
|
8021
|
+
return value.year;
|
|
8022
|
+
}
|
|
8023
|
+
try {
|
|
8024
|
+
for (var _b = __values([value.start, value.end]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8025
|
+
var dateValue = _c.value;
|
|
8026
|
+
var parsed = new Date(normalizeOptionalString(dateValue));
|
|
8027
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
8028
|
+
return parsed.getUTCFullYear();
|
|
8029
|
+
}
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8033
|
+
finally {
|
|
8034
|
+
try {
|
|
8035
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8036
|
+
}
|
|
8037
|
+
finally { if (e_6) throw e_6.error; }
|
|
8038
|
+
}
|
|
8039
|
+
return undefined;
|
|
8040
|
+
}
|
|
8041
|
+
function resolveAssistantEffectiveDataIntentDateWindow(baseDateWindow, requestUnderstanding) {
|
|
8042
|
+
var _a;
|
|
8043
|
+
var contractDateRange = normalizeAssistantContractDateRange((_a = requestUnderstanding === null || requestUnderstanding === void 0 ? void 0 : requestUnderstanding.contract) === null || _a === void 0 ? void 0 : _a.date_range);
|
|
8044
|
+
if (!contractDateRange) {
|
|
8045
|
+
return baseDateWindow;
|
|
8046
|
+
}
|
|
8047
|
+
var effective = __assign(__assign({}, baseDateWindow), contractDateRange);
|
|
8048
|
+
var year = inferAssistantDateWindowYear(effective);
|
|
8049
|
+
if (year) {
|
|
8050
|
+
effective.year = year;
|
|
8051
|
+
}
|
|
8052
|
+
return effective;
|
|
8053
|
+
}
|
|
7967
8054
|
function extractAssistantDataIntentGroupKeys(groupId) {
|
|
7968
8055
|
if (!groupId || typeof groupId !== 'object' || Array.isArray(groupId)) {
|
|
7969
8056
|
return [];
|
|
7970
8057
|
}
|
|
7971
8058
|
return Object.keys(groupId).filter(Boolean);
|
|
7972
8059
|
}
|
|
8060
|
+
function normalizeAssistantGroupKeyForComparison(value) {
|
|
8061
|
+
return cleanAssistantRequestedDimensionText(value).replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
8062
|
+
}
|
|
8063
|
+
function resolveAssistantBreakdownAppliedToGroup(breakdown, groupKeys) {
|
|
8064
|
+
if (!breakdown || breakdown.type === 'unknown') {
|
|
8065
|
+
return true;
|
|
8066
|
+
}
|
|
8067
|
+
var candidates = __spreadArray([
|
|
8068
|
+
breakdown.dimension,
|
|
8069
|
+
breakdown.granularity,
|
|
8070
|
+
breakdown.requested_text,
|
|
8071
|
+
breakdown.field_hint
|
|
8072
|
+
], __read((breakdown.field_hints || [])), false).map(function (value) { return normalizeAssistantGroupKeyForComparison(normalizeOptionalString(value)); })
|
|
8073
|
+
.filter(Boolean);
|
|
8074
|
+
return candidates.some(function (candidate) { return groupKeys.has(candidate); });
|
|
8075
|
+
}
|
|
8076
|
+
function resolveAssistantDroppedBreakdownAmbiguities(requestContract, pipeline) {
|
|
8077
|
+
var _a;
|
|
8078
|
+
var requestedBreakdowns = Array.isArray(requestContract === null || requestContract === void 0 ? void 0 : requestContract.requested_breakdowns)
|
|
8079
|
+
? requestContract.requested_breakdowns
|
|
8080
|
+
: [];
|
|
8081
|
+
if (!requestedBreakdowns.length) {
|
|
8082
|
+
return [];
|
|
8083
|
+
}
|
|
8084
|
+
var groupStage = (_a = (Array.isArray(pipeline) ? pipeline : []).find(function (stage) { return !!(stage === null || stage === void 0 ? void 0 : stage.$group); })) === null || _a === void 0 ? void 0 : _a.$group;
|
|
8085
|
+
var groupKeys = new Set(extractAssistantDataIntentGroupKeys(groupStage === null || groupStage === void 0 ? void 0 : groupStage._id)
|
|
8086
|
+
.map(function (key) { return normalizeAssistantGroupKeyForComparison(key); })
|
|
8087
|
+
.filter(Boolean));
|
|
8088
|
+
return requestedBreakdowns
|
|
8089
|
+
.filter(function (breakdown) { return !resolveAssistantBreakdownAppliedToGroup(breakdown, groupKeys); })
|
|
8090
|
+
.map(function (breakdown) {
|
|
8091
|
+
var label = formatAssistantRequestBreakdownLabel(breakdown) || breakdown.requested_text || 'requested';
|
|
8092
|
+
return "Requested ".concat(label, " breakdown was not applied to the final aggregate group.");
|
|
8093
|
+
});
|
|
8094
|
+
}
|
|
8095
|
+
function buildAssistantAppDataFilterCandidates(intent) {
|
|
8096
|
+
var candidates = [];
|
|
8097
|
+
var seen = new Set();
|
|
8098
|
+
var add = function (candidate) {
|
|
8099
|
+
var id = normalizeOptionalString(candidate.id);
|
|
8100
|
+
var fields = mergeAssistantHintValues(candidate.fields || [])
|
|
8101
|
+
.map(function (field) { return normalizeLookupPath(field); })
|
|
8102
|
+
.filter(function (field) { return !!field && isAssistantProjectionKeyAllowed(field); });
|
|
8103
|
+
if (!id || !fields.length) {
|
|
8104
|
+
return;
|
|
8105
|
+
}
|
|
8106
|
+
var key = "".concat(cleanAssistantRequestedDimensionText(id), ":").concat(fields.join('|'));
|
|
8107
|
+
if (seen.has(key)) {
|
|
8108
|
+
return;
|
|
8109
|
+
}
|
|
8110
|
+
seen.add(key);
|
|
8111
|
+
candidates.push({
|
|
8112
|
+
id: id,
|
|
8113
|
+
terms: mergeAssistantHintValues(__spreadArray([id], __read((candidate.terms || [])), false)).map(function (term) { return term.toLowerCase(); }),
|
|
8114
|
+
fields: fields,
|
|
8115
|
+
type: candidate.type || 'string',
|
|
8116
|
+
operators: mergeAssistantHintValues(candidate.operators || ['eq', 'contains', 'in']).map(function (operator) { return operator.toLowerCase(); })
|
|
8117
|
+
});
|
|
8118
|
+
};
|
|
8119
|
+
(intent.filterFields || []).forEach(add);
|
|
8120
|
+
(intent.dimensions || []).forEach(function (dimension) {
|
|
8121
|
+
if ((dimension.type || 'entity') === 'time') {
|
|
8122
|
+
return;
|
|
8123
|
+
}
|
|
8124
|
+
var fields = extractAssistantDataIntentExpressionFieldHints(dimension.groupId)
|
|
8125
|
+
.filter(function (field) { return isAssistantProjectionKeyAllowed(field); });
|
|
8126
|
+
if (!fields.length) {
|
|
8127
|
+
return;
|
|
8128
|
+
}
|
|
8129
|
+
add({
|
|
8130
|
+
id: dimension.id,
|
|
8131
|
+
terms: dimension.terms || [],
|
|
8132
|
+
fields: fields,
|
|
8133
|
+
type: 'string',
|
|
8134
|
+
operators: ['eq', 'contains', 'in']
|
|
8135
|
+
});
|
|
8136
|
+
});
|
|
8137
|
+
[
|
|
8138
|
+
{ id: 'quantity', field: intent.quantityField, type: 'number' },
|
|
8139
|
+
{ id: 'metric', field: intent.metricField, type: 'number' }
|
|
8140
|
+
].forEach(function (entry) {
|
|
8141
|
+
var field = normalizeOptionalString(entry.field);
|
|
8142
|
+
if (!field) {
|
|
8143
|
+
return;
|
|
8144
|
+
}
|
|
8145
|
+
add({
|
|
8146
|
+
id: field.split('.').pop() || entry.id,
|
|
8147
|
+
terms: [entry.id, field],
|
|
8148
|
+
fields: [field],
|
|
8149
|
+
type: entry.type,
|
|
8150
|
+
operators: ['eq', 'gt', 'gte', 'lt', 'lte']
|
|
8151
|
+
});
|
|
8152
|
+
});
|
|
8153
|
+
return candidates;
|
|
8154
|
+
}
|
|
8155
|
+
function normalizeAssistantContractFilterToken(value) {
|
|
8156
|
+
return normalizeOptionalString(value).toLowerCase().replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
8157
|
+
}
|
|
8158
|
+
function normalizeAssistantContractFilterOperator(value) {
|
|
8159
|
+
var normalized = normalizeOptionalString(value).toLowerCase().replace(/[^a-z0-9_$]+/g, '');
|
|
8160
|
+
if (normalized === '$eq' || normalized === 'equals' || normalized === 'is') {
|
|
8161
|
+
return 'eq';
|
|
8162
|
+
}
|
|
8163
|
+
if (normalized === '$in' || normalized === 'oneof' || normalized === 'anyof') {
|
|
8164
|
+
return 'in';
|
|
8165
|
+
}
|
|
8166
|
+
if (normalized === '$regex' || normalized === 'like' || normalized === 'contains') {
|
|
8167
|
+
return 'contains';
|
|
8168
|
+
}
|
|
8169
|
+
if (normalized === '$gt' || normalized === 'after' || normalized === 'greaterthan') {
|
|
8170
|
+
return 'gt';
|
|
8171
|
+
}
|
|
8172
|
+
if (normalized === '$gte' || normalized === 'onorafter' || normalized === 'greaterthanorequal') {
|
|
8173
|
+
return 'gte';
|
|
8174
|
+
}
|
|
8175
|
+
if (normalized === '$lt' || normalized === 'before' || normalized === 'lessthan') {
|
|
8176
|
+
return 'lt';
|
|
8177
|
+
}
|
|
8178
|
+
if (normalized === '$lte' || normalized === 'onorbefore' || normalized === 'lessthanorequal') {
|
|
8179
|
+
return 'lte';
|
|
8180
|
+
}
|
|
8181
|
+
return normalized || 'eq';
|
|
8182
|
+
}
|
|
8183
|
+
function extractAssistantFilterObjectValue(value) {
|
|
8184
|
+
var e_7, _a;
|
|
8185
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || value instanceof Date) {
|
|
8186
|
+
return {
|
|
8187
|
+
operator: 'eq',
|
|
8188
|
+
values: Array.isArray(value) ? value : [value]
|
|
8189
|
+
};
|
|
8190
|
+
}
|
|
8191
|
+
var operatorKeys = ['$eq', 'eq', 'equals', 'value', '$in', 'in', 'values', '$regex', 'contains', '$gt', 'gt', '$gte', 'gte', '$lt', 'lt', '$lte', 'lte'];
|
|
8192
|
+
try {
|
|
8193
|
+
for (var operatorKeys_1 = __values(operatorKeys), operatorKeys_1_1 = operatorKeys_1.next(); !operatorKeys_1_1.done; operatorKeys_1_1 = operatorKeys_1.next()) {
|
|
8194
|
+
var key = operatorKeys_1_1.value;
|
|
8195
|
+
if (!Object.prototype.hasOwnProperty.call(value, key)) {
|
|
8196
|
+
continue;
|
|
8197
|
+
}
|
|
8198
|
+
var rawValue = value[key];
|
|
8199
|
+
var operator = key === 'value' || key === 'values'
|
|
8200
|
+
? (key === 'values' ? 'in' : 'eq')
|
|
8201
|
+
: normalizeAssistantContractFilterOperator(key);
|
|
8202
|
+
return {
|
|
8203
|
+
operator: operator,
|
|
8204
|
+
values: Array.isArray(rawValue) ? rawValue : [rawValue]
|
|
8205
|
+
};
|
|
8206
|
+
}
|
|
8207
|
+
}
|
|
8208
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8209
|
+
finally {
|
|
8210
|
+
try {
|
|
8211
|
+
if (operatorKeys_1_1 && !operatorKeys_1_1.done && (_a = operatorKeys_1.return)) _a.call(operatorKeys_1);
|
|
8212
|
+
}
|
|
8213
|
+
finally { if (e_7) throw e_7.error; }
|
|
8214
|
+
}
|
|
8215
|
+
return {
|
|
8216
|
+
operator: 'eq',
|
|
8217
|
+
values: [value]
|
|
8218
|
+
};
|
|
8219
|
+
}
|
|
8220
|
+
function resolveAssistantContractFilterSpec(filter) {
|
|
8221
|
+
if (!filter || typeof filter !== 'object' || Array.isArray(filter)) {
|
|
8222
|
+
return null;
|
|
8223
|
+
}
|
|
8224
|
+
var field = normalizeOptionalString(filter.field
|
|
8225
|
+
|| filter.field_hint
|
|
8226
|
+
|| filter.fieldHint
|
|
8227
|
+
|| filter.dimension
|
|
8228
|
+
|| filter.key
|
|
8229
|
+
|| filter.name);
|
|
8230
|
+
var operator = normalizeAssistantContractFilterOperator(filter.operator || filter.op || '');
|
|
8231
|
+
var rawValues = [];
|
|
8232
|
+
if (Object.prototype.hasOwnProperty.call(filter, 'value')) {
|
|
8233
|
+
rawValues = Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
8234
|
+
}
|
|
8235
|
+
else if (Object.prototype.hasOwnProperty.call(filter, 'values')) {
|
|
8236
|
+
operator = operator === 'eq' ? 'in' : operator;
|
|
8237
|
+
rawValues = Array.isArray(filter.values) ? filter.values : [filter.values];
|
|
8238
|
+
}
|
|
8239
|
+
if (!field) {
|
|
8240
|
+
var reserved_1 = new Set(['field', 'field_hint', 'fieldHint', 'field_hints', 'fieldHints', 'dimension', 'key', 'name', 'operator', 'op', 'value', 'values']);
|
|
8241
|
+
var entries = Object.keys(filter).filter(function (key) { return !reserved_1.has(key) && !normalizeOptionalString(key).startsWith('$'); });
|
|
8242
|
+
if (entries.length !== 1) {
|
|
8243
|
+
return null;
|
|
8244
|
+
}
|
|
8245
|
+
field = entries[0];
|
|
8246
|
+
var extracted = extractAssistantFilterObjectValue(filter[field]);
|
|
8247
|
+
operator = extracted.operator;
|
|
8248
|
+
rawValues = extracted.values;
|
|
8249
|
+
}
|
|
8250
|
+
var values = rawValues
|
|
8251
|
+
.filter(function (value) { return value !== undefined && value !== null; })
|
|
8252
|
+
.slice(0, 12);
|
|
8253
|
+
if (!field || !values.length) {
|
|
8254
|
+
return null;
|
|
8255
|
+
}
|
|
8256
|
+
return {
|
|
8257
|
+
field: field,
|
|
8258
|
+
operator: operator,
|
|
8259
|
+
values: values,
|
|
8260
|
+
raw: filter
|
|
8261
|
+
};
|
|
8262
|
+
}
|
|
8263
|
+
function buildAssistantContractFilterSpecKey(spec) {
|
|
8264
|
+
return __spreadArray([
|
|
8265
|
+
normalizeAssistantContractFilterToken(spec.field),
|
|
8266
|
+
normalizeAssistantContractFilterOperator(spec.operator)
|
|
8267
|
+
], __read(spec.values.map(function (value) { return normalizeAssistantContractFilterToken(value && typeof value === 'object' ? JSON.stringify(value) : value); })), false).filter(Boolean).join(':');
|
|
8268
|
+
}
|
|
8269
|
+
function resolveAssistantContractFilterKey(filter) {
|
|
8270
|
+
var spec = resolveAssistantContractFilterSpec(filter);
|
|
8271
|
+
return spec ? buildAssistantContractFilterSpecKey(spec) : normalizeAssistantContractFilterToken(formatAssistantContractFilterLabel(filter));
|
|
8272
|
+
}
|
|
8273
|
+
function collectAssistantContractFilterTokens(value, tokens) {
|
|
8274
|
+
if (tokens === void 0) { tokens = []; }
|
|
8275
|
+
if (value === undefined || value === null) {
|
|
8276
|
+
return tokens;
|
|
8277
|
+
}
|
|
8278
|
+
if (Array.isArray(value)) {
|
|
8279
|
+
value.forEach(function (entry) { return collectAssistantContractFilterTokens(entry, tokens); });
|
|
8280
|
+
return tokens;
|
|
8281
|
+
}
|
|
8282
|
+
if (value && typeof value === 'object') {
|
|
8283
|
+
Object.keys(value).forEach(function (key) {
|
|
8284
|
+
var normalizedKey = normalizeAssistantContractFilterToken(key);
|
|
8285
|
+
if (normalizedKey && !normalizedKey.startsWith('$') && !tokens.includes(normalizedKey)) {
|
|
8286
|
+
tokens.push(normalizedKey);
|
|
8287
|
+
}
|
|
8288
|
+
collectAssistantContractFilterTokens(value[key], tokens);
|
|
8289
|
+
});
|
|
8290
|
+
return tokens;
|
|
8291
|
+
}
|
|
8292
|
+
var normalizedValue = normalizeAssistantContractFilterToken(value);
|
|
8293
|
+
if (normalizedValue && !tokens.includes(normalizedValue)) {
|
|
8294
|
+
tokens.push(normalizedValue);
|
|
8295
|
+
}
|
|
8296
|
+
return tokens;
|
|
8297
|
+
}
|
|
8298
|
+
function formatAssistantContractFilterLabel(filter) {
|
|
8299
|
+
var labels = Object.keys(filter || {})
|
|
8300
|
+
.map(function (key) {
|
|
8301
|
+
var normalizedKey = normalizeAssistantContractFilterToken(key);
|
|
8302
|
+
var value = filter[key];
|
|
8303
|
+
var normalizedValue = value && typeof value === 'object'
|
|
8304
|
+
? normalizeAssistantContractFilterToken(JSON.stringify(value))
|
|
8305
|
+
: normalizeAssistantContractFilterToken(value);
|
|
8306
|
+
if (!normalizedKey) {
|
|
8307
|
+
return '';
|
|
8308
|
+
}
|
|
8309
|
+
return normalizedValue ? "".concat(normalizedKey, "=").concat(normalizedValue) : normalizedKey;
|
|
8310
|
+
})
|
|
8311
|
+
.filter(Boolean);
|
|
8312
|
+
return labels.length ? labels.join(', ') : 'requested';
|
|
8313
|
+
}
|
|
8314
|
+
function scoreAssistantFilterCandidate(spec, candidate) {
|
|
8315
|
+
var requested = cleanAssistantRequestedDimensionText(spec.field);
|
|
8316
|
+
if (!requested) {
|
|
8317
|
+
return 0;
|
|
8318
|
+
}
|
|
8319
|
+
var score = 0;
|
|
8320
|
+
var candidateId = cleanAssistantRequestedDimensionText(candidate.id);
|
|
8321
|
+
if (requested === candidateId) {
|
|
8322
|
+
score += 10;
|
|
8323
|
+
}
|
|
8324
|
+
else if (candidateId && containsAssistantHeuristicTerm(requested, candidateId)) {
|
|
8325
|
+
score += 4;
|
|
8326
|
+
}
|
|
8327
|
+
(candidate.terms || []).forEach(function (term) {
|
|
8328
|
+
var normalizedTerm = cleanAssistantRequestedDimensionText(term);
|
|
8329
|
+
if (!normalizedTerm) {
|
|
8330
|
+
return;
|
|
8331
|
+
}
|
|
8332
|
+
if (requested === normalizedTerm) {
|
|
8333
|
+
score += normalizedTerm.includes(' ') ? 8 : 6;
|
|
8334
|
+
}
|
|
8335
|
+
else if (containsAssistantHeuristicTerm(requested, normalizedTerm)) {
|
|
8336
|
+
score += normalizedTerm.includes(' ') ? 4 : 2;
|
|
8337
|
+
}
|
|
8338
|
+
});
|
|
8339
|
+
(candidate.fields || []).forEach(function (field) {
|
|
8340
|
+
var normalizedField = cleanAssistantRequestedDimensionText(field);
|
|
8341
|
+
var leaf = cleanAssistantRequestedDimensionText(field.split('.').pop() || field);
|
|
8342
|
+
if (requested === normalizedField || requested === leaf) {
|
|
8343
|
+
score += 7;
|
|
8344
|
+
}
|
|
8345
|
+
});
|
|
8346
|
+
return score;
|
|
8347
|
+
}
|
|
8348
|
+
function resolveAssistantFilterCandidate(spec, intent) {
|
|
8349
|
+
var selected = null;
|
|
8350
|
+
buildAssistantAppDataFilterCandidates(intent).forEach(function (candidate) {
|
|
8351
|
+
var score = scoreAssistantFilterCandidate(spec, candidate);
|
|
8352
|
+
if (score <= 0) {
|
|
8353
|
+
return;
|
|
8354
|
+
}
|
|
8355
|
+
if (!selected || score > selected.score) {
|
|
8356
|
+
selected = { candidate: candidate, score: score };
|
|
8357
|
+
}
|
|
8358
|
+
});
|
|
8359
|
+
return (selected === null || selected === void 0 ? void 0 : selected.candidate) || null;
|
|
8360
|
+
}
|
|
8361
|
+
function coerceAssistantFilterValue(value, type) {
|
|
8362
|
+
if (type === 'number') {
|
|
8363
|
+
var numberValue = Number(value);
|
|
8364
|
+
return Number.isFinite(numberValue) ? numberValue : undefined;
|
|
8365
|
+
}
|
|
8366
|
+
if (type === 'boolean') {
|
|
8367
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
8368
|
+
if (['true', 'yes', 'active', '1'].includes(normalized)) {
|
|
8369
|
+
return true;
|
|
8370
|
+
}
|
|
8371
|
+
if (['false', 'no', 'inactive', '0'].includes(normalized)) {
|
|
8372
|
+
return false;
|
|
8373
|
+
}
|
|
8374
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
8375
|
+
}
|
|
8376
|
+
if (type === 'date') {
|
|
8377
|
+
var date = value instanceof Date ? value : new Date(normalizeOptionalString(value));
|
|
8378
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
8379
|
+
}
|
|
8380
|
+
var text = normalizeOptionalString(value);
|
|
8381
|
+
return text ? text.slice(0, 160) : undefined;
|
|
8382
|
+
}
|
|
8383
|
+
function buildAssistantFieldFilterCondition(value, operator, type) {
|
|
8384
|
+
var normalizedOperator = normalizeAssistantContractFilterOperator(operator);
|
|
8385
|
+
var coerced = coerceAssistantFilterValue(value, type);
|
|
8386
|
+
if (coerced === undefined) {
|
|
8387
|
+
return undefined;
|
|
8388
|
+
}
|
|
8389
|
+
if (type === 'number' || type === 'date') {
|
|
8390
|
+
if (normalizedOperator === 'gt') {
|
|
8391
|
+
return { $gt: coerced };
|
|
8392
|
+
}
|
|
8393
|
+
if (normalizedOperator === 'gte') {
|
|
8394
|
+
return { $gte: coerced };
|
|
8395
|
+
}
|
|
8396
|
+
if (normalizedOperator === 'lt') {
|
|
8397
|
+
return { $lt: coerced };
|
|
8398
|
+
}
|
|
8399
|
+
if (normalizedOperator === 'lte') {
|
|
8400
|
+
return { $lte: coerced };
|
|
8401
|
+
}
|
|
8402
|
+
return coerced;
|
|
8403
|
+
}
|
|
8404
|
+
if (type === 'boolean') {
|
|
8405
|
+
return coerced;
|
|
8406
|
+
}
|
|
8407
|
+
var escaped = escapeRegexValue(String(coerced));
|
|
8408
|
+
if (!escaped) {
|
|
8409
|
+
return undefined;
|
|
8410
|
+
}
|
|
8411
|
+
return { $regex: escaped, $options: 'i' };
|
|
8412
|
+
}
|
|
8413
|
+
function buildAssistantContractFilterClause(spec, candidate) {
|
|
8414
|
+
var operator = normalizeAssistantContractFilterOperator(spec.operator);
|
|
8415
|
+
if (candidate.operators.length && !candidate.operators.includes(operator)) {
|
|
8416
|
+
return null;
|
|
8417
|
+
}
|
|
8418
|
+
var fields = (candidate.fields || []).filter(function (field) { return isAssistantProjectionKeyAllowed(field); });
|
|
8419
|
+
if (!fields.length) {
|
|
8420
|
+
return null;
|
|
8421
|
+
}
|
|
8422
|
+
var clauses = [];
|
|
8423
|
+
fields.forEach(function (field) {
|
|
8424
|
+
spec.values.forEach(function (value) {
|
|
8425
|
+
var _a;
|
|
8426
|
+
var condition = buildAssistantFieldFilterCondition(value, operator === 'in' ? 'eq' : operator, candidate.type);
|
|
8427
|
+
if (condition !== undefined) {
|
|
8428
|
+
clauses.push((_a = {}, _a[field] = condition, _a));
|
|
8429
|
+
}
|
|
8430
|
+
});
|
|
8431
|
+
});
|
|
8432
|
+
if (!clauses.length) {
|
|
8433
|
+
return null;
|
|
8434
|
+
}
|
|
8435
|
+
if (clauses.length === 1) {
|
|
8436
|
+
return clauses[0];
|
|
8437
|
+
}
|
|
8438
|
+
return { $or: clauses };
|
|
8439
|
+
}
|
|
8440
|
+
function mergeAssistantMatchClauses(existingMatch, clauses) {
|
|
8441
|
+
var cleanClauses = clauses.filter(function (clause) { return clause && typeof clause === 'object' && Object.keys(clause).length; });
|
|
8442
|
+
if (!cleanClauses.length) {
|
|
8443
|
+
return existingMatch;
|
|
8444
|
+
}
|
|
8445
|
+
var existingKeys = Object.keys(existingMatch || {});
|
|
8446
|
+
if (!existingKeys.length) {
|
|
8447
|
+
return cleanClauses.length === 1 ? cleanClauses[0] : { $and: cleanClauses };
|
|
8448
|
+
}
|
|
8449
|
+
return {
|
|
8450
|
+
$and: __spreadArray([
|
|
8451
|
+
(0, common_1.deepCopy)(existingMatch)
|
|
8452
|
+
], __read(cleanClauses), false)
|
|
8453
|
+
};
|
|
8454
|
+
}
|
|
8455
|
+
function applyAssistantDataIntentContractFiltersToPipeline(pipeline, intent, requestContract) {
|
|
8456
|
+
var _a;
|
|
8457
|
+
var filters = Array.isArray(requestContract === null || requestContract === void 0 ? void 0 : requestContract.filters) ? requestContract.filters : [];
|
|
8458
|
+
if (!filters.length || !Array.isArray(pipeline) || !pipeline.length) {
|
|
8459
|
+
return { pipeline: pipeline, appliedFilterKeys: [] };
|
|
8460
|
+
}
|
|
8461
|
+
var clauses = [];
|
|
8462
|
+
var appliedFilterKeys = [];
|
|
8463
|
+
filters.forEach(function (filter) {
|
|
8464
|
+
var spec = resolveAssistantContractFilterSpec(filter);
|
|
8465
|
+
if (!spec) {
|
|
8466
|
+
return;
|
|
8467
|
+
}
|
|
8468
|
+
var candidate = resolveAssistantFilterCandidate(spec, intent);
|
|
8469
|
+
if (!candidate) {
|
|
8470
|
+
return;
|
|
8471
|
+
}
|
|
8472
|
+
var clause = buildAssistantContractFilterClause(spec, candidate);
|
|
8473
|
+
if (!clause) {
|
|
8474
|
+
return;
|
|
8475
|
+
}
|
|
8476
|
+
clauses.push(clause);
|
|
8477
|
+
appliedFilterKeys.push(buildAssistantContractFilterSpecKey(spec));
|
|
8478
|
+
});
|
|
8479
|
+
if (!clauses.length) {
|
|
8480
|
+
return { pipeline: pipeline, appliedFilterKeys: [] };
|
|
8481
|
+
}
|
|
8482
|
+
var next = (0, common_1.deepCopy)(pipeline);
|
|
8483
|
+
var groupIndex = findAggregateGroupIndex(next);
|
|
8484
|
+
var preGroupLimit = groupIndex > -1 ? groupIndex : next.length;
|
|
8485
|
+
var matchIndex = -1;
|
|
8486
|
+
for (var index = 0; index < preGroupLimit; index += 1) {
|
|
8487
|
+
if (((_a = next[index]) === null || _a === void 0 ? void 0 : _a.$match) && typeof next[index].$match === 'object') {
|
|
8488
|
+
matchIndex = index;
|
|
8489
|
+
}
|
|
8490
|
+
}
|
|
8491
|
+
if (matchIndex > -1) {
|
|
8492
|
+
next[matchIndex].$match = mergeAssistantMatchClauses(next[matchIndex].$match, clauses);
|
|
8493
|
+
}
|
|
8494
|
+
else {
|
|
8495
|
+
var insertIndex = groupIndex > -1 ? groupIndex : 0;
|
|
8496
|
+
next.splice(insertIndex, 0, {
|
|
8497
|
+
$match: clauses.length === 1 ? clauses[0] : { $and: clauses }
|
|
8498
|
+
});
|
|
8499
|
+
}
|
|
8500
|
+
return { pipeline: next, appliedFilterKeys: appliedFilterKeys };
|
|
8501
|
+
}
|
|
8502
|
+
function resolveAssistantDroppedFilterAmbiguities(requestContract, pipeline, appliedFilterKeys) {
|
|
8503
|
+
if (appliedFilterKeys === void 0) { appliedFilterKeys = []; }
|
|
8504
|
+
var filters = Array.isArray(requestContract === null || requestContract === void 0 ? void 0 : requestContract.filters)
|
|
8505
|
+
? requestContract.filters
|
|
8506
|
+
: [];
|
|
8507
|
+
if (!filters.length) {
|
|
8508
|
+
return [];
|
|
8509
|
+
}
|
|
8510
|
+
var pipelineText = normalizeAssistantContractFilterToken(JSON.stringify(pipeline || []));
|
|
8511
|
+
var applied = new Set(appliedFilterKeys.map(function (key) { return normalizeAssistantContractFilterToken(key); }).filter(Boolean));
|
|
8512
|
+
return filters
|
|
8513
|
+
.filter(function (filter) {
|
|
8514
|
+
var filterKey = normalizeAssistantContractFilterToken(resolveAssistantContractFilterKey(filter));
|
|
8515
|
+
if (filterKey && applied.has(filterKey)) {
|
|
8516
|
+
return false;
|
|
8517
|
+
}
|
|
8518
|
+
var tokens = collectAssistantContractFilterTokens(filter)
|
|
8519
|
+
.filter(function (token) { return token.length >= 2 && !['and', 'or', 'eq', 'in', 'gte', 'lte', 'gt', 'lt'].includes(token); });
|
|
8520
|
+
if (!tokens.length) {
|
|
8521
|
+
return false;
|
|
8522
|
+
}
|
|
8523
|
+
return !tokens.every(function (token) { return pipelineText.includes(token); });
|
|
8524
|
+
})
|
|
8525
|
+
.map(function (filter) { return "Requested filter ".concat(formatAssistantContractFilterLabel(filter), " was not applied to the final aggregate pipeline."); });
|
|
8526
|
+
}
|
|
7973
8527
|
function isAssistantProjectFieldFromGroupId(value) {
|
|
7974
8528
|
return typeof value === 'string' && value.startsWith('$_id.');
|
|
7975
8529
|
}
|
|
@@ -8050,10 +8604,13 @@ function buildAssistantAppDataIntentDirective(message, collectionNames, appId, o
|
|
|
8050
8604
|
if (!intent) {
|
|
8051
8605
|
return null;
|
|
8052
8606
|
}
|
|
8053
|
-
var customerText =
|
|
8054
|
-
|
|
8607
|
+
var customerText = doesAssistantDataIntentUseCustomerText(intent)
|
|
8608
|
+
? extractAssistantDataIntentCustomerText(message)
|
|
8609
|
+
: '';
|
|
8610
|
+
var parsedDateWindow = resolveAssistantDataIntentDateWindow(message);
|
|
8055
8611
|
var requestUnderstanding = (options === null || options === void 0 ? void 0 : options.appDataRequestUnderstanding)
|
|
8056
|
-
|| buildAssistantDataRequestUnderstanding(message, intent,
|
|
8612
|
+
|| buildAssistantDataRequestUnderstanding(message, intent, parsedDateWindow, (options === null || options === void 0 ? void 0 : options.appDataRequestContract) || null);
|
|
8613
|
+
var dateWindow = resolveAssistantEffectiveDataIntentDateWindow(parsedDateWindow, requestUnderstanding);
|
|
8057
8614
|
var templatedDimensions = requestUnderstanding.dimensions
|
|
8058
8615
|
.map(function (dimension) { return applyAssistantDataIntentDimensionTemplate(dimension, { customerText: customerText, dateWindow: dateWindow }); })
|
|
8059
8616
|
.filter(function (dimension) { return !!(dimension === null || dimension === void 0 ? void 0 : dimension.groupId); });
|
|
@@ -8082,8 +8639,15 @@ function buildAssistantAppDataIntentDirective(message, collectionNames, appId, o
|
|
|
8082
8639
|
var pipeline = configuredPipeline.length
|
|
8083
8640
|
? configuredPipeline
|
|
8084
8641
|
: buildAssistantGenericDataIntentPipeline(intent, customerText, dateWindow);
|
|
8085
|
-
var
|
|
8086
|
-
|
|
8642
|
+
var dimensionPipeline = applyAssistantDataIntentDimensionsToPipeline(pipeline, templatedDimensions);
|
|
8643
|
+
var filterApplication = applyAssistantDataIntentContractFiltersToPipeline(dimensionPipeline, intent, requestUnderstanding.contract);
|
|
8644
|
+
var finalPipeline = filterApplication.pipeline;
|
|
8645
|
+
var droppedBreakdownAmbiguities = resolveAssistantDroppedBreakdownAmbiguities(requestUnderstanding.contract, finalPipeline);
|
|
8646
|
+
var droppedFilterAmbiguities = resolveAssistantDroppedFilterAmbiguities(requestUnderstanding.contract, finalPipeline, filterApplication.appliedFilterKeys);
|
|
8647
|
+
var droppedContractAmbiguities = mergeAssistantHintValues(droppedBreakdownAmbiguities, droppedFilterAmbiguities);
|
|
8648
|
+
metadata.requestContract = __assign(__assign({}, requestUnderstanding.contract), { measures: buildAssistantDataRequestMeasures(intent, finalPipeline), ambiguities: mergeAssistantHintValues(requestUnderstanding.contract.ambiguities || [], droppedContractAmbiguities), confidence: droppedContractAmbiguities.length
|
|
8649
|
+
? Math.min(requestUnderstanding.contract.confidence || 0.65, 0.65)
|
|
8650
|
+
: requestUnderstanding.contract.confidence });
|
|
8087
8651
|
return { type: 'aggregate', payload: basePayload(finalPipeline), cleaned: '', rawLine: "HEURISTIC_AGG(app-data-intent:".concat(intent.id, ")"), metadata: metadata };
|
|
8088
8652
|
}
|
|
8089
8653
|
function isAssistantDeterministicHeuristicDirective(directive) {
|
|
@@ -8248,7 +8812,7 @@ function ensureAssistantDisplayColumns(display, requestedColumns) {
|
|
|
8248
8812
|
return __assign(__assign({}, display), { columns: columns, rows: rows });
|
|
8249
8813
|
}
|
|
8250
8814
|
function resolveAssistantPipelineTimeGrain(pipeline) {
|
|
8251
|
-
var
|
|
8815
|
+
var e_8, _a;
|
|
8252
8816
|
if (!Array.isArray(pipeline) || !pipeline.length) {
|
|
8253
8817
|
return null;
|
|
8254
8818
|
}
|
|
@@ -8310,12 +8874,12 @@ function resolveAssistantPipelineTimeGrain(pipeline) {
|
|
|
8310
8874
|
}
|
|
8311
8875
|
}
|
|
8312
8876
|
}
|
|
8313
|
-
catch (
|
|
8877
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8314
8878
|
finally {
|
|
8315
8879
|
try {
|
|
8316
8880
|
if (priority_1_1 && !priority_1_1.done && (_a = priority_1.return)) _a.call(priority_1);
|
|
8317
8881
|
}
|
|
8318
|
-
finally { if (
|
|
8882
|
+
finally { if (e_8) throw e_8.error; }
|
|
8319
8883
|
}
|
|
8320
8884
|
return null;
|
|
8321
8885
|
}
|
|
@@ -9000,6 +9564,48 @@ function formatAssistantEvidenceDate(value) {
|
|
|
9000
9564
|
}
|
|
9001
9565
|
return normalized.slice(0, 10);
|
|
9002
9566
|
}
|
|
9567
|
+
function formatAssistantRequestBreakdownLabel(value) {
|
|
9568
|
+
var cleanLabel = function (label) { return normalizeOptionalString(label).replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim(); };
|
|
9569
|
+
if (!value || typeof value !== 'object') {
|
|
9570
|
+
return cleanLabel(value);
|
|
9571
|
+
}
|
|
9572
|
+
var type = normalizeOptionalString(value.type).toLowerCase();
|
|
9573
|
+
if (type === 'time') {
|
|
9574
|
+
return cleanLabel(value.granularity)
|
|
9575
|
+
|| cleanLabel(value.requested_text)
|
|
9576
|
+
|| cleanLabel(value.dimension);
|
|
9577
|
+
}
|
|
9578
|
+
return cleanLabel(value.requested_text)
|
|
9579
|
+
|| cleanLabel(value.dimension)
|
|
9580
|
+
|| cleanLabel(value.field_hint);
|
|
9581
|
+
}
|
|
9582
|
+
function joinAssistantHumanList(values) {
|
|
9583
|
+
var cleaned = normalizeAssistantProgress(values).map(function (value) { return value.toLowerCase(); });
|
|
9584
|
+
if (!cleaned.length) {
|
|
9585
|
+
return '';
|
|
9586
|
+
}
|
|
9587
|
+
if (cleaned.length === 1) {
|
|
9588
|
+
return cleaned[0];
|
|
9589
|
+
}
|
|
9590
|
+
if (cleaned.length === 2) {
|
|
9591
|
+
return "".concat(cleaned[0], " and ").concat(cleaned[1]);
|
|
9592
|
+
}
|
|
9593
|
+
return "".concat(cleaned.slice(0, -1).join(', '), ", and ").concat(cleaned[cleaned.length - 1]);
|
|
9594
|
+
}
|
|
9595
|
+
function resolveAssistantRequestBreakdownSummary(requestContract) {
|
|
9596
|
+
var requestedBreakdowns = Array.isArray(requestContract === null || requestContract === void 0 ? void 0 : requestContract.requested_breakdowns)
|
|
9597
|
+
? requestContract.requested_breakdowns
|
|
9598
|
+
: [];
|
|
9599
|
+
var labels = requestedBreakdowns
|
|
9600
|
+
.map(function (entry) { return formatAssistantRequestBreakdownLabel(entry); })
|
|
9601
|
+
.filter(Boolean);
|
|
9602
|
+
var joined = joinAssistantHumanList(labels);
|
|
9603
|
+
return joined ? "by ".concat(joined) : '';
|
|
9604
|
+
}
|
|
9605
|
+
function buildAssistantBreakdownProgressMessage(requestContract) {
|
|
9606
|
+
var breakdown = resolveAssistantRequestBreakdownSummary(requestContract);
|
|
9607
|
+
return breakdown ? "Grouping and summarizing results ".concat(breakdown) : '';
|
|
9608
|
+
}
|
|
9003
9609
|
function buildAssistantToolFallbackResponse(result) {
|
|
9004
9610
|
var _a, _b;
|
|
9005
9611
|
var rowCount = Math.max(0, Number(result.output.rowCount || 0));
|
|
@@ -9023,6 +9629,10 @@ function buildAssistantToolFallbackResponse(result) {
|
|
|
9023
9629
|
lines.push("- Source: ".concat(source));
|
|
9024
9630
|
}
|
|
9025
9631
|
lines.push("- Rows returned: ".concat(rowCount));
|
|
9632
|
+
var breakdown = resolveAssistantRequestBreakdownSummary(debug.requestContract);
|
|
9633
|
+
if (breakdown) {
|
|
9634
|
+
lines.push("- Summary breakdown: ".concat(breakdown));
|
|
9635
|
+
}
|
|
9026
9636
|
if (customerText) {
|
|
9027
9637
|
lines.push("- Filter: ".concat(customerText));
|
|
9028
9638
|
}
|
|
@@ -9032,13 +9642,11 @@ function buildAssistantToolFallbackResponse(result) {
|
|
|
9032
9642
|
if (typeof result.output.total === 'number') {
|
|
9033
9643
|
lines.push("- Total: ".concat(result.output.total));
|
|
9034
9644
|
}
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
lines.push("- Assumptions: ".concat(assumptions.slice(0, 3).join('; ')));
|
|
9041
|
-
}
|
|
9645
|
+
var assumptions = Array.isArray(debug.assumptions)
|
|
9646
|
+
? debug.assumptions.map(function (entry) { return normalizeOptionalString(entry); }).filter(Boolean)
|
|
9647
|
+
: [];
|
|
9648
|
+
if (assumptions.length) {
|
|
9649
|
+
lines.push("- Assumptions: ".concat(assumptions.slice(0, 3).join('; ')));
|
|
9042
9650
|
}
|
|
9043
9651
|
var leadSummary = buildAssistantDisplayLeadSummary(result.output.display);
|
|
9044
9652
|
if (leadSummary) {
|
|
@@ -9176,7 +9784,7 @@ function applyAssistantDatedReportWindow(value, toolResult) {
|
|
|
9176
9784
|
return "".concat(line, "\n\n").concat(content).trim();
|
|
9177
9785
|
}
|
|
9178
9786
|
function resolveAssistantDatedReportWindow(toolResult) {
|
|
9179
|
-
var
|
|
9787
|
+
var e_9, _a;
|
|
9180
9788
|
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
9181
9789
|
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;
|
|
9182
9790
|
var verificationStart = normalizeOptionalString(verificationWindow === null || verificationWindow === void 0 ? void 0 : verificationWindow.startDate);
|
|
@@ -9242,12 +9850,12 @@ function resolveAssistantDatedReportWindow(toolResult) {
|
|
|
9242
9850
|
};
|
|
9243
9851
|
}
|
|
9244
9852
|
}
|
|
9245
|
-
catch (
|
|
9853
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
9246
9854
|
finally {
|
|
9247
9855
|
try {
|
|
9248
9856
|
if (pipelineCandidates_1_1 && !pipelineCandidates_1_1.done && (_a = pipelineCandidates_1.return)) _a.call(pipelineCandidates_1);
|
|
9249
9857
|
}
|
|
9250
|
-
finally { if (
|
|
9858
|
+
finally { if (e_9) throw e_9.error; }
|
|
9251
9859
|
}
|
|
9252
9860
|
return null;
|
|
9253
9861
|
}
|
|
@@ -9710,9 +10318,30 @@ function createAssistantProgressTracker(messageId, initialProgress) {
|
|
|
9710
10318
|
progress = normalizeAssistantProgress(__spreadArray(__spreadArray([], __read(progress), false), [item], false));
|
|
9711
10319
|
queueProgressUpdate();
|
|
9712
10320
|
},
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
10321
|
+
snapshot: function () { return __spreadArray([], __read(progress), false); },
|
|
10322
|
+
stop: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
10323
|
+
var snapshot, _a;
|
|
10324
|
+
return __generator(this, function (_b) {
|
|
10325
|
+
switch (_b.label) {
|
|
10326
|
+
case 0:
|
|
10327
|
+
snapshot = __spreadArray([], __read(progress), false);
|
|
10328
|
+
if (!(messageId && snapshot.length)) return [3 /*break*/, 4];
|
|
10329
|
+
_b.label = 1;
|
|
10330
|
+
case 1:
|
|
10331
|
+
_b.trys.push([1, 3, , 4]);
|
|
10332
|
+
return [4 /*yield*/, updateAssistantProgress(messageId, snapshot)];
|
|
10333
|
+
case 2:
|
|
10334
|
+
_b.sent();
|
|
10335
|
+
return [3 /*break*/, 4];
|
|
10336
|
+
case 3:
|
|
10337
|
+
_a = _b.sent();
|
|
10338
|
+
return [3 /*break*/, 4];
|
|
10339
|
+
case 4:
|
|
10340
|
+
stopped = true;
|
|
10341
|
+
return [2 /*return*/, snapshot];
|
|
10342
|
+
}
|
|
10343
|
+
});
|
|
10344
|
+
}); }
|
|
9716
10345
|
};
|
|
9717
10346
|
}
|
|
9718
10347
|
function buildAssistantCodexErrorMessage(error) {
|
|
@@ -9926,7 +10555,7 @@ function getValueAtPath(obj, path) {
|
|
|
9926
10555
|
return walk(obj, 0);
|
|
9927
10556
|
}
|
|
9928
10557
|
function hasArrayValueAtPath(docs, path) {
|
|
9929
|
-
var
|
|
10558
|
+
var e_10, _a;
|
|
9930
10559
|
if (!Array.isArray(docs) || !docs.length || !path) {
|
|
9931
10560
|
return false;
|
|
9932
10561
|
}
|
|
@@ -9939,17 +10568,17 @@ function hasArrayValueAtPath(docs, path) {
|
|
|
9939
10568
|
}
|
|
9940
10569
|
}
|
|
9941
10570
|
}
|
|
9942
|
-
catch (
|
|
10571
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
9943
10572
|
finally {
|
|
9944
10573
|
try {
|
|
9945
10574
|
if (docs_1_1 && !docs_1_1.done && (_a = docs_1.return)) _a.call(docs_1);
|
|
9946
10575
|
}
|
|
9947
|
-
finally { if (
|
|
10576
|
+
finally { if (e_10) throw e_10.error; }
|
|
9948
10577
|
}
|
|
9949
10578
|
return false;
|
|
9950
10579
|
}
|
|
9951
10580
|
function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
9952
|
-
var
|
|
10581
|
+
var e_11, _a, e_12, _b;
|
|
9953
10582
|
if (!Array.isArray(docs) || !fieldPath) {
|
|
9954
10583
|
return 'unknown';
|
|
9955
10584
|
}
|
|
@@ -9962,7 +10591,7 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
|
9962
10591
|
: doc === null || doc === void 0 ? void 0 : doc[fieldPath];
|
|
9963
10592
|
var queue = Array.isArray(value) ? value : [value];
|
|
9964
10593
|
try {
|
|
9965
|
-
for (var queue_1 = (
|
|
10594
|
+
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()) {
|
|
9966
10595
|
var entry = queue_1_1.value;
|
|
9967
10596
|
if (entry === null || entry === undefined) {
|
|
9968
10597
|
continue;
|
|
@@ -9975,21 +10604,21 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
|
9975
10604
|
}
|
|
9976
10605
|
}
|
|
9977
10606
|
}
|
|
9978
|
-
catch (
|
|
10607
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
9979
10608
|
finally {
|
|
9980
10609
|
try {
|
|
9981
10610
|
if (queue_1_1 && !queue_1_1.done && (_b = queue_1.return)) _b.call(queue_1);
|
|
9982
10611
|
}
|
|
9983
|
-
finally { if (
|
|
10612
|
+
finally { if (e_12) throw e_12.error; }
|
|
9984
10613
|
}
|
|
9985
10614
|
}
|
|
9986
10615
|
}
|
|
9987
|
-
catch (
|
|
10616
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
9988
10617
|
finally {
|
|
9989
10618
|
try {
|
|
9990
10619
|
if (docs_2_1 && !docs_2_1.done && (_a = docs_2.return)) _a.call(docs_2);
|
|
9991
10620
|
}
|
|
9992
|
-
finally { if (
|
|
10621
|
+
finally { if (e_11) throw e_11.error; }
|
|
9993
10622
|
}
|
|
9994
10623
|
return sawString ? 'string' : 'unknown';
|
|
9995
10624
|
}
|
|
@@ -10084,7 +10713,7 @@ function normalizeLookupKeyValue(value) {
|
|
|
10084
10713
|
return '';
|
|
10085
10714
|
}
|
|
10086
10715
|
function collectTopLevelIdFieldValues(docs, options) {
|
|
10087
|
-
var
|
|
10716
|
+
var e_13, _a, e_14, _b;
|
|
10088
10717
|
if (!Array.isArray(docs) || !docs.length) {
|
|
10089
10718
|
return [];
|
|
10090
10719
|
}
|
|
@@ -10132,26 +10761,26 @@ function collectTopLevelIdFieldValues(docs, options) {
|
|
|
10132
10761
|
});
|
|
10133
10762
|
};
|
|
10134
10763
|
try {
|
|
10135
|
-
for (var keys_1 = (
|
|
10764
|
+
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()) {
|
|
10136
10765
|
var key = keys_1_1.value;
|
|
10137
10766
|
_loop_3(key);
|
|
10138
10767
|
}
|
|
10139
10768
|
}
|
|
10140
|
-
catch (
|
|
10769
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
10141
10770
|
finally {
|
|
10142
10771
|
try {
|
|
10143
10772
|
if (keys_1_1 && !keys_1_1.done && (_b = keys_1.return)) _b.call(keys_1);
|
|
10144
10773
|
}
|
|
10145
|
-
finally { if (
|
|
10774
|
+
finally { if (e_14) throw e_14.error; }
|
|
10146
10775
|
}
|
|
10147
10776
|
}
|
|
10148
10777
|
}
|
|
10149
|
-
catch (
|
|
10778
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
10150
10779
|
finally {
|
|
10151
10780
|
try {
|
|
10152
10781
|
if (docs_3_1 && !docs_3_1.done && (_a = docs_3.return)) _a.call(docs_3);
|
|
10153
10782
|
}
|
|
10154
|
-
finally { if (
|
|
10783
|
+
finally { if (e_13) throw e_13.error; }
|
|
10155
10784
|
}
|
|
10156
10785
|
return Array.from(fieldMap.entries()).map(function (_a) {
|
|
10157
10786
|
var _b = __read(_a, 2), field = _b[0], values = _b[1];
|
|
@@ -10272,8 +10901,8 @@ function resolveLookupMappingsForField(field, mappings) {
|
|
|
10272
10901
|
}
|
|
10273
10902
|
function applyIdLookupDisplayEnrichment(params) {
|
|
10274
10903
|
return __awaiter(this, void 0, void 0, function () {
|
|
10275
|
-
var docs, collection, db, dbName, idClient, idCustomer, isSuperAdmin, idFields, lookupMappings, allCollections, collectionProbeCache, collectionSchemaCache, lookupMeta, enrichedDocs, _loop_4, idFields_1, idFields_1_1, fieldEntry,
|
|
10276
|
-
var
|
|
10904
|
+
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;
|
|
10905
|
+
var e_15, _a;
|
|
10277
10906
|
return __generator(this, function (_b) {
|
|
10278
10907
|
switch (_b.label) {
|
|
10279
10908
|
case 0:
|
|
@@ -10297,8 +10926,8 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
10297
10926
|
lookupMeta = [];
|
|
10298
10927
|
enrichedDocs = docs.map(function (doc) { return (__assign({}, doc)); });
|
|
10299
10928
|
_loop_4 = function (fieldEntry) {
|
|
10300
|
-
var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3,
|
|
10301
|
-
var
|
|
10929
|
+
var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3, e_16_1;
|
|
10930
|
+
var e_16, _c;
|
|
10302
10931
|
return __generator(this, function (_d) {
|
|
10303
10932
|
switch (_d.label) {
|
|
10304
10933
|
case 0:
|
|
@@ -10472,7 +11101,7 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
10472
11101
|
_d.label = 1;
|
|
10473
11102
|
case 1:
|
|
10474
11103
|
_d.trys.push([1, 6, 7, 8]);
|
|
10475
|
-
filteredCandidates_1 = (
|
|
11104
|
+
filteredCandidates_1 = (e_16 = void 0, __values(filteredCandidates)), filteredCandidates_1_1 = filteredCandidates_1.next();
|
|
10476
11105
|
_d.label = 2;
|
|
10477
11106
|
case 2:
|
|
10478
11107
|
if (!!filteredCandidates_1_1.done) return [3 /*break*/, 5];
|
|
@@ -10488,14 +11117,14 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
10488
11117
|
return [3 /*break*/, 2];
|
|
10489
11118
|
case 5: return [3 /*break*/, 8];
|
|
10490
11119
|
case 6:
|
|
10491
|
-
|
|
10492
|
-
|
|
11120
|
+
e_16_1 = _d.sent();
|
|
11121
|
+
e_16 = { error: e_16_1 };
|
|
10493
11122
|
return [3 /*break*/, 8];
|
|
10494
11123
|
case 7:
|
|
10495
11124
|
try {
|
|
10496
11125
|
if (filteredCandidates_1_1 && !filteredCandidates_1_1.done && (_c = filteredCandidates_1.return)) _c.call(filteredCandidates_1);
|
|
10497
11126
|
}
|
|
10498
|
-
finally { if (
|
|
11127
|
+
finally { if (e_16) throw e_16.error; }
|
|
10499
11128
|
return [7 /*endfinally*/];
|
|
10500
11129
|
case 8: return [2 /*return*/];
|
|
10501
11130
|
}
|
|
@@ -10518,14 +11147,14 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
10518
11147
|
return [3 /*break*/, 3];
|
|
10519
11148
|
case 6: return [3 /*break*/, 9];
|
|
10520
11149
|
case 7:
|
|
10521
|
-
|
|
10522
|
-
|
|
11150
|
+
e_15_1 = _b.sent();
|
|
11151
|
+
e_15 = { error: e_15_1 };
|
|
10523
11152
|
return [3 /*break*/, 9];
|
|
10524
11153
|
case 8:
|
|
10525
11154
|
try {
|
|
10526
11155
|
if (idFields_1_1 && !idFields_1_1.done && (_a = idFields_1.return)) _a.call(idFields_1);
|
|
10527
11156
|
}
|
|
10528
|
-
finally { if (
|
|
11157
|
+
finally { if (e_15) throw e_15.error; }
|
|
10529
11158
|
return [7 /*endfinally*/];
|
|
10530
11159
|
case 9:
|
|
10531
11160
|
if (!lookupMeta.length) {
|
|
@@ -10544,7 +11173,7 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
10544
11173
|
});
|
|
10545
11174
|
}
|
|
10546
11175
|
function hasNonEmptyValue(docs, fieldPath, options) {
|
|
10547
|
-
var
|
|
11176
|
+
var e_17, _a;
|
|
10548
11177
|
if (!Array.isArray(docs) || !fieldPath) {
|
|
10549
11178
|
return false;
|
|
10550
11179
|
}
|
|
@@ -10561,12 +11190,12 @@ function hasNonEmptyValue(docs, fieldPath, options) {
|
|
|
10561
11190
|
}
|
|
10562
11191
|
}
|
|
10563
11192
|
}
|
|
10564
|
-
catch (
|
|
11193
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
10565
11194
|
finally {
|
|
10566
11195
|
try {
|
|
10567
11196
|
if (docs_4_1 && !docs_4_1.done && (_a = docs_4.return)) _a.call(docs_4);
|
|
10568
11197
|
}
|
|
10569
|
-
finally { if (
|
|
11198
|
+
finally { if (e_17) throw e_17.error; }
|
|
10570
11199
|
}
|
|
10571
11200
|
return false;
|
|
10572
11201
|
}
|
|
@@ -13182,7 +13811,7 @@ function flattenAssistantExprClauses(expr) {
|
|
|
13182
13811
|
return [expr];
|
|
13183
13812
|
}
|
|
13184
13813
|
function detectAssistantMonthWindowInExpr(expr, allowedDateFields) {
|
|
13185
|
-
var
|
|
13814
|
+
var e_18, _a;
|
|
13186
13815
|
var clauses = flattenAssistantExprClauses(expr);
|
|
13187
13816
|
if (!clauses.length) {
|
|
13188
13817
|
return null;
|
|
@@ -13256,12 +13885,12 @@ function detectAssistantMonthWindowInExpr(expr, allowedDateFields) {
|
|
|
13256
13885
|
return state_4.value;
|
|
13257
13886
|
}
|
|
13258
13887
|
}
|
|
13259
|
-
catch (
|
|
13888
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
13260
13889
|
finally {
|
|
13261
13890
|
try {
|
|
13262
13891
|
if (lowerClauses_1_1 && !lowerClauses_1_1.done && (_a = lowerClauses_1.return)) _a.call(lowerClauses_1);
|
|
13263
13892
|
}
|
|
13264
|
-
finally { if (
|
|
13893
|
+
finally { if (e_18) throw e_18.error; }
|
|
13265
13894
|
}
|
|
13266
13895
|
return null;
|
|
13267
13896
|
}
|
|
@@ -13324,7 +13953,7 @@ function resolveAssistantMonthlyGroupDateFields(pipeline) {
|
|
|
13324
13953
|
return fields;
|
|
13325
13954
|
}
|
|
13326
13955
|
function detectAssistantMonthWindowFromPipeline(pipeline) {
|
|
13327
|
-
var
|
|
13956
|
+
var e_19, _a;
|
|
13328
13957
|
var _b;
|
|
13329
13958
|
var monthlyFields = resolveAssistantMonthlyGroupDateFields(pipeline);
|
|
13330
13959
|
var scanMatch = function (match) {
|
|
@@ -13352,12 +13981,12 @@ function detectAssistantMonthWindowFromPipeline(pipeline) {
|
|
|
13352
13981
|
}
|
|
13353
13982
|
}
|
|
13354
13983
|
}
|
|
13355
|
-
catch (
|
|
13984
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
13356
13985
|
finally {
|
|
13357
13986
|
try {
|
|
13358
13987
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
13359
13988
|
}
|
|
13360
|
-
finally { if (
|
|
13989
|
+
finally { if (e_19) throw e_19.error; }
|
|
13361
13990
|
}
|
|
13362
13991
|
return null;
|
|
13363
13992
|
}
|
|
@@ -13637,7 +14266,7 @@ function normalizeAssistantCustomerLookupProjectionPipeline(pipeline) {
|
|
|
13637
14266
|
var nextProject = __assign({}, project);
|
|
13638
14267
|
var stageChanged = false;
|
|
13639
14268
|
Object.keys(nextProject).forEach(function (field) {
|
|
13640
|
-
var
|
|
14269
|
+
var e_20, _a;
|
|
13641
14270
|
var expression = nextProject[field];
|
|
13642
14271
|
if (typeof expression !== 'string') {
|
|
13643
14272
|
return;
|
|
@@ -13673,12 +14302,12 @@ function normalizeAssistantCustomerLookupProjectionPipeline(pipeline) {
|
|
|
13673
14302
|
break;
|
|
13674
14303
|
}
|
|
13675
14304
|
}
|
|
13676
|
-
catch (
|
|
14305
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
13677
14306
|
finally {
|
|
13678
14307
|
try {
|
|
13679
14308
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
13680
14309
|
}
|
|
13681
|
-
finally { if (
|
|
14310
|
+
finally { if (e_20) throw e_20.error; }
|
|
13682
14311
|
}
|
|
13683
14312
|
});
|
|
13684
14313
|
if (stageChanged) {
|
|
@@ -13851,7 +14480,7 @@ function matchContainsField(value, field) {
|
|
|
13851
14480
|
});
|
|
13852
14481
|
}
|
|
13853
14482
|
function resolveAggregateCompletionFallback(pipeline) {
|
|
13854
|
-
var
|
|
14483
|
+
var e_21, _a;
|
|
13855
14484
|
if (!Array.isArray(pipeline)) {
|
|
13856
14485
|
return null;
|
|
13857
14486
|
}
|
|
@@ -13864,7 +14493,7 @@ function resolveAggregateCompletionFallback(pipeline) {
|
|
|
13864
14493
|
}
|
|
13865
14494
|
var addFields = stage.$addFields;
|
|
13866
14495
|
try {
|
|
13867
|
-
for (var _b = (
|
|
14496
|
+
for (var _b = (e_21 = void 0, __values(Object.keys(addFields))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
13868
14497
|
var key = _c.value;
|
|
13869
14498
|
if (!isCompletionFieldName(key)) {
|
|
13870
14499
|
continue;
|
|
@@ -13878,12 +14507,12 @@ function resolveAggregateCompletionFallback(pipeline) {
|
|
|
13878
14507
|
}
|
|
13879
14508
|
}
|
|
13880
14509
|
}
|
|
13881
|
-
catch (
|
|
14510
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
13882
14511
|
finally {
|
|
13883
14512
|
try {
|
|
13884
14513
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
13885
14514
|
}
|
|
13886
|
-
finally { if (
|
|
14515
|
+
finally { if (e_21) throw e_21.error; }
|
|
13887
14516
|
}
|
|
13888
14517
|
if (candidateField) {
|
|
13889
14518
|
break;
|
|
@@ -14039,7 +14668,7 @@ function buildCompletionFallbackSources(field) {
|
|
|
14039
14668
|
]);
|
|
14040
14669
|
}
|
|
14041
14670
|
function resolveAggregateCompletionExprFallback(pipeline) {
|
|
14042
|
-
var
|
|
14671
|
+
var e_22, _a;
|
|
14043
14672
|
if (!Array.isArray(pipeline)) {
|
|
14044
14673
|
return null;
|
|
14045
14674
|
}
|
|
@@ -14059,7 +14688,7 @@ function resolveAggregateCompletionExprFallback(pipeline) {
|
|
|
14059
14688
|
}
|
|
14060
14689
|
if (!candidateField) {
|
|
14061
14690
|
try {
|
|
14062
|
-
for (var _b = (
|
|
14691
|
+
for (var _b = (e_22 = void 0, __values(Object.keys(matchStage))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14063
14692
|
var key = _c.value;
|
|
14064
14693
|
if (key.startsWith('$')) {
|
|
14065
14694
|
continue;
|
|
@@ -14074,12 +14703,12 @@ function resolveAggregateCompletionExprFallback(pipeline) {
|
|
|
14074
14703
|
}
|
|
14075
14704
|
}
|
|
14076
14705
|
}
|
|
14077
|
-
catch (
|
|
14706
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
14078
14707
|
finally {
|
|
14079
14708
|
try {
|
|
14080
14709
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
14081
14710
|
}
|
|
14082
|
-
finally { if (
|
|
14711
|
+
finally { if (e_22) throw e_22.error; }
|
|
14083
14712
|
}
|
|
14084
14713
|
}
|
|
14085
14714
|
if (!candidateField) {
|
|
@@ -14281,7 +14910,7 @@ function hasAssistantDateGroupingOperator(value) {
|
|
|
14281
14910
|
return Object.keys(value).some(function (key) { return hasAssistantDateGroupingOperator(value[key]); });
|
|
14282
14911
|
}
|
|
14283
14912
|
function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths) {
|
|
14284
|
-
var
|
|
14913
|
+
var e_23, _a, e_24, _b;
|
|
14285
14914
|
if (!Array.isArray(pipeline) || groupIndex <= 0 || !groupPaths.length) {
|
|
14286
14915
|
return false;
|
|
14287
14916
|
}
|
|
@@ -14307,14 +14936,14 @@ function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths)
|
|
|
14307
14936
|
continue;
|
|
14308
14937
|
}
|
|
14309
14938
|
try {
|
|
14310
|
-
for (var stageKeys_1 = (
|
|
14939
|
+
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()) {
|
|
14311
14940
|
var stageKey = stageKeys_1_1.value;
|
|
14312
14941
|
var payload = stage[stageKey];
|
|
14313
14942
|
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
14314
14943
|
continue;
|
|
14315
14944
|
}
|
|
14316
14945
|
try {
|
|
14317
|
-
for (var groupFields_1 = (
|
|
14946
|
+
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()) {
|
|
14318
14947
|
var groupField = groupFields_1_1.value;
|
|
14319
14948
|
if (!Object.prototype.hasOwnProperty.call(payload, groupField)) {
|
|
14320
14949
|
continue;
|
|
@@ -14324,21 +14953,21 @@ function isGroupFieldDerivedFromDateExpression(pipeline, groupIndex, groupPaths)
|
|
|
14324
14953
|
}
|
|
14325
14954
|
}
|
|
14326
14955
|
}
|
|
14327
|
-
catch (
|
|
14956
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
14328
14957
|
finally {
|
|
14329
14958
|
try {
|
|
14330
14959
|
if (groupFields_1_1 && !groupFields_1_1.done && (_b = groupFields_1.return)) _b.call(groupFields_1);
|
|
14331
14960
|
}
|
|
14332
|
-
finally { if (
|
|
14961
|
+
finally { if (e_24) throw e_24.error; }
|
|
14333
14962
|
}
|
|
14334
14963
|
}
|
|
14335
14964
|
}
|
|
14336
|
-
catch (
|
|
14965
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
14337
14966
|
finally {
|
|
14338
14967
|
try {
|
|
14339
14968
|
if (stageKeys_1_1 && !stageKeys_1_1.done && (_a = stageKeys_1.return)) _a.call(stageKeys_1);
|
|
14340
14969
|
}
|
|
14341
|
-
finally { if (
|
|
14970
|
+
finally { if (e_23) throw e_23.error; }
|
|
14342
14971
|
}
|
|
14343
14972
|
}
|
|
14344
14973
|
return false;
|
|
@@ -14445,7 +15074,7 @@ function isRegexMatchCondition(value) {
|
|
|
14445
15074
|
return false;
|
|
14446
15075
|
}
|
|
14447
15076
|
function findRegexMatchInMatchObject(match, prefix) {
|
|
14448
|
-
var
|
|
15077
|
+
var e_25, _a, e_26, _b;
|
|
14449
15078
|
if (prefix === void 0) { prefix = ''; }
|
|
14450
15079
|
if (Array.isArray(match)) {
|
|
14451
15080
|
try {
|
|
@@ -14457,12 +15086,12 @@ function findRegexMatchInMatchObject(match, prefix) {
|
|
|
14457
15086
|
}
|
|
14458
15087
|
}
|
|
14459
15088
|
}
|
|
14460
|
-
catch (
|
|
15089
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
14461
15090
|
finally {
|
|
14462
15091
|
try {
|
|
14463
15092
|
if (match_1_1 && !match_1_1.done && (_a = match_1.return)) _a.call(match_1);
|
|
14464
15093
|
}
|
|
14465
|
-
finally { if (
|
|
15094
|
+
finally { if (e_25) throw e_25.error; }
|
|
14466
15095
|
}
|
|
14467
15096
|
return null;
|
|
14468
15097
|
}
|
|
@@ -14493,12 +15122,12 @@ function findRegexMatchInMatchObject(match, prefix) {
|
|
|
14493
15122
|
}
|
|
14494
15123
|
}
|
|
14495
15124
|
}
|
|
14496
|
-
catch (
|
|
15125
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
14497
15126
|
finally {
|
|
14498
15127
|
try {
|
|
14499
15128
|
if (keys_2_1 && !keys_2_1.done && (_b = keys_2.return)) _b.call(keys_2);
|
|
14500
15129
|
}
|
|
14501
|
-
finally { if (
|
|
15130
|
+
finally { if (e_26) throw e_26.error; }
|
|
14502
15131
|
}
|
|
14503
15132
|
return null;
|
|
14504
15133
|
}
|
|
@@ -14887,7 +15516,7 @@ function collectMatchFieldsByCondition(match, predicate, prefix) {
|
|
|
14887
15516
|
return results;
|
|
14888
15517
|
}
|
|
14889
15518
|
function findMatchConditionForField(match, targetField, prefix) {
|
|
14890
|
-
var
|
|
15519
|
+
var e_27, _a, e_28, _b;
|
|
14891
15520
|
if (prefix === void 0) { prefix = ''; }
|
|
14892
15521
|
if (!match || typeof match !== 'object') {
|
|
14893
15522
|
return undefined;
|
|
@@ -14902,12 +15531,12 @@ function findMatchConditionForField(match, targetField, prefix) {
|
|
|
14902
15531
|
}
|
|
14903
15532
|
}
|
|
14904
15533
|
}
|
|
14905
|
-
catch (
|
|
15534
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
14906
15535
|
finally {
|
|
14907
15536
|
try {
|
|
14908
15537
|
if (match_2_1 && !match_2_1.done && (_a = match_2.return)) _a.call(match_2);
|
|
14909
15538
|
}
|
|
14910
|
-
finally { if (
|
|
15539
|
+
finally { if (e_27) throw e_27.error; }
|
|
14911
15540
|
}
|
|
14912
15541
|
return undefined;
|
|
14913
15542
|
}
|
|
@@ -14934,12 +15563,12 @@ function findMatchConditionForField(match, targetField, prefix) {
|
|
|
14934
15563
|
}
|
|
14935
15564
|
}
|
|
14936
15565
|
}
|
|
14937
|
-
catch (
|
|
15566
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
14938
15567
|
finally {
|
|
14939
15568
|
try {
|
|
14940
15569
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
14941
15570
|
}
|
|
14942
|
-
finally { if (
|
|
15571
|
+
finally { if (e_28) throw e_28.error; }
|
|
14943
15572
|
}
|
|
14944
15573
|
return undefined;
|
|
14945
15574
|
}
|
|
@@ -15172,7 +15801,7 @@ function detectIdLikeValue(value) {
|
|
|
15172
15801
|
return false;
|
|
15173
15802
|
}
|
|
15174
15803
|
function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
15175
|
-
var
|
|
15804
|
+
var e_29, _a, e_30, _b;
|
|
15176
15805
|
if (!Array.isArray(probeDocs) || !probeDocs.length) {
|
|
15177
15806
|
return false;
|
|
15178
15807
|
}
|
|
@@ -15184,7 +15813,7 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
|
15184
15813
|
for (var probeDocs_1 = __values(probeDocs), probeDocs_1_1 = probeDocs_1.next(); !probeDocs_1_1.done; probeDocs_1_1 = probeDocs_1.next()) {
|
|
15185
15814
|
var doc = probeDocs_1_1.value;
|
|
15186
15815
|
try {
|
|
15187
|
-
for (var targets_1 = (
|
|
15816
|
+
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()) {
|
|
15188
15817
|
var field = targets_1_1.value;
|
|
15189
15818
|
var value = getValueAtPath(doc, field);
|
|
15190
15819
|
if (Array.isArray(value)) {
|
|
@@ -15197,21 +15826,21 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
|
15197
15826
|
}
|
|
15198
15827
|
}
|
|
15199
15828
|
}
|
|
15200
|
-
catch (
|
|
15829
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
15201
15830
|
finally {
|
|
15202
15831
|
try {
|
|
15203
15832
|
if (targets_1_1 && !targets_1_1.done && (_b = targets_1.return)) _b.call(targets_1);
|
|
15204
15833
|
}
|
|
15205
|
-
finally { if (
|
|
15834
|
+
finally { if (e_30) throw e_30.error; }
|
|
15206
15835
|
}
|
|
15207
15836
|
}
|
|
15208
15837
|
}
|
|
15209
|
-
catch (
|
|
15838
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
15210
15839
|
finally {
|
|
15211
15840
|
try {
|
|
15212
15841
|
if (probeDocs_1_1 && !probeDocs_1_1.done && (_a = probeDocs_1.return)) _a.call(probeDocs_1);
|
|
15213
15842
|
}
|
|
15214
|
-
finally { if (
|
|
15843
|
+
finally { if (e_29) throw e_29.error; }
|
|
15215
15844
|
}
|
|
15216
15845
|
return false;
|
|
15217
15846
|
}
|
|
@@ -15432,8 +16061,8 @@ function buildChemicalIdFieldCandidates(field) {
|
|
|
15432
16061
|
}
|
|
15433
16062
|
function applyChemicalNameLookupFallbackToQuery(params) {
|
|
15434
16063
|
return __awaiter(this, void 0, void 0, function () {
|
|
15435
|
-
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,
|
|
15436
|
-
var
|
|
16064
|
+
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;
|
|
16065
|
+
var e_31, _a;
|
|
15437
16066
|
var _b;
|
|
15438
16067
|
return __generator(this, function (_c) {
|
|
15439
16068
|
switch (_c.label) {
|
|
@@ -15546,14 +16175,14 @@ function applyChemicalNameLookupFallbackToQuery(params) {
|
|
|
15546
16175
|
return [3 /*break*/, 3];
|
|
15547
16176
|
case 6: return [3 /*break*/, 9];
|
|
15548
16177
|
case 7:
|
|
15549
|
-
|
|
15550
|
-
|
|
16178
|
+
e_31_1 = _c.sent();
|
|
16179
|
+
e_31 = { error: e_31_1 };
|
|
15551
16180
|
return [3 /*break*/, 9];
|
|
15552
16181
|
case 8:
|
|
15553
16182
|
try {
|
|
15554
16183
|
if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
|
|
15555
16184
|
}
|
|
15556
|
-
finally { if (
|
|
16185
|
+
finally { if (e_31) throw e_31.error; }
|
|
15557
16186
|
return [7 /*endfinally*/];
|
|
15558
16187
|
case 9: return [2 /*return*/, null];
|
|
15559
16188
|
}
|
|
@@ -15653,8 +16282,8 @@ function lookupIdsForNameMatch(params) {
|
|
|
15653
16282
|
}
|
|
15654
16283
|
function applyIdLookupFallbackToQuery(params) {
|
|
15655
16284
|
return __awaiter(this, void 0, void 0, function () {
|
|
15656
|
-
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,
|
|
15657
|
-
var
|
|
16285
|
+
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;
|
|
16286
|
+
var e_33, _c, e_32, _d;
|
|
15658
16287
|
var _e;
|
|
15659
16288
|
return __generator(this, function (_f) {
|
|
15660
16289
|
switch (_f.label) {
|
|
@@ -15724,7 +16353,7 @@ function applyIdLookupFallbackToQuery(params) {
|
|
|
15724
16353
|
_f.label = 5;
|
|
15725
16354
|
case 5:
|
|
15726
16355
|
_f.trys.push([5, 14, 15, 16]);
|
|
15727
|
-
candidates_2 = (
|
|
16356
|
+
candidates_2 = (e_32 = void 0, __values(candidates)), candidates_2_1 = candidates_2.next();
|
|
15728
16357
|
_f.label = 6;
|
|
15729
16358
|
case 6:
|
|
15730
16359
|
if (!!candidates_2_1.done) return [3 /*break*/, 13];
|
|
@@ -15791,28 +16420,28 @@ function applyIdLookupFallbackToQuery(params) {
|
|
|
15791
16420
|
return [3 /*break*/, 6];
|
|
15792
16421
|
case 13: return [3 /*break*/, 16];
|
|
15793
16422
|
case 14:
|
|
15794
|
-
|
|
15795
|
-
|
|
16423
|
+
e_32_1 = _f.sent();
|
|
16424
|
+
e_32 = { error: e_32_1 };
|
|
15796
16425
|
return [3 /*break*/, 16];
|
|
15797
16426
|
case 15:
|
|
15798
16427
|
try {
|
|
15799
16428
|
if (candidates_2_1 && !candidates_2_1.done && (_d = candidates_2.return)) _d.call(candidates_2);
|
|
15800
16429
|
}
|
|
15801
|
-
finally { if (
|
|
16430
|
+
finally { if (e_32) throw e_32.error; }
|
|
15802
16431
|
return [7 /*endfinally*/];
|
|
15803
16432
|
case 16:
|
|
15804
16433
|
conditions_1_1 = conditions_1.next();
|
|
15805
16434
|
return [3 /*break*/, 4];
|
|
15806
16435
|
case 17: return [3 /*break*/, 20];
|
|
15807
16436
|
case 18:
|
|
15808
|
-
|
|
15809
|
-
|
|
16437
|
+
e_33_1 = _f.sent();
|
|
16438
|
+
e_33 = { error: e_33_1 };
|
|
15810
16439
|
return [3 /*break*/, 20];
|
|
15811
16440
|
case 19:
|
|
15812
16441
|
try {
|
|
15813
16442
|
if (conditions_1_1 && !conditions_1_1.done && (_c = conditions_1.return)) _c.call(conditions_1);
|
|
15814
16443
|
}
|
|
15815
|
-
finally { if (
|
|
16444
|
+
finally { if (e_33) throw e_33.error; }
|
|
15816
16445
|
return [7 /*endfinally*/];
|
|
15817
16446
|
case 20: return [2 /*return*/, null];
|
|
15818
16447
|
}
|
|
@@ -16257,8 +16886,8 @@ function resolveAssistantSurfaceFileCandidates(baseName) {
|
|
|
16257
16886
|
}
|
|
16258
16887
|
function readFirstAssistantSurfaceFile(candidates) {
|
|
16259
16888
|
return __awaiter(this, void 0, void 0, function () {
|
|
16260
|
-
var candidates_3, candidates_3_1, candidate, normalized, _a,
|
|
16261
|
-
var
|
|
16889
|
+
var candidates_3, candidates_3_1, candidate, normalized, _a, e_34_1;
|
|
16890
|
+
var e_34, _b;
|
|
16262
16891
|
return __generator(this, function (_c) {
|
|
16263
16892
|
switch (_c.label) {
|
|
16264
16893
|
case 0:
|
|
@@ -16285,14 +16914,14 @@ function readFirstAssistantSurfaceFile(candidates) {
|
|
|
16285
16914
|
return [3 /*break*/, 1];
|
|
16286
16915
|
case 6: return [3 /*break*/, 9];
|
|
16287
16916
|
case 7:
|
|
16288
|
-
|
|
16289
|
-
|
|
16917
|
+
e_34_1 = _c.sent();
|
|
16918
|
+
e_34 = { error: e_34_1 };
|
|
16290
16919
|
return [3 /*break*/, 9];
|
|
16291
16920
|
case 8:
|
|
16292
16921
|
try {
|
|
16293
16922
|
if (candidates_3_1 && !candidates_3_1.done && (_b = candidates_3.return)) _b.call(candidates_3);
|
|
16294
16923
|
}
|
|
16295
|
-
finally { if (
|
|
16924
|
+
finally { if (e_34) throw e_34.error; }
|
|
16296
16925
|
return [7 /*endfinally*/];
|
|
16297
16926
|
case 9: return [2 /*return*/, ''];
|
|
16298
16927
|
}
|
|
@@ -16842,6 +17471,15 @@ function cloneAssistantHeuristicProfile(profile) {
|
|
|
16842
17471
|
preGroupStages: Array.isArray(dimension === null || dimension === void 0 ? void 0 : dimension.preGroupStages) ? (0, common_1.deepCopy)(dimension.preGroupStages) : undefined
|
|
16843
17472
|
}); }).filter(function (dimension) { return !!dimension.id && dimension.groupId !== undefined; })
|
|
16844
17473
|
: [],
|
|
17474
|
+
filterFields: Array.isArray(entry === null || entry === void 0 ? void 0 : entry.filterFields)
|
|
17475
|
+
? entry.filterFields.map(function (filterField) { return ({
|
|
17476
|
+
id: normalizeOptionalString(filterField === null || filterField === void 0 ? void 0 : filterField.id),
|
|
17477
|
+
terms: mergeAssistantHintValues((filterField === null || filterField === void 0 ? void 0 : filterField.terms) || []).map(function (term) { return term.toLowerCase(); }),
|
|
17478
|
+
fields: mergeAssistantHintValues((filterField === null || filterField === void 0 ? void 0 : filterField.fields) || []),
|
|
17479
|
+
type: normalizeAssistantAppDataFilterFieldType(filterField === null || filterField === void 0 ? void 0 : filterField.type),
|
|
17480
|
+
operators: mergeAssistantHintValues((filterField === null || filterField === void 0 ? void 0 : filterField.operators) || []).map(function (operator) { return operator.toLowerCase(); })
|
|
17481
|
+
}); }).filter(function (filterField) { return !!filterField.id && !!filterField.fields.length; })
|
|
17482
|
+
: [],
|
|
16845
17483
|
pipeline: Array.isArray(entry === null || entry === void 0 ? void 0 : entry.pipeline) ? (0, common_1.deepCopy)(entry.pipeline) : undefined,
|
|
16846
17484
|
options: (entry === null || entry === void 0 ? void 0 : entry.options) && typeof entry.options === 'object' && !Array.isArray(entry.options)
|
|
16847
17485
|
? (0, common_1.deepCopy)(entry.options)
|
|
@@ -16942,6 +17580,13 @@ function normalizeAssistantAppDataDimensionType(value) {
|
|
|
16942
17580
|
}
|
|
16943
17581
|
return undefined;
|
|
16944
17582
|
}
|
|
17583
|
+
function normalizeAssistantAppDataFilterFieldType(value) {
|
|
17584
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
17585
|
+
if (normalized === 'string' || normalized === 'number' || normalized === 'boolean' || normalized === 'date') {
|
|
17586
|
+
return normalized;
|
|
17587
|
+
}
|
|
17588
|
+
return undefined;
|
|
17589
|
+
}
|
|
16945
17590
|
function normalizeAssistantHeuristicStringList(value) {
|
|
16946
17591
|
if (Array.isArray(value)) {
|
|
16947
17592
|
return mergeAssistantHintValues(value.map(function (entry) { return normalizeOptionalString(entry).toLowerCase(); }));
|
|
@@ -17049,6 +17694,50 @@ function normalizeAssistantAppDataDimensions(value) {
|
|
|
17049
17694
|
});
|
|
17050
17695
|
return dimensions;
|
|
17051
17696
|
}
|
|
17697
|
+
function normalizeAssistantAppDataFilterFields(value) {
|
|
17698
|
+
var entries = Array.isArray(value)
|
|
17699
|
+
? value.map(function (entry) { return ({ key: '', entry: entry }); })
|
|
17700
|
+
: value && typeof value === 'object'
|
|
17701
|
+
? Object.keys(value).map(function (key) { return ({ key: key, entry: value[key] }); })
|
|
17702
|
+
: [];
|
|
17703
|
+
var fields = [];
|
|
17704
|
+
entries.forEach(function (_a) {
|
|
17705
|
+
var key = _a.key, entry = _a.entry;
|
|
17706
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
17707
|
+
return;
|
|
17708
|
+
}
|
|
17709
|
+
var id = normalizeOptionalString(entry.id
|
|
17710
|
+
|| entry.filter_id
|
|
17711
|
+
|| entry.filterId
|
|
17712
|
+
|| key);
|
|
17713
|
+
var rawFilterFields = entry.fields
|
|
17714
|
+
|| entry.field_hints
|
|
17715
|
+
|| entry.fieldHints
|
|
17716
|
+
|| entry.field
|
|
17717
|
+
|| [];
|
|
17718
|
+
var filterFields = (Array.isArray(rawFilterFields)
|
|
17719
|
+
? mergeAssistantHintValues(rawFilterFields)
|
|
17720
|
+
: normalizeOptionalString(rawFilterFields)
|
|
17721
|
+
? [normalizeOptionalString(rawFilterFields)]
|
|
17722
|
+
: []).filter(function (field) { return isAssistantProjectionKeyAllowed(field); });
|
|
17723
|
+
if (!id || !filterFields.length) {
|
|
17724
|
+
return;
|
|
17725
|
+
}
|
|
17726
|
+
var terms = normalizeAssistantHeuristicStringList(entry.terms
|
|
17727
|
+
|| entry.aliases
|
|
17728
|
+
|| entry.phrases
|
|
17729
|
+
|| [id]).map(function (term) { return term.toLowerCase(); });
|
|
17730
|
+
fields.push({
|
|
17731
|
+
id: id,
|
|
17732
|
+
terms: terms.length ? terms : [id.toLowerCase()],
|
|
17733
|
+
fields: filterFields,
|
|
17734
|
+
type: normalizeAssistantAppDataFilterFieldType(entry.type),
|
|
17735
|
+
operators: normalizeAssistantHeuristicStringList(entry.operators || entry.ops || [])
|
|
17736
|
+
.map(function (operator) { return operator.toLowerCase(); })
|
|
17737
|
+
});
|
|
17738
|
+
});
|
|
17739
|
+
return fields;
|
|
17740
|
+
}
|
|
17052
17741
|
function normalizeAssistantAppDataIntents(value) {
|
|
17053
17742
|
var entries = Array.isArray(value) ? value : [];
|
|
17054
17743
|
var intents = [];
|
|
@@ -17083,6 +17772,10 @@ function normalizeAssistantAppDataIntents(value) {
|
|
|
17083
17772
|
|| entry.breakdown_dimensions
|
|
17084
17773
|
|| entry.breakdownDimensions
|
|
17085
17774
|
|| []),
|
|
17775
|
+
filterFields: normalizeAssistantAppDataFilterFields(entry.filter_fields
|
|
17776
|
+
|| entry.filterFields
|
|
17777
|
+
|| entry.filters
|
|
17778
|
+
|| []),
|
|
17086
17779
|
pipeline: Array.isArray(entry.pipeline) ? (0, common_1.deepCopy)(entry.pipeline) : undefined,
|
|
17087
17780
|
options: entry.options && typeof entry.options === 'object' && !Array.isArray(entry.options)
|
|
17088
17781
|
? (0, common_1.deepCopy)(entry.options)
|
|
@@ -17813,7 +18506,7 @@ function doesAssistantPreserveAnyTermMatch(text, terms) {
|
|
|
17813
18506
|
return (Array.isArray(terms) ? terms : []).some(function (term) { return doesAssistantPreserveTermMatch(text, term); });
|
|
17814
18507
|
}
|
|
17815
18508
|
function shouldPreserveAssistantCollectionForRouteFromRules(params) {
|
|
17816
|
-
var
|
|
18509
|
+
var e_35, _a;
|
|
17817
18510
|
var _b, _c, _d, _e, _f, _g, _h;
|
|
17818
18511
|
var routePreferred = normalizeAssistantCollectionOverrideName(params.routePreferredName);
|
|
17819
18512
|
var requested = normalizeAssistantCollectionOverrideName(params.requestedCollection);
|
|
@@ -17845,12 +18538,12 @@ function shouldPreserveAssistantCollectionForRouteFromRules(params) {
|
|
|
17845
18538
|
return true;
|
|
17846
18539
|
}
|
|
17847
18540
|
}
|
|
17848
|
-
catch (
|
|
18541
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
17849
18542
|
finally {
|
|
17850
18543
|
try {
|
|
17851
18544
|
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
17852
18545
|
}
|
|
17853
|
-
finally { if (
|
|
18546
|
+
finally { if (e_35) throw e_35.error; }
|
|
17854
18547
|
}
|
|
17855
18548
|
return false;
|
|
17856
18549
|
}
|
|
@@ -18741,7 +19434,7 @@ function resolveAssistantNestedPrefixCollectionCandidates(params) {
|
|
|
18741
19434
|
function resolveAssistantNestedAggregateFallbacks(params) {
|
|
18742
19435
|
return __awaiter(this, void 0, void 0, function () {
|
|
18743
19436
|
var prefixes, collectionNames, fallbacks, seen, prefixes_1, prefixes_1_1, prefix, rewrite, candidates, candidates_4, candidates_4_1, candidate, normalizedPipeline, key;
|
|
18744
|
-
var
|
|
19437
|
+
var e_36, _a, e_37, _b;
|
|
18745
19438
|
return __generator(this, function (_c) {
|
|
18746
19439
|
switch (_c.label) {
|
|
18747
19440
|
case 0:
|
|
@@ -18771,7 +19464,7 @@ function resolveAssistantNestedAggregateFallbacks(params) {
|
|
|
18771
19464
|
triedCollections: params.triedCollections
|
|
18772
19465
|
});
|
|
18773
19466
|
try {
|
|
18774
|
-
for (candidates_4 = (
|
|
19467
|
+
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()) {
|
|
18775
19468
|
candidate = candidates_4_1.value;
|
|
18776
19469
|
normalizedPipeline = normalizeAssistantAggregatePipeline(rewrite.pipeline, candidate);
|
|
18777
19470
|
if (!normalizedPipeline.length || containsForbiddenMongoOperators(normalizedPipeline)) {
|
|
@@ -18793,21 +19486,21 @@ function resolveAssistantNestedAggregateFallbacks(params) {
|
|
|
18793
19486
|
}
|
|
18794
19487
|
}
|
|
18795
19488
|
}
|
|
18796
|
-
catch (
|
|
19489
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
18797
19490
|
finally {
|
|
18798
19491
|
try {
|
|
18799
19492
|
if (candidates_4_1 && !candidates_4_1.done && (_b = candidates_4.return)) _b.call(candidates_4);
|
|
18800
19493
|
}
|
|
18801
|
-
finally { if (
|
|
19494
|
+
finally { if (e_37) throw e_37.error; }
|
|
18802
19495
|
}
|
|
18803
19496
|
}
|
|
18804
19497
|
}
|
|
18805
|
-
catch (
|
|
19498
|
+
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
18806
19499
|
finally {
|
|
18807
19500
|
try {
|
|
18808
19501
|
if (prefixes_1_1 && !prefixes_1_1.done && (_a = prefixes_1.return)) _a.call(prefixes_1);
|
|
18809
19502
|
}
|
|
18810
|
-
finally { if (
|
|
19503
|
+
finally { if (e_36) throw e_36.error; }
|
|
18811
19504
|
}
|
|
18812
19505
|
return [2 /*return*/, fallbacks];
|
|
18813
19506
|
}
|
|
@@ -18939,8 +19632,8 @@ function resolveAssistantBridgeCollectionHintCandidates(requestedCollection, req
|
|
|
18939
19632
|
}
|
|
18940
19633
|
function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
18941
19634
|
return __awaiter(this, arguments, void 0, function (collection, db, dbName, options) {
|
|
18942
|
-
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,
|
|
18943
|
-
var
|
|
19635
|
+
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;
|
|
19636
|
+
var e_40, _b, e_41, _c, e_38, _d, e_39, _e, e_42, _f;
|
|
18944
19637
|
var _g, _h;
|
|
18945
19638
|
if (dbName === void 0) { dbName = ''; }
|
|
18946
19639
|
return __generator(this, function (_j) {
|
|
@@ -19014,12 +19707,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19014
19707
|
}
|
|
19015
19708
|
}
|
|
19016
19709
|
}
|
|
19017
|
-
catch (
|
|
19710
|
+
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
19018
19711
|
finally {
|
|
19019
19712
|
try {
|
|
19020
19713
|
if (candidates_5_1 && !candidates_5_1.done && (_b = candidates_5.return)) _b.call(candidates_5);
|
|
19021
19714
|
}
|
|
19022
|
-
finally { if (
|
|
19715
|
+
finally { if (e_40) throw e_40.error; }
|
|
19023
19716
|
}
|
|
19024
19717
|
}
|
|
19025
19718
|
if (configuredCollectionNames.length) {
|
|
@@ -19034,12 +19727,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19034
19727
|
}
|
|
19035
19728
|
}
|
|
19036
19729
|
}
|
|
19037
|
-
catch (
|
|
19730
|
+
catch (e_41_1) { e_41 = { error: e_41_1 }; }
|
|
19038
19731
|
finally {
|
|
19039
19732
|
try {
|
|
19040
19733
|
if (candidates_6_1 && !candidates_6_1.done && (_c = candidates_6.return)) _c.call(candidates_6);
|
|
19041
19734
|
}
|
|
19042
|
-
finally { if (
|
|
19735
|
+
finally { if (e_41) throw e_41.error; }
|
|
19043
19736
|
}
|
|
19044
19737
|
}
|
|
19045
19738
|
primaryCollectionHint = normalizeOptionalString((_h = requestHints === null || requestHints === void 0 ? void 0 : requestHints.collectionHints) === null || _h === void 0 ? void 0 : _h[0]);
|
|
@@ -19100,14 +19793,14 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19100
19793
|
return [3 /*break*/, 2];
|
|
19101
19794
|
case 7: return [3 /*break*/, 10];
|
|
19102
19795
|
case 8:
|
|
19103
|
-
|
|
19104
|
-
|
|
19796
|
+
e_38_1 = _j.sent();
|
|
19797
|
+
e_38 = { error: e_38_1 };
|
|
19105
19798
|
return [3 /*break*/, 10];
|
|
19106
19799
|
case 9:
|
|
19107
19800
|
try {
|
|
19108
19801
|
if (resolverTargets_1_1 && !resolverTargets_1_1.done && (_d = resolverTargets_1.return)) _d.call(resolverTargets_1);
|
|
19109
19802
|
}
|
|
19110
|
-
finally { if (
|
|
19803
|
+
finally { if (e_38) throw e_38.error; }
|
|
19111
19804
|
return [7 /*endfinally*/];
|
|
19112
19805
|
case 10:
|
|
19113
19806
|
if (!db) return [3 /*break*/, 18];
|
|
@@ -19133,14 +19826,14 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19133
19826
|
return [3 /*break*/, 12];
|
|
19134
19827
|
case 15: return [3 /*break*/, 18];
|
|
19135
19828
|
case 16:
|
|
19136
|
-
|
|
19137
|
-
|
|
19829
|
+
e_39_1 = _j.sent();
|
|
19830
|
+
e_39 = { error: e_39_1 };
|
|
19138
19831
|
return [3 /*break*/, 18];
|
|
19139
19832
|
case 17:
|
|
19140
19833
|
try {
|
|
19141
19834
|
if (candidates_7_1 && !candidates_7_1.done && (_e = candidates_7.return)) _e.call(candidates_7);
|
|
19142
19835
|
}
|
|
19143
|
-
finally { if (
|
|
19836
|
+
finally { if (e_39) throw e_39.error; }
|
|
19144
19837
|
return [7 /*endfinally*/];
|
|
19145
19838
|
case 18:
|
|
19146
19839
|
try {
|
|
@@ -19151,12 +19844,12 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19151
19844
|
}
|
|
19152
19845
|
}
|
|
19153
19846
|
}
|
|
19154
|
-
catch (
|
|
19847
|
+
catch (e_42_1) { e_42 = { error: e_42_1 }; }
|
|
19155
19848
|
finally {
|
|
19156
19849
|
try {
|
|
19157
19850
|
if (candidates_8_1 && !candidates_8_1.done && (_f = candidates_8.return)) _f.call(candidates_8);
|
|
19158
19851
|
}
|
|
19159
|
-
finally { if (
|
|
19852
|
+
finally { if (e_42) throw e_42.error; }
|
|
19160
19853
|
}
|
|
19161
19854
|
throw new Error('AI assistant report builder bridge: No queryable collection could be resolved.');
|
|
19162
19855
|
}
|
|
@@ -19164,7 +19857,7 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
19164
19857
|
});
|
|
19165
19858
|
}
|
|
19166
19859
|
function findQueryDateField(query) {
|
|
19167
|
-
var
|
|
19860
|
+
var e_43, _a, e_44, _b;
|
|
19168
19861
|
if (!query || typeof query !== 'object') {
|
|
19169
19862
|
return null;
|
|
19170
19863
|
}
|
|
@@ -19178,12 +19871,12 @@ function findQueryDateField(query) {
|
|
|
19178
19871
|
}
|
|
19179
19872
|
}
|
|
19180
19873
|
}
|
|
19181
|
-
catch (
|
|
19874
|
+
catch (e_43_1) { e_43 = { error: e_43_1 }; }
|
|
19182
19875
|
finally {
|
|
19183
19876
|
try {
|
|
19184
19877
|
if (query_1_1 && !query_1_1.done && (_a = query_1.return)) _a.call(query_1);
|
|
19185
19878
|
}
|
|
19186
|
-
finally { if (
|
|
19879
|
+
finally { if (e_43) throw e_43.error; }
|
|
19187
19880
|
}
|
|
19188
19881
|
return null;
|
|
19189
19882
|
}
|
|
@@ -19202,12 +19895,12 @@ function findQueryDateField(query) {
|
|
|
19202
19895
|
}
|
|
19203
19896
|
}
|
|
19204
19897
|
}
|
|
19205
|
-
catch (
|
|
19898
|
+
catch (e_44_1) { e_44 = { error: e_44_1 }; }
|
|
19206
19899
|
finally {
|
|
19207
19900
|
try {
|
|
19208
19901
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
19209
19902
|
}
|
|
19210
|
-
finally { if (
|
|
19903
|
+
finally { if (e_44) throw e_44.error; }
|
|
19211
19904
|
}
|
|
19212
19905
|
return null;
|
|
19213
19906
|
}
|
|
@@ -19495,7 +20188,7 @@ function resolveQueryDateFieldFallback(query) {
|
|
|
19495
20188
|
return { from: dateField, to: fallback };
|
|
19496
20189
|
}
|
|
19497
20190
|
function containsForbiddenMongoOperators(value) {
|
|
19498
|
-
var
|
|
20191
|
+
var e_45, _a;
|
|
19499
20192
|
if (!value || typeof value !== 'object') {
|
|
19500
20193
|
return false;
|
|
19501
20194
|
}
|
|
@@ -19514,12 +20207,12 @@ function containsForbiddenMongoOperators(value) {
|
|
|
19514
20207
|
}
|
|
19515
20208
|
}
|
|
19516
20209
|
}
|
|
19517
|
-
catch (
|
|
20210
|
+
catch (e_45_1) { e_45 = { error: e_45_1 }; }
|
|
19518
20211
|
finally {
|
|
19519
20212
|
try {
|
|
19520
20213
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
19521
20214
|
}
|
|
19522
|
-
finally { if (
|
|
20215
|
+
finally { if (e_45) throw e_45.error; }
|
|
19523
20216
|
}
|
|
19524
20217
|
return false;
|
|
19525
20218
|
}
|
|
@@ -19704,7 +20397,7 @@ function splitAssistantPermissionTokenSets(value) {
|
|
|
19704
20397
|
};
|
|
19705
20398
|
}
|
|
19706
20399
|
function isAssistantTokenSetSubset(subset, superset) {
|
|
19707
|
-
var
|
|
20400
|
+
var e_46, _a;
|
|
19708
20401
|
if (!subset.size) {
|
|
19709
20402
|
return false;
|
|
19710
20403
|
}
|
|
@@ -19716,12 +20409,12 @@ function isAssistantTokenSetSubset(subset, superset) {
|
|
|
19716
20409
|
}
|
|
19717
20410
|
}
|
|
19718
20411
|
}
|
|
19719
|
-
catch (
|
|
20412
|
+
catch (e_46_1) { e_46 = { error: e_46_1 }; }
|
|
19720
20413
|
finally {
|
|
19721
20414
|
try {
|
|
19722
20415
|
if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1);
|
|
19723
20416
|
}
|
|
19724
|
-
finally { if (
|
|
20417
|
+
finally { if (e_46) throw e_46.error; }
|
|
19725
20418
|
}
|
|
19726
20419
|
return true;
|
|
19727
20420
|
}
|
|
@@ -20256,8 +20949,8 @@ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
|
|
|
20256
20949
|
}
|
|
20257
20950
|
function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
20258
20951
|
return __awaiter(this, void 0, void 0, function () {
|
|
20259
|
-
var _a, _b, _c, _d, message, payload, status_1,
|
|
20260
|
-
var _e,
|
|
20952
|
+
var _a, _b, _c, _d, message, payload, status_1, e_47_1;
|
|
20953
|
+
var _e, e_47, _f, _g;
|
|
20261
20954
|
return __generator(this, function (_h) {
|
|
20262
20955
|
switch (_h.label) {
|
|
20263
20956
|
case 0:
|
|
@@ -20284,8 +20977,8 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
20284
20977
|
return [3 /*break*/, 1];
|
|
20285
20978
|
case 4: return [3 /*break*/, 11];
|
|
20286
20979
|
case 5:
|
|
20287
|
-
|
|
20288
|
-
|
|
20980
|
+
e_47_1 = _h.sent();
|
|
20981
|
+
e_47 = { error: e_47_1 };
|
|
20289
20982
|
return [3 /*break*/, 11];
|
|
20290
20983
|
case 6:
|
|
20291
20984
|
_h.trys.push([6, , 9, 10]);
|
|
@@ -20296,7 +20989,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
20296
20989
|
_h.label = 8;
|
|
20297
20990
|
case 8: return [3 /*break*/, 10];
|
|
20298
20991
|
case 9:
|
|
20299
|
-
if (
|
|
20992
|
+
if (e_47) throw e_47.error;
|
|
20300
20993
|
return [7 /*endfinally*/];
|
|
20301
20994
|
case 10: return [7 /*endfinally*/];
|
|
20302
20995
|
case 11: throw new CodexWorkerBootstrapError('AI worker exited before completing.');
|
|
@@ -20640,8 +21333,8 @@ function buildAssistantWorkspaceRootCandidates(params) {
|
|
|
20640
21333
|
}
|
|
20641
21334
|
function resolveAssistantWorkspaceRoot() {
|
|
20642
21335
|
return __awaiter(this, void 0, void 0, function () {
|
|
20643
|
-
var candidates, firstExisting, firstNestedGitRoot, candidates_9, candidates_9_1, candidate, _a, gitRoot, nestedGitRoots,
|
|
20644
|
-
var
|
|
21336
|
+
var candidates, firstExisting, firstNestedGitRoot, candidates_9, candidates_9_1, candidate, _a, gitRoot, nestedGitRoots, e_48_1;
|
|
21337
|
+
var e_48, _b;
|
|
20645
21338
|
return __generator(this, function (_c) {
|
|
20646
21339
|
switch (_c.label) {
|
|
20647
21340
|
case 0:
|
|
@@ -20688,14 +21381,14 @@ function resolveAssistantWorkspaceRoot() {
|
|
|
20688
21381
|
return [3 /*break*/, 2];
|
|
20689
21382
|
case 8: return [3 /*break*/, 11];
|
|
20690
21383
|
case 9:
|
|
20691
|
-
|
|
20692
|
-
|
|
21384
|
+
e_48_1 = _c.sent();
|
|
21385
|
+
e_48 = { error: e_48_1 };
|
|
20693
21386
|
return [3 /*break*/, 11];
|
|
20694
21387
|
case 10:
|
|
20695
21388
|
try {
|
|
20696
21389
|
if (candidates_9_1 && !candidates_9_1.done && (_b = candidates_9.return)) _b.call(candidates_9);
|
|
20697
21390
|
}
|
|
20698
|
-
finally { if (
|
|
21391
|
+
finally { if (e_48) throw e_48.error; }
|
|
20699
21392
|
return [7 /*endfinally*/];
|
|
20700
21393
|
case 11:
|
|
20701
21394
|
if (firstNestedGitRoot) {
|
|
@@ -21103,7 +21796,7 @@ var AI_ASSISTANT_BREAKDOWN_DIMENSION_STOPWORDS = new Set([
|
|
|
21103
21796
|
'by'
|
|
21104
21797
|
]);
|
|
21105
21798
|
function normalizeAssistantBreakdownDimension(value) {
|
|
21106
|
-
var
|
|
21799
|
+
var e_49, _a;
|
|
21107
21800
|
var normalized = normalizeOptionalString(value)
|
|
21108
21801
|
.toLowerCase()
|
|
21109
21802
|
.replace(/[^a-z0-9_\s-]+/g, ' ')
|
|
@@ -21135,12 +21828,12 @@ function normalizeAssistantBreakdownDimension(value) {
|
|
|
21135
21828
|
}
|
|
21136
21829
|
}
|
|
21137
21830
|
}
|
|
21138
|
-
catch (
|
|
21831
|
+
catch (e_49_1) { e_49 = { error: e_49_1 }; }
|
|
21139
21832
|
finally {
|
|
21140
21833
|
try {
|
|
21141
21834
|
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
21142
21835
|
}
|
|
21143
|
-
finally { if (
|
|
21836
|
+
finally { if (e_49) throw e_49.error; }
|
|
21144
21837
|
}
|
|
21145
21838
|
if (!kept.length) {
|
|
21146
21839
|
return '';
|
|
@@ -21345,7 +22038,7 @@ function resolveAssistantPlannerEnabled(config) {
|
|
|
21345
22038
|
return raw === undefined ? false : raw === true;
|
|
21346
22039
|
}
|
|
21347
22040
|
function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
|
|
21348
|
-
var
|
|
22041
|
+
var e_50, _a;
|
|
21349
22042
|
var _b;
|
|
21350
22043
|
if (isSuperAdmin === void 0) { isSuperAdmin = false; }
|
|
21351
22044
|
var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
|
|
@@ -21359,12 +22052,12 @@ function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
|
|
|
21359
22052
|
}
|
|
21360
22053
|
}
|
|
21361
22054
|
}
|
|
21362
|
-
catch (
|
|
22055
|
+
catch (e_50_1) { e_50 = { error: e_50_1 }; }
|
|
21363
22056
|
finally {
|
|
21364
22057
|
try {
|
|
21365
22058
|
if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
|
21366
22059
|
}
|
|
21367
|
-
finally { if (
|
|
22060
|
+
finally { if (e_50) throw e_50.error; }
|
|
21368
22061
|
}
|
|
21369
22062
|
var normalizedRoutes = Array.from(unique);
|
|
21370
22063
|
var allowedRoutes = collectAssistantAllowedRoutesForUser(user, normalizedRoutes, isSuperAdmin);
|
|
@@ -21740,7 +22433,7 @@ function normalizeRouteMatchKey(value) {
|
|
|
21740
22433
|
return normalizeRouteKey(value).toLowerCase();
|
|
21741
22434
|
}
|
|
21742
22435
|
function buildClientRouteIndex() {
|
|
21743
|
-
var
|
|
22436
|
+
var e_51, _a;
|
|
21744
22437
|
var _b;
|
|
21745
22438
|
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);
|
|
21746
22439
|
var set = new Set();
|
|
@@ -21759,12 +22452,12 @@ function buildClientRouteIndex() {
|
|
|
21759
22452
|
}
|
|
21760
22453
|
}
|
|
21761
22454
|
}
|
|
21762
|
-
catch (
|
|
22455
|
+
catch (e_51_1) { e_51 = { error: e_51_1 }; }
|
|
21763
22456
|
finally {
|
|
21764
22457
|
try {
|
|
21765
22458
|
if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
|
21766
22459
|
}
|
|
21767
|
-
finally { if (
|
|
22460
|
+
finally { if (e_51) throw e_51.error; }
|
|
21768
22461
|
}
|
|
21769
22462
|
return { set: set, map: map, size: routes.length };
|
|
21770
22463
|
}
|
|
@@ -22655,8 +23348,8 @@ function shouldSkipAssistantGitDiscoveryDirectory(name) {
|
|
|
22655
23348
|
}
|
|
22656
23349
|
function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
22657
23350
|
return __awaiter(this, void 0, void 0, function () {
|
|
22658
|
-
var roots, seen, push, _a, configuredRoots, configuredRoots_1, configuredRoots_1_1, configuredRoot, _b,
|
|
22659
|
-
var
|
|
23351
|
+
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;
|
|
23352
|
+
var e_52, _e, e_53, _f;
|
|
22660
23353
|
var _g;
|
|
22661
23354
|
return __generator(this, function (_h) {
|
|
22662
23355
|
switch (_h.label) {
|
|
@@ -22701,14 +23394,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
22701
23394
|
return [3 /*break*/, 3];
|
|
22702
23395
|
case 6: return [3 /*break*/, 9];
|
|
22703
23396
|
case 7:
|
|
22704
|
-
|
|
22705
|
-
|
|
23397
|
+
e_52_1 = _h.sent();
|
|
23398
|
+
e_52 = { error: e_52_1 };
|
|
22706
23399
|
return [3 /*break*/, 9];
|
|
22707
23400
|
case 8:
|
|
22708
23401
|
try {
|
|
22709
23402
|
if (configuredRoots_1_1 && !configuredRoots_1_1.done && (_e = configuredRoots_1.return)) _e.call(configuredRoots_1);
|
|
22710
23403
|
}
|
|
22711
|
-
finally { if (
|
|
23404
|
+
finally { if (e_52) throw e_52.error; }
|
|
22712
23405
|
return [7 /*endfinally*/];
|
|
22713
23406
|
case 9:
|
|
22714
23407
|
queue = [];
|
|
@@ -22748,7 +23441,7 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
22748
23441
|
return [3 /*break*/, 14];
|
|
22749
23442
|
case 14:
|
|
22750
23443
|
_h.trys.push([14, 21, 22, 23]);
|
|
22751
|
-
entries_1 = (
|
|
23444
|
+
entries_1 = (e_53 = void 0, __values(entries)), entries_1_1 = entries_1.next();
|
|
22752
23445
|
_h.label = 15;
|
|
22753
23446
|
case 15:
|
|
22754
23447
|
if (!!entries_1_1.done) return [3 /*break*/, 20];
|
|
@@ -22787,14 +23480,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
22787
23480
|
return [3 /*break*/, 15];
|
|
22788
23481
|
case 20: return [3 /*break*/, 23];
|
|
22789
23482
|
case 21:
|
|
22790
|
-
|
|
22791
|
-
|
|
23483
|
+
e_53_1 = _h.sent();
|
|
23484
|
+
e_53 = { error: e_53_1 };
|
|
22792
23485
|
return [3 /*break*/, 23];
|
|
22793
23486
|
case 22:
|
|
22794
23487
|
try {
|
|
22795
23488
|
if (entries_1_1 && !entries_1_1.done && (_f = entries_1.return)) _f.call(entries_1);
|
|
22796
23489
|
}
|
|
22797
|
-
finally { if (
|
|
23490
|
+
finally { if (e_53) throw e_53.error; }
|
|
22798
23491
|
return [7 /*endfinally*/];
|
|
22799
23492
|
case 23: return [3 /*break*/, 10];
|
|
22800
23493
|
case 24: return [2 /*return*/, roots];
|
|
@@ -23134,8 +23827,8 @@ function syncAssistantGitMirror(repoUrl) {
|
|
|
23134
23827
|
}
|
|
23135
23828
|
function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
23136
23829
|
return __awaiter(this, void 0, void 0, function () {
|
|
23137
|
-
var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot,
|
|
23138
|
-
var
|
|
23830
|
+
var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot, e_54_1;
|
|
23831
|
+
var e_54, _a;
|
|
23139
23832
|
return __generator(this, function (_b) {
|
|
23140
23833
|
switch (_b.label) {
|
|
23141
23834
|
case 0: return [4 /*yield*/, resolveAssistantWorkspaceGitRoots(workspaceRoot)];
|
|
@@ -23169,14 +23862,14 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
|
23169
23862
|
return [3 /*break*/, 3];
|
|
23170
23863
|
case 6: return [3 /*break*/, 9];
|
|
23171
23864
|
case 7:
|
|
23172
|
-
|
|
23173
|
-
|
|
23865
|
+
e_54_1 = _b.sent();
|
|
23866
|
+
e_54 = { error: e_54_1 };
|
|
23174
23867
|
return [3 /*break*/, 9];
|
|
23175
23868
|
case 8:
|
|
23176
23869
|
try {
|
|
23177
23870
|
if (repoUrls_1_1 && !repoUrls_1_1.done && (_a = repoUrls_1.return)) _a.call(repoUrls_1);
|
|
23178
23871
|
}
|
|
23179
|
-
finally { if (
|
|
23872
|
+
finally { if (e_54) throw e_54.error; }
|
|
23180
23873
|
return [7 /*endfinally*/];
|
|
23181
23874
|
case 9: return [2 /*return*/, mirroredRoots];
|
|
23182
23875
|
}
|
|
@@ -23185,8 +23878,8 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
|
23185
23878
|
}
|
|
23186
23879
|
function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
23187
23880
|
return __awaiter(this, void 0, void 0, function () {
|
|
23188
|
-
var workspaceRoot, _a, gitRoots, featureKeywords, sawExecutionError, bestFallback, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, summary, hasKeywordMatches, _e,
|
|
23189
|
-
var
|
|
23881
|
+
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;
|
|
23882
|
+
var e_55, _f;
|
|
23190
23883
|
return __generator(this, function (_g) {
|
|
23191
23884
|
switch (_g.label) {
|
|
23192
23885
|
case 0:
|
|
@@ -23308,14 +24001,14 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
|
23308
24001
|
return [3 /*break*/, 7];
|
|
23309
24002
|
case 20: return [3 /*break*/, 23];
|
|
23310
24003
|
case 21:
|
|
23311
|
-
|
|
23312
|
-
|
|
24004
|
+
e_55_1 = _g.sent();
|
|
24005
|
+
e_55 = { error: e_55_1 };
|
|
23313
24006
|
return [3 /*break*/, 23];
|
|
23314
24007
|
case 22:
|
|
23315
24008
|
try {
|
|
23316
24009
|
if (gitRoots_1_1 && !gitRoots_1_1.done && (_f = gitRoots_1.return)) _f.call(gitRoots_1);
|
|
23317
24010
|
}
|
|
23318
|
-
finally { if (
|
|
24011
|
+
finally { if (e_55) throw e_55.error; }
|
|
23319
24012
|
return [7 /*endfinally*/];
|
|
23320
24013
|
case 23:
|
|
23321
24014
|
if (bestFallback) {
|
|
@@ -23496,7 +24189,7 @@ function sanitizeAssistantResponse(value) {
|
|
|
23496
24189
|
return normalizeAssistantRoutes(normalizedCurrency);
|
|
23497
24190
|
}
|
|
23498
24191
|
function evaluateAssistantGuardrails(message) {
|
|
23499
|
-
var
|
|
24192
|
+
var e_56, _a;
|
|
23500
24193
|
var normalized = String(message || '').toLowerCase();
|
|
23501
24194
|
var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
|
|
23502
24195
|
if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
|
|
@@ -23541,12 +24234,12 @@ function evaluateAssistantGuardrails(message) {
|
|
|
23541
24234
|
}
|
|
23542
24235
|
}
|
|
23543
24236
|
}
|
|
23544
|
-
catch (
|
|
24237
|
+
catch (e_56_1) { e_56 = { error: e_56_1 }; }
|
|
23545
24238
|
finally {
|
|
23546
24239
|
try {
|
|
23547
24240
|
if (patterns_3_1 && !patterns_3_1.done && (_a = patterns_3.return)) _a.call(patterns_3);
|
|
23548
24241
|
}
|
|
23549
|
-
finally { if (
|
|
24242
|
+
finally { if (e_56) throw e_56.error; }
|
|
23550
24243
|
}
|
|
23551
24244
|
return null;
|
|
23552
24245
|
}
|
|
@@ -23651,7 +24344,7 @@ function tokenizeArithmeticExpression(expression) {
|
|
|
23651
24344
|
return tokens;
|
|
23652
24345
|
}
|
|
23653
24346
|
function evaluateArithmeticExpression(expression) {
|
|
23654
|
-
var
|
|
24347
|
+
var e_57, _a, e_58, _b;
|
|
23655
24348
|
var tokens = tokenizeArithmeticExpression(expression);
|
|
23656
24349
|
if (!tokens || !tokens.length) {
|
|
23657
24350
|
return null;
|
|
@@ -23708,12 +24401,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
23708
24401
|
prevToken = token;
|
|
23709
24402
|
}
|
|
23710
24403
|
}
|
|
23711
|
-
catch (
|
|
24404
|
+
catch (e_57_1) { e_57 = { error: e_57_1 }; }
|
|
23712
24405
|
finally {
|
|
23713
24406
|
try {
|
|
23714
24407
|
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
23715
24408
|
}
|
|
23716
|
-
finally { if (
|
|
24409
|
+
finally { if (e_57) throw e_57.error; }
|
|
23717
24410
|
}
|
|
23718
24411
|
while (ops.length) {
|
|
23719
24412
|
var op = ops.pop();
|
|
@@ -23753,12 +24446,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
23753
24446
|
stack.push(Number(token));
|
|
23754
24447
|
}
|
|
23755
24448
|
}
|
|
23756
|
-
catch (
|
|
24449
|
+
catch (e_58_1) { e_58 = { error: e_58_1 }; }
|
|
23757
24450
|
finally {
|
|
23758
24451
|
try {
|
|
23759
24452
|
if (output_1_1 && !output_1_1.done && (_b = output_1.return)) _b.call(output_1);
|
|
23760
24453
|
}
|
|
23761
|
-
finally { if (
|
|
24454
|
+
finally { if (e_58) throw e_58.error; }
|
|
23762
24455
|
}
|
|
23763
24456
|
if (stack.length !== 1 || Number.isNaN(stack[0])) {
|
|
23764
24457
|
return null;
|
|
@@ -23942,8 +24635,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
|
|
|
23942
24635
|
}
|
|
23943
24636
|
function readAttachmentContents(attachments) {
|
|
23944
24637
|
return __awaiter(this, void 0, void 0, function () {
|
|
23945
|
-
var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a,
|
|
23946
|
-
var
|
|
24638
|
+
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;
|
|
24639
|
+
var e_59, _b;
|
|
23947
24640
|
return __generator(this, function (_c) {
|
|
23948
24641
|
switch (_c.label) {
|
|
23949
24642
|
case 0:
|
|
@@ -24022,14 +24715,14 @@ function readAttachmentContents(attachments) {
|
|
|
24022
24715
|
return [3 /*break*/, 2];
|
|
24023
24716
|
case 10: return [3 /*break*/, 13];
|
|
24024
24717
|
case 11:
|
|
24025
|
-
|
|
24026
|
-
|
|
24718
|
+
e_59_1 = _c.sent();
|
|
24719
|
+
e_59 = { error: e_59_1 };
|
|
24027
24720
|
return [3 /*break*/, 13];
|
|
24028
24721
|
case 12:
|
|
24029
24722
|
try {
|
|
24030
24723
|
if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
|
|
24031
24724
|
}
|
|
24032
|
-
finally { if (
|
|
24725
|
+
finally { if (e_59) throw e_59.error; }
|
|
24033
24726
|
return [7 /*endfinally*/];
|
|
24034
24727
|
case 13: return [2 /*return*/, {
|
|
24035
24728
|
promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
|
|
@@ -24454,7 +25147,7 @@ function sanitizeAssistantMessageSetPayload(setPayload) {
|
|
|
24454
25147
|
return next;
|
|
24455
25148
|
}
|
|
24456
25149
|
function sanitizeMongoSafeObject(value) {
|
|
24457
|
-
var
|
|
25150
|
+
var e_60, _a;
|
|
24458
25151
|
if (value === null || value === undefined) {
|
|
24459
25152
|
return value;
|
|
24460
25153
|
}
|
|
@@ -24478,17 +25171,17 @@ function sanitizeMongoSafeObject(value) {
|
|
|
24478
25171
|
out[key] = sanitizeMongoSafeObject(rawValue);
|
|
24479
25172
|
}
|
|
24480
25173
|
}
|
|
24481
|
-
catch (
|
|
25174
|
+
catch (e_60_1) { e_60 = { error: e_60_1 }; }
|
|
24482
25175
|
finally {
|
|
24483
25176
|
try {
|
|
24484
25177
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
24485
25178
|
}
|
|
24486
|
-
finally { if (
|
|
25179
|
+
finally { if (e_60) throw e_60.error; }
|
|
24487
25180
|
}
|
|
24488
25181
|
return out;
|
|
24489
25182
|
}
|
|
24490
25183
|
function restoreMongoSafeObject(value) {
|
|
24491
|
-
var
|
|
25184
|
+
var e_61, _a;
|
|
24492
25185
|
if (value === null || value === undefined) {
|
|
24493
25186
|
return value;
|
|
24494
25187
|
}
|
|
@@ -24512,12 +25205,12 @@ function restoreMongoSafeObject(value) {
|
|
|
24512
25205
|
out[key] = restoreMongoSafeObject(rawValue);
|
|
24513
25206
|
}
|
|
24514
25207
|
}
|
|
24515
|
-
catch (
|
|
25208
|
+
catch (e_61_1) { e_61 = { error: e_61_1 }; }
|
|
24516
25209
|
finally {
|
|
24517
25210
|
try {
|
|
24518
25211
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
24519
25212
|
}
|
|
24520
|
-
finally { if (
|
|
25213
|
+
finally { if (e_61) throw e_61.error; }
|
|
24521
25214
|
}
|
|
24522
25215
|
return out;
|
|
24523
25216
|
}
|
|
@@ -24695,7 +25388,7 @@ function recordAssistantAnswerAIRun(input) {
|
|
|
24695
25388
|
});
|
|
24696
25389
|
}
|
|
24697
25390
|
function evaluateGuardrails(message) {
|
|
24698
|
-
var
|
|
25391
|
+
var e_62, _a;
|
|
24699
25392
|
var normalized = String(message || '').toLowerCase();
|
|
24700
25393
|
var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
|
|
24701
25394
|
if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
|
|
@@ -24721,12 +25414,12 @@ function evaluateGuardrails(message) {
|
|
|
24721
25414
|
}
|
|
24722
25415
|
}
|
|
24723
25416
|
}
|
|
24724
|
-
catch (
|
|
25417
|
+
catch (e_62_1) { e_62 = { error: e_62_1 }; }
|
|
24725
25418
|
finally {
|
|
24726
25419
|
try {
|
|
24727
25420
|
if (patterns_4_1 && !patterns_4_1.done && (_a = patterns_4.return)) _a.call(patterns_4);
|
|
24728
25421
|
}
|
|
24729
|
-
finally { if (
|
|
25422
|
+
finally { if (e_62) throw e_62.error; }
|
|
24730
25423
|
}
|
|
24731
25424
|
return null;
|
|
24732
25425
|
}
|