@resolveio/server-lib 22.1.26 → 22.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/methods/ai-terminal.js
CHANGED
|
@@ -1754,10 +1754,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1754
1754
|
insertResult = _d.sent();
|
|
1755
1755
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1756
1756
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1757
|
-
var runStart, steps, recordStep, progressTracker, streamProgress, assistantContent, toolResult, assistantDebug, directiveSource, requestClassification, dataQuestion, lastDirective, heuristicDirectivePrecomputed, usedDeterministicHeuristicFastPath, requestedTimeGrain, requestedBreakdownDimensions, enforceDatedDirective, enforceGroupedDirective, datedDirectiveRetryUsed, datedDirectiveResolved, toolResponseDebug, toolError, termHints, collectionHints, fieldHints, methodHints, publicationHints, collectionTokenization, collectionRanking, collectionSelection, collectionOverride, collectionNames, plannerEnabled, plannerUsed, plannerSkipReason, plannerOutput, plannerRaw, timingBreakdown, codexUsage, accumulateCodexUsage, contextRoute, contextMode, hintSeed, termExpansion, hintText, baseTokens, expandedTokens, baseWeights, expandedWeights, dbName, db, surfaceHints, _a, allowedRoutes, rankedAllowedRoutes, routeHints, rankedCollectionHints, rankedCollections, hintCollections, assistantContext, hasDeterministicHeuristicFastPath, prompt_1, workspaceRoot, codexConfig, runOptions, plannerRunOptions, shouldRunPlanner, plannerPrompt, plannerStart, _b, preferListDirective, directiveStyleHint, directivePromptMode, responseText, directiveText, directive, heuristicDirectiveFastPath, directivePrompt, directiveStart, forcedDirective, _c, initialStart, extractedDirective, error_2, directivePrompt, forcedStart, forcedDirective, _d, strictDirectivePrompt, strictStart, strictDirectiveText, strictDirective, strictDirectiveIsDated, shouldUseStrictDirective, _e, guardDirectivePrompt, guardStart, guardDirectiveText, guardDirective, _f, groupedDirectivePrompt, groupedStart, groupedDirectiveText, groupedDirective, _g, heuristicDirective, requestedCollection, allowCollectionOverride, cleanedResponseText, deniedModuleByIntent, permissionLabel, effectiveDirective, toolRequest, toolStart, toolResponse, _h, toolPayload, skipFollowupCodex, followupPrompt, followupStart, followupText, _j, error_3, error_4, finishedAt, finalNow, finishedAt, codexMs, draftingMs, finalMetadata, finalUsage, usageClientId, usageError_1, finalAssistantDoc, setPayload;
|
|
1758
|
-
var
|
|
1759
|
-
return __generator(this, function (
|
|
1760
|
-
switch (
|
|
1757
|
+
var runStart, steps, recordStep, progressTracker, streamProgress, assistantContent, toolResult, assistantDebug, directiveSource, requestClassification, dataQuestion, lastDirective, heuristicDirectivePrecomputed, usedDeterministicHeuristicFastPath, requestedTimeGrain, requestedBreakdownDimensions, enforceDatedDirective, enforceGroupedDirective, datedDirectiveRetryUsed, datedDirectiveResolved, toolResponseDebug, toolError, termHints, collectionHints, fieldHints, methodHints, publicationHints, collectionTokenization, collectionRanking, collectionSelection, collectionOverride, collectionNames, plannerEnabled, plannerUsed, plannerSkipReason, plannerOutput, plannerRaw, timingBreakdown, codexUsage, accumulateCodexUsage, contextRoute, contextMode, hintSeed, termExpansion, hintText, baseTokens, expandedTokens, baseWeights, expandedWeights, dbName, db, surfaceHints, _a, allowedRoutes, rankedAllowedRoutes, routeHints, rankedCollectionHints, rankedCollections, hintCollections, assistantContext, hasDeterministicHeuristicFastPath, prompt_1, workspaceRoot, codexConfig, runOptions, plannerRunOptions, shouldRunPlanner, plannerPrompt, plannerStart, _b, preferListDirective, directiveStyleHint, directivePromptMode, responseText, directiveText, directive, heuristicDirectiveFastPath, directivePrompt, directiveStart, forcedDirective, _c, initialStart, extractedDirective, error_2, directivePrompt, forcedStart, forcedDirective, _d, strictDirectivePrompt, strictStart, strictDirectiveText, strictDirective, strictDirectiveIsDated, shouldUseStrictDirective, _e, guardDirectivePrompt, guardStart, guardDirectiveText, guardDirective, _f, groupedDirectivePrompt, groupedStart, groupedDirectiveText, groupedDirective, _g, heuristicDirective, requestedCollection, allowCollectionOverride, cleanedResponseText, deniedModuleByIntent, permissionLabel, effectiveDirective, toolRequest, toolStart, toolResponse, _h, toolPayload, skipFollowupCodex, followupPrompt, followupStart, followupText, _j, error_3, error_4, finishedAt, finalNow, finishedAt, codexMs, draftingMs, finalMetadata, finalUsage, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _k;
|
|
1758
|
+
var _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;
|
|
1759
|
+
return __generator(this, function (_14) {
|
|
1760
|
+
switch (_14.label) {
|
|
1761
1761
|
case 0:
|
|
1762
1762
|
runStart = Date.now();
|
|
1763
1763
|
if (aiWorkerDebug) {
|
|
@@ -1837,8 +1837,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1837
1837
|
codexUsage.output_tokens += outputTokens;
|
|
1838
1838
|
codexUsage.total_tokens += inputTokens + outputTokens;
|
|
1839
1839
|
};
|
|
1840
|
-
contextRoute = normalizeOptionalString((
|
|
1841
|
-
contextMode = normalizeOptionalString((
|
|
1840
|
+
contextRoute = normalizeOptionalString((_l = input === null || input === void 0 ? void 0 : input.context) === null || _l === void 0 ? void 0 : _l.route);
|
|
1841
|
+
contextMode = normalizeOptionalString((_m = input === null || input === void 0 ? void 0 : input.context) === null || _m === void 0 ? void 0 : _m.mode);
|
|
1842
1842
|
recordStep('Queued', { requestId: requestId || undefined });
|
|
1843
1843
|
if (changeHistoryFastPathBypassedReason) {
|
|
1844
1844
|
recordStep('Planning: change-history fast path unavailable', {
|
|
@@ -1850,9 +1850,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1850
1850
|
source: requestClassification.source,
|
|
1851
1851
|
dataQuestion: dataQuestion
|
|
1852
1852
|
});
|
|
1853
|
-
|
|
1853
|
+
_14.label = 1;
|
|
1854
1854
|
case 1:
|
|
1855
|
-
|
|
1855
|
+
_14.trys.push([1, 53, 54, 55]);
|
|
1856
1856
|
hintSeed = [message, contextRoute].filter(Boolean).join(' ');
|
|
1857
1857
|
termExpansion = expandAssistantTermSynonyms(hintSeed);
|
|
1858
1858
|
hintText = termExpansion.expanded || hintSeed;
|
|
@@ -1873,19 +1873,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1873
1873
|
recordStep('Planning: term expansion', {
|
|
1874
1874
|
termMatches: termExpansion.matches.length ? termExpansion.matches : undefined
|
|
1875
1875
|
});
|
|
1876
|
-
|
|
1876
|
+
_14.label = 2;
|
|
1877
1877
|
case 2:
|
|
1878
|
-
|
|
1878
|
+
_14.trys.push([2, 5, , 6]);
|
|
1879
1879
|
dbName = resolveAssistantDatabaseName(undefined, input.mongo);
|
|
1880
1880
|
db = resolveio_server_app_1.ResolveIOServer.getMongoConnection().db(dbName);
|
|
1881
1881
|
return [4 /*yield*/, listAssistantCollections(db, dbName)];
|
|
1882
1882
|
case 3:
|
|
1883
|
-
collectionNames =
|
|
1883
|
+
collectionNames = _14.sent();
|
|
1884
1884
|
collectionHints = resolveCollectionHintsFromTokens(expandedTokens, collectionNames, 5);
|
|
1885
1885
|
collectionRanking = buildCollectionRankingDebugFromTokens(expandedTokens, collectionNames, 8);
|
|
1886
1886
|
return [4 /*yield*/, resolveAssistantSurfaceHints(hintSeed, contextRoute, collectionNames)];
|
|
1887
1887
|
case 4:
|
|
1888
|
-
surfaceHints =
|
|
1888
|
+
surfaceHints = _14.sent();
|
|
1889
1889
|
methodHints = surfaceHints.methodHints;
|
|
1890
1890
|
publicationHints = surfaceHints.publicationHints;
|
|
1891
1891
|
if (surfaceHints.collectionHints.length) {
|
|
@@ -1893,7 +1893,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1893
1893
|
}
|
|
1894
1894
|
return [3 /*break*/, 6];
|
|
1895
1895
|
case 5:
|
|
1896
|
-
_a =
|
|
1896
|
+
_a = _14.sent();
|
|
1897
1897
|
collectionHints = [];
|
|
1898
1898
|
collectionRanking = collectionRanking || ((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens)
|
|
1899
1899
|
? buildCollectionRankingDebugFromTokens(collectionTokenization.expandedTokens || [], [], 0)
|
|
@@ -1956,14 +1956,14 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1956
1956
|
if (hasDeterministicHeuristicFastPath) {
|
|
1957
1957
|
recordStep('Planning: heuristic directive fast path', {
|
|
1958
1958
|
type: heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.type,
|
|
1959
|
-
collection: normalizeOptionalString((
|
|
1959
|
+
collection: normalizeOptionalString((_o = heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.payload) === null || _o === void 0 ? void 0 : _o.collection) || undefined,
|
|
1960
1960
|
heuristic: normalizeOptionalString(heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.rawLine) || undefined
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
prompt_1 = buildAssistantCodexPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext);
|
|
1964
1964
|
return [4 /*yield*/, resolveAssistantWorkspaceRoot()];
|
|
1965
1965
|
case 7:
|
|
1966
|
-
workspaceRoot =
|
|
1966
|
+
workspaceRoot = _14.sent();
|
|
1967
1967
|
codexConfig = resolveCodexSettings({
|
|
1968
1968
|
model: codexModel,
|
|
1969
1969
|
fallbackModels: codexFallbackModels
|
|
@@ -2010,20 +2010,20 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2010
2010
|
publicationHints: publicationHints,
|
|
2011
2011
|
inputClientId: input.id_client
|
|
2012
2012
|
});
|
|
2013
|
-
|
|
2013
|
+
_14.label = 8;
|
|
2014
2014
|
case 8:
|
|
2015
|
-
|
|
2015
|
+
_14.trys.push([8, 10, , 11]);
|
|
2016
2016
|
plannerStart = Date.now();
|
|
2017
2017
|
return [4 /*yield*/, runCodexInWorkerThread(plannerPrompt, plannerRunOptions, codexConfig, streamProgress)];
|
|
2018
2018
|
case 9:
|
|
2019
|
-
plannerRaw =
|
|
2019
|
+
plannerRaw = _14.sent();
|
|
2020
2020
|
accumulateCodexUsage(plannerPrompt, plannerRaw);
|
|
2021
2021
|
timingBreakdown.plannerMs = Date.now() - plannerStart;
|
|
2022
2022
|
plannerOutput = parseJsonObject(plannerRaw);
|
|
2023
2023
|
recordStep('Planning: planner result', { parsed: !!plannerOutput });
|
|
2024
2024
|
return [3 /*break*/, 11];
|
|
2025
2025
|
case 10:
|
|
2026
|
-
_b =
|
|
2026
|
+
_b = _14.sent();
|
|
2027
2027
|
recordStep('Planning: planner result', { parsed: false });
|
|
2028
2028
|
return [3 /*break*/, 11];
|
|
2029
2029
|
case 11: return [3 /*break*/, 13];
|
|
@@ -2040,7 +2040,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2040
2040
|
}
|
|
2041
2041
|
recordStep('Planning: planner skipped', { reason: plannerSkipReason });
|
|
2042
2042
|
}
|
|
2043
|
-
|
|
2043
|
+
_14.label = 13;
|
|
2044
2044
|
case 13:
|
|
2045
2045
|
requestClassification = classifyAssistantRequestType(message, plannerOutput || undefined);
|
|
2046
2046
|
dataQuestion = requestClassification.dataQuestion;
|
|
@@ -2082,12 +2082,12 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2082
2082
|
directiveSource = 'forced';
|
|
2083
2083
|
lastDirective = heuristicDirectiveFastPath;
|
|
2084
2084
|
usedDeterministicHeuristicFastPath = true;
|
|
2085
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2085
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_p = directive.payload) === null || _p === void 0 ? void 0 : _p.collection) || '');
|
|
2086
2086
|
recordStep('Directive resolved', {
|
|
2087
2087
|
source: directiveSource,
|
|
2088
2088
|
type: directive.type,
|
|
2089
|
-
collection: normalizeOptionalString((
|
|
2090
|
-
permissionView: normalizeOptionalString((
|
|
2089
|
+
collection: normalizeOptionalString((_q = directive.payload) === null || _q === void 0 ? void 0 : _q.collection) || undefined,
|
|
2090
|
+
permissionView: normalizeOptionalString((_r = directive.payload) === null || _r === void 0 ? void 0 : _r.permissionView) || undefined,
|
|
2091
2091
|
reportStyle: 'heuristic_fast_path',
|
|
2092
2092
|
timeGrain: requestedTimeGrain || undefined
|
|
2093
2093
|
});
|
|
@@ -2095,13 +2095,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2095
2095
|
if (!(dataQuestion && !directive)) return [3 /*break*/, 17];
|
|
2096
2096
|
recordStep('Directive: determine tool', { type: 'data-question' });
|
|
2097
2097
|
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode);
|
|
2098
|
-
|
|
2098
|
+
_14.label = 14;
|
|
2099
2099
|
case 14:
|
|
2100
|
-
|
|
2100
|
+
_14.trys.push([14, 16, , 17]);
|
|
2101
2101
|
directiveStart = Date.now();
|
|
2102
2102
|
return [4 /*yield*/, runCodexInWorkerThread(directivePrompt, runOptions, codexConfig, streamProgress)];
|
|
2103
2103
|
case 15:
|
|
2104
|
-
directiveText =
|
|
2104
|
+
directiveText = _14.sent();
|
|
2105
2105
|
accumulateCodexUsage(directivePrompt, directiveText);
|
|
2106
2106
|
timingBreakdown.directiveMs = Date.now() - directiveStart;
|
|
2107
2107
|
forcedDirective = extractAssistantMongoDirective(directiveText);
|
|
@@ -2109,28 +2109,28 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2109
2109
|
directive = forcedDirective;
|
|
2110
2110
|
directiveSource = 'model';
|
|
2111
2111
|
lastDirective = forcedDirective;
|
|
2112
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2112
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_s = directive.payload) === null || _s === void 0 ? void 0 : _s.collection) || '');
|
|
2113
2113
|
recordStep('Directive resolved', {
|
|
2114
2114
|
source: directiveSource,
|
|
2115
2115
|
type: directive.type,
|
|
2116
|
-
collection: normalizeOptionalString((
|
|
2117
|
-
permissionView: normalizeOptionalString((
|
|
2116
|
+
collection: normalizeOptionalString((_t = directive.payload) === null || _t === void 0 ? void 0 : _t.collection) || undefined,
|
|
2117
|
+
permissionView: normalizeOptionalString((_u = directive.payload) === null || _u === void 0 ? void 0 : _u.permissionView) || undefined
|
|
2118
2118
|
});
|
|
2119
2119
|
}
|
|
2120
2120
|
return [3 /*break*/, 17];
|
|
2121
2121
|
case 16:
|
|
2122
|
-
_c =
|
|
2122
|
+
_c = _14.sent();
|
|
2123
2123
|
return [3 /*break*/, 17];
|
|
2124
2124
|
case 17:
|
|
2125
2125
|
if (!(!directive && !dataQuestion)) return [3 /*break*/, 21];
|
|
2126
2126
|
recordStep('Response: draft initial answer', { mode: 'full' });
|
|
2127
|
-
|
|
2127
|
+
_14.label = 18;
|
|
2128
2128
|
case 18:
|
|
2129
|
-
|
|
2129
|
+
_14.trys.push([18, 20, , 21]);
|
|
2130
2130
|
initialStart = Date.now();
|
|
2131
2131
|
return [4 /*yield*/, runCodexInWorkerThread(prompt_1, runOptions, codexConfig, streamProgress)];
|
|
2132
2132
|
case 19:
|
|
2133
|
-
responseText =
|
|
2133
|
+
responseText = _14.sent();
|
|
2134
2134
|
accumulateCodexUsage(prompt_1, responseText);
|
|
2135
2135
|
timingBreakdown.initialResponseMs = Date.now() - initialStart;
|
|
2136
2136
|
extractedDirective = extractAssistantMongoDirective(responseText);
|
|
@@ -2138,17 +2138,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2138
2138
|
if (directive) {
|
|
2139
2139
|
directiveSource = 'model';
|
|
2140
2140
|
lastDirective = directive;
|
|
2141
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2141
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_v = directive.payload) === null || _v === void 0 ? void 0 : _v.collection) || '');
|
|
2142
2142
|
recordStep('Directive resolved', {
|
|
2143
2143
|
source: directiveSource,
|
|
2144
2144
|
type: directive.type,
|
|
2145
|
-
collection: normalizeOptionalString((
|
|
2146
|
-
permissionView: normalizeOptionalString((
|
|
2145
|
+
collection: normalizeOptionalString((_w = directive.payload) === null || _w === void 0 ? void 0 : _w.collection) || undefined,
|
|
2146
|
+
permissionView: normalizeOptionalString((_x = directive.payload) === null || _x === void 0 ? void 0 : _x.permissionView) || undefined
|
|
2147
2147
|
});
|
|
2148
2148
|
}
|
|
2149
2149
|
return [3 /*break*/, 21];
|
|
2150
2150
|
case 20:
|
|
2151
|
-
error_2 =
|
|
2151
|
+
error_2 = _14.sent();
|
|
2152
2152
|
recordStep('Response: initial draft failed', {
|
|
2153
2153
|
message: normalizeOptionalString(error_2 === null || error_2 === void 0 ? void 0 : error_2.message) || 'Unknown error'
|
|
2154
2154
|
});
|
|
@@ -2157,13 +2157,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2157
2157
|
if (!(!directive && dataQuestion)) return [3 /*break*/, 25];
|
|
2158
2158
|
recordStep('Directive: forced retry', { mode: 'directive-only' });
|
|
2159
2159
|
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode);
|
|
2160
|
-
|
|
2160
|
+
_14.label = 22;
|
|
2161
2161
|
case 22:
|
|
2162
|
-
|
|
2162
|
+
_14.trys.push([22, 24, , 25]);
|
|
2163
2163
|
forcedStart = Date.now();
|
|
2164
2164
|
return [4 /*yield*/, runCodexInWorkerThread(directivePrompt, runOptions, codexConfig, streamProgress)];
|
|
2165
2165
|
case 23:
|
|
2166
|
-
directiveText =
|
|
2166
|
+
directiveText = _14.sent();
|
|
2167
2167
|
accumulateCodexUsage(directivePrompt, directiveText);
|
|
2168
2168
|
timingBreakdown.forcedDirectiveMs = Date.now() - forcedStart;
|
|
2169
2169
|
forcedDirective = extractAssistantMongoDirective(directiveText);
|
|
@@ -2171,17 +2171,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2171
2171
|
directive = forcedDirective;
|
|
2172
2172
|
directiveSource = 'forced';
|
|
2173
2173
|
lastDirective = forcedDirective;
|
|
2174
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2174
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_y = directive.payload) === null || _y === void 0 ? void 0 : _y.collection) || '');
|
|
2175
2175
|
recordStep('Directive resolved', {
|
|
2176
2176
|
source: directiveSource,
|
|
2177
2177
|
type: directive.type,
|
|
2178
|
-
collection: normalizeOptionalString((
|
|
2179
|
-
permissionView: normalizeOptionalString((
|
|
2178
|
+
collection: normalizeOptionalString((_z = directive.payload) === null || _z === void 0 ? void 0 : _z.collection) || undefined,
|
|
2179
|
+
permissionView: normalizeOptionalString((_0 = directive.payload) === null || _0 === void 0 ? void 0 : _0.permissionView) || undefined
|
|
2180
2180
|
});
|
|
2181
2181
|
}
|
|
2182
2182
|
return [3 /*break*/, 25];
|
|
2183
2183
|
case 24:
|
|
2184
|
-
_d =
|
|
2184
|
+
_d = _14.sent();
|
|
2185
2185
|
return [3 /*break*/, 25];
|
|
2186
2186
|
case 25:
|
|
2187
2187
|
if (!(directive
|
|
@@ -2199,13 +2199,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2199
2199
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2200
2200
|
strict: true
|
|
2201
2201
|
}), 'aggregate_only');
|
|
2202
|
-
|
|
2202
|
+
_14.label = 26;
|
|
2203
2203
|
case 26:
|
|
2204
|
-
|
|
2204
|
+
_14.trys.push([26, 28, , 29]);
|
|
2205
2205
|
strictStart = Date.now();
|
|
2206
2206
|
return [4 /*yield*/, runCodexInWorkerThread(strictDirectivePrompt, runOptions, codexConfig, streamProgress)];
|
|
2207
2207
|
case 27:
|
|
2208
|
-
strictDirectiveText =
|
|
2208
|
+
strictDirectiveText = _14.sent();
|
|
2209
2209
|
accumulateCodexUsage(strictDirectivePrompt, strictDirectiveText);
|
|
2210
2210
|
timingBreakdown.forcedDirectiveMs += Date.now() - strictStart;
|
|
2211
2211
|
strictDirective = extractAssistantMongoDirective(strictDirectiveText);
|
|
@@ -2216,19 +2216,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2216
2216
|
directiveSource = 'forced';
|
|
2217
2217
|
lastDirective = strictDirective;
|
|
2218
2218
|
datedDirectiveRetryUsed = true;
|
|
2219
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2219
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_1 = directive.payload) === null || _1 === void 0 ? void 0 : _1.collection) || '');
|
|
2220
2220
|
recordStep('Directive resolved', {
|
|
2221
2221
|
source: directiveSource,
|
|
2222
2222
|
type: directive.type,
|
|
2223
|
-
collection: normalizeOptionalString((
|
|
2224
|
-
permissionView: normalizeOptionalString((
|
|
2223
|
+
collection: normalizeOptionalString((_2 = directive.payload) === null || _2 === void 0 ? void 0 : _2.collection) || undefined,
|
|
2224
|
+
permissionView: normalizeOptionalString((_3 = directive.payload) === null || _3 === void 0 ? void 0 : _3.permissionView) || undefined,
|
|
2225
2225
|
reportStyle: strictDirectiveIsDated ? 'dated' : 'aggregate_fallback',
|
|
2226
2226
|
timeGrain: requestedTimeGrain || undefined
|
|
2227
2227
|
});
|
|
2228
2228
|
}
|
|
2229
2229
|
return [3 /*break*/, 29];
|
|
2230
2230
|
case 28:
|
|
2231
|
-
_e =
|
|
2231
|
+
_e = _14.sent();
|
|
2232
2232
|
return [3 /*break*/, 29];
|
|
2233
2233
|
case 29:
|
|
2234
2234
|
if (!(directive
|
|
@@ -2246,13 +2246,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2246
2246
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2247
2247
|
strict: true
|
|
2248
2248
|
}), 'aggregate_only');
|
|
2249
|
-
|
|
2249
|
+
_14.label = 30;
|
|
2250
2250
|
case 30:
|
|
2251
|
-
|
|
2251
|
+
_14.trys.push([30, 32, , 33]);
|
|
2252
2252
|
guardStart = Date.now();
|
|
2253
2253
|
return [4 /*yield*/, runCodexInWorkerThread(guardDirectivePrompt, runOptions, codexConfig, streamProgress)];
|
|
2254
2254
|
case 31:
|
|
2255
|
-
guardDirectiveText =
|
|
2255
|
+
guardDirectiveText = _14.sent();
|
|
2256
2256
|
accumulateCodexUsage(guardDirectivePrompt, guardDirectiveText);
|
|
2257
2257
|
timingBreakdown.forcedDirectiveMs += Date.now() - guardStart;
|
|
2258
2258
|
guardDirective = extractAssistantMongoDirective(guardDirectiveText);
|
|
@@ -2261,19 +2261,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2261
2261
|
directiveSource = 'forced';
|
|
2262
2262
|
lastDirective = guardDirective;
|
|
2263
2263
|
datedDirectiveRetryUsed = true;
|
|
2264
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2264
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_4 = directive.payload) === null || _4 === void 0 ? void 0 : _4.collection) || '');
|
|
2265
2265
|
recordStep('Directive resolved', {
|
|
2266
2266
|
source: directiveSource,
|
|
2267
2267
|
type: directive.type,
|
|
2268
|
-
collection: normalizeOptionalString((
|
|
2269
|
-
permissionView: normalizeOptionalString((
|
|
2268
|
+
collection: normalizeOptionalString((_5 = directive.payload) === null || _5 === void 0 ? void 0 : _5.collection) || undefined,
|
|
2269
|
+
permissionView: normalizeOptionalString((_6 = directive.payload) === null || _6 === void 0 ? void 0 : _6.permissionView) || undefined,
|
|
2270
2270
|
reportStyle: isAssistantDirectiveDated(guardDirective) ? 'dated' : 'aggregate_fallback',
|
|
2271
2271
|
timeGrain: requestedTimeGrain || undefined
|
|
2272
2272
|
});
|
|
2273
2273
|
}
|
|
2274
2274
|
return [3 /*break*/, 33];
|
|
2275
2275
|
case 32:
|
|
2276
|
-
_f =
|
|
2276
|
+
_f = _14.sent();
|
|
2277
2277
|
return [3 /*break*/, 33];
|
|
2278
2278
|
case 33:
|
|
2279
2279
|
if (!(directive
|
|
@@ -2291,13 +2291,13 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2291
2291
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2292
2292
|
strict: true
|
|
2293
2293
|
}), 'aggregate_only');
|
|
2294
|
-
|
|
2294
|
+
_14.label = 34;
|
|
2295
2295
|
case 34:
|
|
2296
|
-
|
|
2296
|
+
_14.trys.push([34, 36, , 37]);
|
|
2297
2297
|
groupedStart = Date.now();
|
|
2298
2298
|
return [4 /*yield*/, runCodexInWorkerThread(groupedDirectivePrompt, runOptions, codexConfig, streamProgress)];
|
|
2299
2299
|
case 35:
|
|
2300
|
-
groupedDirectiveText =
|
|
2300
|
+
groupedDirectiveText = _14.sent();
|
|
2301
2301
|
accumulateCodexUsage(groupedDirectivePrompt, groupedDirectiveText);
|
|
2302
2302
|
timingBreakdown.forcedDirectiveMs += Date.now() - groupedStart;
|
|
2303
2303
|
groupedDirective = extractAssistantMongoDirective(groupedDirectiveText);
|
|
@@ -2306,12 +2306,12 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2306
2306
|
directiveSource = 'forced';
|
|
2307
2307
|
lastDirective = groupedDirective;
|
|
2308
2308
|
datedDirectiveRetryUsed = true;
|
|
2309
|
-
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((
|
|
2309
|
+
collectionSelection = buildCollectionSelectionDetail((collectionTokenization === null || collectionTokenization === void 0 ? void 0 : collectionTokenization.expandedTokens) || [], normalizeOptionalString((_7 = directive.payload) === null || _7 === void 0 ? void 0 : _7.collection) || '');
|
|
2310
2310
|
recordStep('Directive resolved', {
|
|
2311
2311
|
source: directiveSource,
|
|
2312
2312
|
type: directive.type,
|
|
2313
|
-
collection: normalizeOptionalString((
|
|
2314
|
-
permissionView: normalizeOptionalString((
|
|
2313
|
+
collection: normalizeOptionalString((_8 = directive.payload) === null || _8 === void 0 ? void 0 : _8.collection) || undefined,
|
|
2314
|
+
permissionView: normalizeOptionalString((_9 = directive.payload) === null || _9 === void 0 ? void 0 : _9.permissionView) || undefined,
|
|
2315
2315
|
reportStyle: isAssistantDirectiveDated(groupedDirective)
|
|
2316
2316
|
? 'dated'
|
|
2317
2317
|
: 'grouped',
|
|
@@ -2321,7 +2321,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2321
2321
|
}
|
|
2322
2322
|
return [3 /*break*/, 37];
|
|
2323
2323
|
case 36:
|
|
2324
|
-
_g =
|
|
2324
|
+
_g = _14.sent();
|
|
2325
2325
|
return [3 /*break*/, 37];
|
|
2326
2326
|
case 37:
|
|
2327
2327
|
if (!directive && dataQuestion) {
|
|
@@ -2333,21 +2333,21 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2333
2333
|
recordStep('Directive resolved', {
|
|
2334
2334
|
source: directiveSource,
|
|
2335
2335
|
type: directive.type,
|
|
2336
|
-
collection: normalizeOptionalString((
|
|
2337
|
-
permissionView: normalizeOptionalString((
|
|
2336
|
+
collection: normalizeOptionalString((_10 = directive.payload) === null || _10 === void 0 ? void 0 : _10.collection) || undefined,
|
|
2337
|
+
permissionView: normalizeOptionalString((_11 = directive.payload) === null || _11 === void 0 ? void 0 : _11.permissionView) || undefined,
|
|
2338
2338
|
reportStyle: 'heuristic_fallback'
|
|
2339
2339
|
});
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
2342
|
if (directive) {
|
|
2343
|
-
requestedCollection = normalizeOptionalString((
|
|
2343
|
+
requestedCollection = normalizeOptionalString((_12 = directive.payload) === null || _12 === void 0 ? void 0 : _12.collection);
|
|
2344
2344
|
allowCollectionOverride = !isAssistantDeterministicHeuristicDirective(directive);
|
|
2345
2345
|
collectionOverride = allowCollectionOverride
|
|
2346
2346
|
? resolveCollectionOverrideWithContext({
|
|
2347
2347
|
message: message,
|
|
2348
2348
|
collectionRanking: collectionRanking,
|
|
2349
2349
|
requestedCollection: requestedCollection,
|
|
2350
|
-
permissionView: normalizeOptionalString((
|
|
2350
|
+
permissionView: normalizeOptionalString((_13 = directive.payload) === null || _13 === void 0 ? void 0 : _13.permissionView) || contextRoute,
|
|
2351
2351
|
collectionNames: collectionNames
|
|
2352
2352
|
})
|
|
2353
2353
|
: null;
|
|
@@ -2390,19 +2390,19 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2390
2390
|
collection: normalizeOptionalString(toolRequest === null || toolRequest === void 0 ? void 0 : toolRequest.collection) || undefined,
|
|
2391
2391
|
permissionView: normalizeOptionalString(toolRequest === null || toolRequest === void 0 ? void 0 : toolRequest.permissionView) || undefined
|
|
2392
2392
|
});
|
|
2393
|
-
|
|
2393
|
+
_14.label = 39;
|
|
2394
2394
|
case 39:
|
|
2395
|
-
|
|
2395
|
+
_14.trys.push([39, 49, , 50]);
|
|
2396
2396
|
toolStart = Date.now();
|
|
2397
2397
|
if (!(effectiveDirective.type === 'aggregate')) return [3 /*break*/, 41];
|
|
2398
2398
|
return [4 /*yield*/, executeAiAssistantReportBuilderAggregate(toolRequest, context)];
|
|
2399
2399
|
case 40:
|
|
2400
|
-
_h =
|
|
2400
|
+
_h = _14.sent();
|
|
2401
2401
|
return [3 /*break*/, 43];
|
|
2402
2402
|
case 41: return [4 /*yield*/, executeAiAssistantReportBuilderRead(toolRequest, context)];
|
|
2403
2403
|
case 42:
|
|
2404
|
-
_h =
|
|
2405
|
-
|
|
2404
|
+
_h = _14.sent();
|
|
2405
|
+
_14.label = 43;
|
|
2406
2406
|
case 43:
|
|
2407
2407
|
toolResponse = _h;
|
|
2408
2408
|
timingBreakdown.toolMs = Date.now() - toolStart;
|
|
@@ -2429,26 +2429,26 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2429
2429
|
case 44:
|
|
2430
2430
|
recordStep('Drafting response');
|
|
2431
2431
|
followupPrompt = buildAssistantCodexToolFollowupPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, toolPayload.prompt);
|
|
2432
|
-
|
|
2432
|
+
_14.label = 45;
|
|
2433
2433
|
case 45:
|
|
2434
|
-
|
|
2434
|
+
_14.trys.push([45, 47, , 48]);
|
|
2435
2435
|
followupStart = Date.now();
|
|
2436
2436
|
return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, runOptions, codexConfig, streamProgress)];
|
|
2437
2437
|
case 46:
|
|
2438
|
-
followupText =
|
|
2438
|
+
followupText = _14.sent();
|
|
2439
2439
|
accumulateCodexUsage(followupPrompt, followupText);
|
|
2440
2440
|
timingBreakdown.followupMs = Date.now() - followupStart;
|
|
2441
2441
|
assistantContent = sanitizeAssistantResponse(followupText);
|
|
2442
2442
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2443
2443
|
return [3 /*break*/, 48];
|
|
2444
2444
|
case 47:
|
|
2445
|
-
_j =
|
|
2445
|
+
_j = _14.sent();
|
|
2446
2446
|
assistantContent = buildAssistantToolFallbackResponse(toolPayload.result);
|
|
2447
2447
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
2448
2448
|
return [3 /*break*/, 48];
|
|
2449
2449
|
case 48: return [3 /*break*/, 50];
|
|
2450
2450
|
case 49:
|
|
2451
|
-
error_3 =
|
|
2451
|
+
error_3 = _14.sent();
|
|
2452
2452
|
assistantContent = buildAssistantToolErrorMessage(error_3);
|
|
2453
2453
|
toolError = error_3;
|
|
2454
2454
|
return [3 /*break*/, 50];
|
|
@@ -2456,10 +2456,10 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2456
2456
|
case 51:
|
|
2457
2457
|
progressTracker.push('Drafting response');
|
|
2458
2458
|
recordStep('Drafting response');
|
|
2459
|
-
|
|
2459
|
+
_14.label = 52;
|
|
2460
2460
|
case 52: return [3 /*break*/, 55];
|
|
2461
2461
|
case 53:
|
|
2462
|
-
error_4 =
|
|
2462
|
+
error_4 = _14.sent();
|
|
2463
2463
|
assistantContent = buildAssistantCodexErrorMessage(error_4);
|
|
2464
2464
|
recordStep('Error', { message: normalizeOptionalString(error_4 === null || error_4 === void 0 ? void 0 : error_4.message) || 'Unknown error' });
|
|
2465
2465
|
return [3 /*break*/, 55];
|
|
@@ -2490,6 +2490,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
2492
2492
|
finalNow = new Date();
|
|
2493
|
+
_14.label = 56;
|
|
2494
|
+
case 56:
|
|
2495
|
+
_14.trys.push([56, 67, , 78]);
|
|
2493
2496
|
if (canViewDebug) {
|
|
2494
2497
|
finishedAt = Date.now();
|
|
2495
2498
|
codexMs = timingBreakdown.directiveMs
|
|
@@ -2557,7 +2560,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2557
2560
|
}
|
|
2558
2561
|
});
|
|
2559
2562
|
}
|
|
2560
|
-
finalMetadata = __assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), (changeHistoryFastPathBypassedReason ? {
|
|
2563
|
+
finalMetadata = __assign(__assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false }), (changeHistoryFastPathBypassedReason ? {
|
|
2561
2564
|
fast_path_change_history_bypassed_reason: changeHistoryFastPathBypassedReason
|
|
2562
2565
|
} : {})), (toolResult ? { tool_result: toolResult } : {})), (assistantDebug ? { debug: assistantDebug } : {}));
|
|
2563
2566
|
finalUsage = codexUsage.total_tokens > 0 ? {
|
|
@@ -2566,14 +2569,14 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2566
2569
|
output_tokens: codexUsage.output_tokens,
|
|
2567
2570
|
total_tokens: codexUsage.total_tokens
|
|
2568
2571
|
} : null;
|
|
2569
|
-
if (!finalUsage) return [3 /*break*/,
|
|
2572
|
+
if (!finalUsage) return [3 /*break*/, 61];
|
|
2570
2573
|
return [4 /*yield*/, resolveClientId(conversation, input.id_client, context === null || context === void 0 ? void 0 : context.id_user)];
|
|
2571
|
-
case 56:
|
|
2572
|
-
usageClientId = _13.sent();
|
|
2573
|
-
if (!usageClientId) return [3 /*break*/, 60];
|
|
2574
|
-
_13.label = 57;
|
|
2575
2574
|
case 57:
|
|
2576
|
-
|
|
2575
|
+
usageClientId = _14.sent();
|
|
2576
|
+
if (!usageClientId) return [3 /*break*/, 61];
|
|
2577
|
+
_14.label = 58;
|
|
2578
|
+
case 58:
|
|
2579
|
+
_14.trys.push([58, 60, , 61]);
|
|
2577
2580
|
return [4 /*yield*/, (0, openai_usage_ledger_manager_1.recordOpenAIUsage)({
|
|
2578
2581
|
id_client: usageClientId,
|
|
2579
2582
|
model: finalUsage.model,
|
|
@@ -2584,16 +2587,16 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2584
2587
|
id_request: requestId || undefined,
|
|
2585
2588
|
id_conversation: conversation._id
|
|
2586
2589
|
})];
|
|
2587
|
-
case 58:
|
|
2588
|
-
_13.sent();
|
|
2589
|
-
return [3 /*break*/, 60];
|
|
2590
2590
|
case 59:
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
return [3 /*break*/, 60];
|
|
2591
|
+
_14.sent();
|
|
2592
|
+
return [3 /*break*/, 61];
|
|
2594
2593
|
case 60:
|
|
2594
|
+
usageError_1 = _14.sent();
|
|
2595
|
+
console.error(new Date(), 'Failed to record codex usage', usageError_1);
|
|
2596
|
+
return [3 /*break*/, 61];
|
|
2597
|
+
case 61:
|
|
2595
2598
|
finalAssistantDoc = __assign(__assign(__assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: assistantContent, metadata: finalMetadata }), (finalUsage ? { usage: finalUsage } : {})), { updatedAt: finalNow });
|
|
2596
|
-
if (!assistantMessageId) return [3 /*break*/,
|
|
2599
|
+
if (!assistantMessageId) return [3 /*break*/, 63];
|
|
2597
2600
|
setPayload = {
|
|
2598
2601
|
content: assistantContent,
|
|
2599
2602
|
metadata: finalMetadata,
|
|
@@ -2603,18 +2606,59 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2603
2606
|
setPayload.usage = finalUsage;
|
|
2604
2607
|
}
|
|
2605
2608
|
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, setPayload)];
|
|
2606
|
-
case
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
case
|
|
2610
|
-
case 63:
|
|
2611
|
-
_13.sent();
|
|
2612
|
-
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 65];
|
|
2613
|
-
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
2609
|
+
case 62:
|
|
2610
|
+
_14.sent();
|
|
2611
|
+
_14.label = 63;
|
|
2612
|
+
case 63: return [4 /*yield*/, touchConversation(conversation._id, finalNow, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
2614
2613
|
case 64:
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2614
|
+
_14.sent();
|
|
2615
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 66];
|
|
2616
|
+
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
2617
|
+
case 65:
|
|
2618
|
+
_14.sent();
|
|
2619
|
+
_14.label = 66;
|
|
2620
|
+
case 66: return [2 /*return*/, finalAssistantDoc];
|
|
2621
|
+
case 67:
|
|
2622
|
+
finalizeError_1 = _14.sent();
|
|
2623
|
+
failedAt = new Date();
|
|
2624
|
+
fallbackContent = assistantContent || buildAssistantCodexErrorMessage(finalizeError_1);
|
|
2625
|
+
failureMetadata = __assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false, failed: true, error_message: normalizeOptionalString(finalizeError_1 === null || finalizeError_1 === void 0 ? void 0 : finalizeError_1.message) || 'Unknown error' });
|
|
2626
|
+
_14.label = 68;
|
|
2627
|
+
case 68:
|
|
2628
|
+
_14.trys.push([68, 72, , 73]);
|
|
2629
|
+
if (!assistantMessageId) return [3 /*break*/, 70];
|
|
2630
|
+
return [4 /*yield*/, updateAssistantMessageWithFallback(assistantMessageId, {
|
|
2631
|
+
content: fallbackContent,
|
|
2632
|
+
metadata: failureMetadata,
|
|
2633
|
+
updatedAt: failedAt
|
|
2634
|
+
})];
|
|
2635
|
+
case 69:
|
|
2636
|
+
_14.sent();
|
|
2637
|
+
_14.label = 70;
|
|
2638
|
+
case 70: return [4 /*yield*/, touchConversation(conversation._id, failedAt, assistantMessageId ? String(assistantMessageId) : undefined)];
|
|
2639
|
+
case 71:
|
|
2640
|
+
_14.sent();
|
|
2641
|
+
return [3 /*break*/, 73];
|
|
2642
|
+
case 72:
|
|
2643
|
+
persistError_1 = _14.sent();
|
|
2644
|
+
console.error(new Date(), 'AI assistant finalize fallback update failed', persistError_1);
|
|
2645
|
+
return [3 /*break*/, 73];
|
|
2646
|
+
case 73:
|
|
2647
|
+
if (!(input.delete_files_after_run !== false)) return [3 /*break*/, 77];
|
|
2648
|
+
_14.label = 74;
|
|
2649
|
+
case 74:
|
|
2650
|
+
_14.trys.push([74, 76, , 77]);
|
|
2651
|
+
return [4 /*yield*/, cleanupAttachments(attachmentData.attachments)];
|
|
2652
|
+
case 75:
|
|
2653
|
+
_14.sent();
|
|
2654
|
+
return [3 /*break*/, 77];
|
|
2655
|
+
case 76:
|
|
2656
|
+
_k = _14.sent();
|
|
2657
|
+
return [3 /*break*/, 77];
|
|
2658
|
+
case 77:
|
|
2659
|
+
console.error(new Date(), 'AI assistant run finalize failed:', finalizeError_1);
|
|
2660
|
+
return [2 /*return*/, __assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: fallbackContent, metadata: failureMetadata, updatedAt: failedAt })];
|
|
2661
|
+
case 78: return [2 /*return*/];
|
|
2618
2662
|
}
|
|
2619
2663
|
});
|
|
2620
2664
|
}); });
|