@resolveio/server-lib 20.14.48 → 20.15.1

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.
@@ -61,6 +61,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
62
  }
63
63
  };
64
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
65
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
66
+ var m = o[Symbol.asyncIterator], i;
67
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
68
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
69
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
70
+ };
64
71
  var __read = (this && this.__read) || function (o, n) {
65
72
  var m = typeof Symbol === "function" && o[Symbol.iterator];
66
73
  if (!m) return o;
@@ -152,6 +159,8 @@ var AI_ASSISTANT_DISPLAY_PRIORITY_FIELDS = [
152
159
  'updatedAt',
153
160
  'date_updated',
154
161
  'date_completed',
162
+ 'date_invoice',
163
+ 'date_invoiced',
155
164
  'id_customer',
156
165
  'id_client',
157
166
  'id_user',
@@ -159,7 +168,9 @@ var AI_ASSISTANT_DISPLAY_PRIORITY_FIELDS = [
159
168
  ];
160
169
  var AI_ASSISTANT_DATE_FALLBACKS = {
161
170
  date_created: 'createdAt',
162
- createdAt: 'date_created'
171
+ createdAt: 'date_created',
172
+ date_invoice: 'date_invoiced',
173
+ date_invoiced: 'date_invoice'
163
174
  };
164
175
  var AI_ASSISTANT_BLOCKED_COLLECTIONS = new Set([
165
176
  'user-groups',
@@ -788,7 +799,7 @@ function executeAiFormPatch(payload, context) {
788
799
  }
789
800
  function executeAiAssistantCodexRun(payload, context) {
790
801
  return __awaiter(this, void 0, void 0, function () {
791
- var input, message, requestId, guardrail, conversation_2, now_2, userMsg, assistantMsg, user, isSuperAdmin, hasInvoiceAccess, customerId, conversation, now, attachments, attachmentData, historyLimit, history, _a, historyLines, assistantContext, prompt, workspaceRoot, codexConfig, runOptions, userDoc, initialProgress, assistantDoc, insertResult, assistantMessageId, progressTracker, assistantContent, toolResult, responseText, directive, cleanedResponseText, toolRequest, toolResponse, _b, toolPayload, followupPrompt, followupText, _c, error_1, error_2, finalNow, finalMetadata, finalAssistantDoc;
802
+ var input, message, requestId, guardrail, conversation_2, now_2, userMsg, assistantMsg, user, isSuperAdmin, hasInvoiceAccess, customerId, conversation, now, attachments, attachmentData, historyLimit, history, _a, historyLines, assistantContext, prompt, workspaceRoot, codexConfig, runOptions, userDoc, initialProgress, assistantDoc, insertResult, assistantMessageId, progressTracker, streamProgress, assistantContent, toolResult, responseText, directive, cleanedResponseText, toolRequest, toolResponse, _b, toolPayload, followupPrompt, followupText, _c, error_1, error_2, finalNow, finalMetadata, finalAssistantDoc;
792
803
  var _d, _e;
793
804
  return __generator(this, function (_f) {
794
805
  switch (_f.label) {
@@ -916,12 +927,13 @@ function executeAiAssistantCodexRun(payload, context) {
916
927
  insertResult = _f.sent();
917
928
  assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
918
929
  progressTracker = createAssistantProgressTracker(assistantMessageId, initialProgress);
930
+ streamProgress = createAssistantStreamProgressHandler(progressTracker);
919
931
  assistantContent = '';
920
932
  toolResult = null;
921
933
  _f.label = 15;
922
934
  case 15:
923
935
  _f.trys.push([15, 30, 31, 32]);
924
- return [4 /*yield*/, runCodexInWorkerThread(prompt, runOptions, codexConfig)];
936
+ return [4 /*yield*/, runCodexInWorkerThread(prompt, runOptions, codexConfig, streamProgress)];
925
937
  case 16:
926
938
  responseText = _f.sent();
927
939
  directive = extractAssistantMongoDirective(responseText);
@@ -951,7 +963,7 @@ function executeAiAssistantCodexRun(payload, context) {
951
963
  _f.label = 22;
952
964
  case 22:
953
965
  _f.trys.push([22, 24, , 25]);
954
- return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, runOptions, codexConfig)];
966
+ return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, runOptions, codexConfig, streamProgress)];
955
967
  case 23:
956
968
  followupText = _f.sent();
957
969
  assistantContent = sanitizeAssistantResponse(followupText);
@@ -1092,7 +1104,7 @@ function executeAiAssistantMongoRead(payload, context) {
1092
1104
  }
1093
1105
  function executeAiAssistantMongoAggregate(payload, context) {
1094
1106
  return __awaiter(this, void 0, void 0, function () {
1095
- var input, collection, _a, user, isSuperAdmin, customerId, dbName, db, baseQuery, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, documents, executedPipeline, fallbackMeta, fallback, fallbackPipeline, fallbackDocs, unwindFallback, fallbackPipeline, fallbackDocs, sanitizedDocuments, includeIds, display;
1107
+ var input, collection, _a, user, isSuperAdmin, customerId, dbName, db, baseQuery, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, dateField, documents, executedPipeline, fallbackMeta, fallback, fallbackPipeline, fallbackDocs, createdFallback, createdPipeline, createdDocs, unwindFallback, fallbackPipeline, fallbackDocs, sanitizedDocuments, includeIds, display;
1096
1108
  var _c, _d;
1097
1109
  return __generator(this, function (_e) {
1098
1110
  switch (_e.label) {
@@ -1140,6 +1152,7 @@ function executeAiAssistantMongoAggregate(payload, context) {
1140
1152
  pipelineWithScope = buildAssistantAggregatePipeline(scopedQuery, normalizedPipeline);
1141
1153
  normalizedOptions = normalizeAssistantAggregateOptions(input.options);
1142
1154
  limitedPipeline = applyAssistantAggregateLimit(pipelineWithScope, normalizedOptions.limit);
1155
+ dateField = findAggregateDateField(limitedPipeline);
1143
1156
  if (containsForbiddenMongoOperators(limitedPipeline)) {
1144
1157
  throw new Error('AI assistant mongo aggregate: Pipeline contains restricted operators.');
1145
1158
  }
@@ -1150,7 +1163,7 @@ function executeAiAssistantMongoAggregate(payload, context) {
1150
1163
  documents = _e.sent();
1151
1164
  executedPipeline = limitedPipeline;
1152
1165
  fallbackMeta = {};
1153
- if (!!documents.length) return [3 /*break*/, 7];
1166
+ if (!(!documents.length && dateField)) return [3 /*break*/, 9];
1154
1167
  fallback = resolveAggregateDateFieldFallback(limitedPipeline);
1155
1168
  if (!fallback) return [3 /*break*/, 7];
1156
1169
  fallbackMeta.dateField = __assign(__assign({}, fallback), { attempted: true, used: false });
@@ -1168,24 +1181,41 @@ function executeAiAssistantMongoAggregate(payload, context) {
1168
1181
  }
1169
1182
  _e.label = 7;
1170
1183
  case 7:
1171
- if (!(documents.length <= 1)) return [3 /*break*/, 9];
1184
+ if (!(!documents.length && dateField !== 'createdAt')) return [3 /*break*/, 9];
1185
+ createdFallback = { from: dateField, to: 'createdAt', attempted: true, used: false };
1186
+ createdPipeline = replaceAggregateDateField(limitedPipeline, dateField, 'createdAt');
1187
+ fallbackMeta.dateFieldCreatedAt = createdFallback;
1188
+ if (!!containsForbiddenMongoOperators(createdPipeline)) return [3 /*break*/, 9];
1189
+ return [4 /*yield*/, db.collection(collection)
1190
+ .aggregate(createdPipeline, normalizedOptions.aggregateOptions)
1191
+ .toArray()];
1192
+ case 8:
1193
+ createdDocs = _e.sent();
1194
+ if (createdDocs.length) {
1195
+ documents = createdDocs;
1196
+ executedPipeline = createdPipeline;
1197
+ fallbackMeta.dateFieldCreatedAt.used = true;
1198
+ }
1199
+ _e.label = 9;
1200
+ case 9:
1201
+ if (!(documents.length <= 1)) return [3 /*break*/, 11];
1172
1202
  unwindFallback = resolveAggregateUnwindFallback(executedPipeline);
1173
- if (!unwindFallback) return [3 /*break*/, 9];
1203
+ if (!unwindFallback) return [3 /*break*/, 11];
1174
1204
  fallbackMeta.unwind = { path: unwindFallback.path, attempted: true, used: false };
1175
1205
  fallbackPipeline = buildAggregateUnwindFallbackPipeline(executedPipeline, unwindFallback);
1176
- if (!!containsForbiddenMongoOperators(fallbackPipeline)) return [3 /*break*/, 9];
1206
+ if (!!containsForbiddenMongoOperators(fallbackPipeline)) return [3 /*break*/, 11];
1177
1207
  return [4 /*yield*/, db.collection(collection)
1178
1208
  .aggregate(fallbackPipeline, normalizedOptions.aggregateOptions)
1179
1209
  .toArray()];
1180
- case 8:
1210
+ case 10:
1181
1211
  fallbackDocs = _e.sent();
1182
1212
  if (fallbackDocs.length > documents.length) {
1183
1213
  documents = fallbackDocs;
1184
1214
  executedPipeline = fallbackPipeline;
1185
1215
  fallbackMeta.unwind.used = true;
1186
1216
  }
1187
- _e.label = 9;
1188
- case 9:
1217
+ _e.label = 11;
1218
+ case 11:
1189
1219
  sanitizedDocuments = isSuperAdmin
1190
1220
  ? documents
1191
1221
  : documents.map(function (doc) { return redactSensitiveFields((0, common_1.deepCopy)(doc)); });
@@ -1381,6 +1411,60 @@ function buildAssistantToolErrorMessage(error, directive, request) {
1381
1411
  }
1382
1412
  return "I couldn't access the requested data. ".concat(routeLine);
1383
1413
  }
1414
+ function deriveAssistantStreamStatus(event) {
1415
+ var _a;
1416
+ if (!event || !event.type) {
1417
+ return null;
1418
+ }
1419
+ if (event.type === 'thread.started' || event.type === 'turn.started') {
1420
+ return 'Reviewing request';
1421
+ }
1422
+ if (event.type === 'turn.completed') {
1423
+ return 'Drafting response';
1424
+ }
1425
+ if (event.type === 'item.started' || event.type === 'item.updated' || event.type === 'item.completed') {
1426
+ var itemType = String(((_a = event === null || event === void 0 ? void 0 : event.item) === null || _a === void 0 ? void 0 : _a.type) || '').trim().toLowerCase();
1427
+ if (!itemType) {
1428
+ return null;
1429
+ }
1430
+ if (itemType === 'mcp_tool_call') {
1431
+ return 'Calling tool';
1432
+ }
1433
+ if (itemType === 'command_execution') {
1434
+ return 'Running command';
1435
+ }
1436
+ if (itemType === 'web_search') {
1437
+ return 'Searching references';
1438
+ }
1439
+ if (itemType === 'file_change') {
1440
+ return 'Drafting response';
1441
+ }
1442
+ if (itemType === 'agent_message') {
1443
+ return 'Drafting response';
1444
+ }
1445
+ if (itemType === 'reasoning') {
1446
+ return 'Analyzing';
1447
+ }
1448
+ }
1449
+ return null;
1450
+ }
1451
+ function createAssistantStreamProgressHandler(progressTracker) {
1452
+ var lastStatus = '';
1453
+ var lastSentAt = 0;
1454
+ return function (status) {
1455
+ var trimmed = normalizeOptionalString(status);
1456
+ if (!trimmed) {
1457
+ return;
1458
+ }
1459
+ var now = Date.now();
1460
+ if (trimmed === lastStatus && now - lastSentAt < 3000) {
1461
+ return;
1462
+ }
1463
+ lastStatus = trimmed;
1464
+ lastSentAt = now;
1465
+ progressTracker.push(trimmed);
1466
+ };
1467
+ }
1384
1468
  function normalizeAssistantProgress(items) {
1385
1469
  var seen = new Set();
1386
1470
  var cleaned = [];
@@ -2400,26 +2484,103 @@ var CodexWorkerBootstrapError = /** @class */ (function (_super) {
2400
2484
  }
2401
2485
  return CodexWorkerBootstrapError;
2402
2486
  }(Error));
2403
- function runCodexInWorkerThread(prompt, runOptions, config) {
2487
+ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
2488
+ var _this = this;
2489
+ if (!streamStatusHandler) {
2490
+ return runOptions;
2491
+ }
2492
+ var existing = runOptions === null || runOptions === void 0 ? void 0 : runOptions.onStreamEvent;
2493
+ return __assign(__assign({}, runOptions), { onStreamEvent: function (event) { return __awaiter(_this, void 0, void 0, function () {
2494
+ var status;
2495
+ return __generator(this, function (_a) {
2496
+ switch (_a.label) {
2497
+ case 0:
2498
+ if (!existing) return [3 /*break*/, 2];
2499
+ return [4 /*yield*/, existing(event)];
2500
+ case 1:
2501
+ _a.sent();
2502
+ _a.label = 2;
2503
+ case 2:
2504
+ status = deriveAssistantStreamStatus(event);
2505
+ if (status) {
2506
+ streamStatusHandler(status);
2507
+ }
2508
+ return [2 /*return*/];
2509
+ }
2510
+ });
2511
+ }); } });
2512
+ }
2513
+ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
2404
2514
  return __awaiter(this, void 0, void 0, function () {
2405
- var codexClient, workerPath, codexClient, error_3, codexClient;
2515
+ var _a, _b, _c, _d, message, payload, status_1, e_2_1;
2516
+ var _e, e_2, _f, _g;
2517
+ return __generator(this, function (_h) {
2518
+ switch (_h.label) {
2519
+ case 0:
2520
+ _h.trys.push([0, 5, 6, 11]);
2521
+ _a = true, _b = __asyncValues((0, events_1.on)(worker, 'message'));
2522
+ _h.label = 1;
2523
+ case 1: return [4 /*yield*/, _b.next()];
2524
+ case 2:
2525
+ if (!(_c = _h.sent(), _e = _c.done, !_e)) return [3 /*break*/, 4];
2526
+ _g = _c.value;
2527
+ _a = false;
2528
+ _d = __read(_g, 1), message = _d[0];
2529
+ payload = message;
2530
+ if ((payload === null || payload === void 0 ? void 0 : payload.type) === 'stream') {
2531
+ status_1 = normalizeOptionalString(payload.status);
2532
+ if (status_1 && streamStatusHandler) {
2533
+ streamStatusHandler(status_1);
2534
+ }
2535
+ return [3 /*break*/, 3];
2536
+ }
2537
+ return [2 /*return*/, payload];
2538
+ case 3:
2539
+ _a = true;
2540
+ return [3 /*break*/, 1];
2541
+ case 4: return [3 /*break*/, 11];
2542
+ case 5:
2543
+ e_2_1 = _h.sent();
2544
+ e_2 = { error: e_2_1 };
2545
+ return [3 /*break*/, 11];
2546
+ case 6:
2547
+ _h.trys.push([6, , 9, 10]);
2548
+ if (!(!_a && !_e && (_f = _b.return))) return [3 /*break*/, 8];
2549
+ return [4 /*yield*/, _f.call(_b)];
2550
+ case 7:
2551
+ _h.sent();
2552
+ _h.label = 8;
2553
+ case 8: return [3 /*break*/, 10];
2554
+ case 9:
2555
+ if (e_2) throw e_2.error;
2556
+ return [7 /*endfinally*/];
2557
+ case 10: return [7 /*endfinally*/];
2558
+ case 11: throw new CodexWorkerBootstrapError('Codex worker exited before completing.');
2559
+ }
2560
+ });
2561
+ });
2562
+ }
2563
+ function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler) {
2564
+ return __awaiter(this, void 0, void 0, function () {
2565
+ var streamedOptions, codexClient, workerPath, codexClient, error_3, codexClient;
2406
2566
  return __generator(this, function (_a) {
2407
2567
  switch (_a.label) {
2408
2568
  case 0:
2569
+ streamedOptions = applyCodexStreamStatusHandler(runOptions, streamStatusHandler);
2409
2570
  if (!!resolveCodexWorkerThreadEnabled()) return [3 /*break*/, 2];
2410
2571
  codexClient = getAssistantCodexClient();
2411
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2572
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2412
2573
  case 1: return [2 /*return*/, _a.sent()];
2413
2574
  case 2: return [4 /*yield*/, resolveCodexWorkerPath()];
2414
2575
  case 3:
2415
2576
  workerPath = _a.sent();
2416
2577
  if (!!workerPath) return [3 /*break*/, 5];
2417
2578
  codexClient = getAssistantCodexClient();
2418
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2579
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2419
2580
  case 4: return [2 /*return*/, _a.sent()];
2420
2581
  case 5:
2421
2582
  _a.trys.push([5, 7, , 9]);
2422
- return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)];
2583
+ return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler)];
2423
2584
  case 6: return [2 /*return*/, _a.sent()];
2424
2585
  case 7:
2425
2586
  error_3 = _a.sent();
@@ -2428,14 +2589,14 @@ function runCodexInWorkerThread(prompt, runOptions, config) {
2428
2589
  }
2429
2590
  console.error('Codex worker bootstrap failed, falling back to in-process run.', error_3);
2430
2591
  codexClient = getAssistantCodexClient();
2431
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2592
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2432
2593
  case 8: return [2 /*return*/, _a.sent()];
2433
2594
  case 9: return [2 /*return*/];
2434
2595
  }
2435
2596
  });
2436
2597
  });
2437
2598
  }
2438
- function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config) {
2599
+ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler) {
2439
2600
  return __awaiter(this, void 0, void 0, function () {
2440
2601
  var sanitizedOptions, worker, wrapped, timeoutMs, timeoutController, timeoutPromise, messagePromise, errorPromise, exitPromise, outcome, wrapped;
2441
2602
  var _this = this;
@@ -2449,7 +2610,8 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2449
2610
  workerData: {
2450
2611
  prompt: prompt,
2451
2612
  runOptions: sanitizedOptions,
2452
- config: config
2613
+ config: config,
2614
+ streamStatus: !!streamStatusHandler
2453
2615
  }
2454
2616
  });
2455
2617
  }
@@ -2483,12 +2645,12 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2483
2645
  });
2484
2646
  }); })();
2485
2647
  messagePromise = (function () { return __awaiter(_this, void 0, void 0, function () {
2486
- var _a, message;
2487
- return __generator(this, function (_b) {
2488
- switch (_b.label) {
2489
- case 0: return [4 /*yield*/, (0, events_1.once)(worker, 'message')];
2648
+ var message;
2649
+ return __generator(this, function (_a) {
2650
+ switch (_a.label) {
2651
+ case 0: return [4 /*yield*/, waitForCodexWorkerMessage(worker, streamStatusHandler)];
2490
2652
  case 1:
2491
- _a = __read.apply(void 0, [_b.sent(), 1]), message = _a[0];
2653
+ message = _a.sent();
2492
2654
  return [2 /*return*/, { type: 'message', message: message }];
2493
2655
  }
2494
2656
  });
@@ -2524,7 +2686,6 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2524
2686
  return [3 /*break*/, 4];
2525
2687
  case 3:
2526
2688
  timeoutController.abort();
2527
- worker.removeAllListeners('message');
2528
2689
  worker.removeAllListeners('error');
2529
2690
  worker.removeAllListeners('exit');
2530
2691
  return [7 /*endfinally*/];
@@ -2730,7 +2891,7 @@ function normalizeRouteMatchKey(value) {
2730
2891
  return normalizeRouteKey(value).toLowerCase();
2731
2892
  }
2732
2893
  function buildClientRouteIndex() {
2733
- var e_2, _a;
2894
+ var e_3, _a;
2734
2895
  var _b;
2735
2896
  var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
2736
2897
  var set = new Set();
@@ -2749,12 +2910,12 @@ function buildClientRouteIndex() {
2749
2910
  }
2750
2911
  }
2751
2912
  }
2752
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2913
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2753
2914
  finally {
2754
2915
  try {
2755
2916
  if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
2756
2917
  }
2757
- finally { if (e_2) throw e_2.error; }
2918
+ finally { if (e_3) throw e_3.error; }
2758
2919
  }
2759
2920
  return { set: set, map: map, size: routes.length };
2760
2921
  }
@@ -2877,7 +3038,7 @@ function sanitizeAssistantResponse(value) {
2877
3038
  return normalizeAssistantRoutes(cleaned);
2878
3039
  }
2879
3040
  function evaluateAssistantGuardrails(message) {
2880
- var e_3, _a;
3041
+ var e_4, _a;
2881
3042
  var normalized = String(message || '').toLowerCase();
2882
3043
  var patterns = [
2883
3044
  {
@@ -2923,12 +3084,12 @@ function evaluateAssistantGuardrails(message) {
2923
3084
  }
2924
3085
  }
2925
3086
  }
2926
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3087
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2927
3088
  finally {
2928
3089
  try {
2929
3090
  if (patterns_1_1 && !patterns_1_1.done && (_a = patterns_1.return)) _a.call(patterns_1);
2930
3091
  }
2931
- finally { if (e_3) throw e_3.error; }
3092
+ finally { if (e_4) throw e_4.error; }
2932
3093
  }
2933
3094
  return null;
2934
3095
  }
@@ -3092,8 +3253,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
3092
3253
  }
3093
3254
  function readAttachmentContents(attachments) {
3094
3255
  return __awaiter(this, void 0, void 0, function () {
3095
- var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_4_1;
3096
- var e_4, _b;
3256
+ var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_5_1;
3257
+ var e_5, _b;
3097
3258
  return __generator(this, function (_c) {
3098
3259
  switch (_c.label) {
3099
3260
  case 0:
@@ -3172,14 +3333,14 @@ function readAttachmentContents(attachments) {
3172
3333
  return [3 /*break*/, 2];
3173
3334
  case 10: return [3 /*break*/, 13];
3174
3335
  case 11:
3175
- e_4_1 = _c.sent();
3176
- e_4 = { error: e_4_1 };
3336
+ e_5_1 = _c.sent();
3337
+ e_5 = { error: e_5_1 };
3177
3338
  return [3 /*break*/, 13];
3178
3339
  case 12:
3179
3340
  try {
3180
3341
  if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
3181
3342
  }
3182
- finally { if (e_4) throw e_4.error; }
3343
+ finally { if (e_5) throw e_5.error; }
3183
3344
  return [7 /*endfinally*/];
3184
3345
  case 13: return [2 /*return*/, {
3185
3346
  promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
@@ -3356,7 +3517,7 @@ function estimateUsage(messages, responseText, model) {
3356
3517
  };
3357
3518
  }
3358
3519
  function evaluateGuardrails(message) {
3359
- var e_5, _a;
3520
+ var e_6, _a;
3360
3521
  var normalized = String(message || '').toLowerCase();
3361
3522
  var patterns = [
3362
3523
  { pattern: /\b(source\s*code|full\s*code|entire\s*code|repo\s*dump|repository|git\s*clone)\b/i, reason: 'Code access is restricted.' },
@@ -3378,12 +3539,12 @@ function evaluateGuardrails(message) {
3378
3539
  }
3379
3540
  }
3380
3541
  }
3381
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
3542
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
3382
3543
  finally {
3383
3544
  try {
3384
3545
  if (patterns_2_1 && !patterns_2_1.done && (_a = patterns_2.return)) _a.call(patterns_2);
3385
3546
  }
3386
- finally { if (e_5) throw e_5.error; }
3547
+ finally { if (e_6) throw e_6.error; }
3387
3548
  }
3388
3549
  return null;
3389
3550
  }