@resolveio/server-lib 22.2.19 → 22.2.21
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/managers/error-auto-fix.manager.d.ts +5 -0
- package/managers/error-auto-fix.manager.js +145 -70
- package/managers/error-auto-fix.manager.js.map +1 -1
- package/managers/slow-query-verifier.manager.d.ts +8 -0
- package/managers/slow-query-verifier.manager.js +311 -194
- package/managers/slow-query-verifier.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +1 -0
- package/managers/subscription.manager.js +80 -34
- package/managers/subscription.manager.js.map +1 -1
- package/managers/worker-dispatcher.manager.js +60 -6
- package/managers/worker-dispatcher.manager.js.map +1 -1
- package/methods/app-settings.js +2 -2
- package/methods/app-settings.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +22 -36
- package/server-app.js.map +1 -1
|
@@ -67,6 +67,9 @@ export declare class ErrorAutoFixManager {
|
|
|
67
67
|
private _serverConfig;
|
|
68
68
|
private readonly githubApiBase;
|
|
69
69
|
private readonly dashboardMonitors;
|
|
70
|
+
private static readonly APP_SETTINGS_CACHE_TTL_MS;
|
|
71
|
+
private appSettingsAutoOptimizeCacheExpiresAt;
|
|
72
|
+
private appSettingsAutoOptimizeCacheValue;
|
|
70
73
|
private ready;
|
|
71
74
|
constructor(serverConfig: any, dependencies?: Partial<ErrorAutoFixManagerDependencies>);
|
|
72
75
|
isReady(): boolean;
|
|
@@ -102,6 +105,8 @@ export declare class ErrorAutoFixManager {
|
|
|
102
105
|
private findOpenPullRequest;
|
|
103
106
|
private createPullRequest;
|
|
104
107
|
private commentOnPullRequest;
|
|
108
|
+
private parseBooleanEnv;
|
|
109
|
+
private resolveAutoOptimizeEnabled;
|
|
105
110
|
private reserveLog;
|
|
106
111
|
private markDuplicate;
|
|
107
112
|
private updateLog;
|
|
@@ -93,6 +93,7 @@ var axios_1 = require("axios");
|
|
|
93
93
|
var crypto_1 = require("crypto");
|
|
94
94
|
var url_1 = require("url");
|
|
95
95
|
var user_collection_1 = require("../collections/user.collection");
|
|
96
|
+
var app_setting_collection_1 = require("../collections/app-setting.collection");
|
|
96
97
|
var customer_notification_content_manager_1 = require("./customer-notification-content.manager");
|
|
97
98
|
var OPTIONAL_COLLECTION = {
|
|
98
99
|
findOne: function () { return Promise.resolve(null); },
|
|
@@ -176,6 +177,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
176
177
|
this._serverConfig = null;
|
|
177
178
|
this.githubApiBase = 'https://api.github.com';
|
|
178
179
|
this.dashboardMonitors = new Map();
|
|
180
|
+
this.appSettingsAutoOptimizeCacheExpiresAt = 0;
|
|
181
|
+
this.appSettingsAutoOptimizeCacheValue = null;
|
|
179
182
|
this.ready = false;
|
|
180
183
|
var resolvedDependencies = resolveErrorAutoFixManagerDependencies(dependencies);
|
|
181
184
|
applyErrorAutoFixDependencies(resolvedDependencies);
|
|
@@ -188,8 +191,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
188
191
|
return;
|
|
189
192
|
}
|
|
190
193
|
if (!this.config.dashboardWorkflowEnabled && (!this.config.repoRoot || !this.config.githubOwner || !this.config.githubRepo)) {
|
|
191
|
-
console.warn('ErrorAutoFixManager
|
|
192
|
-
return;
|
|
194
|
+
console.warn('ErrorAutoFixManager auto-optimize unavailable - missing repository configuration. Ingest and manual runs remain available.');
|
|
193
195
|
}
|
|
194
196
|
this.ready = true;
|
|
195
197
|
// console.log('ErrorAutoFixManager initialized (HTTP intake mode).');
|
|
@@ -197,7 +199,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
197
199
|
// if (this.config.debugLogging) {
|
|
198
200
|
// console.log('ErrorAutoFixManager debug logging enabled.');
|
|
199
201
|
// }
|
|
200
|
-
// if (!this.config.
|
|
202
|
+
// if (!this.config.autoOptimizeEnabled) {
|
|
201
203
|
// console.log('ErrorAutoFixManager auto-run disabled. Manual OpenAI runs required.');
|
|
202
204
|
// }
|
|
203
205
|
}
|
|
@@ -296,8 +298,10 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
296
298
|
var ingestSource = typeof process.env.AUTOFIX_INGEST_KEYS !== 'undefined'
|
|
297
299
|
? process.env.AUTOFIX_INGEST_KEYS
|
|
298
300
|
: scAutofix.ingestKeys;
|
|
301
|
+
var hasAutoOptimizeEnv = typeof process.env.AUTOFIX_AUTO_OPTIMIZE_ENABLED !== 'undefined';
|
|
302
|
+
var autoOptimizeEnabled = getBoolean('AUTOFIX_AUTO_OPTIMIZE_ENABLED', 'autoOptimizeEnabled', false);
|
|
299
303
|
return {
|
|
300
|
-
enabled:
|
|
304
|
+
enabled: true,
|
|
301
305
|
repoRoot: getString('AUTOFIX_REPO_ROOT', 'repoRoot', ''),
|
|
302
306
|
baseBranch: getString('AUTOFIX_BASE_BRANCH', 'baseBranch', 'main'),
|
|
303
307
|
branchPrefix: getString('AUTOFIX_BRANCH_PREFIX', 'branchPrefix', 'openai/auto'),
|
|
@@ -307,10 +311,10 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
307
311
|
commandTimeoutMs: getNumber('AUTOFIX_COMMAND_TIMEOUT_MS', 'commandTimeoutMs', 600000),
|
|
308
312
|
notifyEmails: notifyEmails,
|
|
309
313
|
debugLogging: getBoolean('AUTOFIX_DEBUG_LOGS', 'debugLogging', false),
|
|
310
|
-
configSource:
|
|
314
|
+
configSource: hasAutoOptimizeEnv ? 'environment' : (Object.keys(scAutofix).length ? 'serverConfig' : 'defaults'),
|
|
311
315
|
openaiEnvironment: openaiEnvironment,
|
|
312
316
|
openaiProjectId: openaiProjectId,
|
|
313
|
-
|
|
317
|
+
autoOptimizeEnabled: autoOptimizeEnabled,
|
|
314
318
|
ingestKeys: parseKeyList(ingestSource),
|
|
315
319
|
dashboardWorkflowEnabled: getBoolean('AUTOFIX_DASHBOARD_WORKFLOW_ENABLED', 'dashboardWorkflowEnabled', true),
|
|
316
320
|
dashboardFallbackToGithub: getBoolean('AUTOFIX_DASHBOARD_FALLBACK_TO_GITHUB', 'dashboardFallbackToGithub', true),
|
|
@@ -926,9 +930,76 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
926
930
|
});
|
|
927
931
|
});
|
|
928
932
|
};
|
|
929
|
-
ErrorAutoFixManager.prototype.
|
|
933
|
+
ErrorAutoFixManager.prototype.parseBooleanEnv = function (envKey) {
|
|
934
|
+
if (typeof process.env[envKey] === 'undefined') {
|
|
935
|
+
return null;
|
|
936
|
+
}
|
|
937
|
+
return process.env[envKey] === 'true';
|
|
938
|
+
};
|
|
939
|
+
ErrorAutoFixManager.prototype.resolveAutoOptimizeEnabled = function () {
|
|
930
940
|
return __awaiter(this, void 0, void 0, function () {
|
|
941
|
+
var now, envValue, enabled, activeSetting, _a, error_1;
|
|
942
|
+
var _b;
|
|
943
|
+
return __generator(this, function (_c) {
|
|
944
|
+
switch (_c.label) {
|
|
945
|
+
case 0:
|
|
946
|
+
now = Date.now();
|
|
947
|
+
if (this.appSettingsAutoOptimizeCacheValue !== null && now < this.appSettingsAutoOptimizeCacheExpiresAt) {
|
|
948
|
+
return [2 /*return*/, this.appSettingsAutoOptimizeCacheValue];
|
|
949
|
+
}
|
|
950
|
+
envValue = this.parseBooleanEnv('AUTOFIX_AUTO_OPTIMIZE_ENABLED');
|
|
951
|
+
enabled = envValue !== null ? envValue : !!this.config.autoOptimizeEnabled;
|
|
952
|
+
_c.label = 1;
|
|
953
|
+
case 1:
|
|
954
|
+
_c.trys.push([1, 6, , 7]);
|
|
955
|
+
if (!(app_setting_collection_1.AppSettings && typeof app_setting_collection_1.AppSettings.findOne === 'function')) return [3 /*break*/, 5];
|
|
956
|
+
return [4 /*yield*/, app_setting_collection_1.AppSettings.findOne({
|
|
957
|
+
is_active: {
|
|
958
|
+
$ne: false
|
|
959
|
+
}
|
|
960
|
+
}, {
|
|
961
|
+
sort: {
|
|
962
|
+
updatedAt: -1,
|
|
963
|
+
createdAt: -1
|
|
964
|
+
}
|
|
965
|
+
})];
|
|
966
|
+
case 2:
|
|
967
|
+
_a = (_c.sent());
|
|
968
|
+
if (_a) return [3 /*break*/, 4];
|
|
969
|
+
return [4 /*yield*/, app_setting_collection_1.AppSettings.findOne({}, {
|
|
970
|
+
sort: {
|
|
971
|
+
updatedAt: -1,
|
|
972
|
+
createdAt: -1
|
|
973
|
+
}
|
|
974
|
+
})];
|
|
975
|
+
case 3:
|
|
976
|
+
_a = (_c.sent());
|
|
977
|
+
_c.label = 4;
|
|
978
|
+
case 4:
|
|
979
|
+
activeSetting = _a;
|
|
980
|
+
if (activeSetting && typeof activeSetting.enable_auto_fix === 'boolean') {
|
|
981
|
+
enabled = !!activeSetting.enable_auto_fix;
|
|
982
|
+
}
|
|
983
|
+
_c.label = 5;
|
|
984
|
+
case 5: return [3 /*break*/, 7];
|
|
985
|
+
case 6:
|
|
986
|
+
error_1 = _c.sent();
|
|
987
|
+
if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debugLogging) {
|
|
988
|
+
console.warn('ErrorAutoFixManager failed to read app settings auto-fix toggle', error_1);
|
|
989
|
+
}
|
|
990
|
+
return [3 /*break*/, 7];
|
|
991
|
+
case 7:
|
|
992
|
+
this.appSettingsAutoOptimizeCacheValue = enabled;
|
|
993
|
+
this.appSettingsAutoOptimizeCacheExpiresAt = now + ErrorAutoFixManager.APP_SETTINGS_CACHE_TTL_MS;
|
|
994
|
+
return [2 /*return*/, enabled];
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
ErrorAutoFixManager.prototype.reserveLog = function (email_1, client_1) {
|
|
1000
|
+
return __awaiter(this, arguments, void 0, function (email, client, autoOptimizeEnabled) {
|
|
931
1001
|
var hash, rawHash, now, existing, updatedExisting, metaUpdate, reactivated, attemptsUsed, maxAttempts, reason, exhausted, resumed, counterValue, counterString, doc;
|
|
1002
|
+
if (autoOptimizeEnabled === void 0) { autoOptimizeEnabled = false; }
|
|
932
1003
|
return __generator(this, function (_a) {
|
|
933
1004
|
switch (_a.label) {
|
|
934
1005
|
case 0:
|
|
@@ -1037,7 +1108,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1037
1108
|
reason: 'ignored'
|
|
1038
1109
|
}];
|
|
1039
1110
|
}
|
|
1040
|
-
if (!(
|
|
1111
|
+
if (!(autoOptimizeEnabled && (updatedExisting.status === 'failed' || updatedExisting.status === 'skipped') && !updatedExisting.ignored)) return [3 /*break*/, 17];
|
|
1041
1112
|
attemptsUsed = Number.isFinite(Number(updatedExisting.attempt_count))
|
|
1042
1113
|
? Number(updatedExisting.attempt_count)
|
|
1043
1114
|
: 0;
|
|
@@ -1119,14 +1190,14 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1119
1190
|
subject: email.subject,
|
|
1120
1191
|
message_id: email.messageId,
|
|
1121
1192
|
body: email.body,
|
|
1122
|
-
status:
|
|
1193
|
+
status: autoOptimizeEnabled ? 'in_progress' : 'pending',
|
|
1123
1194
|
ignored: false,
|
|
1124
|
-
attempt_count:
|
|
1195
|
+
attempt_count: autoOptimizeEnabled ? 1 : 0,
|
|
1125
1196
|
duplicate_count: 0,
|
|
1126
1197
|
autofix_error_count: counterValue,
|
|
1127
1198
|
autofix_error_count_string: counterString,
|
|
1128
1199
|
first_seen_at: now,
|
|
1129
|
-
last_attempt_at:
|
|
1200
|
+
last_attempt_at: autoOptimizeEnabled ? now : undefined,
|
|
1130
1201
|
from_email: email.fromAddress || '',
|
|
1131
1202
|
id_client: client === null || client === void 0 ? void 0 : client._id,
|
|
1132
1203
|
client_name: client === null || client === void 0 ? void 0 : client.name,
|
|
@@ -1220,7 +1291,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1220
1291
|
};
|
|
1221
1292
|
ErrorAutoFixManager.prototype.sendEscalationNotice = function (log, reason) {
|
|
1222
1293
|
return __awaiter(this, void 0, void 0, function () {
|
|
1223
|
-
var recipients, identifier, subject, body, methodManager, recipients_1, recipients_1_1, recipient,
|
|
1294
|
+
var recipients, identifier, subject, body, methodManager, recipients_1, recipients_1_1, recipient, error_2, e_1_1;
|
|
1224
1295
|
var e_1, _a;
|
|
1225
1296
|
return __generator(this, function (_b) {
|
|
1226
1297
|
switch (_b.label) {
|
|
@@ -1262,8 +1333,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1262
1333
|
_b.sent();
|
|
1263
1334
|
return [3 /*break*/, 6];
|
|
1264
1335
|
case 5:
|
|
1265
|
-
|
|
1266
|
-
console.error('Failed sending auto-fix escalation email', { recipient: recipient, logId: log._id, error:
|
|
1336
|
+
error_2 = _b.sent();
|
|
1337
|
+
console.error('Failed sending auto-fix escalation email', { recipient: recipient, logId: log._id, error: error_2 });
|
|
1267
1338
|
return [3 /*break*/, 6];
|
|
1268
1339
|
case 6:
|
|
1269
1340
|
recipients_1_1 = recipients_1.next();
|
|
@@ -1362,7 +1433,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1362
1433
|
};
|
|
1363
1434
|
ErrorAutoFixManager.prototype.sendLibraryIssueNotice = function (log, reason, evidence) {
|
|
1364
1435
|
return __awaiter(this, void 0, void 0, function () {
|
|
1365
|
-
var recipients, identifier, subject, body, methodManager, recipients_2, recipients_2_1, recipient,
|
|
1436
|
+
var recipients, identifier, subject, body, methodManager, recipients_2, recipients_2_1, recipient, error_3, e_3_1;
|
|
1366
1437
|
var e_3, _a;
|
|
1367
1438
|
return __generator(this, function (_b) {
|
|
1368
1439
|
switch (_b.label) {
|
|
@@ -1404,8 +1475,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1404
1475
|
_b.sent();
|
|
1405
1476
|
return [3 /*break*/, 6];
|
|
1406
1477
|
case 5:
|
|
1407
|
-
|
|
1408
|
-
console.error('Failed sending library-issue auto-fix email', { recipient: recipient, logId: log._id, error:
|
|
1478
|
+
error_3 = _b.sent();
|
|
1479
|
+
console.error('Failed sending library-issue auto-fix email', { recipient: recipient, logId: log._id, error: error_3 });
|
|
1409
1480
|
return [3 /*break*/, 6];
|
|
1410
1481
|
case 6:
|
|
1411
1482
|
recipients_2_1 = recipients_2.next();
|
|
@@ -1626,7 +1697,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1626
1697
|
};
|
|
1627
1698
|
ErrorAutoFixManager.prototype.notifyCustomerWorkflowStatus = function (stage, email, log, extra) {
|
|
1628
1699
|
return __awaiter(this, void 0, void 0, function () {
|
|
1629
|
-
var idClient, isGeneratedApp, resolvedEnvironment, app, issueKey, clientName, targetPayload, idUsers, basePayload, payload,
|
|
1700
|
+
var idClient, isGeneratedApp, resolvedEnvironment, app, issueKey, clientName, targetPayload, idUsers, basePayload, payload, error_4;
|
|
1630
1701
|
return __generator(this, function (_a) {
|
|
1631
1702
|
switch (_a.label) {
|
|
1632
1703
|
case 0:
|
|
@@ -1735,11 +1806,11 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1735
1806
|
_a.sent();
|
|
1736
1807
|
return [3 /*break*/, 11];
|
|
1737
1808
|
case 10:
|
|
1738
|
-
|
|
1809
|
+
error_4 = _a.sent();
|
|
1739
1810
|
this.debugLog('Failed to create customer auto-fix notification', {
|
|
1740
1811
|
logId: log === null || log === void 0 ? void 0 : log._id,
|
|
1741
1812
|
stage: stage,
|
|
1742
|
-
error: (
|
|
1813
|
+
error: (error_4 === null || error_4 === void 0 ? void 0 : error_4.message) || error_4
|
|
1743
1814
|
});
|
|
1744
1815
|
return [3 /*break*/, 11];
|
|
1745
1816
|
case 11: return [2 /*return*/];
|
|
@@ -1810,7 +1881,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1810
1881
|
};
|
|
1811
1882
|
ErrorAutoFixManager.prototype.ingestErrorReport = function (report) {
|
|
1812
1883
|
return __awaiter(this, void 0, void 0, function () {
|
|
1813
|
-
var normalizedReport, email, rawHash, fingerprint, client, reservation, classification, updated, queued, result, finalLog, _a;
|
|
1884
|
+
var normalizedReport, email, rawHash, fingerprint, client, autoOptimizeEnabled, reservation, classification, updated, queued, result, finalLog, _a;
|
|
1814
1885
|
return __generator(this, function (_b) {
|
|
1815
1886
|
switch (_b.label) {
|
|
1816
1887
|
case 0:
|
|
@@ -1842,11 +1913,14 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1842
1913
|
return [4 /*yield*/, this.resolveClientForReport(normalizedReport)];
|
|
1843
1914
|
case 1:
|
|
1844
1915
|
client = _b.sent();
|
|
1845
|
-
return [4 /*yield*/, this.
|
|
1916
|
+
return [4 /*yield*/, this.resolveAutoOptimizeEnabled()];
|
|
1846
1917
|
case 2:
|
|
1918
|
+
autoOptimizeEnabled = _b.sent();
|
|
1919
|
+
return [4 /*yield*/, this.reserveLog(email, client, autoOptimizeEnabled)];
|
|
1920
|
+
case 3:
|
|
1847
1921
|
reservation = _b.sent();
|
|
1848
|
-
if (!!reservation.proceed) return [3 /*break*/,
|
|
1849
|
-
if (!(reservation.reason && this.shouldNotifySkip(reservation.reason))) return [3 /*break*/,
|
|
1922
|
+
if (!!reservation.proceed) return [3 /*break*/, 6];
|
|
1923
|
+
if (!(reservation.reason && this.shouldNotifySkip(reservation.reason))) return [3 /*break*/, 5];
|
|
1850
1924
|
return [4 /*yield*/, this.notify({
|
|
1851
1925
|
status: 'skipped',
|
|
1852
1926
|
email: email,
|
|
@@ -1854,15 +1928,15 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1854
1928
|
error: "Skipped auto-fix (".concat(reservation.reason, ")."),
|
|
1855
1929
|
log: reservation.log
|
|
1856
1930
|
})];
|
|
1857
|
-
case
|
|
1931
|
+
case 4:
|
|
1858
1932
|
_b.sent();
|
|
1859
|
-
_b.label =
|
|
1860
|
-
case
|
|
1933
|
+
_b.label = 5;
|
|
1934
|
+
case 5: return [2 /*return*/, {
|
|
1861
1935
|
status: reservation.reason === 'duplicate' ? 'duplicate' : reservation.reason || 'skipped',
|
|
1862
1936
|
reason: reservation.reason,
|
|
1863
1937
|
log: reservation.log
|
|
1864
1938
|
}];
|
|
1865
|
-
case
|
|
1939
|
+
case 6:
|
|
1866
1940
|
email.logId = reservation.log._id;
|
|
1867
1941
|
classification = this.classifyEmail(email);
|
|
1868
1942
|
return [4 /*yield*/, this.updateLog(email.logId, {
|
|
@@ -1881,18 +1955,18 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1881
1955
|
attachments: email.attachments,
|
|
1882
1956
|
last_reported_at: email.reportedAt || new Date()
|
|
1883
1957
|
})];
|
|
1884
|
-
case
|
|
1958
|
+
case 7:
|
|
1885
1959
|
_b.sent();
|
|
1886
|
-
if (!classification.skip) return [3 /*break*/,
|
|
1960
|
+
if (!classification.skip) return [3 /*break*/, 11];
|
|
1887
1961
|
return [4 /*yield*/, this.updateLog(email.logId, {
|
|
1888
1962
|
status: 'skipped',
|
|
1889
1963
|
ignored: !!classification.markIgnored,
|
|
1890
1964
|
last_error: classification.reason || 'Ignored non-app alert',
|
|
1891
1965
|
last_result_at: new Date()
|
|
1892
1966
|
})];
|
|
1893
|
-
case
|
|
1967
|
+
case 8:
|
|
1894
1968
|
updated = _b.sent();
|
|
1895
|
-
if (!classification.notify) return [3 /*break*/,
|
|
1969
|
+
if (!classification.notify) return [3 /*break*/, 10];
|
|
1896
1970
|
return [4 /*yield*/, this.notify({
|
|
1897
1971
|
status: 'skipped',
|
|
1898
1972
|
email: email,
|
|
@@ -1900,44 +1974,44 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
1900
1974
|
log: updated,
|
|
1901
1975
|
reason: 'classified'
|
|
1902
1976
|
})];
|
|
1903
|
-
case
|
|
1977
|
+
case 9:
|
|
1904
1978
|
_b.sent();
|
|
1905
|
-
_b.label =
|
|
1906
|
-
case
|
|
1979
|
+
_b.label = 10;
|
|
1980
|
+
case 10: return [2 /*return*/, {
|
|
1907
1981
|
status: 'skipped',
|
|
1908
1982
|
reason: classification.reason,
|
|
1909
1983
|
log: updated
|
|
1910
1984
|
}];
|
|
1911
|
-
case
|
|
1912
|
-
if (!!
|
|
1985
|
+
case 11:
|
|
1986
|
+
if (!!autoOptimizeEnabled) return [3 /*break*/, 14];
|
|
1913
1987
|
return [4 /*yield*/, this.updateLog(email.logId, {
|
|
1914
1988
|
status: 'pending'
|
|
1915
1989
|
})];
|
|
1916
|
-
case
|
|
1990
|
+
case 12:
|
|
1917
1991
|
queued = _b.sent();
|
|
1918
1992
|
return [4 /*yield*/, this.notifyCustomerWorkflowStatus('detected_autofix_disabled', email, queued || reservation.log)];
|
|
1919
|
-
case
|
|
1993
|
+
case 13:
|
|
1920
1994
|
_b.sent();
|
|
1921
1995
|
return [2 /*return*/, {
|
|
1922
1996
|
status: 'queued',
|
|
1923
1997
|
log: queued
|
|
1924
1998
|
}];
|
|
1925
|
-
case
|
|
1926
|
-
case
|
|
1999
|
+
case 14: return [4 /*yield*/, this.notifyCustomerWorkflowStatus('detected_autofix_enabled', email, reservation.log)];
|
|
2000
|
+
case 15:
|
|
1927
2001
|
_b.sent();
|
|
1928
2002
|
return [4 /*yield*/, this.processEmail(email, reservation.log)];
|
|
1929
|
-
case
|
|
2003
|
+
case 16:
|
|
1930
2004
|
result = _b.sent();
|
|
1931
2005
|
return [4 /*yield*/, this.notify(result)];
|
|
1932
|
-
case
|
|
2006
|
+
case 17:
|
|
1933
2007
|
_b.sent();
|
|
1934
2008
|
_a = result.log;
|
|
1935
|
-
if (_a) return [3 /*break*/,
|
|
2009
|
+
if (_a) return [3 /*break*/, 19];
|
|
1936
2010
|
return [4 /*yield*/, ErrorAutoFixLogs.findOne({ _id: email.logId })];
|
|
1937
|
-
case 17:
|
|
1938
|
-
_a = (_b.sent());
|
|
1939
|
-
_b.label = 18;
|
|
1940
2011
|
case 18:
|
|
2012
|
+
_a = (_b.sent());
|
|
2013
|
+
_b.label = 19;
|
|
2014
|
+
case 19:
|
|
1941
2015
|
finalLog = _a;
|
|
1942
2016
|
return [2 /*return*/, {
|
|
1943
2017
|
status: result.status,
|
|
@@ -2085,7 +2159,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2085
2159
|
};
|
|
2086
2160
|
ErrorAutoFixManager.prototype.createDashboardJob = function (payload) {
|
|
2087
2161
|
return __awaiter(this, void 0, void 0, function () {
|
|
2088
|
-
var methodManager,
|
|
2162
|
+
var methodManager, error_5, manager;
|
|
2089
2163
|
return __generator(this, function (_a) {
|
|
2090
2164
|
switch (_a.label) {
|
|
2091
2165
|
case 0:
|
|
@@ -2096,9 +2170,9 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2096
2170
|
return [4 /*yield*/, methodManager.callMethod('aiDashboardCreateJob', payload)];
|
|
2097
2171
|
case 2: return [2 /*return*/, _a.sent()];
|
|
2098
2172
|
case 3:
|
|
2099
|
-
|
|
2100
|
-
if (!this.shouldFallbackDashboardMethod(
|
|
2101
|
-
throw
|
|
2173
|
+
error_5 = _a.sent();
|
|
2174
|
+
if (!this.shouldFallbackDashboardMethod(error_5)) {
|
|
2175
|
+
throw error_5;
|
|
2102
2176
|
}
|
|
2103
2177
|
return [3 /*break*/, 4];
|
|
2104
2178
|
case 4:
|
|
@@ -2113,7 +2187,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2113
2187
|
};
|
|
2114
2188
|
ErrorAutoFixManager.prototype.waitForDashboardJobStop = function (jobId, timeoutMs) {
|
|
2115
2189
|
return __awaiter(this, void 0, void 0, function () {
|
|
2116
|
-
var methodManager,
|
|
2190
|
+
var methodManager, error_6, manager;
|
|
2117
2191
|
return __generator(this, function (_a) {
|
|
2118
2192
|
switch (_a.label) {
|
|
2119
2193
|
case 0:
|
|
@@ -2126,9 +2200,9 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2126
2200
|
_a.sent();
|
|
2127
2201
|
return [2 /*return*/];
|
|
2128
2202
|
case 3:
|
|
2129
|
-
|
|
2130
|
-
if (!this.shouldFallbackDashboardMethod(
|
|
2131
|
-
throw
|
|
2203
|
+
error_6 = _a.sent();
|
|
2204
|
+
if (!this.shouldFallbackDashboardMethod(error_6)) {
|
|
2205
|
+
throw error_6;
|
|
2132
2206
|
}
|
|
2133
2207
|
return [3 /*break*/, 4];
|
|
2134
2208
|
case 4:
|
|
@@ -2145,7 +2219,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2145
2219
|
};
|
|
2146
2220
|
ErrorAutoFixManager.prototype.isDashboardJobRunning = function (jobId) {
|
|
2147
2221
|
return __awaiter(this, void 0, void 0, function () {
|
|
2148
|
-
var methodManager, running,
|
|
2222
|
+
var methodManager, running, error_7, manager;
|
|
2149
2223
|
return __generator(this, function (_a) {
|
|
2150
2224
|
switch (_a.label) {
|
|
2151
2225
|
case 0:
|
|
@@ -2158,9 +2232,9 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2158
2232
|
running = _a.sent();
|
|
2159
2233
|
return [2 /*return*/, !!running];
|
|
2160
2234
|
case 3:
|
|
2161
|
-
|
|
2162
|
-
if (!this.shouldFallbackDashboardMethod(
|
|
2163
|
-
throw
|
|
2235
|
+
error_7 = _a.sent();
|
|
2236
|
+
if (!this.shouldFallbackDashboardMethod(error_7)) {
|
|
2237
|
+
throw error_7;
|
|
2164
2238
|
}
|
|
2165
2239
|
return [3 /*break*/, 4];
|
|
2166
2240
|
case 4:
|
|
@@ -2421,7 +2495,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2421
2495
|
return;
|
|
2422
2496
|
}
|
|
2423
2497
|
var monitor = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2424
|
-
var
|
|
2498
|
+
var error_8;
|
|
2425
2499
|
return __generator(this, function (_a) {
|
|
2426
2500
|
switch (_a.label) {
|
|
2427
2501
|
case 0:
|
|
@@ -2431,8 +2505,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2431
2505
|
_a.sent();
|
|
2432
2506
|
return [3 /*break*/, 4];
|
|
2433
2507
|
case 2:
|
|
2434
|
-
|
|
2435
|
-
console.error('Auto-fix dashboard monitor failed', { logId: logId, jobId: normalizedJobId, error:
|
|
2508
|
+
error_8 = _a.sent();
|
|
2509
|
+
console.error('Auto-fix dashboard monitor failed', { logId: logId, jobId: normalizedJobId, error: error_8 });
|
|
2436
2510
|
return [3 /*break*/, 4];
|
|
2437
2511
|
case 3:
|
|
2438
2512
|
this.dashboardMonitors.delete(logId);
|
|
@@ -2445,7 +2519,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2445
2519
|
};
|
|
2446
2520
|
ErrorAutoFixManager.prototype.monitorDashboardAutoFixJob = function (log, email, jobId, effectiveEnvironment) {
|
|
2447
2521
|
return __awaiter(this, void 0, void 0, function () {
|
|
2448
|
-
var logId, fail,
|
|
2522
|
+
var logId, fail, error_9, message, isRunning, error_10, message, job, publishOutcome, fallbackBranch, branchName, successLog;
|
|
2449
2523
|
var _this = this;
|
|
2450
2524
|
var _a;
|
|
2451
2525
|
return __generator(this, function (_b) {
|
|
@@ -2492,8 +2566,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2492
2566
|
_b.sent();
|
|
2493
2567
|
return [3 /*break*/, 5];
|
|
2494
2568
|
case 3:
|
|
2495
|
-
|
|
2496
|
-
message = (
|
|
2569
|
+
error_9 = _b.sent();
|
|
2570
|
+
message = (error_9 === null || error_9 === void 0 ? void 0 : error_9.message) || 'Failed while waiting for dashboard job completion.';
|
|
2497
2571
|
return [4 /*yield*/, fail(message)];
|
|
2498
2572
|
case 4:
|
|
2499
2573
|
_b.sent();
|
|
@@ -2508,8 +2582,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2508
2582
|
isRunning = _b.sent();
|
|
2509
2583
|
return [3 /*break*/, 10];
|
|
2510
2584
|
case 8:
|
|
2511
|
-
|
|
2512
|
-
message = (
|
|
2585
|
+
error_10 = _b.sent();
|
|
2586
|
+
message = (error_10 === null || error_10 === void 0 ? void 0 : error_10.message) || 'Unable to confirm dashboard job completion state.';
|
|
2513
2587
|
return [4 /*yield*/, fail(message)];
|
|
2514
2588
|
case 9:
|
|
2515
2589
|
_b.sent();
|
|
@@ -2575,7 +2649,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2575
2649
|
};
|
|
2576
2650
|
ErrorAutoFixManager.prototype.dispatchDashboardWorkflow = function (email, log) {
|
|
2577
2651
|
return __awaiter(this, void 0, void 0, function () {
|
|
2578
|
-
var fail, openaiEnvironment, app, repo, effectiveEnvironment, emailHash, rawHash, title, description, job,
|
|
2652
|
+
var fail, openaiEnvironment, app, repo, effectiveEnvironment, emailHash, rawHash, title, description, job, error_11, message, jobId, queuedLog;
|
|
2579
2653
|
var _this = this;
|
|
2580
2654
|
return __generator(this, function (_a) {
|
|
2581
2655
|
switch (_a.label) {
|
|
@@ -2634,8 +2708,8 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2634
2708
|
job = _a.sent();
|
|
2635
2709
|
return [3 /*break*/, 10];
|
|
2636
2710
|
case 8:
|
|
2637
|
-
|
|
2638
|
-
message = (
|
|
2711
|
+
error_11 = _a.sent();
|
|
2712
|
+
message = (error_11 === null || error_11 === void 0 ? void 0 : error_11.message) || 'Unable to enqueue dashboard auto-fix job.';
|
|
2639
2713
|
return [4 /*yield*/, fail('failed', 'dashboard_job_create_failed', message)];
|
|
2640
2714
|
case 9: return [2 /*return*/, _a.sent()];
|
|
2641
2715
|
case 10:
|
|
@@ -2947,6 +3021,7 @@ var ErrorAutoFixManager = /** @class */ (function () {
|
|
|
2947
3021
|
});
|
|
2948
3022
|
});
|
|
2949
3023
|
};
|
|
3024
|
+
ErrorAutoFixManager.APP_SETTINGS_CACHE_TTL_MS = 10000;
|
|
2950
3025
|
return ErrorAutoFixManager;
|
|
2951
3026
|
}());
|
|
2952
3027
|
exports.ErrorAutoFixManager = ErrorAutoFixManager;
|