@resolveio/server-lib 22.2.54 → 22.2.56
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/managers/method.manager.d.ts +4 -0
- package/managers/method.manager.js +76 -11
- package/managers/method.manager.js.map +1 -1
- package/methods/ai-terminal.d.ts +10 -0
- package/methods/ai-terminal.js +462 -142
- package/methods/ai-terminal.js.map +1 -1
- package/methods/pdf.js +42 -21
- package/methods/pdf.js.map +1 -1
- package/package.json +1 -1
- package/publications.ts +6 -6
- package/services/codex-client.js +1 -1
- package/services/codex-client.js.map +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -110,9 +110,11 @@ exports.executeAiAssistantMongoRead = executeAiAssistantMongoRead;
|
|
|
110
110
|
exports.executeAiAssistantMongoAggregate = executeAiAssistantMongoAggregate;
|
|
111
111
|
exports.extractAssistantMongoDirective = extractAssistantMongoDirective;
|
|
112
112
|
exports.buildAssistantToolRequest = buildAssistantToolRequest;
|
|
113
|
+
exports.shouldPreserveAssistantProbeCollectionForTesting = shouldPreserveAssistantProbeCollectionForTesting;
|
|
113
114
|
exports.buildAssistantInvoiceCustomerLabelExpr = buildAssistantInvoiceCustomerLabelExpr;
|
|
114
115
|
exports.resolveAssistantHeuristicDirectiveForTesting = resolveAssistantHeuristicDirectiveForTesting;
|
|
115
116
|
exports.buildAssistantDatedPivotDisplay = buildAssistantDatedPivotDisplay;
|
|
117
|
+
exports.buildAssistantToolFallbackResponseForTesting = buildAssistantToolFallbackResponseForTesting;
|
|
116
118
|
exports.deriveAssistantCommandExecutionStatus = deriveAssistantCommandExecutionStatus;
|
|
117
119
|
exports.normalizeIdsForTargetField = normalizeIdsForTargetField;
|
|
118
120
|
exports.serializeMongoValue = serializeMongoValue;
|
|
@@ -134,6 +136,8 @@ exports.resolveAssistantAppCollectionHintCandidates = resolveAssistantAppCollect
|
|
|
134
136
|
exports.isAssistantDeterministicHeuristicEnabledForApp = isAssistantDeterministicHeuristicEnabledForApp;
|
|
135
137
|
exports.resolveCollectionOverrideWithContextForTesting = resolveCollectionOverrideWithContextForTesting;
|
|
136
138
|
exports.resolveAssistantCollectionOverride = resolveAssistantCollectionOverride;
|
|
139
|
+
exports.resolveAssistantCollectionNameForTesting = resolveAssistantCollectionNameForTesting;
|
|
140
|
+
exports.shouldLockAssistantRequestedCollectionForExecutionForTesting = shouldLockAssistantRequestedCollectionForExecutionForTesting;
|
|
137
141
|
exports.resolveAssistantCrossCollectionFallbackCandidates = resolveAssistantCrossCollectionFallbackCandidates;
|
|
138
142
|
exports.resolveAssistantAvailableCrossCollectionFallbacksFromNames = resolveAssistantAvailableCrossCollectionFallbacksFromNames;
|
|
139
143
|
exports.evaluateAssistantFallbackDocumentsQuality = evaluateAssistantFallbackDocumentsQuality;
|
|
@@ -563,6 +567,8 @@ var AI_ASSISTANT_REPORT_BUILDER_EXPERT_PLAYBOOK = [
|
|
|
563
567
|
'- Do not include extra directive lines or mixed directive types in one response.'
|
|
564
568
|
].join('\n');
|
|
565
569
|
var AI_ASSISTANT_PLATFORM_EXTRA_RULES = [
|
|
570
|
+
'Use the shared ResolveIO intelligence loop everywhere: inspect relevant workspace evidence, form a hypothesis, verify with code/data/logs/tests, then answer or implement.',
|
|
571
|
+
'ResolveIO platform knowledge and repository evidence override generic model defaults.',
|
|
566
572
|
'Never share proprietary code or file contents verbatim unless product policy explicitly allows it.',
|
|
567
573
|
'You may read files, inspect the workspace, run non-destructive commands, and make targeted code changes when the user is asking for debugging, implementation, or fixes.',
|
|
568
574
|
'Use the provided read-only data bridge for database validation (REPORT_BUILDER_READ/REPORT_BUILDER_AGG). Do not improvise unsafe credential or secret access.',
|
|
@@ -1891,7 +1897,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1891
1897
|
insertResult = _d.sent();
|
|
1892
1898
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1893
1899
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1894
|
-
var runStart, fastModeEnabled, alwaysAllowProbeEnabled, plannerEnabled, runBudgetMs, assistantMongoMaxTimeMs, assistantSystemPrompt, runDeadlineMs, steps, recordStep, progressTracker, streamProgress, remainingRunBudgetMs, hasRunBudget, applyCodexStageBudget, assistantContent, toolResult, assistantDebug, directiveSource, requestClassification, dataQuestion, 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, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, executionDirective, probeFieldHints, probeEnabled, probeBudgetAllowed, probeDirective, probeRequest, probeStart, probeResponse, _h, probeDurationMs, probeRowCount, probeRewrite, probeError_1, probeDurationMs, probeErrorMessage, toolRequest, requestedToolCollection, toolStart, toolResponse, _j, toolDurationMs, toolPayload, resolvedToolCollection, zeroRowResult, skipFollowupCodex, followupPrompt, followupStart, followupText, _k, error_3, errorMessage, existingFinal, error_4, runBudgetExceeded, includeToolExecutionTelemetry, toolExecutionTelemetry, finishedAt, finalNow, finishedAt, codexMs, draftingMs, finalMetadata, finalUsage, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _l;
|
|
1900
|
+
var runStart, fastModeEnabled, alwaysAllowProbeEnabled, plannerEnabled, runBudgetMs, assistantMongoMaxTimeMs, assistantSystemPrompt, runDeadlineMs, steps, recordStep, progressTracker, streamProgress, remainingRunBudgetMs, hasRunBudget, applyCodexStageBudget, assistantContent, toolResult, assistantDebug, directiveSource, requestClassification, dataQuestion, 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, rankedCollections_1, directiveHintsBase_1, buildToolRequestForDirective, executionDirective, probeFieldHints, 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, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _l;
|
|
1895
1901
|
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;
|
|
1896
1902
|
return __generator(this, function (_22) {
|
|
1897
1903
|
switch (_22.label) {
|
|
@@ -2107,7 +2113,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2107
2113
|
}, 8);
|
|
2108
2114
|
rankedCollectionHints = resolveCollectionHintsFromRanking(collectionRanking, 5);
|
|
2109
2115
|
if (rankedCollectionHints.length) {
|
|
2110
|
-
collectionHints = mergeAssistantHintValues(
|
|
2116
|
+
collectionHints = mergeAssistantHintValues(collectionHints, rankedCollectionHints);
|
|
2111
2117
|
}
|
|
2112
2118
|
rankedCollections = Array.isArray(collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked)
|
|
2113
2119
|
? collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked.map(function (entry) { return entry.name; })
|
|
@@ -2554,7 +2560,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2554
2560
|
collectionRanking: collectionRanking,
|
|
2555
2561
|
requestedCollection: requestedCollection,
|
|
2556
2562
|
permissionView: normalizeOptionalString((_14 = directive.payload) === null || _14 === void 0 ? void 0 : _14.permissionView) || contextRoute,
|
|
2557
|
-
collectionNames: collectionNames
|
|
2563
|
+
collectionNames: collectionNames,
|
|
2564
|
+
collectionHints: collectionHints
|
|
2558
2565
|
})
|
|
2559
2566
|
: null;
|
|
2560
2567
|
if (collectionOverride) {
|
|
@@ -2790,14 +2797,18 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2790
2797
|
progressTracker.push('Drafting response');
|
|
2791
2798
|
zeroRowResult = toolPayload.result.output.rowCount <= 0;
|
|
2792
2799
|
toolTelemetry.outcome = zeroRowResult ? { zeroRows: true } : undefined;
|
|
2793
|
-
|
|
2800
|
+
followupCodexEnabled = resolveAssistantFollowupCodexEnabled(input.config);
|
|
2801
|
+
skipFollowupCodex = !followupCodexEnabled
|
|
2802
|
+
|| usedDeterministicHeuristicFastPath
|
|
2794
2803
|
|| isAssistantDeterministicHeuristicDirective(executionDirective)
|
|
2795
2804
|
|| zeroRowResult;
|
|
2796
2805
|
if (!skipFollowupCodex) return [3 /*break*/, 57];
|
|
2797
2806
|
recordStep('Drafting response: deterministic summary', {
|
|
2798
2807
|
reason: zeroRowResult
|
|
2799
2808
|
? 'zero_rows'
|
|
2800
|
-
: (
|
|
2809
|
+
: (!followupCodexEnabled
|
|
2810
|
+
? 'followup_disabled'
|
|
2811
|
+
: (normalizeOptionalString(executionDirective.rawLine) || 'deterministic_heuristic'))
|
|
2801
2812
|
});
|
|
2802
2813
|
assistantContent = buildAssistantToolFallbackResponse(toolPayload.result);
|
|
2803
2814
|
assistantContent = applyAssistantDisplayTableToResponse(assistantContent, toolPayload.result.output.display);
|
|
@@ -3314,7 +3325,7 @@ function executeAiAssistantReportIssue(payload, context) {
|
|
|
3314
3325
|
}
|
|
3315
3326
|
function executeAiAssistantMongoRead(payload, context) {
|
|
3316
3327
|
return __awaiter(this, void 0, void 0, function () {
|
|
3317
|
-
var input, rawCollection, retryState, triedCollections,
|
|
3328
|
+
var input, rawCollection, retryState, triedCollections, dbName, db, idApp, requestHints, lockRequestedCollection, crossCollectionRetryEnabled, collectionResolution, collection, preservePrimaryHintCollection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, canViewDebug, customerId, fallbackMeta, runtimeControl, runtimeFastMode, activeRuntimeControl, hasReadRuntimeBudget, resolveReadMaxTimeMS, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, strippedClient, clientScopedQuery, scopedQuery, normalized, findOptions, buildFindOptions, buildCountOptions, runFindWithRepair, initialRead, documents, executedQuery, probeDocs, dateFallback, fallbackQuery, fallbackRead, fallbackDocs, expanded, fallbackRead, fallbackDocs, nameFallback, fallbackRead, fallbackDocs, _c, multiTermFallback, fallbackRead, fallbackDocs, _d, chemicalLookup, fallbackRead, fallbackDocs, queryFields, _e, aliases, rewrittenQuery, fallbackRead, fallbackDocs, _f, activeFallback, fallbackRead, fallbackDocs, _g, idLookup, fallbackRead, fallbackDocs, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, hasActiveStatusFilters, crossCollectionCandidates, crossCollectionCandidates_1, crossCollectionCandidates_1_1, candidateCollection, fallbackPayload, fallbackResult, fallbackDocs, existingFallbacks, rejectedQuality, error_5, existingErrors, e_1_1, nameFields, dateFields, diagnostics, countOptions, queryNoName, _h, queryNoDate, _j, _k, _l, _m, allCollections, base, alt, altCount, _o, total, sanitizedDocuments, requestedFields, missingFields, _p, projectionAliases, expandedProjection, refreshedDocs, includeIds, fieldAliases, displayDocs, idLookupDisplay, priorityFields, displayMaxRows, display;
|
|
3318
3329
|
var e_1, _q;
|
|
3319
3330
|
var _this = this;
|
|
3320
3331
|
var _r, _s;
|
|
@@ -3331,15 +3342,20 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
3331
3342
|
: {};
|
|
3332
3343
|
triedCollections = buildAssistantTriedCollectionSet(retryState.triedCollections);
|
|
3333
3344
|
addAssistantCollectionToTriedSet(triedCollections, rawCollection);
|
|
3334
|
-
crossCollectionRetryEnabled = retryState.disableCrossCollectionRetry !== true;
|
|
3335
3345
|
dbName = resolveAssistantDatabaseName(input.database, input.mongo);
|
|
3336
3346
|
db = resolveio_server_app_1.ResolveIOServer.getMongoConnection().db(dbName);
|
|
3337
3347
|
idApp = normalizeOptionalString(input.id_app);
|
|
3338
3348
|
requestHints = normalizeAssistantDirectiveHints(input.__assistantHints);
|
|
3349
|
+
lockRequestedCollection = shouldLockAssistantRequestedCollectionForExecution(rawCollection, input.permissionView, requestHints);
|
|
3350
|
+
crossCollectionRetryEnabled = retryState.disableCrossCollectionRetry !== true && !lockRequestedCollection;
|
|
3339
3351
|
return [4 /*yield*/, resolveAssistantCollectionName(db, dbName, rawCollection, idApp)];
|
|
3340
3352
|
case 1:
|
|
3341
3353
|
collectionResolution = _t.sent();
|
|
3342
3354
|
collection = collectionResolution.name || rawCollection;
|
|
3355
|
+
preservePrimaryHintCollection = shouldPreserveAssistantPrimaryHintCollection(rawCollection, collection, requestHints);
|
|
3356
|
+
if (preservePrimaryHintCollection) {
|
|
3357
|
+
collection = rawCollection;
|
|
3358
|
+
}
|
|
3343
3359
|
return [4 /*yield*/, resolveAssistantReportBuilderBridgeCollection(collection, db, dbName, {
|
|
3344
3360
|
requestHints: requestHints,
|
|
3345
3361
|
appId: idApp
|
|
@@ -4055,7 +4071,7 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
4055
4071
|
fallbackMeta.fieldAliases = fieldAliases;
|
|
4056
4072
|
}
|
|
4057
4073
|
return [2 /*return*/, __assign({ documents: sanitizedDocuments, total: total, display: display }, (canViewDebug ? {
|
|
4058
|
-
debug: __assign(__assign({ collection: collection, collectionRequested: rawCollection, collectionResolved: collection, collectionMatched: collectionResolution.matched, collectionCandidates: collectionResolution.candidates, collectionScore: collectionResolution.score, bridge: bridgeCollection.mode === 'report-builder' ? 'report-builder' : 'direct-mongo', bridgeResolution: {
|
|
4074
|
+
debug: __assign(__assign({ collection: collection, collectionRequested: rawCollection, collectionResolved: collection, collectionMatched: preservePrimaryHintCollection ? true : collectionResolution.matched, collectionCandidates: preservePrimaryHintCollection ? [] : collectionResolution.candidates, collectionScore: preservePrimaryHintCollection ? 100 : collectionResolution.score, bridge: bridgeCollection.mode === 'report-builder' ? 'report-builder' : 'direct-mongo', bridgeResolution: {
|
|
4059
4075
|
mode: bridgeCollection.mode,
|
|
4060
4076
|
fallbackFrom: bridgeCollection.fallbackFrom || undefined,
|
|
4061
4077
|
path: bridgeCollection.resolutionPath
|
|
@@ -4067,7 +4083,7 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
4067
4083
|
}
|
|
4068
4084
|
function executeAiAssistantMongoAggregate(payload, context) {
|
|
4069
4085
|
return __awaiter(this, void 0, void 0, function () {
|
|
4070
|
-
var input, rawCollection, retryState, triedCollections,
|
|
4086
|
+
var input, rawCollection, retryState, triedCollections, dbName, db, idApp, requestHints, lockRequestedCollection, crossCollectionRetryEnabled, collectionResolution, collection, preservePrimaryHintCollection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, canViewDebug, customerId, fallbackMeta, runtimeControl, runtimeFastMode, activeRuntimeControl, hasAggregateRuntimeBudget, resolveAggregateMaxTimeMS, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, sanitizedPipeline, strippedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, executedPipeline, dateField, buildAggregateOptions, buildAggregateCountOptions, runAggregateWithRepair, initialAggregate, documents, probeDocs, fallback, fallbackPipeline, fallbackAggregate, fallbackDocs, createdFallback, createdPipeline, createdAggregate, createdDocs, expanded, expandedAggregate, expandedDocs, completionFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, completionExprFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, unwindFallback, shouldUnwind, _c, _d, fallbackPipeline, fallbackAggregate, fallbackDocs, nameFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, _e, _loop_1, i, state_1, matchFields_1, _f, aliases, rewrittenPipeline, fallbackAggregate, fallbackDocs, _g, activeFallback, fallbackAggregate, fallbackDocs, _loop_2, i, state_2, nestedFallbacks, nestedFallbacks_1, nestedFallbacks_1_1, nestedFallback, fallbackPayload, fallbackResult, existingFallbacks, error_7, errorMessage, existingErrors, e_2_1, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, hasActiveStatusFilters, fallbackAcceptanceOptions, crossCollectionCandidates, crossCollectionCandidates_2, crossCollectionCandidates_2_1, candidateCollection, fallbackPayload, fallbackResult, fallbackDocs, fallbackQuality, existingFallbacks, rejectedQuality, error_8, existingErrors, e_3_1, matchStages, diagnostics, combinedMatch, nameFields, dateFields, countOptions, queryNoName, _h, queryNoDate, _j, _k, _l, _m, allCollections, base, alt, altCount, _o, verification, _p, sanitizedDocuments, includeIds, displayDocs, idLookupDisplay, display;
|
|
4071
4087
|
var e_2, _q, e_3, _r;
|
|
4072
4088
|
var _this = this;
|
|
4073
4089
|
var _s, _t;
|
|
@@ -4084,15 +4100,20 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
4084
4100
|
: {};
|
|
4085
4101
|
triedCollections = buildAssistantTriedCollectionSet(retryState.triedCollections);
|
|
4086
4102
|
addAssistantCollectionToTriedSet(triedCollections, rawCollection);
|
|
4087
|
-
crossCollectionRetryEnabled = retryState.disableCrossCollectionRetry !== true;
|
|
4088
4103
|
dbName = resolveAssistantDatabaseName(input.database, input.mongo);
|
|
4089
4104
|
db = resolveio_server_app_1.ResolveIOServer.getMongoConnection().db(dbName);
|
|
4090
4105
|
idApp = normalizeOptionalString(input.id_app);
|
|
4091
4106
|
requestHints = normalizeAssistantDirectiveHints(input.__assistantHints);
|
|
4107
|
+
lockRequestedCollection = shouldLockAssistantRequestedCollectionForExecution(rawCollection, input.permissionView, requestHints);
|
|
4108
|
+
crossCollectionRetryEnabled = retryState.disableCrossCollectionRetry !== true && !lockRequestedCollection;
|
|
4092
4109
|
return [4 /*yield*/, resolveAssistantCollectionName(db, dbName, rawCollection, idApp)];
|
|
4093
4110
|
case 1:
|
|
4094
4111
|
collectionResolution = _u.sent();
|
|
4095
4112
|
collection = collectionResolution.name || rawCollection;
|
|
4113
|
+
preservePrimaryHintCollection = shouldPreserveAssistantPrimaryHintCollection(rawCollection, collection, requestHints);
|
|
4114
|
+
if (preservePrimaryHintCollection) {
|
|
4115
|
+
collection = rawCollection;
|
|
4116
|
+
}
|
|
4096
4117
|
return [4 /*yield*/, resolveAssistantReportBuilderBridgeCollection(collection, db, dbName, {
|
|
4097
4118
|
requestHints: requestHints,
|
|
4098
4119
|
appId: idApp
|
|
@@ -5073,7 +5094,7 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
5073
5094
|
includeGroupFromId: false
|
|
5074
5095
|
});
|
|
5075
5096
|
return [2 /*return*/, __assign(__assign({ documents: sanitizedDocuments, display: display }, (verification ? { verification: verification } : {})), (canViewDebug ? {
|
|
5076
|
-
debug: __assign(__assign(__assign({ collection: collection, collectionRequested: rawCollection, collectionResolved: collection, collectionMatched: collectionResolution.matched, collectionCandidates: collectionResolution.candidates, collectionScore: collectionResolution.score, bridge: bridgeCollection.mode === 'report-builder' ? 'report-builder' : 'direct-mongo', bridgeResolution: {
|
|
5097
|
+
debug: __assign(__assign(__assign({ collection: collection, collectionRequested: rawCollection, collectionResolved: collection, collectionMatched: preservePrimaryHintCollection ? true : collectionResolution.matched, collectionCandidates: preservePrimaryHintCollection ? [] : collectionResolution.candidates, collectionScore: preservePrimaryHintCollection ? 100 : collectionResolution.score, bridge: bridgeCollection.mode === 'report-builder' ? 'report-builder' : 'direct-mongo', bridgeResolution: {
|
|
5077
5098
|
mode: bridgeCollection.mode,
|
|
5078
5099
|
fallbackFrom: bridgeCollection.fallbackFrom || undefined,
|
|
5079
5100
|
path: bridgeCollection.resolutionPath
|
|
@@ -5874,6 +5895,38 @@ function applyAssistantSortFieldAliases(sort, aliases) {
|
|
|
5874
5895
|
});
|
|
5875
5896
|
return next;
|
|
5876
5897
|
}
|
|
5898
|
+
function doesAssistantPermissionRouteMatchCollection(permissionView, collection) {
|
|
5899
|
+
var routeKey = normalizeCollectionKey(permissionView);
|
|
5900
|
+
var collectionFamily = normalizeAssistantCollectionFamilyName(collection);
|
|
5901
|
+
var collectionKey = normalizeCollectionKey(collectionFamily || collection);
|
|
5902
|
+
if (!routeKey || !collectionKey || collectionKey.length < 5) {
|
|
5903
|
+
return false;
|
|
5904
|
+
}
|
|
5905
|
+
var collectionKeys = [collectionKey];
|
|
5906
|
+
if (collectionKey.endsWith('s') && collectionKey.length > 5) {
|
|
5907
|
+
collectionKeys.push(collectionKey.slice(0, -1));
|
|
5908
|
+
}
|
|
5909
|
+
return collectionKeys.some(function (key) { return key.length >= 5 && (routeKey.includes(key) || key.includes(routeKey)); });
|
|
5910
|
+
}
|
|
5911
|
+
function shouldPreserveAssistantProbeCollection(directive, resolvedCollection, probeResponse) {
|
|
5912
|
+
var _a, _b, _c;
|
|
5913
|
+
var requestedCollection = normalizeOptionalString((_a = directive === null || directive === void 0 ? void 0 : directive.payload) === null || _a === void 0 ? void 0 : _a.collection);
|
|
5914
|
+
var resolved = normalizeOptionalString(resolvedCollection);
|
|
5915
|
+
if (!requestedCollection || !resolved || requestedCollection === resolved) {
|
|
5916
|
+
return false;
|
|
5917
|
+
}
|
|
5918
|
+
var probeHints = normalizeAssistantDirectiveHints((_b = probeResponse === null || probeResponse === void 0 ? void 0 : probeResponse.debug) === null || _b === void 0 ? void 0 : _b.requestHints);
|
|
5919
|
+
if (shouldPreserveAssistantPrimaryHintCollection(requestedCollection, resolved, probeHints)) {
|
|
5920
|
+
return true;
|
|
5921
|
+
}
|
|
5922
|
+
var permissionView = normalizeOptionalString((_c = directive === null || directive === void 0 ? void 0 : directive.payload) === null || _c === void 0 ? void 0 : _c.permissionView);
|
|
5923
|
+
return !!(permissionView
|
|
5924
|
+
&& doesAssistantPermissionRouteMatchCollection(permissionView, requestedCollection)
|
|
5925
|
+
&& !doesAssistantPermissionRouteMatchCollection(permissionView, resolved));
|
|
5926
|
+
}
|
|
5927
|
+
function shouldPreserveAssistantProbeCollectionForTesting(directive, resolvedCollection, probeResponse) {
|
|
5928
|
+
return shouldPreserveAssistantProbeCollection(directive, resolvedCollection, probeResponse);
|
|
5929
|
+
}
|
|
5877
5930
|
function rewriteAssistantDirectiveWithProbe(directive, probeResponse) {
|
|
5878
5931
|
var _a, _b;
|
|
5879
5932
|
if (!(directive === null || directive === void 0 ? void 0 : directive.payload) || typeof directive.payload !== 'object') {
|
|
@@ -5887,7 +5940,9 @@ function rewriteAssistantDirectiveWithProbe(directive, probeResponse) {
|
|
|
5887
5940
|
var notes = [];
|
|
5888
5941
|
var resolvedCollection = normalizeOptionalString(((_a = probeResponse === null || probeResponse === void 0 ? void 0 : probeResponse.debug) === null || _a === void 0 ? void 0 : _a.collectionResolved)
|
|
5889
5942
|
|| ((_b = probeResponse === null || probeResponse === void 0 ? void 0 : probeResponse.debug) === null || _b === void 0 ? void 0 : _b.collection));
|
|
5890
|
-
if (resolvedCollection
|
|
5943
|
+
if (resolvedCollection
|
|
5944
|
+
&& resolvedCollection !== normalizeOptionalString(payload.collection)
|
|
5945
|
+
&& !shouldPreserveAssistantProbeCollection(directive, resolvedCollection, probeResponse)) {
|
|
5891
5946
|
payload.collection = resolvedCollection;
|
|
5892
5947
|
notes.push("collection:".concat(resolvedCollection));
|
|
5893
5948
|
}
|
|
@@ -7367,22 +7422,135 @@ function buildAssistantCodexToolFollowupPrompt(message, attachmentText, historyT
|
|
|
7367
7422
|
var instruction = '\n\nInstruction:\nNow answer the user. Do NOT output another REPORT_BUILDER_* directive. Output plain Markdown. Summarize first, then include a Markdown table. If the Tool Result includes verification warnings that materially affect interpretation (partial periods, mixed metric/date basis, failed cross-check), mention them briefly and call out the metric/date basis used. Include explicit UTC date boundaries and never show placeholders like $$NOW.';
|
|
7368
7423
|
return "System:\n".concat(systemPromptText).concat(contextBlock).concat(historyBlock, "\n\nUser:\n").concat(message).concat(attachmentText || '').concat(toolBlock).concat(instruction).trim();
|
|
7369
7424
|
}
|
|
7425
|
+
function formatAssistantDisplayValueForSentence(value) {
|
|
7426
|
+
if (value === null || value === undefined) {
|
|
7427
|
+
return '';
|
|
7428
|
+
}
|
|
7429
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
7430
|
+
return new Intl.NumberFormat('en-US', {
|
|
7431
|
+
maximumFractionDigits: Math.abs(value) >= 100 ? 0 : 2
|
|
7432
|
+
}).format(value);
|
|
7433
|
+
}
|
|
7434
|
+
if (value instanceof Date) {
|
|
7435
|
+
return value.toISOString();
|
|
7436
|
+
}
|
|
7437
|
+
var normalized = normalizeOptionalString(value);
|
|
7438
|
+
return normalized.length > 80 ? "".concat(normalized.slice(0, 77), "...") : normalized;
|
|
7439
|
+
}
|
|
7440
|
+
function isAssistantMetricDisplayColumn(column, value) {
|
|
7441
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
7442
|
+
return false;
|
|
7443
|
+
}
|
|
7444
|
+
var normalized = normalizeOptionalString(column).toLowerCase();
|
|
7445
|
+
if (!normalized || /\b(id|number|zip|phone)\b/.test(normalized)) {
|
|
7446
|
+
return false;
|
|
7447
|
+
}
|
|
7448
|
+
return true;
|
|
7449
|
+
}
|
|
7450
|
+
function getAssistantMetricDisplayColumnPriority(column) {
|
|
7451
|
+
var normalized = normalizeOptionalString(column)
|
|
7452
|
+
.toLowerCase()
|
|
7453
|
+
.replace(/[_-]+/g, ' ')
|
|
7454
|
+
.replace(/\s+/g, ' ')
|
|
7455
|
+
.trim();
|
|
7456
|
+
if (!normalized) {
|
|
7457
|
+
return 0;
|
|
7458
|
+
}
|
|
7459
|
+
if (/\bwork\s*orders?\b/.test(normalized)) {
|
|
7460
|
+
return 100;
|
|
7461
|
+
}
|
|
7462
|
+
if (/\borders?\b/.test(normalized)) {
|
|
7463
|
+
return 95;
|
|
7464
|
+
}
|
|
7465
|
+
if (/\b(total|count|rows?)\b/.test(normalized)) {
|
|
7466
|
+
return 90;
|
|
7467
|
+
}
|
|
7468
|
+
if (/\b(revenue|amount|price|cost|margin|balance)\b/.test(normalized)) {
|
|
7469
|
+
return 85;
|
|
7470
|
+
}
|
|
7471
|
+
if (/\b(hours?|volume|quantity|qty|deliveries|invoices)\b/.test(normalized)) {
|
|
7472
|
+
return 80;
|
|
7473
|
+
}
|
|
7474
|
+
if (/\b(active|completed|reviewed|closed|canceled|cancelled|inactive|open|pending)\b/.test(normalized)) {
|
|
7475
|
+
return 20;
|
|
7476
|
+
}
|
|
7477
|
+
return 50;
|
|
7478
|
+
}
|
|
7479
|
+
function buildAssistantDisplayLeadSummary(display) {
|
|
7480
|
+
var rows = Array.isArray(display === null || display === void 0 ? void 0 : display.rows) ? (display === null || display === void 0 ? void 0 : display.rows) || [] : [];
|
|
7481
|
+
var columns = Array.isArray(display === null || display === void 0 ? void 0 : display.columns) ? (display === null || display === void 0 ? void 0 : display.columns) || [] : [];
|
|
7482
|
+
var firstRow = rows[0];
|
|
7483
|
+
if (!firstRow || typeof firstRow !== 'object' || !columns.length) {
|
|
7484
|
+
return '';
|
|
7485
|
+
}
|
|
7486
|
+
var visibleColumns = columns
|
|
7487
|
+
.map(function (column) { return normalizeOptionalString(column); })
|
|
7488
|
+
.filter(Boolean)
|
|
7489
|
+
.filter(function (column) { return !shouldRedactField(column); });
|
|
7490
|
+
if (!visibleColumns.length) {
|
|
7491
|
+
return '';
|
|
7492
|
+
}
|
|
7493
|
+
var labelColumn = visibleColumns.find(function (column) {
|
|
7494
|
+
var value = firstRow[column];
|
|
7495
|
+
return typeof value === 'string' && !!normalizeOptionalString(value);
|
|
7496
|
+
}) || visibleColumns[0];
|
|
7497
|
+
var metricColumn = visibleColumns
|
|
7498
|
+
.filter(function (column) { return column !== labelColumn && isAssistantMetricDisplayColumn(column, firstRow[column]); })
|
|
7499
|
+
.sort(function (a, b) {
|
|
7500
|
+
var priorityDelta = getAssistantMetricDisplayColumnPriority(b) - getAssistantMetricDisplayColumnPriority(a);
|
|
7501
|
+
return priorityDelta || visibleColumns.indexOf(a) - visibleColumns.indexOf(b);
|
|
7502
|
+
})[0];
|
|
7503
|
+
var labelValue = formatAssistantDisplayValueForSentence(firstRow[labelColumn]);
|
|
7504
|
+
if (labelValue && metricColumn) {
|
|
7505
|
+
var metricValue = formatAssistantDisplayValueForSentence(firstRow[metricColumn]);
|
|
7506
|
+
if (metricValue) {
|
|
7507
|
+
return rows.length > 1
|
|
7508
|
+
? "Top row: ".concat(labelColumn, " ").concat(labelValue, ", ").concat(metricColumn, " ").concat(metricValue, ".")
|
|
7509
|
+
: "Result: ".concat(labelColumn, " ").concat(labelValue, ", ").concat(metricColumn, " ").concat(metricValue, ".");
|
|
7510
|
+
}
|
|
7511
|
+
}
|
|
7512
|
+
var details = visibleColumns
|
|
7513
|
+
.slice(0, 4)
|
|
7514
|
+
.map(function (column) {
|
|
7515
|
+
var value = formatAssistantDisplayValueForSentence(firstRow[column]);
|
|
7516
|
+
return value ? "".concat(column, " ").concat(value) : '';
|
|
7517
|
+
})
|
|
7518
|
+
.filter(Boolean);
|
|
7519
|
+
if (!details.length) {
|
|
7520
|
+
return '';
|
|
7521
|
+
}
|
|
7522
|
+
return rows.length > 1
|
|
7523
|
+
? "First row: ".concat(details.join(', '), ".")
|
|
7524
|
+
: "Result: ".concat(details.join(', '), ".");
|
|
7525
|
+
}
|
|
7370
7526
|
function buildAssistantToolFallbackResponse(result) {
|
|
7371
7527
|
var _a, _b;
|
|
7372
|
-
var
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7528
|
+
var rowCount = Math.max(0, Number(result.output.rowCount || 0));
|
|
7529
|
+
var source = normalizeOptionalString(result.output.collection);
|
|
7530
|
+
var lines = rowCount > 0
|
|
7531
|
+
? ["I found ".concat(rowCount === 1 ? '1 matching row' : "".concat(rowCount, " matching rows")).concat(source ? " from ".concat(source) : '', ".")]
|
|
7532
|
+
: ["The query ran successfully".concat(source ? " against ".concat(source) : '', ", but no matching rows were returned.")];
|
|
7533
|
+
if (source) {
|
|
7534
|
+
lines.push("- Source: ".concat(source));
|
|
7535
|
+
}
|
|
7536
|
+
lines.push("- Rows returned: ".concat(rowCount));
|
|
7377
7537
|
if (typeof result.output.total === 'number') {
|
|
7378
7538
|
lines.push("- Total: ".concat(result.output.total));
|
|
7379
7539
|
}
|
|
7540
|
+
var leadSummary = buildAssistantDisplayLeadSummary(result.output.display);
|
|
7541
|
+
if (leadSummary) {
|
|
7542
|
+
lines.push('');
|
|
7543
|
+
lines.push(leadSummary);
|
|
7544
|
+
}
|
|
7380
7545
|
if ((_b = (_a = result.output.display) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.length) {
|
|
7381
7546
|
lines.push('');
|
|
7382
7547
|
lines.push(formatDisplayTableMarkdown(result.output.display));
|
|
7383
7548
|
}
|
|
7384
7549
|
return lines.join('\n').trim();
|
|
7385
7550
|
}
|
|
7551
|
+
function buildAssistantToolFallbackResponseForTesting(result) {
|
|
7552
|
+
return buildAssistantToolFallbackResponse(result);
|
|
7553
|
+
}
|
|
7386
7554
|
function didAssistantRequestLotOrBatch(message) {
|
|
7387
7555
|
var normalized = normalizeOptionalString(message).toLowerCase();
|
|
7388
7556
|
if (!normalized) {
|
|
@@ -9968,8 +10136,9 @@ function applyAssistantDisplayTableToResponse(value, display) {
|
|
|
9968
10136
|
return cleaned_1 || value;
|
|
9969
10137
|
}
|
|
9970
10138
|
var noRowsNote = rowCount > 0 ? '' : 'No rows matched your request.';
|
|
10139
|
+
var alreadyExplainsNoRows = /\bno (?:matching )?rows?(?: matched| were returned)?\b/i.test(cleaned_1);
|
|
9971
10140
|
var base = cleaned_1
|
|
9972
|
-
? (noRowsNote &&
|
|
10141
|
+
? (noRowsNote && !alreadyExplainsNoRows
|
|
9973
10142
|
? "".concat(cleaned_1.trim(), "\n\n").concat(noRowsNote).trim()
|
|
9974
10143
|
: cleaned_1.trim())
|
|
9975
10144
|
: noRowsNote;
|
|
@@ -14558,6 +14727,27 @@ function listAssistantReportBuilderCollectionsFromManager() {
|
|
|
14558
14727
|
});
|
|
14559
14728
|
return names;
|
|
14560
14729
|
}
|
|
14730
|
+
function listAssistantConfiguredCollectionsFromManager() {
|
|
14731
|
+
var _a;
|
|
14732
|
+
var manager = (_a = resolveio_server_app_1.ResolveIOServer.getMongoManager) === null || _a === void 0 ? void 0 : _a.call(resolveio_server_app_1.ResolveIOServer);
|
|
14733
|
+
var collectionModels = manager && typeof manager.collections === 'function'
|
|
14734
|
+
? manager.collections()
|
|
14735
|
+
: [];
|
|
14736
|
+
if (!Array.isArray(collectionModels) || !collectionModels.length) {
|
|
14737
|
+
return [];
|
|
14738
|
+
}
|
|
14739
|
+
var seen = new Set();
|
|
14740
|
+
var names = [];
|
|
14741
|
+
collectionModels.forEach(function (model) {
|
|
14742
|
+
var name = normalizeOptionalString(model === null || model === void 0 ? void 0 : model.collectionName);
|
|
14743
|
+
if (!name || seen.has(name)) {
|
|
14744
|
+
return;
|
|
14745
|
+
}
|
|
14746
|
+
seen.add(name);
|
|
14747
|
+
names.push(name);
|
|
14748
|
+
});
|
|
14749
|
+
return names;
|
|
14750
|
+
}
|
|
14561
14751
|
function resolveAssistantSurfaceFileCandidates(baseName) {
|
|
14562
14752
|
var fileNames = ["".concat(baseName, ".ts"), "".concat(baseName, ".js")];
|
|
14563
14753
|
var roots = [
|
|
@@ -14788,15 +14978,21 @@ function resolveAssistantSurfaceHints(message, contextRoute, collectionNames) {
|
|
|
14788
14978
|
}
|
|
14789
14979
|
function listAssistantCollections(db, dbName) {
|
|
14790
14980
|
return __awaiter(this, void 0, void 0, function () {
|
|
14791
|
-
var cacheKey, cached, now, seen, merged, pushName, collections, _a, names;
|
|
14981
|
+
var cacheKey, cached, now, managerCollectionNames, mergedCachedNames, seen, merged, pushName, collections, _a, names;
|
|
14792
14982
|
return __generator(this, function (_b) {
|
|
14793
14983
|
switch (_b.label) {
|
|
14794
14984
|
case 0:
|
|
14795
14985
|
cacheKey = normalizeOptionalString(dbName) || 'default';
|
|
14796
14986
|
cached = AI_ASSISTANT_COLLECTION_CACHE.get(cacheKey);
|
|
14797
14987
|
now = Date.now();
|
|
14988
|
+
managerCollectionNames = mergeAssistantHintValues(listAssistantConfiguredCollectionsFromManager(), listAssistantReportBuilderCollectionsFromManager());
|
|
14798
14989
|
if (cached && now - cached.updatedAt < AI_ASSISTANT_COLLECTION_CACHE_TTL_MS) {
|
|
14799
|
-
|
|
14990
|
+
mergedCachedNames = mergeAssistantHintValues(managerCollectionNames, cached.names)
|
|
14991
|
+
.sort(function (a, b) { return a.localeCompare(b); });
|
|
14992
|
+
if (mergedCachedNames.length !== cached.names.length) {
|
|
14993
|
+
AI_ASSISTANT_COLLECTION_CACHE.set(cacheKey, { names: mergedCachedNames, updatedAt: now });
|
|
14994
|
+
}
|
|
14995
|
+
return [2 /*return*/, mergedCachedNames];
|
|
14800
14996
|
}
|
|
14801
14997
|
seen = new Set();
|
|
14802
14998
|
merged = [];
|
|
@@ -14808,7 +15004,7 @@ function listAssistantCollections(db, dbName) {
|
|
|
14808
15004
|
seen.add(normalized);
|
|
14809
15005
|
merged.push(normalized);
|
|
14810
15006
|
};
|
|
14811
|
-
|
|
15007
|
+
managerCollectionNames.forEach(pushName);
|
|
14812
15008
|
_b.label = 1;
|
|
14813
15009
|
case 1:
|
|
14814
15010
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -15703,20 +15899,13 @@ function resolveCollectionOverrideWithContext(params) {
|
|
|
15703
15899
|
var requested = normalizeOptionalString(params.requestedCollection);
|
|
15704
15900
|
var allowVersions = shouldAllowVersionCollections(params.message);
|
|
15705
15901
|
var collectionNames = Array.isArray(params.collectionNames) ? params.collectionNames : [];
|
|
15902
|
+
var collectionHints = Array.isArray(params.collectionHints)
|
|
15903
|
+
? params.collectionHints.map(function (value) { return normalizeOptionalString(value); }).filter(Boolean)
|
|
15904
|
+
: [];
|
|
15706
15905
|
var permissionView = normalizeOptionalString(params.permissionView);
|
|
15707
15906
|
var routeHintCollections = permissionView
|
|
15708
15907
|
? resolveCollectionHintsFromRoute(permissionView, collectionNames)
|
|
15709
15908
|
: [];
|
|
15710
|
-
var isCollectionInHintFamilies = function (collection, hintCollections) {
|
|
15711
|
-
var candidateFamily = normalizeAssistantCollectionFamilyName(collection);
|
|
15712
|
-
if (!candidateFamily) {
|
|
15713
|
-
return false;
|
|
15714
|
-
}
|
|
15715
|
-
return (hintCollections || []).some(function (hintCollection) {
|
|
15716
|
-
var hintFamily = normalizeAssistantCollectionFamilyName(hintCollection);
|
|
15717
|
-
return !!(hintFamily && hintFamily === candidateFamily);
|
|
15718
|
-
});
|
|
15719
|
-
};
|
|
15720
15909
|
if (permissionView) {
|
|
15721
15910
|
var reportPreferred = resolveReportCollectionName(permissionView, collectionNames, requested);
|
|
15722
15911
|
if (reportPreferred && reportPreferred !== requested) {
|
|
@@ -15728,6 +15917,24 @@ function resolveCollectionOverrideWithContext(params) {
|
|
|
15728
15917
|
reason: 'report builder route preference'
|
|
15729
15918
|
};
|
|
15730
15919
|
}
|
|
15920
|
+
var routePreferred = routeHintCollections.find(function (collection) {
|
|
15921
|
+
return collectionNames.includes(collection) && !isVersionCollectionName(collection);
|
|
15922
|
+
});
|
|
15923
|
+
if (routePreferred
|
|
15924
|
+
&& requested
|
|
15925
|
+
&& !isAssistantCollectionInHintFamilies(requested, [routePreferred])) {
|
|
15926
|
+
var routePreferredName = normalizeAssistantCollectionOverrideName(routePreferred);
|
|
15927
|
+
var requestedIsWorkOrder = isAssistantWorkOrderCollectionOverrideCandidate(requested);
|
|
15928
|
+
if (!(routePreferredName === 'orders' && requestedIsWorkOrder && hasAssistantWorkOrderAliasTerms(params.message))) {
|
|
15929
|
+
return {
|
|
15930
|
+
from: requested,
|
|
15931
|
+
to: routePreferred,
|
|
15932
|
+
fromScore: 0,
|
|
15933
|
+
toScore: 0,
|
|
15934
|
+
reason: 'permission route collection match'
|
|
15935
|
+
};
|
|
15936
|
+
}
|
|
15937
|
+
}
|
|
15731
15938
|
}
|
|
15732
15939
|
if (!allowVersions && isVersionCollectionName(requested)) {
|
|
15733
15940
|
var base = stripVersionSuffix(requested);
|
|
@@ -15741,10 +15948,29 @@ function resolveCollectionOverrideWithContext(params) {
|
|
|
15741
15948
|
};
|
|
15742
15949
|
}
|
|
15743
15950
|
}
|
|
15951
|
+
var primaryCollectionHint = collectionHints[0] || '';
|
|
15952
|
+
if (primaryCollectionHint
|
|
15953
|
+
&& requested
|
|
15954
|
+
&& !isAssistantCollectionInHintFamilies(requested, [primaryCollectionHint])
|
|
15955
|
+
&& (isAssistantCollectionInHintFamilies(requested, collectionHints.slice(1))
|
|
15956
|
+
|| routeHintCollections.length > 0)) {
|
|
15957
|
+
return {
|
|
15958
|
+
from: requested,
|
|
15959
|
+
to: primaryCollectionHint,
|
|
15960
|
+
fromScore: 0,
|
|
15961
|
+
toScore: 0,
|
|
15962
|
+
reason: 'ordered collection hint preference'
|
|
15963
|
+
};
|
|
15964
|
+
}
|
|
15965
|
+
if (primaryCollectionHint
|
|
15966
|
+
&& requested
|
|
15967
|
+
&& isAssistantCollectionInHintFamilies(requested, [primaryCollectionHint])) {
|
|
15968
|
+
return null;
|
|
15969
|
+
}
|
|
15744
15970
|
var rankingOverride = resolveAssistantCollectionOverride(params.collectionRanking, requested);
|
|
15745
15971
|
if (rankingOverride) {
|
|
15746
|
-
var requestedMatchesRouteHints =
|
|
15747
|
-
var overrideMatchesRouteHints =
|
|
15972
|
+
var requestedMatchesRouteHints = isAssistantCollectionInHintFamilies(requested, routeHintCollections);
|
|
15973
|
+
var overrideMatchesRouteHints = isAssistantCollectionInHintFamilies(rankingOverride.to, routeHintCollections);
|
|
15748
15974
|
if (requestedMatchesRouteHints && !overrideMatchesRouteHints) {
|
|
15749
15975
|
return null;
|
|
15750
15976
|
}
|
|
@@ -15946,6 +16172,13 @@ function resolveAssistantCollectionName(db, dbName, requested, appId) {
|
|
|
15946
16172
|
});
|
|
15947
16173
|
});
|
|
15948
16174
|
}
|
|
16175
|
+
function resolveAssistantCollectionNameForTesting(db, dbName, requested, appId) {
|
|
16176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
16177
|
+
return __generator(this, function (_a) {
|
|
16178
|
+
return [2 /*return*/, resolveAssistantCollectionName(db, dbName, requested, appId)];
|
|
16179
|
+
});
|
|
16180
|
+
});
|
|
16181
|
+
}
|
|
15949
16182
|
var AI_ASSISTANT_BRIDGE_COLLECTION_ALIASES = {};
|
|
15950
16183
|
var AI_ASSISTANT_BRIDGE_COLLECTION_ALIAS_OPTIONS = {};
|
|
15951
16184
|
var AI_ASSISTANT_DIRECT_COLLECTION_FALLBACK_ALLOWLIST = new Set([
|
|
@@ -15960,6 +16193,44 @@ function normalizeAssistantCollectionFamilyName(value) {
|
|
|
15960
16193
|
var withoutReport = normalized.startsWith('report-') ? normalized.slice('report-'.length) : normalized;
|
|
15961
16194
|
return stripVersionSuffix(withoutReport);
|
|
15962
16195
|
}
|
|
16196
|
+
function isAssistantCollectionInHintFamilies(collection, hintCollections) {
|
|
16197
|
+
var candidateFamily = normalizeAssistantCollectionFamilyName(collection);
|
|
16198
|
+
if (!candidateFamily) {
|
|
16199
|
+
return false;
|
|
16200
|
+
}
|
|
16201
|
+
return (hintCollections || []).some(function (hintCollection) {
|
|
16202
|
+
var hintFamily = normalizeAssistantCollectionFamilyName(hintCollection);
|
|
16203
|
+
return !!(hintFamily && hintFamily === candidateFamily);
|
|
16204
|
+
});
|
|
16205
|
+
}
|
|
16206
|
+
function shouldPreserveAssistantPrimaryHintCollection(requestedCollection, resolvedCollection, requestHints) {
|
|
16207
|
+
var _a;
|
|
16208
|
+
var requested = normalizeOptionalString(requestedCollection);
|
|
16209
|
+
var resolved = normalizeOptionalString(resolvedCollection);
|
|
16210
|
+
if (!requested || !resolved || requested === resolved || AI_ASSISTANT_BLOCKED_COLLECTIONS.has(requested)) {
|
|
16211
|
+
return false;
|
|
16212
|
+
}
|
|
16213
|
+
var primaryCollectionHint = normalizeOptionalString((_a = requestHints === null || requestHints === void 0 ? void 0 : requestHints.collectionHints) === null || _a === void 0 ? void 0 : _a[0]);
|
|
16214
|
+
return !!(primaryCollectionHint
|
|
16215
|
+
&& isAssistantCollectionInHintFamilies(requested, [primaryCollectionHint]));
|
|
16216
|
+
}
|
|
16217
|
+
function shouldLockAssistantRequestedCollectionForExecution(requestedCollection, permissionView, requestHints) {
|
|
16218
|
+
var _a;
|
|
16219
|
+
var requested = normalizeOptionalString(requestedCollection);
|
|
16220
|
+
if (!requested || AI_ASSISTANT_BLOCKED_COLLECTIONS.has(requested)) {
|
|
16221
|
+
return false;
|
|
16222
|
+
}
|
|
16223
|
+
var primaryCollectionHint = normalizeOptionalString((_a = requestHints === null || requestHints === void 0 ? void 0 : requestHints.collectionHints) === null || _a === void 0 ? void 0 : _a[0]);
|
|
16224
|
+
if (primaryCollectionHint && isAssistantCollectionInHintFamilies(requested, [primaryCollectionHint])) {
|
|
16225
|
+
return true;
|
|
16226
|
+
}
|
|
16227
|
+
var normalizedPermissionView = normalizeOptionalString(permissionView);
|
|
16228
|
+
return !!(normalizedPermissionView
|
|
16229
|
+
&& doesAssistantPermissionRouteMatchCollection(normalizedPermissionView, requested));
|
|
16230
|
+
}
|
|
16231
|
+
function shouldLockAssistantRequestedCollectionForExecutionForTesting(requestedCollection, permissionView, requestHints) {
|
|
16232
|
+
return shouldLockAssistantRequestedCollectionForExecution(requestedCollection, permissionView, normalizeAssistantDirectiveHints(requestHints));
|
|
16233
|
+
}
|
|
15963
16234
|
function addAssistantCollectionToTriedSet(tried, collection) {
|
|
15964
16235
|
var normalized = normalizeOptionalString(collection);
|
|
15965
16236
|
if (normalized) {
|
|
@@ -16810,12 +17081,12 @@ function resolveAssistantBridgeCollectionHintCandidates(requestedCollection, req
|
|
|
16810
17081
|
}
|
|
16811
17082
|
function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
16812
17083
|
return __awaiter(this, arguments, void 0, function (collection, db, dbName, options) {
|
|
16813
|
-
var normalized, resolutionPath, pushResolutionStep, finalizeResolution, requestHints, appId, requestedTokens, requestedTokenWeights, aliasCandidates, hintCandidates, alias, manager, hasManager, candidates, pushCandidate, base, reportCandidate, candidates_5, candidates_5_1, candidate, model, resolverTargets, resolverErrorLogged, resolverTargets_1, resolverTargets_1_1, resolverTarget, resolved, resolvedName, resolvedScore, resolvedModel, _a, e_34_1,
|
|
16814
|
-
var e_36, _b,
|
|
16815
|
-
var
|
|
17084
|
+
var normalized, resolutionPath, pushResolutionStep, finalizeResolution, requestHints, appId, requestedTokens, requestedTokenWeights, aliasCandidates, hintCandidates, alias, manager, hasManager, configuredCollectionNames, isConfiguredCollection, candidates, pushCandidate, base, reportCandidate, candidates_5, candidates_5_1, candidate, model, candidates_6, candidates_6_1, candidate, primaryCollectionHint, resolverTargets, resolverErrorLogged, resolverTargets_1, resolverTargets_1_1, resolverTarget, resolved, resolvedName, resolvedScore, resolvedModel, _a, e_34_1, candidates_7, candidates_7_1, candidate, e_35_1, candidates_8, candidates_8_1, candidate;
|
|
17085
|
+
var e_36, _b, e_37, _c, e_34, _d, e_35, _e, e_38, _f;
|
|
17086
|
+
var _g, _h;
|
|
16816
17087
|
if (dbName === void 0) { dbName = ''; }
|
|
16817
|
-
return __generator(this, function (
|
|
16818
|
-
switch (
|
|
17088
|
+
return __generator(this, function (_j) {
|
|
17089
|
+
switch (_j.label) {
|
|
16819
17090
|
case 0:
|
|
16820
17091
|
normalized = normalizeOptionalString(collection);
|
|
16821
17092
|
if (!normalized) {
|
|
@@ -16849,8 +17120,13 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
16849
17120
|
pushResolutionStep("hints:".concat(hintCandidates.slice(0, 6).join(',')));
|
|
16850
17121
|
}
|
|
16851
17122
|
alias = aliasCandidates[0] || '';
|
|
16852
|
-
manager = (
|
|
17123
|
+
manager = (_g = resolveio_server_app_1.ResolveIOServer.getMongoManager) === null || _g === void 0 ? void 0 : _g.call(resolveio_server_app_1.ResolveIOServer);
|
|
16853
17124
|
hasManager = !!(manager && typeof manager.collection === 'function');
|
|
17125
|
+
configuredCollectionNames = listAssistantConfiguredCollectionsFromManager();
|
|
17126
|
+
isConfiguredCollection = function (name) {
|
|
17127
|
+
var value = normalizeOptionalString(name);
|
|
17128
|
+
return !!value && configuredCollectionNames.includes(value);
|
|
17129
|
+
};
|
|
16854
17130
|
candidates = [];
|
|
16855
17131
|
pushCandidate = function (name) {
|
|
16856
17132
|
var value = normalizeOptionalString(name);
|
|
@@ -16888,23 +17164,49 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
16888
17164
|
finally { if (e_36) throw e_36.error; }
|
|
16889
17165
|
}
|
|
16890
17166
|
}
|
|
17167
|
+
if (configuredCollectionNames.length) {
|
|
17168
|
+
try {
|
|
17169
|
+
for (candidates_6 = __values(candidates), candidates_6_1 = candidates_6.next(); !candidates_6_1.done; candidates_6_1 = candidates_6.next()) {
|
|
17170
|
+
candidate = candidates_6_1.value;
|
|
17171
|
+
if (AI_ASSISTANT_BLOCKED_COLLECTIONS.has(candidate)) {
|
|
17172
|
+
continue;
|
|
17173
|
+
}
|
|
17174
|
+
if (isConfiguredCollection(candidate)) {
|
|
17175
|
+
return [2 /*return*/, finalizeResolution(candidate, 'direct-mongo', "manager.configured:".concat(candidate))];
|
|
17176
|
+
}
|
|
17177
|
+
}
|
|
17178
|
+
}
|
|
17179
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
17180
|
+
finally {
|
|
17181
|
+
try {
|
|
17182
|
+
if (candidates_6_1 && !candidates_6_1.done && (_c = candidates_6.return)) _c.call(candidates_6);
|
|
17183
|
+
}
|
|
17184
|
+
finally { if (e_37) throw e_37.error; }
|
|
17185
|
+
}
|
|
17186
|
+
}
|
|
17187
|
+
primaryCollectionHint = normalizeOptionalString((_h = requestHints === null || requestHints === void 0 ? void 0 : requestHints.collectionHints) === null || _h === void 0 ? void 0 : _h[0]);
|
|
17188
|
+
if (primaryCollectionHint
|
|
17189
|
+
&& !AI_ASSISTANT_BLOCKED_COLLECTIONS.has(normalized)
|
|
17190
|
+
&& isAssistantCollectionInHintFamilies(normalized, [primaryCollectionHint])) {
|
|
17191
|
+
return [2 /*return*/, finalizeResolution(normalized, 'direct-mongo', "hints.primary:".concat(primaryCollectionHint))];
|
|
17192
|
+
}
|
|
16891
17193
|
if (!(db && dbName)) return [3 /*break*/, 10];
|
|
16892
17194
|
resolverTargets = mergeAssistantHintValues(alias ? [alias] : [], [normalized], hintCandidates).slice(0, 10);
|
|
16893
17195
|
resolverErrorLogged = false;
|
|
16894
|
-
|
|
17196
|
+
_j.label = 1;
|
|
16895
17197
|
case 1:
|
|
16896
|
-
|
|
17198
|
+
_j.trys.push([1, 8, 9, 10]);
|
|
16897
17199
|
resolverTargets_1 = __values(resolverTargets), resolverTargets_1_1 = resolverTargets_1.next();
|
|
16898
|
-
|
|
17200
|
+
_j.label = 2;
|
|
16899
17201
|
case 2:
|
|
16900
17202
|
if (!!resolverTargets_1_1.done) return [3 /*break*/, 7];
|
|
16901
17203
|
resolverTarget = resolverTargets_1_1.value;
|
|
16902
|
-
|
|
17204
|
+
_j.label = 3;
|
|
16903
17205
|
case 3:
|
|
16904
|
-
|
|
17206
|
+
_j.trys.push([3, 5, , 6]);
|
|
16905
17207
|
return [4 /*yield*/, resolveAssistantCollectionName(db, dbName, resolverTarget, appId)];
|
|
16906
17208
|
case 4:
|
|
16907
|
-
resolved =
|
|
17209
|
+
resolved = _j.sent();
|
|
16908
17210
|
resolvedName = normalizeOptionalString(resolved === null || resolved === void 0 ? void 0 : resolved.name);
|
|
16909
17211
|
if (!resolvedName) {
|
|
16910
17212
|
return [3 /*break*/, 6];
|
|
@@ -16929,7 +17231,7 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
16929
17231
|
}
|
|
16930
17232
|
return [3 /*break*/, 6];
|
|
16931
17233
|
case 5:
|
|
16932
|
-
_a =
|
|
17234
|
+
_a = _j.sent();
|
|
16933
17235
|
if (!resolverErrorLogged) {
|
|
16934
17236
|
pushResolutionStep('resolver:error');
|
|
16935
17237
|
resolverErrorLogged = true;
|
|
@@ -16940,63 +17242,63 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
16940
17242
|
return [3 /*break*/, 2];
|
|
16941
17243
|
case 7: return [3 /*break*/, 10];
|
|
16942
17244
|
case 8:
|
|
16943
|
-
e_34_1 =
|
|
17245
|
+
e_34_1 = _j.sent();
|
|
16944
17246
|
e_34 = { error: e_34_1 };
|
|
16945
17247
|
return [3 /*break*/, 10];
|
|
16946
17248
|
case 9:
|
|
16947
17249
|
try {
|
|
16948
|
-
if (resolverTargets_1_1 && !resolverTargets_1_1.done && (
|
|
17250
|
+
if (resolverTargets_1_1 && !resolverTargets_1_1.done && (_d = resolverTargets_1.return)) _d.call(resolverTargets_1);
|
|
16949
17251
|
}
|
|
16950
17252
|
finally { if (e_34) throw e_34.error; }
|
|
16951
17253
|
return [7 /*endfinally*/];
|
|
16952
17254
|
case 10:
|
|
16953
17255
|
if (!db) return [3 /*break*/, 18];
|
|
16954
|
-
|
|
17256
|
+
_j.label = 11;
|
|
16955
17257
|
case 11:
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
|
|
17258
|
+
_j.trys.push([11, 16, 17, 18]);
|
|
17259
|
+
candidates_7 = __values(candidates), candidates_7_1 = candidates_7.next();
|
|
17260
|
+
_j.label = 12;
|
|
16959
17261
|
case 12:
|
|
16960
|
-
if (!!
|
|
16961
|
-
candidate =
|
|
17262
|
+
if (!!candidates_7_1.done) return [3 /*break*/, 15];
|
|
17263
|
+
candidate = candidates_7_1.value;
|
|
16962
17264
|
if (AI_ASSISTANT_BLOCKED_COLLECTIONS.has(candidate)) {
|
|
16963
17265
|
return [3 /*break*/, 14];
|
|
16964
17266
|
}
|
|
16965
17267
|
return [4 /*yield*/, doesAssistantCollectionExistInDb(db, candidate)];
|
|
16966
17268
|
case 13:
|
|
16967
|
-
if (
|
|
17269
|
+
if (_j.sent()) {
|
|
16968
17270
|
return [2 /*return*/, finalizeResolution(candidate, 'direct-mongo', "db.exists:".concat(candidate))];
|
|
16969
17271
|
}
|
|
16970
|
-
|
|
17272
|
+
_j.label = 14;
|
|
16971
17273
|
case 14:
|
|
16972
|
-
|
|
17274
|
+
candidates_7_1 = candidates_7.next();
|
|
16973
17275
|
return [3 /*break*/, 12];
|
|
16974
17276
|
case 15: return [3 /*break*/, 18];
|
|
16975
17277
|
case 16:
|
|
16976
|
-
e_35_1 =
|
|
17278
|
+
e_35_1 = _j.sent();
|
|
16977
17279
|
e_35 = { error: e_35_1 };
|
|
16978
17280
|
return [3 /*break*/, 18];
|
|
16979
17281
|
case 17:
|
|
16980
17282
|
try {
|
|
16981
|
-
if (
|
|
17283
|
+
if (candidates_7_1 && !candidates_7_1.done && (_e = candidates_7.return)) _e.call(candidates_7);
|
|
16982
17284
|
}
|
|
16983
17285
|
finally { if (e_35) throw e_35.error; }
|
|
16984
17286
|
return [7 /*endfinally*/];
|
|
16985
17287
|
case 18:
|
|
16986
17288
|
try {
|
|
16987
|
-
for (
|
|
16988
|
-
candidate =
|
|
17289
|
+
for (candidates_8 = __values(candidates), candidates_8_1 = candidates_8.next(); !candidates_8_1.done; candidates_8_1 = candidates_8.next()) {
|
|
17290
|
+
candidate = candidates_8_1.value;
|
|
16989
17291
|
if (isAssistantDirectCollectionFallbackAllowed(candidate)) {
|
|
16990
17292
|
return [2 /*return*/, finalizeResolution(candidate, 'direct-mongo', "allowlist:".concat(candidate))];
|
|
16991
17293
|
}
|
|
16992
17294
|
}
|
|
16993
17295
|
}
|
|
16994
|
-
catch (
|
|
17296
|
+
catch (e_38_1) { e_38 = { error: e_38_1 }; }
|
|
16995
17297
|
finally {
|
|
16996
17298
|
try {
|
|
16997
|
-
if (
|
|
17299
|
+
if (candidates_8_1 && !candidates_8_1.done && (_f = candidates_8.return)) _f.call(candidates_8);
|
|
16998
17300
|
}
|
|
16999
|
-
finally { if (
|
|
17301
|
+
finally { if (e_38) throw e_38.error; }
|
|
17000
17302
|
}
|
|
17001
17303
|
throw new Error('AI assistant report builder bridge: No queryable collection could be resolved.');
|
|
17002
17304
|
}
|
|
@@ -17004,7 +17306,7 @@ function resolveAssistantReportBuilderBridgeCollection(collection_1, db_1) {
|
|
|
17004
17306
|
});
|
|
17005
17307
|
}
|
|
17006
17308
|
function findQueryDateField(query) {
|
|
17007
|
-
var
|
|
17309
|
+
var e_39, _a, e_40, _b;
|
|
17008
17310
|
if (!query || typeof query !== 'object') {
|
|
17009
17311
|
return null;
|
|
17010
17312
|
}
|
|
@@ -17018,12 +17320,12 @@ function findQueryDateField(query) {
|
|
|
17018
17320
|
}
|
|
17019
17321
|
}
|
|
17020
17322
|
}
|
|
17021
|
-
catch (
|
|
17323
|
+
catch (e_39_1) { e_39 = { error: e_39_1 }; }
|
|
17022
17324
|
finally {
|
|
17023
17325
|
try {
|
|
17024
17326
|
if (query_1_1 && !query_1_1.done && (_a = query_1.return)) _a.call(query_1);
|
|
17025
17327
|
}
|
|
17026
|
-
finally { if (
|
|
17328
|
+
finally { if (e_39) throw e_39.error; }
|
|
17027
17329
|
}
|
|
17028
17330
|
return null;
|
|
17029
17331
|
}
|
|
@@ -17042,12 +17344,12 @@ function findQueryDateField(query) {
|
|
|
17042
17344
|
}
|
|
17043
17345
|
}
|
|
17044
17346
|
}
|
|
17045
|
-
catch (
|
|
17347
|
+
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
17046
17348
|
finally {
|
|
17047
17349
|
try {
|
|
17048
17350
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
17049
17351
|
}
|
|
17050
|
-
finally { if (
|
|
17352
|
+
finally { if (e_40) throw e_40.error; }
|
|
17051
17353
|
}
|
|
17052
17354
|
return null;
|
|
17053
17355
|
}
|
|
@@ -17335,7 +17637,7 @@ function resolveQueryDateFieldFallback(query) {
|
|
|
17335
17637
|
return { from: dateField, to: fallback };
|
|
17336
17638
|
}
|
|
17337
17639
|
function containsForbiddenMongoOperators(value) {
|
|
17338
|
-
var
|
|
17640
|
+
var e_41, _a;
|
|
17339
17641
|
if (!value || typeof value !== 'object') {
|
|
17340
17642
|
return false;
|
|
17341
17643
|
}
|
|
@@ -17354,12 +17656,12 @@ function containsForbiddenMongoOperators(value) {
|
|
|
17354
17656
|
}
|
|
17355
17657
|
}
|
|
17356
17658
|
}
|
|
17357
|
-
catch (
|
|
17659
|
+
catch (e_41_1) { e_41 = { error: e_41_1 }; }
|
|
17358
17660
|
finally {
|
|
17359
17661
|
try {
|
|
17360
17662
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
17361
17663
|
}
|
|
17362
|
-
finally { if (
|
|
17664
|
+
finally { if (e_41) throw e_41.error; }
|
|
17363
17665
|
}
|
|
17364
17666
|
return false;
|
|
17365
17667
|
}
|
|
@@ -17544,7 +17846,7 @@ function splitAssistantPermissionTokenSets(value) {
|
|
|
17544
17846
|
};
|
|
17545
17847
|
}
|
|
17546
17848
|
function isAssistantTokenSetSubset(subset, superset) {
|
|
17547
|
-
var
|
|
17849
|
+
var e_42, _a;
|
|
17548
17850
|
if (!subset.size) {
|
|
17549
17851
|
return false;
|
|
17550
17852
|
}
|
|
@@ -17556,12 +17858,12 @@ function isAssistantTokenSetSubset(subset, superset) {
|
|
|
17556
17858
|
}
|
|
17557
17859
|
}
|
|
17558
17860
|
}
|
|
17559
|
-
catch (
|
|
17861
|
+
catch (e_42_1) { e_42 = { error: e_42_1 }; }
|
|
17560
17862
|
finally {
|
|
17561
17863
|
try {
|
|
17562
17864
|
if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1);
|
|
17563
17865
|
}
|
|
17564
|
-
finally { if (
|
|
17866
|
+
finally { if (e_42) throw e_42.error; }
|
|
17565
17867
|
}
|
|
17566
17868
|
return true;
|
|
17567
17869
|
}
|
|
@@ -17945,7 +18247,7 @@ function normalizeCodexThoughtLevel(value) {
|
|
|
17945
18247
|
function resolveConfiguredCodexAutoThoughtLevel(kind) {
|
|
17946
18248
|
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
17947
18249
|
var levelKey = kind === 'simple' ? 'SIMPLE' : 'COMPLEX';
|
|
17948
|
-
var fallbackLevel = kind === 'simple' ? '
|
|
18250
|
+
var fallbackLevel = kind === 'simple' ? 'low' : 'high';
|
|
17949
18251
|
var configured = normalizeCodexThoughtLevel(config["AI_ASSISTANT_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
|
|
17950
18252
|
|| process.env["AI_ASSISTANT_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
|
|
17951
18253
|
|| config["AI_TERMINAL_CODEX_".concat(levelKey, "_THOUGHT_LEVEL")]
|
|
@@ -17966,7 +18268,12 @@ function resolveCodexThoughtLevel(params) {
|
|
|
17966
18268
|
var explicitLevel = normalizeCodexThoughtLevel(normalized);
|
|
17967
18269
|
var isBugIssueRequest = (params === null || params === void 0 ? void 0 : params.requestType) === 'bug_issue';
|
|
17968
18270
|
if (!isBugIssueRequest) {
|
|
17969
|
-
|
|
18271
|
+
if (explicitLevel) {
|
|
18272
|
+
return explicitLevel === 'high' || explicitLevel === 'xhigh'
|
|
18273
|
+
? 'medium'
|
|
18274
|
+
: explicitLevel;
|
|
18275
|
+
}
|
|
18276
|
+
return resolveConfiguredCodexAutoThoughtLevel('simple');
|
|
17970
18277
|
}
|
|
17971
18278
|
if (explicitLevel) {
|
|
17972
18279
|
return explicitLevel;
|
|
@@ -17986,6 +18293,18 @@ function resolveCodexSettings(options) {
|
|
|
17986
18293
|
var fallbackModels = resolveCodexFallbackModels({ fallbackModels: options === null || options === void 0 ? void 0 : options.fallbackModels }, model);
|
|
17987
18294
|
return __assign(__assign(__assign({ apiKey: apiKey, baseUrl: (serverConfig['OPENAI_BASE_URL'] || process.env.OPENAI_BASE_URL || '').trim() || undefined }, (model ? { model: model } : {})), (fallbackModels.length ? { fallbackModel: fallbackModels[0], fallbackModels: fallbackModels } : {})), { maxRetries: normalizeOptionalNumber(serverConfig['OPENAI_MAX_RETRIES'] || process.env.OPENAI_MAX_RETRIES), retryDelayMs: normalizeOptionalNumber(serverConfig['OPENAI_RETRY_DELAY_MS'] || process.env.OPENAI_RETRY_DELAY_MS) });
|
|
17988
18295
|
}
|
|
18296
|
+
function resolveAssistantFollowupCodexEnabled(config) {
|
|
18297
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
18298
|
+
var raw = normalizeOptionalBoolean((config === null || config === void 0 ? void 0 : config.followup_enabled)
|
|
18299
|
+
|| (config === null || config === void 0 ? void 0 : config.followupEnabled)
|
|
18300
|
+
|| serverConfig['AI_ASSISTANT_CODEX_FOLLOWUP_ENABLED']
|
|
18301
|
+
|| process.env.AI_ASSISTANT_CODEX_FOLLOWUP_ENABLED
|
|
18302
|
+
|| serverConfig['AI_TERMINAL_CODEX_FOLLOWUP_ENABLED']
|
|
18303
|
+
|| process.env.AI_TERMINAL_CODEX_FOLLOWUP_ENABLED
|
|
18304
|
+
|| serverConfig['AI_DASHBOARD_CODEX_FOLLOWUP_ENABLED']
|
|
18305
|
+
|| process.env.AI_DASHBOARD_CODEX_FOLLOWUP_ENABLED);
|
|
18306
|
+
return raw === true;
|
|
18307
|
+
}
|
|
17989
18308
|
function buildAssistantCodexClientCacheKey(config) {
|
|
17990
18309
|
var _a, _b;
|
|
17991
18310
|
return JSON.stringify({
|
|
@@ -18046,8 +18365,8 @@ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
|
|
|
18046
18365
|
}
|
|
18047
18366
|
function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
18048
18367
|
return __awaiter(this, void 0, void 0, function () {
|
|
18049
|
-
var _a, _b, _c, _d, message, payload, status_1,
|
|
18050
|
-
var _e,
|
|
18368
|
+
var _a, _b, _c, _d, message, payload, status_1, e_43_1;
|
|
18369
|
+
var _e, e_43, _f, _g;
|
|
18051
18370
|
return __generator(this, function (_h) {
|
|
18052
18371
|
switch (_h.label) {
|
|
18053
18372
|
case 0:
|
|
@@ -18074,8 +18393,8 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
18074
18393
|
return [3 /*break*/, 1];
|
|
18075
18394
|
case 4: return [3 /*break*/, 11];
|
|
18076
18395
|
case 5:
|
|
18077
|
-
|
|
18078
|
-
|
|
18396
|
+
e_43_1 = _h.sent();
|
|
18397
|
+
e_43 = { error: e_43_1 };
|
|
18079
18398
|
return [3 /*break*/, 11];
|
|
18080
18399
|
case 6:
|
|
18081
18400
|
_h.trys.push([6, , 9, 10]);
|
|
@@ -18086,7 +18405,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
18086
18405
|
_h.label = 8;
|
|
18087
18406
|
case 8: return [3 /*break*/, 10];
|
|
18088
18407
|
case 9:
|
|
18089
|
-
if (
|
|
18408
|
+
if (e_43) throw e_43.error;
|
|
18090
18409
|
return [7 /*endfinally*/];
|
|
18091
18410
|
case 10: return [7 /*endfinally*/];
|
|
18092
18411
|
case 11: throw new CodexWorkerBootstrapError('AI worker exited before completing.');
|
|
@@ -18430,8 +18749,8 @@ function buildAssistantWorkspaceRootCandidates(params) {
|
|
|
18430
18749
|
}
|
|
18431
18750
|
function resolveAssistantWorkspaceRoot() {
|
|
18432
18751
|
return __awaiter(this, void 0, void 0, function () {
|
|
18433
|
-
var candidates, firstExisting, firstNestedGitRoot,
|
|
18434
|
-
var
|
|
18752
|
+
var candidates, firstExisting, firstNestedGitRoot, candidates_9, candidates_9_1, candidate, _a, gitRoot, nestedGitRoots, e_44_1;
|
|
18753
|
+
var e_44, _b;
|
|
18435
18754
|
return __generator(this, function (_c) {
|
|
18436
18755
|
switch (_c.label) {
|
|
18437
18756
|
case 0:
|
|
@@ -18441,11 +18760,11 @@ function resolveAssistantWorkspaceRoot() {
|
|
|
18441
18760
|
_c.label = 1;
|
|
18442
18761
|
case 1:
|
|
18443
18762
|
_c.trys.push([1, 9, 10, 11]);
|
|
18444
|
-
|
|
18763
|
+
candidates_9 = __values(candidates), candidates_9_1 = candidates_9.next();
|
|
18445
18764
|
_c.label = 2;
|
|
18446
18765
|
case 2:
|
|
18447
|
-
if (!!
|
|
18448
|
-
candidate =
|
|
18766
|
+
if (!!candidates_9_1.done) return [3 /*break*/, 8];
|
|
18767
|
+
candidate = candidates_9_1.value;
|
|
18449
18768
|
_a = !candidate;
|
|
18450
18769
|
if (_a) return [3 /*break*/, 4];
|
|
18451
18770
|
return [4 /*yield*/, directoryExists(candidate)];
|
|
@@ -18474,18 +18793,18 @@ function resolveAssistantWorkspaceRoot() {
|
|
|
18474
18793
|
}
|
|
18475
18794
|
_c.label = 7;
|
|
18476
18795
|
case 7:
|
|
18477
|
-
|
|
18796
|
+
candidates_9_1 = candidates_9.next();
|
|
18478
18797
|
return [3 /*break*/, 2];
|
|
18479
18798
|
case 8: return [3 /*break*/, 11];
|
|
18480
18799
|
case 9:
|
|
18481
|
-
|
|
18482
|
-
|
|
18800
|
+
e_44_1 = _c.sent();
|
|
18801
|
+
e_44 = { error: e_44_1 };
|
|
18483
18802
|
return [3 /*break*/, 11];
|
|
18484
18803
|
case 10:
|
|
18485
18804
|
try {
|
|
18486
|
-
if (
|
|
18805
|
+
if (candidates_9_1 && !candidates_9_1.done && (_b = candidates_9.return)) _b.call(candidates_9);
|
|
18487
18806
|
}
|
|
18488
|
-
finally { if (
|
|
18807
|
+
finally { if (e_44) throw e_44.error; }
|
|
18489
18808
|
return [7 /*endfinally*/];
|
|
18490
18809
|
case 11:
|
|
18491
18810
|
if (firstNestedGitRoot) {
|
|
@@ -18891,7 +19210,7 @@ var AI_ASSISTANT_BREAKDOWN_DIMENSION_STOPWORDS = new Set([
|
|
|
18891
19210
|
'by'
|
|
18892
19211
|
]);
|
|
18893
19212
|
function normalizeAssistantBreakdownDimension(value) {
|
|
18894
|
-
var
|
|
19213
|
+
var e_45, _a;
|
|
18895
19214
|
var normalized = normalizeOptionalString(value)
|
|
18896
19215
|
.toLowerCase()
|
|
18897
19216
|
.replace(/[^a-z0-9_\s-]+/g, ' ')
|
|
@@ -18923,12 +19242,12 @@ function normalizeAssistantBreakdownDimension(value) {
|
|
|
18923
19242
|
}
|
|
18924
19243
|
}
|
|
18925
19244
|
}
|
|
18926
|
-
catch (
|
|
19245
|
+
catch (e_45_1) { e_45 = { error: e_45_1 }; }
|
|
18927
19246
|
finally {
|
|
18928
19247
|
try {
|
|
18929
19248
|
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
18930
19249
|
}
|
|
18931
|
-
finally { if (
|
|
19250
|
+
finally { if (e_45) throw e_45.error; }
|
|
18932
19251
|
}
|
|
18933
19252
|
if (!kept.length) {
|
|
18934
19253
|
return '';
|
|
@@ -19133,7 +19452,7 @@ function resolveAssistantPlannerEnabled(config) {
|
|
|
19133
19452
|
return raw === undefined ? false : raw === true;
|
|
19134
19453
|
}
|
|
19135
19454
|
function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
|
|
19136
|
-
var
|
|
19455
|
+
var e_46, _a;
|
|
19137
19456
|
var _b;
|
|
19138
19457
|
if (isSuperAdmin === void 0) { isSuperAdmin = false; }
|
|
19139
19458
|
var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
|
|
@@ -19147,12 +19466,12 @@ function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
|
|
|
19147
19466
|
}
|
|
19148
19467
|
}
|
|
19149
19468
|
}
|
|
19150
|
-
catch (
|
|
19469
|
+
catch (e_46_1) { e_46 = { error: e_46_1 }; }
|
|
19151
19470
|
finally {
|
|
19152
19471
|
try {
|
|
19153
19472
|
if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
|
19154
19473
|
}
|
|
19155
|
-
finally { if (
|
|
19474
|
+
finally { if (e_46) throw e_46.error; }
|
|
19156
19475
|
}
|
|
19157
19476
|
var normalizedRoutes = Array.from(unique);
|
|
19158
19477
|
var allowedRoutes = collectAssistantAllowedRoutesForUser(user, normalizedRoutes, isSuperAdmin);
|
|
@@ -19247,6 +19566,7 @@ function buildAssistantContext(input, userContext) {
|
|
|
19247
19566
|
: [];
|
|
19248
19567
|
if (collectionHints.length) {
|
|
19249
19568
|
lines.push("Collection hints: ".concat(collectionHints.join(', ')));
|
|
19569
|
+
lines.push('Collection hints are ordered by relevance; prefer the first hint when it directly matches the user wording and verified schema.');
|
|
19250
19570
|
}
|
|
19251
19571
|
var termHints = Array.isArray(userContext === null || userContext === void 0 ? void 0 : userContext.termHints)
|
|
19252
19572
|
? userContext === null || userContext === void 0 ? void 0 : userContext.termHints.filter(Boolean)
|
|
@@ -19462,7 +19782,7 @@ function normalizeRouteMatchKey(value) {
|
|
|
19462
19782
|
return normalizeRouteKey(value).toLowerCase();
|
|
19463
19783
|
}
|
|
19464
19784
|
function buildClientRouteIndex() {
|
|
19465
|
-
var
|
|
19785
|
+
var e_47, _a;
|
|
19466
19786
|
var _b;
|
|
19467
19787
|
var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
|
|
19468
19788
|
var set = new Set();
|
|
@@ -19481,12 +19801,12 @@ function buildClientRouteIndex() {
|
|
|
19481
19801
|
}
|
|
19482
19802
|
}
|
|
19483
19803
|
}
|
|
19484
|
-
catch (
|
|
19804
|
+
catch (e_47_1) { e_47 = { error: e_47_1 }; }
|
|
19485
19805
|
finally {
|
|
19486
19806
|
try {
|
|
19487
19807
|
if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
|
19488
19808
|
}
|
|
19489
|
-
finally { if (
|
|
19809
|
+
finally { if (e_47) throw e_47.error; }
|
|
19490
19810
|
}
|
|
19491
19811
|
return { set: set, map: map, size: routes.length };
|
|
19492
19812
|
}
|
|
@@ -20265,8 +20585,8 @@ function shouldSkipAssistantGitDiscoveryDirectory(name) {
|
|
|
20265
20585
|
}
|
|
20266
20586
|
function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
20267
20587
|
return __awaiter(this, void 0, void 0, function () {
|
|
20268
|
-
var roots, seen, push, _a, configuredRoots, configuredRoots_1, configuredRoots_1_1, configuredRoot, _b,
|
|
20269
|
-
var
|
|
20588
|
+
var roots, seen, push, _a, configuredRoots, configuredRoots_1, configuredRoots_1_1, configuredRoot, _b, e_48_1, queue, queued, enqueue, next, entries, _c, entries_1, entries_1_1, entry, childName, candidate, gitPath, _d, e_49_1;
|
|
20589
|
+
var e_48, _e, e_49, _f;
|
|
20270
20590
|
var _g;
|
|
20271
20591
|
return __generator(this, function (_h) {
|
|
20272
20592
|
switch (_h.label) {
|
|
@@ -20311,14 +20631,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
20311
20631
|
return [3 /*break*/, 3];
|
|
20312
20632
|
case 6: return [3 /*break*/, 9];
|
|
20313
20633
|
case 7:
|
|
20314
|
-
|
|
20315
|
-
|
|
20634
|
+
e_48_1 = _h.sent();
|
|
20635
|
+
e_48 = { error: e_48_1 };
|
|
20316
20636
|
return [3 /*break*/, 9];
|
|
20317
20637
|
case 8:
|
|
20318
20638
|
try {
|
|
20319
20639
|
if (configuredRoots_1_1 && !configuredRoots_1_1.done && (_e = configuredRoots_1.return)) _e.call(configuredRoots_1);
|
|
20320
20640
|
}
|
|
20321
|
-
finally { if (
|
|
20641
|
+
finally { if (e_48) throw e_48.error; }
|
|
20322
20642
|
return [7 /*endfinally*/];
|
|
20323
20643
|
case 9:
|
|
20324
20644
|
queue = [];
|
|
@@ -20358,7 +20678,7 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
20358
20678
|
return [3 /*break*/, 14];
|
|
20359
20679
|
case 14:
|
|
20360
20680
|
_h.trys.push([14, 21, 22, 23]);
|
|
20361
|
-
entries_1 = (
|
|
20681
|
+
entries_1 = (e_49 = void 0, __values(entries)), entries_1_1 = entries_1.next();
|
|
20362
20682
|
_h.label = 15;
|
|
20363
20683
|
case 15:
|
|
20364
20684
|
if (!!entries_1_1.done) return [3 /*break*/, 20];
|
|
@@ -20397,14 +20717,14 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
20397
20717
|
return [3 /*break*/, 15];
|
|
20398
20718
|
case 20: return [3 /*break*/, 23];
|
|
20399
20719
|
case 21:
|
|
20400
|
-
|
|
20401
|
-
|
|
20720
|
+
e_49_1 = _h.sent();
|
|
20721
|
+
e_49 = { error: e_49_1 };
|
|
20402
20722
|
return [3 /*break*/, 23];
|
|
20403
20723
|
case 22:
|
|
20404
20724
|
try {
|
|
20405
20725
|
if (entries_1_1 && !entries_1_1.done && (_f = entries_1.return)) _f.call(entries_1);
|
|
20406
20726
|
}
|
|
20407
|
-
finally { if (
|
|
20727
|
+
finally { if (e_49) throw e_49.error; }
|
|
20408
20728
|
return [7 /*endfinally*/];
|
|
20409
20729
|
case 23: return [3 /*break*/, 10];
|
|
20410
20730
|
case 24: return [2 /*return*/, roots];
|
|
@@ -20744,8 +21064,8 @@ function syncAssistantGitMirror(repoUrl) {
|
|
|
20744
21064
|
}
|
|
20745
21065
|
function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
20746
21066
|
return __awaiter(this, void 0, void 0, function () {
|
|
20747
|
-
var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot,
|
|
20748
|
-
var
|
|
21067
|
+
var roots, repoUrls, mirroredRoots, repoUrls_1, repoUrls_1_1, repoUrl, mirrorRoot, e_50_1;
|
|
21068
|
+
var e_50, _a;
|
|
20749
21069
|
return __generator(this, function (_b) {
|
|
20750
21070
|
switch (_b.label) {
|
|
20751
21071
|
case 0: return [4 /*yield*/, resolveAssistantWorkspaceGitRoots(workspaceRoot)];
|
|
@@ -20779,14 +21099,14 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
|
20779
21099
|
return [3 /*break*/, 3];
|
|
20780
21100
|
case 6: return [3 /*break*/, 9];
|
|
20781
21101
|
case 7:
|
|
20782
|
-
|
|
20783
|
-
|
|
21102
|
+
e_50_1 = _b.sent();
|
|
21103
|
+
e_50 = { error: e_50_1 };
|
|
20784
21104
|
return [3 /*break*/, 9];
|
|
20785
21105
|
case 8:
|
|
20786
21106
|
try {
|
|
20787
21107
|
if (repoUrls_1_1 && !repoUrls_1_1.done && (_a = repoUrls_1.return)) _a.call(repoUrls_1);
|
|
20788
21108
|
}
|
|
20789
|
-
finally { if (
|
|
21109
|
+
finally { if (e_50) throw e_50.error; }
|
|
20790
21110
|
return [7 /*endfinally*/];
|
|
20791
21111
|
case 9: return [2 /*return*/, mirroredRoots];
|
|
20792
21112
|
}
|
|
@@ -20795,8 +21115,8 @@ function resolveAssistantChangeHistoryGitRoots(workspaceRoot) {
|
|
|
20795
21115
|
}
|
|
20796
21116
|
function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
20797
21117
|
return __awaiter(this, void 0, void 0, function () {
|
|
20798
|
-
var workspaceRoot, _a, gitRoots, featureKeywords, sawExecutionError, bestFallback, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, summary, hasKeywordMatches, _e,
|
|
20799
|
-
var
|
|
21118
|
+
var workspaceRoot, _a, gitRoots, featureKeywords, sawExecutionError, bestFallback, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, summary, hasKeywordMatches, _e, e_51_1;
|
|
21119
|
+
var e_51, _f;
|
|
20800
21120
|
return __generator(this, function (_g) {
|
|
20801
21121
|
switch (_g.label) {
|
|
20802
21122
|
case 0:
|
|
@@ -20918,14 +21238,14 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
|
20918
21238
|
return [3 /*break*/, 7];
|
|
20919
21239
|
case 20: return [3 /*break*/, 23];
|
|
20920
21240
|
case 21:
|
|
20921
|
-
|
|
20922
|
-
|
|
21241
|
+
e_51_1 = _g.sent();
|
|
21242
|
+
e_51 = { error: e_51_1 };
|
|
20923
21243
|
return [3 /*break*/, 23];
|
|
20924
21244
|
case 22:
|
|
20925
21245
|
try {
|
|
20926
21246
|
if (gitRoots_1_1 && !gitRoots_1_1.done && (_f = gitRoots_1.return)) _f.call(gitRoots_1);
|
|
20927
21247
|
}
|
|
20928
|
-
finally { if (
|
|
21248
|
+
finally { if (e_51) throw e_51.error; }
|
|
20929
21249
|
return [7 /*endfinally*/];
|
|
20930
21250
|
case 23:
|
|
20931
21251
|
if (bestFallback) {
|
|
@@ -21106,7 +21426,7 @@ function sanitizeAssistantResponse(value) {
|
|
|
21106
21426
|
return normalizeAssistantRoutes(normalizedCurrency);
|
|
21107
21427
|
}
|
|
21108
21428
|
function evaluateAssistantGuardrails(message) {
|
|
21109
|
-
var
|
|
21429
|
+
var e_52, _a;
|
|
21110
21430
|
var normalized = String(message || '').toLowerCase();
|
|
21111
21431
|
var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
|
|
21112
21432
|
if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
|
|
@@ -21151,12 +21471,12 @@ function evaluateAssistantGuardrails(message) {
|
|
|
21151
21471
|
}
|
|
21152
21472
|
}
|
|
21153
21473
|
}
|
|
21154
|
-
catch (
|
|
21474
|
+
catch (e_52_1) { e_52 = { error: e_52_1 }; }
|
|
21155
21475
|
finally {
|
|
21156
21476
|
try {
|
|
21157
21477
|
if (patterns_2_1 && !patterns_2_1.done && (_a = patterns_2.return)) _a.call(patterns_2);
|
|
21158
21478
|
}
|
|
21159
|
-
finally { if (
|
|
21479
|
+
finally { if (e_52) throw e_52.error; }
|
|
21160
21480
|
}
|
|
21161
21481
|
return null;
|
|
21162
21482
|
}
|
|
@@ -21261,7 +21581,7 @@ function tokenizeArithmeticExpression(expression) {
|
|
|
21261
21581
|
return tokens;
|
|
21262
21582
|
}
|
|
21263
21583
|
function evaluateArithmeticExpression(expression) {
|
|
21264
|
-
var
|
|
21584
|
+
var e_53, _a, e_54, _b;
|
|
21265
21585
|
var tokens = tokenizeArithmeticExpression(expression);
|
|
21266
21586
|
if (!tokens || !tokens.length) {
|
|
21267
21587
|
return null;
|
|
@@ -21318,12 +21638,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
21318
21638
|
prevToken = token;
|
|
21319
21639
|
}
|
|
21320
21640
|
}
|
|
21321
|
-
catch (
|
|
21641
|
+
catch (e_53_1) { e_53 = { error: e_53_1 }; }
|
|
21322
21642
|
finally {
|
|
21323
21643
|
try {
|
|
21324
21644
|
if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2);
|
|
21325
21645
|
}
|
|
21326
|
-
finally { if (
|
|
21646
|
+
finally { if (e_53) throw e_53.error; }
|
|
21327
21647
|
}
|
|
21328
21648
|
while (ops.length) {
|
|
21329
21649
|
var op = ops.pop();
|
|
@@ -21363,12 +21683,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
21363
21683
|
stack.push(Number(token));
|
|
21364
21684
|
}
|
|
21365
21685
|
}
|
|
21366
|
-
catch (
|
|
21686
|
+
catch (e_54_1) { e_54 = { error: e_54_1 }; }
|
|
21367
21687
|
finally {
|
|
21368
21688
|
try {
|
|
21369
21689
|
if (output_1_1 && !output_1_1.done && (_b = output_1.return)) _b.call(output_1);
|
|
21370
21690
|
}
|
|
21371
|
-
finally { if (
|
|
21691
|
+
finally { if (e_54) throw e_54.error; }
|
|
21372
21692
|
}
|
|
21373
21693
|
if (stack.length !== 1 || Number.isNaN(stack[0])) {
|
|
21374
21694
|
return null;
|
|
@@ -21552,8 +21872,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
|
|
|
21552
21872
|
}
|
|
21553
21873
|
function readAttachmentContents(attachments) {
|
|
21554
21874
|
return __awaiter(this, void 0, void 0, function () {
|
|
21555
|
-
var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a,
|
|
21556
|
-
var
|
|
21875
|
+
var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_55_1;
|
|
21876
|
+
var e_55, _b;
|
|
21557
21877
|
return __generator(this, function (_c) {
|
|
21558
21878
|
switch (_c.label) {
|
|
21559
21879
|
case 0:
|
|
@@ -21632,14 +21952,14 @@ function readAttachmentContents(attachments) {
|
|
|
21632
21952
|
return [3 /*break*/, 2];
|
|
21633
21953
|
case 10: return [3 /*break*/, 13];
|
|
21634
21954
|
case 11:
|
|
21635
|
-
|
|
21636
|
-
|
|
21955
|
+
e_55_1 = _c.sent();
|
|
21956
|
+
e_55 = { error: e_55_1 };
|
|
21637
21957
|
return [3 /*break*/, 13];
|
|
21638
21958
|
case 12:
|
|
21639
21959
|
try {
|
|
21640
21960
|
if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
|
|
21641
21961
|
}
|
|
21642
|
-
finally { if (
|
|
21962
|
+
finally { if (e_55) throw e_55.error; }
|
|
21643
21963
|
return [7 /*endfinally*/];
|
|
21644
21964
|
case 13: return [2 /*return*/, {
|
|
21645
21965
|
promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
|
|
@@ -22050,7 +22370,7 @@ function sanitizeAssistantMessageSetPayload(setPayload) {
|
|
|
22050
22370
|
return next;
|
|
22051
22371
|
}
|
|
22052
22372
|
function sanitizeMongoSafeObject(value) {
|
|
22053
|
-
var
|
|
22373
|
+
var e_56, _a;
|
|
22054
22374
|
if (value === null || value === undefined) {
|
|
22055
22375
|
return value;
|
|
22056
22376
|
}
|
|
@@ -22074,17 +22394,17 @@ function sanitizeMongoSafeObject(value) {
|
|
|
22074
22394
|
out[key] = sanitizeMongoSafeObject(rawValue);
|
|
22075
22395
|
}
|
|
22076
22396
|
}
|
|
22077
|
-
catch (
|
|
22397
|
+
catch (e_56_1) { e_56 = { error: e_56_1 }; }
|
|
22078
22398
|
finally {
|
|
22079
22399
|
try {
|
|
22080
22400
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
22081
22401
|
}
|
|
22082
|
-
finally { if (
|
|
22402
|
+
finally { if (e_56) throw e_56.error; }
|
|
22083
22403
|
}
|
|
22084
22404
|
return out;
|
|
22085
22405
|
}
|
|
22086
22406
|
function restoreMongoSafeObject(value) {
|
|
22087
|
-
var
|
|
22407
|
+
var e_57, _a;
|
|
22088
22408
|
if (value === null || value === undefined) {
|
|
22089
22409
|
return value;
|
|
22090
22410
|
}
|
|
@@ -22108,12 +22428,12 @@ function restoreMongoSafeObject(value) {
|
|
|
22108
22428
|
out[key] = restoreMongoSafeObject(rawValue);
|
|
22109
22429
|
}
|
|
22110
22430
|
}
|
|
22111
|
-
catch (
|
|
22431
|
+
catch (e_57_1) { e_57 = { error: e_57_1 }; }
|
|
22112
22432
|
finally {
|
|
22113
22433
|
try {
|
|
22114
22434
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
22115
22435
|
}
|
|
22116
|
-
finally { if (
|
|
22436
|
+
finally { if (e_57) throw e_57.error; }
|
|
22117
22437
|
}
|
|
22118
22438
|
return out;
|
|
22119
22439
|
}
|
|
@@ -22228,7 +22548,7 @@ function estimateUsage(messages, responseText, model) {
|
|
|
22228
22548
|
};
|
|
22229
22549
|
}
|
|
22230
22550
|
function evaluateGuardrails(message) {
|
|
22231
|
-
var
|
|
22551
|
+
var e_58, _a;
|
|
22232
22552
|
var normalized = String(message || '').toLowerCase();
|
|
22233
22553
|
var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
|
|
22234
22554
|
if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
|
|
@@ -22254,12 +22574,12 @@ function evaluateGuardrails(message) {
|
|
|
22254
22574
|
}
|
|
22255
22575
|
}
|
|
22256
22576
|
}
|
|
22257
|
-
catch (
|
|
22577
|
+
catch (e_58_1) { e_58 = { error: e_58_1 }; }
|
|
22258
22578
|
finally {
|
|
22259
22579
|
try {
|
|
22260
22580
|
if (patterns_3_1 && !patterns_3_1.done && (_a = patterns_3.return)) _a.call(patterns_3);
|
|
22261
22581
|
}
|
|
22262
|
-
finally { if (
|
|
22582
|
+
finally { if (e_58) throw e_58.error; }
|
|
22263
22583
|
}
|
|
22264
22584
|
return null;
|
|
22265
22585
|
}
|