@sourcegraph/cody-web 0.7.3 → 0.7.4
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.
- package/dist/{agent.worker-7dUx4v7q.mjs → agent.worker-CiIPD-tv.mjs} +1185 -1355
- package/dist/agent.worker.js +2 -2
- package/dist/{browser-0yJ2hV_u.mjs → browser-BTzYzFoB.mjs} +3600 -3509
- package/dist/{git-log-BEqqPp3D.mjs → git-log-CKjP84c8.mjs} +2 -2
- package/dist/{index-D_qZ0Ahh.mjs → index-D6VgQlqI.mjs} +2 -2
- package/dist/index.js +69 -85
- package/dist/lib/agent/agent.client.d.ts +1 -1
- package/dist/lib/agent/agent.client.d.ts.map +1 -1
- package/dist/lib/components/use-cody-agent.d.ts +1 -1
- package/dist/lib/components/use-cody-agent.d.ts.map +1 -1
- package/dist/{shell-Dil0VopV.mjs → shell-CvNNoU2J.mjs} +2 -2
- package/dist/style.css +39 -30
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
|
@@ -18,7 +18,7 @@ var __privateWrapper = (obj, member, setter2, getter) => ({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
var _a2, _b, _constructing, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, _c, _d, _e, _constructing2, _f, _g, _max2, _maxSize2, _dispose2, _disposeAfter2, _fetchMethod2, _size2, _calculatedSize2, _keyMap2, _keyList2, _valList2, _next2, _prev2, _head2, _tail2, _free2, _disposed2, _sizes2, _starts2, _ttls2, _hasDispose2, _hasFetchMethod2, _hasDisposeAfter2, _LRUCache_instances2, initializeTTLTracking_fn2, _updateItemAge2, _statusTTL2, _setItemTTL2, _isStale2, initializeSizeTracking_fn2, _removeItemSize2, _addItemSize2, _requireSize2, indexes_fn2, rindexes_fn2, isValidIndex_fn2, evict_fn2, backgroundFetch_fn2, isBackgroundFetch_fn2, connect_fn2, moveToTail_fn2, _root2, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
21
|
-
import { bz as createSubscriber, bA as graphqlClient, bB as logError$2, aV as lodashExports, bC as logDebug$1, bD as isFileURI, w as wrapInActiveSpan, bE as INCLUDE_EVERYTHING_CONTEXT_FILTERS, bF as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, bG as isAbortError, b8 as isError$1, bb as isDefined, bH as onAbort, bI as CHAT_OUTPUT_TOKEN_BUDGET, bk as ModelTag, b3 as CodyIDE, bJ as isEnterpriseUser, b2 as isCodyProUser, bs as CHAT_INPUT_TOKEN_BUDGET, bK as getModelInfo, bL as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, bM as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, g as getDefaultExportFromCjs, bN as pathFunctionsForURI, bO as uriBasename, bP as uriHasPrefix, bQ as isWindows, aL as URI, bR as Utils$1, p as ps, bS as Observable, b5 as commonjsGlobal, bT as fromVSCodeEvent, bU as ClientConfigSingleton, by as PromptString, bV as isCustomModel, bW as recordErrorToSpan, bX as dependentAbortController, bY as addCustomUserAgent, bZ as addTraceparent, b_ as fetch$2, b$ as verifyResponseCode, b7 as cryptoJsExports, c0 as openCtx, c1 as extensionForLanguage, c2 as isSourcegraphToken, c3 as _, c4 as toRangeData, c5 as DOTCOM_URL, c6 as
|
|
21
|
+
import { bz as createSubscriber, bA as graphqlClient, bB as logError$2, aV as lodashExports, bC as logDebug$1, bD as isFileURI, w as wrapInActiveSpan, bE as INCLUDE_EVERYTHING_CONTEXT_FILTERS, bF as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, bG as isAbortError, b8 as isError$1, bb as isDefined, bH as onAbort, bI as CHAT_OUTPUT_TOKEN_BUDGET, bk as ModelTag, b3 as CodyIDE, bJ as isEnterpriseUser, b2 as isCodyProUser, bs as CHAT_INPUT_TOKEN_BUDGET, bK as getModelInfo, bL as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, bM as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, g as getDefaultExportFromCjs, bN as pathFunctionsForURI, bO as uriBasename, bP as uriHasPrefix, bQ as isWindows, aL as URI, bR as Utils$1, p as ps, bS as Observable, b5 as commonjsGlobal, bT as fromVSCodeEvent, bU as ClientConfigSingleton, by as PromptString, bV as isCustomModel, bW as recordErrorToSpan, bX as dependentAbortController, bY as addCustomUserAgent, bZ as addTraceparent, b_ as fetch$2, b$ as verifyResponseCode, b7 as cryptoJsExports, c0 as openCtx, c1 as extensionForLanguage, c2 as isSourcegraphToken, c3 as _, c4 as toRangeData, c5 as DOTCOM_URL, c6 as requireBase64Js, c7 as isDotCom, c8 as NetworkError, c9 as isRateLimitError, ca as isAuthError, cb as offlineModeAuthStatus, cc as unauthenticatedStatus, cd as semver, t as telemetryRecorder, ce as defaultAuthStatus, bt as ACCOUNT_USAGE_URL, cf as SourcegraphGraphQLAPIClient, cg as networkErrorAuthStatus, ch as NoOpTelemetryRecorderProvider, ci as TimestampTelemetryProcessor_1, cj as updateGlobalTelemetryInstances, ck as TelemetryRecorderProvider, cl as telemetryRecorderProvider, cm as convertGitCloneURLToCodebaseName, cn as subscriptionDisposable, d as dedent$1, co as uriExtname, cp as SUPPORTED_URI_SCHEMAS, cq as require$$1$4, cr as dedupeWith$1, cs as getEditorInsertSpaces, ct as TimeoutError, cu as getActiveTraceAndSpanId, cv as isNetworkError$1, cw as trace, bj as isCodyProModel, b6 as CodyTaskState, be as isEqual, cx as getAugmentedNamespace, cy as main$1, cz as setUserAgent, cA as TESTING_TELEMETRY_EXPORTER, cB as dist, bm as isMacOS, bl as CustomCommandType, bx as setDisplayPathEnvInfo, T as TokenCounterUtils, C as ContextItemSource, cC as _root, cD as _baseGetTag, cE as isObjectLike_1, cF as isObject_1, bw as isErrorLike, au as displayPath, cG as DefaultChatCommands, cH as uriParseNameAndExtension, cI as uriDirname, cJ as DefaultEditCommands, an as FILE_CONTEXT_MENTION_PROVIDER, ao as SYMBOL_CONTEXT_MENTION_PROVIDER, ap as REMOTE_REPOSITORY_PROVIDER_URI, cK as promiseFactoryToObservable, cL as webMentionProvidersMetadata, cM as allMentionProvidersMetadata, cN as combineLatest$1, cO as expandToLineRange, am as displayPathBasename, av as displayLineRange, cP as truncateTextNearestLine, cQ as TokenCounter, bq as View, aQ as parseMentionQuery, cR as tracer, bd as isAbortErrorOrSocketHangUp, cS as isContextWindowLimitError, cT as truncatePromptString, cU as inputTextWithoutContextChipsFromPromptEditorState, bc as reformatBotMessageForChat, b1 as hydrateAfterPostMessage, cV as addMessageListenersForExtensionAPI, cW as createMessageAPIForExtension, cX as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, cY as editorStateFromPromptString, cZ as getEditorTabSize$1, bi as pluralize, c_ as AbortError, c$ as getEditorIndentString, b9 as RateLimitError$1, d0 as logResponseHeadersToSpan, d1 as TracedError, d2 as isNodeResponse, d3 as SpanStatusCode, aq as REMOTE_FILE_PROVIDER_URI, as as CURRENT_REPOSITORY_DIRECTORY_PROVIDER_URI, d4 as assertFileURI, ar as REMOTE_DIRECTORY_PROVIDER_URI, at as WEB_PROVIDER_URI, d5 as setOpenCtx, d6 as GIT_OPENCTX_PROVIDER_URI, d7 as ACCOUNT_UPGRADE_URL, aZ as scanForMentionTriggerInUserTextInput, ay as LARGE_FILE_WARNING_LABEL, d8 as GENERAL_HELP_LABEL, d9 as diffLines, da as psDedent, db as languageFromFilename, dc as ProgrammingLanguage, dd as truncatePromptStringStart, de as posixFilePaths, df as CODY_DOC_URL, ba as CODY_FEEDBACK_URL, dg as DISCORD_URL, dh as CODY_SUPPORT_URL, bu as getRelativeChatPeriod, di as SG_BLOG_URL, dj as ACCOUNT_LIMITS_INFO_URL, dk as setLogger, dl as CODY_OLLAMA_DOCS_URL, bv as browser$3 } from "./browser-BTzYzFoB.mjs";
|
|
22
22
|
function _mergeNamespaces(n, m) {
|
|
23
23
|
for (var i = 0; i < m.length; i++) {
|
|
24
24
|
const e = m[i];
|
|
@@ -6635,6 +6635,16 @@ __publicField2(_RE2JS, "DISABLE_UNICODE_GROUPS", 8);
|
|
|
6635
6635
|
*/
|
|
6636
6636
|
__publicField2(_RE2JS, "LONGEST_MATCH", 16);
|
|
6637
6637
|
let RE2JS = _RE2JS;
|
|
6638
|
+
function singletonNotYetSet() {
|
|
6639
|
+
return { instance: null };
|
|
6640
|
+
}
|
|
6641
|
+
function setSingleton(container, instance2) {
|
|
6642
|
+
if (container.instance !== null) {
|
|
6643
|
+
throw new Error("singleton already set");
|
|
6644
|
+
}
|
|
6645
|
+
container.instance = instance2;
|
|
6646
|
+
return instance2;
|
|
6647
|
+
}
|
|
6638
6648
|
var define_process_default$m = { env: {} };
|
|
6639
6649
|
const REFETCH_INTERVAL_MAP = {
|
|
6640
6650
|
durable: {
|
|
@@ -6822,7 +6832,8 @@ function parseContextFilterItem(item) {
|
|
|
6822
6832
|
const filePathPatterns = item.filePathPatterns ? item.filePathPatterns.map((pattern) => RE2JS.compile(pattern)) : void 0;
|
|
6823
6833
|
return { repoNamePattern, filePathPatterns };
|
|
6824
6834
|
}
|
|
6825
|
-
const contextFiltersProvider =
|
|
6835
|
+
const contextFiltersProvider = singletonNotYetSet();
|
|
6836
|
+
setSingleton(contextFiltersProvider, new ContextFiltersProvider());
|
|
6826
6837
|
var CompletionStopReason = /* @__PURE__ */ ((CompletionStopReason2) => {
|
|
6827
6838
|
CompletionStopReason2["StreamingChunk"] = "cody-streaming-chunk";
|
|
6828
6839
|
CompletionStopReason2["RequestAborted"] = "cody-request-aborted";
|
|
@@ -6837,7 +6848,7 @@ function createOllamaClient(ollamaOptions, logger2, logDebug2) {
|
|
|
6837
6848
|
const log2 = logger2 == null ? void 0 : logger2.startCompletion(params, url);
|
|
6838
6849
|
const { signal: signal2 } = abortController;
|
|
6839
6850
|
try {
|
|
6840
|
-
const prompt = await params.prompt.toFilteredString(contextFiltersProvider);
|
|
6851
|
+
const prompt = await params.prompt.toFilteredString(contextFiltersProvider.instance);
|
|
6841
6852
|
const res = await ollama.generate({
|
|
6842
6853
|
model: model2,
|
|
6843
6854
|
prompt,
|
|
@@ -6931,7 +6942,7 @@ async function ollamaChatClient({
|
|
|
6931
6942
|
var _a3;
|
|
6932
6943
|
return {
|
|
6933
6944
|
role: msg.speaker === "human" ? "user" : "assistant",
|
|
6934
|
-
content: await ((_a3 = msg.text) == null ? void 0 : _a3.toFilteredString(contextFiltersProvider)) ?? ""
|
|
6945
|
+
content: await ((_a3 = msg.text) == null ? void 0 : _a3.toFilteredString(contextFiltersProvider.instance)) ?? ""
|
|
6935
6946
|
};
|
|
6936
6947
|
})
|
|
6937
6948
|
);
|
|
@@ -7306,7 +7317,8 @@ const _ModelsService = class _ModelsService {
|
|
|
7306
7317
|
};
|
|
7307
7318
|
__publicField2(_ModelsService, "STORAGE_KEY", "model-preferences");
|
|
7308
7319
|
let ModelsService = _ModelsService;
|
|
7309
|
-
const modelsService =
|
|
7320
|
+
const modelsService = singletonNotYetSet();
|
|
7321
|
+
setSingleton(modelsService, new ModelsService());
|
|
7310
7322
|
function capabilityToUsage(capability) {
|
|
7311
7323
|
switch (capability) {
|
|
7312
7324
|
case "autocomplete":
|
|
@@ -8653,7 +8665,8 @@ class FeatureFlagProvider {
|
|
|
8653
8665
|
}
|
|
8654
8666
|
}
|
|
8655
8667
|
const NO_FLAGS = {};
|
|
8656
|
-
const featureFlagProvider =
|
|
8668
|
+
const featureFlagProvider = singletonNotYetSet();
|
|
8669
|
+
setSingleton(featureFlagProvider, new FeatureFlagProvider(graphqlClient));
|
|
8657
8670
|
function computeIfExistingFlagChanged(oldFlags, newFlags) {
|
|
8658
8671
|
return Object.keys(oldFlags).some((key) => oldFlags[key] !== newFlags[key]);
|
|
8659
8672
|
}
|
|
@@ -10793,7 +10806,7 @@ async function anthropicChatClient({
|
|
|
10793
10806
|
var _a4;
|
|
10794
10807
|
return {
|
|
10795
10808
|
role: msg.speaker === "human" ? "user" : "assistant",
|
|
10796
|
-
content: await ((_a4 = msg.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider)) ?? ""
|
|
10809
|
+
content: await ((_a4 = msg.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider.instance)) ?? ""
|
|
10797
10810
|
};
|
|
10798
10811
|
})
|
|
10799
10812
|
);
|
|
@@ -10839,7 +10852,7 @@ async function useCustomChatClient({
|
|
|
10839
10852
|
logger: logger2,
|
|
10840
10853
|
signal: signal2
|
|
10841
10854
|
}) {
|
|
10842
|
-
const model2 = modelsService.getModelByID(params.model ?? "");
|
|
10855
|
+
const model2 = modelsService.instance.getModelByID(params.model ?? "");
|
|
10843
10856
|
if (!model2 || !isCustomModel(model2)) {
|
|
10844
10857
|
return false;
|
|
10845
10858
|
}
|
|
@@ -10964,7 +10977,7 @@ async function serializePrompts(messages, modelID) {
|
|
|
10964
10977
|
var _a4;
|
|
10965
10978
|
return {
|
|
10966
10979
|
...m,
|
|
10967
|
-
text: await ((_a4 = m.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider))
|
|
10980
|
+
text: await ((_a4 = m.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider.instance))
|
|
10968
10981
|
};
|
|
10969
10982
|
})
|
|
10970
10983
|
);
|
|
@@ -11182,7 +11195,7 @@ function tokensToChars(tokens) {
|
|
|
11182
11195
|
return tokens * CHARACTERS_PER_TOKEN;
|
|
11183
11196
|
}
|
|
11184
11197
|
function getCompletionsModelConfig(modelID) {
|
|
11185
|
-
const provider = modelsService.getModelByID(modelID);
|
|
11198
|
+
const provider = modelsService.instance.getModelByID(modelID);
|
|
11186
11199
|
if (!provider) {
|
|
11187
11200
|
return void 0;
|
|
11188
11201
|
}
|
|
@@ -11203,7 +11216,9 @@ async function constructGeminiChatMessages(messages) {
|
|
|
11203
11216
|
var _a3;
|
|
11204
11217
|
return {
|
|
11205
11218
|
role: msg.speaker === "human" ? "user" : "model",
|
|
11206
|
-
parts: [
|
|
11219
|
+
parts: [
|
|
11220
|
+
{ text: await ((_a3 = msg.text) == null ? void 0 : _a3.toFilteredString(contextFiltersProvider.instance)) ?? "" }
|
|
11221
|
+
]
|
|
11207
11222
|
};
|
|
11208
11223
|
})
|
|
11209
11224
|
)).filter((_2, i, arr) => i !== arr.length - 1 || arr[i].role !== "model");
|
|
@@ -11321,7 +11336,7 @@ async function groqChatClient({
|
|
|
11321
11336
|
var _a4;
|
|
11322
11337
|
return {
|
|
11323
11338
|
role: msg.speaker === "human" ? "user" : "assistant",
|
|
11324
|
-
content: await ((_a4 = msg.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider)) ?? ""
|
|
11339
|
+
content: await ((_a4 = msg.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider.instance)) ?? ""
|
|
11325
11340
|
};
|
|
11326
11341
|
})
|
|
11327
11342
|
),
|
|
@@ -16441,7 +16456,7 @@ class AgentTabGroups {
|
|
|
16441
16456
|
const $schema = "package.schema.json";
|
|
16442
16457
|
const name = "cody-ai";
|
|
16443
16458
|
const displayName = "Cody: AI Coding Assistant with Autocomplete & Chat";
|
|
16444
|
-
const version$1 = "1.32.
|
|
16459
|
+
const version$1 = "1.32.5";
|
|
16445
16460
|
const publisher = "sourcegraph";
|
|
16446
16461
|
const license = "Apache-2.0";
|
|
16447
16462
|
const icon = "resources/cody.png";
|
|
@@ -17844,7 +17859,6 @@ const capabilities = {
|
|
|
17844
17859
|
};
|
|
17845
17860
|
const dependencies = {
|
|
17846
17861
|
"@anthropic-ai/sdk": "^0.20.8",
|
|
17847
|
-
"@mdi/js": "^7.2.96",
|
|
17848
17862
|
"@openctx/provider-linear-issues": "^0.0.6",
|
|
17849
17863
|
"@openctx/vscode-lib": "^0.0.21",
|
|
17850
17864
|
"@opentelemetry/api": "^1.7.0",
|
|
@@ -17853,7 +17867,6 @@ const dependencies = {
|
|
|
17853
17867
|
"@opentelemetry/instrumentation": "^0.45.1",
|
|
17854
17868
|
"@opentelemetry/instrumentation-http": "^0.45.1",
|
|
17855
17869
|
"@opentelemetry/resources": "^1.18.1",
|
|
17856
|
-
"@opentelemetry/sdk-node": "^0.45.1",
|
|
17857
17870
|
"@opentelemetry/sdk-trace-base": "^1.18.1",
|
|
17858
17871
|
"@opentelemetry/sdk-trace-node": "^1.18.1",
|
|
17859
17872
|
"@opentelemetry/semantic-conventions": "^1.18.1",
|
|
@@ -17893,20 +17906,16 @@ const dependencies = {
|
|
|
17893
17906
|
"http-proxy-agent": "^7.0.2",
|
|
17894
17907
|
"https-proxy-agent": "^7.0.4",
|
|
17895
17908
|
ini: "^4.1.2",
|
|
17896
|
-
"isomorphic-fetch": "^3.0.0",
|
|
17897
17909
|
"js-levenshtein": "^1.1.6",
|
|
17898
17910
|
lexical: "^0.17.0",
|
|
17899
17911
|
lodash: "^4.17.21",
|
|
17900
17912
|
lowlight: "^3.1.0",
|
|
17901
17913
|
"lru-cache": "^10.0.0",
|
|
17902
|
-
lucide: "^0.381.0",
|
|
17903
17914
|
"lucide-react": "^0.378.0",
|
|
17904
17915
|
"mac-ca": "^2.0.3",
|
|
17905
17916
|
marked: "^4.0.16",
|
|
17906
17917
|
mkdirp: "^3.0.1",
|
|
17907
17918
|
"os-browserify": "^0.3.0",
|
|
17908
|
-
"parse-git-diff": "^0.0.14",
|
|
17909
|
-
"proxy-agent": "^6.4.0",
|
|
17910
17919
|
"react-markdown": "^9.0.1",
|
|
17911
17920
|
"rehype-highlight": "^6.0.0",
|
|
17912
17921
|
"rehype-sanitize": "^6.0.0",
|
|
@@ -17922,14 +17931,12 @@ const dependencies = {
|
|
|
17922
17931
|
uuid: "^9.0.0",
|
|
17923
17932
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
17924
17933
|
"vscode-uri": "^3.0.8",
|
|
17925
|
-
"web-tree-sitter": "^0.21.0",
|
|
17926
17934
|
"wink-nlp-utils": "^2.1.0"
|
|
17927
17935
|
};
|
|
17928
17936
|
const devDependencies = {
|
|
17929
17937
|
"@google-cloud/pubsub": "^3.7.3",
|
|
17930
17938
|
"@npmcli/promise-spawn": "^7.0.2",
|
|
17931
17939
|
"@playwright/test": "1.44.1",
|
|
17932
|
-
"@pollyjs/adapter": "^6.0.6",
|
|
17933
17940
|
"@pollyjs/adapter-node-http": "^6.0.6",
|
|
17934
17941
|
"@pollyjs/core": "^6.0.6",
|
|
17935
17942
|
"@pollyjs/persister": "^6.0.6",
|
|
@@ -17943,7 +17950,6 @@ const devDependencies = {
|
|
|
17943
17950
|
"@types/glob": "^8.0.0",
|
|
17944
17951
|
"@types/graceful-fs": "^4.1.9",
|
|
17945
17952
|
"@types/ini": "^4.1.0",
|
|
17946
|
-
"@types/isomorphic-fetch": "^0.0.39",
|
|
17947
17953
|
"@types/js-levenshtein": "^1.1.1",
|
|
17948
17954
|
"@types/lodash": "^4.14.195",
|
|
17949
17955
|
"@types/marked": "^5.0.0",
|
|
@@ -17951,7 +17957,6 @@ const devDependencies = {
|
|
|
17951
17957
|
"@types/node-fetch": "^2.6.4",
|
|
17952
17958
|
"@types/npmcli__promise-spawn": "^6.0.3",
|
|
17953
17959
|
"@types/pako": "^2.0.3",
|
|
17954
|
-
"@types/progress": "^2.0.5",
|
|
17955
17960
|
"@types/semver": "^7.5.0",
|
|
17956
17961
|
"@types/signal-exit": "^3.0.4",
|
|
17957
17962
|
"@types/unzipper": "^0.10.7",
|
|
@@ -17961,10 +17966,8 @@ const devDependencies = {
|
|
|
17961
17966
|
"@vscode/test-web": "^0.0.47",
|
|
17962
17967
|
"@vscode/vsce": "^2.22.0",
|
|
17963
17968
|
ajv: "^8.14.0",
|
|
17964
|
-
"ajv-errors": "^3.0.0",
|
|
17965
17969
|
"ajv-formats": "^3.0.1",
|
|
17966
17970
|
"buildkite-test-collector": "^1.7.2",
|
|
17967
|
-
chokidar: "^3.6.0",
|
|
17968
17971
|
concurrently: "^8.2.0",
|
|
17969
17972
|
dedent: "^0.7.0",
|
|
17970
17973
|
express: "^4.18.2",
|
|
@@ -17982,7 +17985,6 @@ const devDependencies = {
|
|
|
17982
17985
|
playwright: "1.44.1",
|
|
17983
17986
|
postcss: "^8.4.38",
|
|
17984
17987
|
"postcss-nested": "^6.0.1",
|
|
17985
|
-
progress: "^2.0.3",
|
|
17986
17988
|
"react-head": "^3.4.2",
|
|
17987
17989
|
"typescript-language-server": "^4.3.3",
|
|
17988
17990
|
ulidx: "^2.3.0",
|
|
@@ -21720,11 +21722,11 @@ class ChatModel {
|
|
|
21720
21722
|
this.messages = messages;
|
|
21721
21723
|
this.customChatTitle = customChatTitle;
|
|
21722
21724
|
this.selectedRepos = selectedRepos;
|
|
21723
|
-
this.contextWindow = modelsService.getContextWindowByID(this.modelID);
|
|
21725
|
+
this.contextWindow = modelsService.instance.getContextWindowByID(this.modelID);
|
|
21724
21726
|
}
|
|
21725
21727
|
updateModel(newModelID) {
|
|
21726
21728
|
this.modelID = newModelID;
|
|
21727
|
-
this.contextWindow = modelsService.getContextWindowByID(this.modelID);
|
|
21729
|
+
this.contextWindow = modelsService.instance.getContextWindowByID(this.modelID);
|
|
21728
21730
|
}
|
|
21729
21731
|
isEmpty() {
|
|
21730
21732
|
return this.messages.length === 0;
|
|
@@ -22817,7 +22819,7 @@ function requireBuffer() {
|
|
|
22817
22819
|
if (hasRequiredBuffer) return buffer;
|
|
22818
22820
|
hasRequiredBuffer = 1;
|
|
22819
22821
|
(function(exports2) {
|
|
22820
|
-
const base64 =
|
|
22822
|
+
const base64 = requireBase64Js();
|
|
22821
22823
|
const ieee7542 = requireIeee754();
|
|
22822
22824
|
const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
22823
22825
|
exports2.Buffer = Buffer2;
|
|
@@ -33543,6 +33545,836 @@ function getOSArch() {
|
|
|
33543
33545
|
arch: arch2
|
|
33544
33546
|
};
|
|
33545
33547
|
}
|
|
33548
|
+
var AccountMenuOptions = /* @__PURE__ */ ((AccountMenuOptions2) => {
|
|
33549
|
+
AccountMenuOptions2["SignOut"] = "Sign Out";
|
|
33550
|
+
AccountMenuOptions2["Manage"] = "Manage Account";
|
|
33551
|
+
AccountMenuOptions2["Switch"] = "Switch Account...";
|
|
33552
|
+
return AccountMenuOptions2;
|
|
33553
|
+
})(AccountMenuOptions || {});
|
|
33554
|
+
async function openAccountMenu(authStatus) {
|
|
33555
|
+
if (!authStatus.authenticated || !authStatus.endpoint) {
|
|
33556
|
+
return;
|
|
33557
|
+
}
|
|
33558
|
+
const isOffline = authStatus.isOfflineMode;
|
|
33559
|
+
const isDotComInstance = isDotCom(authStatus.endpoint) && !isOffline;
|
|
33560
|
+
const displayName2 = authStatus.displayName || authStatus.username;
|
|
33561
|
+
const email = authStatus.primaryEmail || "No Email";
|
|
33562
|
+
const username = authStatus.username || authStatus.displayName;
|
|
33563
|
+
const planDetail = `Plan: ${authStatus.userCanUpgrade ? "Cody Free" : "Cody Pro"}`;
|
|
33564
|
+
const enterpriseDetail = `Enterprise Instance:
|
|
33565
|
+
${authStatus.endpoint}`;
|
|
33566
|
+
const offlineDetail = "Use Cody offline with Ollama";
|
|
33567
|
+
const options = isDotComInstance ? [
|
|
33568
|
+
"Manage Account"
|
|
33569
|
+
/* Manage */
|
|
33570
|
+
] : [];
|
|
33571
|
+
options.push(
|
|
33572
|
+
"Switch Account...",
|
|
33573
|
+
"Sign Out"
|
|
33574
|
+
/* SignOut */
|
|
33575
|
+
);
|
|
33576
|
+
const messageOptions = {
|
|
33577
|
+
modal: true,
|
|
33578
|
+
detail: isOffline ? offlineDetail : isDotComInstance ? planDetail : enterpriseDetail
|
|
33579
|
+
};
|
|
33580
|
+
const online = isDotComInstance ? `Signed in as ${displayName2} (${email})` : `Signed in as @${username}`;
|
|
33581
|
+
const offline = "Offline Mode";
|
|
33582
|
+
const message = isOffline ? offline : online;
|
|
33583
|
+
const option = await window$1.showInformationMessage(message, messageOptions, ...options);
|
|
33584
|
+
switch (option !== void 0) {
|
|
33585
|
+
case (option == null ? void 0 : option.startsWith("Sign Out")):
|
|
33586
|
+
return "Sign Out";
|
|
33587
|
+
case (option == null ? void 0 : option.startsWith("Manage")):
|
|
33588
|
+
return "Manage Account";
|
|
33589
|
+
case (option == null ? void 0 : option.startsWith("Switch")):
|
|
33590
|
+
return "Switch Account...";
|
|
33591
|
+
default:
|
|
33592
|
+
return void 0;
|
|
33593
|
+
}
|
|
33594
|
+
}
|
|
33595
|
+
let runningAuthProgressIndicator = null;
|
|
33596
|
+
function startAuthProgressIndicator() {
|
|
33597
|
+
window$1.withProgress(
|
|
33598
|
+
{
|
|
33599
|
+
location: ProgressLocation.Notification,
|
|
33600
|
+
title: "Signing in to Sourcegraph...",
|
|
33601
|
+
cancellable: true
|
|
33602
|
+
},
|
|
33603
|
+
(progress, token) => {
|
|
33604
|
+
token.onCancellationRequested(() => {
|
|
33605
|
+
runningAuthProgressIndicator = null;
|
|
33606
|
+
});
|
|
33607
|
+
return new Promise((resolve2) => {
|
|
33608
|
+
runningAuthProgressIndicator = resolve2;
|
|
33609
|
+
});
|
|
33610
|
+
}
|
|
33611
|
+
);
|
|
33612
|
+
}
|
|
33613
|
+
function closeAuthProgressIndicator() {
|
|
33614
|
+
runningAuthProgressIndicator == null ? void 0 : runningAuthProgressIndicator();
|
|
33615
|
+
runningAuthProgressIndicator = null;
|
|
33616
|
+
}
|
|
33617
|
+
function newAuthStatus(options) {
|
|
33618
|
+
var _a3;
|
|
33619
|
+
const {
|
|
33620
|
+
isOfflineMode,
|
|
33621
|
+
endpoint,
|
|
33622
|
+
siteHasCodyEnabled,
|
|
33623
|
+
username,
|
|
33624
|
+
authenticated,
|
|
33625
|
+
isDotCom: isDotCom2,
|
|
33626
|
+
siteVersion,
|
|
33627
|
+
userOrganizations
|
|
33628
|
+
} = options;
|
|
33629
|
+
if (isOfflineMode) {
|
|
33630
|
+
return { ...offlineModeAuthStatus, endpoint, username };
|
|
33631
|
+
}
|
|
33632
|
+
if (!authenticated) {
|
|
33633
|
+
return { ...unauthenticatedStatus, endpoint };
|
|
33634
|
+
}
|
|
33635
|
+
const primaryEmail = typeof options.primaryEmail === "string" ? options.primaryEmail : ((_a3 = options.primaryEmail) == null ? void 0 : _a3.email) || "";
|
|
33636
|
+
const requiresVerifiedEmail = isDotCom2;
|
|
33637
|
+
const hasVerifiedEmail = requiresVerifiedEmail && options.hasVerifiedEmail;
|
|
33638
|
+
const isAllowed = !requiresVerifiedEmail || hasVerifiedEmail;
|
|
33639
|
+
return {
|
|
33640
|
+
...options,
|
|
33641
|
+
showInvalidAccessTokenError: false,
|
|
33642
|
+
endpoint,
|
|
33643
|
+
primaryEmail,
|
|
33644
|
+
requiresVerifiedEmail,
|
|
33645
|
+
hasVerifiedEmail,
|
|
33646
|
+
isLoggedIn: siteHasCodyEnabled && authenticated && isAllowed,
|
|
33647
|
+
codyApiVersion: inferCodyApiVersion(siteVersion, isDotCom2),
|
|
33648
|
+
isFireworksTracingEnabled: isDotCom2 && !!(userOrganizations == null ? void 0 : userOrganizations.nodes.find((org) => org.name === "sourcegraph"))
|
|
33649
|
+
};
|
|
33650
|
+
}
|
|
33651
|
+
const countGeneratedCode = (text) => {
|
|
33652
|
+
const codeBlockRegex = /```[\S\s]*?```/g;
|
|
33653
|
+
const codeBlocks = text.match(codeBlockRegex);
|
|
33654
|
+
if (!codeBlocks) {
|
|
33655
|
+
return { charCount: 0, lineCount: 0 };
|
|
33656
|
+
}
|
|
33657
|
+
const count = { lineCount: 0, charCount: 0 };
|
|
33658
|
+
const backticks = "```";
|
|
33659
|
+
for (const block of codeBlocks) {
|
|
33660
|
+
const lines2 = block.split("\n");
|
|
33661
|
+
const codeLines = lines2.filter((line) => !line.startsWith(backticks));
|
|
33662
|
+
const lineCount = codeLines.length;
|
|
33663
|
+
const language = lines2[0].replace(backticks, "");
|
|
33664
|
+
const charCount = block.length - language.length - backticks.length * 2 - 2;
|
|
33665
|
+
count.charCount += charCount;
|
|
33666
|
+
count.lineCount += lineCount;
|
|
33667
|
+
}
|
|
33668
|
+
return count;
|
|
33669
|
+
};
|
|
33670
|
+
function inferCodyApiVersion(version2, isDotCom2) {
|
|
33671
|
+
const parsedVersion = semver.valid(version2);
|
|
33672
|
+
if (isDotCom2) {
|
|
33673
|
+
return 1;
|
|
33674
|
+
}
|
|
33675
|
+
if (parsedVersion == null) {
|
|
33676
|
+
return 1;
|
|
33677
|
+
}
|
|
33678
|
+
if (semver.gte(parsedVersion, "5.4.0")) {
|
|
33679
|
+
return 1;
|
|
33680
|
+
}
|
|
33681
|
+
if (parsedVersion === "0.0.0") {
|
|
33682
|
+
return 1;
|
|
33683
|
+
}
|
|
33684
|
+
return 0;
|
|
33685
|
+
}
|
|
33686
|
+
function getEnterpriseContextWindow(chatModel, configOverwrites) {
|
|
33687
|
+
const { chatModelMaxTokens, smartContextWindow } = configOverwrites;
|
|
33688
|
+
let contextWindow = {
|
|
33689
|
+
input: chatModelMaxTokens ?? CHAT_INPUT_TOKEN_BUDGET,
|
|
33690
|
+
output: getEnterpriseOutputLimit(chatModel)
|
|
33691
|
+
};
|
|
33692
|
+
if (smartContextWindow && isModelWithExtendedContextWindowSupport(chatModel)) {
|
|
33693
|
+
contextWindow = {
|
|
33694
|
+
input: EXTENDED_CHAT_INPUT_TOKEN_BUDGET,
|
|
33695
|
+
output: CHAT_OUTPUT_TOKEN_BUDGET,
|
|
33696
|
+
context: { user: EXTENDED_USER_CONTEXT_TOKEN_BUDGET }
|
|
33697
|
+
};
|
|
33698
|
+
}
|
|
33699
|
+
return applyLocalTokenLimitOverwrite(chatModel, contextWindow);
|
|
33700
|
+
}
|
|
33701
|
+
function applyLocalTokenLimitOverwrite(chatModel, contextWindow) {
|
|
33702
|
+
var _a3;
|
|
33703
|
+
const config = (_a3 = workspace.getConfiguration("cody")) == null ? void 0 : _a3.get("provider.limit.prompt");
|
|
33704
|
+
if (config && config <= contextWindow.input) {
|
|
33705
|
+
return { ...contextWindow, input: config };
|
|
33706
|
+
}
|
|
33707
|
+
if (config) {
|
|
33708
|
+
logDebug$1("getEnterpriseContextWindow", `Invalid token limit configured for ${chatModel}`, config);
|
|
33709
|
+
}
|
|
33710
|
+
return contextWindow;
|
|
33711
|
+
}
|
|
33712
|
+
const modelWithExpandedWindowSubStrings = [
|
|
33713
|
+
"claude-3-opus",
|
|
33714
|
+
"claude-3-sonnet",
|
|
33715
|
+
"claude-3-5-sonnet",
|
|
33716
|
+
"gemini-1.5",
|
|
33717
|
+
"gpt-4o",
|
|
33718
|
+
"gpt-4-turbo"
|
|
33719
|
+
];
|
|
33720
|
+
function isModelWithExtendedContextWindowSupport(chatModel) {
|
|
33721
|
+
return modelWithExpandedWindowSubStrings.some((keyword) => chatModel.toLowerCase().includes(keyword));
|
|
33722
|
+
}
|
|
33723
|
+
function getEnterpriseOutputLimit(model2) {
|
|
33724
|
+
if (model2 && isModelWithExtendedContextWindowSupport(model2)) {
|
|
33725
|
+
return CHAT_OUTPUT_TOKEN_BUDGET;
|
|
33726
|
+
}
|
|
33727
|
+
return ANSWER_TOKENS;
|
|
33728
|
+
}
|
|
33729
|
+
async function syncModels(authStatus) {
|
|
33730
|
+
var _a3, _b2;
|
|
33731
|
+
modelsService.instance.setAuthStatus(authStatus);
|
|
33732
|
+
if (authStatus.isOfflineMode) {
|
|
33733
|
+
modelsService.instance.setModels([]);
|
|
33734
|
+
return;
|
|
33735
|
+
}
|
|
33736
|
+
if (!authStatus.authenticated) {
|
|
33737
|
+
modelsService.instance.setModels([]);
|
|
33738
|
+
return;
|
|
33739
|
+
}
|
|
33740
|
+
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
33741
|
+
if (clientConfig == null ? void 0 : clientConfig.modelsAPIEnabled) {
|
|
33742
|
+
logDebug("ModelsService", "new models API enabled");
|
|
33743
|
+
const serverSideModels = await fetchServerSideModels(authStatus.endpoint || "");
|
|
33744
|
+
if (serverSideModels) {
|
|
33745
|
+
modelsService.instance.setServerSentModels(serverSideModels);
|
|
33746
|
+
registerModelsFromVSCodeConfiguration();
|
|
33747
|
+
return;
|
|
33748
|
+
}
|
|
33749
|
+
}
|
|
33750
|
+
if (authStatus.isDotCom) {
|
|
33751
|
+
modelsService.instance.setModels(getDotComDefaultModels());
|
|
33752
|
+
registerModelsFromVSCodeConfiguration();
|
|
33753
|
+
return;
|
|
33754
|
+
}
|
|
33755
|
+
if ((_a3 = authStatus == null ? void 0 : authStatus.configOverwrites) == null ? void 0 : _a3.chatModel) {
|
|
33756
|
+
modelsService.instance.setModels([
|
|
33757
|
+
new Model({
|
|
33758
|
+
id: authStatus.configOverwrites.chatModel,
|
|
33759
|
+
// TODO (umpox) Add configOverwrites.editModel for separate edit support
|
|
33760
|
+
usage: [ModelUsage.Chat, ModelUsage.Edit],
|
|
33761
|
+
contextWindow: getEnterpriseContextWindow(
|
|
33762
|
+
(_b2 = authStatus == null ? void 0 : authStatus.configOverwrites) == null ? void 0 : _b2.chatModel,
|
|
33763
|
+
authStatus == null ? void 0 : authStatus.configOverwrites
|
|
33764
|
+
),
|
|
33765
|
+
tags: [ModelTag.Enterprise]
|
|
33766
|
+
})
|
|
33767
|
+
]);
|
|
33768
|
+
} else {
|
|
33769
|
+
modelsService.instance.setModels([]);
|
|
33770
|
+
}
|
|
33771
|
+
}
|
|
33772
|
+
function registerModelsFromVSCodeConfiguration() {
|
|
33773
|
+
const codyConfig = workspace.getConfiguration("cody");
|
|
33774
|
+
const modelsConfig = codyConfig == null ? void 0 : codyConfig.get("dev.models");
|
|
33775
|
+
if (!(modelsConfig == null ? void 0 : modelsConfig.length)) {
|
|
33776
|
+
return;
|
|
33777
|
+
}
|
|
33778
|
+
modelsService.instance.addModels(
|
|
33779
|
+
modelsConfig.map(
|
|
33780
|
+
(m) => new Model({
|
|
33781
|
+
id: `${m.provider}/${m.model}`,
|
|
33782
|
+
usage: [ModelUsage.Chat, ModelUsage.Edit],
|
|
33783
|
+
contextWindow: {
|
|
33784
|
+
input: m.inputTokens ?? CHAT_INPUT_TOKEN_BUDGET,
|
|
33785
|
+
output: m.outputTokens ?? ANSWER_TOKENS
|
|
33786
|
+
},
|
|
33787
|
+
clientSideConfig: { apiKey: m.apiKey, apiEndpoint: m.apiEndpoint },
|
|
33788
|
+
tags: [ModelTag.Local, ModelTag.BYOK, ModelTag.Experimental]
|
|
33789
|
+
})
|
|
33790
|
+
)
|
|
33791
|
+
);
|
|
33792
|
+
}
|
|
33793
|
+
async function fetchServerSideModels(endpoint) {
|
|
33794
|
+
if (!endpoint) {
|
|
33795
|
+
throw new Error("authStatus has no endpoint available. Unable to fetch models.");
|
|
33796
|
+
}
|
|
33797
|
+
const userAccessToken = await secretStorage.getToken(endpoint);
|
|
33798
|
+
const customHeaders = getConfiguration().customHeaders;
|
|
33799
|
+
const client = new RestClient(endpoint, userAccessToken, customHeaders);
|
|
33800
|
+
return await client.getAvailableModels();
|
|
33801
|
+
}
|
|
33802
|
+
function logFirstEnrollmentEvent(key, isEnabled) {
|
|
33803
|
+
const isEnrolled = localStorage.getEnrollmentHistory(key);
|
|
33804
|
+
const eventName = getFeatureFlagEventName(key);
|
|
33805
|
+
if (isEnrolled || !eventName) {
|
|
33806
|
+
return isEnrolled && !!eventName;
|
|
33807
|
+
}
|
|
33808
|
+
const args2 = { variant: isEnabled ? "treatment" : "control" };
|
|
33809
|
+
telemetryRecorder.recordEvent(`cody.experiment.${eventName}`, "enrolled", {
|
|
33810
|
+
privateMetadata: args2
|
|
33811
|
+
});
|
|
33812
|
+
return true;
|
|
33813
|
+
}
|
|
33814
|
+
function getFeatureFlagEventName(key) {
|
|
33815
|
+
switch (key) {
|
|
33816
|
+
case FeatureFlag.CodyInteractiveTutorial:
|
|
33817
|
+
return "interactiveTutorial";
|
|
33818
|
+
default:
|
|
33819
|
+
return void 0;
|
|
33820
|
+
}
|
|
33821
|
+
}
|
|
33822
|
+
let tutorialDocumentUri;
|
|
33823
|
+
const setTutorialUri = (context2) => {
|
|
33824
|
+
const tutorialPath = path$1.join(context2.extensionUri.fsPath, "walkthroughs", "cody_tutorial.py");
|
|
33825
|
+
tutorialDocumentUri = Uri.file(tutorialPath);
|
|
33826
|
+
return tutorialDocumentUri;
|
|
33827
|
+
};
|
|
33828
|
+
const isInTutorial = (document2) => {
|
|
33829
|
+
if (!tutorialDocumentUri) {
|
|
33830
|
+
return false;
|
|
33831
|
+
}
|
|
33832
|
+
return document2.uri.toString() === tutorialDocumentUri.toString();
|
|
33833
|
+
};
|
|
33834
|
+
const maybeStartInteractiveTutorial = async () => {
|
|
33835
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "attemptingStart");
|
|
33836
|
+
await featureFlagProvider.instance.refresh();
|
|
33837
|
+
const enabled = await featureFlagProvider.instance.evaluateFeatureFlag(
|
|
33838
|
+
FeatureFlag.CodyInteractiveTutorial
|
|
33839
|
+
);
|
|
33840
|
+
logFirstEnrollmentEvent(FeatureFlag.CodyInteractiveTutorial, enabled);
|
|
33841
|
+
if (!enabled) {
|
|
33842
|
+
return;
|
|
33843
|
+
}
|
|
33844
|
+
return commands$1.executeCommand("cody.tutorial.start");
|
|
33845
|
+
};
|
|
33846
|
+
function getItemLabel$1(uri2, current) {
|
|
33847
|
+
const icon2 = current ? "$(check) " : "";
|
|
33848
|
+
if (isDotCom(uri2)) {
|
|
33849
|
+
return `${icon2}Sourcegraph.com`;
|
|
33850
|
+
}
|
|
33851
|
+
return `${icon2}${uri2}`;
|
|
33852
|
+
}
|
|
33853
|
+
const AuthMenu = async (type2, historyItems) => {
|
|
33854
|
+
const historySize = historyItems == null ? void 0 : historyItems.length;
|
|
33855
|
+
const history = historySize > 0 ? historyItems == null ? void 0 : historyItems.map((uri2, i) => ({
|
|
33856
|
+
id: uri2,
|
|
33857
|
+
label: getItemLabel$1(uri2, type2 === "switch" && i === historySize - 1),
|
|
33858
|
+
description: "",
|
|
33859
|
+
uri: uri2
|
|
33860
|
+
})).reverse() : [];
|
|
33861
|
+
const separator = [{ label: type2 === "signin" ? "previously used" : "current", kind: -1 }];
|
|
33862
|
+
const optionItems = [...LoginMenuOptionItems, ...separator, ...history];
|
|
33863
|
+
const option = await window$1.showQuickPick(
|
|
33864
|
+
optionItems,
|
|
33865
|
+
AuthMenuOptions[type2]
|
|
33866
|
+
);
|
|
33867
|
+
return option;
|
|
33868
|
+
};
|
|
33869
|
+
async function showInstanceURLInputBox(title) {
|
|
33870
|
+
const result = await window$1.showInputBox({
|
|
33871
|
+
title,
|
|
33872
|
+
prompt: "Enter the URL of the Sourcegraph instance. For example, https://sourcegraph.example.com.",
|
|
33873
|
+
placeHolder: "https://sourcegraph.example.com",
|
|
33874
|
+
value: "https://",
|
|
33875
|
+
password: false,
|
|
33876
|
+
ignoreFocusOut: true,
|
|
33877
|
+
// valide input to ensure the user is not entering a token as URL
|
|
33878
|
+
validateInput: (value) => {
|
|
33879
|
+
if (!value) {
|
|
33880
|
+
return null;
|
|
33881
|
+
}
|
|
33882
|
+
if (isSourcegraphToken(value)) {
|
|
33883
|
+
return "Please enter a valid URL";
|
|
33884
|
+
}
|
|
33885
|
+
if (value.length > 4 && !value.startsWith("http")) {
|
|
33886
|
+
return "URL must start with http or https";
|
|
33887
|
+
}
|
|
33888
|
+
if (!/([.]|^https?:\/\/)/.test(value)) {
|
|
33889
|
+
return "Please enter a valid URL";
|
|
33890
|
+
}
|
|
33891
|
+
return null;
|
|
33892
|
+
}
|
|
33893
|
+
});
|
|
33894
|
+
if (typeof result === "string") {
|
|
33895
|
+
return result.trim();
|
|
33896
|
+
}
|
|
33897
|
+
return result;
|
|
33898
|
+
}
|
|
33899
|
+
async function showAccessTokenInputBox(endpoint) {
|
|
33900
|
+
const result = await window$1.showInputBox({
|
|
33901
|
+
title: endpoint,
|
|
33902
|
+
prompt: 'Paste your access token. To create an access token, go to "Settings" and then "Access tokens" on the Sourcegraph instance.',
|
|
33903
|
+
placeHolder: "Access Token",
|
|
33904
|
+
password: true,
|
|
33905
|
+
ignoreFocusOut: true
|
|
33906
|
+
});
|
|
33907
|
+
if (typeof result === "string") {
|
|
33908
|
+
return result.trim();
|
|
33909
|
+
}
|
|
33910
|
+
return result;
|
|
33911
|
+
}
|
|
33912
|
+
const AuthMenuOptions = {
|
|
33913
|
+
signin: {
|
|
33914
|
+
title: "Other Sign-in Options",
|
|
33915
|
+
placeholder: "Choose a sign-in option"
|
|
33916
|
+
},
|
|
33917
|
+
switch: {
|
|
33918
|
+
title: "Switch Account",
|
|
33919
|
+
placeHolder: "Choose an account"
|
|
33920
|
+
}
|
|
33921
|
+
};
|
|
33922
|
+
const LoginMenuOptionItems = [
|
|
33923
|
+
{
|
|
33924
|
+
id: "enterprise",
|
|
33925
|
+
label: "Sign In to Sourcegraph Enterprise Instance",
|
|
33926
|
+
description: "v5.1 and above",
|
|
33927
|
+
totalSteps: 1,
|
|
33928
|
+
picked: true
|
|
33929
|
+
},
|
|
33930
|
+
{
|
|
33931
|
+
id: "token",
|
|
33932
|
+
label: "Sign In to Sourcegraph Enterprise Instance with Access Token",
|
|
33933
|
+
description: "v5.0 and above",
|
|
33934
|
+
totalSteps: 2
|
|
33935
|
+
},
|
|
33936
|
+
{
|
|
33937
|
+
id: "token",
|
|
33938
|
+
label: "Sign In with URL and Access Token",
|
|
33939
|
+
totalSteps: 2
|
|
33940
|
+
}
|
|
33941
|
+
];
|
|
33942
|
+
class AuthProviderSimplified {
|
|
33943
|
+
async openExternalAuthUrl(method, tokenReceiverUrl) {
|
|
33944
|
+
if (!await openExternalAuthUrl(method, tokenReceiverUrl)) {
|
|
33945
|
+
return false;
|
|
33946
|
+
}
|
|
33947
|
+
authProvider.instance.authProviderSimplifiedWillAttemptAuth();
|
|
33948
|
+
return true;
|
|
33949
|
+
}
|
|
33950
|
+
}
|
|
33951
|
+
function getAuthReferralCode() {
|
|
33952
|
+
return {
|
|
33953
|
+
"vscode-insiders": "CODY_INSIDERS",
|
|
33954
|
+
vscodium: "CODY_VSCODIUM",
|
|
33955
|
+
cursor: "CODY_CURSOR"
|
|
33956
|
+
}[env.uriScheme] || "CODY";
|
|
33957
|
+
}
|
|
33958
|
+
function openExternalAuthUrl(provider, tokenReceiverUrl) {
|
|
33959
|
+
const referralCode = getAuthReferralCode();
|
|
33960
|
+
const tokenReceiver = tokenReceiverUrl ? `&tokenReceiverUrl=${encodeURIComponent(tokenReceiverUrl)}` : "";
|
|
33961
|
+
const newTokenUrl = `/user/settings/tokens/new/callback?requestFrom=${referralCode}${tokenReceiver}`;
|
|
33962
|
+
const site = new URL(newTokenUrl, DOTCOM_URL);
|
|
33963
|
+
const genericLoginUrl = `${site}sign-in?returnTo=${newTokenUrl}`;
|
|
33964
|
+
const gitHubLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=github&pc=sams&redirect=${newTokenUrl}`;
|
|
33965
|
+
const gitLabLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=gitlab&pc=sams&redirect=${newTokenUrl}`;
|
|
33966
|
+
const googleLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=google&pc=sams&redirect=${newTokenUrl}`;
|
|
33967
|
+
let uriSpec;
|
|
33968
|
+
switch (provider) {
|
|
33969
|
+
case "github":
|
|
33970
|
+
uriSpec = gitHubLoginUrl;
|
|
33971
|
+
break;
|
|
33972
|
+
case "gitlab":
|
|
33973
|
+
uriSpec = gitLabLoginUrl;
|
|
33974
|
+
break;
|
|
33975
|
+
case "google":
|
|
33976
|
+
uriSpec = googleLoginUrl;
|
|
33977
|
+
break;
|
|
33978
|
+
default:
|
|
33979
|
+
uriSpec = genericLoginUrl;
|
|
33980
|
+
break;
|
|
33981
|
+
}
|
|
33982
|
+
return env.openExternal(uriSpec);
|
|
33983
|
+
}
|
|
33984
|
+
const HAS_AUTHENTICATED_BEFORE_KEY = "has-authenticated-before";
|
|
33985
|
+
class AuthProvider {
|
|
33986
|
+
constructor(config) {
|
|
33987
|
+
__publicField2(this, "endpointHistory", []);
|
|
33988
|
+
__publicField2(this, "client", null);
|
|
33989
|
+
__publicField2(this, "status", defaultAuthStatus);
|
|
33990
|
+
__publicField2(this, "didChangeEvent", new AgentEventEmitter());
|
|
33991
|
+
__publicField2(this, "disposables", [this.didChangeEvent]);
|
|
33992
|
+
__publicField2(this, "changes", fromVSCodeEvent(
|
|
33993
|
+
this.didChangeEvent.event,
|
|
33994
|
+
this.getAuthStatus.bind(this)
|
|
33995
|
+
));
|
|
33996
|
+
this.config = config;
|
|
33997
|
+
this.status.endpoint = "init";
|
|
33998
|
+
this.loadEndpointHistory();
|
|
33999
|
+
}
|
|
34000
|
+
dispose() {
|
|
34001
|
+
for (const d2 of this.disposables) {
|
|
34002
|
+
d2.dispose();
|
|
34003
|
+
}
|
|
34004
|
+
this.disposables = [];
|
|
34005
|
+
}
|
|
34006
|
+
// Sign into the last endpoint the user was signed into, if any
|
|
34007
|
+
async init() {
|
|
34008
|
+
const lastEndpoint = (localStorage == null ? void 0 : localStorage.getEndpoint()) || this.config.serverEndpoint;
|
|
34009
|
+
const token = await secretStorage.get(lastEndpoint || "") || this.config.accessToken;
|
|
34010
|
+
logDebug(
|
|
34011
|
+
"AuthProvider:init:lastEndpoint",
|
|
34012
|
+
(token == null ? void 0 : token.trim()) ? "Token recovered from secretStorage" : "No token found in secretStorage",
|
|
34013
|
+
lastEndpoint
|
|
34014
|
+
);
|
|
34015
|
+
await this.auth({
|
|
34016
|
+
endpoint: lastEndpoint,
|
|
34017
|
+
token: token || null,
|
|
34018
|
+
isExtensionStartup: true
|
|
34019
|
+
}).catch((error) => logError$2("AuthProvider:init:failed", lastEndpoint, { verbose: error }));
|
|
34020
|
+
}
|
|
34021
|
+
// Display quickpick to select endpoint to sign in to
|
|
34022
|
+
async signinMenu(type2, uri2) {
|
|
34023
|
+
const mode = this.status.isLoggedIn ? "switch" : "signin";
|
|
34024
|
+
logDebug("AuthProvider:signinMenu", mode);
|
|
34025
|
+
telemetryRecorder.recordEvent("cody.auth.login", "clicked");
|
|
34026
|
+
const item = await AuthMenu(mode, this.endpointHistory);
|
|
34027
|
+
if (!item) {
|
|
34028
|
+
return;
|
|
34029
|
+
}
|
|
34030
|
+
const menuID = type2 || (item == null ? void 0 : item.id);
|
|
34031
|
+
telemetryRecorder.recordEvent("cody.auth.signin.menu", "clicked", {
|
|
34032
|
+
privateMetadata: { menuID }
|
|
34033
|
+
});
|
|
34034
|
+
switch (menuID) {
|
|
34035
|
+
case "enterprise": {
|
|
34036
|
+
const instanceUrl = await showInstanceURLInputBox(item.uri);
|
|
34037
|
+
if (!instanceUrl) {
|
|
34038
|
+
return;
|
|
34039
|
+
}
|
|
34040
|
+
this.status.endpoint = instanceUrl;
|
|
34041
|
+
this.redirectToEndpointLogin(instanceUrl);
|
|
34042
|
+
break;
|
|
34043
|
+
}
|
|
34044
|
+
case "dotcom":
|
|
34045
|
+
this.redirectToEndpointLogin(DOTCOM_URL.href);
|
|
34046
|
+
break;
|
|
34047
|
+
case "token": {
|
|
34048
|
+
const instanceUrl = await showInstanceURLInputBox(uri2 || item.uri);
|
|
34049
|
+
if (!instanceUrl) {
|
|
34050
|
+
return;
|
|
34051
|
+
}
|
|
34052
|
+
await this.signinMenuForInstanceUrl(instanceUrl);
|
|
34053
|
+
break;
|
|
34054
|
+
}
|
|
34055
|
+
default: {
|
|
34056
|
+
const selectedEndpoint = item.uri;
|
|
34057
|
+
const token = await secretStorage.get(selectedEndpoint);
|
|
34058
|
+
let authStatus = await this.auth({
|
|
34059
|
+
endpoint: selectedEndpoint,
|
|
34060
|
+
token: token || null
|
|
34061
|
+
});
|
|
34062
|
+
if (!(authStatus == null ? void 0 : authStatus.isLoggedIn)) {
|
|
34063
|
+
const newToken = await showAccessTokenInputBox(item.uri);
|
|
34064
|
+
if (!newToken) {
|
|
34065
|
+
return;
|
|
34066
|
+
}
|
|
34067
|
+
authStatus = await this.auth({
|
|
34068
|
+
endpoint: selectedEndpoint,
|
|
34069
|
+
token: newToken || null
|
|
34070
|
+
});
|
|
34071
|
+
}
|
|
34072
|
+
await showAuthResultMessage(selectedEndpoint, authStatus);
|
|
34073
|
+
logDebug("AuthProvider:signinMenu", mode, selectedEndpoint);
|
|
34074
|
+
}
|
|
34075
|
+
}
|
|
34076
|
+
}
|
|
34077
|
+
async signinMenuForInstanceUrl(instanceUrl) {
|
|
34078
|
+
const accessToken = await showAccessTokenInputBox(instanceUrl);
|
|
34079
|
+
if (!accessToken) {
|
|
34080
|
+
return;
|
|
34081
|
+
}
|
|
34082
|
+
const authState = await this.auth({
|
|
34083
|
+
endpoint: instanceUrl,
|
|
34084
|
+
token: accessToken
|
|
34085
|
+
});
|
|
34086
|
+
telemetryRecorder.recordEvent("cody.auth.signin.token", "clicked", {
|
|
34087
|
+
metadata: {
|
|
34088
|
+
success: authState.isLoggedIn ? 1 : 0
|
|
34089
|
+
}
|
|
34090
|
+
});
|
|
34091
|
+
await showAuthResultMessage(instanceUrl, authState);
|
|
34092
|
+
}
|
|
34093
|
+
async signoutMenu() {
|
|
34094
|
+
telemetryRecorder.recordEvent("cody.auth.logout", "clicked");
|
|
34095
|
+
const { endpoint } = this.getAuthStatus();
|
|
34096
|
+
if (endpoint) {
|
|
34097
|
+
await this.signout(endpoint);
|
|
34098
|
+
logDebug("AuthProvider:signoutMenu", endpoint);
|
|
34099
|
+
}
|
|
34100
|
+
}
|
|
34101
|
+
async accountMenu() {
|
|
34102
|
+
const selected = await openAccountMenu(this.status);
|
|
34103
|
+
if (selected === void 0) {
|
|
34104
|
+
return;
|
|
34105
|
+
}
|
|
34106
|
+
switch (selected) {
|
|
34107
|
+
case AccountMenuOptions.Manage: {
|
|
34108
|
+
const uri2 = Uri.parse(ACCOUNT_USAGE_URL.toString()).with({
|
|
34109
|
+
query: `cody_client_user=${encodeURIComponent(this.status.username)}`
|
|
34110
|
+
});
|
|
34111
|
+
void env.openExternal(uri2);
|
|
34112
|
+
break;
|
|
34113
|
+
}
|
|
34114
|
+
case AccountMenuOptions.Switch:
|
|
34115
|
+
await this.signinMenu();
|
|
34116
|
+
break;
|
|
34117
|
+
case AccountMenuOptions.SignOut:
|
|
34118
|
+
await this.signoutMenu();
|
|
34119
|
+
break;
|
|
34120
|
+
}
|
|
34121
|
+
}
|
|
34122
|
+
// Log user out of the selected endpoint (remove token from secret)
|
|
34123
|
+
async signout(endpoint) {
|
|
34124
|
+
await secretStorage.deleteToken(endpoint);
|
|
34125
|
+
await localStorage.deleteEndpoint();
|
|
34126
|
+
await this.auth({ endpoint: "", token: null });
|
|
34127
|
+
await commands$1.executeCommand("setContext", "cody.activated", false);
|
|
34128
|
+
}
|
|
34129
|
+
// Create Auth Status
|
|
34130
|
+
async makeAuthStatus(config, isOfflineMode) {
|
|
34131
|
+
var _a3;
|
|
34132
|
+
const endpoint = config.serverEndpoint;
|
|
34133
|
+
const token = config.accessToken;
|
|
34134
|
+
const isCodyWeb = workspace.getConfiguration().get("cody.advanced.agent.ide") === CodyIDE.Web;
|
|
34135
|
+
if (isOfflineMode) {
|
|
34136
|
+
const lastUser = localStorage.getLastStoredUser();
|
|
34137
|
+
return { ...offlineModeAuthStatus, ...lastUser };
|
|
34138
|
+
}
|
|
34139
|
+
if (isCodyWeb) {
|
|
34140
|
+
if (!endpoint) {
|
|
34141
|
+
return { ...defaultAuthStatus, endpoint };
|
|
34142
|
+
}
|
|
34143
|
+
} else {
|
|
34144
|
+
if (!token || !endpoint) {
|
|
34145
|
+
return { ...defaultAuthStatus, endpoint };
|
|
34146
|
+
}
|
|
34147
|
+
}
|
|
34148
|
+
if (this.config !== config || !this.client) {
|
|
34149
|
+
this.config = config;
|
|
34150
|
+
this.client = new SourcegraphGraphQLAPIClient(config);
|
|
34151
|
+
}
|
|
34152
|
+
const [{ enabled: siteHasCodyEnabled, version: siteVersion }, codyLLMConfiguration, userInfo] = await Promise.all([
|
|
34153
|
+
this.client.isCodyEnabled(),
|
|
34154
|
+
this.client.getCodyLLMConfiguration(),
|
|
34155
|
+
this.client.getCurrentUserInfo()
|
|
34156
|
+
]);
|
|
34157
|
+
logDebug("CodyLLMConfiguration", JSON.stringify(codyLLMConfiguration));
|
|
34158
|
+
if (isError$1(userInfo) && isNetworkError(userInfo)) {
|
|
34159
|
+
return { ...networkErrorAuthStatus, endpoint };
|
|
34160
|
+
}
|
|
34161
|
+
if (!userInfo || isError$1(userInfo)) {
|
|
34162
|
+
return { ...unauthenticatedStatus, endpoint };
|
|
34163
|
+
}
|
|
34164
|
+
const configOverwrites = isError$1(codyLLMConfiguration) ? void 0 : codyLLMConfiguration;
|
|
34165
|
+
const isDotCom2 = this.client.isDotCom();
|
|
34166
|
+
if (!isDotCom2) {
|
|
34167
|
+
return newAuthStatus({
|
|
34168
|
+
...userInfo,
|
|
34169
|
+
endpoint,
|
|
34170
|
+
isDotCom: isDotCom2,
|
|
34171
|
+
siteVersion,
|
|
34172
|
+
configOverwrites,
|
|
34173
|
+
authenticated: true,
|
|
34174
|
+
hasVerifiedEmail: false,
|
|
34175
|
+
siteHasCodyEnabled,
|
|
34176
|
+
userCanUpgrade: false
|
|
34177
|
+
});
|
|
34178
|
+
}
|
|
34179
|
+
const proStatus = await this.client.getCurrentUserCodySubscription();
|
|
34180
|
+
const isActiveProUser = proStatus !== null && "plan" in proStatus && proStatus.plan === "PRO" && proStatus.status !== "PENDING";
|
|
34181
|
+
return newAuthStatus({
|
|
34182
|
+
...userInfo,
|
|
34183
|
+
endpoint,
|
|
34184
|
+
isDotCom: isDotCom2,
|
|
34185
|
+
siteHasCodyEnabled,
|
|
34186
|
+
siteVersion,
|
|
34187
|
+
configOverwrites,
|
|
34188
|
+
authenticated: !!userInfo.id,
|
|
34189
|
+
userCanUpgrade: !isActiveProUser,
|
|
34190
|
+
primaryEmail: ((_a3 = userInfo.primaryEmail) == null ? void 0 : _a3.email) ?? ""
|
|
34191
|
+
});
|
|
34192
|
+
}
|
|
34193
|
+
getAuthStatus() {
|
|
34194
|
+
return this.status;
|
|
34195
|
+
}
|
|
34196
|
+
// It processes the authentication steps and stores the login info before sharing the auth status with chatview
|
|
34197
|
+
async auth({
|
|
34198
|
+
endpoint,
|
|
34199
|
+
token,
|
|
34200
|
+
customHeaders,
|
|
34201
|
+
isExtensionStartup = false,
|
|
34202
|
+
isOfflineMode = false
|
|
34203
|
+
}) {
|
|
34204
|
+
const config = {
|
|
34205
|
+
serverEndpoint: formatURL(endpoint) ?? "",
|
|
34206
|
+
accessToken: token,
|
|
34207
|
+
customHeaders: customHeaders || this.config.customHeaders
|
|
34208
|
+
};
|
|
34209
|
+
try {
|
|
34210
|
+
const authStatus = await this.makeAuthStatus(config, isOfflineMode);
|
|
34211
|
+
if (!isOfflineMode) {
|
|
34212
|
+
await this.storeAuthInfo(config.serverEndpoint, config.accessToken);
|
|
34213
|
+
}
|
|
34214
|
+
await commands$1.executeCommand("setContext", "cody.activated", authStatus.isLoggedIn);
|
|
34215
|
+
await this.setAuthStatus(authStatus);
|
|
34216
|
+
if (isExtensionStartup && authStatus.isLoggedIn) {
|
|
34217
|
+
await this.setHasAuthenticatedBefore();
|
|
34218
|
+
} else if (authStatus.isLoggedIn) {
|
|
34219
|
+
this.handleFirstEverAuthentication();
|
|
34220
|
+
}
|
|
34221
|
+
return authStatus;
|
|
34222
|
+
} catch (error) {
|
|
34223
|
+
logDebug("AuthProvider:auth", "failed", error);
|
|
34224
|
+
return await this.reloadAuthStatus().catch(() => unauthenticatedStatus);
|
|
34225
|
+
}
|
|
34226
|
+
}
|
|
34227
|
+
// Set auth status in case of reload
|
|
34228
|
+
async reloadAuthStatus() {
|
|
34229
|
+
await commands$1.executeCommand("setContext", "cody.activated", false);
|
|
34230
|
+
this.config = await getFullConfig();
|
|
34231
|
+
return await this.auth({
|
|
34232
|
+
endpoint: this.config.serverEndpoint,
|
|
34233
|
+
token: this.config.accessToken,
|
|
34234
|
+
customHeaders: this.config.customHeaders
|
|
34235
|
+
});
|
|
34236
|
+
}
|
|
34237
|
+
// Set auth status and share it with chatview
|
|
34238
|
+
async setAuthStatus(authStatus) {
|
|
34239
|
+
if (this.status === authStatus) {
|
|
34240
|
+
return;
|
|
34241
|
+
}
|
|
34242
|
+
this.status = authStatus;
|
|
34243
|
+
if (authStatus.endpoint === "init") {
|
|
34244
|
+
return;
|
|
34245
|
+
}
|
|
34246
|
+
await this.updateAuthStatus(authStatus);
|
|
34247
|
+
}
|
|
34248
|
+
async updateAuthStatus(authStatus) {
|
|
34249
|
+
try {
|
|
34250
|
+
graphqlClient.setConfig(await getFullConfig());
|
|
34251
|
+
await ClientConfigSingleton.getInstance().setAuthStatus(authStatus);
|
|
34252
|
+
await syncModels(authStatus);
|
|
34253
|
+
} catch (error) {
|
|
34254
|
+
logDebug("AuthProvider", "updateAuthStatus error", error);
|
|
34255
|
+
} finally {
|
|
34256
|
+
this.didChangeEvent.fire(this.getAuthStatus());
|
|
34257
|
+
let eventValue;
|
|
34258
|
+
if (authStatus.showNetworkError || authStatus.showInvalidAccessTokenError) {
|
|
34259
|
+
eventValue = "failed";
|
|
34260
|
+
} else if (authStatus.isLoggedIn) {
|
|
34261
|
+
eventValue = "connected";
|
|
34262
|
+
} else {
|
|
34263
|
+
eventValue = "disconnected";
|
|
34264
|
+
}
|
|
34265
|
+
telemetryRecorder.recordEvent("cody.auth", eventValue);
|
|
34266
|
+
}
|
|
34267
|
+
}
|
|
34268
|
+
// Register URI Handler (vscode://sourcegraph.cody-ai) for resolving token
|
|
34269
|
+
// sending back from sourcegraph.com
|
|
34270
|
+
async tokenCallbackHandler(uri2, customHeaders) {
|
|
34271
|
+
closeAuthProgressIndicator();
|
|
34272
|
+
const params = new URLSearchParams(uri2.query);
|
|
34273
|
+
const token = params.get("code");
|
|
34274
|
+
const endpoint = this.status.endpoint;
|
|
34275
|
+
if (!token || !endpoint) {
|
|
34276
|
+
return;
|
|
34277
|
+
}
|
|
34278
|
+
const authState = await this.auth({ endpoint, token, customHeaders });
|
|
34279
|
+
telemetryRecorder.recordEvent("cody.auth.fromCallback.web", "succeeded", {
|
|
34280
|
+
metadata: {
|
|
34281
|
+
success: (authState == null ? void 0 : authState.isLoggedIn) ? 1 : 0
|
|
34282
|
+
}
|
|
34283
|
+
});
|
|
34284
|
+
if (authState == null ? void 0 : authState.isLoggedIn) {
|
|
34285
|
+
await window$1.showInformationMessage(`Signed in to ${endpoint}`);
|
|
34286
|
+
} else {
|
|
34287
|
+
await showAuthFailureMessage(endpoint);
|
|
34288
|
+
}
|
|
34289
|
+
}
|
|
34290
|
+
/** Open callback URL in browser to get token from instance. */
|
|
34291
|
+
redirectToEndpointLogin(uri2) {
|
|
34292
|
+
const endpoint = formatURL(uri2);
|
|
34293
|
+
if (!endpoint) {
|
|
34294
|
+
return;
|
|
34295
|
+
}
|
|
34296
|
+
if (env.uiKind === UIKind.Web) {
|
|
34297
|
+
const newTokenNoCallbackUrl = new URL("/user/settings/tokens/new", endpoint);
|
|
34298
|
+
void env.openExternal(Uri.parse(newTokenNoCallbackUrl.href));
|
|
34299
|
+
void this.signinMenuForInstanceUrl(endpoint);
|
|
34300
|
+
return;
|
|
34301
|
+
}
|
|
34302
|
+
const newTokenCallbackUrl = new URL("/user/settings/tokens/new/callback", endpoint);
|
|
34303
|
+
newTokenCallbackUrl.searchParams.append("requestFrom", getAuthReferralCode());
|
|
34304
|
+
this.status.endpoint = endpoint;
|
|
34305
|
+
void env.openExternal(Uri.parse(newTokenCallbackUrl.href));
|
|
34306
|
+
}
|
|
34307
|
+
// Refresh current endpoint history with the one from local storage
|
|
34308
|
+
loadEndpointHistory() {
|
|
34309
|
+
this.endpointHistory = localStorage.getEndpointHistory() || [];
|
|
34310
|
+
}
|
|
34311
|
+
// Store endpoint in local storage, token in secret storage, and update endpoint history.
|
|
34312
|
+
async storeAuthInfo(endpoint, token) {
|
|
34313
|
+
if (!endpoint) {
|
|
34314
|
+
return;
|
|
34315
|
+
}
|
|
34316
|
+
await localStorage.saveEndpoint(endpoint);
|
|
34317
|
+
if (token) {
|
|
34318
|
+
await secretStorage.storeToken(endpoint, token);
|
|
34319
|
+
}
|
|
34320
|
+
this.loadEndpointHistory();
|
|
34321
|
+
}
|
|
34322
|
+
// Notifies the AuthProvider that the simplified onboarding experiment is
|
|
34323
|
+
// kicking off an authorization flow. That flow ends when (if) this
|
|
34324
|
+
// AuthProvider gets a call to tokenCallbackHandler.
|
|
34325
|
+
authProviderSimplifiedWillAttemptAuth() {
|
|
34326
|
+
this.status.endpoint = DOTCOM_URL.toString();
|
|
34327
|
+
}
|
|
34328
|
+
// Logs a telemetry event if the user has never authenticated to Sourcegraph.
|
|
34329
|
+
handleFirstEverAuthentication() {
|
|
34330
|
+
if (localStorage.get(HAS_AUTHENTICATED_BEFORE_KEY)) {
|
|
34331
|
+
return;
|
|
34332
|
+
}
|
|
34333
|
+
telemetryRecorder.recordEvent("cody.auth.login", "firstEver");
|
|
34334
|
+
this.setHasAuthenticatedBefore();
|
|
34335
|
+
void maybeStartInteractiveTutorial();
|
|
34336
|
+
}
|
|
34337
|
+
setHasAuthenticatedBefore() {
|
|
34338
|
+
return localStorage.set(HAS_AUTHENTICATED_BEFORE_KEY, "true");
|
|
34339
|
+
}
|
|
34340
|
+
}
|
|
34341
|
+
const authProvider = singletonNotYetSet();
|
|
34342
|
+
function isNetworkError(error) {
|
|
34343
|
+
const message = error.message;
|
|
34344
|
+
return message.includes("ENOTFOUND") || message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("EHOSTUNREACH") || message.includes("ETIMEDOUT");
|
|
34345
|
+
}
|
|
34346
|
+
function formatURL(uri2) {
|
|
34347
|
+
try {
|
|
34348
|
+
if (!uri2) {
|
|
34349
|
+
return null;
|
|
34350
|
+
}
|
|
34351
|
+
if (isSourcegraphToken(uri2)) {
|
|
34352
|
+
throw new Error("Access Token is not a valid URL");
|
|
34353
|
+
}
|
|
34354
|
+
if (!uri2.startsWith("http")) {
|
|
34355
|
+
uri2 = `https://${uri2}`;
|
|
34356
|
+
}
|
|
34357
|
+
const endpointUri = new URL(uri2);
|
|
34358
|
+
return endpointUri.href;
|
|
34359
|
+
} catch (error) {
|
|
34360
|
+
console.error("Invalid URL: ", error);
|
|
34361
|
+
return null;
|
|
34362
|
+
}
|
|
34363
|
+
}
|
|
34364
|
+
async function showAuthResultMessage(endpoint, authStatus) {
|
|
34365
|
+
if (authStatus == null ? void 0 : authStatus.isLoggedIn) {
|
|
34366
|
+
const authority = Uri.parse(endpoint).authority;
|
|
34367
|
+
await window$1.showInformationMessage(`Signed in to ${authority || endpoint}`);
|
|
34368
|
+
} else {
|
|
34369
|
+
await showAuthFailureMessage(endpoint);
|
|
34370
|
+
}
|
|
34371
|
+
}
|
|
34372
|
+
async function showAuthFailureMessage(endpoint) {
|
|
34373
|
+
const authority = Uri.parse(endpoint).authority;
|
|
34374
|
+
await window$1.showErrorMessage(
|
|
34375
|
+
`Authentication failed. Please ensure Cody is enabled for ${authority} and verify your email address if required.`
|
|
34376
|
+
);
|
|
34377
|
+
}
|
|
33546
34378
|
const { platform, arch } = getOSArch();
|
|
33547
34379
|
const getExtensionDetails = (config) => ({
|
|
33548
34380
|
ide: config.agentIDE ?? CodyIDE.VSCode,
|
|
@@ -33553,7 +34385,7 @@ const getExtensionDetails = (config) => ({
|
|
|
33553
34385
|
});
|
|
33554
34386
|
const legacyBackcompatLogEventMode = "connected-instance-only";
|
|
33555
34387
|
const debugLogLabel = "telemetry-v2";
|
|
33556
|
-
async function createOrUpdateTelemetryRecorderProvider(config, isExtensionModeDevOrTest
|
|
34388
|
+
async function createOrUpdateTelemetryRecorderProvider(config, isExtensionModeDevOrTest) {
|
|
33557
34389
|
const extensionDetails = getExtensionDetails(config);
|
|
33558
34390
|
const defaultNoOpProvider = new NoOpTelemetryRecorderProvider([new TimestampTelemetryProcessor_1()]);
|
|
33559
34391
|
if (config.telemetryLevel === "off" || !extensionDetails.ide) {
|
|
@@ -33570,7 +34402,7 @@ async function createOrUpdateTelemetryRecorderProvider(config, isExtensionModeDe
|
|
|
33570
34402
|
new TelemetryRecorderProvider(
|
|
33571
34403
|
extensionDetails,
|
|
33572
34404
|
config,
|
|
33573
|
-
|
|
34405
|
+
authProvider.instance,
|
|
33574
34406
|
anonymousUserID,
|
|
33575
34407
|
legacyBackcompatLogEventMode
|
|
33576
34408
|
)
|
|
@@ -33901,10 +34733,12 @@ async function gitLocallyModifiedFiles(uri2, signal2) {
|
|
|
33901
34733
|
var _a3, _b2;
|
|
33902
34734
|
const repo = vscodeGitAPI == null ? void 0 : vscodeGitAPI.getRepository(uri2);
|
|
33903
34735
|
if (!repo) {
|
|
33904
|
-
|
|
34736
|
+
logDebug("gitLocallyModifiedFiles", "no git repository found at", uri2.toString());
|
|
34737
|
+
return [];
|
|
33905
34738
|
}
|
|
33906
34739
|
if (!((_a3 = repo.state.HEAD) == null ? void 0 : _a3.commit)) {
|
|
33907
|
-
|
|
34740
|
+
logDebug("gitLocallyModifiedFiles", "HEAD commit was undefined for git repo at", uri2.toString());
|
|
34741
|
+
return [];
|
|
33908
34742
|
}
|
|
33909
34743
|
let diffBase = repo.state.HEAD.commit;
|
|
33910
34744
|
if ((_b2 = repo.state.HEAD) == null ? void 0 : _b2.upstream) {
|
|
@@ -34205,7 +35039,6 @@ async function resolveGitConfigUri(uri2, signal2) {
|
|
|
34205
35039
|
}
|
|
34206
35040
|
class RepoNameResolver {
|
|
34207
35041
|
constructor() {
|
|
34208
|
-
__publicField2(this, "authProvider");
|
|
34209
35042
|
__publicField2(this, "fsPathToRepoNameCache", new LRUCache$1({ max: 1e3 }));
|
|
34210
35043
|
__publicField2(this, "remoteUrlToRepoNameCache", new LRUCache$1({ max: 1e3 }));
|
|
34211
35044
|
/**
|
|
@@ -34253,19 +35086,18 @@ class RepoNameResolver {
|
|
|
34253
35086
|
return [];
|
|
34254
35087
|
});
|
|
34255
35088
|
}
|
|
34256
|
-
init(
|
|
34257
|
-
|
|
34258
|
-
this.authProvider.changes.subscribe(() => {
|
|
35089
|
+
init() {
|
|
35090
|
+
authProvider.instance.changes.subscribe(() => {
|
|
34259
35091
|
this.fsPathToRepoNameCache.clear();
|
|
34260
35092
|
this.remoteUrlToRepoNameCache.clear();
|
|
34261
35093
|
});
|
|
34262
35094
|
}
|
|
34263
35095
|
async getRepoNamesFromRemoteUrls(remoteUrls) {
|
|
34264
|
-
if (!
|
|
35096
|
+
if (!authProvider.instance) {
|
|
34265
35097
|
throw new Error("RepoNameResolver not initialized");
|
|
34266
35098
|
}
|
|
34267
35099
|
const uniqueRemoteUrls = Array.from(new Set(remoteUrls));
|
|
34268
|
-
if (
|
|
35100
|
+
if (authProvider.instance.getAuthStatus().isDotCom) {
|
|
34269
35101
|
return uniqueRemoteUrls.map(convertGitCloneURLToCodebaseName).filter(isDefined);
|
|
34270
35102
|
}
|
|
34271
35103
|
const repoNames = await Promise.all(
|
|
@@ -36219,11 +37051,6 @@ async function doRewrite(completionsClient, query2, signal2) {
|
|
|
36219
37051
|
}
|
|
36220
37052
|
return [...result];
|
|
36221
37053
|
}
|
|
36222
|
-
var RepoInclusion = /* @__PURE__ */ ((RepoInclusion2) => {
|
|
36223
|
-
RepoInclusion2["Automatic"] = "auto";
|
|
36224
|
-
RepoInclusion2["Manual"] = "manual";
|
|
36225
|
-
return RepoInclusion2;
|
|
36226
|
-
})(RepoInclusion || {});
|
|
36227
37054
|
class RemoteSearch {
|
|
36228
37055
|
constructor(completions) {
|
|
36229
37056
|
// Repositories we are including automatically because of the workspace.
|
|
@@ -36420,7 +37247,7 @@ class WorkspaceRepoMapper {
|
|
|
36420
37247
|
}
|
|
36421
37248
|
}
|
|
36422
37249
|
class WorkspaceReposMonitor {
|
|
36423
|
-
constructor(
|
|
37250
|
+
constructor() {
|
|
36424
37251
|
__publicField2(this, "disposables", []);
|
|
36425
37252
|
__publicField2(this, "repoMetadata", /* @__PURE__ */ new Map());
|
|
36426
37253
|
__publicField2(this, "workspaceRepoMapper", new WorkspaceRepoMapper());
|
|
@@ -36430,12 +37257,15 @@ class WorkspaceReposMonitor {
|
|
|
36430
37257
|
this.disposables.push(
|
|
36431
37258
|
workspace.onDidChangeWorkspaceFolders((evt) => this.onDidChangeWorkspaceFolders(evt))
|
|
36432
37259
|
);
|
|
36433
|
-
|
|
36434
|
-
|
|
36435
|
-
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
37260
|
+
this.disposables.push(
|
|
37261
|
+
subscriptionDisposable(
|
|
37262
|
+
authProvider.instance.changes.subscribe(() => {
|
|
37263
|
+
for (const folderURI of this.getFolderURIs()) {
|
|
37264
|
+
this.addWorkspaceFolder(folderURI);
|
|
37265
|
+
}
|
|
37266
|
+
})
|
|
37267
|
+
)
|
|
37268
|
+
);
|
|
36439
37269
|
}
|
|
36440
37270
|
dispose() {
|
|
36441
37271
|
for (const disposable of this.disposables) {
|
|
@@ -36503,7 +37333,7 @@ class WorkspaceReposMonitor {
|
|
|
36503
37333
|
}
|
|
36504
37334
|
}
|
|
36505
37335
|
let workspaceReposMonitor = void 0;
|
|
36506
|
-
function initWorkspaceReposMonitor(
|
|
37336
|
+
function initWorkspaceReposMonitor(disposables) {
|
|
36507
37337
|
if (!vscodeGitAPI) {
|
|
36508
37338
|
logDebug(
|
|
36509
37339
|
"WorkspaceReposMonitor",
|
|
@@ -36511,7 +37341,7 @@ function initWorkspaceReposMonitor(authProvider, disposables) {
|
|
|
36511
37341
|
);
|
|
36512
37342
|
return void 0;
|
|
36513
37343
|
}
|
|
36514
|
-
workspaceReposMonitor = new WorkspaceReposMonitor(
|
|
37344
|
+
workspaceReposMonitor = new WorkspaceReposMonitor();
|
|
36515
37345
|
disposables.push(workspaceReposMonitor);
|
|
36516
37346
|
return workspaceReposMonitor;
|
|
36517
37347
|
}
|
|
@@ -36729,7 +37559,8 @@ class UpstreamHealthProvider {
|
|
|
36729
37559
|
}
|
|
36730
37560
|
}
|
|
36731
37561
|
}
|
|
36732
|
-
const upstreamHealthProvider =
|
|
37562
|
+
const upstreamHealthProvider = singletonNotYetSet();
|
|
37563
|
+
setSingleton(upstreamHealthProvider, new UpstreamHealthProvider());
|
|
36733
37564
|
function headersToObject(headers) {
|
|
36734
37565
|
const result = {};
|
|
36735
37566
|
for (const [key, value] of headers.entries()) {
|
|
@@ -37626,10 +38457,6 @@ const languages = {
|
|
|
37626
38457
|
class CompletionProviderConfig {
|
|
37627
38458
|
constructor() {
|
|
37628
38459
|
__publicField2(this, "_config");
|
|
37629
|
-
/**
|
|
37630
|
-
* Use the injected feature flag provider to make testing easier.
|
|
37631
|
-
*/
|
|
37632
|
-
__publicField2(this, "featureFlagProvider");
|
|
37633
38460
|
__publicField2(this, "flagsToResolve", [
|
|
37634
38461
|
FeatureFlag.CodyAutocompleteContextBfgMixed,
|
|
37635
38462
|
FeatureFlag.CodyAutocompleteUserLatency,
|
|
@@ -37651,19 +38478,17 @@ class CompletionProviderConfig {
|
|
|
37651
38478
|
* Should be called before `InlineCompletionItemProvider` instance is created, so that the singleton
|
|
37652
38479
|
* with resolved values is ready for downstream use.
|
|
37653
38480
|
*/
|
|
37654
|
-
async init(config
|
|
38481
|
+
async init(config) {
|
|
37655
38482
|
this._config = config;
|
|
37656
|
-
|
|
37657
|
-
|
|
38483
|
+
await Promise.all(
|
|
38484
|
+
this.flagsToResolve.map((flag2) => featureFlagProvider.instance.evaluateFeatureFlag(flag2))
|
|
38485
|
+
);
|
|
37658
38486
|
}
|
|
37659
38487
|
setConfig(config) {
|
|
37660
38488
|
this._config = config;
|
|
37661
38489
|
}
|
|
37662
38490
|
getPrefetchedFlag(flag2) {
|
|
37663
|
-
|
|
37664
|
-
throw new Error("CompletionProviderConfig is not initialized");
|
|
37665
|
-
}
|
|
37666
|
-
return Boolean(this.featureFlagProvider.getFromCache(flag2));
|
|
38491
|
+
return Boolean(featureFlagProvider.instance.getFromCache(flag2));
|
|
37667
38492
|
}
|
|
37668
38493
|
get contextStrategy() {
|
|
37669
38494
|
switch (this.config.autocompleteExperimentalGraphContext) {
|
|
@@ -42055,8 +42880,8 @@ function getSharedParams(event) {
|
|
|
42055
42880
|
items: event.items.map((i) => ({ ...i })),
|
|
42056
42881
|
otherCompletionProviderEnabled: otherCompletionProviders2.length > 0,
|
|
42057
42882
|
otherCompletionProviders: otherCompletionProviders2,
|
|
42058
|
-
upstreamLatency: upstreamHealthProvider.getUpstreamLatency(),
|
|
42059
|
-
gatewayLatency: upstreamHealthProvider.getGatewayLatency(),
|
|
42883
|
+
upstreamLatency: upstreamHealthProvider.instance.getUpstreamLatency(),
|
|
42884
|
+
gatewayLatency: upstreamHealthProvider.instance.getGatewayLatency(),
|
|
42060
42885
|
// 🚨 SECURITY: Do not include any context by default
|
|
42061
42886
|
inlineCompletionItemContext: void 0
|
|
42062
42887
|
};
|
|
@@ -46246,7 +47071,10 @@ class Agent extends MessageHandler {
|
|
|
46246
47071
|
(_c2 = this.globalState) == null ? void 0 : _c2.update(key, value);
|
|
46247
47072
|
}
|
|
46248
47073
|
}
|
|
46249
|
-
this.workspace.workspaceRootUri = Uri.parse(clientInfo2.workspaceRootUri)
|
|
47074
|
+
this.workspace.workspaceRootUri = clientInfo2.workspaceRootUri ? Uri.parse(clientInfo2.workspaceRootUri).with({ scheme: "file" }) : Uri.from({
|
|
47075
|
+
scheme: "file",
|
|
47076
|
+
path: clientInfo2.workspaceRootPath ?? void 0
|
|
47077
|
+
});
|
|
46250
47078
|
setWorkspaceDocuments(this.workspace);
|
|
46251
47079
|
if (((_d2 = clientInfo2.capabilities) == null ? void 0 : _d2.codeActions) === "enabled") {
|
|
46252
47080
|
onDidRegisterNewCodeActionProvider((codeActionProvider) => {
|
|
@@ -46270,7 +47098,7 @@ class Agent extends MessageHandler {
|
|
|
46270
47098
|
);
|
|
46271
47099
|
}
|
|
46272
47100
|
if (((_f2 = clientInfo2.capabilities) == null ? void 0 : _f2.ignore) === "enabled") {
|
|
46273
|
-
contextFiltersProvider.onContextFiltersChanged(() => {
|
|
47101
|
+
contextFiltersProvider.instance.onContextFiltersChanged(() => {
|
|
46274
47102
|
this.notify("ignore/didChange", null);
|
|
46275
47103
|
});
|
|
46276
47104
|
}
|
|
@@ -46283,10 +47111,6 @@ class Agent extends MessageHandler {
|
|
|
46283
47111
|
setClientInfo(clientInfo2);
|
|
46284
47112
|
this.clientInfo = clientInfo2;
|
|
46285
47113
|
setUserAgent(`${clientInfo2 == null ? void 0 : clientInfo2.name} / ${clientInfo2 == null ? void 0 : clientInfo2.version}`);
|
|
46286
|
-
this.workspace.workspaceRootUri = clientInfo2.workspaceRootUri ? Uri.parse(clientInfo2.workspaceRootUri) : Uri.from({
|
|
46287
|
-
scheme: "file",
|
|
46288
|
-
path: clientInfo2.workspaceRootPath ?? void 0
|
|
46289
|
-
});
|
|
46290
47114
|
try {
|
|
46291
47115
|
const secrets = ((_g2 = clientInfo2.capabilities) == null ? void 0 : _g2.secrets) === "client-managed" ? new AgentClientManagedSecretStorage(this, this.secretsDidChange.event) : new AgentStatelessSecretStorage();
|
|
46292
47116
|
await initializeVscodeExtension(
|
|
@@ -46877,7 +47701,7 @@ class Agent extends MessageHandler {
|
|
|
46877
47701
|
this.registerAuthenticatedRequest("editTask/retry", (params2) => {
|
|
46878
47702
|
var _a3;
|
|
46879
47703
|
const instruction = PromptString.unsafe_fromUserQuery(params2.instruction);
|
|
46880
|
-
const models = getModelOptionItems(modelsService.getModels(ModelUsage.Edit), true);
|
|
47704
|
+
const models = getModelOptionItems(modelsService.instance.getModels(ModelUsage.Edit), true);
|
|
46881
47705
|
const previousInput = {
|
|
46882
47706
|
instruction,
|
|
46883
47707
|
userContextFiles: [],
|
|
@@ -46977,7 +47801,7 @@ class Agent extends MessageHandler {
|
|
|
46977
47801
|
});
|
|
46978
47802
|
this.registerAuthenticatedRequest("chat/restore", async ({ modelID, messages, chatID }) => {
|
|
46979
47803
|
const authStatus = await commands$1.executeCommand("cody.auth.status");
|
|
46980
|
-
modelID ?? (modelID = modelsService.getDefaultChatModel() ?? "");
|
|
47804
|
+
modelID ?? (modelID = modelsService.instance.getDefaultChatModel() ?? "");
|
|
46981
47805
|
const chatMessages = (messages == null ? void 0 : messages.map(PromptString.unsafe_deserializeChatMessage)) ?? [];
|
|
46982
47806
|
const chatModel = new ChatModel(modelID, chatID, chatMessages);
|
|
46983
47807
|
await chatHistory.saveChat(authStatus, chatModel.toSerializedChatTranscript());
|
|
@@ -46989,7 +47813,7 @@ class Agent extends MessageHandler {
|
|
|
46989
47813
|
);
|
|
46990
47814
|
});
|
|
46991
47815
|
this.registerAuthenticatedRequest("chat/models", async ({ modelUsage }) => {
|
|
46992
|
-
const models = modelsService.getModels(modelUsage);
|
|
47816
|
+
const models = modelsService.instance.getModels(modelUsage);
|
|
46993
47817
|
return { models };
|
|
46994
47818
|
});
|
|
46995
47819
|
this.registerAuthenticatedRequest("chat/export", async (input) => {
|
|
@@ -47104,7 +47928,7 @@ class Agent extends MessageHandler {
|
|
|
47104
47928
|
this.secretsDidChange.fire({ key });
|
|
47105
47929
|
});
|
|
47106
47930
|
this.registerAuthenticatedRequest("featureFlags/getFeatureFlag", async ({ flagName }) => {
|
|
47107
|
-
return featureFlagProvider.evaluateFeatureFlag(
|
|
47931
|
+
return featureFlagProvider.instance.evaluateFeatureFlag(
|
|
47108
47932
|
FeatureFlag[flagName]
|
|
47109
47933
|
);
|
|
47110
47934
|
});
|
|
@@ -47145,13 +47969,13 @@ class Agent extends MessageHandler {
|
|
|
47145
47969
|
});
|
|
47146
47970
|
this.registerAuthenticatedRequest("ignore/test", async ({ uri: uriString }) => {
|
|
47147
47971
|
const uri2 = Uri.parse(uriString);
|
|
47148
|
-
const isIgnored = await contextFiltersProvider.isUriIgnored(uri2);
|
|
47972
|
+
const isIgnored = await contextFiltersProvider.instance.isUriIgnored(uri2);
|
|
47149
47973
|
return {
|
|
47150
47974
|
policy: isIgnored ? "ignore" : "use"
|
|
47151
47975
|
};
|
|
47152
47976
|
});
|
|
47153
47977
|
this.registerAuthenticatedRequest("testing/ignore/overridePolicy", async (contextFilters) => {
|
|
47154
|
-
contextFiltersProvider.setTestingContextFilters(contextFilters);
|
|
47978
|
+
contextFiltersProvider.instance.setTestingContextFilters(contextFilters);
|
|
47155
47979
|
return null;
|
|
47156
47980
|
});
|
|
47157
47981
|
}
|
|
@@ -47570,7 +48394,7 @@ async function showCodyIgnoreNotification(feature2, type2) {
|
|
|
47570
48394
|
);
|
|
47571
48395
|
}
|
|
47572
48396
|
async function isUriIgnoredByContextFilterWithNotification(uri2, feature2) {
|
|
47573
|
-
const isIgnored = await contextFiltersProvider.isUriIgnored(uri2);
|
|
48397
|
+
const isIgnored = await contextFiltersProvider.instance.isUriIgnored(uri2);
|
|
47574
48398
|
if (isIgnored) {
|
|
47575
48399
|
showCodyIgnoreNotification(feature2, "context-filter");
|
|
47576
48400
|
}
|
|
@@ -48607,7 +49431,7 @@ class CommandsProvider {
|
|
|
48607
49431
|
* Used for retreiving context for the command field in custom command
|
|
48608
49432
|
*/
|
|
48609
49433
|
async runShell(shell2) {
|
|
48610
|
-
const { getContextFileFromShell } = await import("./shell-
|
|
49434
|
+
const { getContextFileFromShell } = await import("./shell-CvNNoU2J.mjs");
|
|
48611
49435
|
return getContextFileFromShell(shell2);
|
|
48612
49436
|
}
|
|
48613
49437
|
/**
|
|
@@ -48618,7 +49442,7 @@ class CommandsProvider {
|
|
|
48618
49442
|
if (!isFileURI(uri2)) {
|
|
48619
49443
|
throw new Error("history only supported on local file paths");
|
|
48620
49444
|
}
|
|
48621
|
-
const { getContextFileFromGitLog } = await import("./git-log-
|
|
49445
|
+
const { getContextFileFromGitLog } = await import("./git-log-CKjP84c8.mjs");
|
|
48622
49446
|
return getContextFileFromGitLog(uri2, options);
|
|
48623
49447
|
}
|
|
48624
49448
|
dispose() {
|
|
@@ -48864,32 +49688,10 @@ async function onTextDocumentChange(newCode) {
|
|
|
48864
49688
|
});
|
|
48865
49689
|
}
|
|
48866
49690
|
}
|
|
48867
|
-
let runningAuthProgressIndicator = null;
|
|
48868
|
-
function startAuthProgressIndicator() {
|
|
48869
|
-
window$1.withProgress(
|
|
48870
|
-
{
|
|
48871
|
-
location: ProgressLocation.Notification,
|
|
48872
|
-
title: "Signing in to Sourcegraph...",
|
|
48873
|
-
cancellable: true
|
|
48874
|
-
},
|
|
48875
|
-
(progress, token) => {
|
|
48876
|
-
token.onCancellationRequested(() => {
|
|
48877
|
-
runningAuthProgressIndicator = null;
|
|
48878
|
-
});
|
|
48879
|
-
return new Promise((resolve2) => {
|
|
48880
|
-
runningAuthProgressIndicator = resolve2;
|
|
48881
|
-
});
|
|
48882
|
-
}
|
|
48883
|
-
);
|
|
48884
|
-
}
|
|
48885
|
-
function closeAuthProgressIndicator() {
|
|
48886
|
-
runningAuthProgressIndicator == null ? void 0 : runningAuthProgressIndicator();
|
|
48887
|
-
runningAuthProgressIndicator = null;
|
|
48888
|
-
}
|
|
48889
49691
|
async function getContextFileFromUri(file, range2) {
|
|
48890
49692
|
return wrapInActiveSpan("commands.context.filePath", async (span2) => {
|
|
48891
49693
|
try {
|
|
48892
|
-
if (await contextFiltersProvider.isUriIgnored(file)) {
|
|
49694
|
+
if (await contextFiltersProvider.instance.isUriIgnored(file)) {
|
|
48893
49695
|
return null;
|
|
48894
49696
|
}
|
|
48895
49697
|
const doc2 = await workspace.openTextDocument(file);
|
|
@@ -48931,7 +49733,7 @@ async function getContextFileFromCursor(newCursorPosition) {
|
|
|
48931
49733
|
if (!(editor == null ? void 0 : editor.active) || !document2) {
|
|
48932
49734
|
throw new Error("No active editor");
|
|
48933
49735
|
}
|
|
48934
|
-
if (await contextFiltersProvider.isUriIgnored(document2.uri)) {
|
|
49736
|
+
if (await contextFiltersProvider.instance.isUriIgnored(document2.uri)) {
|
|
48935
49737
|
return null;
|
|
48936
49738
|
}
|
|
48937
49739
|
const activeCursor = newCursorPosition && new Selection(newCursorPosition, newCursorPosition);
|
|
@@ -49007,7 +49809,7 @@ async function getSelectionOrFileContext() {
|
|
|
49007
49809
|
});
|
|
49008
49810
|
}
|
|
49009
49811
|
async function shouldIgnore(uri2) {
|
|
49010
|
-
return Boolean(await contextFiltersProvider.isUriIgnored(uri2) || isCodyIgnoredFile(uri2));
|
|
49812
|
+
return Boolean(await contextFiltersProvider.instance.isUriIgnored(uri2) || isCodyIgnoredFile(uri2));
|
|
49011
49813
|
}
|
|
49012
49814
|
var fuzzysort$1 = { exports: {} };
|
|
49013
49815
|
(function(module2) {
|
|
@@ -49755,7 +50557,7 @@ async function getFileContextFiles(options) {
|
|
|
49755
50557
|
size: range2 ? 100 : item.file.byteSize,
|
|
49756
50558
|
source: ContextItemSource.User,
|
|
49757
50559
|
remoteRepositoryName: item.repository.name,
|
|
49758
|
-
isIgnored: contextFiltersProvider.isRepoNameIgnored(item.repository.name),
|
|
50560
|
+
isIgnored: contextFiltersProvider.instance.isRepoNameIgnored(item.repository.name),
|
|
49759
50561
|
uri: URI.file(`${item.repository.name}/${item.file.path}`)
|
|
49760
50562
|
}));
|
|
49761
50563
|
}
|
|
@@ -49830,7 +50632,7 @@ async function getSymbolContextFiles(query2, maxResults = 20, remoteRepositories
|
|
|
49830
50632
|
type: "symbol",
|
|
49831
50633
|
remoteRepositoryName: item.repository.name,
|
|
49832
50634
|
uri: URI.file(`${item.repository.name}/${symbol2.location.resource.path}`),
|
|
49833
|
-
isIgnored: contextFiltersProvider.isRepoNameIgnored(item.repository.name),
|
|
50635
|
+
isIgnored: contextFiltersProvider.instance.isRepoNameIgnored(item.repository.name),
|
|
49834
50636
|
source: ContextItemSource.User,
|
|
49835
50637
|
symbolName: symbol2.name,
|
|
49836
50638
|
// TODO [VK] Support other symbols kind
|
|
@@ -49892,7 +50694,7 @@ async function createContextFileFromUri(uri2, source, type2, selectionRange, kin
|
|
|
49892
50694
|
uri: uri2,
|
|
49893
50695
|
range: range2,
|
|
49894
50696
|
source,
|
|
49895
|
-
isIgnored: Boolean(await contextFiltersProvider.isUriIgnored(uri2))
|
|
50697
|
+
isIgnored: Boolean(await contextFiltersProvider.instance.isUriIgnored(uri2))
|
|
49896
50698
|
} : {
|
|
49897
50699
|
type: type2,
|
|
49898
50700
|
symbolName,
|
|
@@ -50035,7 +50837,7 @@ function migrateAndNotifyForOutdatedModels(model2) {
|
|
|
50035
50837
|
return model2;
|
|
50036
50838
|
}
|
|
50037
50839
|
const newModel = "anthropic/claude-3-5-sonnet-20240620";
|
|
50038
|
-
if (modelsService.getModelByID(newModel)) {
|
|
50840
|
+
if (modelsService.instance.getModelByID(newModel)) {
|
|
50039
50841
|
showNotificationIfNotShownYet(
|
|
50040
50842
|
"Claude 2 model support has been removed in favor of the newer Claude 3 models. All chats that used Claude 2 have been upgraded to Claude 3.",
|
|
50041
50843
|
"claude2-migration-notification-shown"
|
|
@@ -50209,7 +51011,7 @@ async function getContextFileFromCurrentFile() {
|
|
|
50209
51011
|
if (!document2) {
|
|
50210
51012
|
throw new Error("No active editor");
|
|
50211
51013
|
}
|
|
50212
|
-
if (await contextFiltersProvider.isUriIgnored(document2.uri)) {
|
|
51014
|
+
if (await contextFiltersProvider.instance.isUriIgnored(document2.uri)) {
|
|
50213
51015
|
return null;
|
|
50214
51016
|
}
|
|
50215
51017
|
return {
|
|
@@ -50376,7 +51178,7 @@ async function getContextFileFromDirectory(directory) {
|
|
|
50376
51178
|
}).sort((a, b) => a[0].localeCompare(b[0]));
|
|
50377
51179
|
for (const [name2, _type] of filtered) {
|
|
50378
51180
|
const fileUri = Utils$1.joinPath(dirUri, name2);
|
|
50379
|
-
if (await contextFiltersProvider.isUriIgnored(fileUri)) {
|
|
51181
|
+
if (await contextFiltersProvider.instance.isUriIgnored(fileUri)) {
|
|
50380
51182
|
continue;
|
|
50381
51183
|
}
|
|
50382
51184
|
const fileSize = await workspace.fs.stat(fileUri);
|
|
@@ -50434,7 +51236,7 @@ async function getWorkspaceFilesContext(globalPattern, excludePattern, maxResult
|
|
|
50434
51236
|
const results = (await workspace.findFiles(globalPattern, excluded, maxResults, token.token)).sort((a, b) => a.toString().localeCompare(b.toString()));
|
|
50435
51237
|
return (await Promise.all(
|
|
50436
51238
|
results.map(async (result) => {
|
|
50437
|
-
if (await contextFiltersProvider.isUriIgnored(result)) {
|
|
51239
|
+
if (await contextFiltersProvider.instance.isUriIgnored(result)) {
|
|
50438
51240
|
return null;
|
|
50439
51241
|
}
|
|
50440
51242
|
const decoded = await getDocText(result);
|
|
@@ -51105,51 +51907,9 @@ async function mergedPromptsAndLegacyCommands(query2, signal2) {
|
|
|
51105
51907
|
query: query2
|
|
51106
51908
|
};
|
|
51107
51909
|
}
|
|
51108
|
-
class AuthProviderSimplified {
|
|
51109
|
-
async openExternalAuthUrl(classicAuthProvider, method, tokenReceiverUrl) {
|
|
51110
|
-
if (!await openExternalAuthUrl(method, tokenReceiverUrl)) {
|
|
51111
|
-
return false;
|
|
51112
|
-
}
|
|
51113
|
-
classicAuthProvider.authProviderSimplifiedWillAttemptAuth();
|
|
51114
|
-
return true;
|
|
51115
|
-
}
|
|
51116
|
-
}
|
|
51117
|
-
function getAuthReferralCode() {
|
|
51118
|
-
return {
|
|
51119
|
-
"vscode-insiders": "CODY_INSIDERS",
|
|
51120
|
-
vscodium: "CODY_VSCODIUM",
|
|
51121
|
-
cursor: "CODY_CURSOR"
|
|
51122
|
-
}[env.uriScheme] || "CODY";
|
|
51123
|
-
}
|
|
51124
|
-
function openExternalAuthUrl(provider, tokenReceiverUrl) {
|
|
51125
|
-
const referralCode = getAuthReferralCode();
|
|
51126
|
-
const tokenReceiver = tokenReceiverUrl ? `&tokenReceiverUrl=${encodeURIComponent(tokenReceiverUrl)}` : "";
|
|
51127
|
-
const newTokenUrl = `/user/settings/tokens/new/callback?requestFrom=${referralCode}${tokenReceiver}`;
|
|
51128
|
-
const site = new URL(newTokenUrl, DOTCOM_URL);
|
|
51129
|
-
const genericLoginUrl = `${site}sign-in?returnTo=${newTokenUrl}`;
|
|
51130
|
-
const gitHubLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=github&pc=sams&redirect=${newTokenUrl}`;
|
|
51131
|
-
const gitLabLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=gitlab&pc=sams&redirect=${newTokenUrl}`;
|
|
51132
|
-
const googleLoginUrl = `${site}.auth/openidconnect/login?prompt_auth=google&pc=sams&redirect=${newTokenUrl}`;
|
|
51133
|
-
let uriSpec;
|
|
51134
|
-
switch (provider) {
|
|
51135
|
-
case "github":
|
|
51136
|
-
uriSpec = gitHubLoginUrl;
|
|
51137
|
-
break;
|
|
51138
|
-
case "gitlab":
|
|
51139
|
-
uriSpec = gitLabLoginUrl;
|
|
51140
|
-
break;
|
|
51141
|
-
case "google":
|
|
51142
|
-
uriSpec = googleLoginUrl;
|
|
51143
|
-
break;
|
|
51144
|
-
default:
|
|
51145
|
-
uriSpec = genericLoginUrl;
|
|
51146
|
-
break;
|
|
51147
|
-
}
|
|
51148
|
-
return env.openExternal(uriSpec);
|
|
51149
|
-
}
|
|
51150
51910
|
function recordExposedExperimentsToSpan(span2) {
|
|
51151
51911
|
var _a3;
|
|
51152
|
-
span2.setAttributes(featureFlagProvider.getExposedExperiments());
|
|
51912
|
+
span2.setAttributes(featureFlagProvider.instance.getExposedExperiments());
|
|
51153
51913
|
const extensionDetails = getExtensionDetails(getConfiguration(workspace.getConfiguration()));
|
|
51154
51914
|
span2.setAttributes(extensionDetails);
|
|
51155
51915
|
const extensionApi = (_a3 = extensions.getExtension("sourcegraph.cody-ai")) == null ? void 0 : _a3.exports;
|
|
@@ -52120,11 +52880,11 @@ function createRepositoryMention(repo, providerId) {
|
|
|
52120
52880
|
data: {
|
|
52121
52881
|
repoId: repo.id,
|
|
52122
52882
|
repoName: repo.name,
|
|
52123
|
-
isIgnored: contextFiltersProvider.isRepoNameIgnored(repo.name)
|
|
52883
|
+
isIgnored: contextFiltersProvider.instance.isRepoNameIgnored(repo.name)
|
|
52124
52884
|
}
|
|
52125
52885
|
};
|
|
52126
52886
|
}
|
|
52127
|
-
function getMentionMenuData(query2,
|
|
52887
|
+
function getMentionMenuData(query2, chatModel) {
|
|
52128
52888
|
const source = "chat";
|
|
52129
52889
|
const atMentionSourceTelemetryMetadataMapping = {
|
|
52130
52890
|
chat: 1
|
|
@@ -52149,23 +52909,19 @@ function getMentionMenuData(query2, remoteSearch, chatModel) {
|
|
|
52149
52909
|
const { input, context: context2 } = chatModel.contextWindow;
|
|
52150
52910
|
try {
|
|
52151
52911
|
const items = promiseFactoryToObservable(
|
|
52152
|
-
(signal2) =>
|
|
52153
|
-
|
|
52154
|
-
|
|
52155
|
-
|
|
52156
|
-
|
|
52157
|
-
|
|
52158
|
-
|
|
52159
|
-
|
|
52160
|
-
|
|
52161
|
-
|
|
52162
|
-
|
|
52163
|
-
|
|
52164
|
-
|
|
52165
|
-
isTooLarge: f.size ? f.size > ((context2 == null ? void 0 : context2.user) || input) : void 0
|
|
52166
|
-
}))
|
|
52167
|
-
);
|
|
52168
|
-
}
|
|
52912
|
+
(signal2) => getChatContextItemsForMention(
|
|
52913
|
+
{
|
|
52914
|
+
mentionQuery: query2,
|
|
52915
|
+
telemetryRecorder: scopedTelemetryRecorder,
|
|
52916
|
+
rangeFilter: !isCodyWeb
|
|
52917
|
+
},
|
|
52918
|
+
signal2
|
|
52919
|
+
).then(
|
|
52920
|
+
(items2) => items2.map((f) => ({
|
|
52921
|
+
...f,
|
|
52922
|
+
isTooLarge: f.size ? f.size > ((context2 == null ? void 0 : context2.user) || input) : void 0
|
|
52923
|
+
}))
|
|
52924
|
+
)
|
|
52169
52925
|
);
|
|
52170
52926
|
const queryLower = query2.text.toLowerCase();
|
|
52171
52927
|
const providers = (query2.provider === null ? isCodyWeb ? webMentionProvidersMetadata() : allMentionProvidersMetadata() : Observable.of([])).pipe(map$1((providers2) => providers2.filter((p) => p.title.toLowerCase().includes(queryLower))));
|
|
@@ -52180,7 +52936,7 @@ function getMentionMenuData(query2, remoteSearch, chatModel) {
|
|
|
52180
52936
|
throw new Error(`Error retrieving mentions: ${error}`);
|
|
52181
52937
|
}
|
|
52182
52938
|
}
|
|
52183
|
-
async function getChatContextItemsForMention(options,
|
|
52939
|
+
async function getChatContextItemsForMention(options, _2) {
|
|
52184
52940
|
const MAX_RESULTS = 20;
|
|
52185
52941
|
const { mentionQuery, telemetryRecorder: telemetryRecorder2, remoteRepositoriesNames, rangeFilter = true } = options;
|
|
52186
52942
|
switch (mentionQuery.provider) {
|
|
@@ -52250,15 +53006,13 @@ function contextItemMentionFromOpenCtxItem(item) {
|
|
|
52250
53006
|
};
|
|
52251
53007
|
}
|
|
52252
53008
|
function startClientStateBroadcaster({
|
|
52253
|
-
|
|
52254
|
-
getRemoteSearch,
|
|
53009
|
+
useRemoteSearch,
|
|
52255
53010
|
postMessage: rawPostMessage,
|
|
52256
53011
|
chatModel
|
|
52257
53012
|
}) {
|
|
52258
53013
|
const postMessage = idempotentPostMessage(rawPostMessage);
|
|
52259
53014
|
async function rawSendClientState(signal2) {
|
|
52260
53015
|
const items = [];
|
|
52261
|
-
const remoteSearch = getRemoteSearch();
|
|
52262
53016
|
const { input, context: context2 } = chatModel.contextWindow;
|
|
52263
53017
|
const userContextSize = (context2 == null ? void 0 : context2.user) ?? input;
|
|
52264
53018
|
const [contextFile] = await getSelectionOrFileContext();
|
|
@@ -52277,7 +53031,7 @@ function startClientStateBroadcaster({
|
|
|
52277
53031
|
};
|
|
52278
53032
|
items.push(item);
|
|
52279
53033
|
}
|
|
52280
|
-
const corpusItems = getCorpusContextItemsForEditorState(
|
|
53034
|
+
const corpusItems = getCorpusContextItemsForEditorState(useRemoteSearch);
|
|
52281
53035
|
items.push(...await corpusItems);
|
|
52282
53036
|
postMessage({ type: "clientState", value: { initialContext: items } });
|
|
52283
53037
|
}
|
|
@@ -52296,7 +53050,7 @@ function startClientStateBroadcaster({
|
|
|
52296
53050
|
);
|
|
52297
53051
|
disposables.push(
|
|
52298
53052
|
subscriptionDisposable(
|
|
52299
|
-
authProvider.changes.subscribe(async () => {
|
|
53053
|
+
authProvider.instance.changes.subscribe(async () => {
|
|
52300
53054
|
void sendClientState("immediate");
|
|
52301
53055
|
})
|
|
52302
53056
|
)
|
|
@@ -52304,15 +53058,13 @@ function startClientStateBroadcaster({
|
|
|
52304
53058
|
void sendClientState("immediate");
|
|
52305
53059
|
return Disposable.from(...disposables);
|
|
52306
53060
|
}
|
|
52307
|
-
async function getCorpusContextItemsForEditorState({
|
|
52308
|
-
remoteSearch
|
|
52309
|
-
}) {
|
|
53061
|
+
async function getCorpusContextItemsForEditorState(useRemote) {
|
|
52310
53062
|
var _a3;
|
|
52311
53063
|
const items = [];
|
|
52312
|
-
if (
|
|
53064
|
+
if (useRemote && workspaceReposMonitor) {
|
|
52313
53065
|
const repoMetadata = await workspaceReposMonitor.getRepoMetadata();
|
|
52314
53066
|
for (const repo of repoMetadata) {
|
|
52315
|
-
if (contextFiltersProvider.isRepoNameIgnored(repo.repoName)) {
|
|
53067
|
+
if (contextFiltersProvider.instance.isRepoNameIgnored(repo.repoName)) {
|
|
52316
53068
|
continue;
|
|
52317
53069
|
}
|
|
52318
53070
|
if (repo.remoteID === void 0) {
|
|
@@ -52393,147 +53145,6 @@ function debounced(fn) {
|
|
|
52393
53145
|
);
|
|
52394
53146
|
};
|
|
52395
53147
|
}
|
|
52396
|
-
function newAuthStatus(options) {
|
|
52397
|
-
var _a3;
|
|
52398
|
-
const {
|
|
52399
|
-
isOfflineMode,
|
|
52400
|
-
endpoint,
|
|
52401
|
-
siteHasCodyEnabled,
|
|
52402
|
-
username,
|
|
52403
|
-
authenticated,
|
|
52404
|
-
isDotCom: isDotCom2,
|
|
52405
|
-
siteVersion,
|
|
52406
|
-
userOrganizations
|
|
52407
|
-
} = options;
|
|
52408
|
-
if (isOfflineMode) {
|
|
52409
|
-
return { ...offlineModeAuthStatus, endpoint, username };
|
|
52410
|
-
}
|
|
52411
|
-
if (!authenticated) {
|
|
52412
|
-
return { ...unauthenticatedStatus, endpoint };
|
|
52413
|
-
}
|
|
52414
|
-
const primaryEmail = typeof options.primaryEmail === "string" ? options.primaryEmail : ((_a3 = options.primaryEmail) == null ? void 0 : _a3.email) || "";
|
|
52415
|
-
const requiresVerifiedEmail = isDotCom2;
|
|
52416
|
-
const hasVerifiedEmail = requiresVerifiedEmail && options.hasVerifiedEmail;
|
|
52417
|
-
const isAllowed = !requiresVerifiedEmail || hasVerifiedEmail;
|
|
52418
|
-
return {
|
|
52419
|
-
...options,
|
|
52420
|
-
showInvalidAccessTokenError: false,
|
|
52421
|
-
endpoint,
|
|
52422
|
-
primaryEmail,
|
|
52423
|
-
requiresVerifiedEmail,
|
|
52424
|
-
hasVerifiedEmail,
|
|
52425
|
-
isLoggedIn: siteHasCodyEnabled && authenticated && isAllowed,
|
|
52426
|
-
codyApiVersion: inferCodyApiVersion(siteVersion, isDotCom2),
|
|
52427
|
-
isFireworksTracingEnabled: isDotCom2 && !!(userOrganizations == null ? void 0 : userOrganizations.nodes.find((org) => org.name === "sourcegraph"))
|
|
52428
|
-
};
|
|
52429
|
-
}
|
|
52430
|
-
const countGeneratedCode = (text) => {
|
|
52431
|
-
const codeBlockRegex = /```[\S\s]*?```/g;
|
|
52432
|
-
const codeBlocks = text.match(codeBlockRegex);
|
|
52433
|
-
if (!codeBlocks) {
|
|
52434
|
-
return { charCount: 0, lineCount: 0 };
|
|
52435
|
-
}
|
|
52436
|
-
const count = { lineCount: 0, charCount: 0 };
|
|
52437
|
-
const backticks = "```";
|
|
52438
|
-
for (const block of codeBlocks) {
|
|
52439
|
-
const lines2 = block.split("\n");
|
|
52440
|
-
const codeLines = lines2.filter((line) => !line.startsWith(backticks));
|
|
52441
|
-
const lineCount = codeLines.length;
|
|
52442
|
-
const language = lines2[0].replace(backticks, "");
|
|
52443
|
-
const charCount = block.length - language.length - backticks.length * 2 - 2;
|
|
52444
|
-
count.charCount += charCount;
|
|
52445
|
-
count.lineCount += lineCount;
|
|
52446
|
-
}
|
|
52447
|
-
return count;
|
|
52448
|
-
};
|
|
52449
|
-
function inferCodyApiVersion(version2, isDotCom2) {
|
|
52450
|
-
const parsedVersion = semver.valid(version2);
|
|
52451
|
-
if (isDotCom2) {
|
|
52452
|
-
return 1;
|
|
52453
|
-
}
|
|
52454
|
-
if (parsedVersion == null) {
|
|
52455
|
-
return 1;
|
|
52456
|
-
}
|
|
52457
|
-
if (semver.gte(parsedVersion, "5.4.0")) {
|
|
52458
|
-
return 1;
|
|
52459
|
-
}
|
|
52460
|
-
if (parsedVersion === "0.0.0") {
|
|
52461
|
-
return 1;
|
|
52462
|
-
}
|
|
52463
|
-
return 0;
|
|
52464
|
-
}
|
|
52465
|
-
async function resolveContext({
|
|
52466
|
-
strategy,
|
|
52467
|
-
editor,
|
|
52468
|
-
input,
|
|
52469
|
-
providers: { remoteSearch, symf, localEmbeddings },
|
|
52470
|
-
signal: signal2
|
|
52471
|
-
}) {
|
|
52472
|
-
return wrapInActiveSpan("chat.resolveCorpusContextMentions", async () => {
|
|
52473
|
-
if (strategy === "none") {
|
|
52474
|
-
logDebug("ChatController", "resolveContext > none");
|
|
52475
|
-
return getVisibleEditorContext(editor);
|
|
52476
|
-
}
|
|
52477
|
-
const repoMentions = input.mentions.filter(
|
|
52478
|
-
(item) => item.type === "repository"
|
|
52479
|
-
);
|
|
52480
|
-
const treeMentions = input.mentions.filter(
|
|
52481
|
-
(item) => item.type === "tree"
|
|
52482
|
-
);
|
|
52483
|
-
const otherMentions = input.mentions.filter(
|
|
52484
|
-
(item) => item.type !== "repository" && item.type !== "tree"
|
|
52485
|
-
);
|
|
52486
|
-
const repoContextSearchResults = remoteSearch && repoMentions.length > 0 ? retrieveContextGracefully(
|
|
52487
|
-
searchRemote(
|
|
52488
|
-
remoteSearch,
|
|
52489
|
-
input.text,
|
|
52490
|
-
repoMentions.map((m) => m.repoID),
|
|
52491
|
-
signal2
|
|
52492
|
-
),
|
|
52493
|
-
"remote-search"
|
|
52494
|
-
) : [];
|
|
52495
|
-
const treeContextSymfSearchResults = symf && strategy !== "embeddings" && treeMentions.length > 0 ? Promise.all(
|
|
52496
|
-
treeMentions.map(
|
|
52497
|
-
(tree) => retrieveContextGracefully(
|
|
52498
|
-
searchSymf(symf, editor, tree.uri, input.text),
|
|
52499
|
-
`symf ${tree.name}`
|
|
52500
|
-
)
|
|
52501
|
-
)
|
|
52502
|
-
).then((v) => v.flat()) : Promise.resolve([]);
|
|
52503
|
-
const treeContextEmbeddingsSearchResults = localEmbeddings && strategy !== "keyword" && treeMentions.length > 0 ? retrieveContextGracefully(
|
|
52504
|
-
searchEmbeddingsLocal(localEmbeddings, input.text),
|
|
52505
|
-
"local-embeddings"
|
|
52506
|
-
) : Promise.resolve([]);
|
|
52507
|
-
const otherMentionsResolved = resolveContextItems(editor, otherMentions, input.text, signal2);
|
|
52508
|
-
const allContext = (await Promise.all([
|
|
52509
|
-
repoContextSearchResults,
|
|
52510
|
-
treeContextSymfSearchResults,
|
|
52511
|
-
treeContextEmbeddingsSearchResults,
|
|
52512
|
-
otherMentionsResolved
|
|
52513
|
-
])).flat();
|
|
52514
|
-
const priorityContext = await getPriorityContext(input.text, editor, allContext);
|
|
52515
|
-
return priorityContext.concat(allContext);
|
|
52516
|
-
});
|
|
52517
|
-
}
|
|
52518
|
-
async function searchRemote(remoteSearch, input, repoIDs, signal2) {
|
|
52519
|
-
return wrapInActiveSpan("chat.context.search.remote", async () => {
|
|
52520
|
-
if (!remoteSearch) {
|
|
52521
|
-
return [];
|
|
52522
|
-
}
|
|
52523
|
-
return (await remoteSearch.query(input, repoIDs, signal2)).map((result) => {
|
|
52524
|
-
return {
|
|
52525
|
-
type: "file",
|
|
52526
|
-
content: result.content,
|
|
52527
|
-
range: new Range(result.startLine, 0, result.endLine, 0),
|
|
52528
|
-
uri: result.uri,
|
|
52529
|
-
source: ContextItemSource.Unified,
|
|
52530
|
-
repoName: result.repoName,
|
|
52531
|
-
title: result.path,
|
|
52532
|
-
revision: result.commit
|
|
52533
|
-
};
|
|
52534
|
-
});
|
|
52535
|
-
});
|
|
52536
|
-
}
|
|
52537
53148
|
async function searchSymf(symf, editor, workspaceRoot, userText, blockOnIndex = false) {
|
|
52538
53149
|
return wrapInActiveSpan("chat.context.symf", async () => {
|
|
52539
53150
|
if (!symf) {
|
|
@@ -52812,9 +53423,10 @@ async function codebaseRootsFromMentions({ repos, trees }, signal2) {
|
|
|
52812
53423
|
}))
|
|
52813
53424
|
);
|
|
52814
53425
|
const localRepoNames = treesToRepoNames.flatMap((t) => t.names);
|
|
52815
|
-
|
|
53426
|
+
let localRepoIDs = localRepoNames.length === 0 ? [] : await graphqlClient.getRepoIds(localRepoNames, localRepoNames.length, signal2);
|
|
52816
53427
|
if (lodashExports.isError(localRepoIDs)) {
|
|
52817
|
-
|
|
53428
|
+
logError$1("codebaseRootFromMentions", "Failed to get repo IDs from Sourcegraph", localRepoIDs);
|
|
53429
|
+
localRepoIDs = [];
|
|
52818
53430
|
}
|
|
52819
53431
|
const uriToId = {};
|
|
52820
53432
|
for (const r2 of localRepoIDs) {
|
|
@@ -52838,9 +53450,10 @@ async function codebaseRootsFromMentions({ repos, trees }, signal2) {
|
|
|
52838
53450
|
return [...remoteRepos, ...localRoots];
|
|
52839
53451
|
}
|
|
52840
53452
|
class ContextRetriever {
|
|
52841
|
-
constructor(editor, symf, llms) {
|
|
53453
|
+
constructor(editor, symf, localEmbeddings, llms) {
|
|
52842
53454
|
this.editor = editor;
|
|
52843
53455
|
this.symf = symf;
|
|
53456
|
+
this.localEmbeddings = localEmbeddings;
|
|
52844
53457
|
this.llms = llms;
|
|
52845
53458
|
}
|
|
52846
53459
|
dispose() {
|
|
@@ -52848,8 +53461,13 @@ class ContextRetriever {
|
|
|
52848
53461
|
(_a3 = this.symf) == null ? void 0 : _a3.dispose();
|
|
52849
53462
|
}
|
|
52850
53463
|
async retrieveContext(mentions, inputTextWithoutContextChips, span2, signal2) {
|
|
52851
|
-
|
|
52852
|
-
|
|
53464
|
+
try {
|
|
53465
|
+
const roots = await codebaseRootsFromMentions(mentions, signal2);
|
|
53466
|
+
return await this._retrieveContext(roots, inputTextWithoutContextChips, span2, signal2);
|
|
53467
|
+
} catch (error) {
|
|
53468
|
+
logError$1("ContextRetriever", "Unhandled error retrieving context", error);
|
|
53469
|
+
return [];
|
|
53470
|
+
}
|
|
52853
53471
|
}
|
|
52854
53472
|
async _retrieveContext(roots, query2, span2, signal2) {
|
|
52855
53473
|
if (roots.length === 0) {
|
|
@@ -52867,10 +53485,20 @@ class ContextRetriever {
|
|
|
52867
53485
|
}
|
|
52868
53486
|
localRoots.push(root2.local);
|
|
52869
53487
|
}
|
|
52870
|
-
|
|
52871
|
-
|
|
52872
|
-
|
|
52873
|
-
|
|
53488
|
+
let changedFilesByRoot = [];
|
|
53489
|
+
let changedFiles = [];
|
|
53490
|
+
try {
|
|
53491
|
+
changedFilesByRoot = await Promise.all(
|
|
53492
|
+
localRoots.map((root2) => gitLocallyModifiedFiles(root2, signal2))
|
|
53493
|
+
);
|
|
53494
|
+
changedFiles = changedFilesByRoot.flat();
|
|
53495
|
+
} catch (error) {
|
|
53496
|
+
logDebug(
|
|
53497
|
+
"ContextRetriever",
|
|
53498
|
+
"Failed to get locally modified files, falling back to indexed context only",
|
|
53499
|
+
error
|
|
53500
|
+
);
|
|
53501
|
+
}
|
|
52874
53502
|
const [liveContext, indexedContext] = await Promise.all([
|
|
52875
53503
|
this.retrieveLiveContext(query2, rewrittenQuery.rewritten, changedFiles, signal2),
|
|
52876
53504
|
this.retrieveIndexedContext(roots, query2, rewrittenQuery.rewritten, span2, signal2)
|
|
@@ -52920,22 +53548,43 @@ class ContextRetriever {
|
|
|
52920
53548
|
)).flat();
|
|
52921
53549
|
}
|
|
52922
53550
|
async retrieveIndexedContext(roots, originalQuery, rewrittenQuery, span2, signal2) {
|
|
53551
|
+
var _a3;
|
|
53552
|
+
const preferServerContext = workspace.getConfiguration().get("cody.internal.serverSideContext", false);
|
|
52923
53553
|
const repoIDsOnRemote = /* @__PURE__ */ new Set();
|
|
52924
53554
|
const localRootURIs = /* @__PURE__ */ new Map();
|
|
52925
|
-
|
|
52926
|
-
|
|
52927
|
-
|
|
52928
|
-
|
|
52929
|
-
|
|
52930
|
-
|
|
53555
|
+
if (preferServerContext) {
|
|
53556
|
+
for (const root2 of roots) {
|
|
53557
|
+
if (root2.remoteRepos.length > 0) {
|
|
53558
|
+
for (const rr of root2.remoteRepos) {
|
|
53559
|
+
if (rr.id) {
|
|
53560
|
+
repoIDsOnRemote.add(rr.id);
|
|
53561
|
+
break;
|
|
53562
|
+
}
|
|
52931
53563
|
}
|
|
53564
|
+
} else if (root2.local && isFileURI(root2.local)) {
|
|
53565
|
+
localRootURIs.set(root2.local.toString(), root2.local);
|
|
53566
|
+
} else {
|
|
53567
|
+
throw new Error(
|
|
53568
|
+
`Codebase root ${JSON.stringify(root2)} is missing both remote and local root`
|
|
53569
|
+
);
|
|
53570
|
+
}
|
|
53571
|
+
}
|
|
53572
|
+
} else {
|
|
53573
|
+
for (const root2 of roots) {
|
|
53574
|
+
if (root2.local && isFileURI(root2.local)) {
|
|
53575
|
+
localRootURIs.set((_a3 = root2.local) == null ? void 0 : _a3.toString(), root2.local);
|
|
53576
|
+
} else if (root2.remoteRepos.length > 0) {
|
|
53577
|
+
for (const rr of root2.remoteRepos) {
|
|
53578
|
+
if (rr.id) {
|
|
53579
|
+
repoIDsOnRemote.add(rr.id);
|
|
53580
|
+
break;
|
|
53581
|
+
}
|
|
53582
|
+
}
|
|
53583
|
+
} else {
|
|
53584
|
+
throw new Error(
|
|
53585
|
+
`Codebase root ${JSON.stringify(root2)} is missing both remote and local root`
|
|
53586
|
+
);
|
|
52932
53587
|
}
|
|
52933
|
-
} else if (root2.local && isFileURI(root2.local)) {
|
|
52934
|
-
localRootURIs.set(root2.local.toString(), root2.local);
|
|
52935
|
-
} else {
|
|
52936
|
-
throw new Error(
|
|
52937
|
-
`Codebase root ${JSON.stringify(root2)} is missing both remote and local root`
|
|
52938
|
-
);
|
|
52939
53588
|
}
|
|
52940
53589
|
}
|
|
52941
53590
|
const remoteResultsPromise = this.retrieveIndexedContextFromRemote(
|
|
@@ -52977,8 +53626,9 @@ class ContextRetriever {
|
|
|
52977
53626
|
const contextStrategy = config.useContext;
|
|
52978
53627
|
span2.setAttribute("strategy", contextStrategy);
|
|
52979
53628
|
const symf = this.symf;
|
|
53629
|
+
let localSymfResults = Promise.resolve([]);
|
|
52980
53630
|
if (symf && contextStrategy !== "embeddings" && localRootURIs.length > 0) {
|
|
52981
|
-
|
|
53631
|
+
localSymfResults = Promise.all(
|
|
52982
53632
|
localRootURIs.map(
|
|
52983
53633
|
(rootURI) => (
|
|
52984
53634
|
// TODO(beyang): retire searchSymf and retrieveContextGracefully
|
|
@@ -52989,10 +53639,17 @@ class ContextRetriever {
|
|
|
52989
53639
|
)
|
|
52990
53640
|
)
|
|
52991
53641
|
)
|
|
53642
|
+
).then((r2) => r2.flat());
|
|
53643
|
+
}
|
|
53644
|
+
const localEmbeddings = this.localEmbeddings;
|
|
53645
|
+
let localEmbeddingsResults = Promise.resolve([]);
|
|
53646
|
+
if (localEmbeddings && contextStrategy !== "keyword" && localRootURIs.length > 0) {
|
|
53647
|
+
localEmbeddingsResults = retrieveContextGracefully(
|
|
53648
|
+
searchEmbeddingsLocal(localEmbeddings, originalQuery),
|
|
53649
|
+
"local-embeddings"
|
|
52992
53650
|
);
|
|
52993
|
-
return localRootResults.flat();
|
|
52994
53651
|
}
|
|
52995
|
-
return [];
|
|
53652
|
+
return (await Promise.all([localSymfResults, localEmbeddingsResults])).flat();
|
|
52996
53653
|
}
|
|
52997
53654
|
}
|
|
52998
53655
|
function contextSearchResultToContextItem(result) {
|
|
@@ -53280,11 +53937,11 @@ class PromptBuilder {
|
|
|
53280
53937
|
};
|
|
53281
53938
|
contextItems = sortContextItemsIfInTest(contextItems);
|
|
53282
53939
|
for (const item of contextItems) {
|
|
53283
|
-
if (isCodyIgnoredFile(item.uri) || await contextFiltersProvider.isUriIgnored(item.uri)) {
|
|
53940
|
+
if (isCodyIgnoredFile(item.uri) || await contextFiltersProvider.instance.isUriIgnored(item.uri)) {
|
|
53284
53941
|
result.ignored.push(item);
|
|
53285
53942
|
continue;
|
|
53286
53943
|
}
|
|
53287
|
-
if (item.type === "file" && (item.uri.scheme === "https" || item.uri.scheme === "http") && item.repoName && contextFiltersProvider.isRepoNameIgnored(item.repoName)) {
|
|
53944
|
+
if (item.type === "file" && (item.uri.scheme === "https" || item.uri.scheme === "http") && item.repoName && contextFiltersProvider.instance.isRepoNameIgnored(item.repoName)) {
|
|
53288
53945
|
result.ignored.push(item);
|
|
53289
53946
|
continue;
|
|
53290
53947
|
}
|
|
@@ -53389,8 +54046,7 @@ class DefaultPrompter {
|
|
|
53389
54046
|
}
|
|
53390
54047
|
}
|
|
53391
54048
|
class AuthDependentRetrievers {
|
|
53392
|
-
constructor(
|
|
53393
|
-
this.authProvider = authProvider;
|
|
54049
|
+
constructor(_localEmbeddings, _symf, _enterpriseContext) {
|
|
53394
54050
|
this._localEmbeddings = _localEmbeddings;
|
|
53395
54051
|
this._symf = _symf;
|
|
53396
54052
|
this._enterpriseContext = _enterpriseContext;
|
|
@@ -53399,7 +54055,7 @@ class AuthDependentRetrievers {
|
|
|
53399
54055
|
return workspace.getConfiguration().get("cody.advanced.agent.ide") === CodyIDE.Web;
|
|
53400
54056
|
}
|
|
53401
54057
|
isConsumer() {
|
|
53402
|
-
return
|
|
54058
|
+
return authProvider.instance.getAuthStatus().isDotCom;
|
|
53403
54059
|
}
|
|
53404
54060
|
allowRemoteContext() {
|
|
53405
54061
|
return this.isCodyWeb() || !this.isConsumer();
|
|
@@ -53417,7 +54073,6 @@ class AuthDependentRetrievers {
|
|
|
53417
54073
|
class ChatController {
|
|
53418
54074
|
constructor({
|
|
53419
54075
|
extensionUri,
|
|
53420
|
-
authProvider,
|
|
53421
54076
|
chatClient,
|
|
53422
54077
|
retrievers,
|
|
53423
54078
|
editor,
|
|
@@ -53428,11 +54083,8 @@ class ChatController {
|
|
|
53428
54083
|
extensionClient
|
|
53429
54084
|
}) {
|
|
53430
54085
|
__publicField2(this, "chatModel");
|
|
53431
|
-
__publicField2(this, "authProvider");
|
|
53432
54086
|
__publicField2(this, "chatClient");
|
|
53433
54087
|
__publicField2(this, "retrievers");
|
|
53434
|
-
__publicField2(this, "remoteSearch");
|
|
53435
|
-
__publicField2(this, "repoPicker");
|
|
53436
54088
|
__publicField2(this, "contextRetriever");
|
|
53437
54089
|
__publicField2(this, "editor");
|
|
53438
54090
|
__publicField2(this, "extensionClient");
|
|
@@ -53448,22 +54100,13 @@ class ChatController {
|
|
|
53448
54100
|
// =======================================================================
|
|
53449
54101
|
__publicField2(this, "extensionUri");
|
|
53450
54102
|
__publicField2(this, "_webviewPanelOrView");
|
|
53451
|
-
var _a3
|
|
54103
|
+
var _a3;
|
|
53452
54104
|
this.extensionUri = extensionUri;
|
|
53453
|
-
this.authProvider = authProvider;
|
|
53454
54105
|
this.chatClient = chatClient;
|
|
53455
54106
|
this.retrievers = retrievers;
|
|
53456
54107
|
this.editor = editor;
|
|
53457
54108
|
this.extensionClient = extensionClient;
|
|
53458
54109
|
this.contextRetriever = contextRetriever;
|
|
53459
|
-
this.repoPicker = ((_a3 = this.retrievers.enterpriseContext) == null ? void 0 : _a3.repoPicker) ?? null;
|
|
53460
|
-
this.remoteSearch = ((_b2 = this.retrievers.enterpriseContext) == null ? void 0 : _b2.createRemoteSearch()) ?? null;
|
|
53461
|
-
const authSubscription = this.authProvider.changes.subscribe(() => {
|
|
53462
|
-
var _a4, _b3;
|
|
53463
|
-
this.repoPicker = ((_a4 = this.retrievers.enterpriseContext) == null ? void 0 : _a4.repoPicker) ?? null;
|
|
53464
|
-
this.remoteSearch = ((_b3 = this.retrievers.enterpriseContext) == null ? void 0 : _b3.createRemoteSearch()) ?? null;
|
|
53465
|
-
});
|
|
53466
|
-
this.disposables.push({ dispose: () => authSubscription.unsubscribe() });
|
|
53467
54110
|
this.chatModel = new ChatModel(getDefaultModelID());
|
|
53468
54111
|
this.guardrails = guardrails;
|
|
53469
54112
|
this.startTokenReceiver = startTokenReceiver;
|
|
@@ -53471,16 +54114,15 @@ class ChatController {
|
|
|
53471
54114
|
if (TestSupport.instance) {
|
|
53472
54115
|
TestSupport.instance.chatPanelProvider.set(this);
|
|
53473
54116
|
}
|
|
53474
|
-
void ((
|
|
54117
|
+
void ((_a3 = this.retrievers.localEmbeddings) == null ? void 0 : _a3.start());
|
|
53475
54118
|
this.disposables.push({
|
|
53476
|
-
dispose: featureFlagProvider.onFeatureFlagChanged("", () => {
|
|
54119
|
+
dispose: featureFlagProvider.instance.onFeatureFlagChanged("", () => {
|
|
53477
54120
|
void this.sendConfig();
|
|
53478
54121
|
})
|
|
53479
54122
|
});
|
|
53480
54123
|
this.disposables.push(
|
|
53481
54124
|
startClientStateBroadcaster({
|
|
53482
|
-
|
|
53483
|
-
getRemoteSearch: () => this.remoteSearch,
|
|
54125
|
+
useRemoteSearch: this.retrievers.enterpriseContext !== null,
|
|
53484
54126
|
postMessage: (message) => this.postMessage(message),
|
|
53485
54127
|
chatModel: this.chatModel
|
|
53486
54128
|
})
|
|
@@ -53537,7 +54179,7 @@ class ChatController {
|
|
|
53537
54179
|
this.handleAbort();
|
|
53538
54180
|
break;
|
|
53539
54181
|
case "chatModel":
|
|
53540
|
-
await modelsService.setSelectedModel(ModelUsage.Chat, message.model);
|
|
54182
|
+
await modelsService.instance.setSelectedModel(ModelUsage.Chat, message.model);
|
|
53541
54183
|
this.handleSetChatModel(message.model);
|
|
53542
54184
|
break;
|
|
53543
54185
|
case "get-chat-models":
|
|
@@ -53563,7 +54205,7 @@ class ChatController {
|
|
|
53563
54205
|
await handleSmartApply(
|
|
53564
54206
|
message.id,
|
|
53565
54207
|
message.code,
|
|
53566
|
-
|
|
54208
|
+
authProvider.instance.getAuthStatus(),
|
|
53567
54209
|
message.instruction,
|
|
53568
54210
|
message.fileName
|
|
53569
54211
|
);
|
|
@@ -53609,13 +54251,6 @@ class ChatController {
|
|
|
53609
54251
|
});
|
|
53610
54252
|
break;
|
|
53611
54253
|
}
|
|
53612
|
-
case "context/choose-remote-search-repo": {
|
|
53613
|
-
await this.handleChooseRemoteSearchRepo(message.explicitRepos ?? void 0);
|
|
53614
|
-
break;
|
|
53615
|
-
}
|
|
53616
|
-
case "context/remove-remote-search-repo":
|
|
53617
|
-
void this.handleRemoveRemoteSearchRepo(message.repoId);
|
|
53618
|
-
break;
|
|
53619
54254
|
case "embeddings/index":
|
|
53620
54255
|
void ((_a3 = this.retrievers.localEmbeddings) == null ? void 0 : _a3.index());
|
|
53621
54256
|
break;
|
|
@@ -53655,11 +54290,11 @@ class ChatController {
|
|
|
53655
54290
|
break;
|
|
53656
54291
|
case "auth": {
|
|
53657
54292
|
if (message.authKind === "callback" && message.endpoint) {
|
|
53658
|
-
|
|
54293
|
+
authProvider.instance.redirectToEndpointLogin(message.endpoint);
|
|
53659
54294
|
break;
|
|
53660
54295
|
}
|
|
53661
54296
|
if (message.authKind === "offline") {
|
|
53662
|
-
|
|
54297
|
+
authProvider.instance.auth({ endpoint: "", token: "", isOfflineMode: true });
|
|
53663
54298
|
break;
|
|
53664
54299
|
}
|
|
53665
54300
|
if (message.authKind === "simplified-onboarding") {
|
|
@@ -53672,7 +54307,7 @@ class ChatController {
|
|
|
53672
54307
|
endpoint,
|
|
53673
54308
|
async (token, endpoint2) => {
|
|
53674
54309
|
closeAuthProgressIndicator();
|
|
53675
|
-
const authStatus = await
|
|
54310
|
+
const authStatus = await authProvider.instance.auth({ endpoint: endpoint2, token });
|
|
53676
54311
|
telemetryRecorder.recordEvent(
|
|
53677
54312
|
"cody.auth.fromTokenReceiver.web",
|
|
53678
54313
|
"succeeded",
|
|
@@ -53692,7 +54327,6 @@ class ChatController {
|
|
|
53692
54327
|
const authProviderSimplified = new AuthProviderSimplified();
|
|
53693
54328
|
const authMethod = message.authMethod || "dotcom";
|
|
53694
54329
|
const successfullyOpenedUrl = await authProviderSimplified.openExternalAuthUrl(
|
|
53695
|
-
this.authProvider,
|
|
53696
54330
|
authMethod,
|
|
53697
54331
|
tokenReceiverUrl
|
|
53698
54332
|
);
|
|
@@ -53702,11 +54336,14 @@ class ChatController {
|
|
|
53702
54336
|
break;
|
|
53703
54337
|
}
|
|
53704
54338
|
if (message.authKind === "signin" && message.endpoint && message.value) {
|
|
53705
|
-
await
|
|
54339
|
+
await authProvider.instance.auth({
|
|
54340
|
+
endpoint: message.endpoint,
|
|
54341
|
+
token: message.value
|
|
54342
|
+
});
|
|
53706
54343
|
break;
|
|
53707
54344
|
}
|
|
53708
54345
|
if (message.authKind === "signout") {
|
|
53709
|
-
await
|
|
54346
|
+
await authProvider.instance.signoutMenu();
|
|
53710
54347
|
this.setWebviewView(View.Login);
|
|
53711
54348
|
break;
|
|
53712
54349
|
}
|
|
@@ -53719,7 +54356,7 @@ class ChatController {
|
|
|
53719
54356
|
if (!token) {
|
|
53720
54357
|
return;
|
|
53721
54358
|
}
|
|
53722
|
-
const authStatus = await
|
|
54359
|
+
const authStatus = await authProvider.instance.auth({
|
|
53723
54360
|
endpoint: DOTCOM_URL.href,
|
|
53724
54361
|
token
|
|
53725
54362
|
});
|
|
@@ -53734,8 +54371,8 @@ class ChatController {
|
|
|
53734
54371
|
break;
|
|
53735
54372
|
}
|
|
53736
54373
|
case "troubleshoot/reloadAuth": {
|
|
53737
|
-
await
|
|
53738
|
-
const nextAuth =
|
|
54374
|
+
await authProvider.instance.reloadAuthStatus();
|
|
54375
|
+
const nextAuth = authProvider.instance.getAuthStatus();
|
|
53739
54376
|
telemetryRecorder.recordEvent("cody.troubleshoot", "reloadAuth", {
|
|
53740
54377
|
metadata: {
|
|
53741
54378
|
success: nextAuth.isLoggedIn ? 1 : 0
|
|
@@ -53782,7 +54419,7 @@ class ChatController {
|
|
|
53782
54419
|
}
|
|
53783
54420
|
async sendConfig() {
|
|
53784
54421
|
var _a3;
|
|
53785
|
-
const authStatus =
|
|
54422
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
53786
54423
|
const configForWebview = await this.getConfigForWebview();
|
|
53787
54424
|
const workspaceFolderUris = ((_a3 = workspace.workspaceFolders) == null ? void 0 : _a3.map((folder2) => folder2.uri.toString())) ?? [];
|
|
53788
54425
|
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
@@ -53824,7 +54461,7 @@ class ChatController {
|
|
|
53824
54461
|
async handleUserMessageSubmission(requestID, inputText, submitType, mentions, editorState, legacyAddEnhancedContext, signal2, source, command) {
|
|
53825
54462
|
return tracer.startActiveSpan("chat.submit", async (span2) => {
|
|
53826
54463
|
span2.setAttribute("sampled", true);
|
|
53827
|
-
const authStatus =
|
|
54464
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
53828
54465
|
const sharedProperties = {
|
|
53829
54466
|
requestID,
|
|
53830
54467
|
chatModel: this.chatModel.modelID,
|
|
@@ -53860,9 +54497,9 @@ class ChatController {
|
|
|
53860
54497
|
(_a3 = this.contextAPIClient) == null ? void 0 : _a3.detectChatIntent(requestID, inputText.toString());
|
|
53861
54498
|
mentions = mentions.map((m) => m.source ? m : { ...m, source: ContextItemSource.User });
|
|
53862
54499
|
if (legacyAddEnhancedContext) {
|
|
53863
|
-
const corpusMentions = await getCorpusContextItemsForEditorState(
|
|
53864
|
-
|
|
53865
|
-
|
|
54500
|
+
const corpusMentions = await getCorpusContextItemsForEditorState(
|
|
54501
|
+
this.retrievers.enterpriseContext !== null
|
|
54502
|
+
);
|
|
53866
54503
|
mentions = mentions.concat(corpusMentions);
|
|
53867
54504
|
const selectionContext = source === "chat" ? await getContextFileFromSelection() : [];
|
|
53868
54505
|
signal2.throwIfAborted();
|
|
@@ -53917,7 +54554,7 @@ class ChatController {
|
|
|
53917
54554
|
});
|
|
53918
54555
|
}
|
|
53919
54556
|
async sendChatExecutedTelemetry(span2, firstTokenSpan, inputText, sharedProperties, context2) {
|
|
53920
|
-
const authStatus =
|
|
54557
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
53921
54558
|
const contextSummary = {};
|
|
53922
54559
|
for (const { source } of context2.used) {
|
|
53923
54560
|
if (!source) {
|
|
@@ -53954,26 +54591,6 @@ class ChatController {
|
|
|
53954
54591
|
});
|
|
53955
54592
|
}
|
|
53956
54593
|
async computeContext({ text, mentions }, requestID, editorState, span2, signal2) {
|
|
53957
|
-
const legacyContextPromise = this.legacyComputeContext(
|
|
53958
|
-
{ text, mentions },
|
|
53959
|
-
requestID,
|
|
53960
|
-
editorState,
|
|
53961
|
-
span2,
|
|
53962
|
-
signal2
|
|
53963
|
-
);
|
|
53964
|
-
if (!workspace.getConfiguration().get("cody.internal.serverSideContext")) {
|
|
53965
|
-
return legacyContextPromise;
|
|
53966
|
-
}
|
|
53967
|
-
const contextPromise = this._computeContext(
|
|
53968
|
-
{ text, mentions },
|
|
53969
|
-
requestID,
|
|
53970
|
-
editorState,
|
|
53971
|
-
span2,
|
|
53972
|
-
signal2
|
|
53973
|
-
);
|
|
53974
|
-
return (await Promise.all([contextPromise, legacyContextPromise])).flat();
|
|
53975
|
-
}
|
|
53976
|
-
async _computeContext({ text, mentions }, requestID, editorState, span2, signal2) {
|
|
53977
54594
|
const inputTextWithoutContextChips = editorState ? PromptString.unsafe_fromUserQuery(
|
|
53978
54595
|
inputTextWithoutContextChipsFromPromptEditorState(editorState)
|
|
53979
54596
|
) : text;
|
|
@@ -54000,7 +54617,8 @@ class ChatController {
|
|
|
54000
54617
|
signal2
|
|
54001
54618
|
);
|
|
54002
54619
|
const rankedContext = [];
|
|
54003
|
-
|
|
54620
|
+
const useReranker = workspace.getConfiguration().get("cody.internal.useReranker") ?? false;
|
|
54621
|
+
if (useReranker && this.contextAPIClient && retrievedContext.length > 1) {
|
|
54004
54622
|
const response = await this.contextAPIClient.rankContext(
|
|
54005
54623
|
requestID,
|
|
54006
54624
|
inputTextWithoutContextChips.toString(),
|
|
@@ -54045,42 +54663,6 @@ class ChatController {
|
|
|
54045
54663
|
});
|
|
54046
54664
|
return rankedContext;
|
|
54047
54665
|
}
|
|
54048
|
-
async legacyComputeContext({ text, mentions }, requestID, editorState, span2, signal2) {
|
|
54049
|
-
var _a3;
|
|
54050
|
-
const config = getConfiguration();
|
|
54051
|
-
const contextStrategy = config.useContext;
|
|
54052
|
-
span2.setAttribute("strategy", contextStrategy);
|
|
54053
|
-
const inputTextWithoutContextChips = editorState ? PromptString.unsafe_fromUserQuery(
|
|
54054
|
-
inputTextWithoutContextChipsFromPromptEditorState(editorState)
|
|
54055
|
-
) : text;
|
|
54056
|
-
const context2 = (await Promise.all([
|
|
54057
|
-
resolveContext({
|
|
54058
|
-
strategy: contextStrategy,
|
|
54059
|
-
editor: this.editor,
|
|
54060
|
-
input: { text: inputTextWithoutContextChips, mentions },
|
|
54061
|
-
providers: {
|
|
54062
|
-
localEmbeddings: this.retrievers.localEmbeddings,
|
|
54063
|
-
symf: this.retrievers.symf,
|
|
54064
|
-
remoteSearch: this.remoteSearch
|
|
54065
|
-
},
|
|
54066
|
-
signal: signal2
|
|
54067
|
-
}),
|
|
54068
|
-
getContextForChatMessage(text.toString(), signal2)
|
|
54069
|
-
])).flat();
|
|
54070
|
-
if (context2.length > 0) {
|
|
54071
|
-
void ((_a3 = this.contextAPIClient) == null ? void 0 : _a3.rankContext(
|
|
54072
|
-
requestID,
|
|
54073
|
-
inputTextWithoutContextChips.toString(),
|
|
54074
|
-
context2
|
|
54075
|
-
));
|
|
54076
|
-
}
|
|
54077
|
-
return [
|
|
54078
|
-
{
|
|
54079
|
-
strategy: `(legacy)${contextStrategy}`,
|
|
54080
|
-
items: context2.flat()
|
|
54081
|
-
}
|
|
54082
|
-
];
|
|
54083
|
-
}
|
|
54084
54666
|
startNewSubmitOrEditOperation() {
|
|
54085
54667
|
var _a3;
|
|
54086
54668
|
(_a3 = this.submitOrEditOperation) == null ? void 0 : _a3.abort();
|
|
@@ -54189,21 +54771,6 @@ class ChatController {
|
|
|
54189
54771
|
});
|
|
54190
54772
|
}
|
|
54191
54773
|
}
|
|
54192
|
-
async handleChooseRemoteSearchRepo(explicitRepos) {
|
|
54193
|
-
var _a3;
|
|
54194
|
-
if (!this.remoteSearch) {
|
|
54195
|
-
return;
|
|
54196
|
-
}
|
|
54197
|
-
const repos = explicitRepos ?? await ((_a3 = this.repoPicker) == null ? void 0 : _a3.show(this.remoteSearch.getRepos(RepoInclusion.Manual)));
|
|
54198
|
-
if (repos) {
|
|
54199
|
-
this.chatModel.setSelectedRepos(repos);
|
|
54200
|
-
this.remoteSearch.setRepos(repos, RepoInclusion.Manual);
|
|
54201
|
-
}
|
|
54202
|
-
}
|
|
54203
|
-
handleRemoveRemoteSearchRepo(repoId) {
|
|
54204
|
-
var _a3;
|
|
54205
|
-
(_a3 = this.remoteSearch) == null ? void 0 : _a3.removeRepo(repoId);
|
|
54206
|
-
}
|
|
54207
54774
|
// #endregion
|
|
54208
54775
|
// =======================================================================
|
|
54209
54776
|
// #region view updaters
|
|
@@ -54247,11 +54814,11 @@ class ChatController {
|
|
|
54247
54814
|
captureException(error);
|
|
54248
54815
|
}
|
|
54249
54816
|
postChatModels() {
|
|
54250
|
-
const authStatus =
|
|
54817
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
54251
54818
|
if (!(authStatus == null ? void 0 : authStatus.isLoggedIn)) {
|
|
54252
54819
|
return;
|
|
54253
54820
|
}
|
|
54254
|
-
const models = modelsService.getModels(ModelUsage.Chat);
|
|
54821
|
+
const models = modelsService.instance.getModels(ModelUsage.Chat);
|
|
54255
54822
|
void this.postMessage({
|
|
54256
54823
|
type: "chatModels",
|
|
54257
54824
|
models
|
|
@@ -54280,7 +54847,7 @@ class ChatController {
|
|
|
54280
54847
|
var _a3;
|
|
54281
54848
|
const { prompt, context: context2 } = await prompter2.makePrompt(
|
|
54282
54849
|
this.chatModel,
|
|
54283
|
-
|
|
54850
|
+
authProvider.instance.getAuthStatus().codyApiVersion
|
|
54284
54851
|
);
|
|
54285
54852
|
abortSignal.throwIfAborted();
|
|
54286
54853
|
this.chatModel.setLastMessageContext([...context2.used, ...context2.ignored], contextAlternatives);
|
|
@@ -54288,7 +54855,7 @@ class ChatController {
|
|
|
54288
54855
|
return { prompt, context: context2 };
|
|
54289
54856
|
}
|
|
54290
54857
|
async buildPrivateContextSummary(context2) {
|
|
54291
|
-
const isDotCom2 =
|
|
54858
|
+
const isDotCom2 = authProvider.instance.getAuthStatus().isDotCom;
|
|
54292
54859
|
if (!isDotCom2) {
|
|
54293
54860
|
return {};
|
|
54294
54861
|
}
|
|
@@ -54424,7 +54991,7 @@ class ChatController {
|
|
|
54424
54991
|
this.chatModel.addBotMessage({ text: messageText });
|
|
54425
54992
|
void this.saveSession();
|
|
54426
54993
|
this.postViewTranscript();
|
|
54427
|
-
const authStatus =
|
|
54994
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
54428
54995
|
const generatedCode = countGeneratedCode(messageText.toString());
|
|
54429
54996
|
const responseEventAction = generatedCode.charCount > 0 ? "hasCode" : "noCode";
|
|
54430
54997
|
telemetryRecorder.recordEvent("cody.chatResponse", responseEventAction, {
|
|
@@ -54455,37 +55022,23 @@ class ChatController {
|
|
|
54455
55022
|
get sessionID() {
|
|
54456
55023
|
return this.chatModel.sessionID;
|
|
54457
55024
|
}
|
|
54458
|
-
// Sets the provider up for a new chat that is not being restored from a
|
|
54459
|
-
// saved session.
|
|
54460
|
-
async newSession() {
|
|
54461
|
-
var _a3, _b2;
|
|
54462
|
-
(_b2 = this.remoteSearch) == null ? void 0 : _b2.setRepos(
|
|
54463
|
-
await ((_a3 = this.repoPicker) == null ? void 0 : _a3.getDefaultRepos()) || [],
|
|
54464
|
-
RepoInclusion.Manual
|
|
54465
|
-
);
|
|
54466
|
-
}
|
|
54467
55025
|
// Attempts to restore the chat to the given sessionID, if it exists in
|
|
54468
55026
|
// history. If it does, then saves the current session and cancels the
|
|
54469
55027
|
// current in-progress completion. If the chat does not exist, then this
|
|
54470
55028
|
// is a no-op.
|
|
54471
55029
|
async restoreSession(sessionID) {
|
|
54472
|
-
|
|
54473
|
-
const oldTranscript = chatHistory.getChat(this.authProvider.getAuthStatus(), sessionID);
|
|
55030
|
+
const oldTranscript = chatHistory.getChat(authProvider.instance.getAuthStatus(), sessionID);
|
|
54474
55031
|
if (!oldTranscript) {
|
|
54475
|
-
return
|
|
55032
|
+
return;
|
|
54476
55033
|
}
|
|
54477
55034
|
this.cancelSubmitOrEditOperation();
|
|
54478
55035
|
const newModel = newChatModelFromSerializedChatTranscript(oldTranscript, this.chatModel.modelID);
|
|
54479
55036
|
this.chatModel = newModel;
|
|
54480
|
-
if (this.remoteSearch) {
|
|
54481
|
-
const repos = this.chatModel.getSelectedRepos() || await ((_a3 = this.repoPicker) == null ? void 0 : _a3.getDefaultRepos()) || [];
|
|
54482
|
-
this.remoteSearch.setRepos(repos, RepoInclusion.Manual);
|
|
54483
|
-
}
|
|
54484
55037
|
this.postViewTranscript();
|
|
54485
55038
|
}
|
|
54486
55039
|
async saveSession() {
|
|
54487
55040
|
const allHistory = await chatHistory.saveChat(
|
|
54488
|
-
|
|
55041
|
+
authProvider.instance.getAuthStatus(),
|
|
54489
55042
|
this.chatModel.toSerializedChatTranscript()
|
|
54490
55043
|
);
|
|
54491
55044
|
if (allHistory) {
|
|
@@ -54513,7 +55066,7 @@ class ChatController {
|
|
|
54513
55066
|
return this.webviewPanelOrView;
|
|
54514
55067
|
}
|
|
54515
55068
|
const viewType = CodyChatEditorViewType;
|
|
54516
|
-
const panelTitle = ((_a3 = chatHistory.getChat(
|
|
55069
|
+
const panelTitle = ((_a3 = chatHistory.getChat(authProvider.instance.getAuthStatus(), this.chatModel.sessionID)) == null ? void 0 : _a3.chatTitle) || getChatPanelTitle(lastQuestion);
|
|
54517
55070
|
const viewColumn = activePanelViewColumn || ViewColumn.Beside;
|
|
54518
55071
|
const webviewPath = Uri.joinPath(this.extensionUri, "dist", "webviews");
|
|
54519
55072
|
const panel2 = window$1.createWebviewPanel(
|
|
@@ -54583,8 +55136,8 @@ class ChatController {
|
|
|
54583
55136
|
}
|
|
54584
55137
|
}),
|
|
54585
55138
|
{
|
|
54586
|
-
mentionMenuData: (query2) => getMentionMenuData(query2, this.
|
|
54587
|
-
evaluatedFeatureFlag: (flag2) => featureFlagProvider.evaluatedFeatureFlag(flag2),
|
|
55139
|
+
mentionMenuData: (query2) => getMentionMenuData(query2, this.chatModel),
|
|
55140
|
+
evaluatedFeatureFlag: (flag2) => featureFlagProvider.instance.evaluatedFeatureFlag(flag2),
|
|
54588
55141
|
prompts: (query2) => promiseFactoryToObservable(
|
|
54589
55142
|
(signal2) => mergedPromptsAndLegacyCommands(query2, signal2)
|
|
54590
55143
|
)
|
|
@@ -54724,7 +55277,7 @@ function revealWebviewViewOrPanel(viewOrPanel) {
|
|
|
54724
55277
|
function getDefaultModelID() {
|
|
54725
55278
|
const pending = "";
|
|
54726
55279
|
try {
|
|
54727
|
-
return modelsService.getDefaultChatModel() || pending;
|
|
55280
|
+
return modelsService.instance.getDefaultChatModel() || pending;
|
|
54728
55281
|
} catch {
|
|
54729
55282
|
return pending;
|
|
54730
55283
|
}
|
|
@@ -54750,7 +55303,7 @@ function combineContext(explicitMentions, openCtxContext, priorityContext, retri
|
|
|
54750
55303
|
}
|
|
54751
55304
|
const CodyChatEditorViewType = "cody.editorPanel";
|
|
54752
55305
|
class ChatsController {
|
|
54753
|
-
constructor(options, chatClient,
|
|
55306
|
+
constructor(options, chatClient, enterpriseContext, localEmbeddings, symf, contextRetriever, guardrails, contextAPIClient, extensionClient) {
|
|
54754
55307
|
// Chat view in the panel (typically in the sidebar)
|
|
54755
55308
|
__publicField2(this, "panel");
|
|
54756
55309
|
// Chat views in editor panels
|
|
@@ -54761,7 +55314,6 @@ class ChatsController {
|
|
|
54761
55314
|
__publicField2(this, "disposables", []);
|
|
54762
55315
|
this.options = options;
|
|
54763
55316
|
this.chatClient = chatClient;
|
|
54764
|
-
this.authProvider = authProvider;
|
|
54765
55317
|
this.enterpriseContext = enterpriseContext;
|
|
54766
55318
|
this.localEmbeddings = localEmbeddings;
|
|
54767
55319
|
this.symf = symf;
|
|
@@ -54773,7 +55325,7 @@ class ChatsController {
|
|
|
54773
55325
|
this.panel = this.createChatController();
|
|
54774
55326
|
this.disposables.push(
|
|
54775
55327
|
subscriptionDisposable(
|
|
54776
|
-
|
|
55328
|
+
authProvider.instance.changes.subscribe((authStatus) => this.setAuthStatus(authStatus))
|
|
54777
55329
|
)
|
|
54778
55330
|
);
|
|
54779
55331
|
}
|
|
@@ -55008,7 +55560,7 @@ class ChatsController {
|
|
|
55008
55560
|
*/
|
|
55009
55561
|
async exportHistory() {
|
|
55010
55562
|
telemetryRecorder.recordEvent("cody.exportChatHistoryButton", "clicked");
|
|
55011
|
-
const authStatus =
|
|
55563
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
55012
55564
|
if (authStatus.isLoggedIn) {
|
|
55013
55565
|
try {
|
|
55014
55566
|
const historyJson = chatHistory.getLocalHistory(authStatus);
|
|
@@ -55033,7 +55585,7 @@ class ChatsController {
|
|
|
55033
55585
|
async clearHistory(chatID) {
|
|
55034
55586
|
const ClearWithoutConfirmID = "clear-all-no-confirm";
|
|
55035
55587
|
const isClearAll = !chatID || chatID === ClearWithoutConfirmID;
|
|
55036
|
-
const authStatus =
|
|
55588
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
55037
55589
|
if (isClearAll) {
|
|
55038
55590
|
if (chatID !== ClearWithoutConfirmID) {
|
|
55039
55591
|
const userConfirmation = await window$1.showWarningMessage(
|
|
@@ -55083,8 +55635,6 @@ class ChatsController {
|
|
|
55083
55635
|
const chatController = this.createChatController();
|
|
55084
55636
|
if (chatID) {
|
|
55085
55637
|
await chatController.restoreSession(chatID);
|
|
55086
|
-
} else {
|
|
55087
|
-
await chatController.newSession();
|
|
55088
55638
|
}
|
|
55089
55639
|
if (panel2) {
|
|
55090
55640
|
this.activeEditor = chatController;
|
|
@@ -55115,7 +55665,6 @@ class ChatsController {
|
|
|
55115
55665
|
...this.options,
|
|
55116
55666
|
chatClient: this.chatClient,
|
|
55117
55667
|
retrievers: new AuthDependentRetrievers(
|
|
55118
|
-
this.authProvider,
|
|
55119
55668
|
this.localEmbeddings,
|
|
55120
55669
|
this.symf,
|
|
55121
55670
|
this.enterpriseContext
|
|
@@ -55552,7 +56101,7 @@ const DOCUMENTABLE_SYMBOL_THROTTLE = 10;
|
|
|
55552
56101
|
const GHOST_TEXT_THROTTLE = 250;
|
|
55553
56102
|
const TELEMETRY_THROTTLE = 30 * 1e3;
|
|
55554
56103
|
class GhostHintDecorator {
|
|
55555
|
-
constructor(
|
|
56104
|
+
constructor() {
|
|
55556
56105
|
// permanentDisposables are disposed when this instance is disposed.
|
|
55557
56106
|
__publicField2(this, "permanentDisposables", []);
|
|
55558
56107
|
// activeDisposables are disposed when the ghost hint is inactive (e.g., due to sign out)
|
|
@@ -55584,17 +56133,17 @@ class GhostHintDecorator {
|
|
|
55584
56133
|
trailing: true
|
|
55585
56134
|
}
|
|
55586
56135
|
);
|
|
55587
|
-
const initialAuth = authProvider.getAuthStatus();
|
|
56136
|
+
const initialAuth = authProvider.instance.getAuthStatus();
|
|
55588
56137
|
this.updateEnablement(initialAuth);
|
|
55589
56138
|
this.permanentDisposables.push(
|
|
55590
56139
|
subscriptionDisposable(
|
|
55591
|
-
authProvider.changes.subscribe((authStatus) => this.updateEnablement(authStatus))
|
|
56140
|
+
authProvider.instance.changes.subscribe((authStatus) => this.updateEnablement(authStatus))
|
|
55592
56141
|
)
|
|
55593
56142
|
);
|
|
55594
56143
|
this.permanentDisposables.push(
|
|
55595
56144
|
workspace.onDidChangeConfiguration((e) => {
|
|
55596
56145
|
if (e.affectsConfiguration("cody")) {
|
|
55597
|
-
this.updateEnablement(authProvider.getAuthStatus());
|
|
56146
|
+
this.updateEnablement(authProvider.instance.getAuthStatus());
|
|
55598
56147
|
}
|
|
55599
56148
|
}),
|
|
55600
56149
|
workspace.onDidChangeTextDocument((event) => {
|
|
@@ -55683,7 +56232,7 @@ class GhostHintDecorator {
|
|
|
55683
56232
|
}
|
|
55684
56233
|
}
|
|
55685
56234
|
async setGhostText(editor, position, variant, textPadding = 0) {
|
|
55686
|
-
if (await contextFiltersProvider.isUriIgnored(editor.document.uri)) {
|
|
56235
|
+
if (await contextFiltersProvider.instance.isUriIgnored(editor.document.uri)) {
|
|
55687
56236
|
return;
|
|
55688
56237
|
}
|
|
55689
56238
|
this.fireThrottledDisplayEvent(variant);
|
|
@@ -56073,7 +56622,7 @@ class CodySourceControl {
|
|
|
56073
56622
|
this.abortController = abortController;
|
|
56074
56623
|
}
|
|
56075
56624
|
setAuthStatus(_2) {
|
|
56076
|
-
const models = modelsService.getModels(ModelUsage.Chat);
|
|
56625
|
+
const models = modelsService.instance.getModels(ModelUsage.Chat);
|
|
56077
56626
|
const preferredModel = models.find((p) => p.id.includes("claude-3-haiku"));
|
|
56078
56627
|
this.model = preferredModel ?? models[0];
|
|
56079
56628
|
}
|
|
@@ -56121,48 +56670,6 @@ function createInlineCompletionItemProvider() {
|
|
|
56121
56670
|
return { dispose: () => {
|
|
56122
56671
|
} };
|
|
56123
56672
|
}
|
|
56124
|
-
function logFirstEnrollmentEvent(key, isEnabled) {
|
|
56125
|
-
const isEnrolled = localStorage.getEnrollmentHistory(key);
|
|
56126
|
-
const eventName = getFeatureFlagEventName(key);
|
|
56127
|
-
if (isEnrolled || !eventName) {
|
|
56128
|
-
return isEnrolled && !!eventName;
|
|
56129
|
-
}
|
|
56130
|
-
const args2 = { variant: isEnabled ? "treatment" : "control" };
|
|
56131
|
-
telemetryRecorder.recordEvent(`cody.experiment.${eventName}`, "enrolled", {
|
|
56132
|
-
privateMetadata: args2
|
|
56133
|
-
});
|
|
56134
|
-
return true;
|
|
56135
|
-
}
|
|
56136
|
-
function getFeatureFlagEventName(key) {
|
|
56137
|
-
switch (key) {
|
|
56138
|
-
case FeatureFlag.CodyInteractiveTutorial:
|
|
56139
|
-
return "interactiveTutorial";
|
|
56140
|
-
default:
|
|
56141
|
-
return void 0;
|
|
56142
|
-
}
|
|
56143
|
-
}
|
|
56144
|
-
let tutorialDocumentUri;
|
|
56145
|
-
const setTutorialUri = (context2) => {
|
|
56146
|
-
const tutorialPath = path$1.join(context2.extensionUri.fsPath, "walkthroughs", "cody_tutorial.py");
|
|
56147
|
-
tutorialDocumentUri = Uri.file(tutorialPath);
|
|
56148
|
-
return tutorialDocumentUri;
|
|
56149
|
-
};
|
|
56150
|
-
const isInTutorial = (document2) => {
|
|
56151
|
-
if (!tutorialDocumentUri) {
|
|
56152
|
-
return false;
|
|
56153
|
-
}
|
|
56154
|
-
return document2.uri.toString() === tutorialDocumentUri.toString();
|
|
56155
|
-
};
|
|
56156
|
-
const maybeStartInteractiveTutorial = async () => {
|
|
56157
|
-
telemetryRecorder.recordEvent("cody.interactiveTutorial", "attemptingStart");
|
|
56158
|
-
await featureFlagProvider.refresh();
|
|
56159
|
-
const enabled = await featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyInteractiveTutorial);
|
|
56160
|
-
logFirstEnrollmentEvent(FeatureFlag.CodyInteractiveTutorial, enabled);
|
|
56161
|
-
if (!enabled) {
|
|
56162
|
-
return;
|
|
56163
|
-
}
|
|
56164
|
-
return commands$1.executeCommand("cody.tutorial.start");
|
|
56165
|
-
};
|
|
56166
56673
|
const defaultLatencies = {
|
|
56167
56674
|
user: 50,
|
|
56168
56675
|
lowPerformance: 1e3,
|
|
@@ -56390,7 +56897,7 @@ async function filter(snippets) {
|
|
|
56390
56897
|
if (isCodyIgnoredFile(snippet.uri)) {
|
|
56391
56898
|
return null;
|
|
56392
56899
|
}
|
|
56393
|
-
if (await contextFiltersProvider.isUriIgnored(snippet.uri)) {
|
|
56900
|
+
if (await contextFiltersProvider.instance.isUriIgnored(snippet.uri)) {
|
|
56394
56901
|
return null;
|
|
56395
56902
|
}
|
|
56396
56903
|
return snippet;
|
|
@@ -158562,7 +159069,7 @@ class InlineCompletionItemProvider {
|
|
|
158562
159069
|
logIgnored(document2.uri, "cody-ignore", isManualCompletion);
|
|
158563
159070
|
return null;
|
|
158564
159071
|
}
|
|
158565
|
-
if (await contextFiltersProvider.isUriIgnored(document2.uri)) {
|
|
159072
|
+
if (await contextFiltersProvider.instance.isUriIgnored(document2.uri)) {
|
|
158566
159073
|
logIgnored(document2.uri, "context-filter", isManualCompletion);
|
|
158567
159074
|
return null;
|
|
158568
159075
|
}
|
|
@@ -159570,7 +160077,7 @@ function createClient(config, logger2) {
|
|
|
159570
160077
|
`POST ${url}`,
|
|
159571
160078
|
async function* (span2) {
|
|
159572
160079
|
var _a3;
|
|
159573
|
-
const tracingFlagEnabled = await featureFlagProvider.evaluateFeatureFlag(
|
|
160080
|
+
const tracingFlagEnabled = await featureFlagProvider.instance.evaluateFeatureFlag(
|
|
159574
160081
|
FeatureFlag.CodyAutocompleteTracing
|
|
159575
160082
|
);
|
|
159576
160083
|
const headers = new Headers({
|
|
@@ -159601,7 +160108,7 @@ function createClient(config, logger2) {
|
|
|
159601
160108
|
var _a4;
|
|
159602
160109
|
return {
|
|
159603
160110
|
...m,
|
|
159604
|
-
text: await ((_a4 = m.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider))
|
|
160111
|
+
text: await ((_a4 = m.text) == null ? void 0 : _a4.toFilteredString(contextFiltersProvider.instance))
|
|
159605
160112
|
};
|
|
159606
160113
|
})
|
|
159607
160114
|
)
|
|
@@ -159750,7 +160257,9 @@ function createFastPathClient(requestParams, abortController, params) {
|
|
|
159750
160257
|
}
|
|
159751
160258
|
};
|
|
159752
160259
|
}
|
|
159753
|
-
const prompt = await requestParams.messages[0].text.toFilteredString(
|
|
160260
|
+
const prompt = await requestParams.messages[0].text.toFilteredString(
|
|
160261
|
+
contextFiltersProvider.instance
|
|
160262
|
+
);
|
|
159754
160263
|
const fireworksRequest = {
|
|
159755
160264
|
model: (fireworksConfig == null ? void 0 : fireworksConfig.model) || ((_a3 = requestParams.model) == null ? void 0 : _a3.replace(/^fireworks\//, "")),
|
|
159756
160265
|
prompt,
|
|
@@ -159987,7 +160496,14 @@ class FireworksProvider extends Provider {
|
|
|
159987
160496
|
isNode ? dotcomTokenToGatewayToken(config.accessToken) : void 0;
|
|
159988
160497
|
}
|
|
159989
160498
|
checkIfDirectRouteShouldBeEnabled() {
|
|
159990
|
-
|
|
160499
|
+
const directRouteModels = [
|
|
160500
|
+
DEEPSEEK_CODER_V2_LITE_BASE_DIRECT_ROUTE,
|
|
160501
|
+
DEEPSEEK_CODER_V2_LITE_BASE_WINDOW_4096,
|
|
160502
|
+
FIREWORKS_DEEPSEEK_7B_LANG_ALL,
|
|
160503
|
+
FIREWORKS_DEEPSEEK_7B_LANG_SPECIFIC_V0,
|
|
160504
|
+
FIREWORKS_DEEPSEEK_7B_LANG_SPECIFIC_V1
|
|
160505
|
+
];
|
|
160506
|
+
return directRouteModels.includes(this.model);
|
|
159991
160507
|
}
|
|
159992
160508
|
generateCompletions(abortSignal, snippets, tracer2) {
|
|
159993
160509
|
const partialRequestParams = getCompletionParams({
|
|
@@ -160573,10 +161089,9 @@ async function createInlineCompletionItemFromMultipleProviders({
|
|
|
160573
161089
|
config,
|
|
160574
161090
|
client,
|
|
160575
161091
|
statusBar,
|
|
160576
|
-
authProvider,
|
|
160577
161092
|
createBfgRetriever
|
|
160578
161093
|
}) {
|
|
160579
|
-
const authStatus = authProvider.getAuthStatus();
|
|
161094
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
160580
161095
|
if (!authStatus.isLoggedIn || config.autocompleteExperimentalMultiModelCompletions === void 0) {
|
|
160581
161096
|
return {
|
|
160582
161097
|
dispose: () => {
|
|
@@ -160613,7 +161128,7 @@ async function createInlineCompletionItemFromMultipleProviders({
|
|
|
160613
161128
|
config: newConfig
|
|
160614
161129
|
});
|
|
160615
161130
|
if (providerConfig) {
|
|
160616
|
-
const authStatus2 = authProvider.getAuthStatus();
|
|
161131
|
+
const authStatus2 = authProvider.instance.getAuthStatus();
|
|
160617
161132
|
const completionsProvider = new InlineCompletionItemProvider({
|
|
160618
161133
|
authStatus: authStatus2,
|
|
160619
161134
|
providerConfig,
|
|
@@ -160668,7 +161183,7 @@ class BaseConfigWatcher {
|
|
|
160668
161183
|
this.currentConfig = initialConfig;
|
|
160669
161184
|
this.disposables.push(this.configChangeEvent);
|
|
160670
161185
|
}
|
|
160671
|
-
static async create(
|
|
161186
|
+
static async create(disposables) {
|
|
160672
161187
|
const w = new BaseConfigWatcher(await getFullConfig());
|
|
160673
161188
|
disposables.push(w);
|
|
160674
161189
|
disposables.push(
|
|
@@ -160681,7 +161196,7 @@ class BaseConfigWatcher {
|
|
|
160681
161196
|
);
|
|
160682
161197
|
disposables.push(
|
|
160683
161198
|
subscriptionDisposable(
|
|
160684
|
-
authProvider.changes.subscribe(async () => {
|
|
161199
|
+
authProvider.instance.changes.subscribe(async () => {
|
|
160685
161200
|
w.set(await getFullConfig());
|
|
160686
161201
|
})
|
|
160687
161202
|
)
|
|
@@ -161070,7 +161585,7 @@ class RemoteRepoPicker {
|
|
|
161070
161585
|
id: repo.id,
|
|
161071
161586
|
label: repo.name,
|
|
161072
161587
|
name: repo.name,
|
|
161073
|
-
isIgnored: contextFiltersProvider.isRepoNameIgnored(repo.name)
|
|
161588
|
+
isIgnored: contextFiltersProvider.instance.isRepoNameIgnored(repo.name)
|
|
161074
161589
|
}));
|
|
161075
161590
|
this.handleRepoListChanged();
|
|
161076
161591
|
void this.workspaceRepoMapper.start();
|
|
@@ -161120,7 +161635,7 @@ class RemoteRepoPicker {
|
|
|
161120
161635
|
continue;
|
|
161121
161636
|
}
|
|
161122
161637
|
displayedRepos.add(repo.id);
|
|
161123
|
-
const isIgnored = contextFiltersProvider.isRepoNameIgnored(repo.name);
|
|
161638
|
+
const isIgnored = contextFiltersProvider.instance.isRepoNameIgnored(repo.name);
|
|
161124
161639
|
const inWorkspace = workspaceRepos.has(repo.id);
|
|
161125
161640
|
const shortName = repo.name.slice(repo.name.lastIndexOf("/") + 1);
|
|
161126
161641
|
const item = {
|
|
@@ -163640,7 +164155,7 @@ function tryGetHTMLDocumentTitle(html2) {
|
|
|
163640
164155
|
var _a3, _b2;
|
|
163641
164156
|
return (_b2 = (_a3 = html2.match(/<title>(?<title>[^<]+)<\/title>/)) == null ? void 0 : _a3.groups) == null ? void 0 : _b2.title.replaceAll(/\s+/gm, " ").trim();
|
|
163642
164157
|
}
|
|
163643
|
-
async function exposeOpenCtxClient(context2, config,
|
|
164158
|
+
async function exposeOpenCtxClient(context2, config, createOpenCtxController) {
|
|
163644
164159
|
await warnIfOpenCtxExtensionConflict();
|
|
163645
164160
|
try {
|
|
163646
164161
|
const isCodyWeb = config.get().agentIDE === CodyIDE.Web;
|
|
@@ -163652,7 +164167,11 @@ async function exposeOpenCtxClient(context2, config, authProvider, createOpenCtx
|
|
|
163652
164167
|
secrets: context2.secrets,
|
|
163653
164168
|
outputChannel,
|
|
163654
164169
|
features: isCodyWeb ? {} : { annotations: true, statusBar: true },
|
|
163655
|
-
providers: isCodyWeb ? Observable.of(getCodyWebOpenCtxProviders()) : getOpenCtxProviders(
|
|
164170
|
+
providers: isCodyWeb ? Observable.of(getCodyWebOpenCtxProviders()) : getOpenCtxProviders(
|
|
164171
|
+
config.changes,
|
|
164172
|
+
authProvider.instance.changes,
|
|
164173
|
+
isValidSiteVersion
|
|
164174
|
+
),
|
|
163656
164175
|
mergeConfiguration
|
|
163657
164176
|
});
|
|
163658
164177
|
setOpenCtx({
|
|
@@ -163667,7 +164186,7 @@ function getOpenCtxProviders(configChanges, authStatusChanges, isValidSiteVersio
|
|
|
163667
164186
|
return combineLatest$1([
|
|
163668
164187
|
configChanges,
|
|
163669
164188
|
authStatusChanges,
|
|
163670
|
-
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.GitMentionProvider)
|
|
164189
|
+
featureFlagProvider.instance.evaluatedFeatureFlag(FeatureFlag.GitMentionProvider)
|
|
163671
164190
|
]).map(
|
|
163672
164191
|
([config, authStatus, gitMentionProvider]) => {
|
|
163673
164192
|
const providers = [
|
|
@@ -163840,7 +164359,7 @@ function getLabelForContextItem(item) {
|
|
|
163840
164359
|
throw new Error(`getLableForContextItem Error: Unexpected type ${item.type}`);
|
|
163841
164360
|
}
|
|
163842
164361
|
}
|
|
163843
|
-
function getItemLabel
|
|
164362
|
+
function getItemLabel(item) {
|
|
163844
164363
|
return item.label.replace(QUICK_PICK_ITEM_EMPTY_INDENT_PREFIX$1, "").replace(QUICK_PICK_ITEM_CHECKED_PREFIX$1, "").trim();
|
|
163845
164364
|
}
|
|
163846
164365
|
async function fetchDocumentSymbols(document2) {
|
|
@@ -163897,8 +164416,8 @@ const getEditInputItems = (activeValue, activeRangeItem, activeModelItem, showMo
|
|
|
163897
164416
|
label: "edit options",
|
|
163898
164417
|
kind: QuickPickItemKind.Separator
|
|
163899
164418
|
},
|
|
163900
|
-
{ ...RANGE_ITEM, detail: getItemLabel
|
|
163901
|
-
showModelSelector ? { ...MODEL_ITEM, detail: activeModelItem ? getItemLabel
|
|
164419
|
+
{ ...RANGE_ITEM, detail: getItemLabel(activeRangeItem) },
|
|
164420
|
+
showModelSelector ? { ...MODEL_ITEM, detail: activeModelItem ? getItemLabel(activeModelItem) : void 0 } : null
|
|
163902
164421
|
];
|
|
163903
164422
|
const items = [...submitItems, ...editItems, ...commandItems].filter(
|
|
163904
164423
|
Boolean
|
|
@@ -164099,7 +164618,7 @@ const PREVIEW_RANGE_DECORATION = window$1.createTextEditorDecorationType({
|
|
|
164099
164618
|
borderWidth: "3px",
|
|
164100
164619
|
borderStyle: "solid"
|
|
164101
164620
|
});
|
|
164102
|
-
const getInput = async (document2,
|
|
164621
|
+
const getInput = async (document2, initialValues, source) => {
|
|
164103
164622
|
const editor = getEditor().active;
|
|
164104
164623
|
if (!editor) {
|
|
164105
164624
|
return null;
|
|
@@ -164113,16 +164632,16 @@ const getInput = async (document2, authProvider, initialValues, source) => {
|
|
|
164113
164632
|
const initialCursorPosition = editor.selection.active;
|
|
164114
164633
|
let activeRange = initialValues.initialExpandedRange || initialValues.initialRange;
|
|
164115
164634
|
let activeRangeItem = initialValues.initialIntent === "add" ? CURSOR_RANGE_ITEM : initialValues.initialExpandedRange ? EXPANDED_RANGE_ITEM : SELECTION_RANGE_ITEM;
|
|
164116
|
-
const authStatus = authProvider.getAuthStatus();
|
|
164635
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
164117
164636
|
const isCodyPro = !authStatus.userCanUpgrade;
|
|
164118
|
-
const modelOptions = modelsService.getModels(ModelUsage.Edit);
|
|
164637
|
+
const modelOptions = modelsService.instance.getModels(ModelUsage.Edit);
|
|
164119
164638
|
const modelItems = getModelOptionItems(modelOptions, isCodyPro);
|
|
164120
164639
|
const showModelSelector = modelOptions.length > 1;
|
|
164121
164640
|
let activeModel = initialValues.initialModel;
|
|
164122
164641
|
let activeModelItem = modelItems.find((item) => item.model === initialValues.initialModel);
|
|
164123
164642
|
const getContextWindowOnModelChange = (model2) => {
|
|
164124
164643
|
var _a3;
|
|
164125
|
-
const latestContextWindow = modelsService.getContextWindowByID(model2);
|
|
164644
|
+
const latestContextWindow = modelsService.instance.getContextWindowByID(model2);
|
|
164126
164645
|
return latestContextWindow.input + (((_a3 = latestContextWindow.context) == null ? void 0 : _a3.user) ?? 0);
|
|
164127
164646
|
};
|
|
164128
164647
|
let activeModelContextWindow = getContextWindowOnModelChange(activeModel);
|
|
@@ -164195,7 +164714,7 @@ const getInput = async (document2, authProvider, initialValues, source) => {
|
|
|
164195
164714
|
}
|
|
164196
164715
|
return;
|
|
164197
164716
|
}
|
|
164198
|
-
modelsService.setSelectedModel(ModelUsage.Edit, acceptedItem.model);
|
|
164717
|
+
modelsService.instance.setSelectedModel(ModelUsage.Edit, acceptedItem.model);
|
|
164199
164718
|
activeModelItem = acceptedItem;
|
|
164200
164719
|
activeModel = acceptedItem.model;
|
|
164201
164720
|
activeModelContextWindow = getContextWindowOnModelChange(acceptedItem.model);
|
|
@@ -165048,7 +165567,7 @@ const trackRejection = (document2, workspace2, { onAccepted, onRejected }, task)
|
|
|
165048
165567
|
}
|
|
165049
165568
|
};
|
|
165050
165569
|
class FixupController {
|
|
165051
|
-
constructor(
|
|
165570
|
+
constructor(client) {
|
|
165052
165571
|
__publicField2(this, "tasks", /* @__PURE__ */ new Map());
|
|
165053
165572
|
__publicField2(this, "files");
|
|
165054
165573
|
__publicField2(this, "editObserver");
|
|
@@ -165070,7 +165589,6 @@ class FixupController {
|
|
|
165070
165589
|
*/
|
|
165071
165590
|
__publicField2(this, "undoCommandEvent", new AgentEventEmitter());
|
|
165072
165591
|
__publicField2(this, "_disposables", []);
|
|
165073
|
-
this.authProvider = authProvider;
|
|
165074
165592
|
this.client = client;
|
|
165075
165593
|
this.controlApplicator = client.createFixupControlApplicator(this);
|
|
165076
165594
|
this.files = new FixupFileObserver();
|
|
@@ -165295,7 +165813,6 @@ class FixupController {
|
|
|
165295
165813
|
const document2 = await workspace.openTextDocument(task.fixupFile.uri);
|
|
165296
165814
|
const input = previousInput ?? await getInput(
|
|
165297
165815
|
document2,
|
|
165298
|
-
this.authProvider,
|
|
165299
165816
|
{
|
|
165300
165817
|
initialInputValue: task.instruction,
|
|
165301
165818
|
initialRange: task.selectionRange,
|
|
@@ -165342,7 +165859,6 @@ class FixupController {
|
|
|
165342
165859
|
async promptUserForTask(preInstruction, document2, range2, expandedRange, mode, model2, intent, source, telemetryMetadata) {
|
|
165343
165860
|
const input = await getInput(
|
|
165344
165861
|
document2,
|
|
165345
|
-
this.authProvider,
|
|
165346
165862
|
{
|
|
165347
165863
|
initialRange: range2,
|
|
165348
165864
|
initialExpandedRange: expandedRange,
|
|
@@ -165374,7 +165890,7 @@ class FixupController {
|
|
|
165374
165890
|
return task;
|
|
165375
165891
|
}
|
|
165376
165892
|
async createTask(document2, instruction, userContextFiles, selectionRange, intent, mode, model2, source, destinationFile, insertionPoint, telemetryMetadata, taskId) {
|
|
165377
|
-
const authStatus =
|
|
165893
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
165378
165894
|
const overridenModel = getOverridenModelForIntent(intent, model2, authStatus);
|
|
165379
165895
|
const fixupFile = this.files.forUri(document2.uri);
|
|
165380
165896
|
const task = new FixupTask(
|
|
@@ -165959,7 +166475,7 @@ const getPrompt = async (instruction, replacement, document2, model2, codyApiVer
|
|
|
165959
166475
|
const documentRange = new Range(0, 0, document2.lineCount - 1, 0);
|
|
165960
166476
|
const documentText = PromptString.fromDocumentText(document2, documentRange);
|
|
165961
166477
|
const tokenCount = await TokenCounterUtils.countPromptString(documentText);
|
|
165962
|
-
const contextWindow = modelsService.getContextWindowByID(model2);
|
|
166478
|
+
const contextWindow = modelsService.instance.getContextWindowByID(model2);
|
|
165963
166479
|
if (tokenCount > contextWindow.input) {
|
|
165964
166480
|
throw new Error("The amount of text in this document exceeds Cody's current capacity.");
|
|
165965
166481
|
}
|
|
@@ -165979,7 +166495,7 @@ const getPrompt = async (instruction, replacement, document2, model2, codyApiVer
|
|
|
165979
166495
|
};
|
|
165980
166496
|
async function promptModelForOriginalCode(instruction, replacement, document2, model2, client, codyApiVersion) {
|
|
165981
166497
|
const multiplexer2 = new BotResponseMultiplexer();
|
|
165982
|
-
const contextWindow = modelsService.getContextWindowByID(model2);
|
|
166498
|
+
const contextWindow = modelsService.instance.getContextWindowByID(model2);
|
|
165983
166499
|
let text = "";
|
|
165984
166500
|
multiplexer2.sub(SMART_APPLY_TOPICS.REPLACE.toString(), {
|
|
165985
166501
|
onResponse: async (content) => {
|
|
@@ -166090,669 +166606,6 @@ const SMART_APPLY_FILE_DECORATION = window$1.createTextEditorDecorationType({
|
|
|
166090
166606
|
backgroundColor: new ThemeColor("diffEditor.unchangedCodeBackground"),
|
|
166091
166607
|
rangeBehavior: DecorationRangeBehavior.ClosedClosed
|
|
166092
166608
|
});
|
|
166093
|
-
var AccountMenuOptions = /* @__PURE__ */ ((AccountMenuOptions2) => {
|
|
166094
|
-
AccountMenuOptions2["SignOut"] = "Sign Out";
|
|
166095
|
-
AccountMenuOptions2["Manage"] = "Manage Account";
|
|
166096
|
-
AccountMenuOptions2["Switch"] = "Switch Account...";
|
|
166097
|
-
return AccountMenuOptions2;
|
|
166098
|
-
})(AccountMenuOptions || {});
|
|
166099
|
-
async function openAccountMenu(authStatus) {
|
|
166100
|
-
if (!authStatus.authenticated || !authStatus.endpoint) {
|
|
166101
|
-
return;
|
|
166102
|
-
}
|
|
166103
|
-
const isOffline = authStatus.isOfflineMode;
|
|
166104
|
-
const isDotComInstance = isDotCom(authStatus.endpoint) && !isOffline;
|
|
166105
|
-
const displayName2 = authStatus.displayName || authStatus.username;
|
|
166106
|
-
const email = authStatus.primaryEmail || "No Email";
|
|
166107
|
-
const username = authStatus.username || authStatus.displayName;
|
|
166108
|
-
const planDetail = `Plan: ${authStatus.userCanUpgrade ? "Cody Free" : "Cody Pro"}`;
|
|
166109
|
-
const enterpriseDetail = `Enterprise Instance:
|
|
166110
|
-
${authStatus.endpoint}`;
|
|
166111
|
-
const offlineDetail = "Use Cody offline with Ollama";
|
|
166112
|
-
const options = isDotComInstance ? [
|
|
166113
|
-
"Manage Account"
|
|
166114
|
-
/* Manage */
|
|
166115
|
-
] : [];
|
|
166116
|
-
options.push(
|
|
166117
|
-
"Switch Account...",
|
|
166118
|
-
"Sign Out"
|
|
166119
|
-
/* SignOut */
|
|
166120
|
-
);
|
|
166121
|
-
const messageOptions = {
|
|
166122
|
-
modal: true,
|
|
166123
|
-
detail: isOffline ? offlineDetail : isDotComInstance ? planDetail : enterpriseDetail
|
|
166124
|
-
};
|
|
166125
|
-
const online = isDotComInstance ? `Signed in as ${displayName2} (${email})` : `Signed in as @${username}`;
|
|
166126
|
-
const offline = "Offline Mode";
|
|
166127
|
-
const message = isOffline ? offline : online;
|
|
166128
|
-
const option = await window$1.showInformationMessage(message, messageOptions, ...options);
|
|
166129
|
-
switch (option !== void 0) {
|
|
166130
|
-
case (option == null ? void 0 : option.startsWith("Sign Out")):
|
|
166131
|
-
return "Sign Out";
|
|
166132
|
-
case (option == null ? void 0 : option.startsWith("Manage")):
|
|
166133
|
-
return "Manage Account";
|
|
166134
|
-
case (option == null ? void 0 : option.startsWith("Switch")):
|
|
166135
|
-
return "Switch Account...";
|
|
166136
|
-
default:
|
|
166137
|
-
return void 0;
|
|
166138
|
-
}
|
|
166139
|
-
}
|
|
166140
|
-
function getEnterpriseContextWindow(chatModel, configOverwrites) {
|
|
166141
|
-
const { chatModelMaxTokens, smartContextWindow } = configOverwrites;
|
|
166142
|
-
let contextWindow = {
|
|
166143
|
-
input: chatModelMaxTokens ?? CHAT_INPUT_TOKEN_BUDGET,
|
|
166144
|
-
output: getEnterpriseOutputLimit(chatModel)
|
|
166145
|
-
};
|
|
166146
|
-
if (smartContextWindow && isModelWithExtendedContextWindowSupport(chatModel)) {
|
|
166147
|
-
contextWindow = {
|
|
166148
|
-
input: EXTENDED_CHAT_INPUT_TOKEN_BUDGET,
|
|
166149
|
-
output: CHAT_OUTPUT_TOKEN_BUDGET,
|
|
166150
|
-
context: { user: EXTENDED_USER_CONTEXT_TOKEN_BUDGET }
|
|
166151
|
-
};
|
|
166152
|
-
}
|
|
166153
|
-
return applyLocalTokenLimitOverwrite(chatModel, contextWindow);
|
|
166154
|
-
}
|
|
166155
|
-
function applyLocalTokenLimitOverwrite(chatModel, contextWindow) {
|
|
166156
|
-
var _a3;
|
|
166157
|
-
const config = (_a3 = workspace.getConfiguration("cody")) == null ? void 0 : _a3.get("provider.limit.prompt");
|
|
166158
|
-
if (config && config <= contextWindow.input) {
|
|
166159
|
-
return { ...contextWindow, input: config };
|
|
166160
|
-
}
|
|
166161
|
-
if (config) {
|
|
166162
|
-
logDebug$1("getEnterpriseContextWindow", `Invalid token limit configured for ${chatModel}`, config);
|
|
166163
|
-
}
|
|
166164
|
-
return contextWindow;
|
|
166165
|
-
}
|
|
166166
|
-
const modelWithExpandedWindowSubStrings = [
|
|
166167
|
-
"claude-3-opus",
|
|
166168
|
-
"claude-3-sonnet",
|
|
166169
|
-
"claude-3-5-sonnet",
|
|
166170
|
-
"gemini-1.5",
|
|
166171
|
-
"gpt-4o",
|
|
166172
|
-
"gpt-4-turbo"
|
|
166173
|
-
];
|
|
166174
|
-
function isModelWithExtendedContextWindowSupport(chatModel) {
|
|
166175
|
-
return modelWithExpandedWindowSubStrings.some((keyword) => chatModel.toLowerCase().includes(keyword));
|
|
166176
|
-
}
|
|
166177
|
-
function getEnterpriseOutputLimit(model2) {
|
|
166178
|
-
if (model2 && isModelWithExtendedContextWindowSupport(model2)) {
|
|
166179
|
-
return CHAT_OUTPUT_TOKEN_BUDGET;
|
|
166180
|
-
}
|
|
166181
|
-
return ANSWER_TOKENS;
|
|
166182
|
-
}
|
|
166183
|
-
async function syncModels(authStatus) {
|
|
166184
|
-
var _a3, _b2;
|
|
166185
|
-
modelsService.setAuthStatus(authStatus);
|
|
166186
|
-
if (authStatus.isOfflineMode) {
|
|
166187
|
-
modelsService.setModels([]);
|
|
166188
|
-
return;
|
|
166189
|
-
}
|
|
166190
|
-
if (!authStatus.authenticated) {
|
|
166191
|
-
modelsService.setModels([]);
|
|
166192
|
-
return;
|
|
166193
|
-
}
|
|
166194
|
-
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
166195
|
-
if (clientConfig == null ? void 0 : clientConfig.modelsAPIEnabled) {
|
|
166196
|
-
logDebug("ModelsService", "new models API enabled");
|
|
166197
|
-
const serverSideModels = await fetchServerSideModels(authStatus.endpoint || "");
|
|
166198
|
-
if (serverSideModels) {
|
|
166199
|
-
modelsService.setServerSentModels(serverSideModels);
|
|
166200
|
-
registerModelsFromVSCodeConfiguration();
|
|
166201
|
-
return;
|
|
166202
|
-
}
|
|
166203
|
-
}
|
|
166204
|
-
if (authStatus.isDotCom) {
|
|
166205
|
-
modelsService.setModels(getDotComDefaultModels());
|
|
166206
|
-
registerModelsFromVSCodeConfiguration();
|
|
166207
|
-
return;
|
|
166208
|
-
}
|
|
166209
|
-
if ((_a3 = authStatus == null ? void 0 : authStatus.configOverwrites) == null ? void 0 : _a3.chatModel) {
|
|
166210
|
-
modelsService.setModels([
|
|
166211
|
-
new Model({
|
|
166212
|
-
id: authStatus.configOverwrites.chatModel,
|
|
166213
|
-
// TODO (umpox) Add configOverwrites.editModel for separate edit support
|
|
166214
|
-
usage: [ModelUsage.Chat, ModelUsage.Edit],
|
|
166215
|
-
contextWindow: getEnterpriseContextWindow(
|
|
166216
|
-
(_b2 = authStatus == null ? void 0 : authStatus.configOverwrites) == null ? void 0 : _b2.chatModel,
|
|
166217
|
-
authStatus == null ? void 0 : authStatus.configOverwrites
|
|
166218
|
-
),
|
|
166219
|
-
tags: [ModelTag.Enterprise]
|
|
166220
|
-
})
|
|
166221
|
-
]);
|
|
166222
|
-
} else {
|
|
166223
|
-
modelsService.setModels([]);
|
|
166224
|
-
}
|
|
166225
|
-
}
|
|
166226
|
-
function registerModelsFromVSCodeConfiguration() {
|
|
166227
|
-
const codyConfig = workspace.getConfiguration("cody");
|
|
166228
|
-
const modelsConfig = codyConfig == null ? void 0 : codyConfig.get("dev.models");
|
|
166229
|
-
if (!(modelsConfig == null ? void 0 : modelsConfig.length)) {
|
|
166230
|
-
return;
|
|
166231
|
-
}
|
|
166232
|
-
modelsService.addModels(
|
|
166233
|
-
modelsConfig.map(
|
|
166234
|
-
(m) => new Model({
|
|
166235
|
-
id: `${m.provider}/${m.model}`,
|
|
166236
|
-
usage: [ModelUsage.Chat, ModelUsage.Edit],
|
|
166237
|
-
contextWindow: {
|
|
166238
|
-
input: m.inputTokens ?? CHAT_INPUT_TOKEN_BUDGET,
|
|
166239
|
-
output: m.outputTokens ?? ANSWER_TOKENS
|
|
166240
|
-
},
|
|
166241
|
-
clientSideConfig: { apiKey: m.apiKey, apiEndpoint: m.apiEndpoint },
|
|
166242
|
-
tags: [ModelTag.Local, ModelTag.BYOK, ModelTag.Experimental]
|
|
166243
|
-
})
|
|
166244
|
-
)
|
|
166245
|
-
);
|
|
166246
|
-
}
|
|
166247
|
-
async function fetchServerSideModels(endpoint) {
|
|
166248
|
-
if (!endpoint) {
|
|
166249
|
-
throw new Error("authStatus has no endpoint available. Unable to fetch models.");
|
|
166250
|
-
}
|
|
166251
|
-
const userAccessToken = await secretStorage.getToken(endpoint);
|
|
166252
|
-
const customHeaders = getConfiguration().customHeaders;
|
|
166253
|
-
const client = new RestClient(endpoint, userAccessToken, customHeaders);
|
|
166254
|
-
return await client.getAvailableModels();
|
|
166255
|
-
}
|
|
166256
|
-
function getItemLabel(uri2, current) {
|
|
166257
|
-
const icon2 = current ? "$(check) " : "";
|
|
166258
|
-
if (isDotCom(uri2)) {
|
|
166259
|
-
return `${icon2}Sourcegraph.com`;
|
|
166260
|
-
}
|
|
166261
|
-
return `${icon2}${uri2}`;
|
|
166262
|
-
}
|
|
166263
|
-
const AuthMenu = async (type2, historyItems) => {
|
|
166264
|
-
const historySize = historyItems == null ? void 0 : historyItems.length;
|
|
166265
|
-
const history = historySize > 0 ? historyItems == null ? void 0 : historyItems.map((uri2, i) => ({
|
|
166266
|
-
id: uri2,
|
|
166267
|
-
label: getItemLabel(uri2, type2 === "switch" && i === historySize - 1),
|
|
166268
|
-
description: "",
|
|
166269
|
-
uri: uri2
|
|
166270
|
-
})).reverse() : [];
|
|
166271
|
-
const separator = [{ label: type2 === "signin" ? "previously used" : "current", kind: -1 }];
|
|
166272
|
-
const optionItems = [...LoginMenuOptionItems, ...separator, ...history];
|
|
166273
|
-
const option = await window$1.showQuickPick(
|
|
166274
|
-
optionItems,
|
|
166275
|
-
AuthMenuOptions[type2]
|
|
166276
|
-
);
|
|
166277
|
-
return option;
|
|
166278
|
-
};
|
|
166279
|
-
async function showInstanceURLInputBox(title) {
|
|
166280
|
-
const result = await window$1.showInputBox({
|
|
166281
|
-
title,
|
|
166282
|
-
prompt: "Enter the URL of the Sourcegraph instance. For example, https://sourcegraph.example.com.",
|
|
166283
|
-
placeHolder: "https://sourcegraph.example.com",
|
|
166284
|
-
value: "https://",
|
|
166285
|
-
password: false,
|
|
166286
|
-
ignoreFocusOut: true,
|
|
166287
|
-
// valide input to ensure the user is not entering a token as URL
|
|
166288
|
-
validateInput: (value) => {
|
|
166289
|
-
if (!value) {
|
|
166290
|
-
return null;
|
|
166291
|
-
}
|
|
166292
|
-
if (isSourcegraphToken(value)) {
|
|
166293
|
-
return "Please enter a valid URL";
|
|
166294
|
-
}
|
|
166295
|
-
if (value.length > 4 && !value.startsWith("http")) {
|
|
166296
|
-
return "URL must start with http or https";
|
|
166297
|
-
}
|
|
166298
|
-
if (!/([.]|^https?:\/\/)/.test(value)) {
|
|
166299
|
-
return "Please enter a valid URL";
|
|
166300
|
-
}
|
|
166301
|
-
return null;
|
|
166302
|
-
}
|
|
166303
|
-
});
|
|
166304
|
-
if (typeof result === "string") {
|
|
166305
|
-
return result.trim();
|
|
166306
|
-
}
|
|
166307
|
-
return result;
|
|
166308
|
-
}
|
|
166309
|
-
async function showAccessTokenInputBox(endpoint) {
|
|
166310
|
-
const result = await window$1.showInputBox({
|
|
166311
|
-
title: endpoint,
|
|
166312
|
-
prompt: 'Paste your access token. To create an access token, go to "Settings" and then "Access tokens" on the Sourcegraph instance.',
|
|
166313
|
-
placeHolder: "Access Token",
|
|
166314
|
-
password: true,
|
|
166315
|
-
ignoreFocusOut: true
|
|
166316
|
-
});
|
|
166317
|
-
if (typeof result === "string") {
|
|
166318
|
-
return result.trim();
|
|
166319
|
-
}
|
|
166320
|
-
return result;
|
|
166321
|
-
}
|
|
166322
|
-
const AuthMenuOptions = {
|
|
166323
|
-
signin: {
|
|
166324
|
-
title: "Other Sign-in Options",
|
|
166325
|
-
placeholder: "Choose a sign-in option"
|
|
166326
|
-
},
|
|
166327
|
-
switch: {
|
|
166328
|
-
title: "Switch Account",
|
|
166329
|
-
placeHolder: "Choose an account"
|
|
166330
|
-
}
|
|
166331
|
-
};
|
|
166332
|
-
const LoginMenuOptionItems = [
|
|
166333
|
-
{
|
|
166334
|
-
id: "enterprise",
|
|
166335
|
-
label: "Sign In to Sourcegraph Enterprise Instance",
|
|
166336
|
-
description: "v5.1 and above",
|
|
166337
|
-
totalSteps: 1,
|
|
166338
|
-
picked: true
|
|
166339
|
-
},
|
|
166340
|
-
{
|
|
166341
|
-
id: "token",
|
|
166342
|
-
label: "Sign In to Sourcegraph Enterprise Instance with Access Token",
|
|
166343
|
-
description: "v5.0 and above",
|
|
166344
|
-
totalSteps: 2
|
|
166345
|
-
},
|
|
166346
|
-
{
|
|
166347
|
-
id: "token",
|
|
166348
|
-
label: "Sign In with URL and Access Token",
|
|
166349
|
-
totalSteps: 2
|
|
166350
|
-
}
|
|
166351
|
-
];
|
|
166352
|
-
const HAS_AUTHENTICATED_BEFORE_KEY = "has-authenticated-before";
|
|
166353
|
-
const _AuthProvider = class _AuthProvider {
|
|
166354
|
-
constructor(config) {
|
|
166355
|
-
__publicField2(this, "endpointHistory", []);
|
|
166356
|
-
__publicField2(this, "client", null);
|
|
166357
|
-
__publicField2(this, "status", defaultAuthStatus);
|
|
166358
|
-
__publicField2(this, "didChangeEvent", new AgentEventEmitter());
|
|
166359
|
-
__publicField2(this, "disposables", [this.didChangeEvent]);
|
|
166360
|
-
__publicField2(this, "changes", fromVSCodeEvent(
|
|
166361
|
-
this.didChangeEvent.event,
|
|
166362
|
-
this.getAuthStatus.bind(this)
|
|
166363
|
-
));
|
|
166364
|
-
this.config = config;
|
|
166365
|
-
this.status.endpoint = "init";
|
|
166366
|
-
this.loadEndpointHistory();
|
|
166367
|
-
}
|
|
166368
|
-
static get instance() {
|
|
166369
|
-
return _AuthProvider._instance;
|
|
166370
|
-
}
|
|
166371
|
-
static create(config) {
|
|
166372
|
-
if (!_AuthProvider._instance) {
|
|
166373
|
-
_AuthProvider._instance = new _AuthProvider(config);
|
|
166374
|
-
}
|
|
166375
|
-
return _AuthProvider._instance;
|
|
166376
|
-
}
|
|
166377
|
-
dispose() {
|
|
166378
|
-
for (const d2 of this.disposables) {
|
|
166379
|
-
d2.dispose();
|
|
166380
|
-
}
|
|
166381
|
-
this.disposables = [];
|
|
166382
|
-
}
|
|
166383
|
-
// Sign into the last endpoint the user was signed into, if any
|
|
166384
|
-
async init() {
|
|
166385
|
-
const lastEndpoint = (localStorage == null ? void 0 : localStorage.getEndpoint()) || this.config.serverEndpoint;
|
|
166386
|
-
const token = await secretStorage.get(lastEndpoint || "") || this.config.accessToken;
|
|
166387
|
-
logDebug(
|
|
166388
|
-
"AuthProvider:init:lastEndpoint",
|
|
166389
|
-
(token == null ? void 0 : token.trim()) ? "Token recovered from secretStorage" : "No token found in secretStorage",
|
|
166390
|
-
lastEndpoint
|
|
166391
|
-
);
|
|
166392
|
-
await this.auth({
|
|
166393
|
-
endpoint: lastEndpoint,
|
|
166394
|
-
token: token || null,
|
|
166395
|
-
isExtensionStartup: true
|
|
166396
|
-
}).catch((error) => logError$2("AuthProvider:init:failed", lastEndpoint, { verbose: error }));
|
|
166397
|
-
}
|
|
166398
|
-
// Display quickpick to select endpoint to sign in to
|
|
166399
|
-
async signinMenu(type2, uri2) {
|
|
166400
|
-
const mode = this.status.isLoggedIn ? "switch" : "signin";
|
|
166401
|
-
logDebug("AuthProvider:signinMenu", mode);
|
|
166402
|
-
telemetryRecorder.recordEvent("cody.auth.login", "clicked");
|
|
166403
|
-
const item = await AuthMenu(mode, this.endpointHistory);
|
|
166404
|
-
if (!item) {
|
|
166405
|
-
return;
|
|
166406
|
-
}
|
|
166407
|
-
const menuID = type2 || (item == null ? void 0 : item.id);
|
|
166408
|
-
telemetryRecorder.recordEvent("cody.auth.signin.menu", "clicked", {
|
|
166409
|
-
privateMetadata: { menuID }
|
|
166410
|
-
});
|
|
166411
|
-
switch (menuID) {
|
|
166412
|
-
case "enterprise": {
|
|
166413
|
-
const instanceUrl = await showInstanceURLInputBox(item.uri);
|
|
166414
|
-
if (!instanceUrl) {
|
|
166415
|
-
return;
|
|
166416
|
-
}
|
|
166417
|
-
this.status.endpoint = instanceUrl;
|
|
166418
|
-
this.redirectToEndpointLogin(instanceUrl);
|
|
166419
|
-
break;
|
|
166420
|
-
}
|
|
166421
|
-
case "dotcom":
|
|
166422
|
-
this.redirectToEndpointLogin(DOTCOM_URL.href);
|
|
166423
|
-
break;
|
|
166424
|
-
case "token": {
|
|
166425
|
-
const instanceUrl = await showInstanceURLInputBox(uri2 || item.uri);
|
|
166426
|
-
if (!instanceUrl) {
|
|
166427
|
-
return;
|
|
166428
|
-
}
|
|
166429
|
-
await this.signinMenuForInstanceUrl(instanceUrl);
|
|
166430
|
-
break;
|
|
166431
|
-
}
|
|
166432
|
-
default: {
|
|
166433
|
-
const selectedEndpoint = item.uri;
|
|
166434
|
-
const token = await secretStorage.get(selectedEndpoint);
|
|
166435
|
-
let authStatus = await this.auth({
|
|
166436
|
-
endpoint: selectedEndpoint,
|
|
166437
|
-
token: token || null
|
|
166438
|
-
});
|
|
166439
|
-
if (!(authStatus == null ? void 0 : authStatus.isLoggedIn)) {
|
|
166440
|
-
const newToken = await showAccessTokenInputBox(item.uri);
|
|
166441
|
-
if (!newToken) {
|
|
166442
|
-
return;
|
|
166443
|
-
}
|
|
166444
|
-
authStatus = await this.auth({
|
|
166445
|
-
endpoint: selectedEndpoint,
|
|
166446
|
-
token: newToken || null
|
|
166447
|
-
});
|
|
166448
|
-
}
|
|
166449
|
-
await showAuthResultMessage(selectedEndpoint, authStatus);
|
|
166450
|
-
logDebug("AuthProvider:signinMenu", mode, selectedEndpoint);
|
|
166451
|
-
}
|
|
166452
|
-
}
|
|
166453
|
-
}
|
|
166454
|
-
async signinMenuForInstanceUrl(instanceUrl) {
|
|
166455
|
-
const accessToken = await showAccessTokenInputBox(instanceUrl);
|
|
166456
|
-
if (!accessToken) {
|
|
166457
|
-
return;
|
|
166458
|
-
}
|
|
166459
|
-
const authState = await this.auth({
|
|
166460
|
-
endpoint: instanceUrl,
|
|
166461
|
-
token: accessToken
|
|
166462
|
-
});
|
|
166463
|
-
telemetryRecorder.recordEvent("cody.auth.signin.token", "clicked", {
|
|
166464
|
-
metadata: {
|
|
166465
|
-
success: authState.isLoggedIn ? 1 : 0
|
|
166466
|
-
}
|
|
166467
|
-
});
|
|
166468
|
-
await showAuthResultMessage(instanceUrl, authState);
|
|
166469
|
-
}
|
|
166470
|
-
async signoutMenu() {
|
|
166471
|
-
telemetryRecorder.recordEvent("cody.auth.logout", "clicked");
|
|
166472
|
-
const { endpoint } = this.getAuthStatus();
|
|
166473
|
-
if (endpoint) {
|
|
166474
|
-
await this.signout(endpoint);
|
|
166475
|
-
logDebug("AuthProvider:signoutMenu", endpoint);
|
|
166476
|
-
}
|
|
166477
|
-
}
|
|
166478
|
-
async accountMenu() {
|
|
166479
|
-
const selected = await openAccountMenu(this.status);
|
|
166480
|
-
if (selected === void 0) {
|
|
166481
|
-
return;
|
|
166482
|
-
}
|
|
166483
|
-
switch (selected) {
|
|
166484
|
-
case AccountMenuOptions.Manage: {
|
|
166485
|
-
const uri2 = Uri.parse(ACCOUNT_USAGE_URL.toString()).with({
|
|
166486
|
-
query: `cody_client_user=${encodeURIComponent(this.status.username)}`
|
|
166487
|
-
});
|
|
166488
|
-
void env.openExternal(uri2);
|
|
166489
|
-
break;
|
|
166490
|
-
}
|
|
166491
|
-
case AccountMenuOptions.Switch:
|
|
166492
|
-
await this.signinMenu();
|
|
166493
|
-
break;
|
|
166494
|
-
case AccountMenuOptions.SignOut:
|
|
166495
|
-
await this.signoutMenu();
|
|
166496
|
-
break;
|
|
166497
|
-
}
|
|
166498
|
-
}
|
|
166499
|
-
// Log user out of the selected endpoint (remove token from secret)
|
|
166500
|
-
async signout(endpoint) {
|
|
166501
|
-
await secretStorage.deleteToken(endpoint);
|
|
166502
|
-
await localStorage.deleteEndpoint();
|
|
166503
|
-
await this.auth({ endpoint: "", token: null });
|
|
166504
|
-
await commands$1.executeCommand("setContext", "cody.activated", false);
|
|
166505
|
-
}
|
|
166506
|
-
// Create Auth Status
|
|
166507
|
-
async makeAuthStatus(config, isOfflineMode) {
|
|
166508
|
-
var _a3;
|
|
166509
|
-
const endpoint = config.serverEndpoint;
|
|
166510
|
-
const token = config.accessToken;
|
|
166511
|
-
const isCodyWeb = workspace.getConfiguration().get("cody.advanced.agent.ide") === CodyIDE.Web;
|
|
166512
|
-
if (isOfflineMode) {
|
|
166513
|
-
const lastUser = localStorage.getLastStoredUser();
|
|
166514
|
-
return { ...offlineModeAuthStatus, ...lastUser };
|
|
166515
|
-
}
|
|
166516
|
-
if (isCodyWeb) {
|
|
166517
|
-
if (!endpoint) {
|
|
166518
|
-
return { ...defaultAuthStatus, endpoint };
|
|
166519
|
-
}
|
|
166520
|
-
} else {
|
|
166521
|
-
if (!token || !endpoint) {
|
|
166522
|
-
return { ...defaultAuthStatus, endpoint };
|
|
166523
|
-
}
|
|
166524
|
-
}
|
|
166525
|
-
if (this.config !== config || !this.client) {
|
|
166526
|
-
this.config = config;
|
|
166527
|
-
this.client = new SourcegraphGraphQLAPIClient(config);
|
|
166528
|
-
}
|
|
166529
|
-
const [{ enabled: siteHasCodyEnabled, version: siteVersion }, codyLLMConfiguration, userInfo] = await Promise.all([
|
|
166530
|
-
this.client.isCodyEnabled(),
|
|
166531
|
-
this.client.getCodyLLMConfiguration(),
|
|
166532
|
-
this.client.getCurrentUserInfo()
|
|
166533
|
-
]);
|
|
166534
|
-
logDebug("CodyLLMConfiguration", JSON.stringify(codyLLMConfiguration));
|
|
166535
|
-
if (isError$1(userInfo) && isNetworkError(userInfo)) {
|
|
166536
|
-
return { ...networkErrorAuthStatus, endpoint };
|
|
166537
|
-
}
|
|
166538
|
-
if (!userInfo || isError$1(userInfo)) {
|
|
166539
|
-
return { ...unauthenticatedStatus, endpoint };
|
|
166540
|
-
}
|
|
166541
|
-
const configOverwrites = isError$1(codyLLMConfiguration) ? void 0 : codyLLMConfiguration;
|
|
166542
|
-
const isDotCom2 = this.client.isDotCom();
|
|
166543
|
-
if (!isDotCom2) {
|
|
166544
|
-
return newAuthStatus({
|
|
166545
|
-
...userInfo,
|
|
166546
|
-
endpoint,
|
|
166547
|
-
isDotCom: isDotCom2,
|
|
166548
|
-
siteVersion,
|
|
166549
|
-
configOverwrites,
|
|
166550
|
-
authenticated: true,
|
|
166551
|
-
hasVerifiedEmail: false,
|
|
166552
|
-
siteHasCodyEnabled,
|
|
166553
|
-
userCanUpgrade: false
|
|
166554
|
-
});
|
|
166555
|
-
}
|
|
166556
|
-
const proStatus = await this.client.getCurrentUserCodySubscription();
|
|
166557
|
-
const isActiveProUser = proStatus !== null && "plan" in proStatus && proStatus.plan === "PRO" && proStatus.status !== "PENDING";
|
|
166558
|
-
return newAuthStatus({
|
|
166559
|
-
...userInfo,
|
|
166560
|
-
endpoint,
|
|
166561
|
-
isDotCom: isDotCom2,
|
|
166562
|
-
siteHasCodyEnabled,
|
|
166563
|
-
siteVersion,
|
|
166564
|
-
configOverwrites,
|
|
166565
|
-
authenticated: !!userInfo.id,
|
|
166566
|
-
userCanUpgrade: !isActiveProUser,
|
|
166567
|
-
primaryEmail: ((_a3 = userInfo.primaryEmail) == null ? void 0 : _a3.email) ?? ""
|
|
166568
|
-
});
|
|
166569
|
-
}
|
|
166570
|
-
getAuthStatus() {
|
|
166571
|
-
return this.status;
|
|
166572
|
-
}
|
|
166573
|
-
// It processes the authentication steps and stores the login info before sharing the auth status with chatview
|
|
166574
|
-
async auth({
|
|
166575
|
-
endpoint,
|
|
166576
|
-
token,
|
|
166577
|
-
customHeaders,
|
|
166578
|
-
isExtensionStartup = false,
|
|
166579
|
-
isOfflineMode = false
|
|
166580
|
-
}) {
|
|
166581
|
-
const config = {
|
|
166582
|
-
serverEndpoint: formatURL(endpoint) ?? "",
|
|
166583
|
-
accessToken: token,
|
|
166584
|
-
customHeaders: customHeaders || this.config.customHeaders
|
|
166585
|
-
};
|
|
166586
|
-
try {
|
|
166587
|
-
const authStatus = await this.makeAuthStatus(config, isOfflineMode);
|
|
166588
|
-
if (!isOfflineMode) {
|
|
166589
|
-
await this.storeAuthInfo(config.serverEndpoint, config.accessToken);
|
|
166590
|
-
}
|
|
166591
|
-
await commands$1.executeCommand("setContext", "cody.activated", authStatus.isLoggedIn);
|
|
166592
|
-
await this.setAuthStatus(authStatus);
|
|
166593
|
-
if (isExtensionStartup && authStatus.isLoggedIn) {
|
|
166594
|
-
await this.setHasAuthenticatedBefore();
|
|
166595
|
-
} else if (authStatus.isLoggedIn) {
|
|
166596
|
-
this.handleFirstEverAuthentication();
|
|
166597
|
-
}
|
|
166598
|
-
return authStatus;
|
|
166599
|
-
} catch (error) {
|
|
166600
|
-
logDebug("AuthProvider:auth", "failed", error);
|
|
166601
|
-
return await this.reloadAuthStatus().catch(() => unauthenticatedStatus);
|
|
166602
|
-
}
|
|
166603
|
-
}
|
|
166604
|
-
// Set auth status in case of reload
|
|
166605
|
-
async reloadAuthStatus() {
|
|
166606
|
-
await commands$1.executeCommand("setContext", "cody.activated", false);
|
|
166607
|
-
this.config = await getFullConfig();
|
|
166608
|
-
return await this.auth({
|
|
166609
|
-
endpoint: this.config.serverEndpoint,
|
|
166610
|
-
token: this.config.accessToken,
|
|
166611
|
-
customHeaders: this.config.customHeaders
|
|
166612
|
-
});
|
|
166613
|
-
}
|
|
166614
|
-
// Set auth status and share it with chatview
|
|
166615
|
-
async setAuthStatus(authStatus) {
|
|
166616
|
-
if (this.status === authStatus) {
|
|
166617
|
-
return;
|
|
166618
|
-
}
|
|
166619
|
-
this.status = authStatus;
|
|
166620
|
-
if (authStatus.endpoint === "init") {
|
|
166621
|
-
return;
|
|
166622
|
-
}
|
|
166623
|
-
await this.updateAuthStatus(authStatus);
|
|
166624
|
-
}
|
|
166625
|
-
async updateAuthStatus(authStatus) {
|
|
166626
|
-
try {
|
|
166627
|
-
graphqlClient.setConfig(await getFullConfig());
|
|
166628
|
-
await ClientConfigSingleton.getInstance().setAuthStatus(authStatus);
|
|
166629
|
-
await syncModels(authStatus);
|
|
166630
|
-
} catch (error) {
|
|
166631
|
-
logDebug("AuthProvider", "updateAuthStatus error", error);
|
|
166632
|
-
} finally {
|
|
166633
|
-
this.didChangeEvent.fire(this.getAuthStatus());
|
|
166634
|
-
let eventValue;
|
|
166635
|
-
if (authStatus.showNetworkError || authStatus.showInvalidAccessTokenError) {
|
|
166636
|
-
eventValue = "failed";
|
|
166637
|
-
} else if (authStatus.isLoggedIn) {
|
|
166638
|
-
eventValue = "connected";
|
|
166639
|
-
} else {
|
|
166640
|
-
eventValue = "disconnected";
|
|
166641
|
-
}
|
|
166642
|
-
telemetryRecorder.recordEvent("cody.auth", eventValue);
|
|
166643
|
-
}
|
|
166644
|
-
}
|
|
166645
|
-
// Register URI Handler (vscode://sourcegraph.cody-ai) for resolving token
|
|
166646
|
-
// sending back from sourcegraph.com
|
|
166647
|
-
async tokenCallbackHandler(uri2, customHeaders) {
|
|
166648
|
-
closeAuthProgressIndicator();
|
|
166649
|
-
const params = new URLSearchParams(uri2.query);
|
|
166650
|
-
const token = params.get("code");
|
|
166651
|
-
const endpoint = this.status.endpoint;
|
|
166652
|
-
if (!token || !endpoint) {
|
|
166653
|
-
return;
|
|
166654
|
-
}
|
|
166655
|
-
const authState = await this.auth({ endpoint, token, customHeaders });
|
|
166656
|
-
telemetryRecorder.recordEvent("cody.auth.fromCallback.web", "succeeded", {
|
|
166657
|
-
metadata: {
|
|
166658
|
-
success: (authState == null ? void 0 : authState.isLoggedIn) ? 1 : 0
|
|
166659
|
-
}
|
|
166660
|
-
});
|
|
166661
|
-
if (authState == null ? void 0 : authState.isLoggedIn) {
|
|
166662
|
-
await window$1.showInformationMessage(`Signed in to ${endpoint}`);
|
|
166663
|
-
} else {
|
|
166664
|
-
await showAuthFailureMessage(endpoint);
|
|
166665
|
-
}
|
|
166666
|
-
}
|
|
166667
|
-
/** Open callback URL in browser to get token from instance. */
|
|
166668
|
-
redirectToEndpointLogin(uri2) {
|
|
166669
|
-
const endpoint = formatURL(uri2);
|
|
166670
|
-
if (!endpoint) {
|
|
166671
|
-
return;
|
|
166672
|
-
}
|
|
166673
|
-
if (env.uiKind === UIKind.Web) {
|
|
166674
|
-
const newTokenNoCallbackUrl = new URL("/user/settings/tokens/new", endpoint);
|
|
166675
|
-
void env.openExternal(Uri.parse(newTokenNoCallbackUrl.href));
|
|
166676
|
-
void this.signinMenuForInstanceUrl(endpoint);
|
|
166677
|
-
return;
|
|
166678
|
-
}
|
|
166679
|
-
const newTokenCallbackUrl = new URL("/user/settings/tokens/new/callback", endpoint);
|
|
166680
|
-
newTokenCallbackUrl.searchParams.append("requestFrom", getAuthReferralCode());
|
|
166681
|
-
this.status.endpoint = endpoint;
|
|
166682
|
-
void env.openExternal(Uri.parse(newTokenCallbackUrl.href));
|
|
166683
|
-
}
|
|
166684
|
-
// Refresh current endpoint history with the one from local storage
|
|
166685
|
-
loadEndpointHistory() {
|
|
166686
|
-
this.endpointHistory = localStorage.getEndpointHistory() || [];
|
|
166687
|
-
}
|
|
166688
|
-
// Store endpoint in local storage, token in secret storage, and update endpoint history.
|
|
166689
|
-
async storeAuthInfo(endpoint, token) {
|
|
166690
|
-
if (!endpoint) {
|
|
166691
|
-
return;
|
|
166692
|
-
}
|
|
166693
|
-
await localStorage.saveEndpoint(endpoint);
|
|
166694
|
-
if (token) {
|
|
166695
|
-
await secretStorage.storeToken(endpoint, token);
|
|
166696
|
-
}
|
|
166697
|
-
this.loadEndpointHistory();
|
|
166698
|
-
}
|
|
166699
|
-
// Notifies the AuthProvider that the simplified onboarding experiment is
|
|
166700
|
-
// kicking off an authorization flow. That flow ends when (if) this
|
|
166701
|
-
// AuthProvider gets a call to tokenCallbackHandler.
|
|
166702
|
-
authProviderSimplifiedWillAttemptAuth() {
|
|
166703
|
-
this.status.endpoint = DOTCOM_URL.toString();
|
|
166704
|
-
}
|
|
166705
|
-
// Logs a telemetry event if the user has never authenticated to Sourcegraph.
|
|
166706
|
-
handleFirstEverAuthentication() {
|
|
166707
|
-
if (localStorage.get(HAS_AUTHENTICATED_BEFORE_KEY)) {
|
|
166708
|
-
return;
|
|
166709
|
-
}
|
|
166710
|
-
telemetryRecorder.recordEvent("cody.auth.login", "firstEver");
|
|
166711
|
-
this.setHasAuthenticatedBefore();
|
|
166712
|
-
void maybeStartInteractiveTutorial();
|
|
166713
|
-
}
|
|
166714
|
-
setHasAuthenticatedBefore() {
|
|
166715
|
-
return localStorage.set(HAS_AUTHENTICATED_BEFORE_KEY, "true");
|
|
166716
|
-
}
|
|
166717
|
-
};
|
|
166718
|
-
__publicField2(_AuthProvider, "_instance", null);
|
|
166719
|
-
let AuthProvider = _AuthProvider;
|
|
166720
|
-
function isNetworkError(error) {
|
|
166721
|
-
const message = error.message;
|
|
166722
|
-
return message.includes("ENOTFOUND") || message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("EHOSTUNREACH") || message.includes("ETIMEDOUT");
|
|
166723
|
-
}
|
|
166724
|
-
function formatURL(uri2) {
|
|
166725
|
-
try {
|
|
166726
|
-
if (!uri2) {
|
|
166727
|
-
return null;
|
|
166728
|
-
}
|
|
166729
|
-
if (isSourcegraphToken(uri2)) {
|
|
166730
|
-
throw new Error("Access Token is not a valid URL");
|
|
166731
|
-
}
|
|
166732
|
-
if (!uri2.startsWith("http")) {
|
|
166733
|
-
uri2 = `https://${uri2}`;
|
|
166734
|
-
}
|
|
166735
|
-
const endpointUri = new URL(uri2);
|
|
166736
|
-
return endpointUri.href;
|
|
166737
|
-
} catch (error) {
|
|
166738
|
-
console.error("Invalid URL: ", error);
|
|
166739
|
-
return null;
|
|
166740
|
-
}
|
|
166741
|
-
}
|
|
166742
|
-
async function showAuthResultMessage(endpoint, authStatus) {
|
|
166743
|
-
if (authStatus == null ? void 0 : authStatus.isLoggedIn) {
|
|
166744
|
-
const authority = Uri.parse(endpoint).authority;
|
|
166745
|
-
await window$1.showInformationMessage(`Signed in to ${authority || endpoint}`);
|
|
166746
|
-
} else {
|
|
166747
|
-
await showAuthFailureMessage(endpoint);
|
|
166748
|
-
}
|
|
166749
|
-
}
|
|
166750
|
-
async function showAuthFailureMessage(endpoint) {
|
|
166751
|
-
const authority = Uri.parse(endpoint).authority;
|
|
166752
|
-
await window$1.showErrorMessage(
|
|
166753
|
-
`Authentication failed. Please ensure Cody is enabled for ${authority} and verify your email address if required.`
|
|
166754
|
-
);
|
|
166755
|
-
}
|
|
166756
166609
|
var he = { exports: {} };
|
|
166757
166610
|
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
|
|
166758
166611
|
he.exports;
|
|
@@ -167538,7 +167391,7 @@ const buildInteraction$1 = async ({
|
|
|
167538
167391
|
instruction: task.instruction,
|
|
167539
167392
|
document: document2
|
|
167540
167393
|
});
|
|
167541
|
-
const promptBuilder = await PromptBuilder.create(modelsService.getContextWindowByID(model2));
|
|
167394
|
+
const promptBuilder = await PromptBuilder.create(modelsService.instance.getContextWindowByID(model2));
|
|
167542
167395
|
const preamble = getSimplePreamble(model2, codyApiVersion, "Default", prompt.system);
|
|
167543
167396
|
promptBuilder.tryAddToPrefix(preamble);
|
|
167544
167397
|
const preInstruction = PromptString.fromConfig(
|
|
@@ -167583,7 +167436,7 @@ class EditProvider {
|
|
|
167583
167436
|
return wrapInActiveSpan("command.edit.start", async (span2) => {
|
|
167584
167437
|
this.config.controller.startTask(this.config.task);
|
|
167585
167438
|
const model2 = this.config.task.model;
|
|
167586
|
-
const contextWindow = modelsService.getContextWindowByID(model2);
|
|
167439
|
+
const contextWindow = modelsService.instance.getContextWindowByID(model2);
|
|
167587
167440
|
const {
|
|
167588
167441
|
messages,
|
|
167589
167442
|
stopSequences,
|
|
@@ -167591,7 +167444,7 @@ class EditProvider {
|
|
|
167591
167444
|
responsePrefix = ""
|
|
167592
167445
|
} = await buildInteraction$1({
|
|
167593
167446
|
model: model2,
|
|
167594
|
-
codyApiVersion:
|
|
167447
|
+
codyApiVersion: authProvider.instance.getAuthStatus().codyApiVersion,
|
|
167595
167448
|
contextWindow: contextWindow.input,
|
|
167596
167449
|
task: this.config.task,
|
|
167597
167450
|
editor: this.config.editor
|
|
@@ -167698,7 +167551,7 @@ class EditProvider {
|
|
|
167698
167551
|
return this.handleResponse(response, false);
|
|
167699
167552
|
}
|
|
167700
167553
|
async handleResponse(response, isMessageInProgress) {
|
|
167701
|
-
var _a3
|
|
167554
|
+
var _a3;
|
|
167702
167555
|
if (!response && !isMessageInProgress) {
|
|
167703
167556
|
this.handleError(new Error("Cody did not respond with any text"));
|
|
167704
167557
|
}
|
|
@@ -167720,7 +167573,7 @@ class EditProvider {
|
|
|
167720
167573
|
...countCode(response)
|
|
167721
167574
|
};
|
|
167722
167575
|
const { metadata: metadata2, privateMetadata } = splitSafeMetadata(legacyMetadata);
|
|
167723
|
-
const endpoint = (
|
|
167576
|
+
const endpoint = (_a3 = authProvider.instance.getAuthStatus()) == null ? void 0 : _a3.endpoint;
|
|
167724
167577
|
telemetryRecorder.recordEvent("cody.fixup.response", "hasCode", {
|
|
167725
167578
|
metadata: metadata2,
|
|
167726
167579
|
privateMetadata: {
|
|
@@ -167827,7 +167680,7 @@ class EditManager {
|
|
|
167827
167680
|
__publicField2(this, "disposables", []);
|
|
167828
167681
|
__publicField2(this, "editProviders", /* @__PURE__ */ new WeakMap());
|
|
167829
167682
|
this.options = options;
|
|
167830
|
-
this.controller = new FixupController(options.
|
|
167683
|
+
this.controller = new FixupController(options.extensionClient);
|
|
167831
167684
|
const editCommand = commands$1.registerCommand(
|
|
167832
167685
|
"cody.command.edit-code",
|
|
167833
167686
|
(args2) => this.executeEdit(args2)
|
|
@@ -167883,7 +167736,7 @@ class EditManager {
|
|
|
167883
167736
|
return;
|
|
167884
167737
|
}
|
|
167885
167738
|
const range2 = getEditLineSelection(document2, proposedRange);
|
|
167886
|
-
const model2 = configuration2.model || modelsService.getDefaultEditModel();
|
|
167739
|
+
const model2 = configuration2.model || modelsService.instance.getDefaultEditModel();
|
|
167887
167740
|
if (!model2) {
|
|
167888
167741
|
throw new Error("No default edit model found. Please set one.");
|
|
167889
167742
|
}
|
|
@@ -167970,7 +167823,7 @@ class EditManager {
|
|
|
167970
167823
|
if (await isUriIgnoredByContextFilterWithNotification(document2.uri, "edit")) {
|
|
167971
167824
|
return;
|
|
167972
167825
|
}
|
|
167973
|
-
const model2 = configuration2.model || modelsService.getDefaultEditModel();
|
|
167826
|
+
const model2 = configuration2.model || modelsService.instance.getDefaultEditModel();
|
|
167974
167827
|
if (!model2) {
|
|
167975
167828
|
throw new Error("No default edit model found. Please set one.");
|
|
167976
167829
|
}
|
|
@@ -168018,7 +167871,7 @@ class EditManager {
|
|
|
168018
167871
|
configuration2.document,
|
|
168019
167872
|
model2,
|
|
168020
167873
|
this.options.chat,
|
|
168021
|
-
|
|
167874
|
+
authProvider.instance.getAuthStatus().codyApiVersion
|
|
168022
167875
|
);
|
|
168023
167876
|
editor.setDecorations(SMART_APPLY_FILE_DECORATION, []);
|
|
168024
167877
|
if (!selection) {
|
|
@@ -168421,9 +168274,8 @@ function notNull(value) {
|
|
|
168421
168274
|
return value !== null && value !== void 0;
|
|
168422
168275
|
}
|
|
168423
168276
|
class ContextAPIClient {
|
|
168424
|
-
constructor(apiClient
|
|
168277
|
+
constructor(apiClient) {
|
|
168425
168278
|
this.apiClient = apiClient;
|
|
168426
|
-
this.featureFlagProvider = featureFlagProvider2;
|
|
168427
168279
|
}
|
|
168428
168280
|
async detectChatIntent(interactionID, query2) {
|
|
168429
168281
|
if (!await this.isServerSideContextAPIEnabled()) {
|
|
@@ -168452,17 +168304,19 @@ class ContextAPIClient {
|
|
|
168452
168304
|
if (workspace.getConfiguration().get("cody.internal.serverSideContext")) {
|
|
168453
168305
|
return true;
|
|
168454
168306
|
}
|
|
168455
|
-
return await
|
|
168307
|
+
return await featureFlagProvider.instance.evaluateFeatureFlag(
|
|
168308
|
+
FeatureFlag.CodyServerSideContextAPI
|
|
168309
|
+
);
|
|
168456
168310
|
}
|
|
168457
168311
|
}
|
|
168458
|
-
async function configureExternalServices(context2, config, platform2
|
|
168312
|
+
async function configureExternalServices(context2, config, platform2) {
|
|
168459
168313
|
var _a3, _b2, _c2, _d2;
|
|
168460
168314
|
const initialConfig = config.get();
|
|
168461
168315
|
const sentryService = (_a3 = platform2.createSentryService) == null ? void 0 : _a3.call(platform2, initialConfig);
|
|
168462
168316
|
const openTelemetryService = (_b2 = platform2.createOpenTelemetryService) == null ? void 0 : _b2.call(platform2, initialConfig);
|
|
168463
168317
|
const completionsClient = platform2.createCompletionsClient(initialConfig, logger$1);
|
|
168464
168318
|
const codeCompletionsClient = createClient(initialConfig, logger$1);
|
|
168465
|
-
const symfRunner = (_c2 = platform2.createSymfRunner) == null ? void 0 : _c2.call(platform2, context2, completionsClient
|
|
168319
|
+
const symfRunner = (_c2 = platform2.createSymfRunner) == null ? void 0 : _c2.call(platform2, context2, completionsClient);
|
|
168466
168320
|
if (initialConfig.codebase && isError$1(await graphqlClient.getRepoId(initialConfig.codebase))) {
|
|
168467
168321
|
logDebug(
|
|
168468
168322
|
"external-services:configureExternalServices",
|
|
@@ -168470,10 +168324,10 @@ async function configureExternalServices(context2, config, platform2, authProvid
|
|
|
168470
168324
|
Please check that the repository exists. You can override the repository with the "cody.codebase" setting.`
|
|
168471
168325
|
);
|
|
168472
168326
|
}
|
|
168473
|
-
const localEmbeddings = authProvider.getAuthStatus().isLoggedIn && authProvider.getAuthStatus().isDotCom ? await ((_d2 = platform2.createLocalEmbeddingsController) == null ? void 0 : _d2.call(platform2, initialConfig)) : void 0;
|
|
168474
|
-
const chatClient = new ChatClient(completionsClient, () => authProvider.getAuthStatus());
|
|
168327
|
+
const localEmbeddings = authProvider.instance.getAuthStatus().isLoggedIn && authProvider.instance.getAuthStatus().isDotCom ? await ((_d2 = platform2.createLocalEmbeddingsController) == null ? void 0 : _d2.call(platform2, initialConfig)) : void 0;
|
|
168328
|
+
const chatClient = new ChatClient(completionsClient, () => authProvider.instance.getAuthStatus());
|
|
168475
168329
|
const guardrails = new SourcegraphGuardrailsClient(graphqlClient, initialConfig);
|
|
168476
|
-
const contextAPIClient = new ContextAPIClient(graphqlClient
|
|
168330
|
+
const contextAPIClient = new ContextAPIClient(graphqlClient);
|
|
168477
168331
|
return {
|
|
168478
168332
|
chatClient,
|
|
168479
168333
|
completionsClient,
|
|
@@ -169317,7 +169171,7 @@ class MinionController extends ReactPanelController {
|
|
|
169317
169171
|
//
|
|
169318
169172
|
// Callbacks
|
|
169319
169173
|
//
|
|
169320
|
-
constructor(
|
|
169174
|
+
constructor(symf, anthropic, assetRoot, onDidDisposePanel) {
|
|
169321
169175
|
super(assetRoot, onDidDisposePanel);
|
|
169322
169176
|
__publicField2(this, "storage", new MinionStorage());
|
|
169323
169177
|
//
|
|
@@ -169325,7 +169179,6 @@ class MinionController extends ReactPanelController {
|
|
|
169325
169179
|
//
|
|
169326
169180
|
__publicField2(this, "sessionState");
|
|
169327
169181
|
__publicField2(this, "planControllers", {});
|
|
169328
|
-
this.authProvider = authProvider;
|
|
169329
169182
|
this.symf = symf;
|
|
169330
169183
|
this.anthropic = anthropic;
|
|
169331
169184
|
}
|
|
@@ -169492,7 +169345,7 @@ class MinionController extends ReactPanelController {
|
|
|
169492
169345
|
}
|
|
169493
169346
|
}
|
|
169494
169347
|
async handleSetSession(id) {
|
|
169495
|
-
const storedSessionState = await this.storage.load(
|
|
169348
|
+
const storedSessionState = await this.storage.load(authProvider.instance.getAuthStatus(), id);
|
|
169496
169349
|
if (!storedSessionState) {
|
|
169497
169350
|
throw new Error(`session not found with id: ${id}`);
|
|
169498
169351
|
}
|
|
@@ -169508,7 +169361,7 @@ class MinionController extends ReactPanelController {
|
|
|
169508
169361
|
this.postUpdateSessionIds();
|
|
169509
169362
|
}
|
|
169510
169363
|
async handleClearHistory() {
|
|
169511
|
-
await this.storage.clear(
|
|
169364
|
+
await this.storage.clear(authProvider.instance.getAuthStatus());
|
|
169512
169365
|
if (this.sessionState) {
|
|
169513
169366
|
await this.save();
|
|
169514
169367
|
}
|
|
@@ -169583,7 +169436,7 @@ class MinionController extends ReactPanelController {
|
|
|
169583
169436
|
if (!this.sessionState) {
|
|
169584
169437
|
throw new Error("no session to save");
|
|
169585
169438
|
}
|
|
169586
|
-
await this.storage.save(
|
|
169439
|
+
await this.storage.save(authProvider.instance.getAuthStatus(), {
|
|
169587
169440
|
session: this.sessionState.session
|
|
169588
169441
|
});
|
|
169589
169442
|
}
|
|
@@ -169641,7 +169494,7 @@ class MinionController extends ReactPanelController {
|
|
|
169641
169494
|
var _a3;
|
|
169642
169495
|
this.postMessage({
|
|
169643
169496
|
type: "update-session-ids",
|
|
169644
|
-
sessionIds: await this.storage.listIds(
|
|
169497
|
+
sessionIds: await this.storage.listIds(authProvider.instance.getAuthStatus()),
|
|
169645
169498
|
currentSessionId: (_a3 = this.sessionState) == null ? void 0 : _a3.session.id
|
|
169646
169499
|
});
|
|
169647
169500
|
}
|
|
@@ -169665,12 +169518,11 @@ function makeDefaultStateMachine(cancellationToken) {
|
|
|
169665
169518
|
);
|
|
169666
169519
|
}
|
|
169667
169520
|
class MinionOrchestrator {
|
|
169668
|
-
constructor(extensionUri,
|
|
169521
|
+
constructor(extensionUri, symf) {
|
|
169669
169522
|
__publicField2(this, "minions", []);
|
|
169670
169523
|
__publicField2(this, "activeMinion");
|
|
169671
169524
|
__publicField2(this, "disposables", []);
|
|
169672
169525
|
this.extensionUri = extensionUri;
|
|
169673
|
-
this.authProvider = authProvider;
|
|
169674
169526
|
this.symf = symf;
|
|
169675
169527
|
this.registerHumanListeners();
|
|
169676
169528
|
}
|
|
@@ -169720,7 +169572,7 @@ class MinionOrchestrator {
|
|
|
169720
169572
|
const anthropic = new Anthropic$1({ apiKey: anthropicKey });
|
|
169721
169573
|
const minion = await ReactPanelController.createAndInit(
|
|
169722
169574
|
() => {
|
|
169723
|
-
return new MinionController(this.
|
|
169575
|
+
return new MinionController(this.symf, anthropic, assetRoot, () => {
|
|
169724
169576
|
});
|
|
169725
169577
|
},
|
|
169726
169578
|
panel2
|
|
@@ -169734,7 +169586,7 @@ const _CodyProExpirationNotifications = class _CodyProExpirationNotifications {
|
|
|
169734
169586
|
* Set up a check (now and when auth status changes) whether to show the user a notification
|
|
169735
169587
|
* about their Cody Pro subscription having expired (or expiring soon).
|
|
169736
169588
|
*/
|
|
169737
|
-
constructor(apiClient,
|
|
169589
|
+
constructor(apiClient, showInformationMessage, openExternal, flagCheckDelayMs = 1e3 * 60 * 30, autoUpdateDelay = 1e3 * 3, checkImmediately = true) {
|
|
169738
169590
|
/**
|
|
169739
169591
|
* Current subscription to auth provider status changes that may trigger a check.
|
|
169740
169592
|
*/
|
|
@@ -169748,8 +169600,6 @@ const _CodyProExpirationNotifications = class _CodyProExpirationNotifications {
|
|
|
169748
169600
|
*/
|
|
169749
169601
|
__publicField2(this, "isDisposed", false);
|
|
169750
169602
|
this.apiClient = apiClient;
|
|
169751
|
-
this.authProvider = authProvider;
|
|
169752
|
-
this.featureFlagProvider = featureFlagProvider2;
|
|
169753
169603
|
this.showInformationMessage = showInformationMessage;
|
|
169754
169604
|
this.openExternal = openExternal;
|
|
169755
169605
|
this.flagCheckDelayMs = flagCheckDelayMs;
|
|
@@ -169764,13 +169614,13 @@ const _CodyProExpirationNotifications = class _CodyProExpirationNotifications {
|
|
|
169764
169614
|
async triggerExpirationCheck() {
|
|
169765
169615
|
if (this.shouldSuppressNotifications()) return;
|
|
169766
169616
|
if (!this.authProviderSubscription) {
|
|
169767
|
-
this.authProviderSubscription =
|
|
169617
|
+
this.authProviderSubscription = authProvider.instance.changes.subscribe(
|
|
169768
169618
|
() => setTimeout(() => this.triggerExpirationCheck(), this.autoUpdateDelay)
|
|
169769
169619
|
);
|
|
169770
169620
|
}
|
|
169771
|
-
const authStatus =
|
|
169621
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
169772
169622
|
if (!authStatus.isLoggedIn || !authStatus.isDotCom) return;
|
|
169773
|
-
const useSscForCodySubscription = await
|
|
169623
|
+
const useSscForCodySubscription = await featureFlagProvider.instance.evaluateFeatureFlag(
|
|
169774
169624
|
FeatureFlag.UseSscForCodySubscription
|
|
169775
169625
|
);
|
|
169776
169626
|
if (this.shouldSuppressNotifications()) return;
|
|
@@ -169789,7 +169639,7 @@ const _CodyProExpirationNotifications = class _CodyProExpirationNotifications {
|
|
|
169789
169639
|
await this.showNotification();
|
|
169790
169640
|
}
|
|
169791
169641
|
async showNotification() {
|
|
169792
|
-
const codyProTrialEnded = await
|
|
169642
|
+
const codyProTrialEnded = await featureFlagProvider.instance.evaluateFeatureFlag(
|
|
169793
169643
|
FeatureFlag.CodyProTrialEnded
|
|
169794
169644
|
);
|
|
169795
169645
|
if (this.shouldSuppressNotifications()) return;
|
|
@@ -170249,7 +170099,7 @@ function createStatusBar() {
|
|
|
170249
170099
|
if (uri2.scheme === "file" && isCodyIgnoredFile(uri2)) {
|
|
170250
170100
|
return "cody-ignore";
|
|
170251
170101
|
}
|
|
170252
|
-
if (await contextFiltersProvider.isUriIgnored(uri2)) {
|
|
170102
|
+
if (await contextFiltersProvider.instance.isUriIgnored(uri2)) {
|
|
170253
170103
|
return "context-filter";
|
|
170254
170104
|
}
|
|
170255
170105
|
return null;
|
|
@@ -170849,7 +170699,7 @@ async function* getSupercompletions({
|
|
|
170849
170699
|
recentEditsRetriever,
|
|
170850
170700
|
chat: chat2
|
|
170851
170701
|
}) {
|
|
170852
|
-
if (await contextFiltersProvider.isUriIgnored(document2.uri)) {
|
|
170702
|
+
if (await contextFiltersProvider.instance.isUriIgnored(document2.uri)) {
|
|
170853
170703
|
return null;
|
|
170854
170704
|
}
|
|
170855
170705
|
const diff2 = await recentEditsRetriever.getDiff(document2.uri);
|
|
@@ -171039,7 +170889,7 @@ class RecentEditsRetriever {
|
|
|
171039
170889
|
this.disposables.push(workspace$1.onDidDeleteFiles(this.onDidDeleteFiles.bind(this)));
|
|
171040
170890
|
}
|
|
171041
170891
|
async getDiff(uri2) {
|
|
171042
|
-
if (await contextFiltersProvider.isUriIgnored(uri2)) {
|
|
170892
|
+
if (await contextFiltersProvider.instance.isUriIgnored(uri2)) {
|
|
171043
170893
|
return null;
|
|
171044
170894
|
}
|
|
171045
170895
|
const trackedDocument = this.trackedDocuments.get(uri2.toString());
|
|
@@ -171454,16 +171304,16 @@ async function start(context2, platform2) {
|
|
|
171454
171304
|
}
|
|
171455
171305
|
setLogger({ logDebug, logError: logError$1 });
|
|
171456
171306
|
const disposables = [];
|
|
171457
|
-
|
|
171458
|
-
const configWatcher = await BaseConfigWatcher.create(
|
|
171307
|
+
setSingleton(authProvider, new AuthProvider(await getFullConfig()));
|
|
171308
|
+
const configWatcher = await BaseConfigWatcher.create(disposables);
|
|
171459
171309
|
disposables.push(
|
|
171460
171310
|
subscriptionDisposable(
|
|
171461
171311
|
configWatcher.changes.subscribe({
|
|
171462
|
-
next: (config) => configureEventsInfra(config, isExtensionModeDevOrTest
|
|
171312
|
+
next: (config) => configureEventsInfra(config, isExtensionModeDevOrTest)
|
|
171463
171313
|
})
|
|
171464
171314
|
)
|
|
171465
171315
|
);
|
|
171466
|
-
await authProvider.init();
|
|
171316
|
+
await authProvider.instance.init();
|
|
171467
171317
|
disposables.push(
|
|
171468
171318
|
subscriptionDisposable(
|
|
171469
171319
|
configWatcher.changes.subscribe({
|
|
@@ -171475,24 +171325,16 @@ async function start(context2, platform2) {
|
|
|
171475
171325
|
})
|
|
171476
171326
|
)
|
|
171477
171327
|
);
|
|
171478
|
-
disposables.push(
|
|
171479
|
-
await register(context2, authProvider, configWatcher, platform2, isExtensionModeDevOrTest)
|
|
171480
|
-
);
|
|
171328
|
+
disposables.push(await register(context2, configWatcher, platform2, isExtensionModeDevOrTest));
|
|
171481
171329
|
return Disposable.from(...disposables);
|
|
171482
171330
|
}
|
|
171483
|
-
const register = async (context2,
|
|
171331
|
+
const register = async (context2, configWatcher, platform2, isExtensionModeDevOrTest) => {
|
|
171484
171332
|
const disposables = [];
|
|
171485
171333
|
setClientNameVersion(platform2.extensionClient.clientName, platform2.extensionClient.clientVersion);
|
|
171486
171334
|
disposables.push(manageDisplayPathEnvInfoForExtension());
|
|
171487
|
-
await initializeSingletons(
|
|
171488
|
-
platform2,
|
|
171489
|
-
authProvider,
|
|
171490
|
-
configWatcher,
|
|
171491
|
-
isExtensionModeDevOrTest,
|
|
171492
|
-
disposables
|
|
171493
|
-
);
|
|
171335
|
+
await initializeSingletons(platform2, configWatcher, isExtensionModeDevOrTest, disposables);
|
|
171494
171336
|
disposables.push(await initVSCodeGitApi());
|
|
171495
|
-
initWorkspaceReposMonitor(
|
|
171337
|
+
initWorkspaceReposMonitor(disposables);
|
|
171496
171338
|
registerParserListeners(disposables);
|
|
171497
171339
|
registerChatListeners(disposables);
|
|
171498
171340
|
const {
|
|
@@ -171504,7 +171346,7 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171504
171346
|
onConfigurationChange: externalServicesOnDidConfigurationChange,
|
|
171505
171347
|
symfRunner,
|
|
171506
171348
|
contextAPIClient
|
|
171507
|
-
} = await configureExternalServices(context2, configWatcher, platform2
|
|
171349
|
+
} = await configureExternalServices(context2, configWatcher, platform2);
|
|
171508
171350
|
disposables.push(
|
|
171509
171351
|
subscriptionDisposable(
|
|
171510
171352
|
configWatcher.changes.subscribe({
|
|
@@ -171530,7 +171372,7 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171530
171372
|
)
|
|
171531
171373
|
);
|
|
171532
171374
|
const editor = new VSCodeEditor();
|
|
171533
|
-
const contextRetriever = new ContextRetriever(editor, symfRunner, completionsClient);
|
|
171375
|
+
const contextRetriever = new ContextRetriever(editor, symfRunner, localEmbeddings, completionsClient);
|
|
171534
171376
|
const { chatsController } = registerChat(
|
|
171535
171377
|
{
|
|
171536
171378
|
context: context2,
|
|
@@ -171538,7 +171380,6 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171538
171380
|
chatClient,
|
|
171539
171381
|
guardrails,
|
|
171540
171382
|
editor,
|
|
171541
|
-
authProvider,
|
|
171542
171383
|
enterpriseContextFactory,
|
|
171543
171384
|
localEmbeddings,
|
|
171544
171385
|
symfRunner,
|
|
@@ -171554,7 +171395,7 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171554
171395
|
statusBar,
|
|
171555
171396
|
sourceControl,
|
|
171556
171397
|
subscriptionDisposable(
|
|
171557
|
-
authProvider.changes.subscribe({
|
|
171398
|
+
authProvider.instance.changes.subscribe({
|
|
171558
171399
|
next: (authStatus) => {
|
|
171559
171400
|
sourceControl.setAuthStatus(authStatus);
|
|
171560
171401
|
statusBar.setAuthStatus(authStatus);
|
|
@@ -171565,29 +171406,23 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171565
171406
|
const autocompleteSetup = registerAutocomplete(
|
|
171566
171407
|
configWatcher,
|
|
171567
171408
|
platform2,
|
|
171568
|
-
authProvider,
|
|
171569
171409
|
statusBar,
|
|
171570
171410
|
codeCompletionsClient,
|
|
171571
171411
|
disposables
|
|
171572
171412
|
);
|
|
171573
171413
|
const tutorialSetup = tryRegisterTutorial(context2, disposables);
|
|
171574
|
-
const openCtxSetup = exposeOpenCtxClient(
|
|
171575
|
-
context2,
|
|
171576
|
-
configWatcher,
|
|
171577
|
-
authProvider,
|
|
171578
|
-
platform2.createOpenCtxController
|
|
171579
|
-
);
|
|
171414
|
+
const openCtxSetup = exposeOpenCtxClient(context2, configWatcher, platform2.createOpenCtxController);
|
|
171580
171415
|
registerCodyCommands(configWatcher, statusBar, sourceControl, chatClient, disposables);
|
|
171581
|
-
registerAuthCommands(
|
|
171582
|
-
registerChatCommands(
|
|
171416
|
+
registerAuthCommands(disposables);
|
|
171417
|
+
registerChatCommands(disposables);
|
|
171583
171418
|
disposables.push(...registerSidebarCommands());
|
|
171584
171419
|
disposables.push(...setUpCodyIgnore(configWatcher.get()));
|
|
171585
171420
|
registerOtherCommands(disposables);
|
|
171586
171421
|
if (isExtensionModeDevOrTest) {
|
|
171587
|
-
await registerTestCommands(context2,
|
|
171422
|
+
await registerTestCommands(context2, disposables);
|
|
171588
171423
|
}
|
|
171589
171424
|
registerDebugCommands(context2, disposables);
|
|
171590
|
-
registerUpgradeHandlers(configWatcher,
|
|
171425
|
+
registerUpgradeHandlers(configWatcher, disposables);
|
|
171591
171426
|
disposables.push(new CharactersLogger());
|
|
171592
171427
|
void showSetupNotification(configWatcher.get());
|
|
171593
171428
|
const [extensionClientDispose] = await Promise.all([
|
|
@@ -171595,27 +171430,27 @@ const register = async (context2, authProvider, configWatcher, platform2, isExte
|
|
|
171595
171430
|
autocompleteSetup,
|
|
171596
171431
|
openCtxSetup,
|
|
171597
171432
|
tutorialSetup,
|
|
171598
|
-
registerMinion(context2, configWatcher,
|
|
171433
|
+
registerMinion(context2, configWatcher, symfRunner, disposables)
|
|
171599
171434
|
]);
|
|
171600
171435
|
disposables.push(extensionClientDispose);
|
|
171601
171436
|
return Disposable.from(...disposables);
|
|
171602
171437
|
};
|
|
171603
|
-
async function initializeSingletons(platform2,
|
|
171438
|
+
async function initializeSingletons(platform2, configWatcher, isExtensionModeDevOrTest, disposables) {
|
|
171604
171439
|
var _a3;
|
|
171605
|
-
modelsService.setStorage(localStorage);
|
|
171606
|
-
disposables.push(upstreamHealthProvider, contextFiltersProvider);
|
|
171440
|
+
modelsService.instance.setStorage(localStorage);
|
|
171441
|
+
disposables.push(upstreamHealthProvider.instance, contextFiltersProvider.instance);
|
|
171607
171442
|
commandControllerInit((_a3 = platform2.createCommandsProvider) == null ? void 0 : _a3.call(platform2), platform2.extensionClient.capabilities);
|
|
171608
|
-
repoNameResolver.init(
|
|
171443
|
+
repoNameResolver.init();
|
|
171609
171444
|
disposables.push(
|
|
171610
171445
|
subscriptionDisposable(
|
|
171611
171446
|
configWatcher.changes.subscribe({
|
|
171612
171447
|
next: (config) => {
|
|
171613
171448
|
void localStorage.setConfig(config);
|
|
171614
171449
|
graphqlClient.setConfig(config);
|
|
171615
|
-
void featureFlagProvider.refresh();
|
|
171616
|
-
contextFiltersProvider.init(repoNameResolver.getRepoNamesFromWorkspaceUri);
|
|
171617
|
-
void modelsService.onConfigChange(config);
|
|
171618
|
-
upstreamHealthProvider.onConfigurationChange(config);
|
|
171450
|
+
void featureFlagProvider.instance.refresh();
|
|
171451
|
+
contextFiltersProvider.instance.init(repoNameResolver.getRepoNamesFromWorkspaceUri);
|
|
171452
|
+
void modelsService.instance.onConfigChange(config);
|
|
171453
|
+
upstreamHealthProvider.instance.onConfigurationChange(config);
|
|
171619
171454
|
}
|
|
171620
171455
|
})
|
|
171621
171456
|
)
|
|
@@ -171738,7 +171573,7 @@ function registerCodyCommands(config, statusBar, sourceControl, chatClient, disp
|
|
|
171738
171573
|
// Generate Commit Message command
|
|
171739
171574
|
);
|
|
171740
171575
|
}
|
|
171741
|
-
function registerChatCommands(
|
|
171576
|
+
function registerChatCommands(disposables) {
|
|
171742
171577
|
disposables.push(
|
|
171743
171578
|
// Chat
|
|
171744
171579
|
commands$1.registerCommand(
|
|
@@ -171751,7 +171586,7 @@ function registerChatCommands(authProvider, disposables) {
|
|
|
171751
171586
|
commands$1.executeCommand("workbench.action.moveEditorToNewWindow");
|
|
171752
171587
|
}),
|
|
171753
171588
|
commands$1.registerCommand("cody.chat.history.panel", async () => {
|
|
171754
|
-
await displayHistoryQuickPick(authProvider.getAuthStatus());
|
|
171589
|
+
await displayHistoryQuickPick(authProvider.instance.getAuthStatus());
|
|
171755
171590
|
}),
|
|
171756
171591
|
commands$1.registerCommand(
|
|
171757
171592
|
"cody.settings.extension.chat",
|
|
@@ -171765,13 +171600,16 @@ function registerChatCommands(authProvider, disposables) {
|
|
|
171765
171600
|
)
|
|
171766
171601
|
);
|
|
171767
171602
|
}
|
|
171768
|
-
function registerAuthCommands(
|
|
171603
|
+
function registerAuthCommands(disposables) {
|
|
171769
171604
|
disposables.push(
|
|
171770
|
-
commands$1.registerCommand("cody.auth.signin", () => authProvider.signinMenu()),
|
|
171771
|
-
commands$1.registerCommand("cody.auth.signout", () => authProvider.signoutMenu()),
|
|
171772
|
-
commands$1.registerCommand("cody.auth.account", () => authProvider.accountMenu()),
|
|
171605
|
+
commands$1.registerCommand("cody.auth.signin", () => authProvider.instance.signinMenu()),
|
|
171606
|
+
commands$1.registerCommand("cody.auth.signout", () => authProvider.instance.signoutMenu()),
|
|
171607
|
+
commands$1.registerCommand("cody.auth.account", () => authProvider.instance.accountMenu()),
|
|
171773
171608
|
commands$1.registerCommand("cody.auth.support", () => showFeedbackSupportQuickPick()),
|
|
171774
|
-
commands$1.registerCommand(
|
|
171609
|
+
commands$1.registerCommand(
|
|
171610
|
+
"cody.auth.status",
|
|
171611
|
+
() => authProvider.instance.getAuthStatus()
|
|
171612
|
+
),
|
|
171775
171613
|
// Used by the agent
|
|
171776
171614
|
commands$1.registerCommand(
|
|
171777
171615
|
"cody.agent.auth.authenticate",
|
|
@@ -171782,7 +171620,7 @@ function registerAuthCommands(authProvider, disposables) {
|
|
|
171782
171620
|
if (typeof accessToken !== "string") {
|
|
171783
171621
|
throw new TypeError("accessToken is required");
|
|
171784
171622
|
}
|
|
171785
|
-
return await authProvider.auth({
|
|
171623
|
+
return await authProvider.instance.auth({
|
|
171786
171624
|
endpoint: serverEndpoint,
|
|
171787
171625
|
token: accessToken,
|
|
171788
171626
|
customHeaders
|
|
@@ -171791,20 +171629,20 @@ function registerAuthCommands(authProvider, disposables) {
|
|
|
171791
171629
|
)
|
|
171792
171630
|
);
|
|
171793
171631
|
}
|
|
171794
|
-
function registerUpgradeHandlers(configWatcher,
|
|
171632
|
+
function registerUpgradeHandlers(configWatcher, disposables) {
|
|
171795
171633
|
disposables.push(
|
|
171796
171634
|
// Register URI Handler (e.g. vscode://sourcegraph.cody-ai)
|
|
171797
171635
|
window$1.registerUriHandler({
|
|
171798
171636
|
handleUri: async (uri2) => {
|
|
171799
171637
|
if (uri2.path === "/app-done") ;
|
|
171800
171638
|
else {
|
|
171801
|
-
authProvider.tokenCallbackHandler(uri2, configWatcher.get().customHeaders);
|
|
171639
|
+
authProvider.instance.tokenCallbackHandler(uri2, configWatcher.get().customHeaders);
|
|
171802
171640
|
}
|
|
171803
171641
|
}
|
|
171804
171642
|
}),
|
|
171805
171643
|
// Check if user has just moved back from a browser window to upgrade cody pro
|
|
171806
171644
|
window$1.onDidChangeWindowState(async (ws) => {
|
|
171807
|
-
const authStatus = authProvider.getAuthStatus();
|
|
171645
|
+
const authStatus = authProvider.instance.getAuthStatus();
|
|
171808
171646
|
if (ws.focused && authStatus.isDotCom && authStatus.isLoggedIn) {
|
|
171809
171647
|
const res = await graphqlClient.getCurrentUserCodyProEnabled();
|
|
171810
171648
|
if (res instanceof Error) {
|
|
@@ -171813,20 +171651,18 @@ function registerUpgradeHandlers(configWatcher, authProvider, disposables) {
|
|
|
171813
171651
|
}
|
|
171814
171652
|
const isCurrentCodyProUser = !authStatus.userCanUpgrade;
|
|
171815
171653
|
if (res && res.codyProEnabled !== isCurrentCodyProUser) {
|
|
171816
|
-
authProvider.reloadAuthStatus();
|
|
171654
|
+
authProvider.instance.reloadAuthStatus();
|
|
171817
171655
|
}
|
|
171818
171656
|
}
|
|
171819
171657
|
}),
|
|
171820
171658
|
new CodyProExpirationNotifications(
|
|
171821
171659
|
graphqlClient,
|
|
171822
|
-
authProvider,
|
|
171823
|
-
featureFlagProvider,
|
|
171824
171660
|
window$1.showInformationMessage,
|
|
171825
171661
|
env.openExternal
|
|
171826
171662
|
)
|
|
171827
171663
|
);
|
|
171828
171664
|
}
|
|
171829
|
-
async function registerTestCommands(context2,
|
|
171665
|
+
async function registerTestCommands(context2, disposables) {
|
|
171830
171666
|
await commands$1.executeCommand("setContext", "cody.devOrTest", true);
|
|
171831
171667
|
disposables.push(
|
|
171832
171668
|
commands$1.registerCommand("cody.test.set-context-filters", async () => {
|
|
@@ -171836,7 +171672,7 @@ async function registerTestCommands(context2, authProvider, disposables) {
|
|
|
171836
171672
|
}
|
|
171837
171673
|
try {
|
|
171838
171674
|
const policy = JSON.parse(raw);
|
|
171839
|
-
contextFiltersProvider.setTestingContextFilters(policy);
|
|
171675
|
+
contextFiltersProvider.instance.setTestingContextFilters(policy);
|
|
171840
171676
|
} catch (error) {
|
|
171841
171677
|
window$1.showErrorMessage(
|
|
171842
171678
|
"Failed to parse context filters policy. Please check your JSON syntax."
|
|
@@ -171846,7 +171682,7 @@ async function registerTestCommands(context2, authProvider, disposables) {
|
|
|
171846
171682
|
// Access token - this is only used in configuration tests
|
|
171847
171683
|
commands$1.registerCommand(
|
|
171848
171684
|
"cody.test.token",
|
|
171849
|
-
async (endpoint, token) => authProvider.auth({ endpoint, token })
|
|
171685
|
+
async (endpoint, token) => authProvider.instance.auth({ endpoint, token })
|
|
171850
171686
|
)
|
|
171851
171687
|
);
|
|
171852
171688
|
}
|
|
@@ -171860,11 +171696,11 @@ async function registerDebugCommands(context2, disposables) {
|
|
|
171860
171696
|
}
|
|
171861
171697
|
async function tryRegisterTutorial(context2, disposables) {
|
|
171862
171698
|
if (!isRunningInsideAgent()) {
|
|
171863
|
-
const { registerInteractiveTutorial } = await import("./index-
|
|
171699
|
+
const { registerInteractiveTutorial } = await import("./index-D6VgQlqI.mjs");
|
|
171864
171700
|
registerInteractiveTutorial(context2).then((disposable) => disposables.push(...disposable));
|
|
171865
171701
|
}
|
|
171866
171702
|
}
|
|
171867
|
-
function registerAutocomplete(configWatcher, platform2,
|
|
171703
|
+
function registerAutocomplete(configWatcher, platform2, statusBar, codeCompletionsClient, disposables) {
|
|
171868
171704
|
let setupAutocompleteQueue = Promise.resolve();
|
|
171869
171705
|
let autocompleteDisposables = [];
|
|
171870
171706
|
function disposeAutocomplete() {
|
|
@@ -171892,7 +171728,7 @@ function registerAutocomplete(configWatcher, platform2, authProvider, statusBar,
|
|
|
171892
171728
|
return;
|
|
171893
171729
|
}
|
|
171894
171730
|
disposeAutocomplete();
|
|
171895
|
-
const autocompleteFeatureFlagChangeSubscriber = featureFlagProvider.onFeatureFlagChanged(
|
|
171731
|
+
const autocompleteFeatureFlagChangeSubscriber = featureFlagProvider.instance.onFeatureFlagChanged(
|
|
171896
171732
|
"cody-autocomplete",
|
|
171897
171733
|
setupAutocomplete
|
|
171898
171734
|
);
|
|
@@ -171904,7 +171740,6 @@ function registerAutocomplete(configWatcher, platform2, authProvider, statusBar,
|
|
|
171904
171740
|
config,
|
|
171905
171741
|
client: codeCompletionsClient,
|
|
171906
171742
|
statusBar,
|
|
171907
|
-
authProvider,
|
|
171908
171743
|
createBfgRetriever: platform2.createBfgRetriever
|
|
171909
171744
|
})
|
|
171910
171745
|
);
|
|
@@ -171913,7 +171748,6 @@ function registerAutocomplete(configWatcher, platform2, authProvider, statusBar,
|
|
|
171913
171748
|
config,
|
|
171914
171749
|
client: codeCompletionsClient,
|
|
171915
171750
|
statusBar,
|
|
171916
|
-
authProvider,
|
|
171917
171751
|
createBfgRetriever: platform2.createBfgRetriever
|
|
171918
171752
|
}),
|
|
171919
171753
|
autocompleteStageCounterLogger
|
|
@@ -171929,9 +171763,9 @@ function registerAutocomplete(configWatcher, platform2, authProvider, statusBar,
|
|
|
171929
171763
|
return setupAutocomplete().catch(() => {
|
|
171930
171764
|
});
|
|
171931
171765
|
}
|
|
171932
|
-
async function registerMinion(context2, config,
|
|
171766
|
+
async function registerMinion(context2, config, symfRunner, disposables) {
|
|
171933
171767
|
if (config.get().experimentalMinionAnthropicKey) {
|
|
171934
|
-
const minionOrchestrator = new MinionOrchestrator(context2.extensionUri,
|
|
171768
|
+
const minionOrchestrator = new MinionOrchestrator(context2.extensionUri, symfRunner);
|
|
171935
171769
|
disposables.push(minionOrchestrator);
|
|
171936
171770
|
disposables.push(
|
|
171937
171771
|
commands$1.registerCommand(
|
|
@@ -171951,7 +171785,6 @@ function registerChat({
|
|
|
171951
171785
|
chatClient,
|
|
171952
171786
|
guardrails,
|
|
171953
171787
|
editor,
|
|
171954
|
-
authProvider,
|
|
171955
171788
|
enterpriseContextFactory,
|
|
171956
171789
|
localEmbeddings,
|
|
171957
171790
|
symfRunner,
|
|
@@ -171961,8 +171794,7 @@ function registerChat({
|
|
|
171961
171794
|
const messageProviderOptions = {
|
|
171962
171795
|
chat: chatClient,
|
|
171963
171796
|
guardrails,
|
|
171964
|
-
editor
|
|
171965
|
-
authProvider
|
|
171797
|
+
editor
|
|
171966
171798
|
};
|
|
171967
171799
|
const chatsController = new ChatsController(
|
|
171968
171800
|
{
|
|
@@ -171971,7 +171803,6 @@ function registerChat({
|
|
|
171971
171803
|
startTokenReceiver: platform2.startTokenReceiver
|
|
171972
171804
|
},
|
|
171973
171805
|
chatClient,
|
|
171974
|
-
authProvider,
|
|
171975
171806
|
enterpriseContextFactory,
|
|
171976
171807
|
localEmbeddings || null,
|
|
171977
171808
|
symfRunner || null,
|
|
@@ -171981,12 +171812,11 @@ function registerChat({
|
|
|
171981
171812
|
platform2.extensionClient
|
|
171982
171813
|
);
|
|
171983
171814
|
chatsController.registerViewsAndCommands();
|
|
171984
|
-
const ghostHintDecorator = new GhostHintDecorator(
|
|
171815
|
+
const ghostHintDecorator = new GhostHintDecorator();
|
|
171985
171816
|
const editorManager = new EditManager({
|
|
171986
171817
|
chat: chatClient,
|
|
171987
171818
|
editor,
|
|
171988
171819
|
ghostHintDecorator,
|
|
171989
|
-
authProvider,
|
|
171990
171820
|
extensionClient: platform2.extensionClient
|
|
171991
171821
|
});
|
|
171992
171822
|
disposables.push(ghostHintDecorator, editorManager, new CodeActionProvider());
|
|
@@ -172005,8 +171835,8 @@ function registerChat({
|
|
|
172005
171835
|
}
|
|
172006
171836
|
return { chatsController };
|
|
172007
171837
|
}
|
|
172008
|
-
async function configureEventsInfra(config, isExtensionModeDevOrTest
|
|
172009
|
-
await createOrUpdateTelemetryRecorderProvider(config, isExtensionModeDevOrTest
|
|
171838
|
+
async function configureEventsInfra(config, isExtensionModeDevOrTest) {
|
|
171839
|
+
await createOrUpdateTelemetryRecorderProvider(config, isExtensionModeDevOrTest);
|
|
172010
171840
|
}
|
|
172011
171841
|
async function activate(context2, platformContext) {
|
|
172012
171842
|
const api = new ExtensionApi(context2.extensionMode);
|