@resolveio/server-lib 22.2.12 → 22.2.14
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 +76 -43
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -171,8 +171,8 @@ var DEFAULT_MAX_TOTAL_ATTACHMENT_CHARS = 40000;
|
|
|
171
171
|
var DEFAULT_CODEX_MODEL = 'gpt-5.3-codex';
|
|
172
172
|
var DEFAULT_CODEX_FALLBACK_MODEL = 'gpt-5.2-codex';
|
|
173
173
|
var DEFAULT_CODEX_TIMEOUT_MS = 180000;
|
|
174
|
-
var DEFAULT_AI_ASSISTANT_RUN_BUDGET_MS =
|
|
175
|
-
var DEFAULT_AI_ASSISTANT_MONGO_MAX_TIME_MS =
|
|
174
|
+
var DEFAULT_AI_ASSISTANT_RUN_BUDGET_MS = 120000;
|
|
175
|
+
var DEFAULT_AI_ASSISTANT_MONGO_MAX_TIME_MS = 12000;
|
|
176
176
|
var AI_ASSISTANT_MONGO_DEFAULT_LIMIT = 20;
|
|
177
177
|
var AI_ASSISTANT_MONGO_MAX_LIMIT = 200;
|
|
178
178
|
var AI_ASSISTANT_MONGO_EXPORT_MAX_LIMIT = 5000;
|
|
@@ -1603,7 +1603,7 @@ function executeAiFormPatch(payload, context) {
|
|
|
1603
1603
|
}
|
|
1604
1604
|
function executeAiAssistantCodexRun(payload, context) {
|
|
1605
1605
|
return __awaiter(this, void 0, void 0, function () {
|
|
1606
|
-
var input, message, aiWorkerDebug, requestId, codexModel, codexFallbackModels, guardrail, conversation_3, now_3, userMsg, assistantMsg,
|
|
1606
|
+
var input, message, aiWorkerDebug, requestId, codexModel, codexFallbackModels, user, isSuperAdmin, guardrail, conversation_3, now_3, userMsg, assistantMsg, canViewDebug, hasInvoiceAccess, customerId, conversation, now, attachments, navigationFastPath, userMsg, assistantMsg, assistantInsert, assistantMessageId_1, changeHistoryFastPath, changeHistoryFastPathBypassedReason, userMsg, assistantMsg, assistantInsert, assistantMessageId_2, attachmentData, historyLines, recentToolError, userDoc, initialProgress, assistantDoc, insertResult, assistantMessageId;
|
|
1607
1607
|
var _this = this;
|
|
1608
1608
|
var _a, _b, _c;
|
|
1609
1609
|
return __generator(this, function (_d) {
|
|
@@ -1621,10 +1621,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1621
1621
|
requestId = normalizeOptionalString(input.request_id);
|
|
1622
1622
|
codexModel = resolveCodexModel(input.config);
|
|
1623
1623
|
codexFallbackModels = resolveCodexFallbackModels(input.config, codexModel);
|
|
1624
|
+
return [4 /*yield*/, user_collection_1.Users.findById(context === null || context === void 0 ? void 0 : context.id_user)];
|
|
1625
|
+
case 1:
|
|
1626
|
+
user = _d.sent();
|
|
1627
|
+
if (!user) {
|
|
1628
|
+
throw new Error('Unauthorized.');
|
|
1629
|
+
}
|
|
1630
|
+
isSuperAdmin = !!((_a = user === null || user === void 0 ? void 0 : user.roles) === null || _a === void 0 ? void 0 : _a.super_admin);
|
|
1624
1631
|
guardrail = evaluateAssistantGuardrails(message);
|
|
1625
|
-
if (!(guardrail === null || guardrail === void 0 ? void 0 : guardrail.blocked)) return [3 /*break*/,
|
|
1632
|
+
if (!(guardrail === null || guardrail === void 0 ? void 0 : guardrail.blocked)) return [3 /*break*/, 6];
|
|
1626
1633
|
return [4 /*yield*/, ensureConversation(input, 'codex', context === null || context === void 0 ? void 0 : context.id_user)];
|
|
1627
|
-
case
|
|
1634
|
+
case 2:
|
|
1628
1635
|
conversation_3 = _d.sent();
|
|
1629
1636
|
now_3 = new Date();
|
|
1630
1637
|
userMsg = {
|
|
@@ -1644,23 +1651,20 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1644
1651
|
updatedAt: now_3
|
|
1645
1652
|
};
|
|
1646
1653
|
return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.insertOne(userMsg)];
|
|
1647
|
-
case
|
|
1654
|
+
case 3:
|
|
1648
1655
|
_d.sent();
|
|
1649
1656
|
return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.insertOne(assistantMsg)];
|
|
1650
|
-
case
|
|
1657
|
+
case 4:
|
|
1651
1658
|
_d.sent();
|
|
1652
1659
|
return [4 /*yield*/, touchConversation(conversation_3._id, now_3)];
|
|
1653
|
-
case
|
|
1660
|
+
case 5:
|
|
1654
1661
|
_d.sent();
|
|
1655
1662
|
return [2 /*return*/, {
|
|
1656
1663
|
conversation: conversation_3,
|
|
1657
1664
|
message: assistantMsg,
|
|
1658
1665
|
guardrails: { blocked: true, reason: guardrail.reason }
|
|
1659
1666
|
}];
|
|
1660
|
-
case 5: return [4 /*yield*/, user_collection_1.Users.findById(context === null || context === void 0 ? void 0 : context.id_user)];
|
|
1661
1667
|
case 6:
|
|
1662
|
-
user = _d.sent();
|
|
1663
|
-
isSuperAdmin = !!((_a = user === null || user === void 0 ? void 0 : user.roles) === null || _a === void 0 ? void 0 : _a.super_admin);
|
|
1664
1668
|
canViewDebug = isAssistantDebugUser(user);
|
|
1665
1669
|
if (shouldLogAssistantFinalizeDebug()) {
|
|
1666
1670
|
console.log(new Date(), '[AI-Dashboard][AI-Assistant] debug-visibility', {
|
|
@@ -1811,14 +1815,17 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1811
1815
|
insertResult = _d.sent();
|
|
1812
1816
|
assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
|
|
1813
1817
|
enqueueAssistantCodexRun(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1814
|
-
var runStart, fastModeEnabled, runBudgetMs, 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, termHints, collectionHints, fieldHints, methodHints, publicationHints, collectionTokenization, collectionRanking, collectionSelection, collectionOverride, collectionNames,
|
|
1818
|
+
var runStart, fastModeEnabled, 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, termHints, collectionHints, fieldHints, 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, rankedCollectionHints, rankedCollections, hintCollections, 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, toolRequest, toolStart, toolResponse, _h, toolPayload, zeroRowResult, skipFollowupCodex, followupPrompt, followupStart, followupText, _j, error_3, error_4, runBudgetExceeded, finishedAt, finalNow, finishedAt, codexMs, draftingMs, finalMetadata, finalUsage, usageClientId, usageError_1, finalAssistantDoc, setPayload, finalizeError_1, failedAt, fallbackContent, failureMetadata, persistError_1, _k;
|
|
1815
1819
|
var _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
1816
1820
|
return __generator(this, function (_14) {
|
|
1817
1821
|
switch (_14.label) {
|
|
1818
1822
|
case 0:
|
|
1819
1823
|
runStart = Date.now();
|
|
1820
|
-
fastModeEnabled = resolveAssistantFastModeEnabled();
|
|
1821
|
-
|
|
1824
|
+
fastModeEnabled = resolveAssistantFastModeEnabled(input.config);
|
|
1825
|
+
plannerEnabled = resolveAssistantPlannerEnabled(input.config);
|
|
1826
|
+
runBudgetMs = resolveAssistantRunBudgetMs(input.config);
|
|
1827
|
+
assistantMongoMaxTimeMs = resolveAssistantMongoDefaultMaxTimeMs(input.config);
|
|
1828
|
+
assistantSystemPrompt = resolveAssistantSystemPrompt(input.config);
|
|
1822
1829
|
runDeadlineMs = fastModeEnabled ? runStart + runBudgetMs : null;
|
|
1823
1830
|
if (aiWorkerDebug) {
|
|
1824
1831
|
console.log(new Date(), '[AI Worker Debug] codex run start', {
|
|
@@ -1901,7 +1908,6 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
1901
1908
|
collectionSelection = null;
|
|
1902
1909
|
collectionOverride = null;
|
|
1903
1910
|
collectionNames = [];
|
|
1904
|
-
plannerEnabled = resolveAssistantPlannerEnabled();
|
|
1905
1911
|
plannerUsed = false;
|
|
1906
1912
|
plannerSkipReason = '';
|
|
1907
1913
|
plannerOutput = null;
|
|
@@ -2052,7 +2058,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2052
2058
|
heuristic: normalizeOptionalString(heuristicDirectivePrecomputed === null || heuristicDirectivePrecomputed === void 0 ? void 0 : heuristicDirectivePrecomputed.rawLine) || undefined
|
|
2053
2059
|
});
|
|
2054
2060
|
}
|
|
2055
|
-
prompt_1 = buildAssistantCodexPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext);
|
|
2061
|
+
prompt_1 = buildAssistantCodexPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, assistantSystemPrompt);
|
|
2056
2062
|
return [4 /*yield*/, resolveAssistantWorkspaceRoot()];
|
|
2057
2063
|
case 7:
|
|
2058
2064
|
workspaceRoot = _14.sent();
|
|
@@ -2190,7 +2196,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2190
2196
|
}
|
|
2191
2197
|
if (!(dataQuestion && !directive)) return [3 /*break*/, 17];
|
|
2192
2198
|
recordStep('Directive: determine tool', { type: 'data-question' });
|
|
2193
|
-
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode);
|
|
2199
|
+
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode, assistantSystemPrompt);
|
|
2194
2200
|
if (!hasRunBudget('Directive: determine tool')) return [3 /*break*/, 17];
|
|
2195
2201
|
_14.label = 14;
|
|
2196
2202
|
case 14:
|
|
@@ -2254,7 +2260,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2254
2260
|
case 21:
|
|
2255
2261
|
if (!(!directive && dataQuestion)) return [3 /*break*/, 25];
|
|
2256
2262
|
recordStep('Directive: forced retry', { mode: 'directive-only' });
|
|
2257
|
-
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode);
|
|
2263
|
+
directivePrompt = buildAssistantCodexDirectivePrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, directiveStyleHint, directivePromptMode, assistantSystemPrompt);
|
|
2258
2264
|
if (!hasRunBudget('Directive: forced retry')) return [3 /*break*/, 25];
|
|
2259
2265
|
_14.label = 22;
|
|
2260
2266
|
case 22:
|
|
@@ -2297,7 +2303,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2297
2303
|
requestedTimeGrain: requestedTimeGrain,
|
|
2298
2304
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2299
2305
|
strict: true
|
|
2300
|
-
}), 'aggregate_only');
|
|
2306
|
+
}), 'aggregate_only', assistantSystemPrompt);
|
|
2301
2307
|
if (!hasRunBudget('Directive: dated retry')) return [3 /*break*/, 29];
|
|
2302
2308
|
_14.label = 26;
|
|
2303
2309
|
case 26:
|
|
@@ -2345,7 +2351,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2345
2351
|
requestedTimeGrain: requestedTimeGrain,
|
|
2346
2352
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2347
2353
|
strict: true
|
|
2348
|
-
}), 'aggregate_only');
|
|
2354
|
+
}), 'aggregate_only', assistantSystemPrompt);
|
|
2349
2355
|
if (!hasRunBudget('Directive: dated guard retry')) return [3 /*break*/, 33];
|
|
2350
2356
|
_14.label = 30;
|
|
2351
2357
|
case 30:
|
|
@@ -2391,7 +2397,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2391
2397
|
requestedTimeGrain: requestedTimeGrain,
|
|
2392
2398
|
requestedBreakdowns: requestedBreakdownDimensions,
|
|
2393
2399
|
strict: true
|
|
2394
|
-
}), 'aggregate_only');
|
|
2400
|
+
}), 'aggregate_only', assistantSystemPrompt);
|
|
2395
2401
|
if (!hasRunBudget('Directive: grouped guard retry')) return [3 /*break*/, 37];
|
|
2396
2402
|
_14.label = 34;
|
|
2397
2403
|
case 34:
|
|
@@ -2489,7 +2495,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2489
2495
|
toolRequest.__assistantRuntime = {
|
|
2490
2496
|
fastMode: fastModeEnabled,
|
|
2491
2497
|
deadlineMs: runDeadlineMs || undefined,
|
|
2492
|
-
maxTimeMS:
|
|
2498
|
+
maxTimeMS: assistantMongoMaxTimeMs
|
|
2493
2499
|
};
|
|
2494
2500
|
progressTracker.push('Grabbing Data');
|
|
2495
2501
|
recordStep('Grabbing Data: start', {
|
|
@@ -2543,7 +2549,7 @@ function executeAiAssistantCodexRun(payload, context) {
|
|
|
2543
2549
|
return [3 /*break*/, 51];
|
|
2544
2550
|
case 45:
|
|
2545
2551
|
recordStep('Drafting response');
|
|
2546
|
-
followupPrompt = buildAssistantCodexToolFollowupPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, toolPayload.prompt);
|
|
2552
|
+
followupPrompt = buildAssistantCodexToolFollowupPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, toolPayload.prompt, assistantSystemPrompt);
|
|
2547
2553
|
if (!hasRunBudget('Drafting response: followup')) return [3 /*break*/, 50];
|
|
2548
2554
|
_14.label = 46;
|
|
2549
2555
|
case 46:
|
|
@@ -7464,14 +7470,15 @@ function buildAssistantToolResultPrompt(result, displayPreview) {
|
|
|
7464
7470
|
}
|
|
7465
7471
|
return lines.join('\n');
|
|
7466
7472
|
}
|
|
7467
|
-
function buildAssistantCodexToolFollowupPrompt(message, attachmentText, historyText, contextText, toolResultText) {
|
|
7473
|
+
function buildAssistantCodexToolFollowupPrompt(message, attachmentText, historyText, contextText, toolResultText, systemPromptText) {
|
|
7474
|
+
if (systemPromptText === void 0) { systemPromptText = AI_ASSISTANT_SYSTEM_PROMPT; }
|
|
7468
7475
|
var trimmedContext = normalizeOptionalString(contextText);
|
|
7469
7476
|
var contextBlock = trimmedContext ? "\n\nContext:\n".concat(trimmedContext) : '';
|
|
7470
7477
|
var trimmedHistory = normalizeOptionalString(historyText);
|
|
7471
7478
|
var historyBlock = trimmedHistory ? "\n\nConversation so far:\n".concat(trimmedHistory) : '';
|
|
7472
7479
|
var toolBlock = toolResultText ? "\n\nTool Result:\n".concat(toolResultText) : '';
|
|
7473
7480
|
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.';
|
|
7474
|
-
return "System:\n".concat(
|
|
7481
|
+
return "System:\n".concat(systemPromptText).concat(contextBlock).concat(historyBlock, "\n\nUser:\n").concat(message).concat(attachmentText || '').concat(toolBlock).concat(instruction).trim();
|
|
7475
7482
|
}
|
|
7476
7483
|
function buildAssistantToolFallbackResponse(result) {
|
|
7477
7484
|
var _a, _b;
|
|
@@ -16969,30 +16976,49 @@ function resolveCodexTimeoutMs() {
|
|
|
16969
16976
|
}
|
|
16970
16977
|
return DEFAULT_CODEX_TIMEOUT_MS;
|
|
16971
16978
|
}
|
|
16972
|
-
function resolveAssistantFastModeEnabled() {
|
|
16973
|
-
var
|
|
16974
|
-
|
|
16979
|
+
function resolveAssistantFastModeEnabled(config) {
|
|
16980
|
+
var override = normalizeOptionalBoolean((config === null || config === void 0 ? void 0 : config.fast_mode)
|
|
16981
|
+
|| (config === null || config === void 0 ? void 0 : config.fastMode));
|
|
16982
|
+
if (typeof override === 'boolean') {
|
|
16983
|
+
return override;
|
|
16984
|
+
}
|
|
16985
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
16986
|
+
var raw = normalizeOptionalBoolean(serverConfig['AI_ASSISTANT_FAST_MODE_ENABLED']
|
|
16975
16987
|
|| process.env.AI_ASSISTANT_FAST_MODE_ENABLED);
|
|
16976
|
-
return raw === undefined ?
|
|
16988
|
+
return raw === undefined ? false : raw === true;
|
|
16977
16989
|
}
|
|
16978
|
-
function resolveAssistantRunBudgetMs() {
|
|
16979
|
-
var
|
|
16980
|
-
|
|
16990
|
+
function resolveAssistantRunBudgetMs(config) {
|
|
16991
|
+
var override = normalizeOptionalNumber((config === null || config === void 0 ? void 0 : config.run_budget_ms)
|
|
16992
|
+
|| (config === null || config === void 0 ? void 0 : config.runBudgetMs));
|
|
16993
|
+
if (override && override > 0) {
|
|
16994
|
+
return Math.max((0, common_1.round)(override), 5000);
|
|
16995
|
+
}
|
|
16996
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
16997
|
+
var raw = normalizeOptionalNumber(serverConfig['AI_ASSISTANT_RUN_BUDGET_MS']
|
|
16981
16998
|
|| process.env.AI_ASSISTANT_RUN_BUDGET_MS);
|
|
16982
16999
|
if (raw && raw > 0) {
|
|
16983
17000
|
return Math.max((0, common_1.round)(raw), 5000);
|
|
16984
17001
|
}
|
|
16985
17002
|
return DEFAULT_AI_ASSISTANT_RUN_BUDGET_MS;
|
|
16986
17003
|
}
|
|
16987
|
-
function resolveAssistantMongoDefaultMaxTimeMs() {
|
|
16988
|
-
var
|
|
16989
|
-
|
|
17004
|
+
function resolveAssistantMongoDefaultMaxTimeMs(config) {
|
|
17005
|
+
var override = normalizeOptionalNumber((config === null || config === void 0 ? void 0 : config.mongo_max_time_ms)
|
|
17006
|
+
|| (config === null || config === void 0 ? void 0 : config.mongoMaxTimeMs));
|
|
17007
|
+
if (override && override > 0) {
|
|
17008
|
+
return Math.max((0, common_1.round)(override), 250);
|
|
17009
|
+
}
|
|
17010
|
+
var serverConfig = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
17011
|
+
var raw = normalizeOptionalNumber(serverConfig['AI_ASSISTANT_MONGO_MAX_TIME_MS']
|
|
16990
17012
|
|| process.env.AI_ASSISTANT_MONGO_MAX_TIME_MS);
|
|
16991
17013
|
if (raw && raw > 0) {
|
|
16992
17014
|
return Math.max((0, common_1.round)(raw), 250);
|
|
16993
17015
|
}
|
|
16994
17016
|
return DEFAULT_AI_ASSISTANT_MONGO_MAX_TIME_MS;
|
|
16995
17017
|
}
|
|
17018
|
+
function resolveAssistantSystemPrompt(config) {
|
|
17019
|
+
var override = normalizeOptionalString((config === null || config === void 0 ? void 0 : config.system_prompt) || (config === null || config === void 0 ? void 0 : config.systemPrompt));
|
|
17020
|
+
return override || AI_ASSISTANT_SYSTEM_PROMPT;
|
|
17021
|
+
}
|
|
16996
17022
|
function normalizeAssistantRuntimeControl(value) {
|
|
16997
17023
|
if (!value || typeof value !== 'object') {
|
|
16998
17024
|
return null;
|
|
@@ -18276,8 +18302,9 @@ function buildAssistantDirectiveStyleHint(params) {
|
|
|
18276
18302
|
params.strict ? '- STRICT: if unsure, still prefer REPORT_BUILDER_AGG.' : ''
|
|
18277
18303
|
].filter(Boolean).join('\n');
|
|
18278
18304
|
}
|
|
18279
|
-
function buildAssistantCodexDirectivePrompt(message, attachmentText, historyText, contextText, directiveStyleHintText, mode) {
|
|
18305
|
+
function buildAssistantCodexDirectivePrompt(message, attachmentText, historyText, contextText, directiveStyleHintText, mode, systemPromptText) {
|
|
18280
18306
|
if (mode === void 0) { mode = 'any'; }
|
|
18307
|
+
if (systemPromptText === void 0) { systemPromptText = AI_ASSISTANT_SYSTEM_PROMPT; }
|
|
18281
18308
|
var trimmedContext = normalizeOptionalString(contextText);
|
|
18282
18309
|
var contextBlock = trimmedContext ? "\n\nContext:\n".concat(trimmedContext) : '';
|
|
18283
18310
|
var trimmedHistory = normalizeOptionalString(historyText);
|
|
@@ -18287,21 +18314,27 @@ function buildAssistantCodexDirectivePrompt(message, attachmentText, historyText
|
|
|
18287
18314
|
var instruction = mode === 'aggregate_only'
|
|
18288
18315
|
? '\n\nInstruction:\nReturn ONLY a single REPORT_BUILDER_AGG directive line. Do not include any other text.'
|
|
18289
18316
|
: '\n\nInstruction:\nReturn ONLY a single REPORT_BUILDER_READ or REPORT_BUILDER_AGG directive line. Do not include any other text.';
|
|
18290
|
-
return "System:\n".concat(
|
|
18317
|
+
return "System:\n".concat(systemPromptText).concat(contextBlock).concat(historyBlock).concat(styleHintBlock, "\n\nUser:\n").concat(message).concat(attachmentText || '').concat(instruction).trim();
|
|
18291
18318
|
}
|
|
18292
|
-
function buildAssistantCodexPrompt(message, attachmentText, historyText, contextText) {
|
|
18319
|
+
function buildAssistantCodexPrompt(message, attachmentText, historyText, contextText, systemPromptText) {
|
|
18320
|
+
if (systemPromptText === void 0) { systemPromptText = AI_ASSISTANT_SYSTEM_PROMPT; }
|
|
18293
18321
|
var trimmedContext = normalizeOptionalString(contextText);
|
|
18294
18322
|
var contextBlock = trimmedContext ? "\n\nContext:\n".concat(trimmedContext) : '';
|
|
18295
18323
|
var trimmedHistory = normalizeOptionalString(historyText);
|
|
18296
18324
|
var historyBlock = trimmedHistory ? "\n\nConversation so far:\n".concat(trimmedHistory) : '';
|
|
18297
|
-
return "System:\n".concat(
|
|
18325
|
+
return "System:\n".concat(systemPromptText).concat(contextBlock).concat(historyBlock, "\n\nUser:\n").concat(message).concat(attachmentText || '').trim();
|
|
18298
18326
|
}
|
|
18299
|
-
function resolveAssistantPlannerEnabled() {
|
|
18327
|
+
function resolveAssistantPlannerEnabled(config) {
|
|
18300
18328
|
var _a;
|
|
18301
|
-
var
|
|
18302
|
-
|
|
18329
|
+
var override = normalizeOptionalBoolean((config === null || config === void 0 ? void 0 : config.planner_enabled)
|
|
18330
|
+
|| (config === null || config === void 0 ? void 0 : config.plannerEnabled));
|
|
18331
|
+
if (typeof override === 'boolean') {
|
|
18332
|
+
return override;
|
|
18333
|
+
}
|
|
18334
|
+
var serverConfig = ((_a = resolveio_server_app_1.ResolveIOServer.getServerConfig) === null || _a === void 0 ? void 0 : _a.call(resolveio_server_app_1.ResolveIOServer)) || {};
|
|
18335
|
+
var raw = normalizeOptionalBoolean(serverConfig['AI_ASSISTANT_CODEX_PLANNER_ENABLED']
|
|
18303
18336
|
|| process.env.AI_ASSISTANT_CODEX_PLANNER_ENABLED);
|
|
18304
|
-
return raw === undefined ?
|
|
18337
|
+
return raw === undefined ? false : raw === true;
|
|
18305
18338
|
}
|
|
18306
18339
|
function resolveAssistantPlannerKnownRoutes(user, isSuperAdmin) {
|
|
18307
18340
|
var e_47, _a;
|