@sourcegraph/cody-web 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/{agent.worker-BLjjG8ds.mjs → agent.worker-CF9GgIzt.mjs} +742 -951
- package/dist/agent.worker.js +2 -2
- package/dist/{git-log-C0C2_x8P.mjs → git-log-Dihxu1-Z.mjs} +1 -1
- package/dist/index.js +102 -353
- package/dist/lib/components/CodyWebChat.d.ts.map +1 -1
- package/dist/{lite-b2NFi2v9.mjs → lite-CQAWMpwn.mjs} +1 -1
- package/dist/style.css +0 -19
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{util-C44wiTt8.mjs → util-D8ltdME7.mjs} +1 -1
- package/dist/{vscode-shim-H_ThTWLs.mjs → vscode-shim-Csgwpsv8.mjs} +483 -696
- package/package.json +17 -15
|
@@ -18,8 +18,8 @@ var __privateWrapper = (obj, member, setter2, getter) => ({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn, _a2, _b, _c, _d, _e, _constructing, _f, _g, _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_fn2, moveToTail_fn, _h, _i, _j, _k, _l;
|
|
21
|
-
import { O as Observable,
|
|
22
|
-
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-
|
|
21
|
+
import { O as Observable, aR as unsubscribe, aS as AsyncSerialScheduler, aT as authStatus, aU as pick, aV as distinctUntilChanged$1, aW as switchMapReplayOperation, aX as pendingOperation, aY as promiseFactoryToObservable, J as map$1, ac as isError$3, aZ as retry$1, a_ as logError$2, aE as firstResultFromOperation, a$ as graphqlClient, P as isDotCom, b0 as semver, b1 as debounceTime, b2 as interval, b3 as filter$3, b4 as startWith$1, b5 as switchMap$1, ar as firstValueFrom$1, as as skipPendingOperation, b6 as logDebug$1, b7 as isAbortError, b8 as expand, ab as LRUCache$1, b9 as TRANSIENT_REFETCH_INTERVAL_HINT, ba as createSubscriber, bb as fromVSCodeEvent, D as isEqual, bc as cenv, aC as lodashExports, bd as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, be as isFileURI, w as wrapInActiveSpan, bf as INCLUDE_EVERYTHING_CONTEXT_FILTERS, bg as onAbort, bh as CHAT_INPUT_TOKEN_BUDGET, bi as CHAT_OUTPUT_TOKEN_BUDGET, ah as ModelTag, bj as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, bk as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, bl as addCodyClientIdentificationHeaders, bm as addTraceparent, bn as addAuthHeaders, bo as fetch$2, bp as verifyResponseCode, H as combineLatest$1, bq as take$2, br as clientCapabilities, bs as shareReplay$1, bt as tap$2, bu as featureFlagProvider, ae as FeatureFlag, bv as telemetryRecorder, bw as currentAuthStatusOrNotReadyYet, bx as mockAuthStatus, by as storeLastValue, bz as resolvedConfig, bA as ps, bB as GuardrailsMode, bC as currentResolvedConfig, aN as PromptString, a7 as CodyIDE, bD as CORPUS_CONTEXT_ALLOCATION, bE as recordErrorToSpan, bF as addClientInfoParams, bG as dependentAbortController, F as FILE_CONTEXT_MENTION_PROVIDER, S as SYMBOL_CONTEXT_MENTION_PROVIDER, R as REMOTE_REPOSITORY_PROVIDER_URI, a as REMOTE_FILE_PROVIDER_URI, b as REMOTE_DIRECTORY_PROVIDER_URI, W as WEB_PROVIDER_URI, C as ContextItemSource, bH as isS2, bI as GIT_OPENCTX_PROVIDER_URI, bJ as CODE_SEARCH_PROVIDER_URI, a9 as cryptoJsExports, bK as currentOpenCtxController, m as URI, bL as MulticastSubject, bM as AsyncSerialScheduler_1, g as getDefaultExportFromCjs, bN as workspace, p as path$1, bO as vscode, bP as Range, bQ as commands$1, bR as window$1, bS as Selection, U as Uri, bT as AgentEventEmitter, bU as MarkdownString, bV as Disposable, bW as TextEditorRevealType, bX as ThemeIcon, bY as StatusBarAlignment, bZ as readFile, b_ as env, b$ as UIKind, c0 as languages$1, c as commonjsGlobal, c1 as InvalidAccessTokenError, c2 as _baseAssignValue, c3 as eq_1, c4 as isArrayLike_1, c5 as isObjectLike_1, c6 as _copyObject, c7 as keysIn_1, c8 as _cloneBufferExports, c9 as _cloneTypedArray, ca as _copyArray, cb as _initCloneObject, cc as isArguments_1, cd as isArray_1, ce as isBufferExports, cf as isFunction_1, cg as isObject_1, ch as isPlainObject_1, ci as isTypedArray_1, cj as _Stack, ck as identity_1, cl as _overRest, cm as _setToString, cn as _isIndex, Y as isSourcegraphToken, aB as v4, co as CONFIG_KEY, aK as CodyAutoSuggestionMode, cp as ConfigurationTarget, cq as pathBrowserify, cr as stat, cs as extensions, ct as version$2, cu as setExtensionVersion, cv as isInvalidAccessTokenError, cw as DOTCOM_URL, cx as isNeedsAuthChallengeError, cy as EMPTY$1, cz as disposableSubscription, cA as externalAuthRefresh, cB as setAuthStatusObservable, X as isAvailabilityError, cC as normalizeServerEndpointURL, cD as AuthConfigError, Q as isWorkspaceInstance, cE as SourcegraphGraphQLAPIClient, cF as isExternalProviderAuthError, cG as isNetworkLikeError, cH as NeedsAuthChallengeError, cI as AvailabilityError, cJ as currentAuthStatus, cK as resolveAuth, cL as QuickPickItemKind, cM as getAuthHeaders, cN as toLightweightChatTranscript, cO as SUPPORTED_URI_SCHEMAS, cP as RelativePattern, cQ as _baseIsEqual, cR as keys_1, cS as _baseGet, cT as _castPath, cU as isLength_1, cV as _toKey, cW as _isKey, cX as toNumber_1, cY as _baseFindIndex, cZ as require$$0$2, c_ as NetworkError, c$ as isRateLimitError, V as isAuthError, d0 as FileType, d1 as dedent$1, d2 as FoldingRange, d3 as CancellationTokenSource, d4 as SymbolKind, d5 as convertGitCloneURLToCodebaseName, aI as isDefined, d6 as pluck, d7 as toRangeData, d8 as Position, d9 as DefaultChatCommands, da as pathFunctionsForURI, db as uriParseNameAndExtension, dc as uriDirname, dd as Utils$1, de as uriExtname, df as uriBasename, dg as DefaultEditCommands, dh as subscriptionDisposable, di as updateGlobalTelemetryInstances, dj as TelemetryRecorderProvider, dk as telemetryRecorderProvider, dl as createGitDiff, dm as AgentWorkspaceEdit, dn as TextDocumentChangeReason, dp as omit$1, dq as getEditorInsertSpaces, dr as escapeRegExp$1, ds as TimeoutError, dt as isNetworkError, du as displayPathWithoutWorkspaceFolderPrefix, dv as http, dw as open, dx as defer$2, dy as merge$2, dz as abortableOperation, dA as ruleSearchPaths, dB as isRuleFilename, dC as parseRuleFile, dD as languageFromFilename, f as displayLineRange, e as displayPath, dE as ruleTitle, dF as debounce_1, aM as isErrorLike, dG as isWindows, dH as GLOBAL_SEARCH_PROVIDER_URI, dI as mentionProvidersMetadata, dJ as ThemeColor, dK as QuickInputButtons, E as scanForMentionTriggerInUserTextInput, u as parseMentionQuery, L as LARGE_FILE_WARNING_LABEL, dL as GENERAL_HELP_LABEL, a8 as CodyTaskState, dM as CodeLens, dN as defaultWebviewPanel, x as createExtensionAPI, y as createMessageAPIForWebview, dO as EndOfLine, dP as ViewColumn, dQ as Location, dR as onDidChangeActiveTextEditor, dS as tabGroups, dT as workspaceTextDocuments, dU as visibleTextEditors, dV as onDidChangeVisibleTextEditors, dW as fs, dX as onDidCloseTextDocument, dY as setCreateWebviewPanel, dZ as getAugmentedNamespace, d_ as extensionConfiguration, d$ as main$1, e0 as setAgent, e1 as setWorkspaceDocuments, e2 as setLastOpenedWorkspaceFolder, e3 as onDidRegisterNewCodeActionProvider, e4 as onDidUnregisterNewCodeActionProvider, e5 as onDidRegisterNewCodeLensProvider, e6 as onDidUnregisterNewCodeLensProvider, e7 as setClientInfo, e8 as firstNonPendingAuthStatus, e9 as workspaceFolders$1, ea as setWorkspaceFolders, eb as onDidChangeWorkspaceFolders, ec as onDidChangeWindowState, ed as onDidOpenTextDocument, ee as onDidSaveTextDocument, ef as onDidRenameFiles, eg as packageJson, eh as progressBars, ei as CodeActionTriggerKind, ej as CodeAction, ek as UriString, el as DiagnosticSeverity, em as diagnostics, en as isIntegrationTesting, eo as TESTING_TELEMETRY_EXPORTER, ep as ProgressLocation, eq as dist, er as completionProvider, es as InlineCompletionTriggerKind, et as currentAuthStatusAuthed, eu as waitUntilComplete, ev as setExtensionConfiguration, ew as onDidChangeConfiguration, ex as onDidChangeTextDocument, ey as onDidChangeTextEditorSelection, an as isMacOS, ap as CustomCommandType, aL as setDisplayPathEnvInfo, aG as ACCOUNT_USAGE_URL, z as debounce$1, ez as structuredPatch, eA as dedupeWith$1, eB as AbortError, eC as createDisposables, eD as isNodeResponse, eE as getClientInfoQueryParams, eF as tracer, eG as getActiveTraceAndSpanId, eH as getClientIdentificationHeaders, eI as setJSONAcceptContentTypeHeaders, eJ as logResponseHeadersToSpan, eK as isCustomAuthChallengeResponse, eL as TracedError, $ as SpanStatusCode, ad as RateLimitError$1, eM as capitalize, eN as InlineCompletionItem, eO as createTwoFilesPatch, eP as vsCodeMocks, a2 as whitespace, a0 as svg, a3 as find$1, a4 as stringify$1, a5 as stringify$2, a6 as ccount, a1 as html$3, eQ as getEditorTabSize$1, eR as metrics, eS as _, aD as deserializeContextItem, eT as editorStateFromPromptString, eU as _baseGetTag, ag as isAbortErrorOrSocketHangUp, eV as inputTextWithoutContextChipsFromPromptEditorState, ai as DeepCodyAgentID, eW as exec, s as spawn, aw as UIToolStatus, i as displayPathBasename, eX as expandToLineRange, eY as openctxController, eZ as openCtxProviderMetadata, e_ as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, e$ as catchError$1, ay as diffWithLineNum, az as UITerminalOutputType, f0 as getPlatform$1, f1 as PromptMode, f2 as skip$1, _ as context, f3 as extractContextFromTraceparent, f4 as isContextWindowLimitError, q as serializeContextItem, K as forceHydration, af as reformatBotMessageForChat, M as hydrateAfterPostMessage, f5 as addMessageListenersForExtensionAPI, f6 as createMessageAPIForExtension, am as View, aF as ChatHistoryType, f7 as NEVER$1, f8 as CodeActionKind, av as pluralize, f9 as assertFileURI, d as RULES_PROVIDER_URI, fa as createCodeSearchProvider, fb as ProgrammingLanguage, fc as psDedent, fd as formatRuleForPrompt, fe as posixFilePaths, ff as DecorationRangeBehavior, fg as diffLines, fh as CODY_SUPPORT_URL, fi as CODY_DOC_URL, fj as CODY_FEEDBACK_URL, fk as DISCORD_URL, fl as globalAgentRef, fm as VSCODE_CHANGELOG_URL, fn as SG_CHANGELOG_URL, fo as ACCOUNT_LIMITS_INFO_URL, fp as assertUnreachable, fq as promise, fr as ExtensionMode, fs as setLogger, ft as setClientCapabilities, fu as setResolvedConfigurationObservable, fv as setClientNameVersion, fw as setOpenCtxControllerObservable, aJ as browser$4 } from "./vscode-shim-Csgwpsv8.mjs";
|
|
22
|
+
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-D8ltdME7.mjs";
|
|
23
23
|
var NOTHING = Symbol.for("immer-nothing");
|
|
24
24
|
var DRAFTABLE = Symbol.for("immer-draftable");
|
|
25
25
|
var DRAFT_STATE = Symbol.for("immer-state");
|
|
@@ -1047,158 +1047,6 @@ const configOverwrites = authStatus.pipe(
|
|
|
1047
1047
|
// the operation catches its own errors, so errors will never get here
|
|
1048
1048
|
);
|
|
1049
1049
|
configOverwrites.subscribe({});
|
|
1050
|
-
var ModelUsage = /* @__PURE__ */ ((ModelUsage2) => {
|
|
1051
|
-
ModelUsage2["Chat"] = "chat";
|
|
1052
|
-
ModelUsage2["Edit"] = "edit";
|
|
1053
|
-
ModelUsage2["Autocomplete"] = "autocomplete";
|
|
1054
|
-
ModelUsage2["Unlimited"] = "unlimitedChat";
|
|
1055
|
-
return ModelUsage2;
|
|
1056
|
-
})(ModelUsage || {});
|
|
1057
|
-
function createModel({
|
|
1058
|
-
id,
|
|
1059
|
-
modelRef: modelRefInput,
|
|
1060
|
-
usage,
|
|
1061
|
-
contextWindow: contextWindow2 = {
|
|
1062
|
-
input: CHAT_INPUT_TOKEN_BUDGET,
|
|
1063
|
-
output: CHAT_OUTPUT_TOKEN_BUDGET
|
|
1064
|
-
},
|
|
1065
|
-
clientSideConfig,
|
|
1066
|
-
tags = [],
|
|
1067
|
-
provider,
|
|
1068
|
-
title
|
|
1069
|
-
}) {
|
|
1070
|
-
var _a3, _b2;
|
|
1071
|
-
let modelRef;
|
|
1072
|
-
if (typeof modelRefInput === "object") {
|
|
1073
|
-
modelRef = modelRefInput;
|
|
1074
|
-
} else if (typeof modelRefInput === "string") {
|
|
1075
|
-
modelRef = parseModelRef(modelRefInput);
|
|
1076
|
-
} else {
|
|
1077
|
-
const info2 = getModelInfo(id);
|
|
1078
|
-
modelRef = {
|
|
1079
|
-
providerId: provider ?? info2.provider,
|
|
1080
|
-
apiVersionId: "unknown",
|
|
1081
|
-
modelId: title ?? info2.title
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
if ((_b2 = (_a3 = clientSideConfig == null ? void 0 : clientSideConfig.options) == null ? void 0 : _a3.categories) == null ? void 0 : _b2.includes(ModelTag.Vision)) {
|
|
1085
|
-
tags.push(ModelTag.Vision);
|
|
1086
|
-
}
|
|
1087
|
-
return {
|
|
1088
|
-
id,
|
|
1089
|
-
modelRef,
|
|
1090
|
-
usage,
|
|
1091
|
-
contextWindow: contextWindow2,
|
|
1092
|
-
clientSideConfig,
|
|
1093
|
-
tags,
|
|
1094
|
-
provider: modelRef.providerId,
|
|
1095
|
-
title: title ?? modelRef.modelId
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
function createModelFromServerModel({
|
|
1099
|
-
modelRef,
|
|
1100
|
-
displayName,
|
|
1101
|
-
capabilities,
|
|
1102
|
-
category,
|
|
1103
|
-
tier,
|
|
1104
|
-
status,
|
|
1105
|
-
clientSideConfig,
|
|
1106
|
-
contextWindow: contextWindow2
|
|
1107
|
-
}, enhancedContextWindowFlagEnabled) {
|
|
1108
|
-
const ref = parseModelRef(modelRef);
|
|
1109
|
-
const { maxInputTokens, maxOutputTokens } = contextWindow2;
|
|
1110
|
-
const _contextWindow = {
|
|
1111
|
-
input: maxInputTokens,
|
|
1112
|
-
output: maxOutputTokens
|
|
1113
|
-
};
|
|
1114
|
-
const usage = capabilities.flatMap(capabilityToUsage);
|
|
1115
|
-
if (capabilities.includes("reasoning") && usage.includes(ModelUsage.Edit)) {
|
|
1116
|
-
usage.splice(usage.indexOf(ModelUsage.Edit), 1);
|
|
1117
|
-
}
|
|
1118
|
-
if (maxInputTokens === EXTENDED_CHAT_INPUT_TOKEN_BUDGET + EXTENDED_USER_CONTEXT_TOKEN_BUDGET) {
|
|
1119
|
-
_contextWindow.input = EXTENDED_CHAT_INPUT_TOKEN_BUDGET;
|
|
1120
|
-
_contextWindow.context = { user: EXTENDED_USER_CONTEXT_TOKEN_BUDGET };
|
|
1121
|
-
}
|
|
1122
|
-
if (enhancedContextWindowFlagEnabled && contextWindow2.maxUserInputTokens && contextWindow2.maxInputTokens > 0 && contextWindow2.maxInputTokens > contextWindow2.maxUserInputTokens) {
|
|
1123
|
-
_contextWindow.input = contextWindow2.maxUserInputTokens;
|
|
1124
|
-
_contextWindow.context = {
|
|
1125
|
-
user: contextWindow2.maxInputTokens - contextWindow2.maxUserInputTokens
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
return createModel({
|
|
1129
|
-
id: modelRef,
|
|
1130
|
-
modelRef: ref,
|
|
1131
|
-
usage,
|
|
1132
|
-
contextWindow: _contextWindow,
|
|
1133
|
-
clientSideConfig,
|
|
1134
|
-
tags: getServerModelTags(capabilities, category, status, tier),
|
|
1135
|
-
provider: ref.providerId,
|
|
1136
|
-
title: displayName
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
function capabilityToUsage(capability) {
|
|
1140
|
-
switch (capability) {
|
|
1141
|
-
case "autocomplete":
|
|
1142
|
-
return [ModelUsage.Autocomplete];
|
|
1143
|
-
case "chat":
|
|
1144
|
-
return [ModelUsage.Chat];
|
|
1145
|
-
case "edit":
|
|
1146
|
-
return [ModelUsage.Edit];
|
|
1147
|
-
default:
|
|
1148
|
-
return [];
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
function modelTier(model2) {
|
|
1152
|
-
const tierSet = /* @__PURE__ */ new Set([ModelTag.Pro, ModelTag.Enterprise]);
|
|
1153
|
-
return model2.tags.find((tag2) => tierSet.has(tag2)) ?? ModelTag.Free;
|
|
1154
|
-
}
|
|
1155
|
-
function parseModelRef(ref) {
|
|
1156
|
-
try {
|
|
1157
|
-
const [providerId, apiVersionId, modelId] = ref.split("::", 3);
|
|
1158
|
-
return {
|
|
1159
|
-
providerId,
|
|
1160
|
-
apiVersionId,
|
|
1161
|
-
modelId
|
|
1162
|
-
};
|
|
1163
|
-
} catch {
|
|
1164
|
-
const [providerId, modelId] = ref.split("/", 2);
|
|
1165
|
-
return {
|
|
1166
|
-
providerId,
|
|
1167
|
-
modelId,
|
|
1168
|
-
apiVersionId: "unknown"
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
function getServerModelTags(capabilities, category, status, tier) {
|
|
1173
|
-
const tags = [tier];
|
|
1174
|
-
if (capabilities.includes("vision")) {
|
|
1175
|
-
tags.push(ModelTag.Vision);
|
|
1176
|
-
}
|
|
1177
|
-
if (capabilities.includes("reasoning")) {
|
|
1178
|
-
tags.push(ModelTag.Reasoning);
|
|
1179
|
-
}
|
|
1180
|
-
if (status === "waitlist") {
|
|
1181
|
-
tags.push(ModelTag.Waitlist);
|
|
1182
|
-
if (tier === ModelTag.Pro) {
|
|
1183
|
-
tags.push(ModelTag.StreamDisabled);
|
|
1184
|
-
}
|
|
1185
|
-
} else if (status === "internal") {
|
|
1186
|
-
tags.push(ModelTag.Internal);
|
|
1187
|
-
} else if (status === "experimental") {
|
|
1188
|
-
tags.push(ModelTag.Experimental);
|
|
1189
|
-
}
|
|
1190
|
-
if (category === "accuracy") {
|
|
1191
|
-
tags.push(ModelTag.Power);
|
|
1192
|
-
} else {
|
|
1193
|
-
tags.push(category);
|
|
1194
|
-
}
|
|
1195
|
-
return tags;
|
|
1196
|
-
}
|
|
1197
|
-
createModel({
|
|
1198
|
-
id: "my-model",
|
|
1199
|
-
usage: [ModelUsage.Chat],
|
|
1200
|
-
tags: [ModelTag.Enterprise]
|
|
1201
|
-
});
|
|
1202
1050
|
var define_process_default$m = { env: {} };
|
|
1203
1051
|
const version$1 = "0.5.1";
|
|
1204
1052
|
class ResponseError extends Error {
|
|
@@ -8216,6 +8064,224 @@ async function ollamaChatClient({
|
|
|
8216
8064
|
}
|
|
8217
8065
|
const OLLAMA_DEFAULT_URL = "http://localhost:11434";
|
|
8218
8066
|
const OLLAMA_DEFAULT_CONTEXT_WINDOW = 2048;
|
|
8067
|
+
var ModelUsage = /* @__PURE__ */ ((ModelUsage2) => {
|
|
8068
|
+
ModelUsage2["Chat"] = "chat";
|
|
8069
|
+
ModelUsage2["Edit"] = "edit";
|
|
8070
|
+
ModelUsage2["Autocomplete"] = "autocomplete";
|
|
8071
|
+
ModelUsage2["Unlimited"] = "unlimitedChat";
|
|
8072
|
+
return ModelUsage2;
|
|
8073
|
+
})(ModelUsage || {});
|
|
8074
|
+
const ANSWER_TOKENS = 1e3;
|
|
8075
|
+
const MAX_CURRENT_FILE_TOKENS = 1e3;
|
|
8076
|
+
const SURROUNDING_LINES = 50;
|
|
8077
|
+
function getProviderName(name2) {
|
|
8078
|
+
const providerName = name2.toLowerCase();
|
|
8079
|
+
switch (providerName) {
|
|
8080
|
+
case "anthropic":
|
|
8081
|
+
return "Anthropic";
|
|
8082
|
+
case "openai":
|
|
8083
|
+
return "OpenAI";
|
|
8084
|
+
case "ollama":
|
|
8085
|
+
return "Ollama";
|
|
8086
|
+
case "google":
|
|
8087
|
+
return "Google";
|
|
8088
|
+
default:
|
|
8089
|
+
return providerName;
|
|
8090
|
+
}
|
|
8091
|
+
}
|
|
8092
|
+
function getModelInfo(modelID) {
|
|
8093
|
+
const [providerID, ...rest] = modelID.split("/");
|
|
8094
|
+
const provider = getProviderName(providerID);
|
|
8095
|
+
const title = (rest.at(-1) || "").replace(/-/g, " ");
|
|
8096
|
+
return { provider, title };
|
|
8097
|
+
}
|
|
8098
|
+
function isCustomModel(model2) {
|
|
8099
|
+
return modelHasTag(model2, ModelTag.Local) || modelHasTag(model2, ModelTag.Dev) || modelHasTag(model2, ModelTag.BYOK);
|
|
8100
|
+
}
|
|
8101
|
+
function modelHasTag(model2, modelTag) {
|
|
8102
|
+
return model2.tags.includes(modelTag);
|
|
8103
|
+
}
|
|
8104
|
+
function getEnterpriseContextWindow(chatModel, configOverwrites2, configuration) {
|
|
8105
|
+
const { chatModelMaxTokens, smartContextWindow } = configOverwrites2;
|
|
8106
|
+
let contextWindow2 = {
|
|
8107
|
+
input: chatModelMaxTokens ?? CHAT_INPUT_TOKEN_BUDGET,
|
|
8108
|
+
output: getEnterpriseOutputLimit(chatModel)
|
|
8109
|
+
};
|
|
8110
|
+
if (smartContextWindow && isModelWithExtendedContextWindowSupport(chatModel)) {
|
|
8111
|
+
contextWindow2 = {
|
|
8112
|
+
input: EXTENDED_CHAT_INPUT_TOKEN_BUDGET,
|
|
8113
|
+
output: CHAT_OUTPUT_TOKEN_BUDGET,
|
|
8114
|
+
context: { user: EXTENDED_USER_CONTEXT_TOKEN_BUDGET }
|
|
8115
|
+
};
|
|
8116
|
+
}
|
|
8117
|
+
return applyLocalTokenLimitOverwrite(configuration, chatModel, contextWindow2);
|
|
8118
|
+
}
|
|
8119
|
+
function applyLocalTokenLimitOverwrite({ providerLimitPrompt }, chatModel, contextWindow2) {
|
|
8120
|
+
if (providerLimitPrompt && providerLimitPrompt <= contextWindow2.input) {
|
|
8121
|
+
return { ...contextWindow2, input: providerLimitPrompt };
|
|
8122
|
+
}
|
|
8123
|
+
if (providerLimitPrompt) {
|
|
8124
|
+
logDebug$1(
|
|
8125
|
+
"getEnterpriseContextWindow",
|
|
8126
|
+
`Invalid token limit configured for ${chatModel}`,
|
|
8127
|
+
providerLimitPrompt
|
|
8128
|
+
);
|
|
8129
|
+
}
|
|
8130
|
+
return contextWindow2;
|
|
8131
|
+
}
|
|
8132
|
+
const modelWithExpandedWindowSubStrings = [
|
|
8133
|
+
"opus",
|
|
8134
|
+
"sonnet",
|
|
8135
|
+
// Covers claude 3 sonnet & 3.5 sonnet
|
|
8136
|
+
"gemini-1.5",
|
|
8137
|
+
"gpt-4o",
|
|
8138
|
+
"gpt-4-turbo"
|
|
8139
|
+
];
|
|
8140
|
+
function isModelWithExtendedContextWindowSupport(chatModel) {
|
|
8141
|
+
return modelWithExpandedWindowSubStrings.some((keyword) => chatModel.toLowerCase().includes(keyword));
|
|
8142
|
+
}
|
|
8143
|
+
function getEnterpriseOutputLimit(model2) {
|
|
8144
|
+
if (model2 && isModelWithExtendedContextWindowSupport(model2)) {
|
|
8145
|
+
return CHAT_OUTPUT_TOKEN_BUDGET;
|
|
8146
|
+
}
|
|
8147
|
+
return ANSWER_TOKENS;
|
|
8148
|
+
}
|
|
8149
|
+
function createModel({
|
|
8150
|
+
id,
|
|
8151
|
+
modelRef: modelRefInput,
|
|
8152
|
+
usage,
|
|
8153
|
+
contextWindow: contextWindow2 = {
|
|
8154
|
+
input: CHAT_INPUT_TOKEN_BUDGET,
|
|
8155
|
+
output: CHAT_OUTPUT_TOKEN_BUDGET
|
|
8156
|
+
},
|
|
8157
|
+
clientSideConfig,
|
|
8158
|
+
tags = [],
|
|
8159
|
+
provider,
|
|
8160
|
+
title
|
|
8161
|
+
}) {
|
|
8162
|
+
var _a3, _b2;
|
|
8163
|
+
let modelRef;
|
|
8164
|
+
if (typeof modelRefInput === "object") {
|
|
8165
|
+
modelRef = modelRefInput;
|
|
8166
|
+
} else if (typeof modelRefInput === "string") {
|
|
8167
|
+
modelRef = parseModelRef(modelRefInput);
|
|
8168
|
+
} else {
|
|
8169
|
+
const info2 = getModelInfo(id);
|
|
8170
|
+
modelRef = {
|
|
8171
|
+
providerId: provider ?? info2.provider,
|
|
8172
|
+
apiVersionId: "unknown",
|
|
8173
|
+
modelId: title ?? info2.title
|
|
8174
|
+
};
|
|
8175
|
+
}
|
|
8176
|
+
if ((_b2 = (_a3 = clientSideConfig == null ? void 0 : clientSideConfig.options) == null ? void 0 : _a3.categories) == null ? void 0 : _b2.includes(ModelTag.Vision)) {
|
|
8177
|
+
tags.push(ModelTag.Vision);
|
|
8178
|
+
}
|
|
8179
|
+
return {
|
|
8180
|
+
id,
|
|
8181
|
+
modelRef,
|
|
8182
|
+
usage,
|
|
8183
|
+
contextWindow: contextWindow2,
|
|
8184
|
+
clientSideConfig,
|
|
8185
|
+
tags,
|
|
8186
|
+
provider: modelRef.providerId,
|
|
8187
|
+
title: title ?? modelRef.modelId
|
|
8188
|
+
};
|
|
8189
|
+
}
|
|
8190
|
+
function createModelFromServerModel({
|
|
8191
|
+
modelRef,
|
|
8192
|
+
displayName,
|
|
8193
|
+
capabilities,
|
|
8194
|
+
category,
|
|
8195
|
+
tier,
|
|
8196
|
+
status,
|
|
8197
|
+
clientSideConfig,
|
|
8198
|
+
contextWindow: contextWindow2
|
|
8199
|
+
}, enhancedContextWindowFlagEnabled) {
|
|
8200
|
+
const ref = parseModelRef(modelRef);
|
|
8201
|
+
const { maxInputTokens, maxOutputTokens } = contextWindow2;
|
|
8202
|
+
const _contextWindow = {
|
|
8203
|
+
input: maxInputTokens,
|
|
8204
|
+
output: maxOutputTokens
|
|
8205
|
+
};
|
|
8206
|
+
const usage = capabilities.flatMap(capabilityToUsage);
|
|
8207
|
+
if (capabilities.includes("reasoning") && usage.includes(ModelUsage.Edit)) {
|
|
8208
|
+
usage.splice(usage.indexOf(ModelUsage.Edit), 1);
|
|
8209
|
+
}
|
|
8210
|
+
if (maxInputTokens === EXTENDED_CHAT_INPUT_TOKEN_BUDGET + EXTENDED_USER_CONTEXT_TOKEN_BUDGET) {
|
|
8211
|
+
_contextWindow.input = EXTENDED_CHAT_INPUT_TOKEN_BUDGET;
|
|
8212
|
+
_contextWindow.context = { user: EXTENDED_USER_CONTEXT_TOKEN_BUDGET };
|
|
8213
|
+
}
|
|
8214
|
+
if (enhancedContextWindowFlagEnabled && contextWindow2.maxUserInputTokens && contextWindow2.maxInputTokens > 0 && contextWindow2.maxInputTokens > contextWindow2.maxUserInputTokens) {
|
|
8215
|
+
_contextWindow.input = contextWindow2.maxUserInputTokens;
|
|
8216
|
+
_contextWindow.context = {
|
|
8217
|
+
user: contextWindow2.maxInputTokens - contextWindow2.maxUserInputTokens
|
|
8218
|
+
};
|
|
8219
|
+
}
|
|
8220
|
+
return createModel({
|
|
8221
|
+
id: modelRef,
|
|
8222
|
+
modelRef: ref,
|
|
8223
|
+
usage,
|
|
8224
|
+
contextWindow: _contextWindow,
|
|
8225
|
+
clientSideConfig,
|
|
8226
|
+
tags: getServerModelTags(capabilities, category, status, tier),
|
|
8227
|
+
provider: ref.providerId,
|
|
8228
|
+
title: displayName
|
|
8229
|
+
});
|
|
8230
|
+
}
|
|
8231
|
+
function capabilityToUsage(capability) {
|
|
8232
|
+
switch (capability) {
|
|
8233
|
+
case "autocomplete":
|
|
8234
|
+
return [ModelUsage.Autocomplete];
|
|
8235
|
+
case "chat":
|
|
8236
|
+
return [ModelUsage.Chat];
|
|
8237
|
+
case "edit":
|
|
8238
|
+
return [ModelUsage.Edit];
|
|
8239
|
+
default:
|
|
8240
|
+
return [];
|
|
8241
|
+
}
|
|
8242
|
+
}
|
|
8243
|
+
function parseModelRef(ref) {
|
|
8244
|
+
try {
|
|
8245
|
+
const [providerId, apiVersionId, modelId] = ref.split("::", 3);
|
|
8246
|
+
return {
|
|
8247
|
+
providerId,
|
|
8248
|
+
apiVersionId,
|
|
8249
|
+
modelId
|
|
8250
|
+
};
|
|
8251
|
+
} catch {
|
|
8252
|
+
const [providerId, modelId] = ref.split("/", 2);
|
|
8253
|
+
return {
|
|
8254
|
+
providerId,
|
|
8255
|
+
modelId,
|
|
8256
|
+
apiVersionId: "unknown"
|
|
8257
|
+
};
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
function getServerModelTags(capabilities, category, status, tier) {
|
|
8261
|
+
const tags = [tier];
|
|
8262
|
+
if (capabilities.includes("vision")) {
|
|
8263
|
+
tags.push(ModelTag.Vision);
|
|
8264
|
+
}
|
|
8265
|
+
if (capabilities.includes("reasoning")) {
|
|
8266
|
+
tags.push(ModelTag.Reasoning);
|
|
8267
|
+
}
|
|
8268
|
+
if (status === "internal") {
|
|
8269
|
+
tags.push(ModelTag.Internal);
|
|
8270
|
+
} else if (status === "experimental") {
|
|
8271
|
+
tags.push(ModelTag.Experimental);
|
|
8272
|
+
}
|
|
8273
|
+
if (category === "accuracy") {
|
|
8274
|
+
tags.push(ModelTag.Power);
|
|
8275
|
+
} else {
|
|
8276
|
+
tags.push(category);
|
|
8277
|
+
}
|
|
8278
|
+
return tags;
|
|
8279
|
+
}
|
|
8280
|
+
createModel({
|
|
8281
|
+
id: "my-model",
|
|
8282
|
+
usage: [ModelUsage.Chat],
|
|
8283
|
+
tags: [ModelTag.Enterprise]
|
|
8284
|
+
});
|
|
8219
8285
|
async function fetchLocalOllamaModels() {
|
|
8220
8286
|
var _a3;
|
|
8221
8287
|
if (cenv.CODY_OVERRIDE_DISABLE_OLLAMA) {
|
|
@@ -8303,8 +8369,7 @@ function syncModels({
|
|
|
8303
8369
|
authStatus: authStatus2,
|
|
8304
8370
|
configOverwrites: configOverwrites2,
|
|
8305
8371
|
clientConfig,
|
|
8306
|
-
fetchServerSideModels_ = fetchServerSideModels
|
|
8307
|
-
userProductSubscription: userProductSubscription2 = Observable.of(null)
|
|
8372
|
+
fetchServerSideModels_ = fetchServerSideModels
|
|
8308
8373
|
}) {
|
|
8309
8374
|
const localModels = combineLatest$1(
|
|
8310
8375
|
resolvedConfig2.pipe(
|
|
@@ -8345,8 +8410,14 @@ function syncModels({
|
|
|
8345
8410
|
),
|
|
8346
8411
|
distinctUntilChanged$1()
|
|
8347
8412
|
);
|
|
8348
|
-
const userModelPreferences = resolvedConfig2.pipe(
|
|
8349
|
-
map$1((config) => {
|
|
8413
|
+
const userModelPreferences = combineLatest$1(resolvedConfig2, authStatus2).pipe(
|
|
8414
|
+
map$1(([config, authStatus22]) => {
|
|
8415
|
+
if (!config.auth.serverEndpoint || authStatus22.endpoint !== config.auth.serverEndpoint || authStatus22.pendingValidation) {
|
|
8416
|
+
return pendingOperation;
|
|
8417
|
+
}
|
|
8418
|
+
if (!authStatus22.authenticated) {
|
|
8419
|
+
return EMPTY_PREFERENCES;
|
|
8420
|
+
}
|
|
8350
8421
|
const prevPreferences = config.clientState.modelPreferences[config.auth.serverEndpoint];
|
|
8351
8422
|
return deepClone$1(prevPreferences ?? EMPTY_PREFERENCES);
|
|
8352
8423
|
}),
|
|
@@ -8356,20 +8427,21 @@ function syncModels({
|
|
|
8356
8427
|
}),
|
|
8357
8428
|
shareReplay$1()
|
|
8358
8429
|
);
|
|
8359
|
-
const remoteModelsData = combineLatest$1(relevantConfig, authStatus2
|
|
8360
|
-
switchMapReplayOperation(([config, authStatus22
|
|
8361
|
-
if (authStatus22.endpoint !== config.auth.serverEndpoint || authStatus22.pendingValidation
|
|
8430
|
+
const remoteModelsData = combineLatest$1(relevantConfig, authStatus2).pipe(
|
|
8431
|
+
switchMapReplayOperation(([config, authStatus22]) => {
|
|
8432
|
+
if (!authStatus22.endpoint || authStatus22.endpoint !== config.auth.serverEndpoint || authStatus22.pendingValidation) {
|
|
8362
8433
|
return Observable.of(pendingOperation);
|
|
8363
8434
|
}
|
|
8364
8435
|
if (!authStatus22.authenticated) {
|
|
8365
8436
|
return Observable.of({ primaryModels: [], preferences: null });
|
|
8366
8437
|
}
|
|
8438
|
+
const configWithEndpoint = config;
|
|
8367
8439
|
const serverModelsConfig = clientConfig.pipe(
|
|
8368
8440
|
switchMapReplayOperation((maybeServerSideClientConfig) => {
|
|
8369
8441
|
if (maybeServerSideClientConfig == null ? void 0 : maybeServerSideClientConfig.modelsAPIEnabled) {
|
|
8370
8442
|
logDebug$1("ModelsService", "new models API enabled");
|
|
8371
8443
|
return promiseFactoryToObservable(
|
|
8372
|
-
(signal2) => fetchServerSideModels_(
|
|
8444
|
+
(signal2) => fetchServerSideModels_(configWithEndpoint, signal2)
|
|
8373
8445
|
).pipe(
|
|
8374
8446
|
switchMap$1((serverModelsConfig2) => {
|
|
8375
8447
|
const data = {
|
|
@@ -8377,12 +8449,6 @@ function syncModels({
|
|
|
8377
8449
|
primaryModels: []
|
|
8378
8450
|
};
|
|
8379
8451
|
return combineLatest$1(
|
|
8380
|
-
featureFlagProvider.evaluatedFeatureFlag(
|
|
8381
|
-
FeatureFlag.CodyEarlyAccess
|
|
8382
|
-
),
|
|
8383
|
-
featureFlagProvider.evaluatedFeatureFlag(
|
|
8384
|
-
FeatureFlag.CodyChatDefaultToClaude35Haiku
|
|
8385
|
-
),
|
|
8386
8452
|
featureFlagProvider.evaluatedFeatureFlag(
|
|
8387
8453
|
FeatureFlag.EnhancedContextWindow,
|
|
8388
8454
|
true
|
|
@@ -8394,137 +8460,124 @@ function syncModels({
|
|
|
8394
8460
|
/** force refresh */
|
|
8395
8461
|
)
|
|
8396
8462
|
).pipe(
|
|
8397
|
-
switchMap$1(
|
|
8398
|
-
(
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8463
|
+
switchMap$1(([enhancedContextWindowFlag, fallbackToFlashFlag]) => {
|
|
8464
|
+
if (serverModelsConfig2) {
|
|
8465
|
+
const filteredModels = serverModelsConfig2 == null ? void 0 : serverModelsConfig2.models.filter(
|
|
8466
|
+
(m) => m.status !== "deprecated"
|
|
8467
|
+
);
|
|
8468
|
+
data.primaryModels = maybeAdjustContextWindows(
|
|
8469
|
+
filteredModels,
|
|
8470
|
+
{
|
|
8471
|
+
tier: "enterprise",
|
|
8472
|
+
enhancedContextWindowFlagEnabled: enhancedContextWindowFlag
|
|
8473
|
+
}
|
|
8474
|
+
).map(
|
|
8475
|
+
(model2) => createModelFromServerModel(
|
|
8476
|
+
model2,
|
|
8477
|
+
enhancedContextWindowFlag
|
|
8478
|
+
)
|
|
8479
|
+
);
|
|
8480
|
+
data.preferences.defaults = defaultModelPreferencesFromServerModelsConfig(
|
|
8481
|
+
serverModelsConfig2
|
|
8482
|
+
);
|
|
8483
|
+
}
|
|
8484
|
+
data.primaryModels = data.primaryModels.map((m) => ({
|
|
8485
|
+
...m,
|
|
8486
|
+
tags: m.provider === "google" ? m.tags.filter((t) => t !== ModelTag.Vision) : m.tags
|
|
8487
|
+
}));
|
|
8488
|
+
if (fallbackToFlashFlag) {
|
|
8489
|
+
if (authStatus22.rateLimited) {
|
|
8490
|
+
const hasUnlimitedModels = data.primaryModels.some(
|
|
8491
|
+
(model2) => model2.tags.includes(ModelTag.Unlimited)
|
|
8422
8492
|
);
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
(model2) => model2.tags.includes(ModelTag.Unlimited)
|
|
8434
|
-
);
|
|
8435
|
-
data.primaryModels = data.primaryModels.map(
|
|
8436
|
-
(model2) => {
|
|
8437
|
-
if (hasUnlimitedModels) {
|
|
8438
|
-
if (!model2.tags.includes(
|
|
8439
|
-
ModelTag.Unlimited
|
|
8440
|
-
)) {
|
|
8441
|
-
return {
|
|
8442
|
-
...model2,
|
|
8443
|
-
disabled: true
|
|
8444
|
-
};
|
|
8445
|
-
}
|
|
8446
|
-
} else {
|
|
8447
|
-
if (!model2.tags.includes(
|
|
8448
|
-
ModelTag.Speed
|
|
8449
|
-
)) {
|
|
8450
|
-
return {
|
|
8451
|
-
...model2,
|
|
8452
|
-
disabled: true
|
|
8453
|
-
};
|
|
8454
|
-
}
|
|
8493
|
+
data.primaryModels = data.primaryModels.map(
|
|
8494
|
+
(model2) => {
|
|
8495
|
+
if (hasUnlimitedModels) {
|
|
8496
|
+
if (!model2.tags.includes(
|
|
8497
|
+
ModelTag.Unlimited
|
|
8498
|
+
)) {
|
|
8499
|
+
return {
|
|
8500
|
+
...model2,
|
|
8501
|
+
disabled: true
|
|
8502
|
+
};
|
|
8455
8503
|
}
|
|
8456
|
-
|
|
8457
|
-
}
|
|
8458
|
-
);
|
|
8459
|
-
if (data.preferences) {
|
|
8460
|
-
const modelToFallback = data.preferences.defaults.unlimitedChat || "google::v1::gemini-2.0-flash";
|
|
8461
|
-
let defaultModel = data.primaryModels.find(
|
|
8462
|
-
(model2) => model2.id === modelToFallback
|
|
8463
|
-
);
|
|
8464
|
-
if (!defaultModel) {
|
|
8465
|
-
defaultModel = data.primaryModels.find(
|
|
8466
|
-
(model2) => model2.tags.includes(
|
|
8467
|
-
ModelTag.Speed
|
|
8468
|
-
)
|
|
8469
|
-
);
|
|
8470
|
-
}
|
|
8471
|
-
if (defaultModel) {
|
|
8472
|
-
rateLimitState.chatModel = data.preferences.defaults.chat || "";
|
|
8473
|
-
rateLimitState.editModel = data.preferences.defaults.edit || "";
|
|
8474
|
-
data.preferences.defaults.chat = defaultModel.id;
|
|
8475
|
-
data.preferences.defaults.edit = defaultModel.id;
|
|
8476
|
-
telemetryRecorder.recordEvent(
|
|
8477
|
-
"cody.rateLimit",
|
|
8478
|
-
"hit",
|
|
8479
|
-
{
|
|
8480
|
-
privateMetadata: {
|
|
8481
|
-
chatModel: defaultModel.id
|
|
8482
|
-
}
|
|
8483
|
-
}
|
|
8484
|
-
);
|
|
8485
|
-
}
|
|
8486
|
-
}
|
|
8487
|
-
} else {
|
|
8488
|
-
data.primaryModels = data.primaryModels.map(
|
|
8489
|
-
(model2) => {
|
|
8504
|
+
} else {
|
|
8490
8505
|
if (!model2.tags.includes(ModelTag.Speed)) {
|
|
8491
8506
|
return {
|
|
8492
8507
|
...model2,
|
|
8493
|
-
disabled:
|
|
8508
|
+
disabled: true
|
|
8494
8509
|
};
|
|
8495
8510
|
}
|
|
8496
|
-
return model2;
|
|
8497
8511
|
}
|
|
8512
|
+
return model2;
|
|
8513
|
+
}
|
|
8514
|
+
);
|
|
8515
|
+
if (data.preferences) {
|
|
8516
|
+
const modelToFallback = data.preferences.defaults.unlimitedChat || "google::v1::gemini-2.0-flash";
|
|
8517
|
+
let defaultModel = data.primaryModels.find(
|
|
8518
|
+
(model2) => model2.id === modelToFallback
|
|
8498
8519
|
);
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
(model2) => model2.id === rateLimitState.editModel
|
|
8504
|
-
);
|
|
8505
|
-
if (originalChatModel && data.preferences) {
|
|
8506
|
-
data.preferences.defaults.chat = originalChatModel.id;
|
|
8520
|
+
if (!defaultModel) {
|
|
8521
|
+
defaultModel = data.primaryModels.find(
|
|
8522
|
+
(model2) => model2.tags.includes(ModelTag.Speed)
|
|
8523
|
+
);
|
|
8507
8524
|
}
|
|
8508
|
-
if (
|
|
8509
|
-
data.preferences.defaults.
|
|
8525
|
+
if (defaultModel) {
|
|
8526
|
+
rateLimitState.chatModel = data.preferences.defaults.chat || "";
|
|
8527
|
+
rateLimitState.editModel = data.preferences.defaults.edit || "";
|
|
8528
|
+
data.preferences.defaults.chat = defaultModel.id;
|
|
8529
|
+
data.preferences.defaults.edit = defaultModel.id;
|
|
8530
|
+
telemetryRecorder.recordEvent(
|
|
8531
|
+
"cody.rateLimit",
|
|
8532
|
+
"hit",
|
|
8533
|
+
{
|
|
8534
|
+
privateMetadata: {
|
|
8535
|
+
chatModel: defaultModel.id
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8538
|
+
);
|
|
8510
8539
|
}
|
|
8511
8540
|
}
|
|
8512
|
-
}
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8541
|
+
} else {
|
|
8542
|
+
data.primaryModels = data.primaryModels.map(
|
|
8543
|
+
(model2) => {
|
|
8544
|
+
if (!model2.tags.includes(ModelTag.Speed)) {
|
|
8545
|
+
return {
|
|
8546
|
+
...model2,
|
|
8547
|
+
disabled: false
|
|
8548
|
+
};
|
|
8549
|
+
}
|
|
8550
|
+
return model2;
|
|
8551
|
+
}
|
|
8552
|
+
);
|
|
8553
|
+
const originalChatModel = data.primaryModels.find(
|
|
8554
|
+
(model2) => model2.id === rateLimitState.chatModel
|
|
8555
|
+
);
|
|
8556
|
+
const originalEditModel = data.primaryModels.find(
|
|
8557
|
+
(model2) => model2.id === rateLimitState.editModel
|
|
8558
|
+
);
|
|
8559
|
+
if (originalChatModel && data.preferences) {
|
|
8560
|
+
data.preferences.defaults.chat = originalChatModel.id;
|
|
8522
8561
|
}
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8562
|
+
if (originalEditModel && data.preferences) {
|
|
8563
|
+
data.preferences.defaults.edit = originalEditModel.id;
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8526
8566
|
}
|
|
8527
|
-
|
|
8567
|
+
data.primaryModels.push(
|
|
8568
|
+
...getModelsFromVSCodeConfiguration(config)
|
|
8569
|
+
);
|
|
8570
|
+
data.primaryModels = data.primaryModels.map((model2) => {
|
|
8571
|
+
if (model2.modelRef === data.preferences.defaults.chat) {
|
|
8572
|
+
return {
|
|
8573
|
+
...model2,
|
|
8574
|
+
tags: [...model2.tags, ModelTag.Default]
|
|
8575
|
+
};
|
|
8576
|
+
}
|
|
8577
|
+
return model2;
|
|
8578
|
+
});
|
|
8579
|
+
return Observable.of(data);
|
|
8580
|
+
})
|
|
8528
8581
|
);
|
|
8529
8582
|
})
|
|
8530
8583
|
);
|
|
@@ -8566,7 +8619,7 @@ function syncModels({
|
|
|
8566
8619
|
return combineLatest$1(localModels, remoteModelsData, userModelPreferences, authStatus2).pipe(
|
|
8567
8620
|
map$1(
|
|
8568
8621
|
([localModels2, remoteModelsData2, userModelPreferences2, currentAuthStatus2]) => {
|
|
8569
|
-
if (remoteModelsData2 === pendingOperation) {
|
|
8622
|
+
if (remoteModelsData2 === pendingOperation || userModelPreferences2 === pendingOperation) {
|
|
8570
8623
|
return pendingOperation;
|
|
8571
8624
|
}
|
|
8572
8625
|
const isRateLimited2 = !!("rateLimited" in currentAuthStatus2 && currentAuthStatus2.rateLimited);
|
|
@@ -8634,7 +8687,11 @@ function getModelsFromVSCodeConfiguration({
|
|
|
8634
8687
|
)) ?? [];
|
|
8635
8688
|
}
|
|
8636
8689
|
async function fetchServerSideModels(config, signal2) {
|
|
8637
|
-
|
|
8690
|
+
if (!config.auth.serverEndpoint) {
|
|
8691
|
+
return;
|
|
8692
|
+
}
|
|
8693
|
+
const authWithEndpoint = config.auth;
|
|
8694
|
+
const client = new RestClient(authWithEndpoint, config.configuration.customHeaders);
|
|
8638
8695
|
return await client.getAvailableModels(signal2);
|
|
8639
8696
|
}
|
|
8640
8697
|
const maybeAdjustContextWindows = (models, config) => {
|
|
@@ -8703,8 +8760,7 @@ class ModelsService {
|
|
|
8703
8760
|
),
|
|
8704
8761
|
authStatus,
|
|
8705
8762
|
configOverwrites,
|
|
8706
|
-
clientConfig: ClientConfigSingleton.getInstance().changes
|
|
8707
|
-
userProductSubscription
|
|
8763
|
+
clientConfig: ClientConfigSingleton.getInstance().changes
|
|
8708
8764
|
}));
|
|
8709
8765
|
if (testing__mockModelsChanges) {
|
|
8710
8766
|
this.modelsChanges = testing__mockModelsChanges;
|
|
@@ -8718,42 +8774,50 @@ class ModelsService {
|
|
|
8718
8774
|
this.syncPreferencesSubscription = combineLatest$1(
|
|
8719
8775
|
this.modelsChanges,
|
|
8720
8776
|
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyEditDefaultToGpt4oMini),
|
|
8721
|
-
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyDeepSeekChat)
|
|
8777
|
+
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.CodyDeepSeekChat),
|
|
8778
|
+
authStatus
|
|
8722
8779
|
).pipe(
|
|
8723
|
-
tap$2(
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
);
|
|
8734
|
-
const gpt4oMini = data.primaryModels.find(
|
|
8735
|
-
(model2) => {
|
|
8736
|
-
var _a4;
|
|
8737
|
-
return ((_a4 = model2 == null ? void 0 : model2.modelRef) == null ? void 0 : _a4.modelId) === "gpt-4o-mini";
|
|
8780
|
+
tap$2(
|
|
8781
|
+
async ([
|
|
8782
|
+
data,
|
|
8783
|
+
shouldEditDefaultToGpt4oMini,
|
|
8784
|
+
shouldChatDefaultToDeepSeek,
|
|
8785
|
+
currentAuthStatus2
|
|
8786
|
+
]) => {
|
|
8787
|
+
var _a3, _b2, _c2, _d2;
|
|
8788
|
+
if (data === pendingOperation || currentAuthStatus2.pendingValidation === true || currentAuthStatus2.authenticated === false) {
|
|
8789
|
+
return;
|
|
8738
8790
|
}
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8791
|
+
const isEnrolled = (_a3 = this.storage) == null ? void 0 : _a3.getEnrollmentHistory(
|
|
8792
|
+
FeatureFlag.CodyEditDefaultToGpt4oMini
|
|
8793
|
+
);
|
|
8794
|
+
const isEnrolledDeepSeekChat = (_b2 = this.storage) == null ? void 0 : _b2.getEnrollmentHistory(
|
|
8795
|
+
FeatureFlag.CodyDeepSeekChat
|
|
8796
|
+
);
|
|
8797
|
+
const gpt4oMini = data.primaryModels.find(
|
|
8798
|
+
(model2) => {
|
|
8799
|
+
var _a4;
|
|
8800
|
+
return ((_a4 = model2 == null ? void 0 : model2.modelRef) == null ? void 0 : _a4.modelId) === "gpt-4o-mini";
|
|
8801
|
+
}
|
|
8802
|
+
);
|
|
8803
|
+
const deepseekModel = data.primaryModels.find(
|
|
8804
|
+
(model2) => (model2 == null ? void 0 : model2.id) === "fireworks::v1::deepseek-v3"
|
|
8805
|
+
);
|
|
8806
|
+
const allSitePrefs = (_c2 = this.storage) == null ? void 0 : _c2.getModelPreferences();
|
|
8807
|
+
const currentAccountPrefs = { ...data.preferences };
|
|
8808
|
+
if (!isEnrolled && shouldEditDefaultToGpt4oMini && gpt4oMini) {
|
|
8809
|
+
currentAccountPrefs.selected.edit = gpt4oMini.id;
|
|
8810
|
+
}
|
|
8811
|
+
if (!isEnrolledDeepSeekChat && shouldChatDefaultToDeepSeek && deepseekModel) {
|
|
8812
|
+
currentAccountPrefs.selected.chat = deepseekModel.id;
|
|
8813
|
+
}
|
|
8814
|
+
const updated = {
|
|
8815
|
+
...allSitePrefs,
|
|
8816
|
+
[currentAuthStatus2.endpoint]: currentAccountPrefs
|
|
8817
|
+
};
|
|
8818
|
+
await ((_d2 = this.storage) == null ? void 0 : _d2.setModelPreferences(updated));
|
|
8750
8819
|
}
|
|
8751
|
-
|
|
8752
|
-
...allSitePrefs,
|
|
8753
|
-
[currentAuthStatus().endpoint]: currentAccountPrefs
|
|
8754
|
-
};
|
|
8755
|
-
(_d2 = this.storage) == null ? void 0 : _d2.setModelPreferences(updated);
|
|
8756
|
-
})
|
|
8820
|
+
)
|
|
8757
8821
|
).subscribe({});
|
|
8758
8822
|
}
|
|
8759
8823
|
dispose() {
|
|
@@ -8770,16 +8834,6 @@ class ModelsService {
|
|
|
8770
8834
|
const data = this.storedValue.value.last;
|
|
8771
8835
|
return data ? data.primaryModels.concat(data.localModels) : [];
|
|
8772
8836
|
}
|
|
8773
|
-
getModelsByType(usage) {
|
|
8774
|
-
return this.modelsChanges.pipe(
|
|
8775
|
-
map$1((models) => {
|
|
8776
|
-
return models === pendingOperation ? pendingOperation : [...models.primaryModels, ...models.localModels].filter(
|
|
8777
|
-
(model2) => model2.usage.includes(usage)
|
|
8778
|
-
);
|
|
8779
|
-
}),
|
|
8780
|
-
distinctUntilChanged$1()
|
|
8781
|
-
);
|
|
8782
|
-
}
|
|
8783
8837
|
/**
|
|
8784
8838
|
* Gets the available models of the specified usage type, with the default model first.
|
|
8785
8839
|
*
|
|
@@ -8802,37 +8856,23 @@ class ModelsService {
|
|
|
8802
8856
|
shareReplay$1()
|
|
8803
8857
|
);
|
|
8804
8858
|
}
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
const isModelAvailable = await firstResultFromOperation(this.isModelAvailable(model2));
|
|
8810
|
-
return { model: model2, isModelAvailable };
|
|
8811
|
-
})
|
|
8812
|
-
);
|
|
8813
|
-
}
|
|
8814
|
-
getDefaultModel(type) {
|
|
8815
|
-
return combineLatest$1(
|
|
8816
|
-
this.getModelsByType(type),
|
|
8817
|
-
this.modelsChanges,
|
|
8818
|
-
authStatus,
|
|
8819
|
-
userProductSubscription
|
|
8820
|
-
).pipe(
|
|
8821
|
-
map$1(([models, modelsData, authStatus2, userProductSubscription2]) => {
|
|
8822
|
-
if (models === pendingOperation || modelsData === pendingOperation || userProductSubscription2 === pendingOperation) {
|
|
8859
|
+
getDefaultModel(usage) {
|
|
8860
|
+
return this.modelsChanges.pipe(
|
|
8861
|
+
map$1((modelsData) => {
|
|
8862
|
+
if (modelsData === pendingOperation) {
|
|
8823
8863
|
return pendingOperation;
|
|
8824
8864
|
}
|
|
8825
|
-
models =
|
|
8826
|
-
|
|
8827
|
-
(m) => this._isModelAvailable(modelsData, authStatus2, m) === true && !m.tags.includes(ModelTag.Reasoning)
|
|
8865
|
+
const models = [...modelsData.primaryModels, ...modelsData.localModels].filter(
|
|
8866
|
+
(model2) => model2.usage.includes(usage) && !model2.tags.includes(ModelTag.Deprecated)
|
|
8828
8867
|
);
|
|
8868
|
+
const firstModelUserCanUse = models.find((m) => !m.tags.includes(ModelTag.Reasoning));
|
|
8829
8869
|
if (modelsData.preferences) {
|
|
8830
8870
|
const selected = this.resolveModel(
|
|
8831
8871
|
modelsData,
|
|
8832
|
-
modelsData.preferences.selected[
|
|
8872
|
+
modelsData.preferences.selected[usage] ?? modelsData.preferences.defaults[usage]
|
|
8833
8873
|
);
|
|
8834
8874
|
if (selected && // Don't set default model for ModelUsage.Edit if the model has certain tags
|
|
8835
|
-
!(
|
|
8875
|
+
!(usage === ModelUsage.Edit && (selected.tags.includes(ModelTag.Reasoning) || selected.tags.includes(ModelTag.Deprecated)))) {
|
|
8836
8876
|
return selected;
|
|
8837
8877
|
}
|
|
8838
8878
|
}
|
|
@@ -8883,7 +8923,10 @@ class ModelsService {
|
|
|
8883
8923
|
if (!this.storage) {
|
|
8884
8924
|
throw new Error("ModelsService.storage is not set");
|
|
8885
8925
|
}
|
|
8886
|
-
const serverEndpoint =
|
|
8926
|
+
const serverEndpoint = (await firstResultFromOperation(authStatus)).endpoint;
|
|
8927
|
+
if (!serverEndpoint) {
|
|
8928
|
+
throw new Error("No server endpoint found");
|
|
8929
|
+
}
|
|
8887
8930
|
const currentPrefs = deepClone(this.storage.getModelPreferences());
|
|
8888
8931
|
if (!currentPrefs[serverEndpoint]) {
|
|
8889
8932
|
currentPrefs[serverEndpoint] = modelsData.preferences;
|
|
@@ -8891,28 +8934,6 @@ class ModelsService {
|
|
|
8891
8934
|
currentPrefs[serverEndpoint].selected[type] = resolved.id;
|
|
8892
8935
|
await this.storage.setModelPreferences(currentPrefs);
|
|
8893
8936
|
}
|
|
8894
|
-
isModelAvailable(model2) {
|
|
8895
|
-
return combineLatest$1(authStatus, this.modelsChanges, userProductSubscription).pipe(
|
|
8896
|
-
map$1(
|
|
8897
|
-
([authStatus2, modelsData, userProductSubscription2]) => modelsData === pendingOperation || userProductSubscription2 === pendingOperation ? pendingOperation : this._isModelAvailable(modelsData, authStatus2, model2)
|
|
8898
|
-
),
|
|
8899
|
-
distinctUntilChanged$1()
|
|
8900
|
-
);
|
|
8901
|
-
}
|
|
8902
|
-
_isModelAvailable(modelsData, authStatus2, model2) {
|
|
8903
|
-
const resolved = this.resolveModel(modelsData, model2);
|
|
8904
|
-
if (!resolved) {
|
|
8905
|
-
return false;
|
|
8906
|
-
}
|
|
8907
|
-
if (resolved.tags.includes(ModelTag.Waitlist) || resolved.tags.includes(ModelTag.OnWaitlist)) {
|
|
8908
|
-
return false;
|
|
8909
|
-
}
|
|
8910
|
-
const tier = modelTier(resolved);
|
|
8911
|
-
if (isEnterpriseUser(authStatus2)) {
|
|
8912
|
-
return true;
|
|
8913
|
-
}
|
|
8914
|
-
return tier === "free";
|
|
8915
|
-
}
|
|
8916
8937
|
// does an approximate match on the model id, seeing if there are any models in the
|
|
8917
8938
|
// cache that are contained within the given model id. This allows passing a qualified,
|
|
8918
8939
|
// unqualified or ModelRefStr in as the model id will be a substring
|
|
@@ -9189,9 +9210,15 @@ function getDefaultSystemPrompt() {
|
|
|
9189
9210
|
const SMART_APPLY_PREAMBLE = ps`If your answer contains fenced code blocks in Markdown, include the relevant full file path in the code block tag using this structure: \`\`\`$LANGUAGE:$FILEPATH\`\`\`
|
|
9190
9211
|
For executable terminal commands: enclose each command in individual "bash" language code block without comments and new lines inside.`;
|
|
9191
9212
|
const TERMINAL_TOOL_PREAMBLE = ps`\n\nCheck if you have access to terminal/shell tools. If so, use it to execute commands to gather information. The terminal output is included in your context. You can reference and analyze this output in your response.`;
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9213
|
+
function getChatPreamble(includeTerminalToolPreamble) {
|
|
9214
|
+
const basePreamble = DEFAULT_PREAMBLE.concat(SMART_APPLY_PREAMBLE);
|
|
9215
|
+
if (includeTerminalToolPreamble) {
|
|
9216
|
+
return basePreamble.concat(TERMINAL_TOOL_PREAMBLE);
|
|
9217
|
+
}
|
|
9218
|
+
return basePreamble;
|
|
9219
|
+
}
|
|
9220
|
+
function getSimplePreamble(model2, apiVersion, type, preInstruction, includeTerminalToolPreamble) {
|
|
9221
|
+
const preamble = type === "Chat" ? getChatPreamble(includeTerminalToolPreamble) : DEFAULT_PREAMBLE;
|
|
9195
9222
|
const intro = ps`${preamble}\n\n${preInstruction ?? ""}`.trim();
|
|
9196
9223
|
if (apiVersion >= 1 && (model2 == null ? void 0 : model2.includes("claude-3"))) {
|
|
9197
9224
|
return [
|
|
@@ -9506,7 +9533,7 @@ async function getTokenCounterUtils() {
|
|
|
9506
9533
|
const browser2 = detect();
|
|
9507
9534
|
if (browser2 && browser2.name === "safari") {
|
|
9508
9535
|
_tokenCounterUtilsPromise = import("./cl100k_base-B4kyDDRQ.mjs").then(async (tokenizer2) => {
|
|
9509
|
-
const tiktoken = await import("./lite-
|
|
9536
|
+
const tiktoken = await import("./lite-CQAWMpwn.mjs");
|
|
9510
9537
|
return createTokenCounterUtils(new tiktoken.Tiktoken(tokenizer2.default));
|
|
9511
9538
|
});
|
|
9512
9539
|
} else {
|
|
@@ -9883,19 +9910,20 @@ function defaultOnOpen(response) {
|
|
|
9883
9910
|
}
|
|
9884
9911
|
}
|
|
9885
9912
|
class CompletionsResponseBuilder {
|
|
9886
|
-
constructor(apiVersion) {
|
|
9913
|
+
constructor(apiVersion, model2) {
|
|
9887
9914
|
__publicField2(this, "totalCompletion", "");
|
|
9888
9915
|
__publicField2(this, "thinkingBuffer", []);
|
|
9889
9916
|
__publicField2(this, "toolCalled", /* @__PURE__ */ new Map());
|
|
9890
9917
|
__publicField2(this, "lastToolCallId");
|
|
9891
9918
|
this.apiVersion = apiVersion;
|
|
9919
|
+
this.model = model2;
|
|
9892
9920
|
}
|
|
9893
9921
|
/**
|
|
9894
9922
|
* Creates a builder from a URL with api-version parameter
|
|
9895
9923
|
*/
|
|
9896
|
-
static fromUrl(url) {
|
|
9924
|
+
static fromUrl(url, model2) {
|
|
9897
9925
|
const apiVersion = Number.parseInt(new URL(url).searchParams.get("api-version") ?? "0", 10);
|
|
9898
|
-
return new CompletionsResponseBuilder(apiVersion);
|
|
9926
|
+
return new CompletionsResponseBuilder(apiVersion, model2);
|
|
9899
9927
|
}
|
|
9900
9928
|
/**
|
|
9901
9929
|
* Processes the next chunk of completion text
|
|
@@ -13441,7 +13469,7 @@ class SourcegraphBrowserCompletionsClient extends SourcegraphCompletionsClient {
|
|
|
13441
13469
|
if (trace) {
|
|
13442
13470
|
headersInstance.set("X-Sourcegraph-Should-Trace", "true");
|
|
13443
13471
|
}
|
|
13444
|
-
const builder = new CompletionsResponseBuilder(apiVersion);
|
|
13472
|
+
const builder = new CompletionsResponseBuilder(apiVersion, params.model);
|
|
13445
13473
|
headersInstance.set("Accept-Encoding", "gzip;q=0");
|
|
13446
13474
|
fetchEventSource(url.toString(), {
|
|
13447
13475
|
method: "POST",
|
|
@@ -13661,10 +13689,6 @@ const events$2 = [
|
|
|
13661
13689
|
({ feature: feature2, action }) => (params) => {
|
|
13662
13690
|
telemetryRecorder.recordEvent(feature2, action, {
|
|
13663
13691
|
metadata: {
|
|
13664
|
-
// Flag indicating this is a transcript event to go through ML data pipeline. Not for enterprise users
|
|
13665
|
-
// See https://github.com/sourcegraph/sourcegraph/pull/59524
|
|
13666
|
-
recordsPrivateMetadataTranscript: 0,
|
|
13667
|
-
// todo(mk): remove in the scope of PLG sunsetting
|
|
13668
13692
|
isPublicRepo: params.repoIsPublic ? 1 : 0,
|
|
13669
13693
|
// TODO: Remove this field when the transition from commands to prompts is complete
|
|
13670
13694
|
isCommand: params.command ? 1 : 0,
|
|
@@ -13678,9 +13702,6 @@ const events$2 = [
|
|
|
13678
13702
|
requestID: params.requestID,
|
|
13679
13703
|
sessionID: params.sessionID,
|
|
13680
13704
|
traceId: params.traceId,
|
|
13681
|
-
promptText: void 0,
|
|
13682
|
-
// todo(mk): remove in the scope of PLG sunsetting
|
|
13683
|
-
gitMetadata: void 0,
|
|
13684
13705
|
chatAgent: params.chatAgent
|
|
13685
13706
|
},
|
|
13686
13707
|
billingMetadata: {
|
|
@@ -25183,6 +25204,7 @@ class LocalStorage {
|
|
|
25183
25204
|
* access it as a singleton via the module import.
|
|
25184
25205
|
*/
|
|
25185
25206
|
__publicField2(this, "_storage", null);
|
|
25207
|
+
__publicField2(this, "_cache", null);
|
|
25186
25208
|
__publicField2(this, "onChange", new AgentEventEmitter());
|
|
25187
25209
|
__publicField2(this, "createdAnonymousUserID", false);
|
|
25188
25210
|
}
|
|
@@ -25195,17 +25217,20 @@ class LocalStorage {
|
|
|
25195
25217
|
setStorage(storage) {
|
|
25196
25218
|
if (storage === "inMemory") {
|
|
25197
25219
|
this._storage = inMemoryEphemeralLocalStorage;
|
|
25220
|
+
this._cache = null;
|
|
25198
25221
|
} else if (storage === "noop") {
|
|
25199
25222
|
this._storage = noopLocalStorage;
|
|
25223
|
+
this._cache = null;
|
|
25200
25224
|
} else {
|
|
25201
25225
|
this._storage = storage;
|
|
25226
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
25202
25227
|
}
|
|
25203
25228
|
this.clearDeprecatedKeys();
|
|
25204
25229
|
}
|
|
25205
|
-
getClientState() {
|
|
25230
|
+
async getClientState() {
|
|
25206
25231
|
return {
|
|
25207
25232
|
lastUsedEndpoint: this.getEndpoint(),
|
|
25208
|
-
anonymousUserID: this.anonymousUserID(),
|
|
25233
|
+
anonymousUserID: await this.anonymousUserID(),
|
|
25209
25234
|
lastUsedChatModality: this.getLastUsedChatModality(),
|
|
25210
25235
|
modelPreferences: this.getModelPreferences()
|
|
25211
25236
|
};
|
|
@@ -25213,17 +25238,12 @@ class LocalStorage {
|
|
|
25213
25238
|
get clientStateChanges() {
|
|
25214
25239
|
return fromVSCodeEvent(this.onChange.event).pipe(
|
|
25215
25240
|
startWith$1(void 0),
|
|
25216
|
-
map$1(() => this.getClientState()),
|
|
25241
|
+
map$1(async () => await this.getClientState()),
|
|
25217
25242
|
distinctUntilChanged$1()
|
|
25218
25243
|
);
|
|
25219
25244
|
}
|
|
25220
25245
|
getEndpoint() {
|
|
25221
|
-
|
|
25222
|
-
if (endpoint && isSourcegraphToken(endpoint)) {
|
|
25223
|
-
this.deleteEndpoint(endpoint);
|
|
25224
|
-
return null;
|
|
25225
|
-
}
|
|
25226
|
-
return endpoint;
|
|
25246
|
+
return this.get(this.LAST_USED_ENDPOINT) || null;
|
|
25227
25247
|
}
|
|
25228
25248
|
/**
|
|
25229
25249
|
* Save the server endpoint to local storage *and* the access token to secret storage, but wait
|
|
@@ -25240,7 +25260,11 @@ class LocalStorage {
|
|
|
25240
25260
|
}
|
|
25241
25261
|
const serverEndpoint = new URL(auth2.serverEndpoint).href;
|
|
25242
25262
|
await this.set(this.LAST_USED_ENDPOINT, serverEndpoint, false);
|
|
25243
|
-
|
|
25263
|
+
const history = this.getEndpointHistory();
|
|
25264
|
+
const historySet = new Set(history);
|
|
25265
|
+
historySet.delete(auth2.serverEndpoint);
|
|
25266
|
+
historySet.add(auth2.serverEndpoint);
|
|
25267
|
+
await this.set(this.CODY_ENDPOINT_HISTORY, [...historySet], false);
|
|
25244
25268
|
if (auth2.credentials && "token" in auth2.credentials) {
|
|
25245
25269
|
await secretStorage.storeToken(
|
|
25246
25270
|
serverEndpoint,
|
|
@@ -25250,41 +25274,34 @@ class LocalStorage {
|
|
|
25250
25274
|
}
|
|
25251
25275
|
this.onChange.fire();
|
|
25252
25276
|
}
|
|
25253
|
-
async
|
|
25254
|
-
|
|
25255
|
-
|
|
25277
|
+
async deleteEndpointAndToken(endpoint) {
|
|
25278
|
+
if (this.getEndpoint() === endpoint) {
|
|
25279
|
+
await this.delete(this.LAST_USED_ENDPOINT, false);
|
|
25280
|
+
}
|
|
25281
|
+
const history = this.getEndpointHistory();
|
|
25282
|
+
const historySet = new Set(history);
|
|
25283
|
+
historySet.delete(endpoint);
|
|
25284
|
+
await this.set(this.CODY_ENDPOINT_HISTORY, [...historySet], false);
|
|
25285
|
+
await secretStorage.deleteToken(endpoint);
|
|
25286
|
+
this.onChange.fire();
|
|
25256
25287
|
}
|
|
25257
25288
|
// Deletes and returns the endpoint history
|
|
25258
25289
|
async deleteEndpointHistory() {
|
|
25259
25290
|
const history = this.getEndpointHistory();
|
|
25291
|
+
const deleteTokens = (history == null ? void 0 : history.map((endpoint) => secretStorage.deleteToken(endpoint))) ?? [];
|
|
25260
25292
|
await Promise.all([
|
|
25261
|
-
this.
|
|
25262
|
-
this.
|
|
25293
|
+
this.delete(this.LAST_USED_ENDPOINT, false),
|
|
25294
|
+
this.delete(this.CODY_ENDPOINT_HISTORY, false),
|
|
25295
|
+
...deleteTokens
|
|
25263
25296
|
]);
|
|
25297
|
+
this.onChange.fire();
|
|
25264
25298
|
return history || [];
|
|
25265
25299
|
}
|
|
25266
|
-
// Deletes and returns the endpoint history
|
|
25267
|
-
async deleteEndpointFromHistory(endpoint) {
|
|
25268
|
-
const history = this.getEndpointHistory();
|
|
25269
|
-
const historySet = new Set(history);
|
|
25270
|
-
historySet.delete(endpoint);
|
|
25271
|
-
await this.set(this.CODY_ENDPOINT_HISTORY, [...historySet]);
|
|
25272
|
-
}
|
|
25273
25300
|
getEndpointHistory() {
|
|
25274
25301
|
return this.get(this.CODY_ENDPOINT_HISTORY);
|
|
25275
25302
|
}
|
|
25276
|
-
async addEndpointHistory(endpoint, fire = true) {
|
|
25277
|
-
if (isSourcegraphToken(endpoint)) {
|
|
25278
|
-
return;
|
|
25279
|
-
}
|
|
25280
|
-
const history = this.storage.get(this.CODY_ENDPOINT_HISTORY, null);
|
|
25281
|
-
const historySet = new Set(history);
|
|
25282
|
-
historySet.delete(endpoint);
|
|
25283
|
-
historySet.add(endpoint);
|
|
25284
|
-
await this.set(this.CODY_ENDPOINT_HISTORY, [...historySet], fire);
|
|
25285
|
-
}
|
|
25286
25303
|
getChatHistory(authStatus2) {
|
|
25287
|
-
const history = this.
|
|
25304
|
+
const history = this.get(this.KEY_LOCAL_HISTORY) || null;
|
|
25288
25305
|
const accountKey = getKeyForAuthStatus(authStatus2);
|
|
25289
25306
|
return (history == null ? void 0 : history[accountKey]) ?? { chat: {} };
|
|
25290
25307
|
}
|
|
@@ -25293,15 +25310,12 @@ class LocalStorage {
|
|
|
25293
25310
|
* Useful for export functionality when user can't authenticate
|
|
25294
25311
|
*/
|
|
25295
25312
|
getAllChatHistory() {
|
|
25296
|
-
return this.
|
|
25313
|
+
return this.get(this.KEY_LOCAL_HISTORY) || null;
|
|
25297
25314
|
}
|
|
25298
25315
|
async setChatHistory(authStatus2, history) {
|
|
25299
25316
|
try {
|
|
25300
25317
|
const key2 = getKeyForAuthStatus(authStatus2);
|
|
25301
|
-
let fullHistory = this.
|
|
25302
|
-
this.KEY_LOCAL_HISTORY,
|
|
25303
|
-
null
|
|
25304
|
-
);
|
|
25318
|
+
let fullHistory = this.get(this.KEY_LOCAL_HISTORY) || null;
|
|
25305
25319
|
if (fullHistory) {
|
|
25306
25320
|
fullHistory[key2] = history;
|
|
25307
25321
|
} else {
|
|
@@ -25316,10 +25330,7 @@ class LocalStorage {
|
|
|
25316
25330
|
}
|
|
25317
25331
|
async importChatHistory(history, shouldMerge) {
|
|
25318
25332
|
if (shouldMerge) {
|
|
25319
|
-
const fullHistory = this.
|
|
25320
|
-
this.KEY_LOCAL_HISTORY,
|
|
25321
|
-
null
|
|
25322
|
-
);
|
|
25333
|
+
const fullHistory = this.get(this.KEY_LOCAL_HISTORY) || null;
|
|
25323
25334
|
merge$1(history, fullHistory);
|
|
25324
25335
|
}
|
|
25325
25336
|
await this.storage.update(this.KEY_LOCAL_HISTORY, history);
|
|
@@ -25374,7 +25385,7 @@ class LocalStorage {
|
|
|
25374
25385
|
* so that the caller can log the first enrollment event.
|
|
25375
25386
|
*/
|
|
25376
25387
|
getEnrollmentHistory(featureName) {
|
|
25377
|
-
const history = this.
|
|
25388
|
+
const history = this.get(this.CODY_ENROLLMENT_HISTORY) || [];
|
|
25378
25389
|
const hasEnrolled = (history == null ? void 0 : history.includes(featureName)) || false;
|
|
25379
25390
|
if (!hasEnrolled) {
|
|
25380
25391
|
history.push(featureName);
|
|
@@ -25387,12 +25398,12 @@ class LocalStorage {
|
|
|
25387
25398
|
* occurs on a fresh installation). Callers can check
|
|
25388
25399
|
* {@link LocalStorage.checkIfCreatedAnonymousUserID} to see if a new anonymous ID was created.
|
|
25389
25400
|
*/
|
|
25390
|
-
anonymousUserID() {
|
|
25391
|
-
let id = this.
|
|
25401
|
+
async anonymousUserID() {
|
|
25402
|
+
let id = this.get(this.ANONYMOUS_USER_ID_KEY);
|
|
25392
25403
|
if (!id) {
|
|
25393
25404
|
this.createdAnonymousUserID = true;
|
|
25394
25405
|
id = v4();
|
|
25395
|
-
this.set(this.ANONYMOUS_USER_ID_KEY, id).catch((error) => console.error(error));
|
|
25406
|
+
await this.set(this.ANONYMOUS_USER_ID_KEY, id).catch((error) => console.error(error));
|
|
25396
25407
|
}
|
|
25397
25408
|
return id;
|
|
25398
25409
|
}
|
|
@@ -25409,8 +25420,8 @@ class LocalStorage {
|
|
|
25409
25420
|
getConfig() {
|
|
25410
25421
|
return this.get(this.KEY_CONFIG);
|
|
25411
25422
|
}
|
|
25412
|
-
setLastUsedChatModality(modality) {
|
|
25413
|
-
this.set(this.LAST_USED_CHAT_MODALITY, modality);
|
|
25423
|
+
async setLastUsedChatModality(modality) {
|
|
25424
|
+
await this.set(this.LAST_USED_CHAT_MODALITY, modality);
|
|
25414
25425
|
}
|
|
25415
25426
|
getLastUsedChatModality() {
|
|
25416
25427
|
return this.get(this.LAST_USED_CHAT_MODALITY) ?? "sidebar";
|
|
@@ -25428,10 +25439,22 @@ class LocalStorage {
|
|
|
25428
25439
|
await this.set(this.DEVICE_PIXEL_RATIO, ratio);
|
|
25429
25440
|
}
|
|
25430
25441
|
get(key2) {
|
|
25442
|
+
if (this._cache) {
|
|
25443
|
+
if (this._cache.has(key2)) {
|
|
25444
|
+
return this._cache.get(key2);
|
|
25445
|
+
}
|
|
25446
|
+
const value = this.storage.get(key2, null);
|
|
25447
|
+
if (value !== null) {
|
|
25448
|
+
this._cache.set(key2, value);
|
|
25449
|
+
}
|
|
25450
|
+
return value;
|
|
25451
|
+
}
|
|
25431
25452
|
return this.storage.get(key2, null);
|
|
25432
25453
|
}
|
|
25433
25454
|
async set(key2, value, fire = true) {
|
|
25455
|
+
var _a3;
|
|
25434
25456
|
try {
|
|
25457
|
+
(_a3 = this._cache) == null ? void 0 : _a3.set(key2, value);
|
|
25435
25458
|
await this.storage.update(key2, value);
|
|
25436
25459
|
if (fire) {
|
|
25437
25460
|
this.onChange.fire();
|
|
@@ -25440,21 +25463,30 @@ class LocalStorage {
|
|
|
25440
25463
|
console.error(error);
|
|
25441
25464
|
}
|
|
25442
25465
|
}
|
|
25443
|
-
async delete(key2) {
|
|
25466
|
+
async delete(key2, fire = true) {
|
|
25467
|
+
var _a3;
|
|
25468
|
+
(_a3 = this._cache) == null ? void 0 : _a3.delete(key2);
|
|
25444
25469
|
await this.storage.update(key2, void 0);
|
|
25445
|
-
|
|
25470
|
+
if (fire) {
|
|
25471
|
+
this.onChange.fire();
|
|
25472
|
+
}
|
|
25446
25473
|
}
|
|
25447
25474
|
async clearDeprecatedKeys() {
|
|
25448
25475
|
try {
|
|
25449
25476
|
const deprecatedKeys = Object.values(this.deprecatedKeys);
|
|
25450
25477
|
for (const key2 of deprecatedKeys) {
|
|
25451
|
-
const value = this.
|
|
25452
|
-
if (value) await this.
|
|
25478
|
+
const value = this.get(key2);
|
|
25479
|
+
if (value) await this.delete(key2, false);
|
|
25453
25480
|
}
|
|
25481
|
+
this.onChange.fire();
|
|
25454
25482
|
} catch (error) {
|
|
25455
25483
|
console.error("Error clearing deprecated keys:", error);
|
|
25456
25484
|
}
|
|
25457
25485
|
}
|
|
25486
|
+
resetCache() {
|
|
25487
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
25488
|
+
this.onChange.fire();
|
|
25489
|
+
}
|
|
25458
25490
|
}
|
|
25459
25491
|
const localStorage = new LocalStorage();
|
|
25460
25492
|
function getKeyForAuthStatus(authStatus2) {
|
|
@@ -25656,11 +25688,23 @@ class OutputChannelManager {
|
|
|
25656
25688
|
return this.outputChannels.get(feature2);
|
|
25657
25689
|
}
|
|
25658
25690
|
appendLine(level2, text2, feature2) {
|
|
25659
|
-
var _a3, _b2;
|
|
25660
|
-
level2 === "error"
|
|
25691
|
+
var _a3, _b2, _c2;
|
|
25692
|
+
if (level2 === "error") {
|
|
25693
|
+
(_a3 = this.defaultOutputChannel) == null ? void 0 : _a3.error(text2);
|
|
25694
|
+
} else if (level2 === "info") {
|
|
25695
|
+
(_b2 = this.defaultOutputChannel) == null ? void 0 : _b2.info(text2);
|
|
25696
|
+
} else {
|
|
25697
|
+
(_c2 = this.defaultOutputChannel) == null ? void 0 : _c2.debug(text2);
|
|
25698
|
+
}
|
|
25661
25699
|
if (feature2) {
|
|
25662
25700
|
const channel2 = this.getOutputChannel(feature2);
|
|
25663
|
-
level2 === "error"
|
|
25701
|
+
if (level2 === "error") {
|
|
25702
|
+
channel2 == null ? void 0 : channel2.error(text2);
|
|
25703
|
+
} else if (level2 === "info") {
|
|
25704
|
+
channel2 == null ? void 0 : channel2.info(text2);
|
|
25705
|
+
} else {
|
|
25706
|
+
channel2 == null ? void 0 : channel2.debug(text2);
|
|
25707
|
+
}
|
|
25664
25708
|
}
|
|
25665
25709
|
const path2 = define_process_default$h.env.CODY_LOG_FILE;
|
|
25666
25710
|
if (path2) {
|
|
@@ -25685,6 +25729,15 @@ class Logger {
|
|
|
25685
25729
|
args: args2
|
|
25686
25730
|
});
|
|
25687
25731
|
}
|
|
25732
|
+
logInfo(filterLabel, text2, ...args2) {
|
|
25733
|
+
this.log({
|
|
25734
|
+
level: "info",
|
|
25735
|
+
feature: this.feature,
|
|
25736
|
+
filterLabel,
|
|
25737
|
+
text: text2,
|
|
25738
|
+
args: args2
|
|
25739
|
+
});
|
|
25740
|
+
}
|
|
25688
25741
|
logError(filterLabel, text2, ...args2) {
|
|
25689
25742
|
this.log({
|
|
25690
25743
|
level: "error",
|
|
@@ -25721,6 +25774,9 @@ const outputChannelLogger = new Logger();
|
|
|
25721
25774
|
function logDebug(filterLabel, text2, ...args2) {
|
|
25722
25775
|
outputChannelLogger.logDebug(filterLabel, text2, ...args2);
|
|
25723
25776
|
}
|
|
25777
|
+
function logInfo(filterLabel, text2, ...args2) {
|
|
25778
|
+
outputChannelLogger.logInfo(filterLabel, text2, ...args2);
|
|
25779
|
+
}
|
|
25724
25780
|
function logError$1(filterLabel, text2, ...args2) {
|
|
25725
25781
|
outputChannelLogger.logError(filterLabel, text2, ...args2);
|
|
25726
25782
|
}
|
|
@@ -25783,52 +25839,23 @@ const version = ((_i = (_h = extensions.getExtension("sourcegraph.cody-ai")) ==
|
|
|
25783
25839
|
setExtensionVersion(version);
|
|
25784
25840
|
const HAS_AUTHENTICATED_BEFORE_KEY = "has-authenticated-before";
|
|
25785
25841
|
class AuthProvider {
|
|
25786
|
-
constructor(setAuthStatusObservable$1 = setAuthStatusObservable
|
|
25842
|
+
constructor(setAuthStatusObservable$1 = setAuthStatusObservable) {
|
|
25787
25843
|
__publicField2(this, "status", new MulticastSubject());
|
|
25788
|
-
__publicField2(this, "refreshRequests", new MulticastSubject());
|
|
25789
25844
|
/**
|
|
25790
25845
|
* Credentials that were already validated with
|
|
25791
25846
|
* {@link AuthProvider.validateAndStoreCredentials}.
|
|
25792
25847
|
*/
|
|
25793
|
-
__publicField2(this, "
|
|
25794
|
-
__publicField2(this, "lastEndpoint");
|
|
25795
|
-
__publicField2(this, "hasAuthed", false);
|
|
25848
|
+
__publicField2(this, "lastValidated", { credentials: null, auth: null });
|
|
25796
25849
|
__publicField2(this, "subscriptions", []);
|
|
25797
|
-
setAuthStatusObservable$1(
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
|
|
25801
|
-
|
|
25802
|
-
|
|
25803
|
-
|
|
25804
|
-
distinctUntilChanged$1()
|
|
25805
|
-
);
|
|
25806
|
-
this.subscriptions.push(
|
|
25807
|
-
ClientConfigSingleton.getInstance().updates.pipe(
|
|
25808
|
-
abortableOperation(async (config, signal2) => {
|
|
25809
|
-
const nextAuthStatus = await validateCredentials(
|
|
25810
|
-
await currentResolvedConfig(),
|
|
25811
|
-
signal2,
|
|
25812
|
-
config
|
|
25813
|
-
);
|
|
25814
|
-
if (!nextAuthStatus.authenticated && isEnterpriseUserDotComError(nextAuthStatus.error)) {
|
|
25815
|
-
this.status.next(nextAuthStatus);
|
|
25816
|
-
}
|
|
25817
|
-
})
|
|
25818
|
-
).subscribe({})
|
|
25819
|
-
);
|
|
25820
|
-
this.subscriptions.push(
|
|
25821
|
-
combineLatest$1(
|
|
25822
|
-
credentialsChangesNeedingValidation,
|
|
25823
|
-
this.refreshRequests.pipe(startWith$1(true))
|
|
25824
|
-
).pipe(
|
|
25825
|
-
abortableOperation(async ([config, resetInitialAuthStatus], signal2) => {
|
|
25826
|
-
if (clientCapabilities().isCodyWeb) {
|
|
25827
|
-
return;
|
|
25828
|
-
}
|
|
25829
|
-
await this.validateAndUpdateAuthStatus(config, signal2, resetInitialAuthStatus);
|
|
25850
|
+
setAuthStatusObservable$1(
|
|
25851
|
+
this.status.pipe(
|
|
25852
|
+
distinctUntilChanged$1(),
|
|
25853
|
+
startWith$1({
|
|
25854
|
+
authenticated: false,
|
|
25855
|
+
endpoint: DOTCOM_URL.toString(),
|
|
25856
|
+
pendingValidation: false
|
|
25830
25857
|
})
|
|
25831
|
-
)
|
|
25858
|
+
)
|
|
25832
25859
|
);
|
|
25833
25860
|
this.subscriptions.push(
|
|
25834
25861
|
authStatus.pipe(
|
|
@@ -25840,13 +25867,12 @@ class AuthProvider {
|
|
|
25840
25867
|
return EMPTY$1;
|
|
25841
25868
|
})
|
|
25842
25869
|
).subscribe(() => {
|
|
25843
|
-
this.
|
|
25870
|
+
this.refresh();
|
|
25844
25871
|
})
|
|
25845
25872
|
);
|
|
25846
25873
|
this.subscriptions.push(
|
|
25847
25874
|
authStatus.subscribe((authStatus2) => {
|
|
25848
25875
|
try {
|
|
25849
|
-
this.lastEndpoint = authStatus2.endpoint;
|
|
25850
25876
|
if (isRunningInsideAgent()) {
|
|
25851
25877
|
commands$1.executeCommand("authStatus.update", authStatus2);
|
|
25852
25878
|
}
|
|
@@ -25865,111 +25891,129 @@ class AuthProvider {
|
|
|
25865
25891
|
}
|
|
25866
25892
|
})
|
|
25867
25893
|
);
|
|
25868
|
-
this.subscriptions.push(
|
|
25894
|
+
this.subscriptions.push(
|
|
25895
|
+
authStatus.subscribe((authStatus2) => {
|
|
25896
|
+
try {
|
|
25897
|
+
this.reportAuthTelemetryEvent(authStatus2);
|
|
25898
|
+
} catch (error) {
|
|
25899
|
+
logError$1("AuthProvider", "Unexpected error while reporting auth telemetry", error);
|
|
25900
|
+
}
|
|
25901
|
+
})
|
|
25902
|
+
);
|
|
25869
25903
|
this.subscriptions.push(
|
|
25870
25904
|
disposableSubscription(
|
|
25871
25905
|
commands$1.registerCommand("cody.auth.refresh", () => this.refresh())
|
|
25872
25906
|
)
|
|
25873
25907
|
);
|
|
25874
|
-
|
|
25875
|
-
|
|
25876
|
-
|
|
25877
|
-
|
|
25878
|
-
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
|
|
25886
|
-
|
|
25887
|
-
await this.handleAuthTelemetry(authStatus2, signal2);
|
|
25888
|
-
} catch (error) {
|
|
25889
|
-
if (!isAbortError(error)) {
|
|
25890
|
-
logError$1("AuthProvider", "Unexpected error validating credentials", error);
|
|
25891
|
-
}
|
|
25892
|
-
}
|
|
25893
|
-
}
|
|
25894
|
-
async handleAuthTelemetry(authStatus2, signal2) {
|
|
25895
|
-
const hasAuthed = this.hasAuthed;
|
|
25896
|
-
this.hasAuthed = true;
|
|
25897
|
-
if (!hasAuthed && authStatus2.authenticated) {
|
|
25898
|
-
await this.setHasAuthenticatedBefore();
|
|
25899
|
-
signal2 == null ? void 0 : signal2.throwIfAborted();
|
|
25900
|
-
} else if (authStatus2.authenticated) {
|
|
25901
|
-
this.handleFirstEverAuthentication();
|
|
25902
|
-
}
|
|
25903
|
-
}
|
|
25904
|
-
dispose() {
|
|
25905
|
-
for (const subscription of this.subscriptions) {
|
|
25906
|
-
subscription.unsubscribe();
|
|
25907
|
-
}
|
|
25908
|
-
}
|
|
25909
|
-
/**
|
|
25910
|
-
* Refresh the auth status.
|
|
25911
|
-
*/
|
|
25912
|
-
refresh(resetInitialAuthStatus = true) {
|
|
25913
|
-
this.lastValidatedAndStoredCredentials.next(null);
|
|
25914
|
-
this.refreshRequests.next(resetInitialAuthStatus);
|
|
25915
|
-
}
|
|
25916
|
-
signout(endpoint) {
|
|
25917
|
-
if (this.lastEndpoint !== endpoint) {
|
|
25918
|
-
return;
|
|
25919
|
-
}
|
|
25920
|
-
this.lastValidatedAndStoredCredentials.next(null);
|
|
25921
|
-
this.status.next({
|
|
25922
|
-
authenticated: false,
|
|
25923
|
-
endpoint: DOTCOM_URL.toString(),
|
|
25924
|
-
pendingValidation: false
|
|
25925
|
-
});
|
|
25908
|
+
this.subscriptions.push(
|
|
25909
|
+
resolvedConfig.pipe(
|
|
25910
|
+
map$1((config) => this.toCredentialsOnlyNormalized(config)),
|
|
25911
|
+
distinctUntilChanged$1(isEqual)
|
|
25912
|
+
).subscribe((authConfig) => {
|
|
25913
|
+
this.validateAndStoreCredentials(authConfig, "store-if-valid");
|
|
25914
|
+
})
|
|
25915
|
+
);
|
|
25916
|
+
this.subscriptions.push(
|
|
25917
|
+
externalAuthRefresh.subscribe(() => {
|
|
25918
|
+
this.refresh();
|
|
25919
|
+
})
|
|
25920
|
+
);
|
|
25926
25921
|
}
|
|
25927
25922
|
async validateAndStoreCredentials(config, mode) {
|
|
25923
|
+
var _a3;
|
|
25928
25924
|
let credentials;
|
|
25929
25925
|
if ("auth" in config) {
|
|
25930
|
-
credentials = toCredentialsOnlyNormalized(config);
|
|
25926
|
+
credentials = this.toCredentialsOnlyNormalized(config);
|
|
25931
25927
|
} else {
|
|
25932
25928
|
const prevConfig = await currentResolvedConfig();
|
|
25933
|
-
credentials = toCredentialsOnlyNormalized({
|
|
25929
|
+
credentials = this.toCredentialsOnlyNormalized({
|
|
25934
25930
|
configuration: prevConfig.configuration,
|
|
25935
25931
|
auth: config,
|
|
25936
25932
|
clientState: prevConfig.clientState
|
|
25937
25933
|
});
|
|
25938
25934
|
}
|
|
25939
|
-
|
|
25935
|
+
if (isEqual(credentials, this.lastValidated.credentials) && ((_a3 = this.lastValidated.auth) == null ? void 0 : _a3.authenticated)) {
|
|
25936
|
+
return this.lastValidated.auth;
|
|
25937
|
+
}
|
|
25938
|
+
this.setAuthPendingToEndpoint(credentials.auth.serverEndpoint);
|
|
25939
|
+
const authStatus2 = await validateCredentials(credentials);
|
|
25940
25940
|
const shouldStore = mode === "always-store" || authStatus2.authenticated;
|
|
25941
25941
|
if (shouldStore) {
|
|
25942
25942
|
await Promise.all([
|
|
25943
25943
|
localStorage.saveEndpointAndToken(credentials.auth),
|
|
25944
25944
|
this.serializeUninstallerInfo(authStatus2)
|
|
25945
25945
|
]);
|
|
25946
|
-
|
|
25947
|
-
|
|
25948
|
-
|
|
25949
|
-
|
|
25950
|
-
|
|
25946
|
+
} else if (!authStatus2.authenticated && !authStatus2.pendingValidation) {
|
|
25947
|
+
const status = authStatus2;
|
|
25948
|
+
if (status.endpoint && isInvalidAccessTokenError(status.error)) {
|
|
25949
|
+
await localStorage.deleteEndpointAndToken(status.endpoint);
|
|
25950
|
+
}
|
|
25951
25951
|
}
|
|
25952
|
-
|
|
25952
|
+
this.lastValidated = { credentials, auth: authStatus2 };
|
|
25953
|
+
this.status.next(authStatus2);
|
|
25953
25954
|
return authStatus2;
|
|
25954
25955
|
}
|
|
25955
|
-
|
|
25956
|
-
|
|
25957
|
-
}
|
|
25958
|
-
// Logs a telemetry event if the user has never authenticated to Sourcegraph.
|
|
25959
|
-
handleFirstEverAuthentication() {
|
|
25960
|
-
if (localStorage.get(HAS_AUTHENTICATED_BEFORE_KEY)) {
|
|
25956
|
+
reportAuthTelemetryEvent(authStatus2) {
|
|
25957
|
+
if (authStatus2.pendingValidation) {
|
|
25961
25958
|
return;
|
|
25962
25959
|
}
|
|
25963
|
-
|
|
25964
|
-
|
|
25965
|
-
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
}
|
|
25969
|
-
|
|
25960
|
+
let eventValue;
|
|
25961
|
+
if (!authStatus2.authenticated && (isAvailabilityError(authStatus2.error) || isInvalidAccessTokenError(authStatus2.error))) {
|
|
25962
|
+
eventValue = "failed";
|
|
25963
|
+
} else if (authStatus2.authenticated) {
|
|
25964
|
+
eventValue = "connected";
|
|
25965
|
+
} else {
|
|
25966
|
+
eventValue = "disconnected";
|
|
25967
|
+
}
|
|
25968
|
+
telemetryRecorder.recordEvent("cody.auth", eventValue);
|
|
25969
|
+
const hasAuthedBefore = localStorage.get(HAS_AUTHENTICATED_BEFORE_KEY) || false;
|
|
25970
|
+
if (!hasAuthedBefore && authStatus2.authenticated) {
|
|
25971
|
+
telemetryRecorder.recordEvent("cody.auth.login", "firstEver", {
|
|
25972
|
+
billingMetadata: {
|
|
25973
|
+
product: "cody",
|
|
25974
|
+
category: "billable"
|
|
25975
|
+
}
|
|
25976
|
+
});
|
|
25977
|
+
localStorage.set(HAS_AUTHENTICATED_BEFORE_KEY, "true");
|
|
25978
|
+
}
|
|
25979
|
+
}
|
|
25980
|
+
toCredentialsOnlyNormalized(config) {
|
|
25981
|
+
return {
|
|
25982
|
+
configuration: {
|
|
25983
|
+
customHeaders: config.configuration.customHeaders
|
|
25984
|
+
},
|
|
25985
|
+
auth: {
|
|
25986
|
+
...config.auth,
|
|
25987
|
+
serverEndpoint: config.auth.serverEndpoint ? normalizeServerEndpointURL(config.auth.serverEndpoint) : void 0
|
|
25988
|
+
},
|
|
25989
|
+
clientState: { anonymousUserID: config.clientState.anonymousUserID }
|
|
25990
|
+
};
|
|
25991
|
+
}
|
|
25992
|
+
async getCurrentConfig() {
|
|
25993
|
+
return await currentResolvedConfig();
|
|
25970
25994
|
}
|
|
25971
|
-
|
|
25972
|
-
|
|
25995
|
+
dispose() {
|
|
25996
|
+
for (const subscription of this.subscriptions) {
|
|
25997
|
+
subscription.unsubscribe();
|
|
25998
|
+
}
|
|
25999
|
+
}
|
|
26000
|
+
async refresh() {
|
|
26001
|
+
this.lastValidated = { credentials: null, auth: null };
|
|
26002
|
+
const config = await this.getCurrentConfig();
|
|
26003
|
+
await this.validateAndStoreCredentials(config, "store-if-valid");
|
|
26004
|
+
}
|
|
26005
|
+
signout(endpoint) {
|
|
26006
|
+
if (localStorage.getEndpoint() === endpoint) {
|
|
26007
|
+
this.lastValidated = { credentials: null, auth: null };
|
|
26008
|
+
this.status.next({
|
|
26009
|
+
authenticated: false,
|
|
26010
|
+
endpoint,
|
|
26011
|
+
pendingValidation: false
|
|
26012
|
+
});
|
|
26013
|
+
}
|
|
26014
|
+
}
|
|
26015
|
+
setAuthPendingToEndpoint(endpoint) {
|
|
26016
|
+
this.status.next({ authenticated: false, endpoint, pendingValidation: true });
|
|
25973
26017
|
}
|
|
25974
26018
|
// When the auth status is updated, we serialize the current configuration to disk,
|
|
25975
26019
|
// so that it can be sent with Telemetry when the post-uninstall script runs.
|
|
@@ -25996,52 +26040,7 @@ class AuthProvider {
|
|
|
25996
26040
|
}
|
|
25997
26041
|
}
|
|
25998
26042
|
const authProvider = new AuthProvider();
|
|
25999
|
-
function startAuthTelemetryReporter() {
|
|
26000
|
-
return authStatus.subscribe((authStatus2) => {
|
|
26001
|
-
reportAuthTelemetryEvent(authStatus2);
|
|
26002
|
-
});
|
|
26003
|
-
}
|
|
26004
|
-
function reportAuthTelemetryEvent(authStatus2) {
|
|
26005
|
-
if (authStatus2.pendingValidation) {
|
|
26006
|
-
return;
|
|
26007
|
-
}
|
|
26008
|
-
let eventValue;
|
|
26009
|
-
if (!authStatus2.authenticated && (isAvailabilityError(authStatus2.error) || isInvalidAccessTokenError(authStatus2.error))) {
|
|
26010
|
-
eventValue = "failed";
|
|
26011
|
-
} else if (authStatus2.authenticated) {
|
|
26012
|
-
eventValue = "connected";
|
|
26013
|
-
} else {
|
|
26014
|
-
eventValue = "disconnected";
|
|
26015
|
-
}
|
|
26016
|
-
telemetryRecorder.recordEvent("cody.auth", eventValue);
|
|
26017
|
-
}
|
|
26018
|
-
function toCredentialsOnlyNormalized(config) {
|
|
26019
|
-
return {
|
|
26020
|
-
configuration: {
|
|
26021
|
-
customHeaders: config.configuration.customHeaders
|
|
26022
|
-
},
|
|
26023
|
-
auth: { ...config.auth, serverEndpoint: normalizeServerEndpointURL(config.auth.serverEndpoint) },
|
|
26024
|
-
clientState: { anonymousUserID: config.clientState.anonymousUserID }
|
|
26025
|
-
};
|
|
26026
|
-
}
|
|
26027
26043
|
let runningAuthProgressIndicator = null;
|
|
26028
|
-
function startAuthProgressIndicator() {
|
|
26029
|
-
window$1.withProgress(
|
|
26030
|
-
{
|
|
26031
|
-
location: ProgressLocation.Notification,
|
|
26032
|
-
title: "Signing in to Sourcegraph...",
|
|
26033
|
-
cancellable: true
|
|
26034
|
-
},
|
|
26035
|
-
(progress, token) => {
|
|
26036
|
-
token.onCancellationRequested(() => {
|
|
26037
|
-
runningAuthProgressIndicator = null;
|
|
26038
|
-
});
|
|
26039
|
-
return new Promise((resolve) => {
|
|
26040
|
-
runningAuthProgressIndicator = resolve;
|
|
26041
|
-
});
|
|
26042
|
-
}
|
|
26043
|
-
);
|
|
26044
|
-
}
|
|
26045
26044
|
function closeAuthProgressIndicator() {
|
|
26046
26045
|
runningAuthProgressIndicator == null ? void 0 : runningAuthProgressIndicator();
|
|
26047
26046
|
runningAuthProgressIndicator = null;
|
|
@@ -26061,7 +26060,7 @@ async function showEnterpriseInstanceUrlFlow(endpoint) {
|
|
|
26061
26060
|
await showAuthResultMessage(endpoint, authStatus2);
|
|
26062
26061
|
}
|
|
26063
26062
|
}
|
|
26064
|
-
async function showSignInMenu(
|
|
26063
|
+
async function showSignInMenu() {
|
|
26065
26064
|
const authStatus2 = currentAuthStatus();
|
|
26066
26065
|
const mode = authStatus2.authenticated ? "switch" : "signin";
|
|
26067
26066
|
logDebug("AuthProvider:signinMenu", mode);
|
|
@@ -26088,9 +26087,6 @@ async function showSignInMenu(type, uri) {
|
|
|
26088
26087
|
redirectToEndpointLogin(instanceUrl);
|
|
26089
26088
|
break;
|
|
26090
26089
|
}
|
|
26091
|
-
case "dotcom":
|
|
26092
|
-
redirectToEndpointLogin(DOTCOM_URL.href);
|
|
26093
|
-
break;
|
|
26094
26090
|
case "token": {
|
|
26095
26091
|
const instanceUrl = await showInstanceURLInputBox(item.uri);
|
|
26096
26092
|
if (!instanceUrl) {
|
|
@@ -26103,18 +26099,18 @@ async function showSignInMenu(type, uri) {
|
|
|
26103
26099
|
const selectedEndpoint = item.uri;
|
|
26104
26100
|
const { configuration } = await currentResolvedConfig();
|
|
26105
26101
|
const auth2 = await resolveAuth(selectedEndpoint, configuration, secretStorage);
|
|
26106
|
-
let
|
|
26107
|
-
if (!(
|
|
26102
|
+
let authStatus3 = await authProvider.validateAndStoreCredentials(auth2, "store-if-valid");
|
|
26103
|
+
if (!(authStatus3 == null ? void 0 : authStatus3.authenticated) && isInvalidAccessTokenError(authStatus3.error)) {
|
|
26108
26104
|
const token = await showAccessTokenInputBox(selectedEndpoint);
|
|
26109
26105
|
if (!token) {
|
|
26110
26106
|
return;
|
|
26111
26107
|
}
|
|
26112
|
-
|
|
26108
|
+
authStatus3 = await authProvider.validateAndStoreCredentials(
|
|
26113
26109
|
{ serverEndpoint: selectedEndpoint, credentials: { token, source: "paste" } },
|
|
26114
26110
|
"store-if-valid"
|
|
26115
26111
|
);
|
|
26116
26112
|
}
|
|
26117
|
-
await showAuthResultMessage(selectedEndpoint,
|
|
26113
|
+
await showAuthResultMessage(selectedEndpoint, authStatus3);
|
|
26118
26114
|
logDebug("AuthProvider:signinMenu", mode, selectedEndpoint);
|
|
26119
26115
|
}
|
|
26120
26116
|
}
|
|
@@ -26340,10 +26336,11 @@ async function signOut(endpoint) {
|
|
|
26340
26336
|
}
|
|
26341
26337
|
);
|
|
26342
26338
|
authProvider.signout(endpoint);
|
|
26343
|
-
await
|
|
26339
|
+
await firstResultFromOperation(authStatus.filter((status) => status.authenticated === false));
|
|
26340
|
+
await localStorage.deleteEndpointAndToken(endpoint);
|
|
26344
26341
|
}
|
|
26345
|
-
async function validateCredentials(config
|
|
26346
|
-
var _a3
|
|
26342
|
+
async function validateCredentials(config) {
|
|
26343
|
+
var _a3;
|
|
26347
26344
|
if (config.auth.error !== void 0) {
|
|
26348
26345
|
logDebug(
|
|
26349
26346
|
"auth",
|
|
@@ -26357,6 +26354,13 @@ async function validateCredentials(config, signal2, clientConfig) {
|
|
|
26357
26354
|
error: new AuthConfigError(((_a3 = config.auth.error) == null ? void 0 : _a3.message) ?? config.auth.error)
|
|
26358
26355
|
};
|
|
26359
26356
|
}
|
|
26357
|
+
if (!config.auth.serverEndpoint || isDotCom(config.auth.serverEndpoint) || isWorkspaceInstance(config.auth.serverEndpoint)) {
|
|
26358
|
+
return {
|
|
26359
|
+
authenticated: false,
|
|
26360
|
+
endpoint: config.auth.serverEndpoint,
|
|
26361
|
+
pendingValidation: false
|
|
26362
|
+
};
|
|
26363
|
+
}
|
|
26360
26364
|
if (!config.auth.credentials && !clientCapabilities().isCodyWeb) {
|
|
26361
26365
|
return { authenticated: false, endpoint: config.auth.serverEndpoint, pendingValidation: false };
|
|
26362
26366
|
}
|
|
@@ -26371,8 +26375,7 @@ async function validateCredentials(config, signal2, clientConfig) {
|
|
|
26371
26375
|
};
|
|
26372
26376
|
const client = SourcegraphGraphQLAPIClient.withStaticConfig(apiClientConfig);
|
|
26373
26377
|
try {
|
|
26374
|
-
const userInfo = await client.getCurrentUserInfo(
|
|
26375
|
-
signal2 == null ? void 0 : signal2.throwIfAborted();
|
|
26378
|
+
const userInfo = await client.getCurrentUserInfo();
|
|
26376
26379
|
if (isError$3(userInfo)) {
|
|
26377
26380
|
if (isExternalProviderAuthError(userInfo)) {
|
|
26378
26381
|
logDebug("auth", userInfo.message);
|
|
@@ -26411,24 +26414,6 @@ async function validateCredentials(config, signal2, clientConfig) {
|
|
|
26411
26414
|
pendingValidation: false
|
|
26412
26415
|
};
|
|
26413
26416
|
}
|
|
26414
|
-
if (isDotCom(config.auth.serverEndpoint)) {
|
|
26415
|
-
if (!clientConfig) {
|
|
26416
|
-
clientConfig = await ClientConfigSingleton.getInstance().fetchConfigWithToken(
|
|
26417
|
-
apiClientConfig,
|
|
26418
|
-
signal2
|
|
26419
|
-
);
|
|
26420
|
-
}
|
|
26421
|
-
if (clientConfig == null ? void 0 : clientConfig.userShouldUseEnterprise) {
|
|
26422
|
-
return {
|
|
26423
|
-
authenticated: false,
|
|
26424
|
-
endpoint: config.auth.serverEndpoint,
|
|
26425
|
-
pendingValidation: false,
|
|
26426
|
-
error: new EnterpriseUserDotComError(
|
|
26427
|
-
getEnterpriseName(((_b2 = userInfo.primaryEmail) == null ? void 0 : _b2.email) || "")
|
|
26428
|
-
)
|
|
26429
|
-
};
|
|
26430
|
-
}
|
|
26431
|
-
}
|
|
26432
26417
|
logDebug("auth", `Authentication succeed to endpoint ${config.auth.serverEndpoint}`);
|
|
26433
26418
|
return newAuthStatus({
|
|
26434
26419
|
...userInfo,
|
|
@@ -26440,34 +26425,30 @@ async function validateCredentials(config, signal2, clientConfig) {
|
|
|
26440
26425
|
client.dispose();
|
|
26441
26426
|
}
|
|
26442
26427
|
}
|
|
26443
|
-
function getEnterpriseName(email) {
|
|
26444
|
-
const domain = email.split("@")[1];
|
|
26445
|
-
const name2 = domain.split(".")[0];
|
|
26446
|
-
return name2.charAt(0).toUpperCase() + name2.slice(1);
|
|
26447
|
-
}
|
|
26448
26428
|
async function requestEndpointSettingsDeliveryToSearchPlugin() {
|
|
26449
26429
|
const searchExtension = extensions.all.find(
|
|
26450
26430
|
({ packageJSON }) => ["sourcegraph.@sourcegraph/vscode", "sourcegraph.sourcegraph"].includes(packageJSON.id)
|
|
26451
26431
|
);
|
|
26452
26432
|
const config = await firstResultFromOperation(resolvedConfig);
|
|
26433
|
+
const endpoint = config.auth.serverEndpoint;
|
|
26434
|
+
if (!endpoint) {
|
|
26435
|
+
return "";
|
|
26436
|
+
}
|
|
26453
26437
|
searchExtension == null ? void 0 : searchExtension.activate().then(async () => {
|
|
26454
26438
|
var _a3;
|
|
26455
26439
|
const commandId = "sourcegraph.setEndpointSettings";
|
|
26456
26440
|
const commands2 = (_a3 = searchExtension.packageJSON.contributes) == null ? void 0 : _a3.commands;
|
|
26457
26441
|
if (Array.isArray(commands2)) {
|
|
26458
26442
|
if (commands2.find(({ command }) => command === commandId)) {
|
|
26459
|
-
const authHeaders = await getAuthHeaders(
|
|
26460
|
-
config.auth,
|
|
26461
|
-
new URL(config.auth.serverEndpoint)
|
|
26462
|
-
);
|
|
26443
|
+
const authHeaders = await getAuthHeaders(config.auth, new URL(endpoint));
|
|
26463
26444
|
commands$1.executeCommand(commandId, {
|
|
26464
|
-
instanceUrl:
|
|
26445
|
+
instanceUrl: endpoint,
|
|
26465
26446
|
headers: authHeaders
|
|
26466
26447
|
});
|
|
26467
26448
|
}
|
|
26468
26449
|
}
|
|
26469
26450
|
});
|
|
26470
|
-
return
|
|
26451
|
+
return endpoint;
|
|
26471
26452
|
}
|
|
26472
26453
|
class ChatHistoryManager {
|
|
26473
26454
|
constructor() {
|
|
@@ -26724,7 +26705,7 @@ async function readIgnoreFile(uri) {
|
|
|
26724
26705
|
if (line.endsWith("/")) {
|
|
26725
26706
|
line = line.slice(0, -1);
|
|
26726
26707
|
}
|
|
26727
|
-
if (!line.includes("*") && !line.includes("/")) {
|
|
26708
|
+
if (!line.includes("*") && !line.includes("/") && !line.includes(".")) {
|
|
26728
26709
|
ignore[`${line}/**`] = true;
|
|
26729
26710
|
} else {
|
|
26730
26711
|
ignore[line] = true;
|
|
@@ -34584,12 +34565,6 @@ class SentryService {
|
|
|
34584
34565
|
debug: !isProd,
|
|
34585
34566
|
// Only send errors when connected to dotcom in the production build.
|
|
34586
34567
|
beforeSend: (event2, hint) => {
|
|
34587
|
-
if (isProd && isDotCom(auth2.serverEndpoint) && shouldErrorBeReported(
|
|
34588
|
-
hint.originalException,
|
|
34589
|
-
!!configuration.isRunningInsideAgent
|
|
34590
|
-
)) {
|
|
34591
|
-
return event2;
|
|
34592
|
-
}
|
|
34593
34568
|
return null;
|
|
34594
34569
|
}
|
|
34595
34570
|
};
|
|
@@ -39528,7 +39503,7 @@ const MODEL_PROVIDER_ICONS = {
|
|
|
39528
39503
|
google: "$(gemini-logo)"
|
|
39529
39504
|
};
|
|
39530
39505
|
const getModelProviderIcon = (provider) => MODEL_PROVIDER_ICONS[provider.toLowerCase()] || "$(cody-logo)";
|
|
39531
|
-
const getModelOptionItems = (modelOptions
|
|
39506
|
+
const getModelOptionItems = (modelOptions) => {
|
|
39532
39507
|
const allOptions = modelOptions.map((modelOption) => {
|
|
39533
39508
|
const icon = getModelProviderIcon(modelOption.provider);
|
|
39534
39509
|
const title = modelOption.title || modelOption.id;
|
|
@@ -39537,17 +39512,13 @@ const getModelOptionItems = (modelOptions, isCodyPro, isEnterpriseUser2) => {
|
|
|
39537
39512
|
description: `by ${modelOption.provider}`,
|
|
39538
39513
|
alwaysShow: true,
|
|
39539
39514
|
model: modelOption.id,
|
|
39540
|
-
modelTitle: title
|
|
39541
|
-
codyProOnly: isCodyProModel(modelOption) && !isEnterpriseUser2
|
|
39515
|
+
modelTitle: title
|
|
39542
39516
|
};
|
|
39543
39517
|
}).filter(isDefined);
|
|
39544
|
-
if (!isCodyPro && !isEnterpriseUser2) {
|
|
39545
|
-
return allOptions.filter((option2) => !option2.codyProOnly);
|
|
39546
|
-
}
|
|
39547
39518
|
return allOptions;
|
|
39548
39519
|
};
|
|
39549
|
-
const getModelInputItems = (modelOptions, activeModel
|
|
39550
|
-
const modelItems = getModelOptionItems(modelOptions
|
|
39520
|
+
const getModelInputItems = (modelOptions, activeModel) => {
|
|
39521
|
+
const modelItems = getModelOptionItems(modelOptions);
|
|
39551
39522
|
const activeItem = modelItems.find((item) => item.model === activeModel);
|
|
39552
39523
|
if (activeItem) {
|
|
39553
39524
|
activeItem.label = activeItem.label.replace(
|
|
@@ -40668,21 +40639,10 @@ const _ChatBuilder = class _ChatBuilder {
|
|
|
40668
40639
|
*/
|
|
40669
40640
|
static resolvedModelForChat(chat2) {
|
|
40670
40641
|
return (chat2 instanceof Observable ? chat2 : chat2.changes).pipe(
|
|
40671
|
-
map$1((chat22) => chat22.selectedModel),
|
|
40672
|
-
distinctUntilChanged$1(),
|
|
40673
40642
|
switchMap$1(
|
|
40674
|
-
(
|
|
40675
|
-
|
|
40676
|
-
|
|
40677
|
-
return Observable.of(selectedModel);
|
|
40678
|
-
}
|
|
40679
|
-
if (chat2 instanceof _ChatBuilder) {
|
|
40680
|
-
chat2.setSelectedModel(void 0);
|
|
40681
|
-
}
|
|
40682
|
-
return modelsService.getDefaultChatModel();
|
|
40683
|
-
})
|
|
40684
|
-
) : modelsService.getDefaultChatModel()
|
|
40685
|
-
)
|
|
40643
|
+
(chat22) => chat22.selectedModel ? Observable.of(chat22.selectedModel) : modelsService.getDefaultChatModel()
|
|
40644
|
+
),
|
|
40645
|
+
distinctUntilChanged$1()
|
|
40686
40646
|
);
|
|
40687
40647
|
}
|
|
40688
40648
|
/**
|
|
@@ -41284,9 +41244,7 @@ class EditInputFlow {
|
|
|
41284
41244
|
__publicField2(this, "selectedContextItems", /* @__PURE__ */ new Map());
|
|
41285
41245
|
__publicField2(this, "contextItems", /* @__PURE__ */ new Map());
|
|
41286
41246
|
__publicField2(this, "textDocumentListener");
|
|
41287
|
-
__publicField2(this, "
|
|
41288
|
-
__publicField2(this, "isCodyPro", false);
|
|
41289
|
-
__publicField2(this, "isEnterpriseUser", false);
|
|
41247
|
+
__publicField2(this, "models", []);
|
|
41290
41248
|
__publicField2(this, "onTitleChangeCallback");
|
|
41291
41249
|
this.document = document2;
|
|
41292
41250
|
this.editInput = editInput;
|
|
@@ -41315,14 +41273,10 @@ class EditInputFlow {
|
|
|
41315
41273
|
});
|
|
41316
41274
|
}
|
|
41317
41275
|
async init() {
|
|
41318
|
-
|
|
41319
|
-
this.
|
|
41320
|
-
this.isCodyPro = Boolean(sub2 && !sub2.userCanUpgrade);
|
|
41321
|
-
this.modelAvailability = await modelsService.getModelsAvailabilityStatus(ModelUsage.Edit);
|
|
41322
|
-
const modelOptions = this.modelAvailability.map((it) => it.model);
|
|
41323
|
-
this.modelItems = getModelOptionItems(modelOptions, this.isCodyPro, this.isEnterpriseUser);
|
|
41276
|
+
this.models = await firstResultFromOperation(modelsService.getModels(ModelUsage.Edit));
|
|
41277
|
+
this.modelItems = getModelOptionItems(this.models);
|
|
41324
41278
|
this.activeModelItem = this.modelItems.find((item) => item.model === this.activeModel);
|
|
41325
|
-
this.showModelSelector =
|
|
41279
|
+
this.showModelSelector = this.models.length > 1;
|
|
41326
41280
|
this.rulesToApply = this.editInput.rules ?? await firstValueFrom$1(ruleService.rulesForPaths([this.document.uri]));
|
|
41327
41281
|
this.editor.revealRange(this.activeRange, TextEditorRevealType.InCenterIfOutsideViewport);
|
|
41328
41282
|
}
|
|
@@ -41336,12 +41290,7 @@ class EditInputFlow {
|
|
|
41336
41290
|
);
|
|
41337
41291
|
}
|
|
41338
41292
|
getModelInputItems() {
|
|
41339
|
-
return getModelInputItems(
|
|
41340
|
-
this.modelAvailability.map((it) => it.model),
|
|
41341
|
-
this.activeModel,
|
|
41342
|
-
this.isCodyPro,
|
|
41343
|
-
this.isEnterpriseUser
|
|
41344
|
-
);
|
|
41293
|
+
return getModelInputItems(this.models, this.activeModel);
|
|
41345
41294
|
}
|
|
41346
41295
|
getRangeSymbolInputItems() {
|
|
41347
41296
|
return getRangeSymbolInputItems(this.activeRange.start, this.symbolsPromise);
|
|
@@ -41355,7 +41304,7 @@ class EditInputFlow {
|
|
|
41355
41304
|
);
|
|
41356
41305
|
}
|
|
41357
41306
|
getAvailableModels() {
|
|
41358
|
-
return this.
|
|
41307
|
+
return this.models;
|
|
41359
41308
|
}
|
|
41360
41309
|
getContextWindowForModel(model2) {
|
|
41361
41310
|
var _a3;
|
|
@@ -41399,9 +41348,6 @@ class EditInputFlow {
|
|
|
41399
41348
|
)}`
|
|
41400
41349
|
);
|
|
41401
41350
|
}
|
|
41402
|
-
if (item.codyProOnly && !this.isCodyPro && !this.isEnterpriseUser) {
|
|
41403
|
-
return { requiresUpgrade: true, modelTitle: item.modelTitle };
|
|
41404
|
-
}
|
|
41405
41351
|
try {
|
|
41406
41352
|
await modelsService.setSelectedModel(ModelUsage.Edit, item.model);
|
|
41407
41353
|
} catch (e) {
|
|
@@ -45335,7 +45281,7 @@ class AgentGlobalState {
|
|
|
45335
45281
|
}
|
|
45336
45282
|
async reset() {
|
|
45337
45283
|
this.db.clear();
|
|
45338
|
-
|
|
45284
|
+
localStorage.resetCache();
|
|
45339
45285
|
}
|
|
45340
45286
|
keys() {
|
|
45341
45287
|
if (this.manager === "server") {
|
|
@@ -45684,7 +45630,7 @@ class Agent extends MessageHandler {
|
|
|
45684
45630
|
this.params = params;
|
|
45685
45631
|
setAgent(this);
|
|
45686
45632
|
this.registerRequest("initialize", async (clientInfo) => {
|
|
45687
|
-
var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2
|
|
45633
|
+
var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
45688
45634
|
languages$1.registerFoldingRangeProvider(
|
|
45689
45635
|
"*",
|
|
45690
45636
|
new IndentationBasedFoldingRangeProvider()
|
|
@@ -45723,12 +45669,7 @@ class Agent extends MessageHandler {
|
|
|
45723
45669
|
(codeLensProvider) => this.codeLens.removeProvider(codeLensProvider)
|
|
45724
45670
|
);
|
|
45725
45671
|
}
|
|
45726
|
-
if (((_f2 = clientInfo.capabilities) == null ? void 0 : _f2.
|
|
45727
|
-
contextFiltersProvider.onContextFiltersChanged(() => {
|
|
45728
|
-
this.notify("ignore/didChange", null);
|
|
45729
|
-
});
|
|
45730
|
-
}
|
|
45731
|
-
if (((_g2 = clientInfo.capabilities) == null ? void 0 : _g2.authentication) === "enabled") {
|
|
45672
|
+
if (((_f2 = clientInfo.capabilities) == null ? void 0 : _f2.authentication) === "enabled") {
|
|
45732
45673
|
this.authenticationHandler = new AgentAuthHandler();
|
|
45733
45674
|
}
|
|
45734
45675
|
if (define_process_default$8.env.CODY_DEBUG === "true") {
|
|
@@ -45740,8 +45681,8 @@ class Agent extends MessageHandler {
|
|
|
45740
45681
|
setClientInfo(clientInfo);
|
|
45741
45682
|
this.clientInfo = clientInfo;
|
|
45742
45683
|
try {
|
|
45743
|
-
const secrets = ((
|
|
45744
|
-
[formatURL(((
|
|
45684
|
+
const secrets = ((_g2 = clientInfo.capabilities) == null ? void 0 : _g2.secrets) === "client-managed" ? new AgentClientManagedSecretStorage(this, this.secretsDidChange) : new AgentStatelessSecretStorage({
|
|
45685
|
+
[formatURL(((_h2 = clientInfo.extensionConfiguration) == null ? void 0 : _h2.serverEndpoint) ?? "") ?? ""]: ((_i2 = clientInfo.extensionConfiguration) == null ? void 0 : _i2.accessToken) ?? void 0
|
|
45745
45686
|
});
|
|
45746
45687
|
await initializeVscodeExtension(
|
|
45747
45688
|
params.extensionActivate,
|
|
@@ -45749,10 +45690,8 @@ class Agent extends MessageHandler {
|
|
|
45749
45690
|
this.globalState,
|
|
45750
45691
|
secrets
|
|
45751
45692
|
);
|
|
45752
|
-
const
|
|
45753
|
-
const
|
|
45754
|
-
const webviewKind = ((_m = clientInfo.capabilities) == null ? void 0 : _m.webview) || "agentic";
|
|
45755
|
-
const nativeWebviewConfig = (_n = clientInfo.capabilities) == null ? void 0 : _n.webviewNativeConfig;
|
|
45693
|
+
const webviewKind = ((_j2 = clientInfo.capabilities) == null ? void 0 : _j2.webview) || "agentic";
|
|
45694
|
+
const nativeWebviewConfig = (_k2 = clientInfo.capabilities) == null ? void 0 : _k2.webviewNativeConfig;
|
|
45756
45695
|
if (webviewKind === "native") {
|
|
45757
45696
|
if (!nativeWebviewConfig) {
|
|
45758
45697
|
throw new Error(
|
|
@@ -45767,9 +45706,7 @@ class Agent extends MessageHandler {
|
|
|
45767
45706
|
} else {
|
|
45768
45707
|
this.registerWebviewHandlers();
|
|
45769
45708
|
}
|
|
45770
|
-
const status = clientInfo.extensionConfiguration ? await this.handleConfigChanges(clientInfo.extensionConfiguration
|
|
45771
|
-
forceAuthentication
|
|
45772
|
-
}) : await firstNonPendingAuthStatus();
|
|
45709
|
+
const status = clientInfo.extensionConfiguration ? await this.handleConfigChanges(clientInfo.extensionConfiguration) : await firstNonPendingAuthStatus();
|
|
45773
45710
|
return {
|
|
45774
45711
|
name: "cody-agent",
|
|
45775
45712
|
authenticated: status.authenticated,
|
|
@@ -46302,20 +46239,6 @@ class Agent extends MessageHandler {
|
|
|
46302
46239
|
}
|
|
46303
46240
|
throw id;
|
|
46304
46241
|
});
|
|
46305
|
-
this.registerAuthenticatedRequest("graphql/currentUserIsPro", async () => {
|
|
46306
|
-
const res = await graphqlClient.getCurrentUserCodyProEnabled();
|
|
46307
|
-
if (res instanceof Error) {
|
|
46308
|
-
throw res;
|
|
46309
|
-
}
|
|
46310
|
-
return Boolean(res == null ? void 0 : res.codyProEnabled);
|
|
46311
|
-
});
|
|
46312
|
-
this.registerAuthenticatedRequest("graphql/getCurrentUserCodySubscription", async () => {
|
|
46313
|
-
const res = await graphqlClient.getCurrentUserCodySubscription();
|
|
46314
|
-
if (res instanceof Error) {
|
|
46315
|
-
throw res;
|
|
46316
|
-
}
|
|
46317
|
-
return res;
|
|
46318
|
-
});
|
|
46319
46242
|
this.registerAuthenticatedRequest("telemetry/recordEvent", async (event2) => {
|
|
46320
46243
|
telemetryRecorder.recordEvent(
|
|
46321
46244
|
// 👷 HACK: We have no control over what gets sent over JSON RPC,
|
|
@@ -46469,7 +46392,7 @@ class Agent extends MessageHandler {
|
|
|
46469
46392
|
const clientConfig = await ClientConfigSingleton.getInstance().getConfig();
|
|
46470
46393
|
return {
|
|
46471
46394
|
readOnly: !(clientConfig == null ? void 0 : clientConfig.modelsAPIEnabled),
|
|
46472
|
-
models: await modelsService.
|
|
46395
|
+
models: await firstResultFromOperation(modelsService.getModels(modelUsage))
|
|
46473
46396
|
};
|
|
46474
46397
|
});
|
|
46475
46398
|
this.registerAuthenticatedRequest("chat/export", async (input) => {
|
|
@@ -46601,17 +46524,6 @@ class Agent extends MessageHandler {
|
|
|
46601
46524
|
limitHit: ((_b2 = result == null ? void 0 : result.attribution) == null ? void 0 : _b2.limitHit) || false
|
|
46602
46525
|
};
|
|
46603
46526
|
});
|
|
46604
|
-
this.registerAuthenticatedRequest("ignore/test", async ({ uri: uriString }) => {
|
|
46605
|
-
const uri = Uri.parse(uriString);
|
|
46606
|
-
const isIgnored = await contextFiltersProvider.isUriIgnored(uri);
|
|
46607
|
-
return {
|
|
46608
|
-
policy: isIgnored ? "ignore" : "use"
|
|
46609
|
-
};
|
|
46610
|
-
});
|
|
46611
|
-
this.registerAuthenticatedRequest("testing/ignore/overridePolicy", async (contextFilters) => {
|
|
46612
|
-
contextFiltersProvider.setTestingContextFilters(contextFilters);
|
|
46613
|
-
return null;
|
|
46614
|
-
});
|
|
46615
46527
|
this.registerAuthenticatedRequest("internal/getAuthHeaders", async (url) => {
|
|
46616
46528
|
const config = await firstResultFromOperation(resolvedConfig);
|
|
46617
46529
|
return await getAuthHeaders(config.auth, new URL(url));
|
|
@@ -46657,11 +46569,10 @@ class Agent extends MessageHandler {
|
|
|
46657
46569
|
var _a3;
|
|
46658
46570
|
return ((_a3 = this.clientInfo) == null ? void 0 : _a3.capabilities) ?? void 0;
|
|
46659
46571
|
}
|
|
46660
|
-
async handleConfigChanges(config
|
|
46661
|
-
const isAuthChange = isTokenOrEndpointChange(config);
|
|
46572
|
+
async handleConfigChanges(config) {
|
|
46662
46573
|
setExtensionConfiguration(config);
|
|
46663
46574
|
try {
|
|
46664
|
-
if (
|
|
46575
|
+
if (config.serverEndpoint) {
|
|
46665
46576
|
await authProvider.validateAndStoreCredentials(
|
|
46666
46577
|
{
|
|
46667
46578
|
configuration: {
|
|
@@ -46677,7 +46588,6 @@ class Agent extends MessageHandler {
|
|
|
46677
46588
|
},
|
|
46678
46589
|
"always-store"
|
|
46679
46590
|
);
|
|
46680
|
-
await firstResultFromOperation(localStorage.clientStateChanges);
|
|
46681
46591
|
}
|
|
46682
46592
|
} catch (error) {
|
|
46683
46593
|
console.log("Authentication failed", error);
|
|
@@ -47980,7 +47890,7 @@ class CommandsProvider {
|
|
|
47980
47890
|
if (!isFileURI(uri)) {
|
|
47981
47891
|
throw new Error("history only supported on local file paths");
|
|
47982
47892
|
}
|
|
47983
|
-
const { getContextFileFromGitLog } = await import("./git-log-
|
|
47893
|
+
const { getContextFileFromGitLog } = await import("./git-log-Dihxu1-Z.mjs");
|
|
47984
47894
|
return getContextFileFromGitLog(uri, options);
|
|
47985
47895
|
}
|
|
47986
47896
|
dispose() {
|
|
@@ -48114,8 +48024,7 @@ const isReinstalling = async () => {
|
|
|
48114
48024
|
};
|
|
48115
48025
|
async function showAccountMenu() {
|
|
48116
48026
|
const authStatus2 = currentAuthStatusAuthed();
|
|
48117
|
-
const
|
|
48118
|
-
const selected = await openAccountMenuFirstStep(authStatus2, sub2);
|
|
48027
|
+
const selected = await openAccountMenuFirstStep(authStatus2);
|
|
48119
48028
|
if (selected === void 0) {
|
|
48120
48029
|
return;
|
|
48121
48030
|
}
|
|
@@ -48135,12 +48044,11 @@ async function showAccountMenu() {
|
|
|
48135
48044
|
break;
|
|
48136
48045
|
}
|
|
48137
48046
|
}
|
|
48138
|
-
async function openAccountMenuFirstStep(authStatus2
|
|
48047
|
+
async function openAccountMenuFirstStep(authStatus2) {
|
|
48139
48048
|
const isDotComInstance = isDotCom(authStatus2.endpoint);
|
|
48140
48049
|
const displayName = authStatus2.displayName || authStatus2.username;
|
|
48141
48050
|
const email = authStatus2.primaryEmail || "No Email";
|
|
48142
48051
|
const username = authStatus2.username || authStatus2.displayName;
|
|
48143
|
-
const planDetail = sub2 ? `Plan: ${sub2.userCanUpgrade ? "Cody Free" : "Cody Pro"}` : "";
|
|
48144
48052
|
const enterpriseDetail = `Enterprise Instance:
|
|
48145
48053
|
${authStatus2.endpoint}`;
|
|
48146
48054
|
const options = isDotComInstance ? [
|
|
@@ -48154,7 +48062,7 @@ ${authStatus2.endpoint}`;
|
|
|
48154
48062
|
);
|
|
48155
48063
|
const messageOptions = {
|
|
48156
48064
|
modal: true,
|
|
48157
|
-
detail:
|
|
48065
|
+
detail: enterpriseDetail
|
|
48158
48066
|
};
|
|
48159
48067
|
const message = isDotComInstance ? `Signed in as ${displayName} (${email})` : `Signed in as @${username}`;
|
|
48160
48068
|
const option2 = await window$1.showInformationMessage(message, messageOptions, ...options);
|
|
@@ -151958,43 +151866,29 @@ const providerModes = {
|
|
|
151958
151866
|
standard: {
|
|
151959
151867
|
tokenLimit: defaultTokenLimit,
|
|
151960
151868
|
promptProvider: void 0,
|
|
151961
|
-
|
|
151962
|
-
dotcom: "autoedits-deepseek-lite-default",
|
|
151963
|
-
sgInstance: "fireworks::v1::autoedits-deepseek-lite-default"
|
|
151964
|
-
}
|
|
151869
|
+
model: "fireworks::v1::autoedits-deepseek-lite-default"
|
|
151965
151870
|
},
|
|
151966
151871
|
hotStreak: {
|
|
151967
151872
|
tokenLimit: hotStreakTokenLimit,
|
|
151968
151873
|
promptProvider: "long-suggestion-prompt-provider",
|
|
151969
|
-
|
|
151970
|
-
dotcom: "autoedits-long-suggestion-default",
|
|
151971
|
-
sgInstance: "fireworks::v1::autoedits-long-suggestion-default"
|
|
151972
|
-
}
|
|
151874
|
+
model: "fireworks::v1::autoedits-long-suggestion-default"
|
|
151973
151875
|
}
|
|
151974
151876
|
};
|
|
151975
|
-
const
|
|
151976
|
-
|
|
151977
|
-
|
|
151978
|
-
|
|
151979
|
-
|
|
151980
|
-
timeoutMs: 1e4
|
|
151981
|
-
},
|
|
151982
|
-
sgInstance: {
|
|
151983
|
-
provider: "sourcegraph",
|
|
151984
|
-
url: "",
|
|
151985
|
-
isChatModel: false,
|
|
151986
|
-
timeoutMs: 1e4
|
|
151987
|
-
}
|
|
151877
|
+
const providerConfig = {
|
|
151878
|
+
provider: "sourcegraph",
|
|
151879
|
+
url: "",
|
|
151880
|
+
isChatModel: false,
|
|
151881
|
+
timeoutMs: 1e4
|
|
151988
151882
|
};
|
|
151989
151883
|
function getBaseProviderConfig() {
|
|
151990
151884
|
const mode = isHotStreakEnabled() ? "hotStreak" : "standard";
|
|
151991
151885
|
const config = providerModes[mode];
|
|
151992
|
-
const authConfig =
|
|
151886
|
+
const authConfig = providerConfig;
|
|
151993
151887
|
return {
|
|
151994
151888
|
...authConfig,
|
|
151995
151889
|
promptProvider: config.promptProvider,
|
|
151996
151890
|
tokenLimit: config.tokenLimit,
|
|
151997
|
-
model: config.
|
|
151891
|
+
model: config.model
|
|
151998
151892
|
};
|
|
151999
151893
|
}
|
|
152000
151894
|
function getAutoeditsProviderConfig() {
|
|
@@ -153001,8 +152895,7 @@ class DefaultCodeCompletionsClient {
|
|
|
153001
152895
|
});
|
|
153002
152896
|
logResponseHeadersToSpan(span2, response);
|
|
153003
152897
|
if (response.status === 429) {
|
|
153004
|
-
|
|
153005
|
-
throw await createRateLimitErrorFromResponse(response, upgradeIsAvailable);
|
|
152898
|
+
throw await createRateLimitErrorFromResponse(response);
|
|
153006
152899
|
}
|
|
153007
152900
|
if (!response.ok) {
|
|
153008
152901
|
throw isCustomAuthChallengeResponse(response) ? new NeedsAuthChallengeError() : new NetworkError(response, await response.text(), traceId);
|
|
@@ -153114,13 +153007,12 @@ class DefaultCodeCompletionsClient {
|
|
|
153114
153007
|
}
|
|
153115
153008
|
const defaultCodeCompletionsClient = singletonNotYetSet();
|
|
153116
153009
|
setSingleton(defaultCodeCompletionsClient, new DefaultCodeCompletionsClient());
|
|
153117
|
-
async function createRateLimitErrorFromResponse(response
|
|
153010
|
+
async function createRateLimitErrorFromResponse(response) {
|
|
153118
153011
|
const retryAfter = response.headers.get("retry-after");
|
|
153119
153012
|
const limit = response.headers.get("x-ratelimit-limit");
|
|
153120
153013
|
return new RateLimitError$1(
|
|
153121
153014
|
"autocompletions",
|
|
153122
153015
|
await response.text(),
|
|
153123
|
-
upgradeIsAvailable,
|
|
153124
153016
|
limit ? Number.parseInt(limit, 10) : void 0,
|
|
153125
153017
|
retryAfter
|
|
153126
153018
|
);
|
|
@@ -154369,8 +154261,6 @@ class AutoeditAnalyticsLogger {
|
|
|
154369
154261
|
otherCompletionProviders: otherCompletionProviders2,
|
|
154370
154262
|
upstreamLatency: upstreamHealthProvider.getUpstreamLatency(),
|
|
154371
154263
|
gatewayLatency: upstreamHealthProvider.getGatewayLatency(),
|
|
154372
|
-
codeToRewrite: void 0,
|
|
154373
|
-
// todo(mk): remove in the scope of PLG sunsetting
|
|
154374
154264
|
...restPayload
|
|
154375
154265
|
}
|
|
154376
154266
|
};
|
|
@@ -154415,8 +154305,6 @@ class AutoeditAnalyticsLogger {
|
|
|
154415
154305
|
payload: {
|
|
154416
154306
|
...request.payload,
|
|
154417
154307
|
id: stableId,
|
|
154418
|
-
prediction: void 0,
|
|
154419
|
-
// todo(mk): remove in the scope of PLG sunsetting
|
|
154420
154308
|
source,
|
|
154421
154309
|
isFuzzyMatch,
|
|
154422
154310
|
responseHeaders: "responseHeaders" in modelResponse ? modelResponse.responseHeaders : {},
|
|
@@ -173052,25 +172940,6 @@ async function getLocalCommands(input) {
|
|
|
173052
172940
|
(c) => matchesQuery(query2, c.key) || matchesQuery(query2, c.description ?? "") || matchesQuery(query2, c.prompt)
|
|
173053
172941
|
);
|
|
173054
172942
|
}
|
|
173055
|
-
class AuthProviderSimplified {
|
|
173056
|
-
async openExternalAuthUrl(method, tokenReceiverUrl) {
|
|
173057
|
-
if (!await openExternalAuthUrl(method, tokenReceiverUrl)) {
|
|
173058
|
-
return false;
|
|
173059
|
-
}
|
|
173060
|
-
authProvider.setAuthPendingToEndpoint(DOTCOM_URL.toString());
|
|
173061
|
-
return true;
|
|
173062
|
-
}
|
|
173063
|
-
}
|
|
173064
|
-
function openExternalAuthUrl(provider, tokenReceiverUrl) {
|
|
173065
|
-
const referralCode = getCodyAuthReferralCode(env.uriScheme);
|
|
173066
|
-
const tokenReceiver = tokenReceiverUrl ? `&tokenReceiverUrl=${tokenReceiverUrl}` : "";
|
|
173067
|
-
const redirect = encodeURIComponent(
|
|
173068
|
-
`/user/settings/tokens/new/callback?requestFrom=${referralCode}${tokenReceiver}`
|
|
173069
|
-
);
|
|
173070
|
-
const site = DOTCOM_URL.toString();
|
|
173071
|
-
const uriSpec = provider === "github" || provider === "gitlab" || provider === "google" ? `${site}.auth/openidconnect/login?prompt_auth=${provider}&pc=sams&redirect=${redirect}` : `${site}sign-in?returnTo=${redirect}`;
|
|
173072
|
-
return env.openExternal(uriSpec);
|
|
173073
|
-
}
|
|
173074
172943
|
const TraceSender = {
|
|
173075
172944
|
send(spanData) {
|
|
173076
172945
|
void doSendTraceData(spanData).catch((error) => {
|
|
@@ -174077,7 +173946,14 @@ class DefaultPrompter {
|
|
|
174077
173946
|
const promptBuilder = await PromptBuilder.create(contextWindow2);
|
|
174078
173947
|
const preInstruction = (await currentResolvedConfig()).configuration.chatPreInstruction;
|
|
174079
173948
|
const chatModel = await firstResultFromOperation(ChatBuilder.resolvedModelForChat(chat2));
|
|
174080
|
-
const
|
|
173949
|
+
const includeTerminalToolPreamble = false;
|
|
173950
|
+
const preambleMessages = getSimplePreamble(
|
|
173951
|
+
chatModel,
|
|
173952
|
+
codyApiVersion,
|
|
173953
|
+
"Chat",
|
|
173954
|
+
preInstruction,
|
|
173955
|
+
includeTerminalToolPreamble
|
|
173956
|
+
);
|
|
174081
173957
|
if (!promptBuilder.tryAddToPrefix(preambleMessages)) {
|
|
174082
173958
|
throw new Error(`Preamble length exceeded context window ${contextWindow2.input}`);
|
|
174083
173959
|
}
|
|
@@ -174390,7 +174266,8 @@ const _DeepCodyHandler = class _DeepCodyHandler extends ChatHandler {
|
|
|
174390
174266
|
};
|
|
174391
174267
|
}
|
|
174392
174268
|
static isAgenticChatEnabled() {
|
|
174393
|
-
|
|
174269
|
+
const currentIDE = clientCapabilities().agentIDE;
|
|
174270
|
+
return _DeepCodyHandler.isToolboxEnabled && Boolean(_DeepCodyHandler.model) && !isCodyTesting && currentIDE !== CodyIDE.Web;
|
|
174394
174271
|
}
|
|
174395
174272
|
static getFeatureError(feature2) {
|
|
174396
174273
|
switch (feature2) {
|
|
@@ -174423,7 +174300,6 @@ __publicField2(_DeepCodyHandler, "observable", combineLatest$1(
|
|
|
174423
174300
|
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.AgenticContextDisabled),
|
|
174424
174301
|
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.ContextAgentDefaultChatModel),
|
|
174425
174302
|
featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.DeepCodyShellContext),
|
|
174426
|
-
userProductSubscription.pipe(distinctUntilChanged$1()),
|
|
174427
174303
|
modelsService.modelsChanges.pipe(
|
|
174428
174304
|
map$1((models) => models === pendingOperation ? null : models),
|
|
174429
174305
|
distinctUntilChanged$1()
|
|
@@ -174437,12 +174313,11 @@ __publicField2(_DeepCodyHandler, "observable", combineLatest$1(
|
|
|
174437
174313
|
isDisabledOnInstance,
|
|
174438
174314
|
useDefaultChatModel,
|
|
174439
174315
|
instanceShellContextFlag,
|
|
174440
|
-
sub2,
|
|
174441
174316
|
models,
|
|
174442
174317
|
config
|
|
174443
174318
|
]) => {
|
|
174444
174319
|
var _a3, _b2, _c2, _d2;
|
|
174445
|
-
if (
|
|
174320
|
+
if (!models || isCodyTesting || isDisabledOnInstance || ((_a3 = config.configuration) == null ? void 0 : _a3.chatAgenticContext) === false) {
|
|
174446
174321
|
_DeepCodyHandler.model = void 0;
|
|
174447
174322
|
_DeepCodyHandler.isToolboxEnabled = false;
|
|
174448
174323
|
return null;
|
|
@@ -182090,7 +181965,11 @@ function getCorpusContextItemsForEditorState() {
|
|
|
182090
181965
|
return pendingOperation;
|
|
182091
181966
|
}
|
|
182092
181967
|
if (isError$3(remoteReposForAllWorkspaceFolders2)) {
|
|
182093
|
-
|
|
181968
|
+
logError$2(
|
|
181969
|
+
"initialContext",
|
|
181970
|
+
"Failed to get remote repos for all workspace folders"
|
|
181971
|
+
);
|
|
181972
|
+
remoteReposForAllWorkspaceFolders2 = [];
|
|
182094
181973
|
}
|
|
182095
181974
|
for (const repo of remoteReposForAllWorkspaceFolders2) {
|
|
182096
181975
|
if (await contextFiltersProvider.isRepoNameIgnored(repo.name)) {
|
|
@@ -183419,11 +183298,11 @@ class ChatsController {
|
|
|
183419
183298
|
};
|
|
183420
183299
|
this.disposables.push(
|
|
183421
183300
|
commands$1.registerCommand("cody.chat.moveToEditor", async () => {
|
|
183422
|
-
localStorage.setLastUsedChatModality("editor");
|
|
183301
|
+
await localStorage.setLastUsedChatModality("editor");
|
|
183423
183302
|
return await this.moveChatFromPanelToEditor();
|
|
183424
183303
|
}),
|
|
183425
183304
|
commands$1.registerCommand("cody.chat.moveFromEditor", async () => {
|
|
183426
|
-
localStorage.setLastUsedChatModality("sidebar");
|
|
183305
|
+
await localStorage.setLastUsedChatModality("sidebar");
|
|
183427
183306
|
return await this.moveChatFromEditorToPanel();
|
|
183428
183307
|
}),
|
|
183429
183308
|
commands$1.registerCommand("cody.action.chat", (args2) => this.submitChat(args2)),
|
|
@@ -183432,7 +183311,7 @@ class ChatsController {
|
|
|
183432
183311
|
() => commands$1.executeCommand("cody.chat.focus")
|
|
183433
183312
|
),
|
|
183434
183313
|
commands$1.registerCommand("cody.chat.newPanel", async (args2) => {
|
|
183435
|
-
localStorage.setLastUsedChatModality("sidebar");
|
|
183314
|
+
await localStorage.setLastUsedChatModality("sidebar");
|
|
183436
183315
|
const isVisible = this.panel.isVisible();
|
|
183437
183316
|
await this.panel.clearAndRestartSession();
|
|
183438
183317
|
try {
|
|
@@ -183447,7 +183326,7 @@ class ChatsController {
|
|
|
183447
183326
|
}
|
|
183448
183327
|
}),
|
|
183449
183328
|
commands$1.registerCommand("cody.chat.newEditorPanel", async (args2) => {
|
|
183450
|
-
localStorage.setLastUsedChatModality("editor");
|
|
183329
|
+
await localStorage.setLastUsedChatModality("editor");
|
|
183451
183330
|
const panel2 = await this.getOrCreateEditorChatController();
|
|
183452
183331
|
try {
|
|
183453
183332
|
const { contextItems } = JSON.parse(args2) || {};
|
|
@@ -183793,7 +183672,6 @@ class ChatsController {
|
|
|
183793
183672
|
...this.options,
|
|
183794
183673
|
chatClient: this.chatClient,
|
|
183795
183674
|
guardrails: this.guardrails,
|
|
183796
|
-
startTokenReceiver: this.options.startTokenReceiver,
|
|
183797
183675
|
contextRetriever: this.contextRetriever,
|
|
183798
183676
|
extensionClient: this.extensionClient
|
|
183799
183677
|
});
|
|
@@ -187197,14 +187075,15 @@ async function getFileMentions(repoName, filePath) {
|
|
|
187197
187075
|
const query2 = `repo:${repoRe} file:${fileRe} type:file count:10`;
|
|
187198
187076
|
const { auth: auth2 } = await currentResolvedConfig();
|
|
187199
187077
|
const dataOrError = await graphqlClient.searchFileMatches(query2);
|
|
187200
|
-
|
|
187078
|
+
const endpoint = auth2.serverEndpoint;
|
|
187079
|
+
if (isError$3(dataOrError) || dataOrError === null || !endpoint) {
|
|
187201
187080
|
return [];
|
|
187202
187081
|
}
|
|
187203
187082
|
return dataOrError.search.results.results.map((result) => {
|
|
187204
187083
|
if (result.__typename !== "FileMatch") {
|
|
187205
187084
|
return null;
|
|
187206
187085
|
}
|
|
187207
|
-
const url = `${
|
|
187086
|
+
const url = `${endpoint.replace(/\/$/, "")}${result.file.url}`;
|
|
187208
187087
|
const basename2 = displayPathBasename(URI.parse(result.file.path));
|
|
187209
187088
|
return {
|
|
187210
187089
|
uri: url,
|
|
@@ -187222,14 +187101,15 @@ async function getFileItem(repoName, filePath, rev2 = "HEAD") {
|
|
|
187222
187101
|
var _a3, _b2;
|
|
187223
187102
|
const { auth: auth2 } = await currentResolvedConfig();
|
|
187224
187103
|
const dataOrError = await graphqlClient.getFileContents(repoName, filePath, rev2);
|
|
187225
|
-
|
|
187104
|
+
const endpoint = auth2.serverEndpoint;
|
|
187105
|
+
if (isError$3(dataOrError) || dataOrError === null || !endpoint) {
|
|
187226
187106
|
return [];
|
|
187227
187107
|
}
|
|
187228
187108
|
const file = (_b2 = (_a3 = dataOrError == null ? void 0 : dataOrError.repository) == null ? void 0 : _a3.commit) == null ? void 0 : _b2.file;
|
|
187229
187109
|
if (!file) {
|
|
187230
187110
|
return [];
|
|
187231
187111
|
}
|
|
187232
|
-
const url = `${
|
|
187112
|
+
const url = `${endpoint.replace(/\/$/, "")}${file.url}`;
|
|
187233
187113
|
return [
|
|
187234
187114
|
{
|
|
187235
187115
|
url,
|
|
@@ -187521,7 +187401,6 @@ class ChatController {
|
|
|
187521
187401
|
chatClient,
|
|
187522
187402
|
editor,
|
|
187523
187403
|
guardrails,
|
|
187524
|
-
startTokenReceiver,
|
|
187525
187404
|
contextRetriever,
|
|
187526
187405
|
extensionClient
|
|
187527
187406
|
}) {
|
|
@@ -187531,7 +187410,6 @@ class ChatController {
|
|
|
187531
187410
|
__publicField2(this, "editor");
|
|
187532
187411
|
__publicField2(this, "extensionClient");
|
|
187533
187412
|
__publicField2(this, "guardrails");
|
|
187534
|
-
__publicField2(this, "startTokenReceiver");
|
|
187535
187413
|
__publicField2(this, "lastKnownTokenUsage");
|
|
187536
187414
|
__publicField2(this, "disposables", []);
|
|
187537
187415
|
__publicField2(this, "clientBroadcast", new MulticastSubject());
|
|
@@ -187550,7 +187428,6 @@ class ChatController {
|
|
|
187550
187428
|
this.contextRetriever = contextRetriever;
|
|
187551
187429
|
this.chatBuilder = new ChatBuilder(void 0);
|
|
187552
187430
|
this.guardrails = guardrails;
|
|
187553
|
-
this.startTokenReceiver = startTokenReceiver;
|
|
187554
187431
|
if (TestSupport.instance) {
|
|
187555
187432
|
TestSupport.instance.chatPanelProvider.set(this);
|
|
187556
187433
|
}
|
|
@@ -187591,7 +187468,7 @@ class ChatController {
|
|
|
187591
187468
|
* @param message is the message from the view.
|
|
187592
187469
|
*/
|
|
187593
187470
|
async onDidReceiveMessage(message) {
|
|
187594
|
-
var _a3, _b2
|
|
187471
|
+
var _a3, _b2;
|
|
187595
187472
|
try {
|
|
187596
187473
|
switch (message.command) {
|
|
187597
187474
|
case "ready":
|
|
@@ -187806,52 +187683,7 @@ class ChatController {
|
|
|
187806
187683
|
break;
|
|
187807
187684
|
case "auth": {
|
|
187808
187685
|
if (message.authKind === "refresh") {
|
|
187809
|
-
authProvider.refresh();
|
|
187810
|
-
break;
|
|
187811
|
-
}
|
|
187812
|
-
if (message.authKind === "simplified-onboarding") {
|
|
187813
|
-
const endpoint = DOTCOM_URL.href;
|
|
187814
|
-
let tokenReceiverUrl = void 0;
|
|
187815
|
-
closeAuthProgressIndicator();
|
|
187816
|
-
startAuthProgressIndicator();
|
|
187817
|
-
tokenReceiverUrl = await ((_c2 = this.startTokenReceiver) == null ? void 0 : _c2.call(
|
|
187818
|
-
this,
|
|
187819
|
-
endpoint,
|
|
187820
|
-
async (credentials) => {
|
|
187821
|
-
closeAuthProgressIndicator();
|
|
187822
|
-
const authStatus2 = await authProvider.validateAndStoreCredentials(
|
|
187823
|
-
credentials,
|
|
187824
|
-
"store-if-valid"
|
|
187825
|
-
);
|
|
187826
|
-
telemetryRecorder.recordEvent(
|
|
187827
|
-
"cody.auth.fromTokenReceiver.web",
|
|
187828
|
-
"succeeded",
|
|
187829
|
-
{
|
|
187830
|
-
metadata: {
|
|
187831
|
-
success: authStatus2.authenticated ? 1 : 0
|
|
187832
|
-
},
|
|
187833
|
-
billingMetadata: {
|
|
187834
|
-
product: "cody",
|
|
187835
|
-
category: "billable"
|
|
187836
|
-
}
|
|
187837
|
-
}
|
|
187838
|
-
);
|
|
187839
|
-
if (!authStatus2.authenticated) {
|
|
187840
|
-
void window$1.showErrorMessage(
|
|
187841
|
-
"Authentication failed. Please check your token and try again."
|
|
187842
|
-
);
|
|
187843
|
-
}
|
|
187844
|
-
}
|
|
187845
|
-
));
|
|
187846
|
-
const authProviderSimplified = new AuthProviderSimplified();
|
|
187847
|
-
const authMethod = message.authMethod || "dotcom";
|
|
187848
|
-
const successfullyOpenedUrl = await authProviderSimplified.openExternalAuthUrl(
|
|
187849
|
-
authMethod,
|
|
187850
|
-
tokenReceiverUrl
|
|
187851
|
-
);
|
|
187852
|
-
if (!successfullyOpenedUrl) {
|
|
187853
|
-
closeAuthProgressIndicator();
|
|
187854
|
-
}
|
|
187686
|
+
await authProvider.refresh();
|
|
187855
187687
|
break;
|
|
187856
187688
|
}
|
|
187857
187689
|
if ((message.authKind === "signin" || message.authKind === "callback") && message.endpoint) {
|
|
@@ -187894,29 +187726,6 @@ class ChatController {
|
|
|
187894
187726
|
await commands$1.executeCommand(`cody.auth.${message.authKind}`);
|
|
187895
187727
|
break;
|
|
187896
187728
|
}
|
|
187897
|
-
case "simplified-onboarding": {
|
|
187898
|
-
if (message.onboardingKind === "web-sign-in-token") {
|
|
187899
|
-
void window$1.showInputBox({ prompt: "Enter web sign-in token" }).then(async (token) => {
|
|
187900
|
-
if (!token) {
|
|
187901
|
-
return;
|
|
187902
|
-
}
|
|
187903
|
-
const authStatus2 = await authProvider.validateAndStoreCredentials(
|
|
187904
|
-
{
|
|
187905
|
-
serverEndpoint: DOTCOM_URL.href,
|
|
187906
|
-
credentials: { token }
|
|
187907
|
-
},
|
|
187908
|
-
"store-if-valid"
|
|
187909
|
-
);
|
|
187910
|
-
if (!authStatus2.authenticated) {
|
|
187911
|
-
void window$1.showErrorMessage(
|
|
187912
|
-
"Authentication failed. Please check your token and try again."
|
|
187913
|
-
);
|
|
187914
|
-
}
|
|
187915
|
-
});
|
|
187916
|
-
break;
|
|
187917
|
-
}
|
|
187918
|
-
break;
|
|
187919
|
-
}
|
|
187920
187729
|
case "log": {
|
|
187921
187730
|
const logger2 = message.level === "debug" ? logDebug : logError$2;
|
|
187922
187731
|
logger2(message.filterLabel, message.message);
|
|
@@ -187954,11 +187763,9 @@ class ChatController {
|
|
|
187954
187763
|
const sidebarViewOnly = ((_b2 = (_a3 = this.extensionClient.capabilities) == null ? void 0 : _a3.webviewNativeConfig) == null ? void 0 : _b2.view) === "single";
|
|
187955
187764
|
const isEditorViewType = ((_c2 = this.webviewPanelOrView) == null ? void 0 : _c2.viewType) === "cody.editorPanel";
|
|
187956
187765
|
const webviewType = isEditorViewType && !sidebarViewOnly ? "editor" : "sidebar";
|
|
187957
|
-
const uiKindIsWeb = (cenv.CODY_OVERRIDE_UI_KIND ?? env.uiKind) === UIKind.Web;
|
|
187958
187766
|
const endpoints = localStorage.getEndpointHistory() ?? [];
|
|
187959
187767
|
const attribution = ((_d2 = await ClientConfigSingleton.getInstance().getConfig()) == null ? void 0 : _d2.attribution) ?? GuardrailsMode.Off;
|
|
187960
187768
|
return {
|
|
187961
|
-
uiKindIsWeb,
|
|
187962
187769
|
serverEndpoint: auth2.serverEndpoint,
|
|
187963
187770
|
endpointHistory: [...endpoints],
|
|
187964
187771
|
experimentalNoodle: configuration.experimentalNoodle,
|
|
@@ -187988,15 +187795,10 @@ class ChatController {
|
|
|
187988
187795
|
const configForWebview = await this.getConfigForWebview();
|
|
187989
187796
|
const workspaceFolderUris = ((_a3 = workspace.workspaceFolders) == null ? void 0 : _a3.map((folder2) => folder2.uri.toString())) ?? [];
|
|
187990
187797
|
let siteHasCodyEnabled = null;
|
|
187991
|
-
let currentUserCodySubscription = null;
|
|
187992
187798
|
if (authStatus2.authenticated && !isCodyTesting) {
|
|
187993
187799
|
try {
|
|
187994
|
-
const
|
|
187995
|
-
graphqlClient.getSiteHasCodyEnabled(),
|
|
187996
|
-
graphqlClient.getCurrentUserCodySubscription()
|
|
187997
|
-
]);
|
|
187800
|
+
const siteResult = await graphqlClient.getSiteHasCodyEnabled();
|
|
187998
187801
|
siteHasCodyEnabled = isError$3(siteResult) ? null : siteResult;
|
|
187999
|
-
currentUserCodySubscription = isError$3(subscriptionResult) ? null : subscriptionResult;
|
|
188000
187802
|
} catch (error) {
|
|
188001
187803
|
console.error("Failed to fetch additional user data", error);
|
|
188002
187804
|
}
|
|
@@ -188006,11 +187808,8 @@ class ChatController {
|
|
|
188006
187808
|
config: configForWebview,
|
|
188007
187809
|
clientCapabilities: clientCapabilities(),
|
|
188008
187810
|
authStatus: authStatus2,
|
|
188009
|
-
userProductSubscription: await currentUserProductSubscription(),
|
|
188010
187811
|
workspaceFolderUris,
|
|
188011
|
-
|
|
188012
|
-
siteHasCodyEnabled,
|
|
188013
|
-
currentUserCodySubscription
|
|
187812
|
+
siteHasCodyEnabled
|
|
188014
187813
|
});
|
|
188015
187814
|
logDebug("ChatController", "updateViewConfig", {
|
|
188016
187815
|
verbose: configForWebview
|
|
@@ -188881,9 +188680,6 @@ class ChatController {
|
|
|
188881
188680
|
authStatus: () => authStatus,
|
|
188882
188681
|
transcript: () => this.chatBuilder.changes.pipe(map$1((chat2) => chat2.getDehydratedMessages())),
|
|
188883
188682
|
userHistory: (type) => type === ChatHistoryType.Full ? chatHistory.changes : chatHistory.lightweightChanges,
|
|
188884
|
-
userProductSubscription: () => userProductSubscription.pipe(
|
|
188885
|
-
map$1((value) => value === pendingOperation ? null : value)
|
|
188886
|
-
),
|
|
188887
188683
|
// Existing tools endpoint - update to include MCP tools
|
|
188888
188684
|
mcpSettings: () => {
|
|
188889
188685
|
return featureFlagProvider.evaluatedFeatureFlag(FeatureFlag.AgenticChatWithMCP).pipe(
|
|
@@ -189157,38 +188953,39 @@ function createAutoEditsProvider({
|
|
|
189157
188953
|
}
|
|
189158
188954
|
return NEVER$1;
|
|
189159
188955
|
}
|
|
189160
|
-
return
|
|
189161
|
-
|
|
189162
|
-
|
|
189163
|
-
|
|
189164
|
-
|
|
189165
|
-
|
|
189166
|
-
|
|
189167
|
-
|
|
189168
|
-
|
|
189169
|
-
|
|
189170
|
-
|
|
189171
|
-
|
|
189172
|
-
|
|
189173
|
-
|
|
189174
|
-
|
|
189175
|
-
|
|
189176
|
-
|
|
189177
|
-
|
|
189178
|
-
|
|
189179
|
-
|
|
189180
|
-
languages$1.registerInlineCompletionItemProvider(
|
|
189181
|
-
[{ scheme: "file", language: "*" }, { notebookType: "*" }],
|
|
189182
|
-
provider
|
|
189183
|
-
),
|
|
189184
|
-
commands$1.registerCommand("cody.command.autoedit.open-debug-panel", () => {
|
|
189185
|
-
AutoeditDebugPanel.showPanel(context2);
|
|
189186
|
-
}),
|
|
188956
|
+
return new Observable((observer) => {
|
|
188957
|
+
const userEligibilityInfo = isUserEligibleForAutoeditsFeature(autoeditFeatureFlagEnabled);
|
|
188958
|
+
if (!userEligibilityInfo.isUserEligible) {
|
|
188959
|
+
handleAutoeditsNotificationForNonEligibleUser(userEligibilityInfo.nonEligibilityReason);
|
|
188960
|
+
observer.complete();
|
|
188961
|
+
return () => {
|
|
188962
|
+
};
|
|
188963
|
+
}
|
|
188964
|
+
const shouldHotStreak = !isRunningInsideAgent() && (autoeditHotStreakEnabled || isHotStreakEnabledInSettings());
|
|
188965
|
+
const provider = new AutoeditsProvider(chatClient, fixupController, statusBar, {
|
|
188966
|
+
shouldHotStreak,
|
|
188967
|
+
allowUsingWebSocket: autoeditUseWebSocketEnabled
|
|
188968
|
+
});
|
|
188969
|
+
const disposables = [
|
|
188970
|
+
commands$1.registerCommand(
|
|
188971
|
+
"cody.command.autoedit-manual-trigger",
|
|
188972
|
+
async () => provider.manuallyTriggerCompletion()
|
|
188973
|
+
),
|
|
188974
|
+
languages$1.registerInlineCompletionItemProvider(
|
|
188975
|
+
[{ scheme: "file", language: "*" }, { notebookType: "*" }],
|
|
189187
188976
|
provider
|
|
189188
|
-
|
|
189189
|
-
|
|
189190
|
-
|
|
189191
|
-
|
|
188977
|
+
),
|
|
188978
|
+
commands$1.registerCommand("cody.command.autoedit.open-debug-panel", () => {
|
|
188979
|
+
AutoeditDebugPanel.showPanel(context2);
|
|
188980
|
+
}),
|
|
188981
|
+
provider
|
|
188982
|
+
];
|
|
188983
|
+
return () => {
|
|
188984
|
+
for (const d2 of disposables) {
|
|
188985
|
+
d2.dispose();
|
|
188986
|
+
}
|
|
188987
|
+
};
|
|
188988
|
+
}).pipe(map$1(() => void 0));
|
|
189192
188989
|
}
|
|
189193
188990
|
async function handleAutoeditsNotificationForNonEligibleUser(nonEligibilityReason) {
|
|
189194
188991
|
if (!nonEligibilityReason || !isSettingsEditorOpen()) {
|
|
@@ -190511,8 +190308,8 @@ function parseMentionURI(uri) {
|
|
|
190511
190308
|
}
|
|
190512
190309
|
}
|
|
190513
190310
|
async function execFileAsync(program2, args2, { cwd }) {
|
|
190514
|
-
const { promisify } = await import("./util-
|
|
190515
|
-
const { execFile } = await import("./vscode-shim-
|
|
190311
|
+
const { promisify } = await import("./util-D8ltdME7.mjs").then((n) => n.u);
|
|
190312
|
+
const { execFile } = await import("./vscode-shim-Csgwpsv8.mjs").then((n) => n.fx);
|
|
190516
190313
|
return promisify(execFile)(program2, args2, { cwd });
|
|
190517
190314
|
}
|
|
190518
190315
|
var __create = Object.create;
|
|
@@ -192484,7 +192281,7 @@ async function getDirectoryMentions(repoName, directoryPath) {
|
|
|
192484
192281
|
auth: { serverEndpoint }
|
|
192485
192282
|
} = await currentResolvedConfig();
|
|
192486
192283
|
const dataOrError = await graphqlClient.searchFileMatches(query2);
|
|
192487
|
-
if (isError$3(dataOrError) || dataOrError === null) {
|
|
192284
|
+
if (!serverEndpoint || isError$3(dataOrError) || dataOrError === null) {
|
|
192488
192285
|
return [];
|
|
192489
192286
|
}
|
|
192490
192287
|
return dataOrError.search.results.results.map((result) => {
|
|
@@ -192506,10 +192303,11 @@ async function getDirectoryMentions(repoName, directoryPath) {
|
|
|
192506
192303
|
}).filter(isDefined);
|
|
192507
192304
|
}
|
|
192508
192305
|
async function getDirectoryItem(query2, repoID, directoryPath) {
|
|
192306
|
+
const directoryRe = directoryPath ? escapeRegExp(directoryPath) : "";
|
|
192509
192307
|
const dataOrError = await graphqlClient.contextSearch({
|
|
192510
192308
|
repoIDs: [repoID],
|
|
192511
192309
|
query: query2,
|
|
192512
|
-
filePatterns: [`^${
|
|
192310
|
+
filePatterns: [`^${directoryRe}.*`]
|
|
192513
192311
|
});
|
|
192514
192312
|
if (isError$3(dataOrError) || dataOrError === null) {
|
|
192515
192313
|
return [];
|
|
@@ -200130,7 +199928,7 @@ async function start(context2, platform2) {
|
|
|
200130
199928
|
if (secretStorage instanceof VSCodeSecretStorage) {
|
|
200131
199929
|
secretStorage.setStorage(context2.secrets);
|
|
200132
199930
|
}
|
|
200133
|
-
setLogger({ logDebug, logError: logError$1 });
|
|
199931
|
+
setLogger({ logDebug, logError: logError$1, logInfo });
|
|
200134
199932
|
setClientCapabilities({
|
|
200135
199933
|
configuration: getConfiguration(),
|
|
200136
199934
|
agentCapabilities: platform2.extensionClient.capabilities
|
|
@@ -200272,13 +200070,6 @@ const register = async (context2, platform2, isExtensionModeDevOrTest) => {
|
|
|
200272
200070
|
})
|
|
200273
200071
|
)
|
|
200274
200072
|
);
|
|
200275
|
-
if (isPlgEsAccessDisabled()) {
|
|
200276
|
-
const endpoints = localStorage.getEndpointHistory() || [];
|
|
200277
|
-
const endpointsToLogout = endpoints.filter(
|
|
200278
|
-
(endpoint) => isDotCom({ endpoint }) || isWorkspaceInstance({ endpoint })
|
|
200279
|
-
);
|
|
200280
|
-
void Promise.all(endpointsToLogout.map((endpoint) => signOut(endpoint)));
|
|
200281
|
-
}
|
|
200282
200073
|
disposables.push(
|
|
200283
200074
|
subscriptionDisposable(
|
|
200284
200075
|
resolvedConfig.subscribe((config) => {
|