@resolveio/server-lib 20.14.47 → 20.15.0

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;
@@ -135,10 +142,8 @@ var AI_ASSISTANT_DISPLAY_MAX_COLUMNS = 12;
135
142
  var AI_ASSISTANT_DISPLAY_PREVIEW_MAX_ROWS = 20;
136
143
  var AI_ASSISTANT_DISPLAY_STRING_LIMIT = 160;
137
144
  var AI_ASSISTANT_PROGRESS_PLACEHOLDER = 'Thinking...';
138
- var AI_ASSISTANT_PROGRESS_TICK_MS = 8000;
145
+ var AI_ASSISTANT_PROGRESS_TICK_MS = 5000;
139
146
  var AI_ASSISTANT_PROGRESS_TICKS = [
140
- 'Reviewing context',
141
- 'Checking data',
142
147
  'Drafting response'
143
148
  ];
144
149
  var AI_ASSISTANT_DISPLAY_PRIORITY_FIELDS = [
@@ -202,6 +207,7 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
202
207
  '- Do not guess or invent collections/fields. If unsure, verify in the codebase or run a small Mongo read (limit 1-5) to learn the shape.',
203
208
  '- Prefer running a small Mongo read over asking multiple questions.',
204
209
  '- Ask at most one clarifying question only when required to run a query or resolve missing details.',
210
+ '- If a field starts with id_ and refers to another collection, treat it as a foreign key and look up the related record when needed.',
205
211
  '- Use the codebase context to choose correct collections/fields/workflows and use MONGO_READ/MONGO_AGG to answer with real data when needed.',
206
212
  '- For direct questions, answer first. Ask a single follow-up only if required to proceed.',
207
213
  'Data Presentation:',
@@ -565,7 +571,7 @@ function loadAiTerminalMethods(methodManager) {
565
571
  }
566
572
  function executeAiTerminalRun(payload, context) {
567
573
  return __awaiter(this, void 0, void 0, function () {
568
- var input, message, isSuperAdmin, guardrailsEnabled, guardrail, conversation_1, now_1, userMsg, assistantMsg, conversation, now, attachments, attachmentData, config, systemPrompt, userPromptTemplate, userPrompt, historyLimit, history, _a, messages, openaiSettings, client, response, usage, idClient, userDoc, assistantDoc, insertResult;
574
+ var input, message, requestId, isSuperAdmin, guardrailsEnabled, guardrail, conversation_1, now_1, userMsg, assistantMsg, conversation, now, attachments, attachmentData, config, systemPrompt, userPromptTemplate, userPrompt, historyLimit, history, _a, messages, openaiSettings, client, response, usage, idClient, userDoc, assistantDoc, insertResult;
569
575
  return __generator(this, function (_b) {
570
576
  switch (_b.label) {
571
577
  case 0:
@@ -574,6 +580,7 @@ function executeAiTerminalRun(payload, context) {
574
580
  if (!message) {
575
581
  throw new Error('Message is required.');
576
582
  }
583
+ requestId = normalizeOptionalString(input.request_id);
577
584
  return [4 /*yield*/, resolveIsSuperAdmin(context === null || context === void 0 ? void 0 : context.id_user)];
578
585
  case 1:
579
586
  isSuperAdmin = _b.sent();
@@ -589,6 +596,7 @@ function executeAiTerminalRun(payload, context) {
589
596
  id_conversation: conversation_1._id,
590
597
  role: 'user',
591
598
  content: message,
599
+ metadata: requestId ? { request_id: requestId } : undefined,
592
600
  createdAt: now_1,
593
601
  updatedAt: now_1
594
602
  };
@@ -596,10 +604,7 @@ function executeAiTerminalRun(payload, context) {
596
604
  id_conversation: conversation_1._id,
597
605
  role: 'assistant',
598
606
  content: guardrail.response,
599
- metadata: {
600
- blocked: true,
601
- reason: guardrail.reason
602
- },
607
+ metadata: __assign({ blocked: true, reason: guardrail.reason }, (requestId ? { request_id: requestId } : {})),
603
608
  createdAt: now_1,
604
609
  updatedAt: now_1
605
610
  };
@@ -679,6 +684,7 @@ function executeAiTerminalRun(payload, context) {
679
684
  id_conversation: conversation._id,
680
685
  role: 'user',
681
686
  content: message,
687
+ metadata: input.request_id ? { request_id: input.request_id } : undefined,
682
688
  attachments: attachmentData.attachments,
683
689
  createdAt: now,
684
690
  updatedAt: now
@@ -687,6 +693,7 @@ function executeAiTerminalRun(payload, context) {
687
693
  id_conversation: conversation._id,
688
694
  role: 'assistant',
689
695
  content: response.content,
696
+ metadata: input.request_id ? { request_id: input.request_id } : undefined,
690
697
  usage: {
691
698
  model: response.model || openaiSettings.model,
692
699
  input_tokens: usage.inputTokens,
@@ -788,7 +795,7 @@ function executeAiFormPatch(payload, context) {
788
795
  }
789
796
  function executeAiAssistantCodexRun(payload, context) {
790
797
  return __awaiter(this, void 0, void 0, function () {
791
- var input, message, 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;
798
+ 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
799
  var _d, _e;
793
800
  return __generator(this, function (_f) {
794
801
  switch (_f.label) {
@@ -801,6 +808,7 @@ function executeAiAssistantCodexRun(payload, context) {
801
808
  if (!(context === null || context === void 0 ? void 0 : context.id_user)) {
802
809
  throw new Error('Unauthorized.');
803
810
  }
811
+ requestId = normalizeOptionalString(input.request_id);
804
812
  guardrail = evaluateAssistantGuardrails(message);
805
813
  if (!(guardrail === null || guardrail === void 0 ? void 0 : guardrail.blocked)) return [3 /*break*/, 5];
806
814
  return [4 /*yield*/, ensureConversation(input, 'codex')];
@@ -811,6 +819,7 @@ function executeAiAssistantCodexRun(payload, context) {
811
819
  id_conversation: conversation_2._id,
812
820
  role: 'user',
813
821
  content: message,
822
+ metadata: requestId ? { request_id: requestId } : undefined,
814
823
  createdAt: now_2,
815
824
  updatedAt: now_2
816
825
  };
@@ -818,10 +827,7 @@ function executeAiAssistantCodexRun(payload, context) {
818
827
  id_conversation: conversation_2._id,
819
828
  role: 'assistant',
820
829
  content: guardrail.response,
821
- metadata: {
822
- blocked: true,
823
- reason: guardrail.reason
824
- },
830
+ metadata: __assign({ blocked: true, reason: guardrail.reason }, (requestId ? { request_id: requestId } : {})),
825
831
  createdAt: now_2,
826
832
  updatedAt: now_2
827
833
  };
@@ -895,6 +901,7 @@ function executeAiAssistantCodexRun(payload, context) {
895
901
  id_conversation: conversation._id,
896
902
  role: 'user',
897
903
  content: message,
904
+ metadata: requestId ? { request_id: requestId } : undefined,
898
905
  attachments: attachmentData.attachments,
899
906
  createdAt: now,
900
907
  updatedAt: now
@@ -904,11 +911,7 @@ function executeAiAssistantCodexRun(payload, context) {
904
911
  id_conversation: conversation._id,
905
912
  role: 'assistant',
906
913
  content: AI_ASSISTANT_PROGRESS_PLACEHOLDER,
907
- metadata: {
908
- model: resolveCodexModel(),
909
- pending: true,
910
- progress: initialProgress
911
- },
914
+ metadata: __assign(__assign({ model: resolveCodexModel() }, (requestId ? { request_id: requestId } : {})), { pending: true, progress: initialProgress }),
912
915
  createdAt: now,
913
916
  updatedAt: now
914
917
  };
@@ -920,12 +923,13 @@ function executeAiAssistantCodexRun(payload, context) {
920
923
  insertResult = _f.sent();
921
924
  assistantMessageId = (insertResult === null || insertResult === void 0 ? void 0 : insertResult._id) || (insertResult === null || insertResult === void 0 ? void 0 : insertResult.insertedId);
922
925
  progressTracker = createAssistantProgressTracker(assistantMessageId, initialProgress);
926
+ streamProgress = createAssistantStreamProgressHandler(progressTracker);
923
927
  assistantContent = '';
924
928
  toolResult = null;
925
929
  _f.label = 15;
926
930
  case 15:
927
931
  _f.trys.push([15, 30, 31, 32]);
928
- return [4 /*yield*/, runCodexInWorkerThread(prompt, runOptions, codexConfig)];
932
+ return [4 /*yield*/, runCodexInWorkerThread(prompt, runOptions, codexConfig, streamProgress)];
929
933
  case 16:
930
934
  responseText = _f.sent();
931
935
  directive = extractAssistantMongoDirective(responseText);
@@ -933,7 +937,7 @@ function executeAiAssistantCodexRun(payload, context) {
933
937
  assistantContent = sanitizeAssistantResponse(cleanedResponseText);
934
938
  if (!((directive === null || directive === void 0 ? void 0 : directive.payload) && AI_ASSISTANT_TOOL_MAX_STEPS > 0)) return [3 /*break*/, 28];
935
939
  toolRequest = buildAssistantToolRequest(directive, input);
936
- progressTracker.push(directive.type === 'aggregate' ? 'Running Mongo aggregation' : 'Running Mongo read');
940
+ progressTracker.push('Looking up Data');
937
941
  _f.label = 17;
938
942
  case 17:
939
943
  _f.trys.push([17, 26, , 27]);
@@ -950,12 +954,12 @@ function executeAiAssistantCodexRun(payload, context) {
950
954
  toolResponse = _b;
951
955
  toolPayload = buildAssistantToolResultPayload(directive, toolResponse);
952
956
  toolResult = toolPayload.result;
953
- progressTracker.push('Summarizing results');
957
+ progressTracker.push('Drafting response');
954
958
  followupPrompt = buildAssistantCodexToolFollowupPrompt(message, attachmentData.promptText, historyLines.join('\n'), assistantContext, toolPayload.prompt);
955
959
  _f.label = 22;
956
960
  case 22:
957
961
  _f.trys.push([22, 24, , 25]);
958
- return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, runOptions, codexConfig)];
962
+ return [4 /*yield*/, runCodexInWorkerThread(followupPrompt, runOptions, codexConfig, streamProgress)];
959
963
  case 23:
960
964
  followupText = _f.sent();
961
965
  assistantContent = sanitizeAssistantResponse(followupText);
@@ -986,7 +990,7 @@ function executeAiAssistantCodexRun(payload, context) {
986
990
  assistantContent = buildAssistantCodexErrorMessage(null);
987
991
  }
988
992
  finalNow = new Date();
989
- finalMetadata = __assign({ model: resolveCodexModel() }, (toolResult ? { tool_result: toolResult } : {}));
993
+ finalMetadata = __assign(__assign({ model: resolveCodexModel() }, (requestId ? { request_id: requestId } : {})), (toolResult ? { tool_result: toolResult } : {}));
990
994
  finalAssistantDoc = __assign(__assign({}, assistantDoc), { _id: assistantMessageId, content: assistantContent, metadata: finalMetadata, updatedAt: finalNow });
991
995
  if (!assistantMessageId) return [3 /*break*/, 34];
992
996
  return [4 /*yield*/, ai_terminal_message_collection_1.AiTerminalMessages.updateOne({ _id: assistantMessageId }, {
@@ -1385,6 +1389,60 @@ function buildAssistantToolErrorMessage(error, directive, request) {
1385
1389
  }
1386
1390
  return "I couldn't access the requested data. ".concat(routeLine);
1387
1391
  }
1392
+ function deriveAssistantStreamStatus(event) {
1393
+ var _a;
1394
+ if (!event || !event.type) {
1395
+ return null;
1396
+ }
1397
+ if (event.type === 'thread.started' || event.type === 'turn.started') {
1398
+ return 'Reviewing request';
1399
+ }
1400
+ if (event.type === 'turn.completed') {
1401
+ return 'Drafting response';
1402
+ }
1403
+ if (event.type === 'item.started' || event.type === 'item.updated' || event.type === 'item.completed') {
1404
+ var itemType = String(((_a = event === null || event === void 0 ? void 0 : event.item) === null || _a === void 0 ? void 0 : _a.type) || '').trim().toLowerCase();
1405
+ if (!itemType) {
1406
+ return null;
1407
+ }
1408
+ if (itemType === 'mcp_tool_call') {
1409
+ return 'Calling tool';
1410
+ }
1411
+ if (itemType === 'command_execution') {
1412
+ return 'Running command';
1413
+ }
1414
+ if (itemType === 'web_search') {
1415
+ return 'Searching references';
1416
+ }
1417
+ if (itemType === 'file_change') {
1418
+ return 'Drafting response';
1419
+ }
1420
+ if (itemType === 'agent_message') {
1421
+ return 'Drafting response';
1422
+ }
1423
+ if (itemType === 'reasoning') {
1424
+ return 'Analyzing';
1425
+ }
1426
+ }
1427
+ return null;
1428
+ }
1429
+ function createAssistantStreamProgressHandler(progressTracker) {
1430
+ var lastStatus = '';
1431
+ var lastSentAt = 0;
1432
+ return function (status) {
1433
+ var trimmed = normalizeOptionalString(status);
1434
+ if (!trimmed) {
1435
+ return;
1436
+ }
1437
+ var now = Date.now();
1438
+ if (trimmed === lastStatus && now - lastSentAt < 3000) {
1439
+ return;
1440
+ }
1441
+ lastStatus = trimmed;
1442
+ lastSentAt = now;
1443
+ progressTracker.push(trimmed);
1444
+ };
1445
+ }
1388
1446
  function normalizeAssistantProgress(items) {
1389
1447
  var seen = new Set();
1390
1448
  var cleaned = [];
@@ -2404,26 +2462,103 @@ var CodexWorkerBootstrapError = /** @class */ (function (_super) {
2404
2462
  }
2405
2463
  return CodexWorkerBootstrapError;
2406
2464
  }(Error));
2407
- function runCodexInWorkerThread(prompt, runOptions, config) {
2465
+ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
2466
+ var _this = this;
2467
+ if (!streamStatusHandler) {
2468
+ return runOptions;
2469
+ }
2470
+ var existing = runOptions === null || runOptions === void 0 ? void 0 : runOptions.onStreamEvent;
2471
+ return __assign(__assign({}, runOptions), { onStreamEvent: function (event) { return __awaiter(_this, void 0, void 0, function () {
2472
+ var status;
2473
+ return __generator(this, function (_a) {
2474
+ switch (_a.label) {
2475
+ case 0:
2476
+ if (!existing) return [3 /*break*/, 2];
2477
+ return [4 /*yield*/, existing(event)];
2478
+ case 1:
2479
+ _a.sent();
2480
+ _a.label = 2;
2481
+ case 2:
2482
+ status = deriveAssistantStreamStatus(event);
2483
+ if (status) {
2484
+ streamStatusHandler(status);
2485
+ }
2486
+ return [2 /*return*/];
2487
+ }
2488
+ });
2489
+ }); } });
2490
+ }
2491
+ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
2408
2492
  return __awaiter(this, void 0, void 0, function () {
2409
- var codexClient, workerPath, codexClient, error_3, codexClient;
2493
+ var _a, _b, _c, _d, message, payload, status_1, e_2_1;
2494
+ var _e, e_2, _f, _g;
2495
+ return __generator(this, function (_h) {
2496
+ switch (_h.label) {
2497
+ case 0:
2498
+ _h.trys.push([0, 5, 6, 11]);
2499
+ _a = true, _b = __asyncValues((0, events_1.on)(worker, 'message'));
2500
+ _h.label = 1;
2501
+ case 1: return [4 /*yield*/, _b.next()];
2502
+ case 2:
2503
+ if (!(_c = _h.sent(), _e = _c.done, !_e)) return [3 /*break*/, 4];
2504
+ _g = _c.value;
2505
+ _a = false;
2506
+ _d = __read(_g, 1), message = _d[0];
2507
+ payload = message;
2508
+ if ((payload === null || payload === void 0 ? void 0 : payload.type) === 'stream') {
2509
+ status_1 = normalizeOptionalString(payload.status);
2510
+ if (status_1 && streamStatusHandler) {
2511
+ streamStatusHandler(status_1);
2512
+ }
2513
+ return [3 /*break*/, 3];
2514
+ }
2515
+ return [2 /*return*/, payload];
2516
+ case 3:
2517
+ _a = true;
2518
+ return [3 /*break*/, 1];
2519
+ case 4: return [3 /*break*/, 11];
2520
+ case 5:
2521
+ e_2_1 = _h.sent();
2522
+ e_2 = { error: e_2_1 };
2523
+ return [3 /*break*/, 11];
2524
+ case 6:
2525
+ _h.trys.push([6, , 9, 10]);
2526
+ if (!(!_a && !_e && (_f = _b.return))) return [3 /*break*/, 8];
2527
+ return [4 /*yield*/, _f.call(_b)];
2528
+ case 7:
2529
+ _h.sent();
2530
+ _h.label = 8;
2531
+ case 8: return [3 /*break*/, 10];
2532
+ case 9:
2533
+ if (e_2) throw e_2.error;
2534
+ return [7 /*endfinally*/];
2535
+ case 10: return [7 /*endfinally*/];
2536
+ case 11: throw new CodexWorkerBootstrapError('Codex worker exited before completing.');
2537
+ }
2538
+ });
2539
+ });
2540
+ }
2541
+ function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler) {
2542
+ return __awaiter(this, void 0, void 0, function () {
2543
+ var streamedOptions, codexClient, workerPath, codexClient, error_3, codexClient;
2410
2544
  return __generator(this, function (_a) {
2411
2545
  switch (_a.label) {
2412
2546
  case 0:
2547
+ streamedOptions = applyCodexStreamStatusHandler(runOptions, streamStatusHandler);
2413
2548
  if (!!resolveCodexWorkerThreadEnabled()) return [3 /*break*/, 2];
2414
2549
  codexClient = getAssistantCodexClient();
2415
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2550
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2416
2551
  case 1: return [2 /*return*/, _a.sent()];
2417
2552
  case 2: return [4 /*yield*/, resolveCodexWorkerPath()];
2418
2553
  case 3:
2419
2554
  workerPath = _a.sent();
2420
2555
  if (!!workerPath) return [3 /*break*/, 5];
2421
2556
  codexClient = getAssistantCodexClient();
2422
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2557
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2423
2558
  case 4: return [2 /*return*/, _a.sent()];
2424
2559
  case 5:
2425
2560
  _a.trys.push([5, 7, , 9]);
2426
- return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)];
2561
+ return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler)];
2427
2562
  case 6: return [2 /*return*/, _a.sent()];
2428
2563
  case 7:
2429
2564
  error_3 = _a.sent();
@@ -2432,14 +2567,14 @@ function runCodexInWorkerThread(prompt, runOptions, config) {
2432
2567
  }
2433
2568
  console.error('Codex worker bootstrap failed, falling back to in-process run.', error_3);
2434
2569
  codexClient = getAssistantCodexClient();
2435
- return [4 /*yield*/, codexClient.run(prompt, runOptions)];
2570
+ return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
2436
2571
  case 8: return [2 /*return*/, _a.sent()];
2437
2572
  case 9: return [2 /*return*/];
2438
2573
  }
2439
2574
  });
2440
2575
  });
2441
2576
  }
2442
- function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config) {
2577
+ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler) {
2443
2578
  return __awaiter(this, void 0, void 0, function () {
2444
2579
  var sanitizedOptions, worker, wrapped, timeoutMs, timeoutController, timeoutPromise, messagePromise, errorPromise, exitPromise, outcome, wrapped;
2445
2580
  var _this = this;
@@ -2453,7 +2588,8 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2453
2588
  workerData: {
2454
2589
  prompt: prompt,
2455
2590
  runOptions: sanitizedOptions,
2456
- config: config
2591
+ config: config,
2592
+ streamStatus: !!streamStatusHandler
2457
2593
  }
2458
2594
  });
2459
2595
  }
@@ -2487,12 +2623,12 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2487
2623
  });
2488
2624
  }); })();
2489
2625
  messagePromise = (function () { return __awaiter(_this, void 0, void 0, function () {
2490
- var _a, message;
2491
- return __generator(this, function (_b) {
2492
- switch (_b.label) {
2493
- case 0: return [4 /*yield*/, (0, events_1.once)(worker, 'message')];
2626
+ var message;
2627
+ return __generator(this, function (_a) {
2628
+ switch (_a.label) {
2629
+ case 0: return [4 /*yield*/, waitForCodexWorkerMessage(worker, streamStatusHandler)];
2494
2630
  case 1:
2495
- _a = __read.apply(void 0, [_b.sent(), 1]), message = _a[0];
2631
+ message = _a.sent();
2496
2632
  return [2 /*return*/, { type: 'message', message: message }];
2497
2633
  }
2498
2634
  });
@@ -2528,7 +2664,6 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config)
2528
2664
  return [3 /*break*/, 4];
2529
2665
  case 3:
2530
2666
  timeoutController.abort();
2531
- worker.removeAllListeners('message');
2532
2667
  worker.removeAllListeners('error');
2533
2668
  worker.removeAllListeners('exit');
2534
2669
  return [7 /*endfinally*/];
@@ -2734,7 +2869,7 @@ function normalizeRouteMatchKey(value) {
2734
2869
  return normalizeRouteKey(value).toLowerCase();
2735
2870
  }
2736
2871
  function buildClientRouteIndex() {
2737
- var e_2, _a;
2872
+ var e_3, _a;
2738
2873
  var _b;
2739
2874
  var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
2740
2875
  var set = new Set();
@@ -2753,12 +2888,12 @@ function buildClientRouteIndex() {
2753
2888
  }
2754
2889
  }
2755
2890
  }
2756
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2891
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2757
2892
  finally {
2758
2893
  try {
2759
2894
  if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
2760
2895
  }
2761
- finally { if (e_2) throw e_2.error; }
2896
+ finally { if (e_3) throw e_3.error; }
2762
2897
  }
2763
2898
  return { set: set, map: map, size: routes.length };
2764
2899
  }
@@ -2881,7 +3016,7 @@ function sanitizeAssistantResponse(value) {
2881
3016
  return normalizeAssistantRoutes(cleaned);
2882
3017
  }
2883
3018
  function evaluateAssistantGuardrails(message) {
2884
- var e_3, _a;
3019
+ var e_4, _a;
2885
3020
  var normalized = String(message || '').toLowerCase();
2886
3021
  var patterns = [
2887
3022
  {
@@ -2927,12 +3062,12 @@ function evaluateAssistantGuardrails(message) {
2927
3062
  }
2928
3063
  }
2929
3064
  }
2930
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3065
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2931
3066
  finally {
2932
3067
  try {
2933
3068
  if (patterns_1_1 && !patterns_1_1.done && (_a = patterns_1.return)) _a.call(patterns_1);
2934
3069
  }
2935
- finally { if (e_3) throw e_3.error; }
3070
+ finally { if (e_4) throw e_4.error; }
2936
3071
  }
2937
3072
  return null;
2938
3073
  }
@@ -3096,8 +3231,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
3096
3231
  }
3097
3232
  function readAttachmentContents(attachments) {
3098
3233
  return __awaiter(this, void 0, void 0, function () {
3099
- 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;
3100
- var e_4, _b;
3234
+ 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;
3235
+ var e_5, _b;
3101
3236
  return __generator(this, function (_c) {
3102
3237
  switch (_c.label) {
3103
3238
  case 0:
@@ -3176,14 +3311,14 @@ function readAttachmentContents(attachments) {
3176
3311
  return [3 /*break*/, 2];
3177
3312
  case 10: return [3 /*break*/, 13];
3178
3313
  case 11:
3179
- e_4_1 = _c.sent();
3180
- e_4 = { error: e_4_1 };
3314
+ e_5_1 = _c.sent();
3315
+ e_5 = { error: e_5_1 };
3181
3316
  return [3 /*break*/, 13];
3182
3317
  case 12:
3183
3318
  try {
3184
3319
  if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
3185
3320
  }
3186
- finally { if (e_4) throw e_4.error; }
3321
+ finally { if (e_5) throw e_5.error; }
3187
3322
  return [7 /*endfinally*/];
3188
3323
  case 13: return [2 /*return*/, {
3189
3324
  promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
@@ -3360,7 +3495,7 @@ function estimateUsage(messages, responseText, model) {
3360
3495
  };
3361
3496
  }
3362
3497
  function evaluateGuardrails(message) {
3363
- var e_5, _a;
3498
+ var e_6, _a;
3364
3499
  var normalized = String(message || '').toLowerCase();
3365
3500
  var patterns = [
3366
3501
  { 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.' },
@@ -3382,12 +3517,12 @@ function evaluateGuardrails(message) {
3382
3517
  }
3383
3518
  }
3384
3519
  }
3385
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
3520
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
3386
3521
  finally {
3387
3522
  try {
3388
3523
  if (patterns_2_1 && !patterns_2_1.done && (_a = patterns_2.return)) _a.call(patterns_2);
3389
3524
  }
3390
- finally { if (e_5) throw e_5.error; }
3525
+ finally { if (e_6) throw e_6.error; }
3391
3526
  }
3392
3527
  return null;
3393
3528
  }