@resolveio/server-lib 22.3.203 → 22.3.204
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 +77 -1
- package/methods/ai-terminal.js +866 -344
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -114,6 +114,7 @@ exports.shouldPreserveAssistantProbeCollectionForTesting = shouldPreserveAssista
|
|
|
114
114
|
exports.buildAssistantAnswerQualityFromExecution = buildAssistantAnswerQualityFromExecution;
|
|
115
115
|
exports.buildAssistantInvoiceCustomerLabelExpr = buildAssistantInvoiceCustomerLabelExpr;
|
|
116
116
|
exports.resolveAssistantHeuristicDirectiveForTesting = resolveAssistantHeuristicDirectiveForTesting;
|
|
117
|
+
exports.buildAssistantDataRequestClassifierMessagesForTesting = buildAssistantDataRequestClassifierMessagesForTesting;
|
|
117
118
|
exports.buildAssistantDatedPivotDisplay = buildAssistantDatedPivotDisplay;
|
|
118
119
|
exports.buildAssistantToolFallbackResponseForTesting = buildAssistantToolFallbackResponseForTesting;
|
|
119
120
|
exports.deriveAssistantCommandExecutionStatus = deriveAssistantCommandExecutionStatus;
|
|
@@ -183,6 +184,7 @@ var ai_terminal_issue_report_collection_1 = require("../collections/ai-terminal-
|
|
|
183
184
|
var common_1 = require("../util/common");
|
|
184
185
|
var tokenizer_1 = require("../util/tokenizer");
|
|
185
186
|
var codex_client_1 = require("../services/codex-client");
|
|
187
|
+
var openai_client_1 = require("../services/openai-client");
|
|
186
188
|
var openai_usage_ledger_manager_1 = require("../managers/openai-usage-ledger.manager");
|
|
187
189
|
var ai_run_evidence_manager_1 = require("../managers/ai-run-evidence.manager");
|
|
188
190
|
var assistant_core_heuristics_1 = require("../ai/assistant-core-heuristics");
|
|
@@ -1886,10 +1888,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1886
1888
|
insertResult = _d.sent();
|
|
1887
1889
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1888
1890
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1889
|
-
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, 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, 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,
|
|
1890
|
-
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;
|
|
1891
|
-
return __generator(this, function (
|
|
1892
|
-
switch (
|
|
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;
|
|
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
|
+
return __generator(this, function (_21) {
|
|
1894
|
+
switch (_21.label) {
|
|
1893
1895
|
case 0:
|
|
1894
1896
|
runStart = Date.now();
|
|
1895
1897
|
fastModeEnabled = resolveAssistantFastModeEnabled(input.config);
|
|
@@ -1994,6 +1996,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1994
1996
|
plannerSkipReason = '';
|
|
1995
1997
|
plannerOutput = null;
|
|
1996
1998
|
plannerRaw = '';
|
|
1999
|
+
appDataRequestClassifierDebug = null;
|
|
2000
|
+
appDataRequestClassifierIntent = null;
|
|
2001
|
+
appDataRequestClassifierUnderstanding = null;
|
|
1997
2002
|
timingBreakdown = {
|
|
1998
2003
|
plannerMs: 0,
|
|
1999
2004
|
directiveMs: 0,
|
|
@@ -2030,9 +2035,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2030
2035
|
source: requestClassification.source,
|
|
2031
2036
|
dataQuestion: dataQuestion
|
|
2032
2037
|
});
|
|
2033
|
-
|
|
2038
|
+
_21.label = 1;
|
|
2034
2039
|
case 1:
|
|
2035
|
-
|
|
2040
|
+
_21.trys.push([1, 76, 77, 78]);
|
|
2036
2041
|
hintSeed = [message, contextRoute].filter(Boolean).join(' ');
|
|
2037
2042
|
termExpansion = expandAssistantTermSynonyms(hintSeed);
|
|
2038
2043
|
hintText = termExpansion.expanded || hintSeed;
|
|
@@ -2053,19 +2058,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2053
2058
|
recordStep('Planning: term expansion', {
|
|
2054
2059
|
termMatches: termExpansion.matches.length ? termExpansion.matches : undefined
|
|
2055
2060
|
});
|
|
2056
|
-
|
|
2061
|
+
_21.label = 2;
|
|
2057
2062
|
case 2:
|
|
2058
|
-
|
|
2063
|
+
_21.trys.push([2, 5, , 6]);
|
|
2059
2064
|
dbName = resolveAssistantDatabaseName(undefined, input.mongo);
|
|
2060
2065
|
db = resolveio_server_app_1.ResolveIOServer.getMongoConnection().db(dbName);
|
|
2061
2066
|
return [4 /*yield*/, listAssistantCollections(db, dbName)];
|
|
2062
2067
|
case 3:
|
|
2063
|
-
collectionNames =
|
|
2068
|
+
collectionNames = _21.sent();
|
|
2064
2069
|
collectionHints = resolveCollectionHintsFromTokens(expandedTokens, collectionNames, 5);
|
|
2065
2070
|
collectionRanking = buildCollectionRankingDebugFromTokens(expandedTokens, collectionNames, 8);
|
|
2066
2071
|
return [4 /*yield*/, resolveAssistantSurfaceHints(hintSeed, contextRoute, collectionNames)];
|
|
2067
2072
|
case 4:
|
|
2068
|
-
surfaceHints =
|
|
2073
|
+
surfaceHints = _21.sent();
|
|
2069
2074
|
methodHints = surfaceHints.methodHints;
|
|
2070
2075
|
publicationHints = surfaceHints.publicationHints;
|
|
2071
2076
|
if (surfaceHints.collectionHints.length) {
|
|
@@ -2073,7 +2078,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2073
2078
|
}
|
|
2074
2079
|
return [3 /*break*/, 6];
|
|
2075
2080
|
case 5:
|
|
2076
|
-
_a =
|
|
2081
|
+
_a = _21.sent();
|
|
2077
2082
|
collectionHints = [];
|
|
2078
2083
|
collectionRanking = collectionRanking || ((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens)
|
|
2079
2084
|
? buildCollectionRankingDebugFromTokens(collectionTokenization.expandedTokens || [], [], 0)
|
|
@@ -2137,28 +2142,104 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2137
2142
|
recentToolError: recentToolError,
|
|
2138
2143
|
changeHistoryFastPathBypassedReason: changeHistoryFastPathBypassedReason
|
|
2139
2144
|
});
|
|
2140
|
-
|
|
2145
|
+
scoredAppDataIntentCandidates = rankAssistantAppDataIntentCandidates(message, collectionNames, input.id_app, { includeUnscored: false, limit: 3 });
|
|
2146
|
+
shouldAttemptAppDataClassifier = resolveAssistantDeterministicHeuristicEnabled(AI_ASSISTANT_HEURISTIC_ID_APP_DATA_INTENT, input.id_app) && (dataQuestion
|
|
2147
|
+
|| scoredAppDataIntentCandidates.length > 0
|
|
2148
|
+
|| isAssistantStrongDataQuestion(message));
|
|
2149
|
+
if (!(shouldAttemptAppDataClassifier && hasRunBudget('Planning: data request classifier', 500))) return [3 /*break*/, 13];
|
|
2150
|
+
return [4 /*yield*/, classifyAssistantAppDataRequest({
|
|
2151
|
+
message: message,
|
|
2152
|
+
appId: input.id_app,
|
|
2153
|
+
collectionNames: collectionNames,
|
|
2154
|
+
dateWindow: resolveAssistantDataIntentDateWindow(message),
|
|
2155
|
+
config: input.config
|
|
2156
|
+
})];
|
|
2157
|
+
case 7:
|
|
2158
|
+
classifierResult = _21.sent();
|
|
2159
|
+
if (!classifierResult) return [3 /*break*/, 12];
|
|
2160
|
+
appDataRequestClassifierDebug = classifierResult.debug || null;
|
|
2161
|
+
appDataRequestClassifierIntent = classifierResult.intent || null;
|
|
2162
|
+
appDataRequestClassifierUnderstanding = classifierResult.understanding || null;
|
|
2163
|
+
recordStep('Planning: data request classifier', {
|
|
2164
|
+
enabled: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.enabled,
|
|
2165
|
+
attempted: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.attempted,
|
|
2166
|
+
succeeded: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.succeeded,
|
|
2167
|
+
model: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.model,
|
|
2168
|
+
durationMs: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.durationMs,
|
|
2169
|
+
intentId: (appDataRequestClassifierIntent === null || appDataRequestClassifierIntent === void 0 ? void 0 : appDataRequestClassifierIntent.id) || (appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.intentId),
|
|
2170
|
+
requestedBreakdowns: ((_j = appDataRequestClassifierUnderstanding === null || appDataRequestClassifierUnderstanding === void 0 ? void 0 : appDataRequestClassifierUnderstanding.contract) === null || _j === void 0 ? void 0 : _j.requested_breakdowns) || undefined,
|
|
2171
|
+
reason: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.reason,
|
|
2172
|
+
error: appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.error
|
|
2173
|
+
});
|
|
2174
|
+
if (!((_k = classifierResult.usage) === null || _k === void 0 ? void 0 : _k.totalTokens)) return [3 /*break*/, 12];
|
|
2175
|
+
_21.label = 8;
|
|
2176
|
+
case 8:
|
|
2177
|
+
_21.trys.push([8, 11, , 12]);
|
|
2178
|
+
return [4 /*yield*/, resolveClientId(conversation, input.id_client, context === null || context === void 0 ? void 0 : context.id_user)];
|
|
2179
|
+
case 9:
|
|
2180
|
+
classifierUsageClientId = _21.sent();
|
|
2181
|
+
return [4 /*yield*/, (0, openai_usage_ledger_manager_1.recordOpenAIUsage)(buildAssistantAIRunUsageLedgerEntry({
|
|
2182
|
+
idClient: classifierUsageClientId || '',
|
|
2183
|
+
model: classifierResult.usage.model || (appDataRequestClassifierDebug === null || appDataRequestClassifierDebug === void 0 ? void 0 : appDataRequestClassifierDebug.model) || resolveAssistantDataRequestClassifierModel(input.config),
|
|
2184
|
+
inputTokens: classifierResult.usage.inputTokens || 0,
|
|
2185
|
+
outputTokens: classifierResult.usage.outputTokens || 0,
|
|
2186
|
+
totalTokens: classifierResult.usage.totalTokens || 0,
|
|
2187
|
+
category: 'ai-terminal-classifier',
|
|
2188
|
+
conversationId: conversation._id,
|
|
2189
|
+
requestId: requestId || classifierResult.usage.requestId || undefined,
|
|
2190
|
+
usagePhase: 'data_request_classifier',
|
|
2191
|
+
idApp: String((conversation === null || conversation === void 0 ? void 0 : conversation.id_app) || ''),
|
|
2192
|
+
metadata: {
|
|
2193
|
+
conversationId: conversation._id,
|
|
2194
|
+
requestId: requestId || '',
|
|
2195
|
+
classifierRequestId: classifierResult.usage.requestId || '',
|
|
2196
|
+
intentId: (appDataRequestClassifierIntent === null || appDataRequestClassifierIntent === void 0 ? void 0 : appDataRequestClassifierIntent.id) || ''
|
|
2197
|
+
}
|
|
2198
|
+
}))];
|
|
2199
|
+
case 10:
|
|
2200
|
+
_21.sent();
|
|
2201
|
+
return [3 /*break*/, 12];
|
|
2202
|
+
case 11:
|
|
2203
|
+
usageError_1 = _21.sent();
|
|
2204
|
+
console.error(new Date(), 'Failed to record AI data request classifier usage', usageError_1);
|
|
2205
|
+
return [3 /*break*/, 12];
|
|
2206
|
+
case 12: return [3 /*break*/, 14];
|
|
2207
|
+
case 13:
|
|
2208
|
+
if (shouldAttemptAppDataClassifier) {
|
|
2209
|
+
appDataRequestClassifierDebug = {
|
|
2210
|
+
enabled: resolveAssistantDataRequestClassifierEnabled(input.config),
|
|
2211
|
+
attempted: false,
|
|
2212
|
+
reason: 'run_budget_exhausted'
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2215
|
+
_21.label = 14;
|
|
2216
|
+
case 14:
|
|
2217
|
+
heuristicDirectivePrecomputed = buildAssistantHeuristicDirective(message, collectionHints, collectionNames, input.id_app, {
|
|
2218
|
+
appDataIntent: appDataRequestClassifierIntent,
|
|
2219
|
+
appDataRequestUnderstanding: appDataRequestClassifierUnderstanding,
|
|
2220
|
+
appDataRequestClassifier: appDataRequestClassifierDebug
|
|
2221
|
+
});
|
|
2141
2222
|
hasDeterministicHeuristicFastPath = isAssistantExecutableDirective(heuristicDirectivePrecomputed)
|
|
2142
2223
|
&& isAssistantDeterministicHeuristicDirective(heuristicDirectivePrecomputed);
|
|
2143
2224
|
if (hasDeterministicHeuristicFastPath && !dataQuestion) {
|
|
2144
2225
|
requestClassification = __assign(__assign({}, requestClassification), { type: requestClassification.type === 'navigation' ? 'mixed' : 'data', dataQuestion: true, source: requestClassification.type === 'navigation' ? 'merged' : 'heuristic' });
|
|
2145
2226
|
dataQuestion = true;
|
|
2146
2227
|
recordStep('Planning: app data intent classified request', {
|
|
2147
|
-
collection: normalizeOptionalString((
|
|
2228
|
+
collection: normalizeOptionalString((_l = heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.payload) === null || _l === void 0 ? void 0 : _l.collection) || undefined,
|
|
2148
2229
|
heuristic: normalizeOptionalString(heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.rawLine) || undefined
|
|
2149
2230
|
});
|
|
2150
2231
|
}
|
|
2151
2232
|
if (hasDeterministicHeuristicFastPath) {
|
|
2152
2233
|
recordStep('Planning: heuristic directive fast path', {
|
|
2153
2234
|
type: heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.type,
|
|
2154
|
-
collection: normalizeOptionalString((
|
|
2235
|
+
collection: normalizeOptionalString((_m = heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.payload) === null || _m === void 0 ? void 0 : _m.collection) || undefined,
|
|
2155
2236
|
heuristic: normalizeOptionalString(heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.rawLine) || undefined
|
|
2156
2237
|
});
|
|
2157
2238
|
}
|
|
2158
2239
|
prompt_1 = buildAssistantCodexPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, assistantSystemPrompt);
|
|
2159
2240
|
return [4 /*yield*/, resolveAssistantWorkspaceRoot()];
|
|
2160
|
-
case
|
|
2161
|
-
workspaceRoot =
|
|
2241
|
+
case 15:
|
|
2242
|
+
workspaceRoot = _21.sent();
|
|
2162
2243
|
codexConfig = resolveCodexSettings({
|
|
2163
2244
|
model: codexModel,
|
|
2164
2245
|
fallbackModels: codexFallbackModels
|
|
@@ -2191,7 +2272,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2191
2272
|
hasDeterministicHeuristicFastPath: hasDeterministicHeuristicFastPath
|
|
2192
2273
|
});
|
|
2193
2274
|
plannerBudgetAvailable = !shouldRunPlanner || hasRunBudget('Planning: planner');
|
|
2194
|
-
if (!(shouldRunPlanner && plannerBudgetAvailable)) return [3 /*break*/,
|
|
2275
|
+
if (!(shouldRunPlanner && plannerBudgetAvailable)) return [3 /*break*/, 20];
|
|
2195
2276
|
plannerUsed = true;
|
|
2196
2277
|
recordStep('Planning: planner prompt');
|
|
2197
2278
|
plannerPrompt = buildAssistantPlannerPrompt({
|
|
@@ -2207,24 +2288,24 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2207
2288
|
publicationHints: publicationHints,
|
|
2208
2289
|
inputClientId: input.id_client
|
|
2209
2290
|
});
|
|
2210
|
-
|
|
2211
|
-
case
|
|
2212
|
-
|
|
2291
|
+
_21.label = 16;
|
|
2292
|
+
case 16:
|
|
2293
|
+
_21.trys.push([16, 18, , 19]);
|
|
2213
2294
|
plannerStart = Date.now();
|
|
2214
2295
|
return [4 /*yield*/, runCodexInWorkerThread(plannerPrompt, applyCodexStageBudget(plannerRunOptions), codexConfig, streamProgress)];
|
|
2215
|
-
case
|
|
2216
|
-
plannerRaw =
|
|
2296
|
+
case 17:
|
|
2297
|
+
plannerRaw = _21.sent();
|
|
2217
2298
|
accumulateCodexUsage(plannerPrompt, plannerRaw);
|
|
2218
2299
|
timingBreakdown.plannerMs = Date.now() - plannerStart;
|
|
2219
2300
|
plannerOutput = parseJsonObject(plannerRaw);
|
|
2220
2301
|
recordStep('Planning: planner result', { parsed: !!plannerOutput });
|
|
2221
|
-
return [3 /*break*/,
|
|
2222
|
-
case
|
|
2223
|
-
_b =
|
|
2302
|
+
return [3 /*break*/, 19];
|
|
2303
|
+
case 18:
|
|
2304
|
+
_b = _21.sent();
|
|
2224
2305
|
recordStep('Planning: planner result', { parsed: false });
|
|
2225
|
-
return [3 /*break*/,
|
|
2226
|
-
case
|
|
2227
|
-
case
|
|
2306
|
+
return [3 /*break*/, 19];
|
|
2307
|
+
case 19: return [3 /*break*/, 21];
|
|
2308
|
+
case 20:
|
|
2228
2309
|
if (plannerEnabled) {
|
|
2229
2310
|
if (hasDeterministicHeuristicFastPath) {
|
|
2230
2311
|
plannerSkipReason = 'heuristic_directive_fast_path';
|
|
@@ -2240,8 +2321,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2240
2321
|
}
|
|
2241
2322
|
recordStep('Planning: planner skipped', { reason: plannerSkipReason });
|
|
2242
2323
|
}
|
|
2243
|
-
|
|
2244
|
-
case
|
|
2324
|
+
_21.label = 21;
|
|
2325
|
+
case 21:
|
|
2245
2326
|
requestClassification = classifyAssistantRequestType(message, plannerOutput || undefined);
|
|
2246
2327
|
if (hasDeterministicHeuristicFastPath && !requestClassification.dataQuestion) {
|
|
2247
2328
|
requestClassification = __assign(__assign({}, requestClassification), { type: requestClassification.type === 'navigation' ? 'mixed' : 'data', dataQuestion: true, source: requestClassification.type === 'navigation' ? 'merged' : 'heuristic' });
|
|
@@ -2276,7 +2357,11 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2276
2357
|
directiveText = '';
|
|
2277
2358
|
directive = null;
|
|
2278
2359
|
heuristicDirectiveFastPath = dataQuestion
|
|
2279
|
-
? (heuristicDirectivePrecomputed || buildAssistantHeuristicDirective(message, collectionHints, collectionNames, input.id_app
|
|
2360
|
+
? (heuristicDirectivePrecomputed || buildAssistantHeuristicDirective(message, collectionHints, collectionNames, input.id_app, {
|
|
2361
|
+
appDataIntent: appDataRequestClassifierIntent,
|
|
2362
|
+
appDataRequestUnderstanding: appDataRequestClassifierUnderstanding,
|
|
2363
|
+
appDataRequestClassifier: appDataRequestClassifierDebug
|
|
2364
|
+
}))
|
|
2280
2365
|
: null;
|
|
2281
2366
|
if (dataQuestion
|
|
2282
2367
|
&& isAssistantExecutableDirective(heuristicDirectiveFastPath)
|
|
@@ -2285,27 +2370,27 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2285
2370
|
directiveSource = 'forced';
|
|
2286
2371
|
lastDirective = heuristicDirectiveFastPath;
|
|
2287
2372
|
usedDeterministicHeuristicFastPath = true;
|
|
2288
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2373
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_o = directive.payload) === null || _o === void 0 ? void 0 : _o.collection) || '');
|
|
2289
2374
|
recordStep('Directive resolved', {
|
|
2290
2375
|
source: directiveSource,
|
|
2291
2376
|
type: directive.type,
|
|
2292
|
-
collection: normalizeOptionalString((
|
|
2293
|
-
permissionView: normalizeOptionalString((
|
|
2377
|
+
collection: normalizeOptionalString((_p = directive.payload) === null || _p === void 0 ? void 0 : _p.collection) || undefined,
|
|
2378
|
+
permissionView: normalizeOptionalString((_q = directive.payload) === null || _q === void 0 ? void 0 : _q.permissionView) || undefined,
|
|
2294
2379
|
reportStyle: 'heuristic_fast_path',
|
|
2295
2380
|
timeGrain: requestedTimeGrain || undefined
|
|
2296
2381
|
});
|
|
2297
2382
|
}
|
|
2298
|
-
if (!(dataQuestion && !directive)) return [3 /*break*/,
|
|
2383
|
+
if (!(dataQuestion && !directive)) return [3 /*break*/, 25];
|
|
2299
2384
|
recordStep('Directive: determine tool', { type: 'data-question' });
|
|
2300
2385
|
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode, assistantSystemPrompt);
|
|
2301
|
-
if (!hasRunBudget('Directive: determine tool')) return [3 /*break*/,
|
|
2302
|
-
|
|
2303
|
-
case
|
|
2304
|
-
|
|
2386
|
+
if (!hasRunBudget('Directive: determine tool')) return [3 /*break*/, 25];
|
|
2387
|
+
_21.label = 22;
|
|
2388
|
+
case 22:
|
|
2389
|
+
_21.trys.push([22, 24, , 25]);
|
|
2305
2390
|
directiveStart = Date.now();
|
|
2306
2391
|
return [4 /*yield*/, runCodexInWorkerThread(directivePrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2307
|
-
case
|
|
2308
|
-
directiveText =
|
|
2392
|
+
case 23:
|
|
2393
|
+
directiveText = _21.sent();
|
|
2309
2394
|
accumulateCodexUsage(directivePrompt, directiveText);
|
|
2310
2395
|
timingBreakdown.directiveMs = Date.now() - directiveStart;
|
|
2311
2396
|
forcedDirective = extractAssistantMongoDirective(directiveText);
|
|
@@ -2313,32 +2398,32 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2313
2398
|
directive = forcedDirective;
|
|
2314
2399
|
directiveSource = 'model';
|
|
2315
2400
|
lastDirective = forcedDirective;
|
|
2316
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2401
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_r = directive.payload) === null || _r === void 0 ? void 0 : _r.collection) || '');
|
|
2317
2402
|
recordStep('Directive resolved', {
|
|
2318
2403
|
source: directiveSource,
|
|
2319
2404
|
type: directive.type,
|
|
2320
|
-
collection: normalizeOptionalString((
|
|
2321
|
-
permissionView: normalizeOptionalString((
|
|
2405
|
+
collection: normalizeOptionalString((_s = directive.payload) === null || _s === void 0 ? void 0 : _s.collection) || undefined,
|
|
2406
|
+
permissionView: normalizeOptionalString((_t = directive.payload) === null || _t === void 0 ? void 0 : _t.permissionView) || undefined
|
|
2322
2407
|
});
|
|
2323
2408
|
}
|
|
2324
|
-
return [3 /*break*/,
|
|
2325
|
-
case
|
|
2326
|
-
error_2 =
|
|
2409
|
+
return [3 /*break*/, 25];
|
|
2410
|
+
case 24:
|
|
2411
|
+
error_2 = _21.sent();
|
|
2327
2412
|
recordStep('Directive: determine tool failed', {
|
|
2328
2413
|
message: normalizeOptionalString(error_2 === null || error_2 === void 0 ? void 0 : error_2.message) || 'Unknown error'
|
|
2329
2414
|
});
|
|
2330
|
-
return [3 /*break*/,
|
|
2331
|
-
case
|
|
2332
|
-
if (!(!directive && !dataQuestion)) return [3 /*break*/,
|
|
2415
|
+
return [3 /*break*/, 25];
|
|
2416
|
+
case 25:
|
|
2417
|
+
if (!(!directive && !dataQuestion)) return [3 /*break*/, 29];
|
|
2333
2418
|
recordStep('Response: draft initial answer', { mode: 'full' });
|
|
2334
|
-
if (!hasRunBudget('Response: initial draft')) return [3 /*break*/,
|
|
2335
|
-
|
|
2336
|
-
case
|
|
2337
|
-
|
|
2419
|
+
if (!hasRunBudget('Response: initial draft')) return [3 /*break*/, 29];
|
|
2420
|
+
_21.label = 26;
|
|
2421
|
+
case 26:
|
|
2422
|
+
_21.trys.push([26, 28, , 29]);
|
|
2338
2423
|
initialStart = Date.now();
|
|
2339
2424
|
return [4 /*yield*/, runCodexInWorkerThread(prompt_1, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2340
|
-
case
|
|
2341
|
-
responseText =
|
|
2425
|
+
case 27:
|
|
2426
|
+
responseText = _21.sent();
|
|
2342
2427
|
accumulateCodexUsage(prompt_1, responseText);
|
|
2343
2428
|
timingBreakdown.initialResponseMs = Date.now() - initialStart;
|
|
2344
2429
|
extractedDirective = extractAssistantMongoDirective(responseText);
|
|
@@ -2346,33 +2431,33 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2346
2431
|
if (directive) {
|
|
2347
2432
|
directiveSource = 'model';
|
|
2348
2433
|
lastDirective = directive;
|
|
2349
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2434
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_u = directive.payload) === null || _u === void 0 ? void 0 : _u.collection) || '');
|
|
2350
2435
|
recordStep('Directive resolved', {
|
|
2351
2436
|
source: directiveSource,
|
|
2352
2437
|
type: directive.type,
|
|
2353
|
-
collection: normalizeOptionalString((
|
|
2354
|
-
permissionView: normalizeOptionalString((
|
|
2438
|
+
collection: normalizeOptionalString((_v = directive.payload) === null || _v === void 0 ? void 0 : _v.collection) || undefined,
|
|
2439
|
+
permissionView: normalizeOptionalString((_w = directive.payload) === null || _w === void 0 ? void 0 : _w.permissionView) || undefined
|
|
2355
2440
|
});
|
|
2356
2441
|
}
|
|
2357
|
-
return [3 /*break*/,
|
|
2358
|
-
case
|
|
2359
|
-
error_3 =
|
|
2442
|
+
return [3 /*break*/, 29];
|
|
2443
|
+
case 28:
|
|
2444
|
+
error_3 = _21.sent();
|
|
2360
2445
|
recordStep('Response: initial draft failed', {
|
|
2361
2446
|
message: normalizeOptionalString(error_3 === null || error_3 === void 0 ? void 0 : error_3.message) || 'Unknown error'
|
|
2362
2447
|
});
|
|
2363
|
-
return [3 /*break*/,
|
|
2364
|
-
case
|
|
2365
|
-
if (!(!directive && dataQuestion)) return [3 /*break*/,
|
|
2448
|
+
return [3 /*break*/, 29];
|
|
2449
|
+
case 29:
|
|
2450
|
+
if (!(!directive && dataQuestion)) return [3 /*break*/, 33];
|
|
2366
2451
|
recordStep('Directive: forced retry', { mode: 'directive-only' });
|
|
2367
2452
|
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode, assistantSystemPrompt);
|
|
2368
|
-
if (!hasRunBudget('Directive: forced retry')) return [3 /*break*/,
|
|
2369
|
-
|
|
2370
|
-
case
|
|
2371
|
-
|
|
2453
|
+
if (!hasRunBudget('Directive: forced retry')) return [3 /*break*/, 33];
|
|
2454
|
+
_21.label = 30;
|
|
2455
|
+
case 30:
|
|
2456
|
+
_21.trys.push([30, 32, , 33]);
|
|
2372
2457
|
forcedStart = Date.now();
|
|
2373
2458
|
return [4 /*yield*/, runCodexInWorkerThread(directivePrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2374
|
-
case
|
|
2375
|
-
directiveText =
|
|
2459
|
+
case 31:
|
|
2460
|
+
directiveText = _21.sent();
|
|
2376
2461
|
accumulateCodexUsage(directivePrompt, directiveText);
|
|
2377
2462
|
timingBreakdown.forcedDirectiveMs = Date.now() - forcedStart;
|
|
2378
2463
|
forcedDirective = extractAssistantMongoDirective(directiveText);
|
|
@@ -2380,26 +2465,26 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2380
2465
|
directive = forcedDirective;
|
|
2381
2466
|
directiveSource = 'forced';
|
|
2382
2467
|
lastDirective = forcedDirective;
|
|
2383
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2468
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_x = directive.payload) === null || _x === void 0 ? void 0 : _x.collection) || '');
|
|
2384
2469
|
recordStep('Directive resolved', {
|
|
2385
2470
|
source: directiveSource,
|
|
2386
2471
|
type: directive.type,
|
|
2387
|
-
collection: normalizeOptionalString((
|
|
2388
|
-
permissionView: normalizeOptionalString((
|
|
2472
|
+
collection: normalizeOptionalString((_y = directive.payload) === null || _y === void 0 ? void 0 : _y.collection) || undefined,
|
|
2473
|
+
permissionView: normalizeOptionalString((_z = directive.payload) === null || _z === void 0 ? void 0 : _z.permissionView) || undefined
|
|
2389
2474
|
});
|
|
2390
2475
|
}
|
|
2391
|
-
return [3 /*break*/,
|
|
2392
|
-
case
|
|
2393
|
-
error_4 =
|
|
2476
|
+
return [3 /*break*/, 33];
|
|
2477
|
+
case 32:
|
|
2478
|
+
error_4 = _21.sent();
|
|
2394
2479
|
recordStep('Directive: forced retry failed', {
|
|
2395
2480
|
message: normalizeOptionalString(error_4 === null || error_4 === void 0 ? void 0 : error_4.message) || 'Unknown error'
|
|
2396
2481
|
});
|
|
2397
|
-
return [3 /*break*/,
|
|
2398
|
-
case
|
|
2482
|
+
return [3 /*break*/, 33];
|
|
2483
|
+
case 33:
|
|
2399
2484
|
if (!(directive
|
|
2400
2485
|
&& enforceDatedDirective
|
|
2401
2486
|
&& !isAssistantDeterministicHeuristicDirective(directive)
|
|
2402
|
-
&& !isAssistantDirectiveDated(directive))) return [3 /*break*/,
|
|
2487
|
+
&& !isAssistantDirectiveDated(directive))) return [3 /*break*/, 37];
|
|
2403
2488
|
recordStep('Directive: dated retry', {
|
|
2404
2489
|
currentType: directive.type,
|
|
2405
2490
|
timeGrain: requestedTimeGrain || undefined
|
|
@@ -2411,14 +2496,14 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2411
2496
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2412
2497
|
strict: true
|
|
2413
2498
|
}), 'aggregate_only', assistantSystemPrompt);
|
|
2414
|
-
if (!hasRunBudget('Directive: dated retry')) return [3 /*break*/,
|
|
2415
|
-
|
|
2416
|
-
case
|
|
2417
|
-
|
|
2499
|
+
if (!hasRunBudget('Directive: dated retry')) return [3 /*break*/, 37];
|
|
2500
|
+
_21.label = 34;
|
|
2501
|
+
case 34:
|
|
2502
|
+
_21.trys.push([34, 36, , 37]);
|
|
2418
2503
|
strictStart = Date.now();
|
|
2419
2504
|
return [4 /*yield*/, runCodexInWorkerThread(strictDirectivePrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2420
|
-
case
|
|
2421
|
-
strictDirectiveText =
|
|
2505
|
+
case 35:
|
|
2506
|
+
strictDirectiveText = _21.sent();
|
|
2422
2507
|
accumulateCodexUsage(strictDirectivePrompt, strictDirectiveText);
|
|
2423
2508
|
timingBreakdown.forcedDirectiveMs += Date.now() - strictStart;
|
|
2424
2509
|
strictDirective = extractAssistantMongoDirective(strictDirectiveText);
|
|
@@ -2429,28 +2514,28 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2429
2514
|
directiveSource = 'forced';
|
|
2430
2515
|
lastDirective = strictDirective;
|
|
2431
2516
|
datedDirectiveRetryUsed = true;
|
|
2432
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2517
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_0 = directive.payload) === null || _0 === void 0 ? void 0 : _0.collection) || '');
|
|
2433
2518
|
recordStep('Directive resolved', {
|
|
2434
2519
|
source: directiveSource,
|
|
2435
2520
|
type: directive.type,
|
|
2436
|
-
collection: normalizeOptionalString((
|
|
2437
|
-
permissionView: normalizeOptionalString((
|
|
2521
|
+
collection: normalizeOptionalString((_1 = directive.payload) === null || _1 === void 0 ? void 0 : _1.collection) || undefined,
|
|
2522
|
+
permissionView: normalizeOptionalString((_2 = directive.payload) === null || _2 === void 0 ? void 0 : _2.permissionView) || undefined,
|
|
2438
2523
|
reportStyle: strictDirectiveIsDated ? 'dated' : 'aggregate_fallback',
|
|
2439
2524
|
timeGrain: requestedTimeGrain || undefined
|
|
2440
2525
|
});
|
|
2441
2526
|
}
|
|
2442
|
-
return [3 /*break*/,
|
|
2443
|
-
case
|
|
2444
|
-
error_5 =
|
|
2527
|
+
return [3 /*break*/, 37];
|
|
2528
|
+
case 36:
|
|
2529
|
+
error_5 = _21.sent();
|
|
2445
2530
|
recordStep('Directive: dated retry failed', {
|
|
2446
2531
|
message: normalizeOptionalString(error_5 === null || error_5 === void 0 ? void 0 : error_5.message) || 'Unknown error'
|
|
2447
2532
|
});
|
|
2448
|
-
return [3 /*break*/,
|
|
2449
|
-
case
|
|
2533
|
+
return [3 /*break*/, 37];
|
|
2534
|
+
case 37:
|
|
2450
2535
|
if (!(directive
|
|
2451
2536
|
&& enforceDatedDirective
|
|
2452
2537
|
&& !isAssistantDeterministicHeuristicDirective(directive)
|
|
2453
|
-
&& directive.type === 'read')) return [3 /*break*/,
|
|
2538
|
+
&& directive.type === 'read')) return [3 /*break*/, 41];
|
|
2454
2539
|
recordStep('Directive: dated guard retry', {
|
|
2455
2540
|
currentType: directive.type,
|
|
2456
2541
|
timeGrain: requestedTimeGrain || undefined
|
|
@@ -2462,14 +2547,14 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2462
2547
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2463
2548
|
strict: true
|
|
2464
2549
|
}), 'aggregate_only', assistantSystemPrompt);
|
|
2465
|
-
if (!hasRunBudget('Directive: dated guard retry')) return [3 /*break*/,
|
|
2466
|
-
|
|
2467
|
-
case
|
|
2468
|
-
|
|
2550
|
+
if (!hasRunBudget('Directive: dated guard retry')) return [3 /*break*/, 41];
|
|
2551
|
+
_21.label = 38;
|
|
2552
|
+
case 38:
|
|
2553
|
+
_21.trys.push([38, 40, , 41]);
|
|
2469
2554
|
guardStart = Date.now();
|
|
2470
2555
|
return [4 /*yield*/, runCodexInWorkerThread(guardDirectivePrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2471
|
-
case
|
|
2472
|
-
guardDirectiveText =
|
|
2556
|
+
case 39:
|
|
2557
|
+
guardDirectiveText = _21.sent();
|
|
2473
2558
|
accumulateCodexUsage(guardDirectivePrompt, guardDirectiveText);
|
|
2474
2559
|
timingBreakdown.forcedDirectiveMs += Date.now() - guardStart;
|
|
2475
2560
|
guardDirective = extractAssistantMongoDirective(guardDirectiveText);
|
|
@@ -2478,28 +2563,28 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2478
2563
|
directiveSource = 'forced';
|
|
2479
2564
|
lastDirective = guardDirective;
|
|
2480
2565
|
datedDirectiveRetryUsed = true;
|
|
2481
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2566
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_3 = directive.payload) === null || _3 === void 0 ? void 0 : _3.collection) || '');
|
|
2482
2567
|
recordStep('Directive resolved', {
|
|
2483
2568
|
source: directiveSource,
|
|
2484
2569
|
type: directive.type,
|
|
2485
|
-
collection: normalizeOptionalString((
|
|
2486
|
-
permissionView: normalizeOptionalString((
|
|
2570
|
+
collection: normalizeOptionalString((_4 = directive.payload) === null || _4 === void 0 ? void 0 : _4.collection) || undefined,
|
|
2571
|
+
permissionView: normalizeOptionalString((_5 = directive.payload) === null || _5 === void 0 ? void 0 : _5.permissionView) || undefined,
|
|
2487
2572
|
reportStyle: isAssistantDirectiveDated(guardDirective) ? 'dated' : 'aggregate_fallback',
|
|
2488
2573
|
timeGrain: requestedTimeGrain || undefined
|
|
2489
2574
|
});
|
|
2490
2575
|
}
|
|
2491
|
-
return [3 /*break*/,
|
|
2492
|
-
case
|
|
2493
|
-
error_6 =
|
|
2576
|
+
return [3 /*break*/, 41];
|
|
2577
|
+
case 40:
|
|
2578
|
+
error_6 = _21.sent();
|
|
2494
2579
|
recordStep('Directive: dated guard retry failed', {
|
|
2495
2580
|
message: normalizeOptionalString(error_6 === null || error_6 === void 0 ? void 0 : error_6.message) || 'Unknown error'
|
|
2496
2581
|
});
|
|
2497
|
-
return [3 /*break*/,
|
|
2498
|
-
case
|
|
2582
|
+
return [3 /*break*/, 41];
|
|
2583
|
+
case 41:
|
|
2499
2584
|
if (!(directive
|
|
2500
2585
|
&& enforceGroupedDirective
|
|
2501
2586
|
&& !isAssistantDeterministicHeuristicDirective(directive)
|
|
2502
|
-
&& !isAssistantDirectiveGrouped(directive))) return [3 /*break*/,
|
|
2587
|
+
&& !isAssistantDirectiveGrouped(directive))) return [3 /*break*/, 45];
|
|
2503
2588
|
recordStep('Directive: grouped guard retry', {
|
|
2504
2589
|
currentType: directive.type,
|
|
2505
2590
|
breakdownDimensions: requestedBreakdownDimensions.length ? requestedBreakdownDimensions : undefined
|
|
@@ -2511,14 +2596,14 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2511
2596
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2512
2597
|
strict: true
|
|
2513
2598
|
}), 'aggregate_only', assistantSystemPrompt);
|
|
2514
|
-
if (!hasRunBudget('Directive: grouped guard retry')) return [3 /*break*/,
|
|
2515
|
-
|
|
2516
|
-
case
|
|
2517
|
-
|
|
2599
|
+
if (!hasRunBudget('Directive: grouped guard retry')) return [3 /*break*/, 45];
|
|
2600
|
+
_21.label = 42;
|
|
2601
|
+
case 42:
|
|
2602
|
+
_21.trys.push([42, 44, , 45]);
|
|
2518
2603
|
groupedStart = Date.now();
|
|
2519
2604
|
return [4 /*yield*/, runCodexInWorkerThread(groupedDirectivePrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2520
|
-
case
|
|
2521
|
-
groupedDirectiveText =
|
|
2605
|
+
case 43:
|
|
2606
|
+
groupedDirectiveText = _21.sent();
|
|
2522
2607
|
accumulateCodexUsage(groupedDirectivePrompt, groupedDirectiveText);
|
|
2523
2608
|
timingBreakdown.forcedDirectiveMs += Date.now() - groupedStart;
|
|
2524
2609
|
groupedDirective = extractAssistantMongoDirective(groupedDirectiveText);
|
|
@@ -2527,12 +2612,12 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2527
2612
|
directiveSource = 'forced';
|
|
2528
2613
|
lastDirective = groupedDirective;
|
|
2529
2614
|
datedDirectiveRetryUsed = true;
|
|
2530
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2615
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_6 = directive.payload) === null || _6 === void 0 ? void 0 : _6.collection) || '');
|
|
2531
2616
|
recordStep('Directive resolved', {
|
|
2532
2617
|
source: directiveSource,
|
|
2533
2618
|
type: directive.type,
|
|
2534
|
-
collection: normalizeOptionalString((
|
|
2535
|
-
permissionView: normalizeOptionalString((
|
|
2619
|
+
collection: normalizeOptionalString((_7 = directive.payload) === null || _7 === void 0 ? void 0 : _7.collection) || undefined,
|
|
2620
|
+
permissionView: normalizeOptionalString((_8 = directive.payload) === null || _8 === void 0 ? void 0 : _8.permissionView) || undefined,
|
|
2536
2621
|
reportStyle: isAssistantDirectiveDated(groupedDirective)
|
|
2537
2622
|
? 'dated'
|
|
2538
2623
|
: 'grouped',
|
|
@@ -2540,16 +2625,20 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2540
2625
|
timeGrain: requestedTimeGrain || undefined
|
|
2541
2626
|
});
|
|
2542
2627
|
}
|
|
2543
|
-
return [3 /*break*/,
|
|
2544
|
-
case
|
|
2545
|
-
error_7 =
|
|
2628
|
+
return [3 /*break*/, 45];
|
|
2629
|
+
case 44:
|
|
2630
|
+
error_7 = _21.sent();
|
|
2546
2631
|
recordStep('Directive: grouped guard retry failed', {
|
|
2547
2632
|
message: normalizeOptionalString(error_7 === null || error_7 === void 0 ? void 0 : error_7.message) || 'Unknown error'
|
|
2548
2633
|
});
|
|
2549
|
-
return [3 /*break*/,
|
|
2550
|
-
case
|
|
2634
|
+
return [3 /*break*/, 45];
|
|
2635
|
+
case 45:
|
|
2551
2636
|
if (!directive && dataQuestion) {
|
|
2552
|
-
heuristicDirective = buildAssistantHeuristicDirective(message, collectionHints, collectionNames, input.id_app
|
|
2637
|
+
heuristicDirective = buildAssistantHeuristicDirective(message, collectionHints, collectionNames, input.id_app, {
|
|
2638
|
+
appDataIntent: appDataRequestClassifierIntent,
|
|
2639
|
+
appDataRequestUnderstanding: appDataRequestClassifierUnderstanding,
|
|
2640
|
+
appDataRequestClassifier: appDataRequestClassifierDebug
|
|
2641
|
+
});
|
|
2553
2642
|
if (isAssistantExecutableDirective(heuristicDirective)) {
|
|
2554
2643
|
directive = heuristicDirective;
|
|
2555
2644
|
directiveSource = 'forced';
|
|
@@ -2557,21 +2646,21 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2557
2646
|
recordStep('Directive resolved', {
|
|
2558
2647
|
source: directiveSource,
|
|
2559
2648
|
type: directive.type,
|
|
2560
|
-
collection: normalizeOptionalString((
|
|
2561
|
-
permissionView: normalizeOptionalString((
|
|
2649
|
+
collection: normalizeOptionalString((_9 = directive.payload) === null || _9 === void 0 ? void 0 : _9.collection) || undefined,
|
|
2650
|
+
permissionView: normalizeOptionalString((_10 = directive.payload) === null || _10 === void 0 ? void 0 : _10.permissionView) || undefined,
|
|
2562
2651
|
reportStyle: 'heuristic_fallback'
|
|
2563
2652
|
});
|
|
2564
2653
|
}
|
|
2565
2654
|
}
|
|
2566
2655
|
if (directive) {
|
|
2567
|
-
requestedCollection = normalizeOptionalString((
|
|
2656
|
+
requestedCollection = normalizeOptionalString((_11 = directive.payload) === null || _11 === void 0 ? void 0 : _11.collection);
|
|
2568
2657
|
allowCollectionOverride = !isAssistantDeterministicHeuristicDirective(directive);
|
|
2569
2658
|
collectionOverride = allowCollectionOverride
|
|
2570
2659
|
? resolveCollectionOverrideWithContext({
|
|
2571
2660
|
message: message,
|
|
2572
2661
|
collectionRanking: collectionRanking,
|
|
2573
2662
|
requestedCollection: requestedCollection,
|
|
2574
|
-
permissionView: normalizeOptionalString((
|
|
2663
|
+
permissionView: normalizeOptionalString((_12 = directive.payload) === null || _12 === void 0 ? void 0 : _12.permissionView) || contextRoute,
|
|
2575
2664
|
collectionNames: collectionNames,
|
|
2576
2665
|
collectionHints: collectionHints,
|
|
2577
2666
|
appId: input.id_app
|
|
@@ -2596,7 +2685,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2596
2685
|
isSuperAdmin: isSuperAdmin,
|
|
2597
2686
|
message: message
|
|
2598
2687
|
});
|
|
2599
|
-
if (!deniedModuleByIntent) return [3 /*break*/,
|
|
2688
|
+
if (!deniedModuleByIntent) return [3 /*break*/, 46];
|
|
2600
2689
|
permissionLabel = formatAssistantModulePermissionLabel(deniedModuleByIntent);
|
|
2601
2690
|
progressTracker.push(AI_ASSISTANT_PROGRESS_DATA_LOOKUP);
|
|
2602
2691
|
recordStep('Grabbing Data: denied', {
|
|
@@ -2613,9 +2702,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2613
2702
|
toolTelemetry.outcome = {
|
|
2614
2703
|
error: 'permission_denied'
|
|
2615
2704
|
};
|
|
2616
|
-
return [3 /*break*/,
|
|
2617
|
-
case
|
|
2618
|
-
if (!((directive === null || directive === void 0 ? void 0 : directive.payload) && AI_ASSISTANT_TOOL_MAX_STEPS > 0)) return [3 /*break*/,
|
|
2705
|
+
return [3 /*break*/, 75];
|
|
2706
|
+
case 46:
|
|
2707
|
+
if (!((directive === null || directive === void 0 ? void 0 : directive.payload) && AI_ASSISTANT_TOOL_MAX_STEPS > 0)) return [3 /*break*/, 74];
|
|
2619
2708
|
effectiveDirective = collectionOverride
|
|
2620
2709
|
? __assign(__assign({}, directive), { payload: __assign(__assign({}, (directive.payload || {})), { collection: collectionOverride.to }) }) : directive;
|
|
2621
2710
|
effectiveDirectiveMetadata = effectiveDirective.metadata && typeof effectiveDirective.metadata === 'object'
|
|
@@ -2667,10 +2756,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2667
2756
|
directiveProgressMessages.slice(0, 2).forEach(function (messageText) { return progressTracker.push(messageText); });
|
|
2668
2757
|
executionDirective = effectiveDirective;
|
|
2669
2758
|
probeFieldHints = [];
|
|
2670
|
-
|
|
2671
|
-
case
|
|
2672
|
-
|
|
2673
|
-
if (!(!alwaysAllowProbeEnabled && !hasRunBudget('Grabbing Data', AI_ASSISTANT_MONGO_MIN_STAGE_BUDGET_MS))) return [3 /*break*/,
|
|
2759
|
+
_21.label = 47;
|
|
2760
|
+
case 47:
|
|
2761
|
+
_21.trys.push([47, 72, , 73]);
|
|
2762
|
+
if (!(!alwaysAllowProbeEnabled && !hasRunBudget('Grabbing Data', AI_ASSISTANT_MONGO_MIN_STAGE_BUDGET_MS))) return [3 /*break*/, 48];
|
|
2674
2763
|
assistantContent = buildAssistantRunBudgetExceededMessage();
|
|
2675
2764
|
toolTelemetry.final = {
|
|
2676
2765
|
attempted: false,
|
|
@@ -2680,17 +2769,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2680
2769
|
toolTelemetry.outcome = {
|
|
2681
2770
|
error: 'run_budget_exhausted'
|
|
2682
2771
|
};
|
|
2683
|
-
return [3 /*break*/,
|
|
2684
|
-
case
|
|
2772
|
+
return [3 /*break*/, 71];
|
|
2773
|
+
case 48:
|
|
2685
2774
|
aggregateProbeDisabled = executionDirective.type === 'aggregate'
|
|
2686
2775
|
&& !alwaysAllowProbeEnabled
|
|
2687
2776
|
&& !isAssistantAppDataIntentHeuristicDirective(executionDirective);
|
|
2688
2777
|
probeEnabled = AI_ASSISTANT_TOOL_MAX_STEPS > 1 && !aggregateProbeDisabled;
|
|
2689
2778
|
probeBudgetAllowed = alwaysAllowProbeEnabled
|
|
2690
2779
|
|| hasRunBudget('Grabbing Data: probe', AI_ASSISTANT_MONGO_MIN_STAGE_BUDGET_MS);
|
|
2691
|
-
if (!(probeEnabled && probeBudgetAllowed)) return [3 /*break*/,
|
|
2780
|
+
if (!(probeEnabled && probeBudgetAllowed)) return [3 /*break*/, 58];
|
|
2692
2781
|
probeDirective = buildAssistantProbeDirective(executionDirective);
|
|
2693
|
-
if (!(probeDirective === null || probeDirective === void 0 ? void 0 : probeDirective.payload)) return [3 /*break*/,
|
|
2782
|
+
if (!(probeDirective === null || probeDirective === void 0 ? void 0 : probeDirective.payload)) return [3 /*break*/, 56];
|
|
2694
2783
|
probeRequest = buildToolRequestForDirective(probeDirective);
|
|
2695
2784
|
recordStep('Grabbing Data: probe start', {
|
|
2696
2785
|
type: probeDirective.type,
|
|
@@ -2701,19 +2790,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2701
2790
|
attempted: true
|
|
2702
2791
|
};
|
|
2703
2792
|
probeStart = Date.now();
|
|
2704
|
-
|
|
2705
|
-
case
|
|
2706
|
-
|
|
2707
|
-
if (!(probeDirective.type === 'aggregate')) return [3 /*break*/,
|
|
2793
|
+
_21.label = 49;
|
|
2794
|
+
case 49:
|
|
2795
|
+
_21.trys.push([49, 54, , 55]);
|
|
2796
|
+
if (!(probeDirective.type === 'aggregate')) return [3 /*break*/, 51];
|
|
2708
2797
|
return [4 /*yield*/, executeAiAssistantReportBuilderAggregate(probeRequest, context)];
|
|
2709
|
-
case
|
|
2710
|
-
_c =
|
|
2711
|
-
return [3 /*break*/,
|
|
2712
|
-
case
|
|
2713
|
-
case
|
|
2714
|
-
_c =
|
|
2715
|
-
|
|
2716
|
-
case
|
|
2798
|
+
case 50:
|
|
2799
|
+
_c = _21.sent();
|
|
2800
|
+
return [3 /*break*/, 53];
|
|
2801
|
+
case 51: return [4 /*yield*/, executeAiAssistantReportBuilderRead(probeRequest, context)];
|
|
2802
|
+
case 52:
|
|
2803
|
+
_c = _21.sent();
|
|
2804
|
+
_21.label = 53;
|
|
2805
|
+
case 53:
|
|
2717
2806
|
probeResponse = _c;
|
|
2718
2807
|
probeDurationMs = Date.now() - probeStart;
|
|
2719
2808
|
timingBreakdown.toolMs += probeDurationMs;
|
|
@@ -2734,7 +2823,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2734
2823
|
};
|
|
2735
2824
|
recordStep('Grabbing Data: probe complete', {
|
|
2736
2825
|
rowCount: probeRowCount,
|
|
2737
|
-
collection: normalizeOptionalString(((
|
|
2826
|
+
collection: normalizeOptionalString(((_13 = probeResponse === null || probeResponse === void 0 ? void 0 : probeResponse.debug) === null || _13 === void 0 ? void 0 : _13.collectionResolved) || ((_14 = probeResponse === null || probeResponse === void 0 ? void 0 : probeResponse.debug) === null || _14 === void 0 ? void 0 : _14.collection)) || undefined
|
|
2738
2827
|
});
|
|
2739
2828
|
if (probeRewrite.notes.length || probeFieldHints.length) {
|
|
2740
2829
|
recordStep('Grabbing Data: probe rewrite', {
|
|
@@ -2742,9 +2831,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2742
2831
|
fieldHints: probeFieldHints.length ? probeFieldHints.slice(0, 6) : undefined
|
|
2743
2832
|
});
|
|
2744
2833
|
}
|
|
2745
|
-
return [3 /*break*/,
|
|
2746
|
-
case
|
|
2747
|
-
probeError_1 =
|
|
2834
|
+
return [3 /*break*/, 55];
|
|
2835
|
+
case 54:
|
|
2836
|
+
probeError_1 = _21.sent();
|
|
2748
2837
|
probeDurationMs = Date.now() - probeStart;
|
|
2749
2838
|
probeErrorMessage = normalizeOptionalString(probeError_1 === null || probeError_1 === void 0 ? void 0 : probeError_1.message) || 'Unknown error';
|
|
2750
2839
|
toolTelemetry.probe = {
|
|
@@ -2756,16 +2845,16 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2756
2845
|
recordStep('Grabbing Data: probe failed', {
|
|
2757
2846
|
message: probeErrorMessage
|
|
2758
2847
|
});
|
|
2759
|
-
return [3 /*break*/,
|
|
2760
|
-
case
|
|
2761
|
-
case
|
|
2848
|
+
return [3 /*break*/, 55];
|
|
2849
|
+
case 55: return [3 /*break*/, 57];
|
|
2850
|
+
case 56:
|
|
2762
2851
|
toolTelemetry.probe = {
|
|
2763
2852
|
attempted: false,
|
|
2764
2853
|
skippedReason: 'probe_directive_missing_payload'
|
|
2765
2854
|
};
|
|
2766
|
-
|
|
2767
|
-
case
|
|
2768
|
-
case
|
|
2855
|
+
_21.label = 57;
|
|
2856
|
+
case 57: return [3 /*break*/, 59];
|
|
2857
|
+
case 58:
|
|
2769
2858
|
if (probeEnabled) {
|
|
2770
2859
|
toolTelemetry.probe = {
|
|
2771
2860
|
attempted: false,
|
|
@@ -2778,9 +2867,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2778
2867
|
skippedReason: 'aggregate_probe_disabled'
|
|
2779
2868
|
};
|
|
2780
2869
|
}
|
|
2781
|
-
|
|
2782
|
-
case
|
|
2783
|
-
if (!(!alwaysAllowProbeEnabled && !hasRunBudget('Grabbing Data: final', AI_ASSISTANT_MONGO_MIN_STAGE_BUDGET_MS))) return [3 /*break*/,
|
|
2870
|
+
_21.label = 59;
|
|
2871
|
+
case 59:
|
|
2872
|
+
if (!(!alwaysAllowProbeEnabled && !hasRunBudget('Grabbing Data: final', AI_ASSISTANT_MONGO_MIN_STAGE_BUDGET_MS))) return [3 /*break*/, 60];
|
|
2784
2873
|
assistantContent = buildAssistantRunBudgetExceededMessage();
|
|
2785
2874
|
toolTelemetry.final = {
|
|
2786
2875
|
attempted: false,
|
|
@@ -2790,8 +2879,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2790
2879
|
toolTelemetry.outcome = {
|
|
2791
2880
|
error: 'run_budget_exhausted'
|
|
2792
2881
|
};
|
|
2793
|
-
return [3 /*break*/,
|
|
2794
|
-
case
|
|
2882
|
+
return [3 /*break*/, 71];
|
|
2883
|
+
case 60:
|
|
2795
2884
|
toolRequest = buildToolRequestForDirective(executionDirective, probeFieldHints);
|
|
2796
2885
|
requestedToolCollection = normalizeOptionalString(toolRequest === null || toolRequest === void 0 ? void 0 : toolRequest.collection);
|
|
2797
2886
|
recordStep('Grabbing Data: start', {
|
|
@@ -2805,16 +2894,16 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2805
2894
|
collection: requestedToolCollection || undefined
|
|
2806
2895
|
};
|
|
2807
2896
|
toolStart = Date.now();
|
|
2808
|
-
if (!(executionDirective.type === 'aggregate')) return [3 /*break*/,
|
|
2897
|
+
if (!(executionDirective.type === 'aggregate')) return [3 /*break*/, 62];
|
|
2809
2898
|
return [4 /*yield*/, executeAiAssistantReportBuilderAggregate(toolRequest, context)];
|
|
2810
|
-
case
|
|
2811
|
-
_d =
|
|
2812
|
-
return [3 /*break*/,
|
|
2813
|
-
case
|
|
2814
|
-
case
|
|
2815
|
-
_d =
|
|
2816
|
-
|
|
2817
|
-
case
|
|
2899
|
+
case 61:
|
|
2900
|
+
_d = _21.sent();
|
|
2901
|
+
return [3 /*break*/, 64];
|
|
2902
|
+
case 62: return [4 /*yield*/, executeAiAssistantReportBuilderRead(toolRequest, context)];
|
|
2903
|
+
case 63:
|
|
2904
|
+
_d = _21.sent();
|
|
2905
|
+
_21.label = 64;
|
|
2906
|
+
case 64:
|
|
2818
2907
|
toolResponse = _d;
|
|
2819
2908
|
toolDurationMs = Date.now() - toolStart;
|
|
2820
2909
|
timingBreakdown.toolMs += toolDurationMs;
|
|
@@ -2824,8 +2913,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2824
2913
|
toolPayload = buildAssistantToolResultPayload(executionDirective, toolResponse, message);
|
|
2825
2914
|
toolResult = toolPayload.result;
|
|
2826
2915
|
resolvedToolCollection = normalizeOptionalString(toolPayload.result.output.collection
|
|
2827
|
-
|| ((
|
|
2828
|
-
|| ((
|
|
2916
|
+
|| ((_15 = toolResponse === null || toolResponse === void 0 ? void 0 : toolResponse.debug) === null || _15 === void 0 ? void 0 : _15.collectionResolved)
|
|
2917
|
+
|| ((_16 = toolResponse === null || toolResponse === void 0 ? void 0 : toolResponse.debug) === null || _16 === void 0 ? void 0 : _16.collection)
|
|
2829
2918
|
|| requestedToolCollection);
|
|
2830
2919
|
toolTelemetry.final = {
|
|
2831
2920
|
attempted: true,
|
|
@@ -2849,7 +2938,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2849
2938
|
|| usedDeterministicHeuristicFastPath
|
|
2850
2939
|
|| isAssistantDeterministicHeuristicDirective(executionDirective)
|
|
2851
2940
|
|| zeroRowResult;
|
|
2852
|
-
if (!skipFollowupCodex) return [3 /*break*/,
|
|
2941
|
+
if (!skipFollowupCodex) return [3 /*break*/, 65];
|
|
2853
2942
|
recordStep('Drafting response: deterministic summary', {
|
|
2854
2943
|
reason: zeroRowResult
|
|
2855
2944
|
? 'zero_rows'
|
|
@@ -2859,36 +2948,36 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2859
2948
|
});
|
|
2860
2949
|
assistantContent = buildAssistantToolFallbackResponse(toolPayload.result);
|
|
2861
2950
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2862
|
-
return [3 /*break*/,
|
|
2863
|
-
case
|
|
2951
|
+
return [3 /*break*/, 71];
|
|
2952
|
+
case 65:
|
|
2864
2953
|
recordStep('Drafting response');
|
|
2865
2954
|
followupPrompt = buildAssistantCodexToolFollowupPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, toolPayload.prompt, assistantSystemPrompt);
|
|
2866
|
-
if (!hasRunBudget('Drafting response: followup')) return [3 /*break*/,
|
|
2867
|
-
|
|
2868
|
-
case
|
|
2869
|
-
|
|
2955
|
+
if (!hasRunBudget('Drafting response: followup')) return [3 /*break*/, 70];
|
|
2956
|
+
_21.label = 66;
|
|
2957
|
+
case 66:
|
|
2958
|
+
_21.trys.push([66, 68, , 69]);
|
|
2870
2959
|
followupStart = Date.now();
|
|
2871
2960
|
return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, applyCodexStageBudget(runOptions), codexConfig, streamProgress)];
|
|
2872
|
-
case
|
|
2873
|
-
followupText =
|
|
2961
|
+
case 67:
|
|
2962
|
+
followupText = _21.sent();
|
|
2874
2963
|
accumulateCodexUsage(followupPrompt, followupText);
|
|
2875
2964
|
timingBreakdown.followupMs = Date.now() - followupStart;
|
|
2876
2965
|
assistantContent = sanitizeAssistantResponse(followupText);
|
|
2877
2966
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2878
|
-
return [3 /*break*/,
|
|
2879
|
-
case
|
|
2880
|
-
_e =
|
|
2967
|
+
return [3 /*break*/, 69];
|
|
2968
|
+
case 68:
|
|
2969
|
+
_e = _21.sent();
|
|
2881
2970
|
assistantContent = buildAssistantToolFallbackResponse(toolPayload.result);
|
|
2882
2971
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2883
|
-
return [3 /*break*/,
|
|
2884
|
-
case
|
|
2885
|
-
case
|
|
2972
|
+
return [3 /*break*/, 69];
|
|
2973
|
+
case 69: return [3 /*break*/, 71];
|
|
2974
|
+
case 70:
|
|
2886
2975
|
assistantContent = buildAssistantToolFallbackResponse(toolPayload.result);
|
|
2887
2976
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2888
|
-
|
|
2889
|
-
case
|
|
2890
|
-
case
|
|
2891
|
-
error_8 =
|
|
2977
|
+
_21.label = 71;
|
|
2978
|
+
case 71: return [3 /*break*/, 73];
|
|
2979
|
+
case 72:
|
|
2980
|
+
error_8 = _21.sent();
|
|
2892
2981
|
assistantContent = buildAssistantToolErrorMessage(error_8);
|
|
2893
2982
|
toolError = error_8;
|
|
2894
2983
|
errorMessage = normalizeOptionalString(error_8 === null || error_8 === void 0 ? void 0 : error_8.message) || 'Unknown error';
|
|
@@ -2897,22 +2986,22 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2897
2986
|
: { attempted: false };
|
|
2898
2987
|
toolTelemetry.final = __assign(__assign({}, existingFinal), { attempted: existingFinal.attempted === true, failed: true, error: errorMessage });
|
|
2899
2988
|
toolTelemetry.outcome = __assign(__assign({}, (toolTelemetry.outcome || {})), { error: errorMessage });
|
|
2900
|
-
return [3 /*break*/,
|
|
2901
|
-
case
|
|
2902
|
-
case
|
|
2989
|
+
return [3 /*break*/, 73];
|
|
2990
|
+
case 73: return [3 /*break*/, 75];
|
|
2991
|
+
case 74:
|
|
2903
2992
|
progressTracker.push(AI_ASSISTANT_PROGRESS_DRAFT);
|
|
2904
2993
|
recordStep('Drafting response');
|
|
2905
|
-
|
|
2906
|
-
case
|
|
2907
|
-
case
|
|
2908
|
-
error_9 =
|
|
2994
|
+
_21.label = 75;
|
|
2995
|
+
case 75: return [3 /*break*/, 78];
|
|
2996
|
+
case 76:
|
|
2997
|
+
error_9 = _21.sent();
|
|
2909
2998
|
assistantContent = buildAssistantCodexErrorMessage(error_9);
|
|
2910
2999
|
recordStep('Error', { message: normalizeOptionalString(error_9 === null || error_9 === void 0 ? void 0 : error_9.message) || 'Unknown error' });
|
|
2911
|
-
return [3 /*break*/,
|
|
2912
|
-
case
|
|
3000
|
+
return [3 /*break*/, 78];
|
|
3001
|
+
case 77:
|
|
2913
3002
|
progressTracker.stop();
|
|
2914
3003
|
return [7 /*endfinally*/];
|
|
2915
|
-
case
|
|
3004
|
+
case 78:
|
|
2916
3005
|
runBudgetExceeded = runDeadlineMs ? Date.now() > runDeadlineMs : false;
|
|
2917
3006
|
if (!assistantContent) {
|
|
2918
3007
|
assistantContent = runBudgetExceeded
|
|
@@ -2923,10 +3012,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2923
3012
|
assistantContent = applyAssistantDatedReportWindow(assistantContent, toolResult);
|
|
2924
3013
|
assistantContent = applyAssistantLotNumberResponseGuard(assistantContent, message, toolResult);
|
|
2925
3014
|
assistantContent = normalizeAssistantCurrencyText(assistantContent);
|
|
2926
|
-
if (toolError && !normalizeOptionalString((
|
|
3015
|
+
if (toolError && !normalizeOptionalString((_17 = toolTelemetry === null || toolTelemetry === void 0 ? void 0 : toolTelemetry.outcome) === null || _17 === void 0 ? void 0 : _17.error)) {
|
|
2927
3016
|
toolTelemetry.outcome = __assign(__assign({}, (toolTelemetry.outcome || {})), { error: normalizeOptionalString(toolError === null || toolError === void 0 ? void 0 : toolError.message) || 'tool_error' });
|
|
2928
3017
|
}
|
|
2929
|
-
if (((
|
|
3018
|
+
if (((_18 = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _18 === void 0 ? void 0 : _18.rowCount) === 0 && !((_19 = toolTelemetry === null || toolTelemetry === void 0 ? void 0 : toolTelemetry.outcome) === null || _19 === void 0 ? void 0 : _19.zeroRows)) {
|
|
2930
3019
|
toolTelemetry.outcome = __assign(__assign({}, (toolTelemetry.outcome || {})), { zeroRows: true });
|
|
2931
3020
|
}
|
|
2932
3021
|
includeToolExecutionTelemetry = dataQuestion
|
|
@@ -2956,9 +3045,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2956
3045
|
});
|
|
2957
3046
|
}
|
|
2958
3047
|
finalNow = new Date();
|
|
2959
|
-
|
|
2960
|
-
case
|
|
2961
|
-
|
|
3048
|
+
_21.label = 79;
|
|
3049
|
+
case 79:
|
|
3050
|
+
_21.trys.push([79, 91, , 102]);
|
|
2962
3051
|
if (canViewDebug) {
|
|
2963
3052
|
finishedAt = Date.now();
|
|
2964
3053
|
codexMs = timingBreakdown.directiveMs
|
|
@@ -3000,6 +3089,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3000
3089
|
collectionRanking: collectionRanking || undefined,
|
|
3001
3090
|
collectionSelection: collectionSelection || undefined,
|
|
3002
3091
|
collectionOverride: collectionOverride || undefined,
|
|
3092
|
+
dataRequestClassifier: appDataRequestClassifierDebug || undefined,
|
|
3003
3093
|
planner: plannerUsed ? {
|
|
3004
3094
|
enabled: true,
|
|
3005
3095
|
parsed: !!plannerOutput,
|
|
@@ -3058,13 +3148,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3058
3148
|
total_tokens: codexUsage.total_tokens
|
|
3059
3149
|
} : null;
|
|
3060
3150
|
finalUsageLedgerEntry = null;
|
|
3061
|
-
if (!finalUsage) return [3 /*break*/,
|
|
3151
|
+
if (!finalUsage) return [3 /*break*/, 84];
|
|
3062
3152
|
return [4 /*yield*/, resolveClientId(conversation, input.id_client, context === null || context === void 0 ? void 0 : context.id_user)];
|
|
3063
|
-
case
|
|
3064
|
-
usageClientId =
|
|
3065
|
-
|
|
3066
|
-
case
|
|
3067
|
-
|
|
3153
|
+
case 80:
|
|
3154
|
+
usageClientId = _21.sent();
|
|
3155
|
+
_21.label = 81;
|
|
3156
|
+
case 81:
|
|
3157
|
+
_21.trys.push([81, 83, , 84]);
|
|
3068
3158
|
finalUsageLedgerEntry = buildAssistantAIRunUsageLedgerEntry({
|
|
3069
3159
|
idClient: usageClientId || '',
|
|
3070
3160
|
model: finalUsage.model,
|
|
@@ -3084,16 +3174,16 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3084
3174
|
}
|
|
3085
3175
|
});
|
|
3086
3176
|
return [4 /*yield*/, (0, openai_usage_ledger_manager_1.recordOpenAIUsage)(finalUsageLedgerEntry)];
|
|
3087
|
-
case
|
|
3088
|
-
|
|
3089
|
-
return [3 /*break*/,
|
|
3090
|
-
case
|
|
3091
|
-
|
|
3092
|
-
console.error(new Date(), 'Failed to record AI usage',
|
|
3093
|
-
return [3 /*break*/,
|
|
3094
|
-
case
|
|
3177
|
+
case 82:
|
|
3178
|
+
_21.sent();
|
|
3179
|
+
return [3 /*break*/, 84];
|
|
3180
|
+
case 83:
|
|
3181
|
+
usageError_2 = _21.sent();
|
|
3182
|
+
console.error(new Date(), 'Failed to record AI usage', usageError_2);
|
|
3183
|
+
return [3 /*break*/, 84];
|
|
3184
|
+
case 84:
|
|
3095
3185
|
finalAssistantDoc = __assign(__assign(__assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: assistantContent, metadata: finalMetadata }), (finalUsage ? { usage: finalUsage } : {})), { updatedAt: finalNow });
|
|
3096
|
-
if (!assistantMessageId) return [3 /*break*/,
|
|
3186
|
+
if (!assistantMessageId) return [3 /*break*/, 86];
|
|
3097
3187
|
setPayload = {
|
|
3098
3188
|
content: assistantContent,
|
|
3099
3189
|
metadata: finalMetadata,
|
|
@@ -3103,12 +3193,12 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3103
3193
|
setPayload.usage = finalUsage;
|
|
3104
3194
|
}
|
|
3105
3195
|
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, setPayload)];
|
|
3106
|
-
case
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
case
|
|
3110
|
-
case
|
|
3111
|
-
|
|
3196
|
+
case 85:
|
|
3197
|
+
_21.sent();
|
|
3198
|
+
_21.label = 86;
|
|
3199
|
+
case 86: return [4 /*yield*/, touchConversation(conversation._id, finalNow, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
3200
|
+
case 87:
|
|
3201
|
+
_21.sent();
|
|
3112
3202
|
return [4 /*yield*/, recordAssistantAnswerAIRun({
|
|
3113
3203
|
runId: buildAssistantAIRunId('codex_query', [conversation._id, assistantMessageId || requestId]),
|
|
3114
3204
|
requestId: requestId || undefined,
|
|
@@ -3117,7 +3207,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3117
3207
|
userMessage: __assign(__assign({}, userDoc), { _id: userMessageId ? String(userMessageId) : undefined }),
|
|
3118
3208
|
assistantMessage: finalAssistantDoc,
|
|
3119
3209
|
usageLedgerEntry: finalUsageLedgerEntry || undefined,
|
|
3120
|
-
correctnessChecks: ((
|
|
3210
|
+
correctnessChecks: ((_20 = toolTelemetry === null || toolTelemetry === void 0 ? void 0 : toolTelemetry.outcome) === null || _20 === void 0 ? void 0 : _20.error) ? [{
|
|
3121
3211
|
assertion: 'assistant_tool_execution',
|
|
3122
3212
|
status: 'fail',
|
|
3123
3213
|
observed: toolTelemetry.outcome.error,
|
|
@@ -3126,55 +3216,55 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3126
3216
|
answerQuality: answerQualityEvidence,
|
|
3127
3217
|
now: finalNow
|
|
3128
3218
|
})];
|
|
3129
|
-
case
|
|
3130
|
-
|
|
3131
|
-
if (!(input.delete_files_after_run !== false)) return [3 /*break*/,
|
|
3219
|
+
case 88:
|
|
3220
|
+
_21.sent();
|
|
3221
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 90];
|
|
3132
3222
|
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
3133
|
-
case
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
case
|
|
3137
|
-
case
|
|
3138
|
-
finalizeError_1 =
|
|
3223
|
+
case 89:
|
|
3224
|
+
_21.sent();
|
|
3225
|
+
_21.label = 90;
|
|
3226
|
+
case 90: return [2 /*return*/, finalAssistantDoc];
|
|
3227
|
+
case 91:
|
|
3228
|
+
finalizeError_1 = _21.sent();
|
|
3139
3229
|
failedAt = new Date();
|
|
3140
3230
|
fallbackContent = assistantContent || buildAssistantCodexErrorMessage(finalizeError_1);
|
|
3141
3231
|
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' });
|
|
3142
|
-
|
|
3143
|
-
case
|
|
3144
|
-
|
|
3145
|
-
if (!assistantMessageId) return [3 /*break*/,
|
|
3232
|
+
_21.label = 92;
|
|
3233
|
+
case 92:
|
|
3234
|
+
_21.trys.push([92, 96, , 97]);
|
|
3235
|
+
if (!assistantMessageId) return [3 /*break*/, 94];
|
|
3146
3236
|
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, {
|
|
3147
3237
|
content: fallbackContent,
|
|
3148
3238
|
metadata: failureMetadata,
|
|
3149
3239
|
updatedAt: failedAt
|
|
3150
3240
|
})];
|
|
3151
|
-
case
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
case
|
|
3155
|
-
case
|
|
3156
|
-
|
|
3157
|
-
return [3 /*break*/,
|
|
3158
|
-
case
|
|
3159
|
-
persistError_1 =
|
|
3241
|
+
case 93:
|
|
3242
|
+
_21.sent();
|
|
3243
|
+
_21.label = 94;
|
|
3244
|
+
case 94: return [4 /*yield*/, touchConversation(conversation._id, failedAt, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
3245
|
+
case 95:
|
|
3246
|
+
_21.sent();
|
|
3247
|
+
return [3 /*break*/, 97];
|
|
3248
|
+
case 96:
|
|
3249
|
+
persistError_1 = _21.sent();
|
|
3160
3250
|
console.error(new Date(), 'AI assistant finalize fallback update failed', persistError_1);
|
|
3161
|
-
return [3 /*break*/,
|
|
3162
|
-
case
|
|
3163
|
-
if (!(input.delete_files_after_run !== false)) return [3 /*break*/,
|
|
3164
|
-
|
|
3165
|
-
case
|
|
3166
|
-
|
|
3251
|
+
return [3 /*break*/, 97];
|
|
3252
|
+
case 97:
|
|
3253
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 101];
|
|
3254
|
+
_21.label = 98;
|
|
3255
|
+
case 98:
|
|
3256
|
+
_21.trys.push([98, 100, , 101]);
|
|
3167
3257
|
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
3168
|
-
case
|
|
3169
|
-
|
|
3170
|
-
return [3 /*break*/,
|
|
3171
|
-
case
|
|
3172
|
-
_f =
|
|
3173
|
-
return [3 /*break*/,
|
|
3174
|
-
case
|
|
3258
|
+
case 99:
|
|
3259
|
+
_21.sent();
|
|
3260
|
+
return [3 /*break*/, 101];
|
|
3261
|
+
case 100:
|
|
3262
|
+
_f = _21.sent();
|
|
3263
|
+
return [3 /*break*/, 101];
|
|
3264
|
+
case 101:
|
|
3175
3265
|
console.error(new Date(), 'AI assistant run finalize failed:', finalizeError_1);
|
|
3176
3266
|
return [2 /*return*/, __assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: fallbackContent, metadata: failureMetadata, updatedAt: failedAt })];
|
|
3177
|
-
case
|
|
3267
|
+
case 102: return [2 /*return*/];
|
|
3178
3268
|
}
|
|
3179
3269
|
});
|
|
3180
3270
|
}); });
|
|
@@ -6868,29 +6958,40 @@ function scoreAssistantAppDataIntent(messageText, intent) {
|
|
|
6868
6958
|
return score + (term.includes(' ') ? 4 : 1);
|
|
6869
6959
|
}, 0);
|
|
6870
6960
|
}
|
|
6871
|
-
function
|
|
6961
|
+
function rankAssistantAppDataIntentCandidates(message, collectionNames, appId, options) {
|
|
6872
6962
|
var text = normalizeOptionalString(message).toLowerCase();
|
|
6873
6963
|
if (!text) {
|
|
6874
|
-
return
|
|
6964
|
+
return [];
|
|
6875
6965
|
}
|
|
6876
6966
|
var availableNames = new Set((Array.isArray(collectionNames) ? collectionNames : []).map(function (value) { return normalizeOptionalString(value); }).filter(Boolean));
|
|
6877
6967
|
var profile = resolveAssistantAppHeuristicProfile(appId);
|
|
6878
|
-
var
|
|
6879
|
-
|
|
6968
|
+
var includeUnscored = (options === null || options === void 0 ? void 0 : options.includeUnscored) === true;
|
|
6969
|
+
var limit = Math.max(1, Math.min((0, common_1.round)((options === null || options === void 0 ? void 0 : options.limit) || 6), 12));
|
|
6970
|
+
return profile.dataIntents
|
|
6971
|
+
.filter(function (intent) {
|
|
6880
6972
|
if (!(intent === null || intent === void 0 ? void 0 : intent.id) || !intent.collection) {
|
|
6881
|
-
return;
|
|
6882
|
-
}
|
|
6883
|
-
if (availableNames.size && !availableNames.has(intent.collection)) {
|
|
6884
|
-
return;
|
|
6885
|
-
}
|
|
6886
|
-
var score = scoreAssistantAppDataIntent(text, intent);
|
|
6887
|
-
if (score <= 0) {
|
|
6888
|
-
return;
|
|
6973
|
+
return false;
|
|
6889
6974
|
}
|
|
6890
|
-
|
|
6891
|
-
|
|
6975
|
+
return !availableNames.size || availableNames.has(intent.collection);
|
|
6976
|
+
})
|
|
6977
|
+
.map(function (intent) { return ({
|
|
6978
|
+
intent: intent,
|
|
6979
|
+
score: scoreAssistantAppDataIntent(text, intent)
|
|
6980
|
+
}); })
|
|
6981
|
+
.filter(function (candidate) { return includeUnscored || candidate.score > 0; })
|
|
6982
|
+
.sort(function (a, b) {
|
|
6983
|
+
if (b.score !== a.score) {
|
|
6984
|
+
return b.score - a.score;
|
|
6892
6985
|
}
|
|
6893
|
-
|
|
6986
|
+
return a.intent.id.localeCompare(b.intent.id);
|
|
6987
|
+
})
|
|
6988
|
+
.slice(0, limit);
|
|
6989
|
+
}
|
|
6990
|
+
function selectAssistantAppDataIntent(message, collectionNames, appId) {
|
|
6991
|
+
var selected = rankAssistantAppDataIntentCandidates(message, collectionNames, appId, {
|
|
6992
|
+
includeUnscored: false,
|
|
6993
|
+
limit: 1
|
|
6994
|
+
})[0];
|
|
6894
6995
|
return selected ? selected.intent : null;
|
|
6895
6996
|
}
|
|
6896
6997
|
function extractAssistantDataIntentCustomerText(message) {
|
|
@@ -7354,8 +7455,419 @@ function buildAssistantDataRequestMeasures(intent, pipeline) {
|
|
|
7354
7455
|
}
|
|
7355
7456
|
return measures;
|
|
7356
7457
|
}
|
|
7357
|
-
function
|
|
7358
|
-
|
|
7458
|
+
function clampAssistantConfidence(value, fallback) {
|
|
7459
|
+
if (fallback === void 0) { fallback = 0.75; }
|
|
7460
|
+
var parsed = Number(value);
|
|
7461
|
+
if (!Number.isFinite(parsed)) {
|
|
7462
|
+
return fallback;
|
|
7463
|
+
}
|
|
7464
|
+
return Math.max(0, Math.min(parsed, 1));
|
|
7465
|
+
}
|
|
7466
|
+
function normalizeAssistantContractStringList(value, max) {
|
|
7467
|
+
if (max === void 0) { max = 12; }
|
|
7468
|
+
var source = Array.isArray(value) ? value : (normalizeOptionalString(value) ? [value] : []);
|
|
7469
|
+
var values = [];
|
|
7470
|
+
source.forEach(function (entry) {
|
|
7471
|
+
var normalized = normalizeOptionalString(entry);
|
|
7472
|
+
if (!normalized || values.includes(normalized)) {
|
|
7473
|
+
return;
|
|
7474
|
+
}
|
|
7475
|
+
values.push(normalized.slice(0, 160));
|
|
7476
|
+
});
|
|
7477
|
+
return values.slice(0, max);
|
|
7478
|
+
}
|
|
7479
|
+
function normalizeAssistantContractFilters(value) {
|
|
7480
|
+
if (!Array.isArray(value)) {
|
|
7481
|
+
return [];
|
|
7482
|
+
}
|
|
7483
|
+
return value
|
|
7484
|
+
.filter(function (entry) { return !!entry && typeof entry === 'object' && !Array.isArray(entry); })
|
|
7485
|
+
.map(function (entry) { return Object.keys(entry).reduce(function (acc, key) {
|
|
7486
|
+
var normalizedKey = normalizeOptionalString(key);
|
|
7487
|
+
if (!normalizedKey || shouldRedactField(normalizedKey)) {
|
|
7488
|
+
return acc;
|
|
7489
|
+
}
|
|
7490
|
+
var rawValue = entry[key];
|
|
7491
|
+
if (rawValue === undefined || rawValue === null) {
|
|
7492
|
+
return acc;
|
|
7493
|
+
}
|
|
7494
|
+
if (typeof rawValue === 'object') {
|
|
7495
|
+
try {
|
|
7496
|
+
acc[normalizedKey] = JSON.parse(JSON.stringify(rawValue));
|
|
7497
|
+
}
|
|
7498
|
+
catch (_a) {
|
|
7499
|
+
acc[normalizedKey] = normalizeOptionalString(rawValue).slice(0, 240);
|
|
7500
|
+
}
|
|
7501
|
+
return acc;
|
|
7502
|
+
}
|
|
7503
|
+
acc[normalizedKey] = normalizeOptionalString(rawValue).slice(0, 240);
|
|
7504
|
+
return acc;
|
|
7505
|
+
}, {}); })
|
|
7506
|
+
.filter(function (entry) { return Object.keys(entry).length > 0; })
|
|
7507
|
+
.slice(0, 12);
|
|
7508
|
+
}
|
|
7509
|
+
function normalizeAssistantContractDateRange(value) {
|
|
7510
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
7511
|
+
return null;
|
|
7512
|
+
}
|
|
7513
|
+
var start = normalizeOptionalString(value.start || value.start_date || value.startDate);
|
|
7514
|
+
var end = normalizeOptionalString(value.end || value.end_date || value.endDate);
|
|
7515
|
+
var year = normalizeOptionalNumber(value.year);
|
|
7516
|
+
var result = {};
|
|
7517
|
+
if (start) {
|
|
7518
|
+
result.start = start;
|
|
7519
|
+
}
|
|
7520
|
+
if (end) {
|
|
7521
|
+
result.end = end;
|
|
7522
|
+
}
|
|
7523
|
+
if (year && year >= 1900 && year <= 3000) {
|
|
7524
|
+
result.year = (0, common_1.round)(year);
|
|
7525
|
+
}
|
|
7526
|
+
return Object.keys(result).length ? result : null;
|
|
7527
|
+
}
|
|
7528
|
+
function extractAssistantDataRequestClassifierRoot(value) {
|
|
7529
|
+
if (!value || typeof value !== 'object') {
|
|
7530
|
+
return value;
|
|
7531
|
+
}
|
|
7532
|
+
return value.request
|
|
7533
|
+
|| value.contract
|
|
7534
|
+
|| value.data_request
|
|
7535
|
+
|| value.dataRequest
|
|
7536
|
+
|| value;
|
|
7537
|
+
}
|
|
7538
|
+
function normalizeAssistantDataRequestBreakdownContract(value) {
|
|
7539
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
7540
|
+
var text_1 = cleanAssistantRequestedDimensionText(normalizeOptionalString(value));
|
|
7541
|
+
return text_1 ? { type: 'unknown', requested_text: text_1 } : null;
|
|
7542
|
+
}
|
|
7543
|
+
var rawType = normalizeOptionalString(value.type || value.kind).toLowerCase();
|
|
7544
|
+
var requestedText = cleanAssistantRequestedDimensionText(value.requested_text
|
|
7545
|
+
|| value.requestedText
|
|
7546
|
+
|| value.text
|
|
7547
|
+
|| value.label
|
|
7548
|
+
|| value.dimension
|
|
7549
|
+
|| value.field
|
|
7550
|
+
|| value.granularity);
|
|
7551
|
+
var dimension = cleanAssistantRequestedDimensionText(value.dimension
|
|
7552
|
+
|| value.dimension_id
|
|
7553
|
+
|| value.dimensionId
|
|
7554
|
+
|| '');
|
|
7555
|
+
var granularity = cleanAssistantRequestedDimensionText(value.granularity
|
|
7556
|
+
|| value.time_grain
|
|
7557
|
+
|| value.timeGrain
|
|
7558
|
+
|| '');
|
|
7559
|
+
var fieldHint = normalizeOptionalString(value.field_hint || value.fieldHint || value.date_field || value.dateField);
|
|
7560
|
+
var fieldHints = normalizeAssistantContractStringList(value.field_hints || value.fieldHints || value.fields, 8);
|
|
7561
|
+
var inferredGranularity = granularity || resolveAssistantTimeBreakdownGranularity(requestedText || dimension);
|
|
7562
|
+
var type = rawType === 'time' || inferredGranularity
|
|
7563
|
+
? 'time'
|
|
7564
|
+
: rawType === 'entity'
|
|
7565
|
+
? 'entity'
|
|
7566
|
+
: rawType === 'unknown'
|
|
7567
|
+
? 'unknown'
|
|
7568
|
+
: 'unknown';
|
|
7569
|
+
var text = requestedText || dimension || granularity;
|
|
7570
|
+
if (!text) {
|
|
7571
|
+
return null;
|
|
7572
|
+
}
|
|
7573
|
+
return __assign(__assign(__assign(__assign({ type: type, requested_text: text }, (dimension ? { dimension: dimension } : {})), (inferredGranularity ? { granularity: inferredGranularity } : {})), (fieldHint ? { field_hint: fieldHint } : {})), (fieldHints.length ? { field_hints: fieldHints } : {}));
|
|
7574
|
+
}
|
|
7575
|
+
function normalizeAssistantDataRequestContract(value, intent, dateWindow, source) {
|
|
7576
|
+
if (source === void 0) { source = 'mini_model_classifier'; }
|
|
7577
|
+
var root = extractAssistantDataRequestClassifierRoot(value);
|
|
7578
|
+
if (!root || typeof root !== 'object' || Array.isArray(root)) {
|
|
7579
|
+
return null;
|
|
7580
|
+
}
|
|
7581
|
+
var breakdownSource = root.requested_breakdowns
|
|
7582
|
+
|| root.requestedBreakdowns
|
|
7583
|
+
|| root.breakdowns
|
|
7584
|
+
|| root.groupings
|
|
7585
|
+
|| root.group_by
|
|
7586
|
+
|| root.groupBy
|
|
7587
|
+
|| [];
|
|
7588
|
+
var requestedBreakdowns = (Array.isArray(breakdownSource) ? breakdownSource : [breakdownSource])
|
|
7589
|
+
.map(function (entry) { return normalizeAssistantDataRequestBreakdownContract(entry); })
|
|
7590
|
+
.filter(function (entry) { return !!entry; });
|
|
7591
|
+
var dateRange = normalizeAssistantContractDateRange(root.date_range || root.dateRange)
|
|
7592
|
+
|| (dateWindow.start || dateWindow.end ? __assign({}, dateWindow) : null);
|
|
7593
|
+
var intentId = normalizeOptionalString(root.intent_id || root.intentId || intent.id);
|
|
7594
|
+
var collection = normalizeOptionalString(root.collection || intent.collection);
|
|
7595
|
+
return {
|
|
7596
|
+
intent_type: 'data_summary',
|
|
7597
|
+
intent_id: intentId || undefined,
|
|
7598
|
+
domain: normalizeOptionalString(root.domain || intent.id || intent.collection),
|
|
7599
|
+
collection: collection || undefined,
|
|
7600
|
+
operation: 'aggregate',
|
|
7601
|
+
requested_breakdowns: requestedBreakdowns,
|
|
7602
|
+
date_range: dateRange,
|
|
7603
|
+
measures: normalizeAssistantContractStringList(root.measures || root.metrics || root.measure, 16),
|
|
7604
|
+
filters: normalizeAssistantContractFilters(root.filters || root.where),
|
|
7605
|
+
output_format: 'collapse_table',
|
|
7606
|
+
ambiguities: normalizeAssistantContractStringList(root.ambiguities || root.questions || root.uncertainties, 8),
|
|
7607
|
+
confidence: clampAssistantConfidence(root.confidence, requestedBreakdowns.length ? 0.82 : 0.65),
|
|
7608
|
+
source: source
|
|
7609
|
+
};
|
|
7610
|
+
}
|
|
7611
|
+
function buildAssistantRequestedBreakdownCandidates(message, classifierContract) {
|
|
7612
|
+
var candidates = [];
|
|
7613
|
+
var seen = new Set();
|
|
7614
|
+
var add = function (text, breakdown) {
|
|
7615
|
+
var normalized = cleanAssistantRequestedDimensionText(text);
|
|
7616
|
+
if (!normalized) {
|
|
7617
|
+
return;
|
|
7618
|
+
}
|
|
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(':');
|
|
7625
|
+
if (seen.has(key)) {
|
|
7626
|
+
return;
|
|
7627
|
+
}
|
|
7628
|
+
seen.add(key);
|
|
7629
|
+
candidates.push({ text: normalized, breakdown: breakdown });
|
|
7630
|
+
};
|
|
7631
|
+
((classifierContract === null || classifierContract === void 0 ? void 0 : classifierContract.requested_breakdowns) || []).forEach(function (breakdown) {
|
|
7632
|
+
add(breakdown.granularity
|
|
7633
|
+
|| breakdown.dimension
|
|
7634
|
+
|| breakdown.requested_text, breakdown);
|
|
7635
|
+
});
|
|
7636
|
+
extractAssistantRequestedBreakdownDimensionTexts(message).forEach(function (text) { return add(text); });
|
|
7637
|
+
return candidates;
|
|
7638
|
+
}
|
|
7639
|
+
function buildAssistantDataRequestClassifierCandidatePayload(candidate) {
|
|
7640
|
+
var intent = candidate.intent;
|
|
7641
|
+
return {
|
|
7642
|
+
intent_id: intent.id,
|
|
7643
|
+
collection: intent.collection,
|
|
7644
|
+
permission_view: intent.permissionView || undefined,
|
|
7645
|
+
score: candidate.score,
|
|
7646
|
+
trigger_terms: (intent.terms || []).slice(0, 16),
|
|
7647
|
+
date_field: intent.dateField || undefined,
|
|
7648
|
+
quantity_field: intent.quantityField || undefined,
|
|
7649
|
+
metric_field: intent.metricField || undefined,
|
|
7650
|
+
dimensions: (intent.dimensions || []).map(function (dimension) { return ({
|
|
7651
|
+
id: dimension.id,
|
|
7652
|
+
type: dimension.type || 'entity',
|
|
7653
|
+
granularity: dimension.granularity || undefined,
|
|
7654
|
+
terms: (dimension.terms || []).slice(0, 12),
|
|
7655
|
+
field_hints: extractAssistantDataIntentExpressionFieldHints(dimension.groupId).slice(0, 8)
|
|
7656
|
+
}); })
|
|
7657
|
+
};
|
|
7658
|
+
}
|
|
7659
|
+
function buildAssistantDataRequestClassifierMessages(params) {
|
|
7660
|
+
var systemPrompt = [
|
|
7661
|
+
'Classify one business app data request into strict JSON.',
|
|
7662
|
+
'Use only the supplied app-owned intent candidates and configured dimensions.',
|
|
7663
|
+
'Do not create MongoDB pipelines, queries, field paths, or collections.',
|
|
7664
|
+
'Preserve every explicit grouping phrase: "by month by chemical" must produce two requested_breakdowns, one for month and one for chemical.',
|
|
7665
|
+
'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.',
|
|
7667
|
+
'For time breakdowns, set type="time" and granularity to one of year, quarter, month, week, day, date.',
|
|
7668
|
+
'For configured dimensions, set type="entity" and dimension to the candidate dimension id.',
|
|
7669
|
+
'If unsure, include an ambiguity instead of guessing.',
|
|
7670
|
+
'Always set output_format to "collapse_table".',
|
|
7671
|
+
'Return JSON only with keys: intent_id, domain, collection, operation, requested_breakdowns, date_range, measures, filters, output_format, ambiguities, confidence.'
|
|
7672
|
+
].join('\n');
|
|
7673
|
+
var userPayload = {
|
|
7674
|
+
message: params.message,
|
|
7675
|
+
app_id: normalizeOptionalString(params.appId) || undefined,
|
|
7676
|
+
candidates: params.candidates.map(buildAssistantDataRequestClassifierCandidatePayload)
|
|
7677
|
+
};
|
|
7678
|
+
return [
|
|
7679
|
+
{ role: 'system', content: systemPrompt },
|
|
7680
|
+
{ role: 'user', content: JSON.stringify(userPayload) }
|
|
7681
|
+
];
|
|
7682
|
+
}
|
|
7683
|
+
function resolveAssistantDataRequestClassifierEnabled(config) {
|
|
7684
|
+
var override = normalizeOptionalBoolean((config === null || config === void 0 ? void 0 : config.data_request_classifier_enabled)
|
|
7685
|
+
|| (config === null || config === void 0 ? void 0 : config.dataRequestClassifierEnabled));
|
|
7686
|
+
if (typeof override === 'boolean') {
|
|
7687
|
+
return override;
|
|
7688
|
+
}
|
|
7689
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
7690
|
+
var raw = normalizeOptionalBoolean(serverConfig['AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_ENABLED']
|
|
7691
|
+
|| process.env.AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_ENABLED
|
|
7692
|
+
|| serverConfig['AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_ENABLED']
|
|
7693
|
+
|| process.env.AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_ENABLED);
|
|
7694
|
+
return raw === undefined ? true : raw === true;
|
|
7695
|
+
}
|
|
7696
|
+
function resolveAssistantDataRequestClassifierModel(config) {
|
|
7697
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
7698
|
+
return normalizeOptionalString((config === null || config === void 0 ? void 0 : config.data_request_classifier_model)
|
|
7699
|
+
|| (config === null || config === void 0 ? void 0 : config.dataRequestClassifierModel)
|
|
7700
|
+
|| serverConfig['AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_MODEL']
|
|
7701
|
+
|| process.env.AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_MODEL
|
|
7702
|
+
|| serverConfig['AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_MODEL']
|
|
7703
|
+
|| process.env.AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_MODEL
|
|
7704
|
+
|| serverConfig['AI_ASSISTANT_INTENT_MODEL']
|
|
7705
|
+
|| process.env.AI_ASSISTANT_INTENT_MODEL
|
|
7706
|
+
|| 'gpt-5.4-mini');
|
|
7707
|
+
}
|
|
7708
|
+
function resolveAssistantDataRequestClassifierTimeoutMs(config) {
|
|
7709
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
7710
|
+
var raw = normalizeOptionalNumber((config === null || config === void 0 ? void 0 : config.data_request_classifier_timeout_ms)
|
|
7711
|
+
|| (config === null || config === void 0 ? void 0 : config.dataRequestClassifierTimeoutMs)
|
|
7712
|
+
|| serverConfig['AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_TIMEOUT_MS']
|
|
7713
|
+
|| process.env.AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_TIMEOUT_MS
|
|
7714
|
+
|| serverConfig['AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_TIMEOUT_MS']
|
|
7715
|
+
|| process.env.AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_TIMEOUT_MS);
|
|
7716
|
+
if (raw && raw > 0) {
|
|
7717
|
+
return Math.max(250, Math.min((0, common_1.round)(raw), 5000));
|
|
7718
|
+
}
|
|
7719
|
+
return 1800;
|
|
7720
|
+
}
|
|
7721
|
+
function resolveAssistantDataRequestClassifierMaxTokens() {
|
|
7722
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
7723
|
+
var raw = normalizeOptionalNumber(serverConfig['AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_MAX_TOKENS']
|
|
7724
|
+
|| process.env.AI_ASSISTANT_DATA_REQUEST_CLASSIFIER_MAX_TOKENS
|
|
7725
|
+
|| serverConfig['AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_MAX_TOKENS']
|
|
7726
|
+
|| process.env.AI_ASSISTANT_DATA_CONTRACT_CLASSIFIER_MAX_TOKENS);
|
|
7727
|
+
if (raw && raw > 0) {
|
|
7728
|
+
return Math.max(128, Math.min((0, common_1.round)(raw), 1200));
|
|
7729
|
+
}
|
|
7730
|
+
return 650;
|
|
7731
|
+
}
|
|
7732
|
+
function resolveAssistantDataRequestClassifierIntent(raw, candidates) {
|
|
7733
|
+
var _a, _b;
|
|
7734
|
+
var root = extractAssistantDataRequestClassifierRoot(raw);
|
|
7735
|
+
var rawKeys = [
|
|
7736
|
+
root === null || root === void 0 ? void 0 : root.intent_id,
|
|
7737
|
+
root === null || root === void 0 ? void 0 : root.intentId,
|
|
7738
|
+
root === null || root === void 0 ? void 0 : root.domain,
|
|
7739
|
+
root === null || root === void 0 ? void 0 : root.collection
|
|
7740
|
+
].map(function (value) { return normalizeCollectionKey(normalizeOptionalString(value)); }).filter(Boolean);
|
|
7741
|
+
if (!rawKeys.length) {
|
|
7742
|
+
return ((_a = candidates[0]) === null || _a === void 0 ? void 0 : _a.intent) || null;
|
|
7743
|
+
}
|
|
7744
|
+
var selected = candidates.find(function (candidate) {
|
|
7745
|
+
var intentKeys = [
|
|
7746
|
+
candidate.intent.id,
|
|
7747
|
+
candidate.intent.collection
|
|
7748
|
+
].map(function (value) { return normalizeCollectionKey(normalizeOptionalString(value)); }).filter(Boolean);
|
|
7749
|
+
return rawKeys.some(function (key) { return intentKeys.includes(key); });
|
|
7750
|
+
});
|
|
7751
|
+
return (selected === null || selected === void 0 ? void 0 : selected.intent) || ((_b = candidates[0]) === null || _b === void 0 ? void 0 : _b.intent) || null;
|
|
7752
|
+
}
|
|
7753
|
+
function classifyAssistantAppDataRequest(params) {
|
|
7754
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7755
|
+
var candidates, serverConfig, apiKey, model, timeoutMs, messages, start, client, response, parsed, intent, contract, understanding, error_15;
|
|
7756
|
+
var _a, _b, _c;
|
|
7757
|
+
return __generator(this, function (_d) {
|
|
7758
|
+
switch (_d.label) {
|
|
7759
|
+
case 0:
|
|
7760
|
+
if (!resolveAssistantDataRequestClassifierEnabled(params.config)) {
|
|
7761
|
+
return [2 /*return*/, {
|
|
7762
|
+
debug: {
|
|
7763
|
+
enabled: false,
|
|
7764
|
+
reason: 'disabled'
|
|
7765
|
+
}
|
|
7766
|
+
}];
|
|
7767
|
+
}
|
|
7768
|
+
candidates = rankAssistantAppDataIntentCandidates(params.message, params.collectionNames, params.appId, { includeUnscored: true, limit: 6 });
|
|
7769
|
+
if (!candidates.length) {
|
|
7770
|
+
return [2 /*return*/, {
|
|
7771
|
+
debug: {
|
|
7772
|
+
enabled: true,
|
|
7773
|
+
attempted: false,
|
|
7774
|
+
reason: 'no_app_data_intent_candidates'
|
|
7775
|
+
}
|
|
7776
|
+
}];
|
|
7777
|
+
}
|
|
7778
|
+
serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
7779
|
+
apiKey = normalizeOptionalString(serverConfig['OPENAI_API_KEY'] || process.env.OPENAI_API_KEY);
|
|
7780
|
+
if (!apiKey) {
|
|
7781
|
+
return [2 /*return*/, {
|
|
7782
|
+
debug: {
|
|
7783
|
+
enabled: true,
|
|
7784
|
+
attempted: false,
|
|
7785
|
+
reason: 'missing_openai_api_key',
|
|
7786
|
+
candidates: candidates.map(function (candidate) { return ({ intentId: candidate.intent.id, score: candidate.score }); })
|
|
7787
|
+
}
|
|
7788
|
+
}];
|
|
7789
|
+
}
|
|
7790
|
+
model = resolveAssistantDataRequestClassifierModel(params.config);
|
|
7791
|
+
timeoutMs = resolveAssistantDataRequestClassifierTimeoutMs(params.config);
|
|
7792
|
+
messages = buildAssistantDataRequestClassifierMessages({
|
|
7793
|
+
message: params.message,
|
|
7794
|
+
appId: params.appId,
|
|
7795
|
+
candidates: candidates
|
|
7796
|
+
});
|
|
7797
|
+
start = Date.now();
|
|
7798
|
+
_d.label = 1;
|
|
7799
|
+
case 1:
|
|
7800
|
+
_d.trys.push([1, 3, , 4]);
|
|
7801
|
+
client = new openai_client_1.OpenAIClient({
|
|
7802
|
+
apiKey: apiKey,
|
|
7803
|
+
baseUrl: normalizeOptionalString(serverConfig['OPENAI_BASE_URL'] || process.env.OPENAI_BASE_URL) || undefined,
|
|
7804
|
+
model: model,
|
|
7805
|
+
temperature: 0,
|
|
7806
|
+
maxRetries: 0,
|
|
7807
|
+
maxTokens: resolveAssistantDataRequestClassifierMaxTokens(),
|
|
7808
|
+
responseFormat: 'json_object'
|
|
7809
|
+
});
|
|
7810
|
+
return [4 /*yield*/, client.chat(messages, {
|
|
7811
|
+
timeoutMs: timeoutMs,
|
|
7812
|
+
responseFormat: 'json_object'
|
|
7813
|
+
})];
|
|
7814
|
+
case 2:
|
|
7815
|
+
response = _d.sent();
|
|
7816
|
+
parsed = parseJsonObject(response.content);
|
|
7817
|
+
intent = resolveAssistantDataRequestClassifierIntent(parsed, candidates);
|
|
7818
|
+
contract = intent
|
|
7819
|
+
? normalizeAssistantDataRequestContract(parsed, intent, params.dateWindow, 'mini_model_classifier')
|
|
7820
|
+
: null;
|
|
7821
|
+
understanding = intent && contract
|
|
7822
|
+
? buildAssistantDataRequestUnderstanding(params.message, intent, params.dateWindow, contract)
|
|
7823
|
+
: null;
|
|
7824
|
+
return [2 /*return*/, {
|
|
7825
|
+
intent: intent,
|
|
7826
|
+
understanding: understanding,
|
|
7827
|
+
debug: {
|
|
7828
|
+
enabled: true,
|
|
7829
|
+
attempted: true,
|
|
7830
|
+
succeeded: !!understanding,
|
|
7831
|
+
model: response.model || model,
|
|
7832
|
+
durationMs: Date.now() - start,
|
|
7833
|
+
intentId: (intent === null || intent === void 0 ? void 0 : intent.id) || undefined,
|
|
7834
|
+
requestedBreakdowns: ((_a = understanding === null || understanding === void 0 ? void 0 : understanding.contract) === null || _a === void 0 ? void 0 : _a.requested_breakdowns) || undefined,
|
|
7835
|
+
ambiguities: ((_b = understanding === null || understanding === void 0 ? void 0 : understanding.contract) === null || _b === void 0 ? void 0 : _b.ambiguities) || undefined,
|
|
7836
|
+
confidence: (_c = understanding === null || understanding === void 0 ? void 0 : understanding.contract) === null || _c === void 0 ? void 0 : _c.confidence,
|
|
7837
|
+
candidates: candidates.map(function (candidate) { return ({ intentId: candidate.intent.id, score: candidate.score }); }),
|
|
7838
|
+
parseSucceeded: !!parsed
|
|
7839
|
+
},
|
|
7840
|
+
usage: response.usage ? {
|
|
7841
|
+
model: response.model || model,
|
|
7842
|
+
inputTokens: response.usage.inputTokens,
|
|
7843
|
+
outputTokens: response.usage.outputTokens,
|
|
7844
|
+
totalTokens: response.usage.totalTokens,
|
|
7845
|
+
requestId: response.requestId
|
|
7846
|
+
} : undefined
|
|
7847
|
+
}];
|
|
7848
|
+
case 3:
|
|
7849
|
+
error_15 = _d.sent();
|
|
7850
|
+
return [2 /*return*/, {
|
|
7851
|
+
debug: {
|
|
7852
|
+
enabled: true,
|
|
7853
|
+
attempted: true,
|
|
7854
|
+
succeeded: false,
|
|
7855
|
+
model: model,
|
|
7856
|
+
durationMs: Date.now() - start,
|
|
7857
|
+
error: normalizeOptionalString(error_15 === null || error_15 === void 0 ? void 0 : error_15.message) || 'classifier_failed',
|
|
7858
|
+
candidates: candidates.map(function (candidate) { return ({ intentId: candidate.intent.id, score: candidate.score }); })
|
|
7859
|
+
}
|
|
7860
|
+
}];
|
|
7861
|
+
case 4: return [2 /*return*/];
|
|
7862
|
+
}
|
|
7863
|
+
});
|
|
7864
|
+
});
|
|
7865
|
+
}
|
|
7866
|
+
function buildAssistantDataRequestUnderstanding(message, intent, dateWindow, classifierContract) {
|
|
7867
|
+
var normalizedClassifierContract = classifierContract
|
|
7868
|
+
? normalizeAssistantDataRequestContract(classifierContract, intent, dateWindow, classifierContract.source || 'mini_model_classifier')
|
|
7869
|
+
: null;
|
|
7870
|
+
var requestedBreakdownCandidates = buildAssistantRequestedBreakdownCandidates(message, normalizedClassifierContract);
|
|
7359
7871
|
var dimensions = [];
|
|
7360
7872
|
var requestedBreakdowns = [];
|
|
7361
7873
|
var ambiguities = [];
|
|
@@ -7365,11 +7877,19 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow) {
|
|
|
7365
7877
|
if (!id || seenDimensionIds.has(id)) {
|
|
7366
7878
|
return;
|
|
7367
7879
|
}
|
|
7880
|
+
if ((dimension.type || '') === 'time' && dimensions.some(function (entry) { return (entry.type || '') === 'time'; })) {
|
|
7881
|
+
return;
|
|
7882
|
+
}
|
|
7368
7883
|
seenDimensionIds.add(id);
|
|
7369
7884
|
dimensions.push(dimension);
|
|
7370
7885
|
};
|
|
7371
|
-
|
|
7372
|
-
var
|
|
7886
|
+
requestedBreakdownCandidates.forEach(function (candidate) {
|
|
7887
|
+
var _a;
|
|
7888
|
+
var requestedDimensionText = candidate.text;
|
|
7889
|
+
var requestedGranularity = ((_a = candidate.breakdown) === null || _a === void 0 ? void 0 : _a.granularity) || resolveAssistantTimeBreakdownGranularity(requestedDimensionText);
|
|
7890
|
+
var timeDimension = requestedGranularity
|
|
7891
|
+
? buildAssistantDataIntentTimeDimension(requestedGranularity, intent)
|
|
7892
|
+
: null;
|
|
7373
7893
|
if (timeDimension) {
|
|
7374
7894
|
addDimension(timeDimension);
|
|
7375
7895
|
requestedBreakdowns.push({
|
|
@@ -7381,18 +7901,21 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow) {
|
|
|
7381
7901
|
});
|
|
7382
7902
|
return;
|
|
7383
7903
|
}
|
|
7384
|
-
if (
|
|
7904
|
+
if (requestedGranularity && !intent.dateField) {
|
|
7385
7905
|
ambiguities.push("Requested ".concat(requestedDimensionText, " breakdown, but this app data intent has no date field."));
|
|
7386
7906
|
requestedBreakdowns.push({
|
|
7387
7907
|
type: 'unknown',
|
|
7388
7908
|
requested_text: requestedDimensionText,
|
|
7389
|
-
granularity:
|
|
7909
|
+
granularity: requestedGranularity
|
|
7390
7910
|
});
|
|
7391
7911
|
return;
|
|
7392
7912
|
}
|
|
7393
7913
|
var selected = null;
|
|
7394
7914
|
(intent.dimensions || []).forEach(function (dimension) {
|
|
7395
|
-
var
|
|
7915
|
+
var _a;
|
|
7916
|
+
var score = Math.max(scoreAssistantDataDimensionMatch(requestedDimensionText, dimension), ((_a = candidate.breakdown) === null || _a === void 0 ? void 0 : _a.dimension) && cleanAssistantRequestedDimensionText(candidate.breakdown.dimension) === cleanAssistantRequestedDimensionText(dimension.id)
|
|
7917
|
+
? 10
|
|
7918
|
+
: 0);
|
|
7396
7919
|
if (score <= 0) {
|
|
7397
7920
|
return;
|
|
7398
7921
|
}
|
|
@@ -7418,24 +7941,26 @@ function buildAssistantDataRequestUnderstanding(message, intent, dateWindow) {
|
|
|
7418
7941
|
});
|
|
7419
7942
|
});
|
|
7420
7943
|
var confidence = requestedBreakdowns.length && !ambiguities.length
|
|
7421
|
-
? 0.9
|
|
7944
|
+
? clampAssistantConfidence(normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.confidence, 0.9)
|
|
7422
7945
|
: requestedBreakdowns.length
|
|
7423
|
-
? 0.65
|
|
7424
|
-
: 0.75;
|
|
7946
|
+
? clampAssistantConfidence(normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.confidence, 0.65)
|
|
7947
|
+
: clampAssistantConfidence(normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.confidence, 0.75);
|
|
7425
7948
|
return {
|
|
7426
7949
|
dimensions: dimensions,
|
|
7427
7950
|
contract: {
|
|
7428
7951
|
intent_type: 'data_summary',
|
|
7952
|
+
intent_id: (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.intent_id) || intent.id,
|
|
7429
7953
|
domain: intent.id || intent.collection,
|
|
7954
|
+
collection: intent.collection,
|
|
7430
7955
|
operation: 'aggregate',
|
|
7431
7956
|
requested_breakdowns: requestedBreakdowns,
|
|
7432
|
-
date_range: dateWindow.start || dateWindow.end ? __assign({}, dateWindow) : null,
|
|
7433
|
-
measures: [],
|
|
7434
|
-
filters: [],
|
|
7957
|
+
date_range: (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.date_range) || (dateWindow.start || dateWindow.end ? __assign({}, dateWindow) : null),
|
|
7958
|
+
measures: (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.measures) || [],
|
|
7959
|
+
filters: (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.filters) || [],
|
|
7435
7960
|
output_format: 'collapse_table',
|
|
7436
|
-
ambiguities: ambiguities,
|
|
7961
|
+
ambiguities: mergeAssistantHintValues((normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.ambiguities) || [], ambiguities),
|
|
7437
7962
|
confidence: confidence,
|
|
7438
|
-
source: 'fast_app_data_request_contract'
|
|
7963
|
+
source: (normalizedClassifierContract === null || normalizedClassifierContract === void 0 ? void 0 : normalizedClassifierContract.source) || 'fast_app_data_request_contract'
|
|
7439
7964
|
}
|
|
7440
7965
|
};
|
|
7441
7966
|
}
|
|
@@ -7519,15 +8044,16 @@ function applyAssistantDataIntentDimensionsToPipeline(pipeline, dimensions) {
|
|
|
7519
8044
|
}
|
|
7520
8045
|
return next;
|
|
7521
8046
|
}
|
|
7522
|
-
function buildAssistantAppDataIntentDirective(message, collectionNames, appId) {
|
|
8047
|
+
function buildAssistantAppDataIntentDirective(message, collectionNames, appId, options) {
|
|
7523
8048
|
if (collectionNames === void 0) { collectionNames = []; }
|
|
7524
|
-
var intent = selectAssistantAppDataIntent(message, collectionNames, appId);
|
|
8049
|
+
var intent = (options === null || options === void 0 ? void 0 : options.appDataIntent) || selectAssistantAppDataIntent(message, collectionNames, appId);
|
|
7525
8050
|
if (!intent) {
|
|
7526
8051
|
return null;
|
|
7527
8052
|
}
|
|
7528
8053
|
var customerText = extractAssistantDataIntentCustomerText(message);
|
|
7529
8054
|
var dateWindow = resolveAssistantDataIntentDateWindow(message);
|
|
7530
|
-
var requestUnderstanding =
|
|
8055
|
+
var requestUnderstanding = (options === null || options === void 0 ? void 0 : options.appDataRequestUnderstanding)
|
|
8056
|
+
|| buildAssistantDataRequestUnderstanding(message, intent, dateWindow, (options === null || options === void 0 ? void 0 : options.appDataRequestContract) || null);
|
|
7531
8057
|
var templatedDimensions = requestUnderstanding.dimensions
|
|
7532
8058
|
.map(function (dimension) { return applyAssistantDataIntentDimensionTemplate(dimension, { customerText: customerText, dateWindow: dateWindow }); })
|
|
7533
8059
|
.filter(function (dimension) { return !!(dimension === null || dimension === void 0 ? void 0 : dimension.groupId); });
|
|
@@ -7537,27 +8063,15 @@ function buildAssistantAppDataIntentDirective(message, collectionNames, appId) {
|
|
|
7537
8063
|
.replace(/\{\{customer\}\}/g, customerText || 'the requested customer')
|
|
7538
8064
|
.replace(/\{\{year\}\}/g, dateWindow.year ? String(dateWindow.year) : 'the requested date range');
|
|
7539
8065
|
});
|
|
7540
|
-
var metadata = {
|
|
7541
|
-
intentId: intent.id,
|
|
7542
|
-
recipeUsed: intent.id,
|
|
7543
|
-
acknowledgementText: acknowledgementText,
|
|
7544
|
-
progress: progress,
|
|
7545
|
-
assumptions: intent.assumptions,
|
|
7546
|
-
fallbackCollections: intent.fallbackCollections,
|
|
7547
|
-
customerText: customerText,
|
|
7548
|
-
dateWindow: dateWindow,
|
|
7549
|
-
requestedDimension: templatedDimensions[0] ? {
|
|
8066
|
+
var metadata = __assign({ intentId: intent.id, recipeUsed: intent.id, acknowledgementText: acknowledgementText, progress: progress, assumptions: intent.assumptions, fallbackCollections: intent.fallbackCollections, customerText: customerText, dateWindow: dateWindow, requestedDimension: templatedDimensions[0] ? {
|
|
7550
8067
|
id: templatedDimensions[0].id,
|
|
7551
8068
|
terms: templatedDimensions[0].terms
|
|
7552
|
-
} : null,
|
|
7553
|
-
requestedDimensions: templatedDimensions.map(function (dimension) { return ({
|
|
8069
|
+
} : null, requestedDimensions: templatedDimensions.map(function (dimension) { return ({
|
|
7554
8070
|
id: dimension.id,
|
|
7555
8071
|
type: dimension.type || 'entity',
|
|
7556
8072
|
granularity: dimension.granularity || undefined,
|
|
7557
8073
|
terms: dimension.terms
|
|
7558
|
-
}); }),
|
|
7559
|
-
requestContract: requestUnderstanding.contract
|
|
7560
|
-
};
|
|
8074
|
+
}); }), requestContract: requestUnderstanding.contract }, ((options === null || options === void 0 ? void 0 : options.appDataRequestClassifier) ? { requestClassifier: options.appDataRequestClassifier } : {}));
|
|
7561
8075
|
var basePayload = function (pipeline) { return ({
|
|
7562
8076
|
collection: intent.collection,
|
|
7563
8077
|
permissionView: intent.permissionView || resolveDefaultAssistantPermissionView(intent.collection),
|
|
@@ -7576,13 +8090,13 @@ function isAssistantDeterministicHeuristicDirective(directive) {
|
|
|
7576
8090
|
return isAssistantSchemaHoursHeuristicDirective(directive)
|
|
7577
8091
|
|| isAssistantAppDataIntentHeuristicDirective(directive);
|
|
7578
8092
|
}
|
|
7579
|
-
function buildAssistantHeuristicDirective(message, collectionHints, collectionNames, appId) {
|
|
8093
|
+
function buildAssistantHeuristicDirective(message, collectionHints, collectionNames, appId, options) {
|
|
7580
8094
|
if (collectionNames === void 0) { collectionNames = []; }
|
|
7581
8095
|
if (!normalizeOptionalString(message)) {
|
|
7582
8096
|
return null;
|
|
7583
8097
|
}
|
|
7584
8098
|
var appDataIntentDirective = resolveAssistantDeterministicHeuristicEnabled(AI_ASSISTANT_HEURISTIC_ID_APP_DATA_INTENT, appId)
|
|
7585
|
-
? buildAssistantAppDataIntentDirective(message, collectionNames, appId)
|
|
8099
|
+
? buildAssistantAppDataIntentDirective(message, collectionNames, appId, options)
|
|
7586
8100
|
: null;
|
|
7587
8101
|
if (appDataIntentDirective) {
|
|
7588
8102
|
return appDataIntentDirective;
|
|
@@ -7595,9 +8109,17 @@ function buildAssistantHeuristicDirective(message, collectionHints, collectionNa
|
|
|
7595
8109
|
}
|
|
7596
8110
|
return null;
|
|
7597
8111
|
}
|
|
7598
|
-
function resolveAssistantHeuristicDirectiveForTesting(message, collectionHints, collectionNames, appId) {
|
|
8112
|
+
function resolveAssistantHeuristicDirectiveForTesting(message, collectionHints, collectionNames, appId, options) {
|
|
7599
8113
|
if (collectionNames === void 0) { collectionNames = []; }
|
|
7600
|
-
return buildAssistantHeuristicDirective(message, collectionHints, collectionNames, appId);
|
|
8114
|
+
return buildAssistantHeuristicDirective(message, collectionHints, collectionNames, appId, options);
|
|
8115
|
+
}
|
|
8116
|
+
function buildAssistantDataRequestClassifierMessagesForTesting(params) {
|
|
8117
|
+
var candidates = rankAssistantAppDataIntentCandidates(params.message, params.collectionNames || [], params.appId, { includeUnscored: true, limit: 6 });
|
|
8118
|
+
return buildAssistantDataRequestClassifierMessages({
|
|
8119
|
+
message: params.message,
|
|
8120
|
+
appId: params.appId,
|
|
8121
|
+
candidates: candidates
|
|
8122
|
+
});
|
|
7601
8123
|
}
|
|
7602
8124
|
function resolveDefaultAssistantPermissionView(collection) {
|
|
7603
8125
|
var normalizedCollection = normalizeOptionalString(collection).toLowerCase();
|
|
@@ -19784,7 +20306,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
19784
20306
|
}
|
|
19785
20307
|
function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler) {
|
|
19786
20308
|
return __awaiter(this, void 0, void 0, function () {
|
|
19787
|
-
var streamedOptions, normalizedThreadKey, shouldForceInProcessThreadReuse, codexClient, codexClient, workerPath, codexClient,
|
|
20309
|
+
var streamedOptions, normalizedThreadKey, shouldForceInProcessThreadReuse, codexClient, codexClient, workerPath, codexClient, error_16, codexClient;
|
|
19788
20310
|
return __generator(this, function (_a) {
|
|
19789
20311
|
switch (_a.label) {
|
|
19790
20312
|
case 0:
|
|
@@ -19812,11 +20334,11 @@ function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler)
|
|
|
19812
20334
|
return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler)];
|
|
19813
20335
|
case 8: return [2 /*return*/, _a.sent()];
|
|
19814
20336
|
case 9:
|
|
19815
|
-
|
|
19816
|
-
if (!(
|
|
19817
|
-
throw
|
|
20337
|
+
error_16 = _a.sent();
|
|
20338
|
+
if (!(error_16 instanceof CodexWorkerBootstrapError)) {
|
|
20339
|
+
throw error_16;
|
|
19818
20340
|
}
|
|
19819
|
-
console.error('AI worker bootstrap failed, falling back to in-process run.',
|
|
20341
|
+
console.error('AI worker bootstrap failed, falling back to in-process run.', error_16);
|
|
19820
20342
|
codexClient = getAssistantCodexClient(config);
|
|
19821
20343
|
return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
|
|
19822
20344
|
case 10: return [2 /*return*/, _a.sent()];
|
|
@@ -19854,7 +20376,7 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config,
|
|
|
19854
20376
|
timeoutMs = ((sanitizedOptions === null || sanitizedOptions === void 0 ? void 0 : sanitizedOptions.timeoutMs) || resolveCodexTimeoutMs()) + 15000;
|
|
19855
20377
|
timeoutController = new AbortController();
|
|
19856
20378
|
timeoutPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
19857
|
-
var
|
|
20379
|
+
var error_17;
|
|
19858
20380
|
return __generator(this, function (_a) {
|
|
19859
20381
|
switch (_a.label) {
|
|
19860
20382
|
case 0:
|
|
@@ -19864,11 +20386,11 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config,
|
|
|
19864
20386
|
_a.sent();
|
|
19865
20387
|
return [2 /*return*/, { type: 'timeout' }];
|
|
19866
20388
|
case 2:
|
|
19867
|
-
|
|
19868
|
-
if ((
|
|
20389
|
+
error_17 = _a.sent();
|
|
20390
|
+
if ((error_17 === null || error_17 === void 0 ? void 0 : error_17.name) === 'AbortError') {
|
|
19869
20391
|
return [2 /*return*/, { type: 'aborted' }];
|
|
19870
20392
|
}
|
|
19871
|
-
throw
|
|
20393
|
+
throw error_17;
|
|
19872
20394
|
case 3: return [2 /*return*/];
|
|
19873
20395
|
}
|
|
19874
20396
|
});
|
|
@@ -23718,7 +24240,7 @@ function resolveAssistantDatabaseNameForSystemCollections() {
|
|
|
23718
24240
|
}
|
|
23719
24241
|
function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
23720
24242
|
return __awaiter(this, void 0, void 0, function () {
|
|
23721
|
-
var safeSetPayload, fallbackId, debugEnabled, result,
|
|
24243
|
+
var safeSetPayload, fallbackId, debugEnabled, result, error_18, dbName, messagesCollection, result, _a, retryResult;
|
|
23722
24244
|
var _b, _c, _d, _e, _f, _g;
|
|
23723
24245
|
return __generator(this, function (_h) {
|
|
23724
24246
|
switch (_h.label) {
|
|
@@ -23757,14 +24279,14 @@ function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
|
23757
24279
|
}
|
|
23758
24280
|
return [2 /*return*/];
|
|
23759
24281
|
case 5:
|
|
23760
|
-
|
|
23761
|
-
if (!isAssistantTransactionCommittedError(
|
|
23762
|
-
throw
|
|
24282
|
+
error_18 = _h.sent();
|
|
24283
|
+
if (!isAssistantTransactionCommittedError(error_18)) {
|
|
24284
|
+
throw error_18;
|
|
23763
24285
|
}
|
|
23764
24286
|
if (debugEnabled) {
|
|
23765
24287
|
console.log(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update fallback triggered', {
|
|
23766
24288
|
messageId: fallbackId || messageId,
|
|
23767
|
-
reason: normalizeOptionalString(
|
|
24289
|
+
reason: normalizeOptionalString(error_18 === null || error_18 === void 0 ? void 0 : error_18.message) || 'transaction_committed'
|
|
23768
24290
|
});
|
|
23769
24291
|
}
|
|
23770
24292
|
dbName = resolveAssistantDatabaseNameForSystemCollections();
|
|
@@ -23840,7 +24362,7 @@ function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
|
23840
24362
|
}
|
|
23841
24363
|
function touchConversation(idConversation, timestamp, lastMessageId) {
|
|
23842
24364
|
return __awaiter(this, void 0, void 0, function () {
|
|
23843
|
-
var update, result,
|
|
24365
|
+
var update, result, error_19, dbName, conversationsCollection, fallbackResult;
|
|
23844
24366
|
return __generator(this, function (_a) {
|
|
23845
24367
|
switch (_a.label) {
|
|
23846
24368
|
case 0:
|
|
@@ -23865,9 +24387,9 @@ function touchConversation(idConversation, timestamp, lastMessageId) {
|
|
|
23865
24387
|
}
|
|
23866
24388
|
return [2 /*return*/];
|
|
23867
24389
|
case 3:
|
|
23868
|
-
|
|
23869
|
-
if (!isAssistantTransactionCommittedError(
|
|
23870
|
-
throw
|
|
24390
|
+
error_19 = _a.sent();
|
|
24391
|
+
if (!isAssistantTransactionCommittedError(error_19)) {
|
|
24392
|
+
throw error_19;
|
|
23871
24393
|
}
|
|
23872
24394
|
dbName = resolveAssistantDatabaseNameForSystemCollections();
|
|
23873
24395
|
conversationsCollection = resolveio_server_app_1.ResolveIOServer.getMongoConnection()
|
|
@@ -24139,7 +24661,7 @@ function buildAssistantAIRunId(prefix, parts) {
|
|
|
24139
24661
|
}
|
|
24140
24662
|
function recordAssistantAnswerAIRun(input) {
|
|
24141
24663
|
return __awaiter(this, void 0, void 0, function () {
|
|
24142
|
-
var messages, run,
|
|
24664
|
+
var messages, run, error_20;
|
|
24143
24665
|
return __generator(this, function (_a) {
|
|
24144
24666
|
switch (_a.label) {
|
|
24145
24667
|
case 0:
|
|
@@ -24164,8 +24686,8 @@ function recordAssistantAnswerAIRun(input) {
|
|
|
24164
24686
|
_a.sent();
|
|
24165
24687
|
return [3 /*break*/, 3];
|
|
24166
24688
|
case 2:
|
|
24167
|
-
|
|
24168
|
-
console.error(new Date(), 'Failed to record AI assistant AIRun evidence',
|
|
24689
|
+
error_20 = _a.sent();
|
|
24690
|
+
console.error(new Date(), 'Failed to record AI assistant AIRun evidence', error_20);
|
|
24169
24691
|
return [3 /*break*/, 3];
|
|
24170
24692
|
case 3: return [2 /*return*/];
|
|
24171
24693
|
}
|