@resolveio/server-lib 22.1.28 → 22.1.30

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.
@@ -1184,6 +1184,24 @@ function loadAiTerminalMethods(methodManager) {
1184
1184
  });
1185
1185
  });
1186
1186
  } }),
1187
+ aiCoderTerminalRunStatus: {
1188
+ check: new simpl_schema_1.default({
1189
+ payload: {
1190
+ type: Object,
1191
+ blackbox: true
1192
+ }
1193
+ }),
1194
+ function: function (payload) {
1195
+ return __awaiter(this, void 0, void 0, function () {
1196
+ return __generator(this, function (_a) {
1197
+ switch (_a.label) {
1198
+ case 0: return [4 /*yield*/, executeAiAssistantCodexRunStatus(payload, this)];
1199
+ case 1: return [2 /*return*/, _a.sent()];
1200
+ }
1201
+ });
1202
+ });
1203
+ }
1204
+ },
1187
1205
  aiCoderTerminalReportIssue: {
1188
1206
  check: new simpl_schema_1.default({
1189
1207
  payload: {
@@ -1614,6 +1632,15 @@ function executeAiAssistantCodexRun(payload, context) {
1614
1632
  user = _d.sent();
1615
1633
  isSuperAdmin = !!((_a = user === null || user === void 0 ? void 0 : user.roles) === null || _a === void 0 ? void 0 : _a.super_admin);
1616
1634
  canViewDebug = isAssistantDebugUser(user);
1635
+ if (shouldLogAssistantFinalizeDebug()) {
1636
+ console.log(new Date(), '[AI-Dashboard][AI-Assistant] debug-visibility', {
1637
+ requestId: requestId || null,
1638
+ id_user: (context === null || context === void 0 ? void 0 : context.id_user) || null,
1639
+ username: normalizeOptionalString(user === null || user === void 0 ? void 0 : user.username) || null,
1640
+ isSuperAdmin: isSuperAdmin,
1641
+ canViewDebug: canViewDebug
1642
+ });
1643
+ }
1617
1644
  hasInvoiceAccess = userHasInvoiceAccess(user);
1618
1645
  customerId = normalizeOptionalString((_b = user === null || user === void 0 ? void 0 : user.other) === null || _b === void 0 ? void 0 : _b.id_customer);
1619
1646
  return [4 /*yield*/, ensureConversation(input, 'codex', context === null || context === void 0 ? void 0 : context.id_user)];
@@ -2669,6 +2696,98 @@ function executeAiAssistantCodexRun(payload, context) {
2669
2696
  });
2670
2697
  });
2671
2698
  }
2699
+ function executeAiAssistantCodexRunStatus(payload, context) {
2700
+ return __awaiter(this, void 0, void 0, function () {
2701
+ var input, idUser, requestedConversationId, requestedMessageId, requestedRequestId, conversation, conversationId, ownerId, assistantMessage, messageConversationId, ownerId, pending, messageRequestId;
2702
+ var _a, _b;
2703
+ return __generator(this, function (_c) {
2704
+ switch (_c.label) {
2705
+ case 0:
2706
+ input = payload || {};
2707
+ idUser = normalizeOptionalString(context === null || context === void 0 ? void 0 : context.id_user);
2708
+ if (!idUser) {
2709
+ throw new Error('Unauthorized.');
2710
+ }
2711
+ requestedConversationId = normalizeOptionalString(input.id_conversation);
2712
+ requestedMessageId = normalizeOptionalString(input.id_message);
2713
+ requestedRequestId = normalizeOptionalString(input.request_id);
2714
+ if (!requestedConversationId && !requestedMessageId && !requestedRequestId) {
2715
+ throw new Error('Conversation id, message id, or request id is required.');
2716
+ }
2717
+ conversation = null;
2718
+ conversationId = requestedConversationId;
2719
+ if (!conversationId) return [3 /*break*/, 2];
2720
+ return [4 /*yield*/, ai_terminal_conversation_collection_1.AiTerminalConversations.findById(conversationId)];
2721
+ case 1:
2722
+ conversation = _c.sent();
2723
+ if (!conversation) {
2724
+ throw new Error('Conversation not found.');
2725
+ }
2726
+ ownerId = normalizeOptionalString(conversation.id_user);
2727
+ if (ownerId && ownerId !== idUser) {
2728
+ throw new Error('Conversation access denied.');
2729
+ }
2730
+ _c.label = 2;
2731
+ case 2:
2732
+ assistantMessage = null;
2733
+ if (!requestedMessageId) return [3 /*break*/, 4];
2734
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.findOne({ _id: requestedMessageId })];
2735
+ case 3:
2736
+ assistantMessage = (_c.sent());
2737
+ if (assistantMessage) {
2738
+ messageConversationId = normalizeOptionalString(assistantMessage.id_conversation);
2739
+ if (!conversationId) {
2740
+ conversationId = messageConversationId;
2741
+ }
2742
+ if (conversationId && messageConversationId && messageConversationId !== conversationId) {
2743
+ throw new Error('Message does not belong to the selected conversation.');
2744
+ }
2745
+ }
2746
+ _c.label = 4;
2747
+ case 4:
2748
+ if (!(!conversation && conversationId)) return [3 /*break*/, 6];
2749
+ return [4 /*yield*/, ai_terminal_conversation_collection_1.AiTerminalConversations.findById(conversationId)];
2750
+ case 5:
2751
+ conversation = _c.sent();
2752
+ if (!conversation) {
2753
+ throw new Error('Conversation not found.');
2754
+ }
2755
+ ownerId = normalizeOptionalString(conversation.id_user);
2756
+ if (ownerId && ownerId !== idUser) {
2757
+ throw new Error('Conversation access denied.');
2758
+ }
2759
+ _c.label = 6;
2760
+ case 6:
2761
+ if (!(!assistantMessage && conversationId && requestedRequestId)) return [3 /*break*/, 8];
2762
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.findOne({
2763
+ id_conversation: conversationId,
2764
+ role: 'assistant',
2765
+ 'metadata.request_id': requestedRequestId
2766
+ }, { sort: { createdAt: -1 } })];
2767
+ case 7:
2768
+ assistantMessage = (_c.sent());
2769
+ _c.label = 8;
2770
+ case 8:
2771
+ if (!(!assistantMessage && conversationId && !requestedRequestId)) return [3 /*break*/, 10];
2772
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.findOne({ id_conversation: conversationId, role: 'assistant' }, { sort: { createdAt: -1 } })];
2773
+ case 9:
2774
+ assistantMessage = (_c.sent());
2775
+ _c.label = 10;
2776
+ case 10:
2777
+ pending = ((_a = assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage.metadata) === null || _a === void 0 ? void 0 : _a.pending) === true;
2778
+ messageRequestId = normalizeOptionalString((_b = assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage.metadata) === null || _b === void 0 ? void 0 : _b.request_id);
2779
+ return [2 /*return*/, {
2780
+ id_conversation: conversationId || normalizeOptionalString(assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage.id_conversation),
2781
+ id_message: normalizeOptionalString(assistantMessage === null || assistantMessage === void 0 ? void 0 : assistantMessage._id),
2782
+ request_id: requestedRequestId || messageRequestId,
2783
+ pending: pending,
2784
+ done: !!assistantMessage && !pending,
2785
+ message: assistantMessage || null
2786
+ }];
2787
+ }
2788
+ });
2789
+ });
2790
+ }
2672
2791
  function executeAiAssistantReportBuilderRead(payload, context) {
2673
2792
  return __awaiter(this, void 0, void 0, function () {
2674
2793
  return __generator(this, function (_a) {
@@ -20485,54 +20604,129 @@ function resolveAssistantDatabaseNameForSystemCollections() {
20485
20604
  }
20486
20605
  function updateAssistantMessageWithFallback(messageId, setPayload) {
20487
20606
  return __awaiter(this, void 0, void 0, function () {
20488
- var error_12, dbName, _a;
20489
- return __generator(this, function (_b) {
20490
- switch (_b.label) {
20607
+ var safeSetPayload, fallbackId, debugEnabled, result, error_12, dbName, messagesCollection, result, _a, retryResult;
20608
+ var _b, _c, _d, _e, _f, _g;
20609
+ return __generator(this, function (_h) {
20610
+ switch (_h.label) {
20491
20611
  case 0:
20492
20612
  if (!messageId || !setPayload || typeof setPayload !== 'object') {
20493
20613
  return [2 /*return*/];
20494
20614
  }
20495
- _b.label = 1;
20615
+ safeSetPayload = sanitizeAssistantMessageSetPayload(setPayload);
20616
+ fallbackId = normalizeOptionalString(typeof messageId === 'string' ? messageId : String(messageId));
20617
+ debugEnabled = shouldLogAssistantFinalizeDebug();
20618
+ _h.label = 1;
20496
20619
  case 1:
20497
- _b.trys.push([1, 3, , 10]);
20498
- return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: messageId }, { $set: setPayload }, undefined, false, false, true)];
20620
+ _h.trys.push([1, 5, , 17]);
20621
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: messageId }, { $set: safeSetPayload }, undefined, false, false, true)];
20499
20622
  case 2:
20500
- _b.sent();
20501
- return [2 /*return*/];
20623
+ result = _h.sent();
20624
+ if (!((result === null || result === void 0 ? void 0 : result.matchedCount) === 0 && fallbackId && fallbackId !== messageId)) return [3 /*break*/, 4];
20625
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: fallbackId }, { $set: safeSetPayload }, undefined, false, false, true)];
20502
20626
  case 3:
20503
- error_12 = _b.sent();
20627
+ result = _h.sent();
20628
+ _h.label = 4;
20629
+ case 4:
20630
+ if (!result || result.matchedCount === 0) {
20631
+ console.warn(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update no-match', {
20632
+ messageId: fallbackId || messageId,
20633
+ via: 'collection_manager'
20634
+ });
20635
+ }
20636
+ if (debugEnabled) {
20637
+ console.log(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update', {
20638
+ messageId: fallbackId || messageId,
20639
+ matchedCount: (_b = result === null || result === void 0 ? void 0 : result.matchedCount) !== null && _b !== void 0 ? _b : 0,
20640
+ modifiedCount: (_c = result === null || result === void 0 ? void 0 : result.modifiedCount) !== null && _c !== void 0 ? _c : 0,
20641
+ via: 'collection_manager'
20642
+ });
20643
+ }
20644
+ return [2 /*return*/];
20645
+ case 5:
20646
+ error_12 = _h.sent();
20504
20647
  if (!isAssistantTransactionCommittedError(error_12)) {
20505
20648
  throw error_12;
20506
20649
  }
20650
+ if (debugEnabled) {
20651
+ console.log(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update fallback triggered', {
20652
+ messageId: fallbackId || messageId,
20653
+ reason: normalizeOptionalString(error_12 === null || error_12 === void 0 ? void 0 : error_12.message) || 'transaction_committed'
20654
+ });
20655
+ }
20507
20656
  dbName = resolveAssistantDatabaseNameForSystemCollections();
20508
- _b.label = 4;
20509
- case 4:
20510
- _b.trys.push([4, 6, , 7]);
20511
- return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMongoConnection()
20512
- .db(dbName)
20513
- .collection('ai-terminal-messages')
20514
- .updateOne({ _id: messageId }, { $set: setPayload })];
20515
- case 5:
20516
- _b.sent();
20517
- return [2 /*return*/];
20657
+ _h.label = 6;
20518
20658
  case 6:
20519
- _a = _b.sent();
20520
- return [3 /*break*/, 7];
20521
- case 7: return [4 /*yield*/, (0, promises_1.setTimeout)(15)];
20659
+ _h.trys.push([6, 11, , 12]);
20660
+ messagesCollection = resolveio_server_app_1.ResolveIOServer.getMongoConnection()
20661
+ .db(dbName)
20662
+ .collection('ai-terminal-messages');
20663
+ return [4 /*yield*/, messagesCollection
20664
+ .updateOne({ _id: String(messageId) }, { $set: safeSetPayload })];
20665
+ case 7:
20666
+ result = _h.sent();
20667
+ if (!((result === null || result === void 0 ? void 0 : result.matchedCount) === 0 && fallbackId && fallbackId !== messageId)) return [3 /*break*/, 9];
20668
+ return [4 /*yield*/, messagesCollection
20669
+ .updateOne({ _id: fallbackId }, { $set: safeSetPayload })];
20522
20670
  case 8:
20523
- _b.sent();
20524
- return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: messageId }, { $set: setPayload }, undefined, false, false, true)];
20671
+ result = _h.sent();
20672
+ _h.label = 9;
20525
20673
  case 9:
20526
- _b.sent();
20527
- return [3 /*break*/, 10];
20528
- case 10: return [2 /*return*/];
20674
+ if (!result || result.matchedCount === 0) {
20675
+ console.warn(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update no-match', {
20676
+ messageId: fallbackId || messageId,
20677
+ via: 'direct_mongo_fallback'
20678
+ });
20679
+ }
20680
+ return [4 /*yield*/, notifyAiTerminalCollectionUpdate('ai-terminal-messages', fallbackId || messageId)];
20681
+ case 10:
20682
+ _h.sent();
20683
+ if (debugEnabled) {
20684
+ console.log(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update', {
20685
+ messageId: fallbackId || messageId,
20686
+ matchedCount: (_d = result === null || result === void 0 ? void 0 : result.matchedCount) !== null && _d !== void 0 ? _d : 0,
20687
+ modifiedCount: (_e = result === null || result === void 0 ? void 0 : result.modifiedCount) !== null && _e !== void 0 ? _e : 0,
20688
+ via: 'direct_mongo_fallback'
20689
+ });
20690
+ }
20691
+ return [2 /*return*/];
20692
+ case 11:
20693
+ _a = _h.sent();
20694
+ return [3 /*break*/, 12];
20695
+ case 12: return [4 /*yield*/, (0, promises_1.setTimeout)(15)];
20696
+ case 13:
20697
+ _h.sent();
20698
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: messageId }, { $set: safeSetPayload }, undefined, false, false, true)];
20699
+ case 14:
20700
+ retryResult = _h.sent();
20701
+ if (!((retryResult === null || retryResult === void 0 ? void 0 : retryResult.matchedCount) === 0 && fallbackId && fallbackId !== messageId)) return [3 /*break*/, 16];
20702
+ return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: fallbackId }, { $set: safeSetPayload }, undefined, false, false, true)];
20703
+ case 15:
20704
+ retryResult = _h.sent();
20705
+ _h.label = 16;
20706
+ case 16:
20707
+ if (!retryResult || retryResult.matchedCount === 0) {
20708
+ console.warn(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update no-match', {
20709
+ messageId: fallbackId || messageId,
20710
+ via: 'collection_manager_retry'
20711
+ });
20712
+ }
20713
+ if (debugEnabled) {
20714
+ console.log(new Date(), '[AI-Dashboard][AI-Assistant] message finalize update', {
20715
+ messageId: fallbackId || messageId,
20716
+ matchedCount: (_f = retryResult === null || retryResult === void 0 ? void 0 : retryResult.matchedCount) !== null && _f !== void 0 ? _f : 0,
20717
+ modifiedCount: (_g = retryResult === null || retryResult === void 0 ? void 0 : retryResult.modifiedCount) !== null && _g !== void 0 ? _g : 0,
20718
+ via: 'collection_manager_retry'
20719
+ });
20720
+ }
20721
+ return [3 /*break*/, 17];
20722
+ case 17: return [2 /*return*/];
20529
20723
  }
20530
20724
  });
20531
20725
  });
20532
20726
  }
20533
20727
  function touchConversation(idConversation, timestamp, lastMessageId) {
20534
20728
  return __awaiter(this, void 0, void 0, function () {
20535
- var update, error_13, dbName;
20729
+ var update, result, error_13, dbName, conversationsCollection, fallbackResult;
20536
20730
  return __generator(this, function (_a) {
20537
20731
  switch (_a.label) {
20538
20732
  case 0:
@@ -20545,10 +20739,16 @@ function touchConversation(idConversation, timestamp, lastMessageId) {
20545
20739
  }
20546
20740
  _a.label = 1;
20547
20741
  case 1:
20548
- _a.trys.push([1, 3, , 5]);
20742
+ _a.trys.push([1, 3, , 6]);
20549
20743
  return [4 /*yield*/, ai_terminal_conversation_collection_1.AiTerminalConversations.updateOne({ _id: idConversation }, { $set: update }, undefined, false, false, true)];
20550
20744
  case 2:
20551
- _a.sent();
20745
+ result = _a.sent();
20746
+ if (!result || result.matchedCount === 0) {
20747
+ console.warn(new Date(), '[AI-Dashboard][AI-Assistant] conversation touch no-match', {
20748
+ idConversation: idConversation,
20749
+ via: 'collection_manager'
20750
+ });
20751
+ }
20552
20752
  return [2 /*return*/];
20553
20753
  case 3:
20554
20754
  error_13 = _a.sent();
@@ -20556,18 +20756,112 @@ function touchConversation(idConversation, timestamp, lastMessageId) {
20556
20756
  throw error_13;
20557
20757
  }
20558
20758
  dbName = resolveAssistantDatabaseNameForSystemCollections();
20559
- return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMongoConnection()
20560
- .db(dbName)
20561
- .collection('ai-terminal-conversations')
20562
- .updateOne({ _id: idConversation }, { $set: update })];
20759
+ conversationsCollection = resolveio_server_app_1.ResolveIOServer.getMongoConnection()
20760
+ .db(dbName)
20761
+ .collection('ai-terminal-conversations');
20762
+ return [4 /*yield*/, conversationsCollection.updateOne({ _id: idConversation }, { $set: update })];
20563
20763
  case 4:
20764
+ fallbackResult = _a.sent();
20765
+ if (!fallbackResult || fallbackResult.matchedCount === 0) {
20766
+ console.warn(new Date(), '[AI-Dashboard][AI-Assistant] conversation touch no-match', {
20767
+ idConversation: idConversation,
20768
+ via: 'direct_mongo_fallback'
20769
+ });
20770
+ }
20771
+ return [4 /*yield*/, notifyAiTerminalCollectionUpdate('ai-terminal-conversations', idConversation)];
20772
+ case 5:
20564
20773
  _a.sent();
20774
+ return [3 /*break*/, 6];
20775
+ case 6: return [2 /*return*/];
20776
+ }
20777
+ });
20778
+ });
20779
+ }
20780
+ function shouldLogAssistantFinalizeDebug() {
20781
+ return parseDebugFlag(process.env.AI_DASHBOARD_DEBUG)
20782
+ || parseDebugFlag(process.env.AI_ASSISTANT_WORKER_DEBUG);
20783
+ }
20784
+ function notifyAiTerminalCollectionUpdate(collection, documentId) {
20785
+ return __awaiter(this, void 0, void 0, function () {
20786
+ var subManager, _a;
20787
+ var _b, _c;
20788
+ return __generator(this, function (_d) {
20789
+ switch (_d.label) {
20790
+ case 0:
20791
+ try {
20792
+ resolveio_server_app_1.ResolveIOServer.getMongoManager().invalidateQueryCache(collection, true);
20793
+ }
20794
+ catch (_e) { }
20795
+ _d.label = 1;
20796
+ case 1:
20797
+ _d.trys.push([1, 4, , 5]);
20798
+ subManager = (_c = (_b = resolveio_server_app_1.ResolveIOServer.getMainServer()) === null || _b === void 0 ? void 0 : _b.getSubscriptionManager) === null || _c === void 0 ? void 0 : _c.call(_b);
20799
+ if (!(subManager && typeof subManager.invalidatePubsCache === 'function')) return [3 /*break*/, 3];
20800
+ return [4 /*yield*/, subManager.invalidatePubsCache(collection, 'update', documentId)];
20801
+ case 2:
20802
+ _d.sent();
20803
+ _d.label = 3;
20804
+ case 3: return [3 /*break*/, 5];
20805
+ case 4:
20806
+ _a = _d.sent();
20565
20807
  return [3 /*break*/, 5];
20566
20808
  case 5: return [2 /*return*/];
20567
20809
  }
20568
20810
  });
20569
20811
  });
20570
20812
  }
20813
+ function sanitizeAssistantMessageSetPayload(setPayload) {
20814
+ var next = __assign({}, setPayload);
20815
+ if (next.metadata && typeof next.metadata === 'object') {
20816
+ next.metadata = sanitizeMongoSafeObject(next.metadata);
20817
+ }
20818
+ return next;
20819
+ }
20820
+ function sanitizeMongoSafeObject(value) {
20821
+ var e_57, _a;
20822
+ if (value === null || value === undefined) {
20823
+ return value;
20824
+ }
20825
+ if (Array.isArray(value)) {
20826
+ return value.map(function (entry) { return sanitizeMongoSafeObject(entry); });
20827
+ }
20828
+ if (value instanceof Date) {
20829
+ return value;
20830
+ }
20831
+ if (isMongoObjectId(value)) {
20832
+ return value;
20833
+ }
20834
+ if (!isPlainObject(value)) {
20835
+ return value;
20836
+ }
20837
+ var out = {};
20838
+ try {
20839
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
20840
+ var _d = __read(_c.value, 2), rawKey = _d[0], rawValue = _d[1];
20841
+ var key = sanitizeMongoKey(rawKey);
20842
+ out[key] = sanitizeMongoSafeObject(rawValue);
20843
+ }
20844
+ }
20845
+ catch (e_57_1) { e_57 = { error: e_57_1 }; }
20846
+ finally {
20847
+ try {
20848
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
20849
+ }
20850
+ finally { if (e_57) throw e_57.error; }
20851
+ }
20852
+ return out;
20853
+ }
20854
+ function sanitizeMongoKey(rawKey) {
20855
+ var key = String(rawKey || '');
20856
+ if (!key) {
20857
+ return '_';
20858
+ }
20859
+ var sanitized = key.replace(/\./g, '__dot__');
20860
+ if (sanitized.startsWith('$')) {
20861
+ sanitized = "_dollar_".concat(sanitized.slice(1));
20862
+ }
20863
+ return sanitized || '_';
20864
+ }
20571
20865
  function normalizeOptionalString(value) {
20572
20866
  var raw = typeof value === 'string' ? value.trim() : '';
20573
20867
  return raw || '';
@@ -20654,7 +20948,7 @@ function estimateUsage(messages, responseText, model) {
20654
20948
  };
20655
20949
  }
20656
20950
  function evaluateGuardrails(message) {
20657
- var e_57, _a;
20951
+ var e_58, _a;
20658
20952
  var normalized = String(message || '').toLowerCase();
20659
20953
  var identityGuardrail = evaluateAssistantIdentityDisclosureGuardrail(normalized);
20660
20954
  if (identityGuardrail === null || identityGuardrail === void 0 ? void 0 : identityGuardrail.blocked) {
@@ -20680,12 +20974,12 @@ function evaluateGuardrails(message) {
20680
20974
  }
20681
20975
  }
20682
20976
  }
20683
- catch (e_57_1) { e_57 = { error: e_57_1 }; }
20977
+ catch (e_58_1) { e_58 = { error: e_58_1 }; }
20684
20978
  finally {
20685
20979
  try {
20686
20980
  if (patterns_3_1 && !patterns_3_1.done && (_a = patterns_3.return)) _a.call(patterns_3);
20687
20981
  }
20688
- finally { if (e_57) throw e_57.error; }
20982
+ finally { if (e_58) throw e_58.error; }
20689
20983
  }
20690
20984
  return null;
20691
20985
  }