@resolveio/server-lib 22.1.16 → 22.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/methods/ai-terminal.js +57 -17
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +2 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -1519,7 +1519,7 @@ function executeAiFormPatch(payload, context) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
function executeAiAssistantCodexRun(payload, context) {
|
|
1521
1521
|
return __awaiter(this, void 0, void 0, function () {
|
|
1522
|
-
var input, message, aiWorkerDebug, requestId, codexModel, codexFallbackModels, guardrail, conversation_3, now_3, userMsg, assistantMsg, user, isSuperAdmin, canViewDebug, hasInvoiceAccess, customerId, conversation, now, attachments, navigationFastPath, userMsg, assistantMsg, assistantInsert, assistantMessageId_1, changeHistoryFastPath, userMsg, assistantMsg, assistantInsert, assistantMessageId_2, attachmentData, historyLimit, history, _a, historyLines, recentToolError, userDoc, initialProgress, assistantDoc, insertResult, assistantMessageId;
|
|
1522
|
+
var input, message, aiWorkerDebug, requestId, codexModel, codexFallbackModels, guardrail, conversation_3, now_3, userMsg, assistantMsg, user, isSuperAdmin, canViewDebug, hasInvoiceAccess, customerId, conversation, now, attachments, navigationFastPath, userMsg, assistantMsg, assistantInsert, assistantMessageId_1, changeHistoryFastPath, changeHistoryFastPathBypassedReason, userMsg, assistantMsg, assistantInsert, assistantMessageId_2, attachmentData, historyLimit, history, _a, historyLines, recentToolError, userDoc, initialProgress, assistantDoc, insertResult, assistantMessageId;
|
|
1523
1523
|
var _this = this;
|
|
1524
1524
|
var _b, _c, _d;
|
|
1525
1525
|
return __generator(this, function (_e) {
|
|
@@ -1646,7 +1646,12 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1646
1646
|
})];
|
|
1647
1647
|
case 12:
|
|
1648
1648
|
changeHistoryFastPath = _e.sent();
|
|
1649
|
-
|
|
1649
|
+
changeHistoryFastPathBypassedReason = (changeHistoryFastPath
|
|
1650
|
+
&& (changeHistoryFastPath.reason === 'no_repo' || changeHistoryFastPath.reason === 'error')
|
|
1651
|
+
&& !shouldReturnAssistantChangeHistoryUnavailableFastPath())
|
|
1652
|
+
? changeHistoryFastPath.reason
|
|
1653
|
+
: '';
|
|
1654
|
+
if (!(changeHistoryFastPath && !changeHistoryFastPathBypassedReason)) return [3 /*break*/, 16];
|
|
1650
1655
|
userMsg = {
|
|
1651
1656
|
id_conversation: conversation._id,
|
|
1652
1657
|
role: 'user',
|
|
@@ -1819,6 +1824,11 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1819
1824
|
contextRoute = normalizeOptionalString((_k = input === null || input === void 0 ? void 0 : input.context) === null || _k === void 0 ? void 0 : _k.route);
|
|
1820
1825
|
contextMode = normalizeOptionalString((_l = input === null || input === void 0 ? void 0 : input.context) === null || _l === void 0 ? void 0 : _l.mode);
|
|
1821
1826
|
recordStep('Queued', { requestId: requestId || undefined });
|
|
1827
|
+
if (changeHistoryFastPathBypassedReason) {
|
|
1828
|
+
recordStep('Planning: change-history fast path unavailable', {
|
|
1829
|
+
reason: changeHistoryFastPathBypassedReason
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1822
1832
|
recordStep('Planning: request classification', {
|
|
1823
1833
|
type: requestClassification.type,
|
|
1824
1834
|
source: requestClassification.source,
|
|
@@ -1918,7 +1928,8 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1918
1928
|
fieldHints: fieldHints,
|
|
1919
1929
|
methodHints: methodHints,
|
|
1920
1930
|
publicationHints: publicationHints,
|
|
1921
|
-
recentToolError: recentToolError
|
|
1931
|
+
recentToolError: recentToolError,
|
|
1932
|
+
changeHistoryFastPathBypassedReason: changeHistoryFastPathBypassedReason
|
|
1922
1933
|
});
|
|
1923
1934
|
heuristicDirectivePrecomputed = dataQuestion
|
|
1924
1935
|
? buildAssistantHeuristicDirective(message, collectionHints, collectionNames)
|
|
@@ -2513,7 +2524,9 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2513
2524
|
}
|
|
2514
2525
|
});
|
|
2515
2526
|
}
|
|
2516
|
-
finalMetadata = __assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), (
|
|
2527
|
+
finalMetadata = __assign(__assign(__assign(__assign(__assign({ model: codexModel }, (codexFallbackModels.length ? { model_fallbacks: codexFallbackModels } : {})), (requestId ? { request_id: requestId } : {})), (changeHistoryFastPathBypassedReason ? {
|
|
2528
|
+
fast_path_change_history_bypassed_reason: changeHistoryFastPathBypassedReason
|
|
2529
|
+
} : {})), (toolResult ? { tool_result: toolResult } : {})), (assistantDebug ? { debug: assistantDebug } : {}));
|
|
2517
2530
|
finalUsage = codexUsage.total_tokens > 0 ? {
|
|
2518
2531
|
model: codexModel || 'unknown',
|
|
2519
2532
|
input_tokens: codexUsage.input_tokens,
|
|
@@ -16884,6 +16897,11 @@ function parseAssistantPathList(value) {
|
|
|
16884
16897
|
.map(function (entry) { return normalizeOptionalString(entry); })
|
|
16885
16898
|
.filter(Boolean);
|
|
16886
16899
|
}
|
|
16900
|
+
function resolveAssistantConfiguredWorkspaceRoots(serverConfigParam, envParam) {
|
|
16901
|
+
var serverConfig = serverConfigParam || resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
16902
|
+
var env = envParam || process.env || {};
|
|
16903
|
+
return mergeAssistantHintValues(parseAssistantPathList(serverConfig['AI_ASSISTANT_WORKSPACE_ROOTS']), parseAssistantPathList(env['AI_ASSISTANT_WORKSPACE_ROOTS']), parseAssistantPathList(serverConfig['AI_ASSISTANT_GIT_ROOTS']), parseAssistantPathList(env['AI_ASSISTANT_GIT_ROOTS']), parseAssistantPathList(serverConfig['AI_ASSISTANT_WORKSPACE_ROOT']), parseAssistantPathList(env['AI_ASSISTANT_WORKSPACE_ROOT']), parseAssistantPathList(serverConfig['AI_ASSISTANT_ROOT_WORKSPACE']), parseAssistantPathList(env['AI_ASSISTANT_ROOT_WORKSPACE']), parseAssistantPathList(serverConfig['AI_TERMINAL_WORKSPACE_ROOT']), parseAssistantPathList(env['AI_TERMINAL_WORKSPACE_ROOT']), parseAssistantPathList(serverConfig['AI_DASHBOARD_WORKSPACE_ROOT']), parseAssistantPathList(env['AI_DASHBOARD_WORKSPACE_ROOT']));
|
|
16904
|
+
}
|
|
16887
16905
|
function buildAssistantParentDirectoryCandidates(basePath, maxDepth) {
|
|
16888
16906
|
if (maxDepth === void 0) { maxDepth = 4; }
|
|
16889
16907
|
var normalized = normalizeOptionalString(basePath);
|
|
@@ -16908,7 +16926,7 @@ function buildAssistantWorkspaceRootCandidates(params) {
|
|
|
16908
16926
|
var cwdValue = normalizeOptionalString((params === null || params === void 0 ? void 0 : params.cwd) || process.cwd());
|
|
16909
16927
|
var dirnameValue = normalizeOptionalString((params === null || params === void 0 ? void 0 : params.dirname) || __dirname);
|
|
16910
16928
|
var homeDir = normalizeOptionalString(os.homedir());
|
|
16911
|
-
var configuredRoots =
|
|
16929
|
+
var configuredRoots = resolveAssistantConfiguredWorkspaceRoots(serverConfig, env);
|
|
16912
16930
|
var pathCandidates = __spreadArray(__spreadArray(__spreadArray([
|
|
16913
16931
|
serverConfig['AI_ASSISTANT_WORKSPACE_ROOT'],
|
|
16914
16932
|
env['AI_ASSISTANT_WORKSPACE_ROOT'],
|
|
@@ -16943,20 +16961,21 @@ function buildAssistantWorkspaceRootCandidates(params) {
|
|
|
16943
16961
|
}
|
|
16944
16962
|
function resolveAssistantWorkspaceRoot() {
|
|
16945
16963
|
return __awaiter(this, void 0, void 0, function () {
|
|
16946
|
-
var candidates, firstExisting, candidates_8, candidates_8_1, candidate, _a, gitRoot, e_44_1;
|
|
16964
|
+
var candidates, firstExisting, firstNestedGitRoot, candidates_8, candidates_8_1, candidate, _a, gitRoot, nestedGitRoots, e_44_1;
|
|
16947
16965
|
var e_44, _b;
|
|
16948
16966
|
return __generator(this, function (_c) {
|
|
16949
16967
|
switch (_c.label) {
|
|
16950
16968
|
case 0:
|
|
16951
16969
|
candidates = buildAssistantWorkspaceRootCandidates();
|
|
16952
16970
|
firstExisting = '';
|
|
16971
|
+
firstNestedGitRoot = '';
|
|
16953
16972
|
_c.label = 1;
|
|
16954
16973
|
case 1:
|
|
16955
|
-
_c.trys.push([1,
|
|
16974
|
+
_c.trys.push([1, 9, 10, 11]);
|
|
16956
16975
|
candidates_8 = __values(candidates), candidates_8_1 = candidates_8.next();
|
|
16957
16976
|
_c.label = 2;
|
|
16958
16977
|
case 2:
|
|
16959
|
-
if (!!candidates_8_1.done) return [3 /*break*/,
|
|
16978
|
+
if (!!candidates_8_1.done) return [3 /*break*/, 8];
|
|
16960
16979
|
candidate = candidates_8_1.value;
|
|
16961
16980
|
_a = !candidate;
|
|
16962
16981
|
if (_a) return [3 /*break*/, 4];
|
|
@@ -16966,7 +16985,7 @@ function resolveAssistantWorkspaceRoot() {
|
|
|
16966
16985
|
_c.label = 4;
|
|
16967
16986
|
case 4:
|
|
16968
16987
|
if (_a) {
|
|
16969
|
-
return [3 /*break*/,
|
|
16988
|
+
return [3 /*break*/, 7];
|
|
16970
16989
|
}
|
|
16971
16990
|
if (!firstExisting) {
|
|
16972
16991
|
firstExisting = candidate;
|
|
@@ -16975,24 +16994,34 @@ function resolveAssistantWorkspaceRoot() {
|
|
|
16975
16994
|
case 5:
|
|
16976
16995
|
gitRoot = _c.sent();
|
|
16977
16996
|
if (gitRoot) {
|
|
16978
|
-
return [2 /*return*/,
|
|
16997
|
+
return [2 /*return*/, gitRoot];
|
|
16979
16998
|
}
|
|
16980
|
-
|
|
16999
|
+
if (!!firstNestedGitRoot) return [3 /*break*/, 7];
|
|
17000
|
+
return [4 /*yield*/, resolveAssistantWorkspaceGitRoots(candidate)];
|
|
16981
17001
|
case 6:
|
|
17002
|
+
nestedGitRoots = _c.sent();
|
|
17003
|
+
if (nestedGitRoots.length) {
|
|
17004
|
+
firstNestedGitRoot = nestedGitRoots[0];
|
|
17005
|
+
}
|
|
17006
|
+
_c.label = 7;
|
|
17007
|
+
case 7:
|
|
16982
17008
|
candidates_8_1 = candidates_8.next();
|
|
16983
17009
|
return [3 /*break*/, 2];
|
|
16984
|
-
case
|
|
16985
|
-
case
|
|
17010
|
+
case 8: return [3 /*break*/, 11];
|
|
17011
|
+
case 9:
|
|
16986
17012
|
e_44_1 = _c.sent();
|
|
16987
17013
|
e_44 = { error: e_44_1 };
|
|
16988
|
-
return [3 /*break*/,
|
|
16989
|
-
case
|
|
17014
|
+
return [3 /*break*/, 11];
|
|
17015
|
+
case 10:
|
|
16990
17016
|
try {
|
|
16991
17017
|
if (candidates_8_1 && !candidates_8_1.done && (_b = candidates_8.return)) _b.call(candidates_8);
|
|
16992
17018
|
}
|
|
16993
17019
|
finally { if (e_44) throw e_44.error; }
|
|
16994
17020
|
return [7 /*endfinally*/];
|
|
16995
|
-
case
|
|
17021
|
+
case 11:
|
|
17022
|
+
if (firstNestedGitRoot) {
|
|
17023
|
+
return [2 /*return*/, firstNestedGitRoot];
|
|
17024
|
+
}
|
|
16996
17025
|
if (firstExisting) {
|
|
16997
17026
|
return [2 /*return*/, firstExisting];
|
|
16998
17027
|
}
|
|
@@ -17769,6 +17798,11 @@ function buildAssistantContext(input, userContext) {
|
|
|
17769
17798
|
if (recentToolError) {
|
|
17770
17799
|
lines.push("Most recent data-query error: ".concat(recentToolError));
|
|
17771
17800
|
}
|
|
17801
|
+
var changeHistoryBypassReason = normalizeOptionalString(userContext === null || userContext === void 0 ? void 0 : userContext.changeHistoryFastPathBypassedReason);
|
|
17802
|
+
if (changeHistoryBypassReason) {
|
|
17803
|
+
lines.push("Change history fast path unavailable: ".concat(changeHistoryBypassReason));
|
|
17804
|
+
lines.push('For change-history requests, run git history lookups through available repository tooling before concluding history is unavailable.');
|
|
17805
|
+
}
|
|
17772
17806
|
var mongoDb = normalizeOptionalString((_c = input === null || input === void 0 ? void 0 : input.mongo) === null || _c === void 0 ? void 0 : _c.database);
|
|
17773
17807
|
var mongoDbs = Array.isArray((_d = input === null || input === void 0 ? void 0 : input.mongo) === null || _d === void 0 ? void 0 : _d.databases)
|
|
17774
17808
|
? input.mongo.databases.map(function (value) { return normalizeOptionalString(value); }).filter(Boolean)
|
|
@@ -18734,7 +18768,7 @@ function resolveAssistantWorkspaceGitRoots(workspaceRoot) {
|
|
|
18734
18768
|
return [4 /*yield*/, resolveAssistantGitRoot(workspaceRoot)];
|
|
18735
18769
|
case 1:
|
|
18736
18770
|
_a.apply(void 0, [_h.sent()]);
|
|
18737
|
-
configuredRoots =
|
|
18771
|
+
configuredRoots = resolveAssistantConfiguredWorkspaceRoots();
|
|
18738
18772
|
_h.label = 2;
|
|
18739
18773
|
case 2:
|
|
18740
18774
|
_h.trys.push([2, 7, 8, 9]);
|
|
@@ -19016,6 +19050,12 @@ function buildAssistantChangeHistoryUnavailableResponse(message, reason) {
|
|
|
19016
19050
|
generic: true
|
|
19017
19051
|
};
|
|
19018
19052
|
}
|
|
19053
|
+
function shouldReturnAssistantChangeHistoryUnavailableFastPath() {
|
|
19054
|
+
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
19055
|
+
var configured = normalizeOptionalBoolean(config['AI_ASSISTANT_CHANGE_HISTORY_UNAVAILABLE_FAST_PATH']
|
|
19056
|
+
|| process.env.AI_ASSISTANT_CHANGE_HISTORY_UNAVAILABLE_FAST_PATH);
|
|
19057
|
+
return configured === true;
|
|
19058
|
+
}
|
|
19019
19059
|
function resolveAssistantChangeHistoryGitRepoUrls() {
|
|
19020
19060
|
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
19021
19061
|
var rawValues = [
|