@resolveio/server-lib 22.3.158 → 22.3.160
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 +1 -0
- package/methods/ai-terminal.js +133 -3
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
- package/util/ai-run-evidence-adapters.d.ts +37 -0
- package/util/ai-run-evidence-adapters.js +988 -79
- package/util/ai-run-evidence-adapters.js.map +1 -1
- package/util/ai-run-evidence.d.ts +1 -1
- package/util/ai-run-evidence.js.map +1 -1
- package/util/ai-runner-manager-autopilot.d.ts +99 -1
- package/util/ai-runner-manager-autopilot.js +370 -41
- package/util/ai-runner-manager-autopilot.js.map +1 -1
- package/util/ai-runner-manager-policy.d.ts +159 -0
- package/util/ai-runner-manager-policy.js +782 -30
- package/util/ai-runner-manager-policy.js.map +1 -1
- package/util/aicoder-runner-v6.d.ts +93 -3
- package/util/aicoder-runner-v6.js +699 -27
- package/util/aicoder-runner-v6.js.map +1 -1
- package/util/support-runner-v5.d.ts +192 -2
- package/util/support-runner-v5.js +1140 -74
- package/util/support-runner-v5.js.map +1 -1
package/methods/ai-terminal.d.ts
CHANGED
|
@@ -184,6 +184,7 @@ export declare function executeAiAssistantMongoAggregate(payload: AiAssistantMon
|
|
|
184
184
|
export declare function extractAssistantMongoDirective(content: string): AssistantMongoDirective | null;
|
|
185
185
|
export declare function buildAssistantToolRequest(directive: AssistantMongoDirective, payload: AiCodexRunInput, hints?: AiAssistantDirectiveHints): Record<string, any>;
|
|
186
186
|
export declare function shouldPreserveAssistantProbeCollectionForTesting(directive: any, resolvedCollection: string, probeResponse?: any): boolean;
|
|
187
|
+
export declare function buildAssistantAnswerQualityFromExecution(input?: Record<string, any>): Record<string, any>;
|
|
187
188
|
export declare function buildAssistantInvoiceCustomerLabelExpr(): Record<string, any>;
|
|
188
189
|
export declare function resolveAssistantHeuristicDirectiveForTesting(message: string, collectionHints: string[], collectionNames?: string[], appId?: string): any;
|
|
189
190
|
export declare function buildAssistantDatedPivotDisplay(display: AiAssistantDisplayTable, expectedMonths?: string[]): AiAssistantDisplayTable | null;
|
package/methods/ai-terminal.js
CHANGED
|
@@ -111,6 +111,7 @@ exports.executeAiAssistantMongoAggregate = executeAiAssistantMongoAggregate;
|
|
|
111
111
|
exports.extractAssistantMongoDirective = extractAssistantMongoDirective;
|
|
112
112
|
exports.buildAssistantToolRequest = buildAssistantToolRequest;
|
|
113
113
|
exports.shouldPreserveAssistantProbeCollectionForTesting = shouldPreserveAssistantProbeCollectionForTesting;
|
|
114
|
+
exports.buildAssistantAnswerQualityFromExecution = buildAssistantAnswerQualityFromExecution;
|
|
114
115
|
exports.buildAssistantInvoiceCustomerLabelExpr = buildAssistantInvoiceCustomerLabelExpr;
|
|
115
116
|
exports.resolveAssistantHeuristicDirectiveForTesting = resolveAssistantHeuristicDirectiveForTesting;
|
|
116
117
|
exports.buildAssistantDatedPivotDisplay = buildAssistantDatedPivotDisplay;
|
|
@@ -1969,7 +1970,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1969
1970
|
insertResult = _d.sent();
|
|
1970
1971
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1971
1972
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1972
|
-
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, _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, effectiveDirectiveMetadata, directiveAcknowledgementText, directiveProgressMessages, deterministicDataIntentDirective, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, executionDirective, probeFieldHints, aggregateProbeDisabled, probeEnabled, probeBudgetAllowed, probeDirective, probeRequest, probeStart, probeResponse, _h, probeDurationMs, probeRowCount, probeRewrite, probeError_1, probeDurationMs, probeErrorMessage, toolRequest, requestedToolCollection, toolStart, toolResponse, _j, toolDurationMs, toolPayload, resolvedToolCollection, zeroRowResult, followupCodexEnabled, skipFollowupCodex, followupPrompt, followupStart, followupText, _k, error_3, errorMessage, existingFinal, error_4, runBudgetExceeded, includeToolExecutionTelemetry, toolExecutionTelemetry, finishedAt, finalNow, finishedAt, codexMs, draftingMs, finalMetadata, finalUsage, finalUsageLedgerEntry, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _l;
|
|
1973
|
+
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, _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, effectiveDirectiveMetadata, directiveAcknowledgementText, directiveProgressMessages, deterministicDataIntentDirective, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, executionDirective, probeFieldHints, aggregateProbeDisabled, probeEnabled, probeBudgetAllowed, probeDirective, probeRequest, probeStart, probeResponse, _h, probeDurationMs, probeRowCount, probeRewrite, probeError_1, probeDurationMs, probeErrorMessage, toolRequest, requestedToolCollection, toolStart, toolResponse, _j, toolDurationMs, toolPayload, resolvedToolCollection, zeroRowResult, followupCodexEnabled, skipFollowupCodex, followupPrompt, followupStart, followupText, _k, error_3, errorMessage, existingFinal, error_4, runBudgetExceeded, includeToolExecutionTelemetry, toolExecutionTelemetry, finishedAt, finalNow, finishedAt, codexMs, draftingMs, answerQualityEvidence, finalMetadata, finalUsage, finalUsageLedgerEntry, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _l;
|
|
1973
1974
|
var _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, _21, _22;
|
|
1974
1975
|
return __generator(this, function (_23) {
|
|
1975
1976
|
switch (_23.label) {
|
|
@@ -3087,13 +3088,29 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3087
3088
|
}
|
|
3088
3089
|
});
|
|
3089
3090
|
}
|
|
3090
|
-
|
|
3091
|
+
answerQualityEvidence = buildAssistantAnswerQualityFromExecution({
|
|
3092
|
+
requestMessage: message,
|
|
3093
|
+
dataQuestion: dataQuestion,
|
|
3094
|
+
reportStyleIntent: enforceDatedDirective
|
|
3095
|
+
? 'dated'
|
|
3096
|
+
: (enforceGroupedDirective ? 'grouped' : null),
|
|
3097
|
+
requestedTimeGrain: requestedTimeGrain,
|
|
3098
|
+
datedDirectiveResolved: datedDirectiveResolved,
|
|
3099
|
+
enforceDatedDirective: enforceDatedDirective,
|
|
3100
|
+
directive: lastDirective,
|
|
3101
|
+
directiveSource: directiveSource,
|
|
3102
|
+
toolResult: toolResult,
|
|
3103
|
+
toolExecution: toolTelemetry,
|
|
3104
|
+
toolError: toolError,
|
|
3105
|
+
now: finalNow
|
|
3106
|
+
});
|
|
3107
|
+
finalMetadata = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), { pending: false }), (fastModeEnabled ? {
|
|
3091
3108
|
fast_mode: true,
|
|
3092
3109
|
run_budget_ms: runBudgetMs,
|
|
3093
3110
|
run_budget_exhausted: runBudgetExceeded
|
|
3094
3111
|
} : {})), (changeHistoryFastPathBypassedReason ? {
|
|
3095
3112
|
fast_path_change_history_bypassed_reason: changeHistoryFastPathBypassedReason
|
|
3096
|
-
} : {})), (toolResult ? { tool_result: toolResult } : {})), (toolExecutionTelemetry ? { tool_execution: toolExecutionTelemetry } : {})), (assistantDebug ? { debug: assistantDebug } : {}));
|
|
3113
|
+
} : {})), (toolResult ? { tool_result: toolResult } : {})), (toolExecutionTelemetry ? { tool_execution: toolExecutionTelemetry } : {})), { answer_quality: answerQualityEvidence }), (assistantDebug ? { debug: assistantDebug } : {}));
|
|
3097
3114
|
finalUsage = codexUsage.total_tokens > 0 ? {
|
|
3098
3115
|
model: codexModel || 'unknown',
|
|
3099
3116
|
input_tokens: codexUsage.input_tokens,
|
|
@@ -3166,6 +3183,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
3166
3183
|
observed: toolTelemetry.outcome.error,
|
|
3167
3184
|
message: 'Assistant tool execution reported an error.'
|
|
3168
3185
|
}] : [],
|
|
3186
|
+
answerQuality: answerQualityEvidence,
|
|
3169
3187
|
now: finalNow
|
|
3170
3188
|
})];
|
|
3171
3189
|
case 80:
|
|
@@ -6167,6 +6185,117 @@ function buildAssistantToolExecutionTelemetrySnapshot(telemetry) {
|
|
|
6167
6185
|
} : undefined
|
|
6168
6186
|
};
|
|
6169
6187
|
}
|
|
6188
|
+
function buildAssistantAnswerQualityFromExecution(input) {
|
|
6189
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
6190
|
+
if (input === void 0) { input = {}; }
|
|
6191
|
+
var toolResult = input.toolResult && typeof input.toolResult === 'object'
|
|
6192
|
+
? input.toolResult
|
|
6193
|
+
: null;
|
|
6194
|
+
var toolExecution = input.toolExecution && typeof input.toolExecution === 'object'
|
|
6195
|
+
? input.toolExecution
|
|
6196
|
+
: {};
|
|
6197
|
+
var nowValue = input.now instanceof Date ? input.now : (input.now ? new Date(input.now) : new Date());
|
|
6198
|
+
var currentDate = Number.isFinite(nowValue.getTime())
|
|
6199
|
+
? nowValue.toISOString().slice(0, 10)
|
|
6200
|
+
: new Date().toISOString().slice(0, 10);
|
|
6201
|
+
var outcome = toolExecution.outcome && typeof toolExecution.outcome === 'object' ? toolExecution.outcome : {};
|
|
6202
|
+
var final = toolExecution.final && typeof toolExecution.final === 'object' ? toolExecution.final : {};
|
|
6203
|
+
var toolErrorMessage = normalizeOptionalString(((_a = input.toolError) === null || _a === void 0 ? void 0 : _a.message) || input.toolError)
|
|
6204
|
+
|| normalizeOptionalString(outcome.error)
|
|
6205
|
+
|| normalizeOptionalString(final.error);
|
|
6206
|
+
var permissionDenied = toolExecution.permissionDenied === true
|
|
6207
|
+
|| toolExecution.permission_denied === true
|
|
6208
|
+
|| /permission|access denied|unauthorized|forbidden/i.test(toolErrorMessage);
|
|
6209
|
+
var rowCount = typeof ((_b = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _b === void 0 ? void 0 : _b.rowCount) === 'number'
|
|
6210
|
+
? toolResult.output.rowCount
|
|
6211
|
+
: (typeof final.rowCount === 'number'
|
|
6212
|
+
? final.rowCount
|
|
6213
|
+
: (typeof final.row_count === 'number' ? final.row_count : undefined));
|
|
6214
|
+
var dataQuestion = input.dataQuestion === true || input.data_question === true;
|
|
6215
|
+
var queryStatus = permissionDenied
|
|
6216
|
+
? 'permission_error'
|
|
6217
|
+
: (toolErrorMessage
|
|
6218
|
+
? 'query_error'
|
|
6219
|
+
: (toolResult
|
|
6220
|
+
? ((rowCount || 0) <= 0 ? 'no_data' : 'ok')
|
|
6221
|
+
: (dataQuestion ? 'unknown' : 'ok')));
|
|
6222
|
+
var collection = normalizeOptionalString((_c = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _c === void 0 ? void 0 : _c.collection)
|
|
6223
|
+
|| normalizeOptionalString(final.collection)
|
|
6224
|
+
|| normalizeOptionalString((_d = toolResult === null || toolResult === void 0 ? void 0 : toolResult.input) === null || _d === void 0 ? void 0 : _d.collection);
|
|
6225
|
+
var toolType = (toolResult === null || toolResult === void 0 ? void 0 : toolResult.type) || normalizeOptionalString(final.toolType || final.tool_type);
|
|
6226
|
+
var evidenceSeed = JSON.stringify({
|
|
6227
|
+
type: toolType,
|
|
6228
|
+
collection: collection,
|
|
6229
|
+
rowCount: rowCount,
|
|
6230
|
+
input: (toolResult === null || toolResult === void 0 ? void 0 : toolResult.input) || null
|
|
6231
|
+
});
|
|
6232
|
+
var evidenceId = (0, crypto_1.createHash)('sha1').update(evidenceSeed).digest('hex').slice(0, 12);
|
|
6233
|
+
var evidenceRef = toolResult
|
|
6234
|
+
? "assistant-tool:".concat(toolResult.type, ":").concat(collection || 'unknown', ":rows:").concat(Math.max(0, Number(rowCount || 0)), ":").concat(evidenceId)
|
|
6235
|
+
: '';
|
|
6236
|
+
var reportStyleIntent = normalizeOptionalString(input.reportStyleIntent || input.report_style_intent).toLowerCase();
|
|
6237
|
+
var requestedTimeGrain = normalizeOptionalString(input.requestedTimeGrain || input.requested_time_grain);
|
|
6238
|
+
var message = normalizeOptionalString(input.requestMessage || input.request_message);
|
|
6239
|
+
var relativeDateSignal = /\b(today|yesterday|tomorrow|this\s+(?:week|month|quarter|year)|last|past|recent|current\s+(?:week|month|quarter|year))\b/i.test(message);
|
|
6240
|
+
var dateWindow = resolveAssistantDatedReportWindow(toolResult);
|
|
6241
|
+
var requiresDateWindow = reportStyleIntent === 'dated'
|
|
6242
|
+
|| input.enforceDatedDirective === true
|
|
6243
|
+
|| input.enforce_dated_directive === true
|
|
6244
|
+
|| !!requestedTimeGrain
|
|
6245
|
+
|| input.datedDirectiveResolved === true
|
|
6246
|
+
|| input.dated_directive_resolved === true
|
|
6247
|
+
|| !!dateWindow
|
|
6248
|
+
|| (dataQuestion && relativeDateSignal);
|
|
6249
|
+
var illegalQueryShape = /positional.*projection|projection.*positional|invalid.*projection|query contains restricted operators/i.test(toolErrorMessage);
|
|
6250
|
+
var nextActions = queryStatus === 'permission_error'
|
|
6251
|
+
? ['Ask an authorized user or admin to grant access before answering from this dataset.']
|
|
6252
|
+
: queryStatus === 'query_error'
|
|
6253
|
+
? ['Fix the data query and rerun it before presenting the answer.']
|
|
6254
|
+
: queryStatus === 'no_data'
|
|
6255
|
+
? ['Confirm the date range, customer, and filters if matching records were expected.']
|
|
6256
|
+
: ['Use the cited system-data result as the answer evidence.'];
|
|
6257
|
+
var queryExecution = toolResult ? {
|
|
6258
|
+
id: evidenceRef,
|
|
6259
|
+
tool: toolType === 'mongo_agg'
|
|
6260
|
+
? 'aiAssistantMongoAggregate'
|
|
6261
|
+
: (toolType === 'mongo_read' ? 'aiAssistantMongoRead' : (toolType || 'aiAssistantTool')),
|
|
6262
|
+
type: toolType,
|
|
6263
|
+
status: queryStatus,
|
|
6264
|
+
queryStatus: queryStatus,
|
|
6265
|
+
collection: collection || undefined,
|
|
6266
|
+
resultCount: Math.max(0, Number(rowCount || 0)),
|
|
6267
|
+
rowCount: Math.max(0, Number(rowCount || 0)),
|
|
6268
|
+
legalQueryShape: !illegalQueryShape,
|
|
6269
|
+
input: toolResult.input || null,
|
|
6270
|
+
output: {
|
|
6271
|
+
collection: normalizeOptionalString((_e = toolResult.output) === null || _e === void 0 ? void 0 : _e.collection) || collection || undefined,
|
|
6272
|
+
rowCount: Math.max(0, Number(rowCount || 0)),
|
|
6273
|
+
columns: Array.isArray((_f = toolResult.output) === null || _f === void 0 ? void 0 : _f.columns) ? toolResult.output.columns.slice(0, 40) : [],
|
|
6274
|
+
total: typeof ((_g = toolResult.output) === null || _g === void 0 ? void 0 : _g.total) === 'number' ? toolResult.output.total : undefined,
|
|
6275
|
+
truncated: ((_h = toolResult.output) === null || _h === void 0 ? void 0 : _h.truncated) === true || ((_k = (_j = toolResult.output) === null || _j === void 0 ? void 0 : _j.display) === null || _k === void 0 ? void 0 : _k.truncated) === true
|
|
6276
|
+
}
|
|
6277
|
+
} : null;
|
|
6278
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({ queryStatus: queryStatus, noDataConfirmed: queryStatus === 'no_data' && !!toolResult, requiresQueryEvidence: dataQuestion }, (queryExecution ? {
|
|
6279
|
+
queryExecutions: [queryExecution],
|
|
6280
|
+
queryEvidenceRefs: evidenceRef ? [evidenceRef] : []
|
|
6281
|
+
} : {})), { requiresCurrentDate: requiresDateWindow, currentDateUsed: currentDate, expectedCurrentDate: currentDate, requiresDateWindow: requiresDateWindow }), (dateWindow ? {
|
|
6282
|
+
dateWindow: {
|
|
6283
|
+
startDate: dateWindow.startDate,
|
|
6284
|
+
endDate: dateWindow.endDate,
|
|
6285
|
+
months: dateWindow.months,
|
|
6286
|
+
mode: dateWindow.mode
|
|
6287
|
+
}
|
|
6288
|
+
} : {})), (illegalQueryShape ? {
|
|
6289
|
+
queryShape: {
|
|
6290
|
+
legal: false,
|
|
6291
|
+
reason: toolErrorMessage
|
|
6292
|
+
}
|
|
6293
|
+
} : {})), ((toolResult === null || toolResult === void 0 ? void 0 : toolResult.input) ? { mongoQuery: toolResult.input } : {})), { requiresCitations: dataQuestion, citationRefs: evidenceRef ? [evidenceRef] : [], evidenceRefs: evidenceRef ? [evidenceRef] : [], confidenceLevel: queryStatus === 'ok'
|
|
6294
|
+
? 'high'
|
|
6295
|
+
: (queryStatus === 'no_data' ? 'medium' : 'low'), nextActions: nextActions, dataSource: collection || undefined, costCategory: 'assistant_answer', canDraftSupportReply: queryStatus === 'ok' && !!evidenceRef, canAnswerCustomer: queryStatus === 'ok' && !!evidenceRef, requiresHumanReview: queryStatus !== 'ok', toolError: toolErrorMessage || undefined, dateSignalSource: requiresDateWindow
|
|
6296
|
+
? (dateWindow ? 'tool_window' : (reportStyleIntent === 'dated' || requestedTimeGrain ? 'directive_policy' : 'message_signal'))
|
|
6297
|
+
: undefined });
|
|
6298
|
+
}
|
|
6170
6299
|
function buildAssistantTrimmedStringExpr(value) {
|
|
6171
6300
|
return {
|
|
6172
6301
|
$trim: {
|
|
@@ -23150,6 +23279,7 @@ function recordAssistantAnswerAIRun(input) {
|
|
|
23150
23279
|
messages: messages,
|
|
23151
23280
|
usageLedger: input.usageLedgerEntry ? [input.usageLedgerEntry] : [],
|
|
23152
23281
|
correctnessChecks: input.correctnessChecks || [],
|
|
23282
|
+
answerQuality: input.answerQuality || {},
|
|
23153
23283
|
now: input.now || new Date()
|
|
23154
23284
|
});
|
|
23155
23285
|
return [4 /*yield*/, ai_run_evidence_manager_1.AIRunEvidenceManager.upsertRuns([run])];
|