@resolveio/server-lib 20.14.26 → 20.14.27
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
|
@@ -419,6 +419,7 @@ function loadAiTerminalMethods(methodManager) {
|
|
|
419
419
|
}),
|
|
420
420
|
forceWorker: true,
|
|
421
421
|
maxConcurrencyPerInstance: 1,
|
|
422
|
+
timeoutOverride: resolveCodexTimeoutMs() + 15000,
|
|
422
423
|
function: function (payload) {
|
|
423
424
|
return __awaiter(this, void 0, void 0, function () {
|
|
424
425
|
return __generator(this, function (_a) {
|
|
@@ -1148,6 +1149,18 @@ function resolveCodexTimeoutMs() {
|
|
|
1148
1149
|
}
|
|
1149
1150
|
return DEFAULT_CODEX_TIMEOUT_MS;
|
|
1150
1151
|
}
|
|
1152
|
+
function resolveCodexWorkerThreadEnabled() {
|
|
1153
|
+
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1154
|
+
var raw = normalizeOptionalString(config['AI_ASSISTANT_CODEX_USE_WORKER_THREAD']
|
|
1155
|
+
|| process.env.AI_ASSISTANT_CODEX_USE_WORKER_THREAD
|
|
1156
|
+
|| config['AI_ASSISTANT_CODEX_WORKER_THREAD']
|
|
1157
|
+
|| process.env.AI_ASSISTANT_CODEX_WORKER_THREAD);
|
|
1158
|
+
var normalized = normalizeOptionalBoolean(raw);
|
|
1159
|
+
if (typeof normalized === 'boolean') {
|
|
1160
|
+
return normalized;
|
|
1161
|
+
}
|
|
1162
|
+
return process.env.IS_WORKER_INSTANCE !== 'true';
|
|
1163
|
+
}
|
|
1151
1164
|
function resolveCodexModel() {
|
|
1152
1165
|
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1153
1166
|
var raw = normalizeOptionalString(config['AI_ASSISTANT_CODEX_MODEL']
|
|
@@ -1189,21 +1202,26 @@ var CodexWorkerBootstrapError = /** @class */ (function (_super) {
|
|
|
1189
1202
|
}(Error));
|
|
1190
1203
|
function runCodexInWorkerThread(prompt, runOptions, config) {
|
|
1191
1204
|
return __awaiter(this, void 0, void 0, function () {
|
|
1192
|
-
var workerPath, codexClient, error_1, codexClient;
|
|
1205
|
+
var codexClient, workerPath, codexClient, error_1, codexClient;
|
|
1193
1206
|
return __generator(this, function (_a) {
|
|
1194
1207
|
switch (_a.label) {
|
|
1195
|
-
case 0:
|
|
1196
|
-
|
|
1197
|
-
workerPath = _a.sent();
|
|
1198
|
-
if (!!workerPath) return [3 /*break*/, 3];
|
|
1208
|
+
case 0:
|
|
1209
|
+
if (!!resolveCodexWorkerThreadEnabled()) return [3 /*break*/, 2];
|
|
1199
1210
|
codexClient = getAssistantCodexClient();
|
|
1200
1211
|
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1201
|
-
case
|
|
1212
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1213
|
+
case 2: return [4 /*yield*/, resolveCodexWorkerPath()];
|
|
1202
1214
|
case 3:
|
|
1203
|
-
_a.
|
|
1204
|
-
return [
|
|
1215
|
+
workerPath = _a.sent();
|
|
1216
|
+
if (!!workerPath) return [3 /*break*/, 5];
|
|
1217
|
+
codexClient = getAssistantCodexClient();
|
|
1218
|
+
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1205
1219
|
case 4: return [2 /*return*/, _a.sent()];
|
|
1206
1220
|
case 5:
|
|
1221
|
+
_a.trys.push([5, 7, , 9]);
|
|
1222
|
+
return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)];
|
|
1223
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
1224
|
+
case 7:
|
|
1207
1225
|
error_1 = _a.sent();
|
|
1208
1226
|
if (!(error_1 instanceof CodexWorkerBootstrapError)) {
|
|
1209
1227
|
throw error_1;
|
|
@@ -1211,8 +1229,8 @@ function runCodexInWorkerThread(prompt, runOptions, config) {
|
|
|
1211
1229
|
console.error('Codex worker bootstrap failed, falling back to in-process run.', error_1);
|
|
1212
1230
|
codexClient = getAssistantCodexClient();
|
|
1213
1231
|
return [4 /*yield*/, codexClient.run(prompt, runOptions)];
|
|
1214
|
-
case
|
|
1215
|
-
case
|
|
1232
|
+
case 8: return [2 /*return*/, _a.sent()];
|
|
1233
|
+
case 9: return [2 /*return*/];
|
|
1216
1234
|
}
|
|
1217
1235
|
});
|
|
1218
1236
|
});
|
|
@@ -2084,6 +2102,22 @@ function normalizeOptionalNumber(value) {
|
|
|
2084
2102
|
var parsed = Number(value);
|
|
2085
2103
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
2086
2104
|
}
|
|
2105
|
+
function normalizeOptionalBoolean(value) {
|
|
2106
|
+
if (typeof value === 'boolean') {
|
|
2107
|
+
return value;
|
|
2108
|
+
}
|
|
2109
|
+
var normalized = normalizeOptionalString(value).toLowerCase();
|
|
2110
|
+
if (!normalized) {
|
|
2111
|
+
return undefined;
|
|
2112
|
+
}
|
|
2113
|
+
if (['true', '1', 'yes', 'y', 'on'].includes(normalized)) {
|
|
2114
|
+
return true;
|
|
2115
|
+
}
|
|
2116
|
+
if (['false', '0', 'no', 'n', 'off'].includes(normalized)) {
|
|
2117
|
+
return false;
|
|
2118
|
+
}
|
|
2119
|
+
return undefined;
|
|
2120
|
+
}
|
|
2087
2121
|
function normalizeHistoryLimit(value) {
|
|
2088
2122
|
var parsed = Number(value);
|
|
2089
2123
|
if (!Number.isFinite(parsed)) {
|