@resolveio/server-lib 22.1.8 → 22.1.9
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 +3 -0
- package/methods/ai-terminal.js +228 -21
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.d.ts
CHANGED
|
@@ -127,6 +127,7 @@ export declare function resolveAssistantCollectionOverride(collectionRanking: Re
|
|
|
127
127
|
} | null;
|
|
128
128
|
export declare function resolveAssistantCrossCollectionFallbackCandidates(collection: string): string[];
|
|
129
129
|
export declare function resolveAssistantAvailableCrossCollectionFallbacksFromNames(collection: string, triedCollections: Set<string>, collectionNames: string[]): string[];
|
|
130
|
+
export declare function shouldAcceptAssistantFallbackDocuments(documents: any[]): boolean;
|
|
130
131
|
export declare function collectUserViewPermissions(user: any): string[];
|
|
131
132
|
export declare function userHasInvoiceAccess(user: any): boolean;
|
|
132
133
|
export declare function resolveAssistantUserAccessTier(user: any): 'super_admin' | 'customer_portal' | 'client_user';
|
|
@@ -147,6 +148,7 @@ export declare function shouldRunAssistantPlanner(params: {
|
|
|
147
148
|
requestClassification: AssistantRequestClassification;
|
|
148
149
|
hasDeterministicHeuristicFastPath: boolean;
|
|
149
150
|
}): boolean;
|
|
151
|
+
export declare function shouldEnforceAssistantDatedDirective(message: string, plannerOutput: any, requestClassification: AssistantRequestClassification): boolean;
|
|
150
152
|
export declare function collectAssistantAllowedRoutesForUser(user: any, allRoutes: string[], isSuperAdmin: boolean): string[];
|
|
151
153
|
export declare function rankAssistantNavigationRoutes(message: string, routes: string[], limit?: number): string[];
|
|
152
154
|
export declare function shouldUseAssistantNavigationFastPath(message: string, hasAttachments?: boolean): boolean;
|
|
@@ -163,6 +165,7 @@ export declare function buildAssistantChangeHistorySummaryFromCommits(params: {
|
|
|
163
165
|
isSuperAdmin: boolean;
|
|
164
166
|
commits: AssistantChangeHistoryCommit[];
|
|
165
167
|
branch?: string;
|
|
168
|
+
repositoryName?: string;
|
|
166
169
|
now?: Date;
|
|
167
170
|
}): AssistantChangeHistoryFastPathResult;
|
|
168
171
|
export {};
|
package/methods/ai-terminal.js
CHANGED
|
@@ -128,6 +128,7 @@ exports.rewriteEmbeddedMatchObjects = rewriteEmbeddedMatchObjects;
|
|
|
128
128
|
exports.resolveAssistantCollectionOverride = resolveAssistantCollectionOverride;
|
|
129
129
|
exports.resolveAssistantCrossCollectionFallbackCandidates = resolveAssistantCrossCollectionFallbackCandidates;
|
|
130
130
|
exports.resolveAssistantAvailableCrossCollectionFallbacksFromNames = resolveAssistantAvailableCrossCollectionFallbacksFromNames;
|
|
131
|
+
exports.shouldAcceptAssistantFallbackDocuments = shouldAcceptAssistantFallbackDocuments;
|
|
131
132
|
exports.collectUserViewPermissions = collectUserViewPermissions;
|
|
132
133
|
exports.userHasInvoiceAccess = userHasInvoiceAccess;
|
|
133
134
|
exports.resolveAssistantUserAccessTier = resolveAssistantUserAccessTier;
|
|
@@ -135,6 +136,7 @@ exports.resolveCodexThoughtLevel = resolveCodexThoughtLevel;
|
|
|
135
136
|
exports.buildAssistantWorkspaceRootCandidates = buildAssistantWorkspaceRootCandidates;
|
|
136
137
|
exports.classifyAssistantRequestType = classifyAssistantRequestType;
|
|
137
138
|
exports.shouldRunAssistantPlanner = shouldRunAssistantPlanner;
|
|
139
|
+
exports.shouldEnforceAssistantDatedDirective = shouldEnforceAssistantDatedDirective;
|
|
138
140
|
exports.collectAssistantAllowedRoutesForUser = collectAssistantAllowedRoutesForUser;
|
|
139
141
|
exports.rankAssistantNavigationRoutes = rankAssistantNavigationRoutes;
|
|
140
142
|
exports.shouldUseAssistantNavigationFastPath = shouldUseAssistantNavigationFastPath;
|
|
@@ -511,7 +513,9 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
|
|
|
511
513
|
'- For troubleshooting, ask clarifying questions only when needed to proceed; otherwise answer directly, then give a short decision tree (If X, do Y; If not, do Z).',
|
|
512
514
|
'- Provide checklists for common tasks, highlighting required fields and common pitfalls.',
|
|
513
515
|
'- If asked "where is this set," give the screen/workflow name and navigation steps to reach it.',
|
|
514
|
-
'- If asked "what changed
|
|
516
|
+
'- If asked "what changed" or "how long has this feature been around," provide the most specific app-level timeline/details available from project history.',
|
|
517
|
+
'- For server-lib/client-lib/platform updates, keep implementation details high-level, but dates/release windows are allowed.',
|
|
518
|
+
'- If exact history is unavailable in this runtime, say repository history is not accessible here and provide the best-known approximate timeframe.',
|
|
515
519
|
'- After answering, optionally suggest 0-1 related next steps only when helpful. Do not ask for "next steps" every time.',
|
|
516
520
|
'- If access is blocked, name the permission/role needed and how to request it.',
|
|
517
521
|
'- Avoid vague labels like "Operations app"; use the specific screen/workflow name.',
|
|
@@ -2545,7 +2549,7 @@ function executeAiAssistantReportIssue(payload, context) {
|
|
|
2545
2549
|
}
|
|
2546
2550
|
function executeAiAssistantMongoRead(payload, context) {
|
|
2547
2551
|
return __awaiter(this, void 0, void 0, function () {
|
|
2548
|
-
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, strippedClient, clientScopedQuery, scopedQuery, normalized, findOptions, runFindWithRepair, initialRead, documents, executedQuery, probeDocs, dateFallback, fallbackQuery, fallbackRead, fallbackDocs, expanded, fallbackRead, fallbackDocs, nameFallback, fallbackRead, fallbackDocs, _c, chemicalLookup, fallbackRead, fallbackDocs, queryFields, _d, aliases, rewrittenQuery, fallbackRead, fallbackDocs, _e, activeFallback, fallbackRead, fallbackDocs, _f, idLookup, fallbackRead, fallbackDocs, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_1, crossCollectionCandidates_1_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_1_1, nameFields, dateFields, diagnostics, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, total, sanitizedDocuments, requestedFields, missingFields, _o, projectionAliases, expandedProjection, refreshedDocs, includeIds, fieldAliases, displayDocs, idLookupDisplay, priorityFields, displayMaxRows, display;
|
|
2552
|
+
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, strippedClient, clientScopedQuery, scopedQuery, normalized, findOptions, runFindWithRepair, initialRead, documents, executedQuery, probeDocs, dateFallback, fallbackQuery, fallbackRead, fallbackDocs, expanded, fallbackRead, fallbackDocs, nameFallback, fallbackRead, fallbackDocs, _c, chemicalLookup, fallbackRead, fallbackDocs, queryFields, _d, aliases, rewrittenQuery, fallbackRead, fallbackDocs, _e, activeFallback, fallbackRead, fallbackDocs, _f, idLookup, fallbackRead, fallbackDocs, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_1, crossCollectionCandidates_1_1, candidateCollection, fallbackPayload, fallbackResult, fallbackDocs, existingFallbacks, rejectedQuality, e_1_1, nameFields, dateFields, diagnostics, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, total, sanitizedDocuments, requestedFields, missingFields, _o, projectionAliases, expandedProjection, refreshedDocs, includeIds, fieldAliases, displayDocs, idLookupDisplay, priorityFields, displayMaxRows, display;
|
|
2549
2553
|
var e_1, _p;
|
|
2550
2554
|
var _this = this;
|
|
2551
2555
|
var _q, _r;
|
|
@@ -2958,7 +2962,8 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2958
2962
|
return [4 /*yield*/, executeAiAssistantMongoRead(fallbackPayload, context)];
|
|
2959
2963
|
case 38:
|
|
2960
2964
|
fallbackResult = _s.sent();
|
|
2961
|
-
|
|
2965
|
+
fallbackDocs = Array.isArray(fallbackResult === null || fallbackResult === void 0 ? void 0 : fallbackResult.documents) ? fallbackResult.documents : [];
|
|
2966
|
+
if (fallbackDocs.length && shouldAcceptAssistantFallbackDocuments(fallbackDocs)) {
|
|
2962
2967
|
if (isSuperAdmin && (fallbackResult === null || fallbackResult === void 0 ? void 0 : fallbackResult.debug) && typeof fallbackResult.debug === 'object') {
|
|
2963
2968
|
existingFallbacks = fallbackResult.debug.fallbacks && typeof fallbackResult.debug.fallbacks === 'object'
|
|
2964
2969
|
? fallbackResult.debug.fallbacks
|
|
@@ -2973,6 +2978,16 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2973
2978
|
}
|
|
2974
2979
|
return [2 /*return*/, fallbackResult];
|
|
2975
2980
|
}
|
|
2981
|
+
if (fallbackDocs.length && isSuperAdmin && fallbackMeta.collectionRetry && typeof fallbackMeta.collectionRetry === 'object') {
|
|
2982
|
+
rejectedQuality = Array.isArray(fallbackMeta.collectionRetry.rejectedQuality)
|
|
2983
|
+
? fallbackMeta.collectionRetry.rejectedQuality
|
|
2984
|
+
: [];
|
|
2985
|
+
rejectedQuality.push({
|
|
2986
|
+
collection: candidateCollection,
|
|
2987
|
+
reason: 'empty_dimension_values'
|
|
2988
|
+
});
|
|
2989
|
+
fallbackMeta.collectionRetry.rejectedQuality = rejectedQuality;
|
|
2990
|
+
}
|
|
2976
2991
|
_s.label = 39;
|
|
2977
2992
|
case 39:
|
|
2978
2993
|
crossCollectionCandidates_1_1 = crossCollectionCandidates_1.next();
|
|
@@ -3182,7 +3197,7 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
3182
3197
|
}
|
|
3183
3198
|
function executeAiAssistantMongoAggregate(payload, context) {
|
|
3184
3199
|
return __awaiter(this, void 0, void 0, function () {
|
|
3185
|
-
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, sanitizedPipeline, strippedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, executedPipeline, dateField, aggregateOptions, 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, _loop_2, i, state_2, nestedFallbacks, nestedFallbacks_1, nestedFallbacks_1_1, nestedFallback, fallbackPayload, fallbackResult, existingFallbacks, error_6, errorMessage, existingErrors, e_2_1, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_2, crossCollectionCandidates_2_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_3_1, matchStages, diagnostics, combinedMatch, nameFields, dateFields, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, verification, sanitizedDocuments, includeIds, displayDocs, idLookupDisplay, display;
|
|
3200
|
+
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, sanitizedPipeline, strippedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, executedPipeline, dateField, aggregateOptions, 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, _loop_2, i, state_2, nestedFallbacks, nestedFallbacks_1, nestedFallbacks_1_1, nestedFallback, fallbackPayload, fallbackResult, existingFallbacks, error_6, errorMessage, existingErrors, e_2_1, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_2, crossCollectionCandidates_2_1, candidateCollection, fallbackPayload, fallbackResult, fallbackDocs, existingFallbacks, rejectedQuality, e_3_1, matchStages, diagnostics, combinedMatch, nameFields, dateFields, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, verification, sanitizedDocuments, includeIds, displayDocs, idLookupDisplay, display;
|
|
3186
3201
|
var e_2, _o, e_3, _p;
|
|
3187
3202
|
var _this = this;
|
|
3188
3203
|
var _q, _r;
|
|
@@ -3856,7 +3871,8 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3856
3871
|
return [4 /*yield*/, executeAiAssistantMongoAggregate(fallbackPayload, context)];
|
|
3857
3872
|
case 60:
|
|
3858
3873
|
fallbackResult = _s.sent();
|
|
3859
|
-
|
|
3874
|
+
fallbackDocs = Array.isArray(fallbackResult === null || fallbackResult === void 0 ? void 0 : fallbackResult.documents) ? fallbackResult.documents : [];
|
|
3875
|
+
if (fallbackDocs.length && shouldAcceptAssistantFallbackDocuments(fallbackDocs)) {
|
|
3860
3876
|
if (isSuperAdmin && (fallbackResult === null || fallbackResult === void 0 ? void 0 : fallbackResult.debug) && typeof fallbackResult.debug === 'object') {
|
|
3861
3877
|
existingFallbacks = fallbackResult.debug.fallbacks && typeof fallbackResult.debug.fallbacks === 'object'
|
|
3862
3878
|
? fallbackResult.debug.fallbacks
|
|
@@ -3871,6 +3887,16 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3871
3887
|
}
|
|
3872
3888
|
return [2 /*return*/, fallbackResult];
|
|
3873
3889
|
}
|
|
3890
|
+
if (fallbackDocs.length && isSuperAdmin && fallbackMeta.collectionRetry && typeof fallbackMeta.collectionRetry === 'object') {
|
|
3891
|
+
rejectedQuality = Array.isArray(fallbackMeta.collectionRetry.rejectedQuality)
|
|
3892
|
+
? fallbackMeta.collectionRetry.rejectedQuality
|
|
3893
|
+
: [];
|
|
3894
|
+
rejectedQuality.push({
|
|
3895
|
+
collection: candidateCollection,
|
|
3896
|
+
reason: 'empty_dimension_values'
|
|
3897
|
+
});
|
|
3898
|
+
fallbackMeta.collectionRetry.rejectedQuality = rejectedQuality;
|
|
3899
|
+
}
|
|
3874
3900
|
_s.label = 61;
|
|
3875
3901
|
case 61:
|
|
3876
3902
|
crossCollectionCandidates_2_1 = crossCollectionCandidates_2.next();
|
|
@@ -12639,6 +12665,123 @@ function resolveAssistantAvailableCrossCollectionFallbacks(db, dbName, collectio
|
|
|
12639
12665
|
});
|
|
12640
12666
|
});
|
|
12641
12667
|
}
|
|
12668
|
+
var AI_ASSISTANT_FALLBACK_DIMENSION_EMPTY_VALUES = new Set([
|
|
12669
|
+
'',
|
|
12670
|
+
'-',
|
|
12671
|
+
'--',
|
|
12672
|
+
'n/a',
|
|
12673
|
+
'na',
|
|
12674
|
+
'none',
|
|
12675
|
+
'null',
|
|
12676
|
+
'unknown',
|
|
12677
|
+
'(unknown)',
|
|
12678
|
+
'not set',
|
|
12679
|
+
'unassigned'
|
|
12680
|
+
]);
|
|
12681
|
+
function isAssistantNumericLikeValue(value) {
|
|
12682
|
+
if (typeof value === 'number') {
|
|
12683
|
+
return Number.isFinite(value);
|
|
12684
|
+
}
|
|
12685
|
+
if (typeof value !== 'string') {
|
|
12686
|
+
return false;
|
|
12687
|
+
}
|
|
12688
|
+
var trimmed = value.trim();
|
|
12689
|
+
if (!trimmed) {
|
|
12690
|
+
return false;
|
|
12691
|
+
}
|
|
12692
|
+
var normalized = trimmed
|
|
12693
|
+
.replace(/[$,%\s]/g, '')
|
|
12694
|
+
.replace(/,/g, '');
|
|
12695
|
+
return /^[-+]?\d+(\.\d+)?$/.test(normalized);
|
|
12696
|
+
}
|
|
12697
|
+
function isAssistantDateLikeValue(value) {
|
|
12698
|
+
if (value instanceof Date) {
|
|
12699
|
+
return !Number.isNaN(value.getTime());
|
|
12700
|
+
}
|
|
12701
|
+
if (typeof value !== 'string') {
|
|
12702
|
+
return false;
|
|
12703
|
+
}
|
|
12704
|
+
var trimmed = value.trim();
|
|
12705
|
+
if (!trimmed || trimmed.length < 8) {
|
|
12706
|
+
return false;
|
|
12707
|
+
}
|
|
12708
|
+
if (!/[-/]/.test(trimmed)) {
|
|
12709
|
+
return false;
|
|
12710
|
+
}
|
|
12711
|
+
var parsed = new Date(trimmed);
|
|
12712
|
+
return !Number.isNaN(parsed.getTime());
|
|
12713
|
+
}
|
|
12714
|
+
function isAssistantNonEmptyDimensionValue(value) {
|
|
12715
|
+
if (value === null || value === undefined) {
|
|
12716
|
+
return false;
|
|
12717
|
+
}
|
|
12718
|
+
if (typeof value === 'string') {
|
|
12719
|
+
var normalized = value.trim().toLowerCase();
|
|
12720
|
+
return normalized ? !AI_ASSISTANT_FALLBACK_DIMENSION_EMPTY_VALUES.has(normalized) : false;
|
|
12721
|
+
}
|
|
12722
|
+
if (typeof value === 'number') {
|
|
12723
|
+
return Number.isFinite(value);
|
|
12724
|
+
}
|
|
12725
|
+
if (typeof value === 'boolean') {
|
|
12726
|
+
return true;
|
|
12727
|
+
}
|
|
12728
|
+
if (value instanceof Date) {
|
|
12729
|
+
return !Number.isNaN(value.getTime());
|
|
12730
|
+
}
|
|
12731
|
+
if (isMongoObjectId(value)) {
|
|
12732
|
+
return true;
|
|
12733
|
+
}
|
|
12734
|
+
return true;
|
|
12735
|
+
}
|
|
12736
|
+
function resolveAssistantFallbackDimensionFields(documents) {
|
|
12737
|
+
var docs = Array.isArray(documents) ? documents : [];
|
|
12738
|
+
var keys = new Set();
|
|
12739
|
+
docs.forEach(function (doc) {
|
|
12740
|
+
if (!doc || typeof doc !== 'object' || Array.isArray(doc)) {
|
|
12741
|
+
return;
|
|
12742
|
+
}
|
|
12743
|
+
Object.keys(doc).forEach(function (key) {
|
|
12744
|
+
if (key && key !== '_id') {
|
|
12745
|
+
keys.add(key);
|
|
12746
|
+
}
|
|
12747
|
+
});
|
|
12748
|
+
});
|
|
12749
|
+
var dimensions = [];
|
|
12750
|
+
Array.from(keys).forEach(function (key) {
|
|
12751
|
+
var values = docs
|
|
12752
|
+
.map(function (doc) { return (doc && typeof doc === 'object' ? doc[key] : undefined); })
|
|
12753
|
+
.filter(function (value) { return value !== null && value !== undefined; });
|
|
12754
|
+
if (!values.length) {
|
|
12755
|
+
dimensions.push(key);
|
|
12756
|
+
return;
|
|
12757
|
+
}
|
|
12758
|
+
var allNumericLike = values.every(function (value) { return isAssistantNumericLikeValue(value); });
|
|
12759
|
+
if (allNumericLike) {
|
|
12760
|
+
return;
|
|
12761
|
+
}
|
|
12762
|
+
var allDateLike = values.every(function (value) { return isAssistantDateLikeValue(value); });
|
|
12763
|
+
if (allDateLike) {
|
|
12764
|
+
return;
|
|
12765
|
+
}
|
|
12766
|
+
dimensions.push(key);
|
|
12767
|
+
});
|
|
12768
|
+
return dimensions;
|
|
12769
|
+
}
|
|
12770
|
+
function shouldAcceptAssistantFallbackDocuments(documents) {
|
|
12771
|
+
var docs = Array.isArray(documents)
|
|
12772
|
+
? documents.filter(function (doc) { return doc && typeof doc === 'object' && !Array.isArray(doc); })
|
|
12773
|
+
: [];
|
|
12774
|
+
if (!docs.length) {
|
|
12775
|
+
return false;
|
|
12776
|
+
}
|
|
12777
|
+
var dimensionFields = resolveAssistantFallbackDimensionFields(docs);
|
|
12778
|
+
if (!dimensionFields.length) {
|
|
12779
|
+
return true;
|
|
12780
|
+
}
|
|
12781
|
+
return docs.some(function (doc) {
|
|
12782
|
+
return dimensionFields.some(function (field) { return isAssistantNonEmptyDimensionValue(doc[field]); });
|
|
12783
|
+
});
|
|
12784
|
+
}
|
|
12642
12785
|
function collectAggregateReferencedFieldPaths(pipeline) {
|
|
12643
12786
|
var fields = new Set();
|
|
12644
12787
|
(pipeline || []).forEach(function (stage) {
|
|
@@ -14268,7 +14411,7 @@ var AI_ASSISTANT_BUG_ISSUE_PATTERNS = [
|
|
|
14268
14411
|
/\bbug\b/,
|
|
14269
14412
|
/\bissue\b/,
|
|
14270
14413
|
/\berror\b/,
|
|
14271
|
-
/\bexception\b/,
|
|
14414
|
+
/\bexception\b(?!\s+list\b)/,
|
|
14272
14415
|
/\bfail(?:ed|ing|ure)?\b/,
|
|
14273
14416
|
/\bbroken\b/,
|
|
14274
14417
|
/\bnot working\b/,
|
|
@@ -14375,6 +14518,7 @@ function normalizeAssistantPlannerIntentType(value) {
|
|
|
14375
14518
|
function classifyAssistantRequestByHeuristics(message) {
|
|
14376
14519
|
var isData = isAssistantDataQuestion(message);
|
|
14377
14520
|
var isNavigation = isAssistantNavigationQuestion(message);
|
|
14521
|
+
var isChangeHistory = isAssistantChangeHistoryQuestion(message);
|
|
14378
14522
|
var isBug = isAssistantBugIssueQuestion(message);
|
|
14379
14523
|
var isFeatureInfo = isAssistantFeatureInfoQuestion(message);
|
|
14380
14524
|
var type = 'unknown';
|
|
@@ -14387,6 +14531,9 @@ function classifyAssistantRequestByHeuristics(message) {
|
|
|
14387
14531
|
else if (isNavigation) {
|
|
14388
14532
|
type = 'navigation';
|
|
14389
14533
|
}
|
|
14534
|
+
else if (isChangeHistory) {
|
|
14535
|
+
type = 'feature_info';
|
|
14536
|
+
}
|
|
14390
14537
|
else if (isBug) {
|
|
14391
14538
|
type = 'bug_issue';
|
|
14392
14539
|
}
|
|
@@ -14478,8 +14625,8 @@ function hasAssistantDatedLanguage(message) {
|
|
|
14478
14625
|
/\b(over|across)\s+time\b/i,
|
|
14479
14626
|
/\btime\s*series\b/i,
|
|
14480
14627
|
/\btrend(?:ing|s)?\b/i,
|
|
14481
|
-
/\b(
|
|
14482
|
-
/\
|
|
14628
|
+
/\b(daily|weekly|monthly|quarterly|yearly)\b/i,
|
|
14629
|
+
/\b(each|every)\s+(day|week|month|quarter|year)\b/i,
|
|
14483
14630
|
/\bmonth\s+over\s+month\b/i,
|
|
14484
14631
|
/\bquarter\s+over\s+quarter\b/i,
|
|
14485
14632
|
/\byear\s+over\s+year\b/i
|
|
@@ -14680,14 +14827,25 @@ function shouldPreferAssistantListDirective(message, plannerOutput, requestClass
|
|
|
14680
14827
|
}
|
|
14681
14828
|
return hasListVerb && (hasLimitCue || hasWindowCue);
|
|
14682
14829
|
}
|
|
14830
|
+
function isAssistantTemporalGroupByValue(value) {
|
|
14831
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
14832
|
+
return normalized === 'day'
|
|
14833
|
+
|| normalized === 'week'
|
|
14834
|
+
|| normalized === 'month'
|
|
14835
|
+
|| normalized === 'quarter'
|
|
14836
|
+
|| normalized === 'year'
|
|
14837
|
+
|| normalized === 'date';
|
|
14838
|
+
}
|
|
14683
14839
|
function shouldEnforceAssistantDatedDirective(message, plannerOutput, requestClassification) {
|
|
14840
|
+
var _a, _b;
|
|
14684
14841
|
if (!(requestClassification === null || requestClassification === void 0 ? void 0 : requestClassification.dataQuestion)) {
|
|
14685
14842
|
return false;
|
|
14686
14843
|
}
|
|
14687
14844
|
if (shouldPreferAssistantListDirective(message, plannerOutput, requestClassification)) {
|
|
14688
14845
|
return false;
|
|
14689
14846
|
}
|
|
14690
|
-
|
|
14847
|
+
var plannerGroupBy = normalizeOptionalString((_b = (_a = plannerOutput === null || plannerOutput === void 0 ? void 0 : plannerOutput.dataPlan) === null || _a === void 0 ? void 0 : _a.queryPlan) === null || _b === void 0 ? void 0 : _b.groupBy);
|
|
14848
|
+
if (isAssistantTemporalGroupByValue(plannerGroupBy)) {
|
|
14691
14849
|
return true;
|
|
14692
14850
|
}
|
|
14693
14851
|
return hasAssistantDatedLanguage(message);
|
|
@@ -15962,6 +16120,8 @@ function parseAssistantGitLogOutput(raw) {
|
|
|
15962
16120
|
function buildAssistantChangeHistorySummaryFromCommits(params) {
|
|
15963
16121
|
var message = normalizeOptionalString(params.message);
|
|
15964
16122
|
var branch = normalizeOptionalString(params.branch);
|
|
16123
|
+
var repositoryName = normalizeOptionalString(params.repositoryName).toLowerCase();
|
|
16124
|
+
var isLibraryRepository = /(?:^|[-_/])(resolveio[-_/])?(server[-_/]?lib|client[-_/]?lib)(?:$|[-_/])/i.test(repositoryName);
|
|
15965
16125
|
var now = params.now instanceof Date && !Number.isNaN(params.now.getTime()) ? params.now : new Date();
|
|
15966
16126
|
var commits = Array.isArray(params.commits) ? params.commits : [];
|
|
15967
16127
|
var requestedModules = resolveAssistantChangeModulesFromText(message);
|
|
@@ -16010,6 +16170,10 @@ function buildAssistantChangeHistorySummaryFromCommits(params) {
|
|
|
16010
16170
|
}
|
|
16011
16171
|
topCommits.forEach(function (commit) {
|
|
16012
16172
|
var dateText = formatAssistantChangeDate(commit.date) || 'recent';
|
|
16173
|
+
if (isLibraryRepository) {
|
|
16174
|
+
lines.push("- ".concat(dateText, ": Platform/library update."));
|
|
16175
|
+
return;
|
|
16176
|
+
}
|
|
16013
16177
|
lines.push("- ".concat(dateText, ": ").concat(sanitizeAssistantChangeSubject(commit.subject), "."));
|
|
16014
16178
|
});
|
|
16015
16179
|
if (asksDuration) {
|
|
@@ -16032,9 +16196,29 @@ function buildAssistantChangeHistorySummaryFromCommits(params) {
|
|
|
16032
16196
|
}
|
|
16033
16197
|
return __assign({ response: lines.join('\n'), reason: 'detailed', commitCount: topCommits.length, generic: false }, (branch ? { branch: branch } : {}));
|
|
16034
16198
|
}
|
|
16199
|
+
function buildAssistantChangeHistoryUnavailableResponse(message, reason) {
|
|
16200
|
+
var asksDuration = isAssistantChangeDurationQuestion(message);
|
|
16201
|
+
var lines = ['Recent change summary:'];
|
|
16202
|
+
if (reason === 'error') {
|
|
16203
|
+
lines.push('- I could not read repository history in this environment right now, so exact rollout dates are unavailable.');
|
|
16204
|
+
}
|
|
16205
|
+
else {
|
|
16206
|
+
lines.push('- Repository history is not accessible in this environment, so exact rollout dates are unavailable here.');
|
|
16207
|
+
}
|
|
16208
|
+
lines.push('- I can still explain current behavior now, and provide exact dates once repository history is available.');
|
|
16209
|
+
if (asksDuration) {
|
|
16210
|
+
lines.push('- Best-known timing: unable to confirm exact first release date from this runtime.');
|
|
16211
|
+
}
|
|
16212
|
+
return {
|
|
16213
|
+
response: lines.join('\n'),
|
|
16214
|
+
reason: reason,
|
|
16215
|
+
commitCount: 0,
|
|
16216
|
+
generic: true
|
|
16217
|
+
};
|
|
16218
|
+
}
|
|
16035
16219
|
function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
16036
16220
|
return __awaiter(this, void 0, void 0, function () {
|
|
16037
|
-
var workspaceRoot, _a, gitRoots, sawExecutionError, gitRoots_1, gitRoots_1_1, gitRoot, _b, branch, _c, _d, limit, historyDepth, rawHistory, commits, _e, e_46_1;
|
|
16221
|
+
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_46_1;
|
|
16038
16222
|
var e_46, _f;
|
|
16039
16223
|
return __generator(this, function (_g) {
|
|
16040
16224
|
switch (_g.label) {
|
|
@@ -16056,15 +16240,17 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
|
16056
16240
|
return [3 /*break*/, 4];
|
|
16057
16241
|
case 4:
|
|
16058
16242
|
if (!workspaceRoot) {
|
|
16059
|
-
return [2 /*return*/,
|
|
16243
|
+
return [2 /*return*/, buildAssistantChangeHistoryUnavailableResponse(params.message, 'no_repo')];
|
|
16060
16244
|
}
|
|
16061
16245
|
return [4 /*yield*/, resolveAssistantWorkspaceGitRoots(workspaceRoot)];
|
|
16062
16246
|
case 5:
|
|
16063
16247
|
gitRoots = _g.sent();
|
|
16064
16248
|
if (!gitRoots.length) {
|
|
16065
|
-
return [2 /*return*/,
|
|
16249
|
+
return [2 /*return*/, buildAssistantChangeHistoryUnavailableResponse(params.message, 'no_repo')];
|
|
16066
16250
|
}
|
|
16251
|
+
featureKeywords = resolveAssistantChangeHistoryKeywords(params.message);
|
|
16067
16252
|
sawExecutionError = false;
|
|
16253
|
+
bestFallback = null;
|
|
16068
16254
|
_g.label = 6;
|
|
16069
16255
|
case 6:
|
|
16070
16256
|
_g.trys.push([6, 21, 22, 23]);
|
|
@@ -16121,13 +16307,31 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
|
16121
16307
|
if (!commits.length) {
|
|
16122
16308
|
return [3 /*break*/, 19];
|
|
16123
16309
|
}
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16310
|
+
summary = buildAssistantChangeHistorySummaryFromCommits({
|
|
16311
|
+
message: params.message,
|
|
16312
|
+
user: params.user,
|
|
16313
|
+
isSuperAdmin: params.isSuperAdmin,
|
|
16314
|
+
commits: commits,
|
|
16315
|
+
branch: branch,
|
|
16316
|
+
repositoryName: path.basename(gitRoot)
|
|
16317
|
+
});
|
|
16318
|
+
hasKeywordMatches = !featureKeywords.length
|
|
16319
|
+
|| commits.some(function (commit) { return scoreAssistantChangeHistoryCommitByKeywords(commit, featureKeywords) > 0; });
|
|
16320
|
+
if (hasKeywordMatches && summary.reason === 'detailed') {
|
|
16321
|
+
return [2 /*return*/, summary];
|
|
16322
|
+
}
|
|
16323
|
+
if (!bestFallback) {
|
|
16324
|
+
bestFallback = summary;
|
|
16325
|
+
return [3 /*break*/, 19];
|
|
16326
|
+
}
|
|
16327
|
+
if (summary.reason === 'detailed' && bestFallback.reason !== 'detailed') {
|
|
16328
|
+
bestFallback = summary;
|
|
16329
|
+
return [3 /*break*/, 19];
|
|
16330
|
+
}
|
|
16331
|
+
if (summary.reason === bestFallback.reason && summary.commitCount > bestFallback.commitCount) {
|
|
16332
|
+
bestFallback = summary;
|
|
16333
|
+
}
|
|
16334
|
+
return [3 /*break*/, 19];
|
|
16131
16335
|
case 18:
|
|
16132
16336
|
_e = _g.sent();
|
|
16133
16337
|
sawExecutionError = true;
|
|
@@ -16147,10 +16351,13 @@ function resolveAssistantChangeHistoryFastPathResponse(params) {
|
|
|
16147
16351
|
finally { if (e_46) throw e_46.error; }
|
|
16148
16352
|
return [7 /*endfinally*/];
|
|
16149
16353
|
case 23:
|
|
16354
|
+
if (bestFallback) {
|
|
16355
|
+
return [2 /*return*/, bestFallback];
|
|
16356
|
+
}
|
|
16150
16357
|
if (sawExecutionError) {
|
|
16151
|
-
return [2 /*return*/,
|
|
16358
|
+
return [2 /*return*/, buildAssistantChangeHistoryUnavailableResponse(params.message, 'error')];
|
|
16152
16359
|
}
|
|
16153
|
-
return [2 /*return*/,
|
|
16360
|
+
return [2 /*return*/, buildAssistantChangeHistoryUnavailableResponse(params.message, 'no_repo')];
|
|
16154
16361
|
}
|
|
16155
16362
|
});
|
|
16156
16363
|
});
|