@vscode/chat-lib 0.0.1 → 0.0.2

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 (391) hide show
  1. package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
  2. package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
  3. package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
  4. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -0
  5. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
  6. package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -0
  7. package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
  8. package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
  9. package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
  10. package/dist/src/_internal/platform/env/common/envService.js +2 -1
  11. package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
  12. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
  13. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
  14. package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
  15. package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
  16. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
  17. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
  18. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
  19. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
  20. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
  21. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
  22. package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
  23. package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
  24. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
  25. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
  26. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
  27. package/dist/src/_internal/vscodeTypes.d.ts +4 -0
  28. package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
  29. package/dist/src/_internal/vscodeTypes.js +5 -1
  30. package/dist/src/_internal/vscodeTypes.js.map +1 -1
  31. package/dist/src/main.d.ts +5 -0
  32. package/dist/src/main.d.ts.map +1 -1
  33. package/dist/src/main.js +12 -0
  34. package/dist/src/main.js.map +1 -1
  35. package/dist/src/package.json +46 -19
  36. package/package.json +3 -6
  37. package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
  38. package/src/_internal/extension/common/constants.ts +0 -90
  39. package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
  40. package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
  41. package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
  42. package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
  43. package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
  44. package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
  45. package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
  46. package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
  47. package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
  48. package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
  49. package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
  50. package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
  51. package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
  52. package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
  53. package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
  54. package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
  55. package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
  56. package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
  57. package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
  58. package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
  59. package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
  60. package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
  61. package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
  62. package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
  63. package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
  64. package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
  65. package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
  66. package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
  67. package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
  68. package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
  69. package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
  70. package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
  71. package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
  72. package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
  73. package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
  74. package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
  75. package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
  76. package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
  77. package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
  78. package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
  79. package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
  80. package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
  81. package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
  82. package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
  83. package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
  84. package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
  85. package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
  86. package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
  87. package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
  88. package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
  89. package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
  90. package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
  91. package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
  92. package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
  93. package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
  94. package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
  95. package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
  96. package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
  97. package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
  98. package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
  99. package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
  100. package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
  101. package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
  102. package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
  103. package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
  104. package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
  105. package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
  106. package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
  107. package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
  108. package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
  109. package/src/_internal/platform/authentication/common/authentication.ts +0 -309
  110. package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
  111. package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
  112. package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
  113. package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
  114. package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
  115. package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
  116. package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
  117. package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
  118. package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
  119. package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
  120. package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
  121. package/src/_internal/platform/chat/common/interactionService.ts +0 -35
  122. package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
  123. package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
  124. package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
  125. package/src/_internal/platform/configuration/common/validator.ts +0 -242
  126. package/src/_internal/platform/diff/common/diffService.ts +0 -41
  127. package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
  128. package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
  129. package/src/_internal/platform/editing/common/abstractText.ts +0 -177
  130. package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
  131. package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
  132. package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
  133. package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
  134. package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
  135. package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
  136. package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
  137. package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
  138. package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
  139. package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
  140. package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
  141. package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
  142. package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
  143. package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
  144. package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
  145. package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
  146. package/src/_internal/platform/env/common/envService.ts +0 -134
  147. package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
  148. package/src/_internal/platform/env/common/packagejson.ts +0 -49
  149. package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
  150. package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
  151. package/src/_internal/platform/git/vscode/git.d.ts +0 -414
  152. package/src/_internal/platform/github/common/githubAPI.ts +0 -44
  153. package/src/_internal/platform/github/common/githubService.ts +0 -87
  154. package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
  155. package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
  156. package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
  157. package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
  158. package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
  159. package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
  160. package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
  161. package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
  162. package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
  163. package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
  164. package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
  165. package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
  166. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
  167. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
  168. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
  169. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
  170. package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
  171. package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
  172. package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
  173. package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
  174. package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
  175. package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
  176. package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
  177. package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
  178. package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
  179. package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
  180. package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
  181. package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
  182. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
  183. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
  184. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
  185. package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
  186. package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
  187. package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
  188. package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
  189. package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
  190. package/src/_internal/platform/log/common/logService.ts +0 -232
  191. package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
  192. package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
  193. package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
  194. package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
  195. package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
  196. package/src/_internal/platform/networking/common/fetch.ts +0 -349
  197. package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
  198. package/src/_internal/platform/networking/common/networking.ts +0 -442
  199. package/src/_internal/platform/networking/common/openai.ts +0 -273
  200. package/src/_internal/platform/networking/node/chatStream.ts +0 -137
  201. package/src/_internal/platform/networking/node/stream.ts +0 -749
  202. package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
  203. package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
  204. package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
  205. package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
  206. package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
  207. package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
  208. package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
  209. package/src/_internal/platform/notebook/common/helpers.ts +0 -212
  210. package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
  211. package/src/_internal/platform/openai/node/fetch.ts +0 -596
  212. package/src/_internal/platform/parser/node/nodes.ts +0 -190
  213. package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
  214. package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
  215. package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
  216. package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
  217. package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
  218. package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
  219. package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
  220. package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
  221. package/src/_internal/platform/thinking/common/thinking.ts +0 -61
  222. package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
  223. package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
  224. package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
  225. package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
  226. package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
  227. package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
  228. package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
  229. package/src/_internal/util/common/anomalyDetection.ts +0 -112
  230. package/src/_internal/util/common/arrays.ts +0 -81
  231. package/src/_internal/util/common/async.ts +0 -155
  232. package/src/_internal/util/common/cache.ts +0 -183
  233. package/src/_internal/util/common/crypto.ts +0 -41
  234. package/src/_internal/util/common/errors.ts +0 -22
  235. package/src/_internal/util/common/globals.d.ts +0 -12
  236. package/src/_internal/util/common/imageUtils.ts +0 -154
  237. package/src/_internal/util/common/languages.ts +0 -940
  238. package/src/_internal/util/common/notebooks.ts +0 -286
  239. package/src/_internal/util/common/result.ts +0 -71
  240. package/src/_internal/util/common/services.ts +0 -43
  241. package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
  242. package/src/_internal/util/common/test/shims/editing.ts +0 -233
  243. package/src/_internal/util/common/test/shims/enums.ts +0 -61
  244. package/src/_internal/util/common/test/shims/l10n.ts +0 -37
  245. package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
  246. package/src/_internal/util/common/test/shims/terminal.ts +0 -33
  247. package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
  248. package/src/_internal/util/common/time.ts +0 -31
  249. package/src/_internal/util/common/tokenizer.ts +0 -30
  250. package/src/_internal/util/common/tracing.ts +0 -52
  251. package/src/_internal/util/common/types.ts +0 -33
  252. package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
  253. package/src/_internal/util/node/worker.ts +0 -130
  254. package/src/_internal/util/vs/base/common/arrays.ts +0 -926
  255. package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
  256. package/src/_internal/util/vs/base/common/assert.ts +0 -89
  257. package/src/_internal/util/vs/base/common/async.ts +0 -2582
  258. package/src/_internal/util/vs/base/common/buffer.ts +0 -501
  259. package/src/_internal/util/vs/base/common/cache.ts +0 -122
  260. package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
  261. package/src/_internal/util/vs/base/common/charCode.ts +0 -452
  262. package/src/_internal/util/vs/base/common/codicons.ts +0 -66
  263. package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
  264. package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
  265. package/src/_internal/util/vs/base/common/collections.ts +0 -156
  266. package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
  267. package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
  268. package/src/_internal/util/vs/base/common/equals.ts +0 -148
  269. package/src/_internal/util/vs/base/common/errors.ts +0 -342
  270. package/src/_internal/util/vs/base/common/event.ts +0 -1782
  271. package/src/_internal/util/vs/base/common/extpath.ts +0 -425
  272. package/src/_internal/util/vs/base/common/filters.ts +0 -928
  273. package/src/_internal/util/vs/base/common/functional.ts +0 -34
  274. package/src/_internal/util/vs/base/common/glob.ts +0 -839
  275. package/src/_internal/util/vs/base/common/hash.ts +0 -326
  276. package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
  277. package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
  278. package/src/_internal/util/vs/base/common/iterator.ts +0 -196
  279. package/src/_internal/util/vs/base/common/lazy.ts +0 -59
  280. package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
  281. package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
  282. package/src/_internal/util/vs/base/common/map.ts +0 -954
  283. package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
  284. package/src/_internal/util/vs/base/common/mime.ts +0 -136
  285. package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
  286. package/src/_internal/util/vs/base/common/network.ts +0 -429
  287. package/src/_internal/util/vs/base/common/numbers.ts +0 -166
  288. package/src/_internal/util/vs/base/common/objects.ts +0 -242
  289. package/src/_internal/util/vs/base/common/observable.ts +0 -10
  290. package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
  291. package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
  292. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
  293. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
  294. package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
  295. package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
  296. package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
  297. package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
  298. package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
  299. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
  300. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
  301. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
  302. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
  303. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
  304. package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
  305. package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
  306. package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
  307. package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
  308. package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
  309. package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
  310. package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
  311. package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
  312. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
  313. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
  314. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
  315. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
  316. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
  317. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
  318. package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
  319. package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
  320. package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
  321. package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
  322. package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
  323. package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
  324. package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
  325. package/src/_internal/util/vs/base/common/path.ts +0 -1591
  326. package/src/_internal/util/vs/base/common/platform.ts +0 -282
  327. package/src/_internal/util/vs/base/common/process.ts +0 -78
  328. package/src/_internal/util/vs/base/common/resources.ts +0 -446
  329. package/src/_internal/util/vs/base/common/sequence.ts +0 -36
  330. package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
  331. package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
  332. package/src/_internal/util/vs/base/common/stream.ts +0 -792
  333. package/src/_internal/util/vs/base/common/strings.ts +0 -1364
  334. package/src/_internal/util/vs/base/common/symbols.ts +0 -11
  335. package/src/_internal/util/vs/base/common/themables.ts +0 -106
  336. package/src/_internal/util/vs/base/common/types.ts +0 -345
  337. package/src/_internal/util/vs/base/common/uint.ts +0 -61
  338. package/src/_internal/util/vs/base/common/uri.ts +0 -752
  339. package/src/_internal/util/vs/base/common/uuid.ts +0 -72
  340. package/src/_internal/util/vs/base-common.d.ts +0 -42
  341. package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
  342. package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
  343. package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
  344. package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
  345. package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
  346. package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
  347. package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
  348. package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
  349. package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
  350. package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
  351. package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
  352. package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
  353. package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
  354. package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
  355. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
  356. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
  357. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
  358. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
  359. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
  360. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
  361. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
  362. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
  363. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
  364. package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
  365. package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
  366. package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
  367. package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
  368. package/src/_internal/util/vs/nls.messages.ts +0 -21
  369. package/src/_internal/util/vs/nls.ts +0 -243
  370. package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
  371. package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
  372. package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
  373. package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
  374. package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
  375. package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
  376. package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
  377. package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
  378. package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
  379. package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
  380. package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
  381. package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
  382. package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
  383. package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
  384. package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
  385. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
  386. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
  387. package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
  388. package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
  389. package/src/_internal/vscodeTypes.ts +0 -100
  390. package/src/main.ts +0 -207
  391. package/src/package.json +0 -4063
@@ -1,442 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- import { RequestMetadata } from '@vscode/copilot-api';
7
- import { Raw } from '@vscode/prompt-tsx';
8
- import type { CancellationToken } from 'vscode';
9
- import { createServiceIdentifier } from '../../../util/common/services';
10
- import { ITokenizer, TokenizerType } from '../../../util/common/tokenizer';
11
- import { AsyncIterableObject } from '../../../util/vs/base/common/async';
12
- import { CancellationError } from '../../../util/vs/base/common/errors';
13
- import { Source } from '../../chat/common/chatMLFetcher';
14
- import type { ChatLocation, ChatResponse } from '../../chat/common/commonTypes';
15
- import { ICAPIClientService } from '../../endpoint/common/capiClient';
16
- import { IDomainService } from '../../endpoint/common/domainService';
17
- import { IEnvService } from '../../env/common/envService';
18
- import { ILogService } from '../../log/common/logService';
19
- import { ITelemetryService, TelemetryProperties } from '../../telemetry/common/telemetry';
20
- import { TelemetryData } from '../../telemetry/common/telemetryData';
21
- import { FinishedCallback, OpenAiFunctionTool, OpenAiResponsesFunctionTool, OptionalChatRequestParams } from './fetch';
22
- import { FetchOptions, IAbortController, IFetcherService, Response } from './fetcherService';
23
- import { ChatCompletion, RawMessageConversionCallback, rawMessageToCAPI } from './openai';
24
-
25
- /**
26
- * Encapsulates all the functionality related to making GET/POST requests using
27
- * different libraries (and in the future, different environments like web vs
28
- * node).
29
- */
30
- export interface IFetcher {
31
- getUserAgentLibrary(): string;
32
- fetch(url: string, options: FetchOptions): Promise<Response>;
33
- disconnectAll(): Promise<unknown>;
34
- makeAbortController(): IAbortController;
35
- isAbortError(e: any): boolean;
36
- isInternetDisconnectedError(e: any): boolean;
37
- isFetcherError(err: any): boolean;
38
- getUserMessageForFetcherError(err: any): string;
39
- }
40
-
41
- export const userAgentLibraryHeader = 'X-VSCode-User-Agent-Library-Version';
42
-
43
- export type ReqHeaders = { [key: string]: string };
44
- /**
45
- * The HeaderContributor provides the interface which allows implmentors
46
- * to decorate a request's `headers` object with additional key / value pairs.
47
- */
48
- export interface HeaderContributor {
49
- contributeHeaderValues(headers: ReqHeaders): void;
50
- }
51
-
52
- // The maximum time to wait for a request to complete.
53
- const requestTimeoutMs = 30 * 1000; // 30 seconds
54
-
55
-
56
- /**
57
- * Rough shape of an endpoint body. A superset of the parameters of any request,
58
- * but provided to at least have rough typings.
59
- */
60
- export interface IEndpointBody {
61
- /** General or completions: */
62
- tools?: (OpenAiFunctionTool | OpenAiResponsesFunctionTool)[];
63
- model?: string;
64
- previous_response_id?: string;
65
- max_tokens?: number;
66
- max_output_tokens?: number;
67
- max_completion_tokens?: number;
68
- temperature?: number;
69
- top_p?: number;
70
- stream?: boolean;
71
- messages?: any[];
72
- n?: number;
73
- reasoning?: { effort?: string; summary?: string };
74
- tool_choice?: OptionalChatRequestParams['tool_choice'] | { type: 'function'; name: string };
75
- top_logprobs?: number;
76
- intent?: boolean;
77
- intent_threshold?: number;
78
- state?: 'enabled';
79
- snippy?: { enabled: boolean };
80
- stream_options?: { include_usage?: boolean };
81
- prompt?: string;
82
- /** Embeddings endpoints only: */
83
- dimensions?: number;
84
- embed?: boolean;
85
- /** Chunking endpoints: */
86
- qos?: any;
87
- content?: string;
88
- path?: string;
89
- local_hashes?: string[];
90
- language_id?: number;
91
- /** docs search */
92
- query?: string;
93
- scopingQuery?: string;
94
- limit?: number;
95
- similarity?: number;
96
- /** Code search: */
97
- scoping_query?: string;
98
-
99
- /** Responses API: */
100
- input?: readonly any[];
101
- truncation?: 'auto' | 'disabled';
102
- include?: ['reasoning.encrypted_content'];
103
- store?: boolean;
104
- }
105
-
106
- export interface IEndpoint {
107
- readonly urlOrRequestMetadata: string | RequestMetadata;
108
- getExtraHeaders?(): Record<string, string>;
109
- interceptBody?(body: IEndpointBody | undefined): void;
110
- acquireTokenizer(): ITokenizer;
111
- readonly modelMaxPromptTokens: number;
112
- readonly name: string;
113
- readonly version: string;
114
- readonly family: string;
115
- readonly tokenizer: TokenizerType;
116
- }
117
-
118
- export function stringifyUrlOrRequestMetadata(urlOrRequestMetadata: string | RequestMetadata): string {
119
- if (typeof urlOrRequestMetadata === 'string') {
120
- return urlOrRequestMetadata;
121
- }
122
- return JSON.stringify(urlOrRequestMetadata);
123
- }
124
-
125
- export interface IMakeChatRequestOptions {
126
- /** The debug name for this request */
127
- debugName: string;
128
- /** The array of chat messages to send */
129
- messages: Raw.ChatMessage[];
130
- // todo
131
- ignoreStatefulMarker?: boolean;
132
- /** Streaming callback for each response part. */
133
- finishedCb: FinishedCallback | undefined;
134
- /** Location where the chat message is being sent. */
135
- location: ChatLocation;
136
- /** Optional source of the chat request */
137
- source?: Source;
138
- /** Additional request options */
139
- requestOptions?: Omit<OptionalChatRequestParams, 'n'>;
140
- /** Indicates if the request was user-initiated */
141
- userInitiatedRequest?: boolean;
142
- /** (CAPI-only) Optional telemetry properties for analytics */
143
- telemetryProperties?: TelemetryProperties;
144
- /** Whether this request is retrying a filtered response */
145
- isFilterRetry?: boolean;
146
- }
147
-
148
- export interface ICreateEndpointBodyOptions extends IMakeChatRequestOptions {
149
- requestId: string;
150
- postOptions: OptionalChatRequestParams;
151
- }
152
-
153
- export interface IChatEndpoint extends IEndpoint {
154
- readonly maxOutputTokens: number;
155
- /** The model ID- this may change and will be `copilot-base` for the base model. Use `family` to switch behavior based on model type. */
156
- readonly model: string;
157
- readonly apiType?: string;
158
- readonly supportsToolCalls: boolean;
159
- readonly supportsVision: boolean;
160
- readonly supportsPrediction: boolean;
161
- readonly showInModelPicker: boolean;
162
- readonly isPremium?: boolean;
163
- readonly multiplier?: number;
164
- readonly restrictedToSkus?: string[];
165
- readonly isDefault: boolean;
166
- readonly isFallback: boolean;
167
- readonly policy: 'enabled' | { terms: string };
168
- /**
169
- * Handles processing of responses from a chat endpoint. Each endpoint can have different response formats.
170
- * @param telemetryService The telemetry service
171
- * @param logService The log service
172
- * @param response The response from the chat endpoint
173
- * @param expectedNumChoices The expected number of choices in the response
174
- * @param finishCallback A finish callback to indicate when the response should be complete
175
- * @param telemetryData GH telemetry data from the originating request, will be extended with request information
176
- * @param cancellationToken A cancellation tokenf for cancelling the request
177
- * @returns An async iterable object of chat completions
178
- */
179
- processResponseFromChatEndpoint(
180
- telemetryService: ITelemetryService,
181
- logService: ILogService,
182
- response: Response,
183
- expectedNumChoices: number,
184
- finishCallback: FinishedCallback,
185
- telemetryData: TelemetryData,
186
- cancellationToken?: CancellationToken
187
- ): Promise<AsyncIterableObject<ChatCompletion>>;
188
-
189
- /**
190
- * Accepts the chat policy for the given endpoint, enabling its usage.
191
- * @returns A promise that resolves to true if the chat policy was accepted, false otherwise.
192
- */
193
- acceptChatPolicy(): Promise<boolean>;
194
-
195
- /**
196
- * Flights a request from the chat endpoint returning a chat response.
197
- * Most of the time this is ChatMLFetcher#fetchOne, but it can be overridden for special cases.
198
- * TODO @lramos15 - Support multiple completions in the future, we don't use this at the moment.
199
- *
200
- * @param userInitiatedRequest Is only applicable to CAPI requests
201
- * @param telemetryProperties An object containing various properties for telemetry, e.g., can contain a field `requestId` that sets the header request ID
202
- */
203
- makeChatRequest(
204
- debugName: string,
205
- messages: Raw.ChatMessage[],
206
- finishedCb: FinishedCallback | undefined,
207
- token: CancellationToken,
208
- location: ChatLocation,
209
- source?: Source,
210
- requestOptions?: Omit<OptionalChatRequestParams, 'n'>,
211
- userInitiatedRequest?: boolean,
212
- telemetryProperties?: TelemetryProperties,
213
- ): Promise<ChatResponse>;
214
-
215
- /**
216
- * Flights a request from the chat endpoint returning a chat response.
217
- * Most of the time this is ChatMLFetcher#fetchOne, but it can be overridden for special cases.
218
- */
219
- makeChatRequest2(options: IMakeChatRequestOptions, token: CancellationToken): Promise<ChatResponse>;
220
-
221
- /**
222
- * Creates the request body to be sent to the endpoint based on the request.
223
- */
224
- createRequestBody(options: ICreateEndpointBodyOptions): IEndpointBody;
225
-
226
- cloneWithTokenOverride(modelMaxPromptTokens: number): IChatEndpoint;
227
- }
228
-
229
- /** Function to create a standard request body for CAPI completions */
230
- export function createCapiRequestBody(options: ICreateEndpointBodyOptions, model: string, callback?: RawMessageConversionCallback) {
231
- // FIXME@ulugbekna: need to investigate why language configs have such stop words, eg
232
- // python has `\ndef` and `\nclass` which must be stop words for ghost text
233
- // const stops = getLanguageConfig<string[]>(accessor, ConfigKey.Stops);
234
-
235
- const request: IEndpointBody = {
236
- messages: rawMessageToCAPI(options.messages, callback),
237
- model,
238
- // stop: stops,
239
- };
240
-
241
- if (options.postOptions) {
242
- Object.assign(request, options.postOptions);
243
- }
244
-
245
- return request;
246
- }
247
-
248
- function networkRequest(
249
- fetcher: IFetcher,
250
- envService: IEnvService,
251
- telemetryService: ITelemetryService,
252
- domainService: IDomainService,
253
- capiClientService: ICAPIClientService,
254
- requestType: 'GET' | 'POST',
255
- endpointOrUrl: IEndpoint | string | RequestMetadata,
256
- secretKey: string,
257
- hmac: string | undefined,
258
- intent: string,
259
- requestId: string,
260
- body?: IEndpointBody,
261
- additionalHeaders?: Record<string, string>,
262
- cancelToken?: CancellationToken
263
- ): Promise<Response> {
264
- // TODO @lramos15 Eventually don't even construct this fake endpoint object.
265
- const endpoint = typeof endpointOrUrl === 'string' || 'type' in endpointOrUrl ? {
266
- modelMaxPromptTokens: 0,
267
- urlOrRequestMetadata: endpointOrUrl,
268
- family: '',
269
- tokenizer: TokenizerType.O200K,
270
- acquireTokenizer: () => {
271
- throw new Error('Method not implemented.');
272
- },
273
- name: '',
274
- version: '',
275
- } satisfies IEndpoint : endpointOrUrl;
276
- const headers: ReqHeaders = {
277
- Authorization: `Bearer ${secretKey}`,
278
- 'X-Request-Id': requestId,
279
- 'X-Interaction-Type': intent,
280
- 'OpenAI-Intent': intent, // Tells CAPI who flighted this request. Helps find buggy features
281
- 'X-GitHub-Api-Version': '2025-05-01',
282
- ...additionalHeaders,
283
- ...(endpoint.getExtraHeaders ? endpoint.getExtraHeaders() : {}),
284
- };
285
-
286
- if (endpoint.interceptBody) {
287
- endpoint.interceptBody(body);
288
- }
289
-
290
- const request: FetchOptions = {
291
- method: requestType,
292
- headers: headers,
293
- json: body,
294
- timeout: requestTimeoutMs,
295
- };
296
-
297
- if (cancelToken) {
298
- const abort = fetcher.makeAbortController();
299
- cancelToken.onCancellationRequested(() => {
300
- // abort the request when the token is canceled
301
- telemetryService.sendGHTelemetryEvent('networking.cancelRequest', {
302
- headerRequestId: requestId,
303
- });
304
- abort.abort();
305
- });
306
- // pass the controller abort signal to the request
307
- request.signal = abort.signal;
308
- }
309
- if (typeof endpoint.urlOrRequestMetadata === 'string') {
310
- const requestPromise = fetcher.fetch(endpoint.urlOrRequestMetadata, request).catch(reason => {
311
- if (canRetryOnceNetworkError(reason)) {
312
- // disconnect and retry the request once if the connection was reset
313
- telemetryService.sendGHTelemetryEvent('networking.disconnectAll');
314
- return fetcher.disconnectAll().then(() => {
315
- return fetcher.fetch(endpoint.urlOrRequestMetadata as string, request);
316
- });
317
- } else if (fetcher.isAbortError(reason)) {
318
- throw new CancellationError();
319
- } else {
320
- throw reason;
321
- }
322
- });
323
- return requestPromise;
324
- } else {
325
- return capiClientService.makeRequest(request, endpoint.urlOrRequestMetadata as RequestMetadata);
326
- }
327
- }
328
-
329
- export function canRetryOnceNetworkError(reason: any) {
330
- return [
331
- 'ECONNRESET',
332
- 'ETIMEDOUT',
333
- 'ERR_NETWORK_CHANGED',
334
- 'ERR_HTTP2_INVALID_SESSION',
335
- 'ERR_HTTP2_STREAM_CANCEL',
336
- 'ERR_HTTP2_GOAWAY_SESSION',
337
- 'ERR_HTTP2_PROTOCOL_ERROR',
338
- ].includes(reason?.code);
339
- }
340
-
341
- export function postRequest(
342
- fetcherService: IFetcherService,
343
- envService: IEnvService,
344
- telemetryService: ITelemetryService,
345
- domainService: IDomainService,
346
- capiClientService: ICAPIClientService,
347
- endpointOrUrl: IEndpoint | string | RequestMetadata,
348
- secretKey: string,
349
- hmac: string | undefined,
350
- intent: string,
351
- requestId: string,
352
- body?: IEndpointBody,
353
- additionalHeaders?: Record<string, string>,
354
- cancelToken?: CancellationToken
355
- ): Promise<Response> {
356
- return networkRequest(fetcherService,
357
- envService,
358
- telemetryService,
359
- domainService,
360
- capiClientService,
361
- 'POST',
362
- endpointOrUrl,
363
- secretKey,
364
- hmac,
365
- intent,
366
- requestId,
367
- body,
368
- additionalHeaders,
369
- cancelToken
370
- );
371
- }
372
-
373
- export function getRequest(
374
- fetcherService: IFetcher,
375
- envService: IEnvService,
376
- telemetryService: ITelemetryService,
377
- domainService: IDomainService,
378
- capiClientService: ICAPIClientService,
379
- endpointOrUrl: IEndpoint | string | RequestMetadata,
380
- secretKey: string,
381
- hmac: string | undefined,
382
- intent: string,
383
- requestId: string,
384
- body?: IEndpointBody,
385
- additionalHeaders?: Record<string, string>,
386
- cancelToken?: CancellationToken
387
- ): Promise<Response> {
388
- return networkRequest(fetcherService,
389
- envService,
390
- telemetryService,
391
- domainService,
392
- capiClientService,
393
- 'GET',
394
- endpointOrUrl,
395
- secretKey,
396
- hmac,
397
- intent,
398
- requestId,
399
- body,
400
- additionalHeaders,
401
- cancelToken
402
- );
403
- }
404
-
405
- export const IHeaderContributors = createServiceIdentifier<HeaderContributors>('headerContributors');
406
-
407
- export interface IHeaderContributors {
408
- readonly _serviceBrand: undefined;
409
- add(contributor: HeaderContributor): void;
410
- remove(contributor: HeaderContributor): void;
411
- contributeHeaders(headers: ReqHeaders): void;
412
- size(): number;
413
- }
414
-
415
- export class HeaderContributors implements IHeaderContributors {
416
- declare readonly _serviceBrand: undefined;
417
- private readonly contributors: HeaderContributor[] = [];
418
-
419
- add(contributor: HeaderContributor) {
420
- this.contributors.push(contributor);
421
- }
422
-
423
- remove(contributor: HeaderContributor) {
424
- const index = this.contributors.indexOf(contributor);
425
-
426
- if (index === -1) {
427
- return;
428
- }
429
-
430
- this.contributors.splice(index, 1);
431
- }
432
-
433
- contributeHeaders(headers: ReqHeaders) {
434
- for (const contributor of this.contributors) {
435
- contributor.contributeHeaderValues(headers);
436
- }
437
- }
438
-
439
- size() {
440
- return this.contributors.length;
441
- }
442
- }
@@ -1,273 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- import { OpenAI, OutputMode, Raw, toMode } from '@vscode/prompt-tsx';
7
- import { ChatCompletionContentPartKind } from '@vscode/prompt-tsx/dist/base/output/rawTypes';
8
- import { rawPartAsThinkingData } from '../../endpoint/common/thinkingDataContainer';
9
- import { TelemetryData } from '../../telemetry/common/telemetryData';
10
- import { ThinkingData, ThinkingDataInMessage } from '../../thinking/common/thinking';
11
- import { ICopilotReference, RequestId } from './fetch';
12
-
13
- /**
14
- * How the logprobs field looks in the OpenAI API chunks.
15
- */
16
- export interface APILogprobs {
17
- text_offset: number[];
18
- token_logprobs: number[];
19
- top_logprobs?: { [key: string]: number }[];
20
- tokens: string[];
21
- }
22
-
23
- /**
24
- * Usage statistics for the completion request.
25
- */
26
- export interface APIUsage {
27
- /**
28
- * Number of tokens in the prompt.
29
- */
30
- prompt_tokens: number;
31
- /**
32
- * Number of tokens in the generated completion.
33
- */
34
- completion_tokens: number;
35
- /**
36
- * Total number of tokens used in the request (prompt + completion).
37
- */
38
- total_tokens: number;
39
- /**
40
- * Breakdown of tokens used in the prompt.
41
- */
42
- prompt_tokens_details?: {
43
- cached_tokens: number;
44
- };
45
- /**
46
- * Breakdown of tokens used in a completion.
47
- *
48
- * @remark it's an optional field because Copilot Proxy returns this information but not CAPI as of 18 Jun 2025
49
- */
50
- completion_tokens_details?: {
51
- /**
52
- * Tokens generated by the model for reasoning.
53
- */
54
- reasoning_tokens: number;
55
- /**
56
- * When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
57
- */
58
- accepted_prediction_tokens: number;
59
- /**
60
- * When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion.
61
- * However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing,
62
- * output, and context window limits.
63
- */
64
- rejected_prediction_tokens: number;
65
- };
66
- }
67
-
68
- export function isApiUsage(obj: unknown): obj is APIUsage {
69
- return typeof (obj as APIUsage).prompt_tokens === 'number' &&
70
- typeof (obj as APIUsage).completion_tokens === 'number' &&
71
- typeof (obj as APIUsage).total_tokens === 'number';
72
- }
73
-
74
-
75
- export interface APIJsonData {
76
- text: string;
77
- /* Joining this together produces `text`, due to the way the proxy works. */
78
- tokens: readonly string[];
79
- /* These are only generated in certain situations. */
80
- logprobs?: APILogprobs;
81
- }
82
-
83
- export interface APIErrorResponse {
84
- code: number;
85
- message: string;
86
- metadata?: Record<string, any>;
87
- }
88
-
89
-
90
- export enum ChatRole {
91
- System = 'system',
92
- User = 'user',
93
- Assistant = 'assistant',
94
- Function = 'function',
95
- Tool = 'tool'
96
- }
97
-
98
-
99
- export type CAPIChatMessage = OpenAI.ChatMessage & {
100
- /**
101
- * CAPI references used in this message.
102
- */
103
- copilot_references?: ICopilotReference[];
104
- /**
105
- * CAPI confirmations used in this message.
106
- */
107
- copilot_confirmations?: { state: string; confirmation: any }[];
108
-
109
- copilot_cache_control?: {
110
- 'type': 'ephemeral';
111
- };
112
- } & ThinkingDataInMessage;
113
-
114
- export function getCAPITextPart(content: string | OpenAI.ChatCompletionContentPart[] | OpenAI.ChatCompletionContentPart): string {
115
- if (Array.isArray(content)) {
116
- return content.map((part) => getCAPITextPart(part)).join('');
117
- } else if (typeof content === 'string') {
118
- return content;
119
- } else if (typeof content === 'object' && 'text' in content) {
120
- return content.text;
121
- } else {
122
- return '';
123
- }
124
- }
125
-
126
- export type RawMessageConversionCallback = (message: CAPIChatMessage, thinkingData?: ThinkingData) => void;
127
- /**
128
- * Converts a raw TSX chat message to CAPI's format.
129
- *
130
- * **Extra:** the raw message can have `copilot_references` and
131
- * `copilot_confirmations` properties, which are copied to the CAPI message.
132
- */
133
- export function rawMessageToCAPI(message: Raw.ChatMessage, callback?: RawMessageConversionCallback): CAPIChatMessage;
134
- export function rawMessageToCAPI(message: Raw.ChatMessage[], callback?: RawMessageConversionCallback): CAPIChatMessage[];
135
- export function rawMessageToCAPI(message: Raw.ChatMessage[] | Raw.ChatMessage, callback?: RawMessageConversionCallback): CAPIChatMessage | CAPIChatMessage[] {
136
- if (Array.isArray(message)) {
137
- return message.map(m => rawMessageToCAPI(m, callback));
138
- }
139
-
140
- const out: CAPIChatMessage = toMode(OutputMode.OpenAI, message);
141
- if ('copilot_references' in message) {
142
- out.copilot_references = (message as any).copilot_references;
143
- }
144
- if ('copilot_confirmations' in message) {
145
- out.copilot_confirmations = (message as any).copilot_confirmations;
146
- }
147
- if (typeof out.content === 'string') {
148
- out.content = out.content.trimEnd();
149
- } else {
150
- for (const part of out.content) {
151
- if (part.type === 'text') {
152
- part.text = part.text.trimEnd();
153
- }
154
- }
155
- }
156
-
157
- if (message.content.find(part => part.type === ChatCompletionContentPartKind.CacheBreakpoint)) {
158
- out.copilot_cache_control = { type: 'ephemeral' };
159
- }
160
-
161
- for (const content of message.content) {
162
- if (content.type === Raw.ChatCompletionContentPartKind.Opaque) {
163
- const data = rawPartAsThinkingData(content);
164
- if (callback && data) {
165
- callback(out, data);
166
- }
167
- }
168
- }
169
-
170
- return out;
171
- }
172
-
173
- export enum FinishedCompletionReason {
174
- /**
175
- * Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
176
- */
177
- Stop = 'stop',
178
- /**
179
- * Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
180
- */
181
- Length = 'length',
182
- /**
183
- * Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
184
- */
185
- FunctionCall = 'function_call',
186
- /**
187
- * Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
188
- */
189
- ToolCalls = 'tool_calls',
190
- /**
191
- * Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
192
- */
193
- ContentFilter = 'content_filter',
194
- /**
195
- * Reason generated by the server (CAPI). Happens when the stream cannot be completed and the server must terminate the response.
196
- */
197
- ServerError = 'error',
198
- /**
199
- * Reason generated by the client when the finish callback asked for processing to stop.
200
- */
201
- ClientTrimmed = 'client-trimmed',
202
- /**
203
- * Reason generated by the client when we never received a finish_reason for this particular completion (indicates a server-side bug)
204
- */
205
- ClientIterationDone = 'Iteration Done',
206
- /**
207
- * Reason generated by the client when we never received a finish_reason for this particular completion (indicates a server-side bug)
208
- */
209
- ClientDone = 'DONE',
210
- }
211
-
212
- export interface IToolCall {
213
- index: number;
214
- id?: string;
215
- function?: { name: string; arguments: string };
216
- }
217
-
218
- /**
219
- * Contains the possible reasons a response can be filtered
220
- */
221
- export enum FilterReason {
222
- /**
223
- * Content deemed to be hateful
224
- */
225
- Hate = 'hate',
226
- /**
227
- * Content deemed to cause self harm
228
- */
229
- SelfHarm = 'self_harm',
230
- /**
231
- * Content deemed to be sexual in nature
232
- */
233
- Sexual = 'sexual',
234
- /**
235
- * Content deemed to be violent in nature
236
- */
237
- Violence = 'violence',
238
- /**
239
- * Content contains copyrighted material
240
- */
241
- Copyright = 'snippy',
242
- /**
243
- * The prompt was filtered, the reason was not provided
244
- */
245
- Prompt = 'prompt'
246
- }
247
-
248
- export interface ChatCompletion {
249
- message: Raw.ChatMessage;
250
- choiceIndex: number;
251
- requestId: RequestId;
252
- tokens: readonly string[];
253
- usage: APIUsage | undefined;
254
- blockFinished: boolean; // Whether the block completion was determined to be finished
255
- finishReason: FinishedCompletionReason;
256
- filterReason?: FilterReason; // optional filter reason if the completion was filtered
257
- telemetryData: TelemetryData; // optional telemetry data providing background
258
- error?: APIErrorResponse; // optional, error was encountered during the response
259
- }
260
-
261
- export interface ChoiceLogProbs {
262
- content: ChoiceLogProbsContent[];
263
- }
264
-
265
- export interface TokenLogProb {
266
- bytes: number[];
267
- token: string;
268
- logprob: number;
269
- }
270
-
271
- export interface ChoiceLogProbsContent extends TokenLogProb {
272
- top_logprobs: TokenLogProb[];
273
- }