@resolveio/server-lib 20.14.26 → 20.14.28
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
CHANGED
|
@@ -141,11 +141,11 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
|
|
|
141
141
|
'- Prefer high-level explanations and point to routes instead of code. Only mention file paths if explicitly requested.',
|
|
142
142
|
'- When asked where to do something, give the exact screen name and the in-app route as a standalone path starting with "/" so it can be clicked.',
|
|
143
143
|
'- When asked "why is this happening," respond with: cause, trigger, data source(s), and expected vs actual outcome.',
|
|
144
|
-
'- For troubleshooting, ask
|
|
144
|
+
'- 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).',
|
|
145
145
|
'- Provide checklists for common tasks, highlighting required fields and common pitfalls.',
|
|
146
146
|
'- If asked "where is this set," give the screen/workflow name and navigation steps to reach it.',
|
|
147
147
|
'- If asked "what changed," summarize release notes if known; if not available, say so and suggest where to check or offer a support ticket.',
|
|
148
|
-
'-
|
|
148
|
+
'- After answering, optionally suggest 0-1 related next steps only when helpful. Do not ask for "next steps" every time.',
|
|
149
149
|
'- If access is blocked, name the permission/role needed and how to request it.',
|
|
150
150
|
'- Avoid vague labels like "Operations app"; use the specific screen/workflow name.',
|
|
151
151
|
'- Do not mention other client projects or ask which client; stay within the current project context.',
|
|
@@ -157,6 +157,7 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
|
|
|
157
157
|
'- If the user explicitly asks to create/open/file a support ticket, end your response with a single line exactly in this format:',
|
|
158
158
|
'- SUPPORT_TICKET_CREATE: <one-line summary>',
|
|
159
159
|
'- Only include that line when the user clearly wants a ticket created. Do not claim a ticket is created unless you include that line.',
|
|
160
|
+
'- For direct questions, answer first. Ask a single follow-up only if required to run a query or resolve missing details.',
|
|
160
161
|
'- If you need database data to answer, end your response with a single line exactly in this format:',
|
|
161
162
|
'- MONGO_READ: {"collection":"<name>","query":{...},"options":{"projection":{...},"sort":{...},"limit":20},"permissionView":"</route>"}',
|
|
162
163
|
'- For invoice data, set permissionView to an invoice route (ex: /invoice/list or /report/invoice).',
|
|
@@ -164,6 +165,8 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
|
|
|
164
165
|
'- Assume you are not a super admin unless explicitly told otherwise.',
|
|
165
166
|
'- Only request data when the user has permission for that module; invoice data requires invoice view access.',
|
|
166
167
|
'- If the user lacks permission, answer without data and explain how to view it in the app or request access.',
|
|
168
|
+
'- For counts, totals, or time-range metrics, always use MONGO_READ. Do not guess or return 0 without data.',
|
|
169
|
+
'- Before issuing MONGO_READ, verify the collection name and key fields by checking collection/model definitions in the current app (look for "collectionName:" and date fields like date_created/date_completed/createdAt). Do not invent collection names.',
|
|
167
170
|
'- Use MONGO_READ only to produce summaries/snapshots/health checks (not raw dumps) when permitted.',
|
|
168
171
|
'- When referencing data, summarize it in bullets and avoid raw JSON or dumps.',
|
|
169
172
|
'- Keep responses concise and use low reasoning effort.'
|
|
@@ -419,6 +422,7 @@ function loadAiTerminalMethods(methodManager) {
|
|
|
419
422
|
}),
|
|
420
423
|
forceWorker: true,
|
|
421
424
|
maxConcurrencyPerInstance: 1,
|
|
425
|
+
timeoutOverride: resolveCodexTimeoutMs() + 15000,
|
|
422
426
|
function: function (payload) {
|
|
423
427
|
return __awaiter(this, void 0, void 0, function () {
|
|
424
428
|
return __generator(this, function (_a) {
|
|
@@ -1148,6 +1152,18 @@ function resolveCodexTimeoutMs() {
|
|
|
1148
1152
|
}
|
|
1149
1153
|
return DEFAULT_CODEX_TIMEOUT_MS;
|
|
1150
1154
|
}
|
|
1155
|
+
function resolveCodexWorkerThreadEnabled() {
|
|
1156
|
+
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1157
|
+
var raw = normalizeOptionalString(config['AI_ASSISTANT_CODEX_USE_WORKER_THREAD']
|
|
1158
|
+
|| process.env.AI_ASSISTANT_CODEX_USE_WORKER_THREAD
|
|
1159
|
+
|| config['AI_ASSISTANT_CODEX_WORKER_THREAD']
|
|
1160
|
+
|| process.env.AI_ASSISTANT_CODEX_WORKER_THREAD);
|
|
1161
|
+
var normalized = normalizeOptionalBoolean(raw);
|
|
1162
|
+
if (typeof normalized === 'boolean') {
|
|
1163
|
+
return normalized;
|
|
1164
|
+
}
|
|
1165
|
+
return process.env.IS_WORKER_INSTANCE !== 'true';
|
|
1166
|
+
}
|
|
1151
1167
|
function resolveCodexModel() {
|
|
1152
1168
|
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1153
1169
|
var raw = normalizeOptionalString(config['AI_ASSISTANT_CODEX_MODEL']
|
|
@@ -1189,21 +1205,26 @@ var CodexWorkerBootstrapError = /** @class */ (function (_super) {
|
|
|
1189
1205
|
}(Error));
|
|
1190
1206
|
function runCodexInWorkerThread(prompt, runOptions, config) {
|
|
1191
1207
|
return __awaiter(this, void 0, void 0, function () {
|
|
1192
|
-
var workerPath, codexClient, error_1, codexClient;
|
|
1208
|
+
var codexClient, workerPath, codexClient, error_1, codexClient;
|
|
1193
1209
|
return __generator(this, function (_a) {
|
|
1194
1210
|
switch (_a.label) {
|
|
1195
|
-
case 0:
|
|
1196
|
-
|
|
1197
|
-
workerPath = _a.sent();
|
|
1198
|
-
if (!!workerPath) return [3 /*break*/, 3];
|
|
1211
|
+
case 0:
|
|
1212
|
+
if (!!resolveCodexWorkerThreadEnabled()) return [3 /*break*/, 2];
|
|
1199
1213
|
codexClient = getAssistantCodexClient();
|
|
1200
1214
|
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1201
|
-
case
|
|
1215
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1216
|
+
case 2: return [4 /*yield*/, resolveCodexWorkerPath()];
|
|
1202
1217
|
case 3:
|
|
1203
|
-
_a.
|
|
1204
|
-
return [
|
|
1218
|
+
workerPath = _a.sent();
|
|
1219
|
+
if (!!workerPath) return [3 /*break*/, 5];
|
|
1220
|
+
codexClient = getAssistantCodexClient();
|
|
1221
|
+
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1205
1222
|
case 4: return [2 /*return*/, _a.sent()];
|
|
1206
1223
|
case 5:
|
|
1224
|
+
_a.trys.push([5, 7, , 9]);
|
|
1225
|
+
return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)];
|
|
1226
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
1227
|
+
case 7:
|
|
1207
1228
|
error_1 = _a.sent();
|
|
1208
1229
|
if (!(error_1 instanceof CodexWorkerBootstrapError)) {
|
|
1209
1230
|
throw error_1;
|
|
@@ -1211,8 +1232,8 @@ function runCodexInWorkerThread(prompt, runOptions, config) {
|
|
|
1211
1232
|
console.error('Codex worker bootstrap failed, falling back to in-process run.', error_1);
|
|
1212
1233
|
codexClient = getAssistantCodexClient();
|
|
1213
1234
|
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1214
|
-
case
|
|
1215
|
-
case
|
|
1235
|
+
case 8: return [2 /*return*/, _a.sent()];
|
|
1236
|
+
case 9: return [2 /*return*/];
|
|
1216
1237
|
}
|
|
1217
1238
|
});
|
|
1218
1239
|
});
|
|
@@ -2084,6 +2105,22 @@ function normalizeOptionalNumber(value) {
|
|
|
2084
2105
|
var parsed = Number(value);
|
|
2085
2106
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
2086
2107
|
}
|
|
2108
|
+
function normalizeOptionalBoolean(value) {
|
|
2109
|
+
if (typeof value === 'boolean') {
|
|
2110
|
+
return value;
|
|
2111
|
+
}
|
|
2112
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
2113
|
+
if (!normalized) {
|
|
2114
|
+
return undefined;
|
|
2115
|
+
}
|
|
2116
|
+
if (['true', '1', 'yes', 'y', 'on'].includes(normalized)) {
|
|
2117
|
+
return true;
|
|
2118
|
+
}
|
|
2119
|
+
if (['false', '0', 'no', 'n', 'off'].includes(normalized)) {
|
|
2120
|
+
return false;
|
|
2121
|
+
}
|
|
2122
|
+
return undefined;
|
|
2123
|
+
}
|
|
2087
2124
|
function normalizeHistoryLimit(value) {
|
|
2088
2125
|
var parsed = Number(value);
|
|
2089
2126
|
if (!Number.isFinite(parsed)) {
|