@vscode/chat-lib 0.65.0 → 0.67.2026091415

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.
Files changed (65) hide show
  1. package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +0 -1
  2. package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
  3. package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +2 -6
  4. package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
  5. package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
  6. package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +52 -22
  7. package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
  8. package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts +4 -1
  9. package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts.map +1 -1
  10. package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js +19 -1
  11. package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js.map +1 -1
  12. package/dist/src/_internal/platform/chat/common/commonTypes.d.ts +17 -4
  13. package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
  14. package/dist/src/_internal/platform/chat/common/commonTypes.js +21 -4
  15. package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
  16. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +5 -20
  17. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
  18. package/dist/src/_internal/platform/configuration/common/configurationService.js +5 -20
  19. package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
  20. package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +2 -2
  21. package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
  22. package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +2 -1
  23. package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
  24. package/dist/src/_internal/platform/endpoint/node/messagesApi.js +10 -6
  25. package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
  26. package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts +2 -1
  27. package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
  28. package/dist/src/_internal/platform/endpoint/node/responsesApi.js +7 -5
  29. package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
  30. package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
  31. package/dist/src/_internal/platform/github/common/githubService.js +1 -3
  32. package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
  33. package/dist/src/_internal/platform/inlineEdits/common/utils/utils.d.ts +0 -1
  34. package/dist/src/_internal/platform/inlineEdits/common/utils/utils.d.ts.map +1 -1
  35. package/dist/src/_internal/platform/inlineEdits/common/utils/utils.js +0 -6
  36. package/dist/src/_internal/platform/inlineEdits/common/utils/utils.js.map +1 -1
  37. package/dist/src/_internal/platform/networking/common/fetch.d.ts +12 -0
  38. package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
  39. package/dist/src/_internal/platform/networking/common/fetch.js +24 -0
  40. package/dist/src/_internal/platform/networking/common/fetch.js.map +1 -1
  41. package/dist/src/_internal/platform/networking/common/networking.d.ts +4 -0
  42. package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
  43. package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
  44. package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts +2 -0
  45. package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts.map +1 -1
  46. package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js +12 -0
  47. package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js.map +1 -1
  48. package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts +2 -0
  49. package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts.map +1 -1
  50. package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js +16 -0
  51. package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js.map +1 -1
  52. package/dist/src/_internal/platform/telemetry/common/telemetry.js +1 -1
  53. package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
  54. package/dist/src/_internal/platform/telemetry/common/telemetryData.d.ts.map +1 -1
  55. package/dist/src/_internal/platform/telemetry/common/telemetryData.js +1 -0
  56. package/dist/src/_internal/platform/telemetry/common/telemetryData.js.map +1 -1
  57. package/dist/src/main.d.ts.map +1 -1
  58. package/dist/src/main.js +0 -1
  59. package/dist/src/main.js.map +1 -1
  60. package/dist/src/package.json +4 -23
  61. package/package.json +1 -1
  62. package/dist/src/_internal/platform/inlineEdits/common/dataTypes/jointCompletionsProviderOptions.d.ts +0 -10
  63. package/dist/src/_internal/platform/inlineEdits/common/dataTypes/jointCompletionsProviderOptions.d.ts.map +0 -1
  64. package/dist/src/_internal/platform/inlineEdits/common/dataTypes/jointCompletionsProviderOptions.js +0 -19
  65. package/dist/src/_internal/platform/inlineEdits/common/dataTypes/jointCompletionsProviderOptions.js.map +0 -1
@@ -476,8 +476,10 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
476
476
  parentRequestId: telemetryProperties.parentRequestId,
477
477
  retryAfterError: telemetryProperties.retryAfterError,
478
478
  retryAfterErrorGitHubRequestId: telemetryProperties.retryAfterErrorGitHubRequestId,
479
+ retryAfterErrorCopilotServiceRequestId: telemetryProperties.retryAfterErrorCopilotServiceRequestId,
479
480
  connectivityTestError: telemetryProperties.connectivityTestError,
480
481
  connectivityTestErrorGitHubRequestId: telemetryProperties.connectivityTestErrorGitHubRequestId,
482
+ connectivityTestErrorCopilotServiceRequestId: telemetryProperties.connectivityTestErrorCopilotServiceRequestId,
481
483
  retryAfterFilterCategory: telemetryProperties.retryAfterFilterCategory,
482
484
  fetcher: actualFetcher,
483
485
  suspendEventSeen,
@@ -585,11 +587,11 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
585
587
  if (err.resumeEventSeen) {
586
588
  resumeEventSeen = true;
587
589
  }
588
- const processed = this.processError(err, ourRequestId, err.gitHubRequestId, usernameToScrub, (0, autoChatEndpoint_1.isAutoModel)(chatEndpoint) === 1);
590
+ const processed = this.processError(err, ourRequestId, err.gitHubRequestId, err.copilotServiceRequestId, usernameToScrub, (0, autoChatEndpoint_1.isAutoModel)(chatEndpoint) === 1);
589
591
  const retryNetworkError = enableRetryOnError && processed.type === commonTypes_1.ChatFetchResponseType.NetworkError && this._configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.RetryNetworkErrors, this._experimentationService);
590
592
  const retryWithoutWebSocket = enableRetryOnError && useWebSocket && (processed.type === commonTypes_1.ChatFetchResponseType.NetworkError || processed.type === commonTypes_1.ChatFetchResponseType.Failed);
591
593
  if (retryNetworkError || retryWithoutWebSocket) {
592
- const { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId } = await this._retryAfterError({
594
+ const { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId } = await this._retryAfterError({
593
595
  opts,
594
596
  processed,
595
597
  telemetryProperties,
@@ -615,12 +617,13 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
615
617
  if (retryResult) {
616
618
  return retryResult;
617
619
  }
618
- telemetryProperties = { ...telemetryProperties, connectivityTestError, connectivityTestErrorGitHubRequestId };
620
+ telemetryProperties = { ...telemetryProperties, connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId };
619
621
  }
620
622
  if (processed.type === commonTypes_1.ChatFetchResponseType.Canceled) {
621
623
  chatMLFetcherTelemetry_1.ChatMLFetcherTelemetrySender.sendCancellationTelemetry(this._telemetryService, {
622
624
  source: telemetryProperties.messageSource ?? 'unknown',
623
625
  requestId: ourRequestId,
626
+ copilotServiceRequestId: processed.copilotServiceRequestId,
624
627
  model: chatEndpoint.model,
625
628
  apiType: chatEndpoint.apiType,
626
629
  transport,
@@ -630,8 +633,10 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
630
633
  parentRequestId: telemetryProperties.parentRequestId,
631
634
  retryAfterError: telemetryProperties.retryAfterError,
632
635
  retryAfterErrorGitHubRequestId: telemetryProperties.retryAfterErrorGitHubRequestId,
636
+ retryAfterErrorCopilotServiceRequestId: telemetryProperties.retryAfterErrorCopilotServiceRequestId,
633
637
  connectivityTestError: telemetryProperties.connectivityTestError,
634
638
  connectivityTestErrorGitHubRequestId: telemetryProperties.connectivityTestErrorGitHubRequestId,
639
+ connectivityTestErrorCopilotServiceRequestId: telemetryProperties.connectivityTestErrorCopilotServiceRequestId,
635
640
  retryAfterFilterCategory: telemetryProperties.retryAfterFilterCategory,
636
641
  fetcher: actualFetcher,
637
642
  suspendEventSeen,
@@ -680,6 +685,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
680
685
  const delays = this.connectivityCheckDelays;
681
686
  let connectivityTestError = undefined;
682
687
  let connectivityTestErrorGitHubRequestId = undefined;
688
+ let connectivityTestErrorCopilotServiceRequestId = undefined;
683
689
  for (const delay of delays) {
684
690
  this._logService.info(`Waiting ${delay}ms before pinging CAPI to check network connectivity...`);
685
691
  await new Promise(resolve => setTimeout(resolve, delay));
@@ -694,21 +700,23 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
694
700
  });
695
701
  if (res.status >= 200 && res.status < 300) {
696
702
  this._logService.info(`CAPI ping successful, proceeding with chat request retry...`);
697
- return { retryRequest: true, connectivityTestError, connectivityTestErrorGitHubRequestId };
703
+ return { retryRequest: true, connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId };
698
704
  }
699
705
  else {
700
706
  connectivityTestError = `Status ${res.status}: ${res.statusText}`;
701
707
  connectivityTestErrorGitHubRequestId = res.headers.get('x-github-request-id') ?? '';
708
+ connectivityTestErrorCopilotServiceRequestId = (0, fetch_1.getCopilotServiceRequestId)(res.headers);
702
709
  this._logService.info(`CAPI ping returned status ${res.status}, retrying ping...`);
703
710
  }
704
711
  }
705
712
  catch (err) {
706
713
  connectivityTestError = (0, logService_1.collectSingleLineErrorMessage)(err, true);
707
714
  connectivityTestErrorGitHubRequestId = undefined; // no response headers yet
715
+ connectivityTestErrorCopilotServiceRequestId = undefined; // no response headers yet
708
716
  this._logService.info(`CAPI ping failed with error, retrying ping: ${connectivityTestError}`);
709
717
  }
710
718
  }
711
- return { retryRequest: false, connectivityTestError, connectivityTestErrorGitHubRequestId };
719
+ return { retryRequest: false, connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId };
712
720
  }
713
721
  async _getAuthHeaders(isGHEnterprise, url) {
714
722
  const authHeaders = {};
@@ -745,9 +753,10 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
745
753
  const connectivity = await this._checkNetworkConnectivity(useFetcher);
746
754
  const connectivityTestError = connectivity.connectivityTestError ? this.scrubErrorDetail(connectivity.connectivityTestError, usernameToScrub) : undefined;
747
755
  const connectivityTestErrorGitHubRequestId = connectivity.connectivityTestErrorGitHubRequestId;
756
+ const connectivityTestErrorCopilotServiceRequestId = connectivity.connectivityTestErrorCopilotServiceRequestId;
748
757
  if (!connectivity.retryRequest) {
749
758
  this._logService.info(`Not retrying chat request as network connectivity could not be re-established.`);
750
- return { connectivityTestError, connectivityTestErrorGitHubRequestId };
759
+ return { connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId };
751
760
  }
752
761
  chatMLFetcherTelemetry_1.ChatMLFetcherTelemetrySender.sendResponseErrorTelemetry(this._telemetryService, {
753
762
  processed,
@@ -779,8 +788,10 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
779
788
  ...telemetryProperties,
780
789
  retryAfterError: processed.reasonDetail || processed.reason,
781
790
  retryAfterErrorGitHubRequestId: processed.serverRequestId,
791
+ retryAfterErrorCopilotServiceRequestId: processed.copilotServiceRequestId,
782
792
  connectivityTestError,
783
793
  connectivityTestErrorGitHubRequestId,
794
+ connectivityTestErrorCopilotServiceRequestId,
784
795
  },
785
796
  enableRetryOnError: false,
786
797
  useFetcher,
@@ -794,7 +805,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
794
805
  this._webSocketManager.closeConnection(opts.conversationId, opts.webSocketConnectionId);
795
806
  }
796
807
  }
797
- return { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId };
808
+ return { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId };
798
809
  }
799
810
  async _fetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, countTokens, userInitiatedRequest, useWebSocket, turnId, conversationId, webSocketConnectionId, telemetryProperties, useFetcher, canRetryOnce, interactionTypeOverride, summarizedAtRoundId, modeChanged) {
800
811
  const isPowerSaveBlockerEnabled = this._configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.ChatRequestPowerSaveBlocker, this._experimentationService);
@@ -937,6 +948,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
937
948
  }
938
949
  catch (err) {
939
950
  err.gitHubRequestId = connection.gitHubRequestId;
951
+ err.copilotServiceRequestId = connection.copilotServiceRequestId;
940
952
  throw err;
941
953
  }
942
954
  // Generate unique ID to link input and output messages
@@ -978,7 +990,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
978
990
  const requestStart = Date.now();
979
991
  const handle = connection.sendRequest(request, { userInitiated: !!userInitiatedRequest, turnId, requestId: ourRequestId, model: chatEndpointInfo.model, countTokens, tokenCountMax: chatEndpointInfo.maxOutputTokens, modelMaxPromptTokens: chatEndpointInfo.modelMaxPromptTokens, summarizedAtRoundId, modeChanged }, cancellationToken);
980
992
  const extendedBaseTelemetryData = baseTelemetryData.extendedBy({ modelCallId });
981
- const processor = this._instantiationService.createInstance(responsesApi_1.OpenAIResponsesProcessor, extendedBaseTelemetryData, this._telemetryService, modelRequestId.headerRequestId, modelRequestId.gitHubRequestId, modelRequestId.serverExperiments, (0, responsesApi_1.getResponsesApiCompactionThresholdFromBody)(request));
993
+ const processor = this._instantiationService.createInstance(responsesApi_1.OpenAIResponsesProcessor, extendedBaseTelemetryData, this._telemetryService, modelRequestId.headerRequestId, modelRequestId.gitHubRequestId, modelRequestId.copilotServiceRequestId, modelRequestId.serverExperiments, (0, responsesApi_1.getResponsesApiCompactionThresholdFromBody)(request));
982
994
  // Set up streaming first so event listeners are registered before we
983
995
  // await the first event — AsyncIterableObject runs its executor eagerly.
984
996
  const chatCompletions = new async_1.AsyncIterableObject(async (emitter) => {
@@ -1001,11 +1013,13 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1001
1013
  // Mid-stream CAPI error — throw so the caller can handle it
1002
1014
  const error = new Error(`${event.error.message} (${event.error.code})`);
1003
1015
  error.gitHubRequestId = modelRequestId.gitHubRequestId;
1016
+ error.copilotServiceRequestId = modelRequestId.copilotServiceRequestId;
1004
1017
  error.capiWebSocketError = event;
1005
1018
  reject(error);
1006
1019
  });
1007
1020
  handle.onError(error => {
1008
1021
  error.gitHubRequestId = modelRequestId.gitHubRequestId;
1022
+ error.copilotServiceRequestId = modelRequestId.copilotServiceRequestId;
1009
1023
  if ((0, errors_2.isCancellationError)(error)) {
1010
1024
  reject(error);
1011
1025
  return;
@@ -1105,6 +1119,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1105
1119
  const extendedBaseTelemetryData = baseTelemetryData.extendedBy({ modelCallId });
1106
1120
  let chatCompletions;
1107
1121
  const gitHubRequestId = response.headers.get('x-github-request-id') ?? '';
1122
+ const copilotServiceRequestId = (0, fetch_1.getCopilotServiceRequestId)(response.headers);
1108
1123
  try {
1109
1124
  const completions = await chatEndpointInfo.processResponseFromChatEndpoint(this._telemetryService, this._logService, response, nChoices ?? /* OpenAI's default */ 1, finishedCb, extendedBaseTelemetryData, cancellationToken, location);
1110
1125
  chatCompletions = new async_1.AsyncIterableObject(async (emitter) => {
@@ -1116,6 +1131,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1116
1131
  catch (err) {
1117
1132
  err.fetcherId = response.fetcher;
1118
1133
  err.gitHubRequestId = gitHubRequestId;
1134
+ err.copilotServiceRequestId = copilotServiceRequestId;
1119
1135
  err.bytesReceived = response.bytesReceived;
1120
1136
  throw err;
1121
1137
  }
@@ -1124,6 +1140,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1124
1140
  catch (err) {
1125
1141
  err.fetcherId = response.fetcher;
1126
1142
  err.gitHubRequestId = gitHubRequestId;
1143
+ err.copilotServiceRequestId = copilotServiceRequestId;
1127
1144
  err.bytesReceived = response.bytesReceived;
1128
1145
  throw err;
1129
1146
  }
@@ -1497,6 +1514,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1497
1514
  value: successfulCompletions.map(c => (0, globalStringUtils_1.getTextPart)(c.message.content)),
1498
1515
  requestId,
1499
1516
  serverRequestId: successfulCompletions[0].requestId.headerRequestId,
1517
+ copilotServiceRequestId: successfulCompletions[0].requestId.copilotServiceRequestId,
1500
1518
  modelCallId,
1501
1519
  };
1502
1520
  }
@@ -1510,6 +1528,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1510
1528
  value: completions.map(c => (0, globalStringUtils_1.getTextPart)(c.message.content)),
1511
1529
  requestId: requestId,
1512
1530
  serverRequestId: result.requestId.headerRequestId,
1531
+ copilotServiceRequestId: result.requestId.copilotServiceRequestId,
1513
1532
  };
1514
1533
  case openai_1.FinishedCompletionReason.Refusal:
1515
1534
  return {
@@ -1517,6 +1536,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1517
1536
  reason: 'Model declined to respond.',
1518
1537
  requestId: requestId,
1519
1538
  serverRequestId: result.requestId.headerRequestId,
1539
+ copilotServiceRequestId: result.requestId.copilotServiceRequestId,
1520
1540
  };
1521
1541
  case openai_1.FinishedCompletionReason.Length:
1522
1542
  return {
@@ -1524,6 +1544,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1524
1544
  reason: 'Response too long.',
1525
1545
  requestId: requestId,
1526
1546
  serverRequestId: result.requestId.headerRequestId,
1547
+ copilotServiceRequestId: result.requestId.copilotServiceRequestId,
1527
1548
  truncatedValue: (0, globalStringUtils_1.getTextPart)(result.message.content)
1528
1549
  };
1529
1550
  case openai_1.FinishedCompletionReason.ServerError:
@@ -1532,6 +1553,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1532
1553
  reason: 'Server error. Stream terminated',
1533
1554
  requestId: requestId,
1534
1555
  serverRequestId: result.requestId.headerRequestId,
1556
+ copilotServiceRequestId: result.requestId.copilotServiceRequestId,
1535
1557
  streamError: result.error
1536
1558
  };
1537
1559
  }
@@ -1540,6 +1562,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1540
1562
  reason: commonTypes_1.RESPONSE_CONTAINED_NO_CHOICES,
1541
1563
  requestId: requestId,
1542
1564
  serverRequestId: result?.requestId.headerRequestId,
1565
+ copilotServiceRequestId: result?.requestId.copilotServiceRequestId,
1543
1566
  };
1544
1567
  }
1545
1568
  filterImageMessages(messages) {
@@ -1642,47 +1665,48 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1642
1665
  }
1643
1666
  processFailedResponse(response, requestId, isAuto) {
1644
1667
  const serverRequestId = response.modelRequestId?.gitHubRequestId;
1668
+ const copilotServiceRequestId = response.modelRequestId?.copilotServiceRequestId;
1645
1669
  const reason = response.reason;
1646
1670
  if (response.failKind === fetch_2.ChatFailKind.RateLimited) {
1647
- return { type: commonTypes_1.ChatFetchResponseType.RateLimited, reason, requestId, serverRequestId, retryAfter: response.data?.retryAfter, rateLimitKey: (response.data?.rateLimitKey || ''), isAuto, capiError: response.data?.capiError };
1671
+ return { type: commonTypes_1.ChatFetchResponseType.RateLimited, reason, requestId, serverRequestId, copilotServiceRequestId, retryAfter: response.data?.retryAfter, rateLimitKey: (response.data?.rateLimitKey || ''), isAuto, capiError: response.data?.capiError };
1648
1672
  }
1649
1673
  if (response.failKind === fetch_2.ChatFailKind.QuotaExceeded) {
1650
- return { type: commonTypes_1.ChatFetchResponseType.QuotaExceeded, reason, requestId, serverRequestId, retryAfter: response.data?.retryAfter, capiError: response.data?.capiError };
1674
+ return { type: commonTypes_1.ChatFetchResponseType.QuotaExceeded, reason, requestId, serverRequestId, copilotServiceRequestId, retryAfter: response.data?.retryAfter, capiError: response.data?.capiError };
1651
1675
  }
1652
1676
  if (response.failKind === fetch_2.ChatFailKind.OffTopic) {
1653
- return { type: commonTypes_1.ChatFetchResponseType.OffTopic, reason, requestId, serverRequestId };
1677
+ return { type: commonTypes_1.ChatFetchResponseType.OffTopic, reason, requestId, serverRequestId, copilotServiceRequestId };
1654
1678
  }
1655
1679
  if (response.failKind === fetch_2.ChatFailKind.TokenExpiredOrInvalid || response.failKind === fetch_2.ChatFailKind.ClientNotSupported || reason.includes('Bad request: ')) {
1656
- return { type: commonTypes_1.ChatFetchResponseType.BadRequest, reason, requestId, serverRequestId };
1680
+ return { type: commonTypes_1.ChatFetchResponseType.BadRequest, reason, requestId, serverRequestId, copilotServiceRequestId };
1657
1681
  }
1658
1682
  if (response.failKind === fetch_2.ChatFailKind.ServerError) {
1659
- return { type: commonTypes_1.ChatFetchResponseType.Failed, reason, requestId, serverRequestId };
1683
+ return { type: commonTypes_1.ChatFetchResponseType.Failed, reason, requestId, serverRequestId, copilotServiceRequestId };
1660
1684
  }
1661
1685
  if (response.failKind === fetch_2.ChatFailKind.ContentFilter) {
1662
- return { type: commonTypes_1.ChatFetchResponseType.PromptFiltered, reason, category: openai_1.FilterReason.Prompt, requestId, serverRequestId };
1686
+ return { type: commonTypes_1.ChatFetchResponseType.PromptFiltered, reason, category: openai_1.FilterReason.Prompt, requestId, serverRequestId, copilotServiceRequestId };
1663
1687
  }
1664
1688
  if (response.failKind === fetch_2.ChatFailKind.AgentUnauthorized) {
1665
- return { type: commonTypes_1.ChatFetchResponseType.AgentUnauthorized, reason, authorizationUrl: response.data.authorize_url, requestId, serverRequestId };
1689
+ return { type: commonTypes_1.ChatFetchResponseType.AgentUnauthorized, reason, authorizationUrl: response.data.authorize_url, requestId, serverRequestId, copilotServiceRequestId };
1666
1690
  }
1667
1691
  if (response.failKind === fetch_2.ChatFailKind.AgentFailedDependency) {
1668
- return { type: commonTypes_1.ChatFetchResponseType.AgentFailedDependency, reason, requestId, serverRequestId };
1692
+ return { type: commonTypes_1.ChatFetchResponseType.AgentFailedDependency, reason, requestId, serverRequestId, copilotServiceRequestId };
1669
1693
  }
1670
1694
  if (response.failKind === fetch_2.ChatFailKind.ExtensionBlocked) {
1671
1695
  const retryAfter = typeof response.data?.retryAfter === 'number' ? response.data.retryAfter : 300;
1672
- return { type: commonTypes_1.ChatFetchResponseType.ExtensionBlocked, reason, requestId, retryAfter, learnMoreLink: response.data?.learnMoreLink ?? '', serverRequestId };
1696
+ return { type: commonTypes_1.ChatFetchResponseType.ExtensionBlocked, reason, requestId, retryAfter, learnMoreLink: response.data?.learnMoreLink ?? '', serverRequestId, copilotServiceRequestId };
1673
1697
  }
1674
1698
  if (response.failKind === fetch_2.ChatFailKind.NotFound) {
1675
- return { type: commonTypes_1.ChatFetchResponseType.NotFound, reason, requestId, serverRequestId };
1699
+ return { type: commonTypes_1.ChatFetchResponseType.NotFound, reason, requestId, serverRequestId, copilotServiceRequestId };
1676
1700
  }
1677
1701
  if (response.failKind === fetch_2.ChatFailKind.InvalidPreviousResponseId) {
1678
- return { type: commonTypes_1.ChatFetchResponseType.InvalidStatefulMarker, reason, requestId, serverRequestId };
1702
+ return { type: commonTypes_1.ChatFetchResponseType.InvalidStatefulMarker, reason, requestId, serverRequestId, copilotServiceRequestId };
1679
1703
  }
1680
- return { type: commonTypes_1.ChatFetchResponseType.Failed, reason, requestId, serverRequestId };
1704
+ return { type: commonTypes_1.ChatFetchResponseType.Failed, reason, requestId, serverRequestId, copilotServiceRequestId };
1681
1705
  }
1682
- processError(err, requestId, gitHubRequestId, usernameToScrub, isAuto) {
1706
+ processError(err, requestId, gitHubRequestId, copilotServiceRequestId, usernameToScrub, isAuto) {
1683
1707
  const capiWebSocketError = err?.capiWebSocketError;
1684
1708
  if (capiWebSocketError) {
1685
- return this._handleWebSocketError(capiWebSocketError, requestId, gitHubRequestId, isAuto);
1709
+ return { ...this._handleWebSocketError(capiWebSocketError, requestId, gitHubRequestId, isAuto), copilotServiceRequestId };
1686
1710
  }
1687
1711
  const fetcher = this._fetcherService;
1688
1712
  // If we cancelled a network request, we don't want to log an error
@@ -1692,6 +1716,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1692
1716
  reason: 'network request aborted',
1693
1717
  requestId: requestId,
1694
1718
  serverRequestId: gitHubRequestId,
1719
+ copilotServiceRequestId,
1695
1720
  };
1696
1721
  }
1697
1722
  if ((0, errors_2.isCancellationError)(err)) {
@@ -1700,6 +1725,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1700
1725
  reason: 'Got a cancellation error',
1701
1726
  requestId: requestId,
1702
1727
  serverRequestId: gitHubRequestId,
1728
+ copilotServiceRequestId,
1703
1729
  };
1704
1730
  }
1705
1731
  if (err && ((err instanceof Error && err.message === 'Premature close') ||
@@ -1709,6 +1735,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1709
1735
  reason: 'Stream closed prematurely',
1710
1736
  requestId: requestId,
1711
1737
  serverRequestId: gitHubRequestId,
1738
+ copilotServiceRequestId,
1712
1739
  };
1713
1740
  }
1714
1741
  this._logService.error(errors_1.ErrorUtils.fromUnknown(err), `Error on conversation request`);
@@ -1723,6 +1750,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1723
1750
  reasonDetail: scrubbedErrorDetail,
1724
1751
  requestId: requestId,
1725
1752
  serverRequestId: gitHubRequestId,
1753
+ copilotServiceRequestId,
1726
1754
  };
1727
1755
  }
1728
1756
  else if (fetcher.isFetcherError(err)) {
@@ -1733,6 +1761,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1733
1761
  reasonDetail: scrubbedErrorDetail,
1734
1762
  requestId: requestId,
1735
1763
  serverRequestId: gitHubRequestId,
1764
+ copilotServiceRequestId,
1736
1765
  ...(isNetworkProcessCrash ? { isNetworkProcessCrash: true } : {}),
1737
1766
  };
1738
1767
  }
@@ -1743,6 +1772,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
1743
1772
  reasonDetail: scrubbedErrorDetail,
1744
1773
  requestId: requestId,
1745
1774
  serverRequestId: gitHubRequestId,
1775
+ copilotServiceRequestId,
1746
1776
  };
1747
1777
  }
1748
1778
  }