@sourcegraph/cody-web 0.36.0 → 0.38.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/dist/{agent.worker-CF9GgIzt.mjs → agent.worker-Bm74MuX8.mjs} +1491 -499
- package/dist/agent.worker.js +2 -2
- package/dist/{git-log-Dihxu1-Z.mjs → git-log-DjCz8t7A.mjs} +1 -1
- package/dist/index-CQZWUrDD.mjs +1071 -0
- package/dist/index.js +17 -20
- package/dist/{lite-CQAWMpwn.mjs → lite-BPYOwOSx.mjs} +1 -1
- package/dist/style.css +15 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{util-D8ltdME7.mjs → util-Ci-ROool.mjs} +1 -1
- package/dist/{vscode-shim-Csgwpsv8.mjs → vscode-shim-CdmSM8Q0.mjs} +1490 -486
- package/package.json +3 -3
|
@@ -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 {
|
|
22
|
-
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-
|
|
21
|
+
import { dt as Observable, dX as unsubscribe, dY as AsyncSerialScheduler, de as authStatus, cB as pick, cF as distinctUntilChanged$1, c$ as switchMapReplayOperation, c_ as pendingOperation, co as promiseFactoryToObservable, dw as map$1, a as isError$3, cZ as retry$1, a8 as logError$1, d1 as firstResultFromOperation, aD as graphqlClient, ag as isDotCom, dZ as semver, cP as debounceTime, d_ as interval, cX as filter$3, cJ as startWith$1, cN as switchMap$1, ci as firstValueFrom$1, d0 as skipPendingOperation, a7 as logDebug, i as isAbortError, d$ as expand, dK as LRUCache$1, e0 as TRANSIENT_REFETCH_INTERVAL_HINT, aR as createSubscriber, cw as fromVSCodeEvent, dv as isEqual, dc as cenv, dS as lodashExports, aG as EXCLUDE_EVERYTHING_CONTEXT_FILTERS, J as isFileURI, w as wrapInActiveSpan, aF as INCLUDE_EVERYTHING_CONTEXT_FILTERS, bn as onAbort, bN as CHAT_INPUT_TOKEN_BUDGET, bP as CHAT_OUTPUT_TOKEN_BUDGET, M as ModelTag, bS as EXTENDED_CHAT_INPUT_TOKEN_BUDGET, bR as EXTENDED_USER_CONTEXT_TOKEN_BUDGET, ae as addCodyClientIdentificationHeaders, bw as addTraceparent, bM as addAuthHeaders, bI as fetch$2, e1 as verifyResponseCode, ct as combineLatest$1, cK as take$2, d7 as clientCapabilities, cC as shareReplay$1, cG as tap$2, a3 as featureFlagProvider, a2 as FeatureFlag, bs as telemetryRecorder, dh as currentAuthStatusOrNotReadyYet, dj as mockAuthStatus, cO as storeLastValue, d4 as resolvedConfig, bD as AUTH_STATUS_FIXTURE_AUTHED_DOTCOM, bF as ps, e2 as logInfo, a5 as GuardrailsMode, d5 as currentResolvedConfig, bE as PromptString, bT as CodyIDE, T as displayPath, bQ as CORPUS_CONTEXT_ALLOCATION, bz as recordErrorToSpan, aa as addClientInfoParams, bm as dependentAbortController, aY as FILE_CONTEXT_MENTION_PROVIDER, aZ as SYMBOL_CONTEXT_MENTION_PROVIDER, b0 as REMOTE_REPOSITORY_PROVIDER_URI, b1 as REMOTE_FILE_PROVIDER_URI, b2 as REMOTE_DIRECTORY_PROVIDER_URI, b3 as WEB_PROVIDER_URI, C as ContextItemSource, bd as isS2, b4 as GIT_OPENCTX_PROVIDER_URI, b5 as CODE_SEARCH_PROVIDER_URI, dJ as cryptoJsExports, b7 as currentOpenCtxController, c as URI, e3 as MulticastSubject, e4 as AsyncSerialScheduler_1, dn as getDefaultExportFromCjs, e5 as workspace, p as path$1, e6 as vscode, e7 as Range, e8 as commands$1, e9 as window$1, ea as Selection, U as Uri, eb as AgentEventEmitter, ec as MarkdownString, ed as Disposable, ee as TextEditorRevealType, ef as ThemeIcon, eg as StatusBarAlignment, eh as readFile, ei as env, ej as UIKind, ek as languages$1, dm as commonjsGlobal, an as InvalidAccessTokenError, el as _baseAssignValue, em as eq_1, en as isArrayLike_1, eo as isObjectLike_1, ep as _copyObject, eq as keysIn_1, er as _cloneBufferExports, es as _cloneTypedArray, et as _copyArray, eu as _initCloneObject, ev as isArguments_1, ew as isArray_1, ex as isBufferExports, ey as isFunction_1, ez as isObject_1, eA as isPlainObject_1, eB as isTypedArray_1, eC as _Stack, eD as identity_1, eE as _overRest, eF as _setToString, eG as _isIndex, dx as isSourcegraphToken, dR as v4, eH as CONFIG_KEY, bU as CodyAutoSuggestionMode, eI as ConfigurationTarget, eJ as appendFileSync, eK as pathBrowserify, eL as stat, eM as extensions, eN as version$2, d9 as setExtensionVersion, eO as normalizeServerEndpointURL, ax as isInvalidAccessTokenError, eP as isOAuthProviderError, af as DOTCOM_URL, ay as isNeedsAuthChallengeError, cq as EMPTY$1, cf as disposableSubscription, eQ as externalAuthRefresh, dd as setAuthStatusObservable, av as isAvailabilityError, aj as AuthConfigError, be as isWorkspaceInstance, aC as SourcegraphGraphQLAPIClient, eR as isExternalAuthProviderError, aA as isNetworkLikeError, ao as NeedsAuthChallengeError, al as AvailabilityError, df as currentAuthStatus, eS as resolveAuth, eT as QuickPickItemKind, eU as revokeOAuthTokens, bL as getAuthHeaders, eV as toLightweightChatTranscript, S as SUPPORTED_URI_SCHEMAS, eW as RelativePattern, eX as _baseIsEqual, eY as keys_1, eZ as _baseGet, e_ as _castPath, e$ as isLength_1, f0 as _toKey, f1 as _isKey, f2 as toNumber_1, f3 as _baseFindIndex, f4 as require$$0$2, ap as NetworkError, aB as isRateLimitError, au as isAuthError, f5 as FileType, f6 as dedent$1, f7 as FoldingRange, f8 as CancellationTokenSource, f9 as SymbolKind, aQ as convertGitCloneURLToCodebaseName, b as isDefined, cA as pluck, t as toRangeData, fa as Position, D as DefaultChatCommands, A as pathFunctionsForURI, R as uriParseNameAndExtension, O as uriDirname, fb as Utils$1, Q as uriExtname, K as uriBasename, h as DefaultEditCommands, ce as subscriptionDisposable, bt as updateGlobalTelemetryInstances, aN as TelemetryRecorderProvider, br as telemetryRecorderProvider, bf as createGitDiff, fc as AgentWorkspaceEdit, fd as TextDocumentChangeReason, fe as omit$1, bo as getEditorInsertSpaces, ff as escapeRegExp$1, ar as TimeoutError, az as isNetworkError, Z as displayPathWithoutWorkspaceFolderPrefix, fg as http, fh as open, cW as defer$2, cs as merge$2, cT as abortableOperation, bl as ruleSearchPaths, bi as isRuleFilename, bk as parseRuleFile, q as languageFromFilename, m as displayLineRange, bj as ruleTitle, fi as debounce_1, k as isErrorLike, d as isWindows, b6 as GLOBAL_SEARCH_PROVIDER_URI, aW as mentionProvidersMetadata, fj as ThemeColor, fk as QuickInputButtons, aV as scanForMentionTriggerInUserTextInput, aU as parseMentionQuery, L as LARGE_FILE_WARNING_LABEL, G as GENERAL_HELP_LABEL, dI as CodyTaskState, fl as CodeLens, fm as defaultWebviewPanel, cd as createExtensionAPI, bb as createMessageAPIForWebview, y as isMatlabFile, fn as EndOfLine, fo as ViewColumn, fp as Location, fq as onDidChangeActiveTextEditor, fr as tabGroups, fs as workspaceTextDocuments, ft as visibleTextEditors, fu as onDidChangeVisibleTextEditors, fv as fs, fw as onDidCloseTextDocument, fx as setCreateWebviewPanel, fy as getAugmentedNamespace, fz as extensionConfiguration, fA as existsSync, fB as rmSync, fC as mkdirSync, fD as main$1, fE as setAgent, fF as setWorkspaceDocuments, fG as setLastOpenedWorkspaceFolder, fH as onDidRegisterNewCodeActionProvider, fI as onDidUnregisterNewCodeActionProvider, fJ as onDidRegisterNewCodeLensProvider, fK as onDidUnregisterNewCodeLensProvider, fL as setClientInfo, di as firstNonPendingAuthStatus, fM as workspaceFolders$1, fN as setWorkspaceFolders, fO as onDidChangeWorkspaceFolders, fP as onDidChangeWindowState, fQ as onDidOpenTextDocument, fR as onDidSaveTextDocument, fS as onDidRenameFiles, fT as packageJson, fU as progressBars, fV as CodeActionTriggerKind, fW as CodeAction, fX as UriString, fY as DiagnosticSeverity, fZ as diagnostics, f_ as isIntegrationTesting, f$ as TESTING_TELEMETRY_EXPORTER, g0 as ProgressLocation, g1 as dist, g2 as completionProvider, g3 as InlineCompletionTriggerKind, dg as currentAuthStatusAuthed, ck as waitUntilComplete, g4 as setExtensionConfiguration, g5 as onDidChangeConfiguration, g6 as onDidChangeTextDocument, g7 as onDidChangeTextEditorSelection, g8 as statSync, g9 as copySync, E as isMacOS, g as CustomCommandType, _ as setDisplayPathEnvInfo, dU as ACCOUNT_USAGE_URL, ga as getOIDCConfiguration$1, gb as getOAuthClientId, gc as OAuthCredential, du as debounce$1, gd as structuredPatch, j as dedupeWith$1, ai as AbortError, cz as createDisposables, aE as isNodeResponse, ab as getClientInfoQueryParams, bu as tracer, bv as getActiveTraceAndSpanId, ac as getClientIdentificationHeaders, aI as setJSONAcceptContentTypeHeaders, bx as logResponseHeadersToSpan, aJ as isCustomAuthChallengeResponse, as as TracedError, dA as SpanStatusCode, aq as RateLimitError$1, ge as capitalize, gf as InlineCompletionItem, gg as createTwoFilesPatch, gh as vsCodeMocks, dD as whitespace, dB as svg, dE as find$1, dF as stringify$1, dG as stringify$2, dH as ccount, dC as html$3, bp as getEditorTabSize$1, gi as metrics, gj as _, c6 as deserializeContextItem, c2 as editorStateFromPromptString, gk as _baseGetTag, at as isAbortErrorOrSocketHangUp, b_ as inputTextWithoutContextChipsFromPromptEditorState, dL as DeepCodyAgentID, gl as exec, s as spawn, dk as UIToolStatus, W as displayPathBasename, o as expandToLineRange, a$ as openctxController, aX as openCtxProviderMetadata, e as CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID, cU as catchError$1, dP as diffWithLineNum, dl as UITerminalOutputType, gm as getPlatform$1, aH as PromptMode, cL as skip$1, dz as context, bA as extractContextFromTraceparent, aw as isContextWindowLimitError, c5 as serializeContextItem, a0 as forceHydration, r as reformatBotMessageForChat, a1 as hydrateAfterPostMessage, ba as addMessageListenersForExtensionAPI, bc as createMessageAPIForExtension, dM as View, dT as ChatHistoryType, cr as NEVER$1, gn as CodeActionKind, l as pluralize, H as assertFileURI, b8 as RULES_PROVIDER_URI, go as createCodeSearchProvider, u as languageFromFilenameAndContent, P as ProgrammingLanguage, bG as psDedent, gp as formatRuleForPrompt, z as posixFilePaths, gq as DecorationRangeBehavior, gr as diffLines, gs as CODY_SUPPORT_URL, gt as CODY_DOC_URL, gu as DISCORD_URL, bJ as globalAgentRef, gv as VSCODE_CHANGELOG_URL, gw as SG_CHANGELOG_URL, gx as ACCOUNT_LIMITS_INFO_URL, aP as assertUnreachable, aT as promise, gy as ExtensionMode, a9 as setLogger, d8 as setClientCapabilities, d2 as setResolvedConfigurationObservable, ad as setClientNameVersion, a_ as setOpenCtxControllerObservable, dW as browser$4 } from "./vscode-shim-CdmSM8Q0.mjs";
|
|
22
|
+
import { r as requireUtil, i as inherits_browserExports, a as utilExports } from "./util-Ci-ROool.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");
|
|
@@ -157,6 +157,10 @@ function getPlugin(pluginKey) {
|
|
|
157
157
|
}
|
|
158
158
|
return plugin;
|
|
159
159
|
}
|
|
160
|
+
function loadPlugin(pluginKey, implementation) {
|
|
161
|
+
if (!plugins[pluginKey])
|
|
162
|
+
plugins[pluginKey] = implementation;
|
|
163
|
+
}
|
|
160
164
|
var currentScope;
|
|
161
165
|
function getCurrentScope$1() {
|
|
162
166
|
return currentScope;
|
|
@@ -637,6 +641,254 @@ function currentImpl(value) {
|
|
|
637
641
|
}
|
|
638
642
|
return copy2;
|
|
639
643
|
}
|
|
644
|
+
function enableMapSet() {
|
|
645
|
+
class DraftMap extends Map {
|
|
646
|
+
constructor(target, parent) {
|
|
647
|
+
super();
|
|
648
|
+
this[DRAFT_STATE] = {
|
|
649
|
+
type_: 2,
|
|
650
|
+
parent_: parent,
|
|
651
|
+
scope_: parent ? parent.scope_ : getCurrentScope$1(),
|
|
652
|
+
modified_: false,
|
|
653
|
+
finalized_: false,
|
|
654
|
+
copy_: void 0,
|
|
655
|
+
assigned_: void 0,
|
|
656
|
+
base_: target,
|
|
657
|
+
draft_: this,
|
|
658
|
+
isManual_: false,
|
|
659
|
+
revoked_: false
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
get size() {
|
|
663
|
+
return latest(this[DRAFT_STATE]).size;
|
|
664
|
+
}
|
|
665
|
+
has(key2) {
|
|
666
|
+
return latest(this[DRAFT_STATE]).has(key2);
|
|
667
|
+
}
|
|
668
|
+
set(key2, value) {
|
|
669
|
+
const state2 = this[DRAFT_STATE];
|
|
670
|
+
assertUnrevoked(state2);
|
|
671
|
+
if (!latest(state2).has(key2) || latest(state2).get(key2) !== value) {
|
|
672
|
+
prepareMapCopy(state2);
|
|
673
|
+
markChanged(state2);
|
|
674
|
+
state2.assigned_.set(key2, true);
|
|
675
|
+
state2.copy_.set(key2, value);
|
|
676
|
+
state2.assigned_.set(key2, true);
|
|
677
|
+
}
|
|
678
|
+
return this;
|
|
679
|
+
}
|
|
680
|
+
delete(key2) {
|
|
681
|
+
if (!this.has(key2)) {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
const state2 = this[DRAFT_STATE];
|
|
685
|
+
assertUnrevoked(state2);
|
|
686
|
+
prepareMapCopy(state2);
|
|
687
|
+
markChanged(state2);
|
|
688
|
+
if (state2.base_.has(key2)) {
|
|
689
|
+
state2.assigned_.set(key2, false);
|
|
690
|
+
} else {
|
|
691
|
+
state2.assigned_.delete(key2);
|
|
692
|
+
}
|
|
693
|
+
state2.copy_.delete(key2);
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
clear() {
|
|
697
|
+
const state2 = this[DRAFT_STATE];
|
|
698
|
+
assertUnrevoked(state2);
|
|
699
|
+
if (latest(state2).size) {
|
|
700
|
+
prepareMapCopy(state2);
|
|
701
|
+
markChanged(state2);
|
|
702
|
+
state2.assigned_ = /* @__PURE__ */ new Map();
|
|
703
|
+
each(state2.base_, (key2) => {
|
|
704
|
+
state2.assigned_.set(key2, false);
|
|
705
|
+
});
|
|
706
|
+
state2.copy_.clear();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
forEach(cb, thisArg) {
|
|
710
|
+
const state2 = this[DRAFT_STATE];
|
|
711
|
+
latest(state2).forEach((_value, key2, _map) => {
|
|
712
|
+
cb.call(thisArg, this.get(key2), key2, this);
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
get(key2) {
|
|
716
|
+
const state2 = this[DRAFT_STATE];
|
|
717
|
+
assertUnrevoked(state2);
|
|
718
|
+
const value = latest(state2).get(key2);
|
|
719
|
+
if (state2.finalized_ || !isDraftable(value)) {
|
|
720
|
+
return value;
|
|
721
|
+
}
|
|
722
|
+
if (value !== state2.base_.get(key2)) {
|
|
723
|
+
return value;
|
|
724
|
+
}
|
|
725
|
+
const draft = createProxy(value, state2);
|
|
726
|
+
prepareMapCopy(state2);
|
|
727
|
+
state2.copy_.set(key2, draft);
|
|
728
|
+
return draft;
|
|
729
|
+
}
|
|
730
|
+
keys() {
|
|
731
|
+
return latest(this[DRAFT_STATE]).keys();
|
|
732
|
+
}
|
|
733
|
+
values() {
|
|
734
|
+
const iterator = this.keys();
|
|
735
|
+
return {
|
|
736
|
+
[Symbol.iterator]: () => this.values(),
|
|
737
|
+
next: () => {
|
|
738
|
+
const r2 = iterator.next();
|
|
739
|
+
if (r2.done)
|
|
740
|
+
return r2;
|
|
741
|
+
const value = this.get(r2.value);
|
|
742
|
+
return {
|
|
743
|
+
done: false,
|
|
744
|
+
value
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
entries() {
|
|
750
|
+
const iterator = this.keys();
|
|
751
|
+
return {
|
|
752
|
+
[Symbol.iterator]: () => this.entries(),
|
|
753
|
+
next: () => {
|
|
754
|
+
const r2 = iterator.next();
|
|
755
|
+
if (r2.done)
|
|
756
|
+
return r2;
|
|
757
|
+
const value = this.get(r2.value);
|
|
758
|
+
return {
|
|
759
|
+
done: false,
|
|
760
|
+
value: [r2.value, value]
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
[Symbol.iterator]() {
|
|
766
|
+
return this.entries();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function proxyMap_(target, parent) {
|
|
770
|
+
return new DraftMap(target, parent);
|
|
771
|
+
}
|
|
772
|
+
function prepareMapCopy(state2) {
|
|
773
|
+
if (!state2.copy_) {
|
|
774
|
+
state2.assigned_ = /* @__PURE__ */ new Map();
|
|
775
|
+
state2.copy_ = new Map(state2.base_);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
class DraftSet extends Set {
|
|
779
|
+
constructor(target, parent) {
|
|
780
|
+
super();
|
|
781
|
+
this[DRAFT_STATE] = {
|
|
782
|
+
type_: 3,
|
|
783
|
+
parent_: parent,
|
|
784
|
+
scope_: parent ? parent.scope_ : getCurrentScope$1(),
|
|
785
|
+
modified_: false,
|
|
786
|
+
finalized_: false,
|
|
787
|
+
copy_: void 0,
|
|
788
|
+
base_: target,
|
|
789
|
+
draft_: this,
|
|
790
|
+
drafts_: /* @__PURE__ */ new Map(),
|
|
791
|
+
revoked_: false,
|
|
792
|
+
isManual_: false
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
get size() {
|
|
796
|
+
return latest(this[DRAFT_STATE]).size;
|
|
797
|
+
}
|
|
798
|
+
has(value) {
|
|
799
|
+
const state2 = this[DRAFT_STATE];
|
|
800
|
+
assertUnrevoked(state2);
|
|
801
|
+
if (!state2.copy_) {
|
|
802
|
+
return state2.base_.has(value);
|
|
803
|
+
}
|
|
804
|
+
if (state2.copy_.has(value))
|
|
805
|
+
return true;
|
|
806
|
+
if (state2.drafts_.has(value) && state2.copy_.has(state2.drafts_.get(value)))
|
|
807
|
+
return true;
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
add(value) {
|
|
811
|
+
const state2 = this[DRAFT_STATE];
|
|
812
|
+
assertUnrevoked(state2);
|
|
813
|
+
if (!this.has(value)) {
|
|
814
|
+
prepareSetCopy(state2);
|
|
815
|
+
markChanged(state2);
|
|
816
|
+
state2.copy_.add(value);
|
|
817
|
+
}
|
|
818
|
+
return this;
|
|
819
|
+
}
|
|
820
|
+
delete(value) {
|
|
821
|
+
if (!this.has(value)) {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
const state2 = this[DRAFT_STATE];
|
|
825
|
+
assertUnrevoked(state2);
|
|
826
|
+
prepareSetCopy(state2);
|
|
827
|
+
markChanged(state2);
|
|
828
|
+
return state2.copy_.delete(value) || (state2.drafts_.has(value) ? state2.copy_.delete(state2.drafts_.get(value)) : (
|
|
829
|
+
/* istanbul ignore next */
|
|
830
|
+
false
|
|
831
|
+
));
|
|
832
|
+
}
|
|
833
|
+
clear() {
|
|
834
|
+
const state2 = this[DRAFT_STATE];
|
|
835
|
+
assertUnrevoked(state2);
|
|
836
|
+
if (latest(state2).size) {
|
|
837
|
+
prepareSetCopy(state2);
|
|
838
|
+
markChanged(state2);
|
|
839
|
+
state2.copy_.clear();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
values() {
|
|
843
|
+
const state2 = this[DRAFT_STATE];
|
|
844
|
+
assertUnrevoked(state2);
|
|
845
|
+
prepareSetCopy(state2);
|
|
846
|
+
return state2.copy_.values();
|
|
847
|
+
}
|
|
848
|
+
entries() {
|
|
849
|
+
const state2 = this[DRAFT_STATE];
|
|
850
|
+
assertUnrevoked(state2);
|
|
851
|
+
prepareSetCopy(state2);
|
|
852
|
+
return state2.copy_.entries();
|
|
853
|
+
}
|
|
854
|
+
keys() {
|
|
855
|
+
return this.values();
|
|
856
|
+
}
|
|
857
|
+
[Symbol.iterator]() {
|
|
858
|
+
return this.values();
|
|
859
|
+
}
|
|
860
|
+
forEach(cb, thisArg) {
|
|
861
|
+
const iterator = this.values();
|
|
862
|
+
let result = iterator.next();
|
|
863
|
+
while (!result.done) {
|
|
864
|
+
cb.call(thisArg, result.value, result.value, this);
|
|
865
|
+
result = iterator.next();
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function proxySet_(target, parent) {
|
|
870
|
+
return new DraftSet(target, parent);
|
|
871
|
+
}
|
|
872
|
+
function prepareSetCopy(state2) {
|
|
873
|
+
if (!state2.copy_) {
|
|
874
|
+
state2.copy_ = /* @__PURE__ */ new Set();
|
|
875
|
+
state2.base_.forEach((value) => {
|
|
876
|
+
if (isDraftable(value)) {
|
|
877
|
+
const draft = createProxy(value, state2);
|
|
878
|
+
state2.drafts_.set(value, draft);
|
|
879
|
+
state2.copy_.add(draft);
|
|
880
|
+
} else {
|
|
881
|
+
state2.copy_.add(value);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
function assertUnrevoked(state2) {
|
|
887
|
+
if (state2.revoked_)
|
|
888
|
+
die$1(3, JSON.stringify(latest(state2)));
|
|
889
|
+
}
|
|
890
|
+
loadPlugin("MapSet", { proxyMap_, proxySet_ });
|
|
891
|
+
}
|
|
640
892
|
var immer = new Immer2();
|
|
641
893
|
var produce = immer.produce;
|
|
642
894
|
immer.produceWithPatches.bind(
|
|
@@ -697,13 +949,13 @@ function filter$2(test) {
|
|
|
697
949
|
});
|
|
698
950
|
};
|
|
699
951
|
}
|
|
700
|
-
var define_process_default$
|
|
952
|
+
var define_process_default$p = { env: {} };
|
|
701
953
|
let _editorWindowIsFocused;
|
|
702
954
|
function setEditorWindowIsFocused(editorWindowIsFocused2) {
|
|
703
955
|
_editorWindowIsFocused = editorWindowIsFocused2;
|
|
704
956
|
}
|
|
705
957
|
function editorWindowIsFocused() {
|
|
706
|
-
if (define_process_default$
|
|
958
|
+
if (define_process_default$p.env.VITEST) {
|
|
707
959
|
return true;
|
|
708
960
|
}
|
|
709
961
|
if (!_editorWindowIsFocused) {
|
|
@@ -742,7 +994,7 @@ const siteVersion = authStatus.pipe(
|
|
|
742
994
|
retry$1(3),
|
|
743
995
|
map$1((siteVersion2) => {
|
|
744
996
|
if (isError$3(siteVersion2)) {
|
|
745
|
-
logError$
|
|
997
|
+
logError$1("siteVersion", `Failed to get site version: ${siteVersion2}`);
|
|
746
998
|
return null;
|
|
747
999
|
}
|
|
748
1000
|
return siteVersion2;
|
|
@@ -753,7 +1005,7 @@ async function currentSiteVersion() {
|
|
|
753
1005
|
const authStatus2 = await firstResultFromOperation(authStatusAuthed);
|
|
754
1006
|
const siteVersion2 = await graphqlClient.getSiteVersion();
|
|
755
1007
|
if (isError$3(siteVersion2)) {
|
|
756
|
-
logError$
|
|
1008
|
+
logError$1("siteVersion", `Failed to get site version from ${authStatus2.endpoint}: ${siteVersion2}`);
|
|
757
1009
|
return siteVersion2;
|
|
758
1010
|
}
|
|
759
1011
|
const isDotComUser = isDotCom(authStatus2);
|
|
@@ -830,7 +1082,7 @@ function parseDateFromPreReleaseVersion(version2) {
|
|
|
830
1082
|
return void 0;
|
|
831
1083
|
}
|
|
832
1084
|
}
|
|
833
|
-
var define_process_default$
|
|
1085
|
+
var define_process_default$o = { env: {} };
|
|
834
1086
|
const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
835
1087
|
constructor() {
|
|
836
1088
|
// Default values for the legacy GraphQL features API, used when a Sourcegraph instance
|
|
@@ -888,7 +1140,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
888
1140
|
return await firstValueFrom$1(this.changes.pipe(skipPendingOperation()), signal2);
|
|
889
1141
|
}
|
|
890
1142
|
async fetchConfig(signal2) {
|
|
891
|
-
logDebug
|
|
1143
|
+
logDebug("ClientConfigSingleton", "refreshing configuration");
|
|
892
1144
|
let omniBoxEnabled = false;
|
|
893
1145
|
return graphqlClient.getSiteVersion(signal2).then((siteVersion2) => {
|
|
894
1146
|
signal2 == null ? void 0 : signal2.throwIfAborted();
|
|
@@ -896,7 +1148,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
896
1148
|
if (isAbortError(siteVersion2)) {
|
|
897
1149
|
throw siteVersion2;
|
|
898
1150
|
}
|
|
899
|
-
logError$
|
|
1151
|
+
logError$1(
|
|
900
1152
|
"ClientConfigSingleton",
|
|
901
1153
|
"Failed to determine site version, GraphQL error",
|
|
902
1154
|
siteVersion2
|
|
@@ -923,7 +1175,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
923
1175
|
return this.fetchConfigEndpoint(signal2);
|
|
924
1176
|
}).then(async (clientConfig) => {
|
|
925
1177
|
signal2 == null ? void 0 : signal2.throwIfAborted();
|
|
926
|
-
logDebug
|
|
1178
|
+
logDebug("ClientConfigSingleton", "refreshed", JSON.stringify(clientConfig));
|
|
927
1179
|
return Promise.all([
|
|
928
1180
|
graphqlClient.viewerSettings(signal2),
|
|
929
1181
|
graphqlClient.codeSearchEnabled(signal2)
|
|
@@ -949,7 +1201,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
949
1201
|
});
|
|
950
1202
|
}).catch((e) => {
|
|
951
1203
|
if (!isAbortError(e)) {
|
|
952
|
-
logError$
|
|
1204
|
+
logError$1("ClientConfigSingleton", "failed to refresh client config", e);
|
|
953
1205
|
}
|
|
954
1206
|
throw e;
|
|
955
1207
|
});
|
|
@@ -978,7 +1230,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
978
1230
|
async fetchConfigFeaturesLegacy(defaultErrorValue, signal2) {
|
|
979
1231
|
const features2 = await graphqlClient.getCodyConfigFeatures(signal2);
|
|
980
1232
|
if (features2 instanceof Error) {
|
|
981
|
-
logError$
|
|
1233
|
+
logError$1("ClientConfigSingleton", "refreshConfig", features2);
|
|
982
1234
|
return defaultErrorValue;
|
|
983
1235
|
}
|
|
984
1236
|
return features2;
|
|
@@ -1014,7 +1266,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
|
|
|
1014
1266
|
};
|
|
1015
1267
|
__publicField2(_ClientConfigSingleton, "instance");
|
|
1016
1268
|
// REFETCH_INTERVAL is only updated via process.env during test execution, otherwise it is 60 seconds.
|
|
1017
|
-
__publicField2(_ClientConfigSingleton, "REFETCH_INTERVAL", define_process_default$
|
|
1269
|
+
__publicField2(_ClientConfigSingleton, "REFETCH_INTERVAL", define_process_default$o.env.CODY_CLIENT_CONFIG_SINGLETON_REFETCH_INTERVAL ? Number.parseInt(define_process_default$o.env.CODY_CLIENT_CONFIG_SINGLETON_REFETCH_INTERVAL, 10) : 60 * 1e3);
|
|
1018
1270
|
let ClientConfigSingleton = _ClientConfigSingleton;
|
|
1019
1271
|
const configOverwrites = authStatus.pipe(
|
|
1020
1272
|
pick("authenticated", "endpoint", "pendingValidation"),
|
|
@@ -1032,7 +1284,7 @@ const configOverwrites = authStatus.pipe(
|
|
|
1032
1284
|
).pipe(
|
|
1033
1285
|
map$1((result) => {
|
|
1034
1286
|
if (isError$3(result)) {
|
|
1035
|
-
logError$
|
|
1287
|
+
logError$1(
|
|
1036
1288
|
"configOverwrites",
|
|
1037
1289
|
`Failed to get Cody LLM configuration from ${authStatus2.endpoint}: ${result}`
|
|
1038
1290
|
);
|
|
@@ -1047,7 +1299,7 @@ const configOverwrites = authStatus.pipe(
|
|
|
1047
1299
|
// the operation catches its own errors, so errors will never get here
|
|
1048
1300
|
);
|
|
1049
1301
|
configOverwrites.subscribe({});
|
|
1050
|
-
var define_process_default$
|
|
1302
|
+
var define_process_default$n = { env: {} };
|
|
1051
1303
|
const version$1 = "0.5.1";
|
|
1052
1304
|
class ResponseError extends Error {
|
|
1053
1305
|
constructor(error, status_code) {
|
|
@@ -1087,8 +1339,8 @@ const checkOk = async (response) => {
|
|
|
1087
1339
|
function getPlatform() {
|
|
1088
1340
|
if (typeof window !== "undefined" && window.navigator) {
|
|
1089
1341
|
return `${window.navigator.platform.toLowerCase()} Browser/${navigator.userAgent};`;
|
|
1090
|
-
} else if (typeof define_process_default$
|
|
1091
|
-
return `${define_process_default$
|
|
1342
|
+
} else if (typeof define_process_default$n !== "undefined") {
|
|
1343
|
+
return `${define_process_default$n.arch} ${define_process_default$n.platform} Node.js/${define_process_default$n.version}`;
|
|
1092
1344
|
}
|
|
1093
1345
|
return "";
|
|
1094
1346
|
}
|
|
@@ -1953,7 +2205,7 @@ let AST = _AST;
|
|
|
1953
2205
|
const escape$1 = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
1954
2206
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1955
2207
|
};
|
|
1956
|
-
var define_process_default$
|
|
2208
|
+
var define_process_default$m = { env: {} };
|
|
1957
2209
|
const minimatch = (p2, pattern, options = {}) => {
|
|
1958
2210
|
assertValidPattern(pattern);
|
|
1959
2211
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
@@ -2011,7 +2263,7 @@ const qmarksTestNoExtDot = ([$0]) => {
|
|
|
2011
2263
|
const len2 = $0.length;
|
|
2012
2264
|
return (f) => f.length === len2 && f !== "." && f !== "..";
|
|
2013
2265
|
};
|
|
2014
|
-
const defaultPlatform = typeof define_process_default$
|
|
2266
|
+
const defaultPlatform = typeof define_process_default$m === "object" && define_process_default$m ? typeof define_process_default$m.env === "object" && define_process_default$m.env && define_process_default$m.env.__MINIMATCH_TESTING_PLATFORM__ || define_process_default$m.platform : "posix";
|
|
2015
2267
|
const path = {
|
|
2016
2268
|
win32: { sep: "\\" },
|
|
2017
2269
|
posix: { sep: "/" }
|
|
@@ -7782,7 +8034,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
7782
8034
|
this.setContextFilters(filters);
|
|
7783
8035
|
return refetchIntervalHint;
|
|
7784
8036
|
} catch (error) {
|
|
7785
|
-
logError$
|
|
8037
|
+
logError$1("ContextFiltersProvider", "fetchContextFilters", {
|
|
7786
8038
|
verbose: error
|
|
7787
8039
|
});
|
|
7788
8040
|
return TRANSIENT_REFETCH_INTERVAL_HINT;
|
|
@@ -7805,7 +8057,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
7805
8057
|
this.parsedContextFilters = null;
|
|
7806
8058
|
this.lastContextFiltersResponse = canonicalizeContextFilters(contextFilters);
|
|
7807
8059
|
if (!cenv.CODY_TESTING_LOG_SUPRESS_VERBOSE) {
|
|
7808
|
-
logDebug
|
|
8060
|
+
logDebug("ContextFiltersProvider", "setContextFilters", {
|
|
7809
8061
|
verbose: contextFilters
|
|
7810
8062
|
});
|
|
7811
8063
|
}
|
|
@@ -7894,7 +8146,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
7894
8146
|
return maybeError;
|
|
7895
8147
|
}
|
|
7896
8148
|
if (!isFileURI(uri)) {
|
|
7897
|
-
logDebug
|
|
8149
|
+
logDebug("ContextFiltersProvider", "isUriIgnored", `non-file URI ${uri.scheme}`);
|
|
7898
8150
|
return "non-file-uri";
|
|
7899
8151
|
}
|
|
7900
8152
|
if (!_ContextFiltersProvider.repoNameResolver) {
|
|
@@ -7935,7 +8187,7 @@ const _ContextFiltersProvider = class _ContextFiltersProvider {
|
|
|
7935
8187
|
}
|
|
7936
8188
|
return patterns.some((pattern) => minimatch(relativePath, pattern, { dot: true }));
|
|
7937
8189
|
} catch (error) {
|
|
7938
|
-
logDebug
|
|
8190
|
+
logDebug("ContextFiltersProvider", "isExcludedByPatterns error", { error });
|
|
7939
8191
|
return false;
|
|
7940
8192
|
}
|
|
7941
8193
|
}
|
|
@@ -8074,6 +8326,9 @@ var ModelUsage = /* @__PURE__ */ ((ModelUsage2) => {
|
|
|
8074
8326
|
const ANSWER_TOKENS = 1e3;
|
|
8075
8327
|
const MAX_CURRENT_FILE_TOKENS = 1e3;
|
|
8076
8328
|
const SURROUNDING_LINES = 50;
|
|
8329
|
+
const NUM_CODE_RESULTS = 12;
|
|
8330
|
+
const NUM_TEXT_RESULTS = 3;
|
|
8331
|
+
const MAX_BYTES_PER_FILE = 4096;
|
|
8077
8332
|
function getProviderName(name2) {
|
|
8078
8333
|
const providerName = name2.toLowerCase();
|
|
8079
8334
|
switch (providerName) {
|
|
@@ -8101,6 +8356,10 @@ function isCustomModel(model2) {
|
|
|
8101
8356
|
function modelHasTag(model2, modelTag) {
|
|
8102
8357
|
return model2.tags.includes(modelTag);
|
|
8103
8358
|
}
|
|
8359
|
+
function toModelRefStr(modelRef) {
|
|
8360
|
+
const { providerId, apiVersionId, modelId } = modelRef;
|
|
8361
|
+
return `${providerId}::${apiVersionId}::${modelId}`;
|
|
8362
|
+
}
|
|
8104
8363
|
function getEnterpriseContextWindow(chatModel, configOverwrites2, configuration) {
|
|
8105
8364
|
const { chatModelMaxTokens, smartContextWindow } = configOverwrites2;
|
|
8106
8365
|
let contextWindow2 = {
|
|
@@ -8121,7 +8380,7 @@ function applyLocalTokenLimitOverwrite({ providerLimitPrompt }, chatModel, conte
|
|
|
8121
8380
|
return { ...contextWindow2, input: providerLimitPrompt };
|
|
8122
8381
|
}
|
|
8123
8382
|
if (providerLimitPrompt) {
|
|
8124
|
-
logDebug
|
|
8383
|
+
logDebug(
|
|
8125
8384
|
"getEnterpriseContextWindow",
|
|
8126
8385
|
`Invalid token limit configured for ${chatModel}`,
|
|
8127
8386
|
providerLimitPrompt
|
|
@@ -8240,6 +8499,10 @@ function capabilityToUsage(capability) {
|
|
|
8240
8499
|
return [];
|
|
8241
8500
|
}
|
|
8242
8501
|
}
|
|
8502
|
+
function modelTier(model2) {
|
|
8503
|
+
const tierSet = /* @__PURE__ */ new Set([ModelTag.Pro, ModelTag.Enterprise]);
|
|
8504
|
+
return model2.tags.find((tag2) => tierSet.has(tag2)) ?? ModelTag.Free;
|
|
8505
|
+
}
|
|
8243
8506
|
function parseModelRef(ref) {
|
|
8244
8507
|
try {
|
|
8245
8508
|
const [providerId, apiVersionId, modelId] = ref.split("::", 3);
|
|
@@ -8257,6 +8520,9 @@ function parseModelRef(ref) {
|
|
|
8257
8520
|
};
|
|
8258
8521
|
}
|
|
8259
8522
|
}
|
|
8523
|
+
function toLegacyModel(modelRefOrID) {
|
|
8524
|
+
return parseModelRef(modelRefOrID).modelId || modelRefOrID;
|
|
8525
|
+
}
|
|
8260
8526
|
function getServerModelTags(capabilities, category, status, tier) {
|
|
8261
8527
|
const tags = [tier];
|
|
8262
8528
|
if (capabilities.includes("vision")) {
|
|
@@ -8277,7 +8543,7 @@ function getServerModelTags(capabilities, category, status, tier) {
|
|
|
8277
8543
|
}
|
|
8278
8544
|
return tags;
|
|
8279
8545
|
}
|
|
8280
|
-
createModel({
|
|
8546
|
+
const FIXTURE_MODEL = createModel({
|
|
8281
8547
|
id: "my-model",
|
|
8282
8548
|
usage: [ModelUsage.Chat],
|
|
8283
8549
|
tags: [ModelTag.Enterprise]
|
|
@@ -8350,7 +8616,7 @@ class RestClient {
|
|
|
8350
8616
|
if (isAbortError(serverSideConfig)) {
|
|
8351
8617
|
throw serverSideConfig;
|
|
8352
8618
|
}
|
|
8353
|
-
logError$
|
|
8619
|
+
logError$1("RestClient::getAvailableModels", "failed to fetch available models", {
|
|
8354
8620
|
verbose: serverSideConfig
|
|
8355
8621
|
});
|
|
8356
8622
|
return;
|
|
@@ -8423,7 +8689,7 @@ function syncModels({
|
|
|
8423
8689
|
}),
|
|
8424
8690
|
distinctUntilChanged$1(),
|
|
8425
8691
|
tap$2((preferences) => {
|
|
8426
|
-
logDebug
|
|
8692
|
+
logDebug("ModelsService", "User model preferences changed", JSON.stringify(preferences));
|
|
8427
8693
|
}),
|
|
8428
8694
|
shareReplay$1()
|
|
8429
8695
|
);
|
|
@@ -8439,7 +8705,7 @@ function syncModels({
|
|
|
8439
8705
|
const serverModelsConfig = clientConfig.pipe(
|
|
8440
8706
|
switchMapReplayOperation((maybeServerSideClientConfig) => {
|
|
8441
8707
|
if (maybeServerSideClientConfig == null ? void 0 : maybeServerSideClientConfig.modelsAPIEnabled) {
|
|
8442
|
-
logDebug
|
|
8708
|
+
logDebug("ModelsService", "new models API enabled");
|
|
8443
8709
|
return promiseFactoryToObservable(
|
|
8444
8710
|
(signal2) => fetchServerSideModels_(configWithEndpoint, signal2)
|
|
8445
8711
|
).pipe(
|
|
@@ -8634,7 +8900,7 @@ function syncModels({
|
|
|
8634
8900
|
distinctUntilChanged$1(),
|
|
8635
8901
|
tap$2((modelsData) => {
|
|
8636
8902
|
if (modelsData !== pendingOperation && modelsData.primaryModels.length > 0) {
|
|
8637
|
-
logDebug
|
|
8903
|
+
logDebug(
|
|
8638
8904
|
"ModelsService",
|
|
8639
8905
|
"ModelsData changed",
|
|
8640
8906
|
`${modelsData.primaryModels.length} primary models`
|
|
@@ -8919,7 +9185,7 @@ class ModelsService {
|
|
|
8919
9185
|
if (!resolved.usage.includes(type)) {
|
|
8920
9186
|
throw new Error(`Model "${resolved.id}" is not compatible with usage type "${type}".`);
|
|
8921
9187
|
}
|
|
8922
|
-
logDebug
|
|
9188
|
+
logDebug("ModelsService", `Setting selected ${type} model to ${resolved.id}`);
|
|
8923
9189
|
if (!this.storage) {
|
|
8924
9190
|
throw new Error("ModelsService.storage is not set");
|
|
8925
9191
|
}
|
|
@@ -8985,6 +9251,34 @@ class ModelsService {
|
|
|
8985
9251
|
}
|
|
8986
9252
|
}
|
|
8987
9253
|
const modelsService = new ModelsService();
|
|
9254
|
+
class TestLocalStorageForModelPreferences {
|
|
9255
|
+
constructor(data = null) {
|
|
9256
|
+
__publicField2(this, "isEnrolled", /* @__PURE__ */ new Map());
|
|
9257
|
+
this.data = data;
|
|
9258
|
+
}
|
|
9259
|
+
getModelPreferences() {
|
|
9260
|
+
return this.data || {};
|
|
9261
|
+
}
|
|
9262
|
+
async setModelPreferences(preferences) {
|
|
9263
|
+
this.data = preferences;
|
|
9264
|
+
}
|
|
9265
|
+
getEnrollmentHistory(_featureName) {
|
|
9266
|
+
if (!this.isEnrolled.has(_featureName)) {
|
|
9267
|
+
this.isEnrolled.set(_featureName, true);
|
|
9268
|
+
return false;
|
|
9269
|
+
}
|
|
9270
|
+
return true;
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9273
|
+
function mockModelsService({
|
|
9274
|
+
storage = new TestLocalStorageForModelPreferences(),
|
|
9275
|
+
modelsService: modelsService2 = new ModelsService(),
|
|
9276
|
+
authStatus: authStatus2 = AUTH_STATUS_FIXTURE_AUTHED_DOTCOM
|
|
9277
|
+
}) {
|
|
9278
|
+
modelsService2.setStorage(storage);
|
|
9279
|
+
mockAuthStatus(authStatus2);
|
|
9280
|
+
return { storage, modelsService: modelsService2 };
|
|
9281
|
+
}
|
|
8988
9282
|
function deepClone(value) {
|
|
8989
9283
|
return JSON.parse(JSON.stringify(value));
|
|
8990
9284
|
}
|
|
@@ -9118,9 +9412,7 @@ __publicField2(_BotResponseMultiplexer, "DEFAULT_TOPIC", "Assistant");
|
|
|
9118
9412
|
__publicField2(_BotResponseMultiplexer, "TOPIC_RE", /<$|<\/?([\dA-Za-z-]?$|[\dA-Za-z-]+>?)/m);
|
|
9119
9413
|
let BotResponseMultiplexer = _BotResponseMultiplexer;
|
|
9120
9414
|
const DEFAULT_CHAT_COMPLETION_PARAMETERS = {
|
|
9121
|
-
temperature: 0.2
|
|
9122
|
-
topK: -1,
|
|
9123
|
-
topP: -1
|
|
9415
|
+
temperature: 0.2
|
|
9124
9416
|
};
|
|
9125
9417
|
class ChatClient {
|
|
9126
9418
|
constructor(completions) {
|
|
@@ -9370,6 +9662,23 @@ function envPaths() {
|
|
|
9370
9662
|
return { data: "/tmp/data", config: "/tmp/config", log: "/tmp/log" };
|
|
9371
9663
|
}
|
|
9372
9664
|
const codyPaths = () => envPaths();
|
|
9665
|
+
const EVENT_LINE_PREFIX = "event: ";
|
|
9666
|
+
const DATA_LINE_PREFIX = "data: ";
|
|
9667
|
+
const EVENTS_SEPARATOR = "\n\n";
|
|
9668
|
+
function parseEventType(eventLine) {
|
|
9669
|
+
if (!eventLine.startsWith(EVENT_LINE_PREFIX)) {
|
|
9670
|
+
return new Error(`cannot parse event type: ${eventLine}`);
|
|
9671
|
+
}
|
|
9672
|
+
const eventType = eventLine.slice(EVENT_LINE_PREFIX.length);
|
|
9673
|
+
switch (eventType) {
|
|
9674
|
+
case "completion":
|
|
9675
|
+
case "error":
|
|
9676
|
+
case "done":
|
|
9677
|
+
return eventType;
|
|
9678
|
+
default:
|
|
9679
|
+
return new Error(`unexpected event type: ${eventType}`);
|
|
9680
|
+
}
|
|
9681
|
+
}
|
|
9373
9682
|
function parseJSON(data) {
|
|
9374
9683
|
try {
|
|
9375
9684
|
return JSON.parse(data);
|
|
@@ -9380,6 +9689,85 @@ function parseJSON(data) {
|
|
|
9380
9689
|
function parseCompletionJSON(jsonData) {
|
|
9381
9690
|
return parseJSON(jsonData);
|
|
9382
9691
|
}
|
|
9692
|
+
function parseEventData(builder, eventType, dataLine) {
|
|
9693
|
+
if (!dataLine.startsWith(DATA_LINE_PREFIX)) {
|
|
9694
|
+
return new Error(`cannot parse event data: ${dataLine}`);
|
|
9695
|
+
}
|
|
9696
|
+
const jsonData = dataLine.slice(DATA_LINE_PREFIX.length);
|
|
9697
|
+
switch (eventType) {
|
|
9698
|
+
case "completion": {
|
|
9699
|
+
const data = parseCompletionJSON(jsonData);
|
|
9700
|
+
if (isError$3(data)) {
|
|
9701
|
+
return data;
|
|
9702
|
+
}
|
|
9703
|
+
let usage = void 0;
|
|
9704
|
+
if (data.usage) {
|
|
9705
|
+
usage = {
|
|
9706
|
+
completionTokens: data.usage.completion_tokens,
|
|
9707
|
+
promptTokens: data.usage.prompt_tokens,
|
|
9708
|
+
totalTokens: data.usage.total_tokens
|
|
9709
|
+
};
|
|
9710
|
+
logInfo(
|
|
9711
|
+
"server-usage",
|
|
9712
|
+
`${JSON.stringify({
|
|
9713
|
+
model: builder.model,
|
|
9714
|
+
output_tokens: data.usage.completion_tokens,
|
|
9715
|
+
input_tokens: data.usage.prompt_tokens,
|
|
9716
|
+
total_tokens: data.usage.total_tokens
|
|
9717
|
+
})}`
|
|
9718
|
+
);
|
|
9719
|
+
}
|
|
9720
|
+
builder.nextThinking(data.delta_thinking);
|
|
9721
|
+
const completion = builder.nextCompletion(data.completion, data.deltaText);
|
|
9722
|
+
const toolCalls = builder.nextToolCalls(data == null ? void 0 : data.delta_tool_calls);
|
|
9723
|
+
const content = [];
|
|
9724
|
+
content.push(...toolCalls);
|
|
9725
|
+
return {
|
|
9726
|
+
type: eventType,
|
|
9727
|
+
completion,
|
|
9728
|
+
stopReason: data.stopReason,
|
|
9729
|
+
content,
|
|
9730
|
+
usage
|
|
9731
|
+
};
|
|
9732
|
+
}
|
|
9733
|
+
case "error": {
|
|
9734
|
+
const data = parseJSON(jsonData);
|
|
9735
|
+
if (isError$3(data)) {
|
|
9736
|
+
return data;
|
|
9737
|
+
}
|
|
9738
|
+
if (typeof data.error === "undefined") {
|
|
9739
|
+
return new Error("invalid error event");
|
|
9740
|
+
}
|
|
9741
|
+
return { type: eventType, error: data.error };
|
|
9742
|
+
}
|
|
9743
|
+
case "done":
|
|
9744
|
+
return { type: eventType };
|
|
9745
|
+
}
|
|
9746
|
+
}
|
|
9747
|
+
function parseEvent(builder, eventBuffer) {
|
|
9748
|
+
const [eventLine, dataLine] = eventBuffer.split("\n");
|
|
9749
|
+
const eventType = parseEventType(eventLine);
|
|
9750
|
+
if (isError$3(eventType)) {
|
|
9751
|
+
return eventType;
|
|
9752
|
+
}
|
|
9753
|
+
return parseEventData(builder, eventType, dataLine);
|
|
9754
|
+
}
|
|
9755
|
+
function parseEvents(builder, eventsBuffer) {
|
|
9756
|
+
let eventStartIndex = 0;
|
|
9757
|
+
let eventEndIndex = eventsBuffer.indexOf(EVENTS_SEPARATOR);
|
|
9758
|
+
const events2 = [];
|
|
9759
|
+
while (eventEndIndex >= 0) {
|
|
9760
|
+
const eventBuffer = eventsBuffer.slice(eventStartIndex, eventEndIndex);
|
|
9761
|
+
const event2 = parseEvent(builder, eventBuffer);
|
|
9762
|
+
if (isError$3(event2)) {
|
|
9763
|
+
return event2;
|
|
9764
|
+
}
|
|
9765
|
+
events2.push(event2);
|
|
9766
|
+
eventStartIndex = eventEndIndex + EVENTS_SEPARATOR.length;
|
|
9767
|
+
eventEndIndex = eventsBuffer.indexOf(EVENTS_SEPARATOR, eventStartIndex);
|
|
9768
|
+
}
|
|
9769
|
+
return { events: events2, remainingBuffer: eventsBuffer.slice(eventStartIndex) };
|
|
9770
|
+
}
|
|
9383
9771
|
const defaultTimeoutSeconds = 45;
|
|
9384
9772
|
class SourcegraphGuardrailsClient {
|
|
9385
9773
|
async searchAttribution(snippet) {
|
|
@@ -9489,6 +9877,10 @@ function populateCurrentEditorDiagnosticsTemplate(diagnostic, uri) {
|
|
|
9489
9877
|
const { type, message, text: text2 } = PromptString.fromTextEditorDiagnostic(diagnostic, uri);
|
|
9490
9878
|
return DIAGNOSTICS_CONTEXT_TEMPLATE.replaceAll("{type}", type).replaceAll("{filePath}", PromptString.fromDisplayPath(uri)).replaceAll("{prefix}", type).replaceAll("{message}", message).replaceAll("{languageID}", PromptString.fromMarkdownCodeBlockLanguageIDForFilename(uri)).replaceAll("{code}", text2);
|
|
9491
9879
|
}
|
|
9880
|
+
const COMMAND_OUTPUT_TEMPLATE = "Here is the output returned from the terminal.\n";
|
|
9881
|
+
function populateTerminalOutputContextTemplate(output2) {
|
|
9882
|
+
return COMMAND_OUTPUT_TEMPLATE + output2;
|
|
9883
|
+
}
|
|
9492
9884
|
const SELECTED_CODE_CONTEXT_TEMPLATE = ps`My selected code from codebase file {filePath}:\n\`\`\`\n{code}\`\`\``;
|
|
9493
9885
|
function populateCurrentSelectedCodeContextTemplate(code18, fileUri, range) {
|
|
9494
9886
|
return SELECTED_CODE_CONTEXT_TEMPLATE.replace("{code}", code18).replaceAll(
|
|
@@ -9496,10 +9888,20 @@ function populateCurrentSelectedCodeContextTemplate(code18, fileUri, range) {
|
|
|
9496
9888
|
PromptString.fromDisplayPathLineRange(fileUri, range)
|
|
9497
9889
|
);
|
|
9498
9890
|
}
|
|
9891
|
+
const DIRECTORY_FILE_LIST_TEMPLATE = "Here is a list of files from the directory contains {fileName} in my codebase: ";
|
|
9892
|
+
const ROOT_DIRECTORY_FILE_LIST_TEMPLATE = "Here is a list of files from the root codebase directory: ";
|
|
9893
|
+
function populateListOfFilesContextTemplate(fileList, fileUri) {
|
|
9894
|
+
return (fileUri ? DIRECTORY_FILE_LIST_TEMPLATE.replace("{fileName}", displayPath(fileUri)) : ROOT_DIRECTORY_FILE_LIST_TEMPLATE) + fileList;
|
|
9895
|
+
}
|
|
9499
9896
|
function populateContextTemplateFromText(templateText, content, fileUri, range) {
|
|
9500
9897
|
return templateText.replace("{displayPath}", PromptString.fromDisplayPathLineRange(fileUri, range)).concat(content);
|
|
9501
9898
|
}
|
|
9502
|
-
ps`{fileName} has imported the following: `;
|
|
9899
|
+
const FILE_IMPORTS_TEMPLATE = ps`{fileName} has imported the following: `;
|
|
9900
|
+
function populateImportListContextTemplate(importList, fileUri) {
|
|
9901
|
+
return FILE_IMPORTS_TEMPLATE.replace("{fileName}", PromptString.fromDisplayPath(fileUri)).concat(
|
|
9902
|
+
importList
|
|
9903
|
+
);
|
|
9904
|
+
}
|
|
9503
9905
|
const CODE_GENERATION_CONTEXT_TEMPLATE = ps`Below is the code from file path {filePath}. Review the code outside the XML tags to detect the functionality, formats, style, patterns, and logics in use. Then, use what you detect and reuse methods/libraries to complete and enclose completed code only inside XML tags precisely without duplicating existing implementations. Here is the code:
|
|
9504
9906
|
{precedingText}<{outputTag}></{outputTag}>{followingText}
|
|
9505
9907
|
`;
|
|
@@ -9533,7 +9935,7 @@ async function getTokenCounterUtils() {
|
|
|
9533
9935
|
const browser2 = detect();
|
|
9534
9936
|
if (browser2 && browser2.name === "safari") {
|
|
9535
9937
|
_tokenCounterUtilsPromise = import("./cl100k_base-B4kyDDRQ.mjs").then(async (tokenizer2) => {
|
|
9536
|
-
const tiktoken = await import("./lite-
|
|
9938
|
+
const tiktoken = await import("./lite-BPYOwOSx.mjs");
|
|
9537
9939
|
return createTokenCounterUtils(new tiktoken.Tiktoken(tokenizer2.default));
|
|
9538
9940
|
});
|
|
9539
9941
|
} else {
|
|
@@ -9713,6 +10115,30 @@ async function truncatePromptString(text2, maxTokens) {
|
|
|
9713
10115
|
const encoded = await TokenCounterUtils.encode(text2.toString());
|
|
9714
10116
|
return encoded.length <= maxTokens ? text2 : text2.slice(0, (_a3 = await TokenCounterUtils.decode(encoded.slice(0, maxTokens))) == null ? void 0 : _a3.length).trim();
|
|
9715
10117
|
}
|
|
10118
|
+
function truncateTextNearestLine(text2, maxBytes) {
|
|
10119
|
+
if (text2.length <= maxBytes) {
|
|
10120
|
+
return { truncated: text2 };
|
|
10121
|
+
}
|
|
10122
|
+
const textMaxBytes = text2.slice(0, maxBytes);
|
|
10123
|
+
const textMaxBytesLines = textMaxBytes.split("\n");
|
|
10124
|
+
if (text2.at(maxBytes) === "\n" || text2.at(maxBytes - 1) === "\n") {
|
|
10125
|
+
return {
|
|
10126
|
+
truncated: textMaxBytes,
|
|
10127
|
+
range: {
|
|
10128
|
+
start: { line: 0, character: 0 },
|
|
10129
|
+
end: { line: textMaxBytesLines.length, character: 0 }
|
|
10130
|
+
}
|
|
10131
|
+
};
|
|
10132
|
+
}
|
|
10133
|
+
const truncated = textMaxBytesLines.slice(0, -1).join("\n");
|
|
10134
|
+
return {
|
|
10135
|
+
truncated,
|
|
10136
|
+
range: {
|
|
10137
|
+
start: { line: 0, character: 0 },
|
|
10138
|
+
end: { line: textMaxBytesLines.length - 1, character: 0 }
|
|
10139
|
+
}
|
|
10140
|
+
};
|
|
10141
|
+
}
|
|
9716
10142
|
async function truncatePromptStringStart(text2, maxTokens) {
|
|
9717
10143
|
const encoded = await TokenCounterUtils.encode(text2.toString());
|
|
9718
10144
|
if (encoded.length <= maxTokens) {
|
|
@@ -9919,7 +10345,7 @@ class CompletionsResponseBuilder {
|
|
|
9919
10345
|
this.model = model2;
|
|
9920
10346
|
}
|
|
9921
10347
|
/**
|
|
9922
|
-
* Creates a builder from a URL with api-version parameter
|
|
10348
|
+
* Creates a builder from a URL with api-version parameter and optional model
|
|
9923
10349
|
*/
|
|
9924
10350
|
static fromUrl(url, model2) {
|
|
9925
10351
|
const apiVersion = Number.parseInt(new URL(url).searchParams.get("api-version") ?? "0", 10);
|
|
@@ -10616,7 +11042,7 @@ const getStringFromMaybeBuffer = (x) => {
|
|
|
10616
11042
|
};
|
|
10617
11043
|
const isAsyncIterableIterator = (value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
|
|
10618
11044
|
const isMultipartBody = (body2) => body2 && typeof body2 === "object" && body2.body && body2[Symbol.toStringTag] === "MultipartBody";
|
|
10619
|
-
var define_process_default$
|
|
11045
|
+
var define_process_default$l = { env: {} };
|
|
10620
11046
|
var __classPrivateFieldSet$3 = function(receiver, state2, value, kind2, f) {
|
|
10621
11047
|
if (typeof state2 === "function" ? receiver !== state2 || !f : !state2.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10622
11048
|
return state2.set(receiver, value), value;
|
|
@@ -11157,17 +11583,17 @@ const getPlatformProperties = () => {
|
|
|
11157
11583
|
"X-Stainless-OS": "Unknown",
|
|
11158
11584
|
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
11159
11585
|
"X-Stainless-Runtime": "edge",
|
|
11160
|
-
"X-Stainless-Runtime-Version": define_process_default$
|
|
11586
|
+
"X-Stainless-Runtime-Version": define_process_default$l.version
|
|
11161
11587
|
};
|
|
11162
11588
|
}
|
|
11163
|
-
if (Object.prototype.toString.call(typeof define_process_default$
|
|
11589
|
+
if (Object.prototype.toString.call(typeof define_process_default$l !== "undefined" ? define_process_default$l : 0) === "[object process]") {
|
|
11164
11590
|
return {
|
|
11165
11591
|
"X-Stainless-Lang": "js",
|
|
11166
11592
|
"X-Stainless-Package-Version": VERSION,
|
|
11167
|
-
"X-Stainless-OS": normalizePlatform(define_process_default$
|
|
11168
|
-
"X-Stainless-Arch": normalizeArch(define_process_default$
|
|
11593
|
+
"X-Stainless-OS": normalizePlatform(define_process_default$l.platform),
|
|
11594
|
+
"X-Stainless-Arch": normalizeArch(define_process_default$l.arch),
|
|
11169
11595
|
"X-Stainless-Runtime": "node",
|
|
11170
|
-
"X-Stainless-Runtime-Version": define_process_default$
|
|
11596
|
+
"X-Stainless-Runtime-Version": define_process_default$l.version
|
|
11171
11597
|
};
|
|
11172
11598
|
}
|
|
11173
11599
|
const browserInfo = getBrowserInfo();
|
|
@@ -11284,8 +11710,8 @@ const castToError = (err2) => {
|
|
|
11284
11710
|
};
|
|
11285
11711
|
const readEnv = (env2) => {
|
|
11286
11712
|
var _a3, _b2, _c2, _d2, _e2;
|
|
11287
|
-
if (typeof define_process_default$
|
|
11288
|
-
return ((_b2 = (_a3 = define_process_default$
|
|
11713
|
+
if (typeof define_process_default$l !== "undefined") {
|
|
11714
|
+
return ((_b2 = (_a3 = define_process_default$l.env) == null ? void 0 : _a3[env2]) == null ? void 0 : _b2.trim()) ?? void 0;
|
|
11289
11715
|
}
|
|
11290
11716
|
if (typeof Deno !== "undefined") {
|
|
11291
11717
|
return (_e2 = (_d2 = (_c2 = Deno.env) == null ? void 0 : _c2.get) == null ? void 0 : _d2.call(_c2, env2)) == null ? void 0 : _e2.trim();
|
|
@@ -11319,7 +11745,7 @@ function applyHeadersMut(targetHeaders, newHeaders) {
|
|
|
11319
11745
|
}
|
|
11320
11746
|
function debug$1(action, ...args2) {
|
|
11321
11747
|
var _a3;
|
|
11322
|
-
if (typeof define_process_default$
|
|
11748
|
+
if (typeof define_process_default$l !== "undefined" && ((_a3 = define_process_default$l == null ? void 0 : define_process_default$l.env) == null ? void 0 : _a3["DEBUG"]) === "true") {
|
|
11323
11749
|
console.log(`Anthropic:DEBUG:${action}`, ...args2);
|
|
11324
11750
|
}
|
|
11325
11751
|
}
|
|
@@ -13278,11 +13704,11 @@ async function useCustomChatClient({
|
|
|
13278
13704
|
}
|
|
13279
13705
|
return false;
|
|
13280
13706
|
}
|
|
13281
|
-
var define_process_default$
|
|
13707
|
+
var define_process_default$k = { env: {} };
|
|
13282
13708
|
class SourcegraphCompletionsClient {
|
|
13283
13709
|
constructor(logger2) {
|
|
13284
13710
|
__publicField2(this, "errorEncountered", false);
|
|
13285
|
-
__publicField2(this, "isTemperatureZero", define_process_default$
|
|
13711
|
+
__publicField2(this, "isTemperatureZero", define_process_default$k.env.CODY_TEMPERATURE_ZERO === "true");
|
|
13286
13712
|
this.logger = logger2;
|
|
13287
13713
|
}
|
|
13288
13714
|
async completionsEndpoint() {
|
|
@@ -13614,7 +14040,7 @@ function event(featureAction, record, maps) {
|
|
|
13614
14040
|
const wrappedRecord = (...args2) => {
|
|
13615
14041
|
const fn = record(ctx);
|
|
13616
14042
|
const handleError = (e) => {
|
|
13617
|
-
logError$
|
|
14043
|
+
logError$1("Telemetry Recording", "Failed to record telemetry event", {
|
|
13618
14044
|
error: e
|
|
13619
14045
|
});
|
|
13620
14046
|
};
|
|
@@ -15498,7 +15924,7 @@ const getContextForChatMessage = async (message, parentSignal) => {
|
|
|
15498
15924
|
try {
|
|
15499
15925
|
return (_a4 = message.match(new RegExp(pattern))) == null ? void 0 : _a4.length;
|
|
15500
15926
|
} catch {
|
|
15501
|
-
logDebug
|
|
15927
|
+
logDebug(
|
|
15502
15928
|
"OpenCtx",
|
|
15503
15929
|
`getContextForChatMessage Error: matching regex ${pattern} for provider ${p2.providerUri}`
|
|
15504
15930
|
);
|
|
@@ -16156,10 +16582,10 @@ function observeAnnotations(providerClients, params, { logger: logger2, makeRang
|
|
|
16156
16582
|
return (((_c2 = a.range) == null ? void 0 : _c2.start.character) ?? 0) - (((_d2 = b.range) == null ? void 0 : _d2.start.character) ?? 0);
|
|
16157
16583
|
}) : null)), { logger: logger2, emitPartial, errorHook });
|
|
16158
16584
|
}
|
|
16159
|
-
var define_process_default$
|
|
16585
|
+
var define_process_default$j = { env: {} };
|
|
16160
16586
|
const perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
16161
16587
|
const warned = /* @__PURE__ */ new Set();
|
|
16162
|
-
const PROCESS = typeof define_process_default$
|
|
16588
|
+
const PROCESS = typeof define_process_default$j === "object" && !!define_process_default$j ? define_process_default$j : {};
|
|
16163
16589
|
const emitWarning = (msg, type, code18, fn) => {
|
|
16164
16590
|
typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code18, fn) : console.error(`[${code18}] ${type}: ${msg}`);
|
|
16165
16591
|
};
|
|
@@ -19996,24 +20422,6 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
19996
20422
|
__proto__: null,
|
|
19997
20423
|
createController
|
|
19998
20424
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
19999
|
-
function appendFileSync() {
|
|
20000
|
-
throw new Error("not implemented");
|
|
20001
|
-
}
|
|
20002
|
-
function existsSync() {
|
|
20003
|
-
throw new Error("not implemented");
|
|
20004
|
-
}
|
|
20005
|
-
function mkdirSync() {
|
|
20006
|
-
throw new Error("not implemented");
|
|
20007
|
-
}
|
|
20008
|
-
function rmSync() {
|
|
20009
|
-
throw new Error("not implemented");
|
|
20010
|
-
}
|
|
20011
|
-
function copySync() {
|
|
20012
|
-
throw new Error("not implemented");
|
|
20013
|
-
}
|
|
20014
|
-
function statSync() {
|
|
20015
|
-
throw new Error("not implemented");
|
|
20016
|
-
}
|
|
20017
20425
|
var events = { exports: {} };
|
|
20018
20426
|
var R = typeof Reflect === "object" ? Reflect : null;
|
|
20019
20427
|
var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args2) {
|
|
@@ -25072,6 +25480,8 @@ var merge_1 = merge;
|
|
|
25072
25480
|
const merge$1 = /* @__PURE__ */ getDefaultExportFromCjs(merge_1);
|
|
25073
25481
|
const CODY_ACCESS_TOKEN_SOURCE = "cody.access-token.source";
|
|
25074
25482
|
const CODY_ACCESS_TOKEN_SECRET = "cody.access-token";
|
|
25483
|
+
const CODY_REFRESH_TOKEN_SECRET = "cody.refresh-token";
|
|
25484
|
+
const CODY_TOKEN_EXPIRES_AT = "cody.token.expires-at";
|
|
25075
25485
|
class VSCodeSecretStorage {
|
|
25076
25486
|
constructor() {
|
|
25077
25487
|
__publicField2(this, "fsPath", null);
|
|
@@ -25084,7 +25494,7 @@ class VSCodeSecretStorage {
|
|
|
25084
25494
|
const config = workspace.getConfiguration("cody");
|
|
25085
25495
|
this.fsPath = config.get("experimental.localTokenPath") || null;
|
|
25086
25496
|
if (this.fsPath) {
|
|
25087
|
-
logDebug("VSCodeSecretStorage:experimental.localTokenPath", "enabled", {
|
|
25497
|
+
outputChannelLogger.logDebug("VSCodeSecretStorage:experimental.localTokenPath", "enabled", {
|
|
25088
25498
|
verbose: this.fsPath
|
|
25089
25499
|
});
|
|
25090
25500
|
}
|
|
@@ -25122,7 +25532,9 @@ class VSCodeSecretStorage {
|
|
|
25122
25532
|
await this.secretStorage.store(key2, value);
|
|
25123
25533
|
}
|
|
25124
25534
|
} catch (error) {
|
|
25125
|
-
logError
|
|
25535
|
+
outputChannelLogger.logError("VSCodeSecretStorage:store:failed", key2, {
|
|
25536
|
+
verbose: error
|
|
25537
|
+
});
|
|
25126
25538
|
}
|
|
25127
25539
|
}
|
|
25128
25540
|
async getToken(endpoint) {
|
|
@@ -25147,6 +25559,21 @@ class VSCodeSecretStorage {
|
|
|
25147
25559
|
await this.secretStorage.delete(endpoint);
|
|
25148
25560
|
await this.secretStorage.delete(CODY_ACCESS_TOKEN_SECRET);
|
|
25149
25561
|
await this.secretStorage.delete(endpoint + CODY_ACCESS_TOKEN_SOURCE);
|
|
25562
|
+
await this.secretStorage.delete(endpoint + CODY_REFRESH_TOKEN_SECRET);
|
|
25563
|
+
await this.secretStorage.delete(endpoint + CODY_TOKEN_EXPIRES_AT);
|
|
25564
|
+
}
|
|
25565
|
+
async storeRefreshToken(endpoint, refreshToken) {
|
|
25566
|
+
await this.store(endpoint + CODY_REFRESH_TOKEN_SECRET, refreshToken);
|
|
25567
|
+
}
|
|
25568
|
+
async getRefreshToken(endpoint) {
|
|
25569
|
+
return this.get(endpoint + CODY_REFRESH_TOKEN_SECRET);
|
|
25570
|
+
}
|
|
25571
|
+
async storeTokenExpiresAt(endpoint, expiresAt) {
|
|
25572
|
+
await this.store(endpoint + CODY_TOKEN_EXPIRES_AT, expiresAt.toString());
|
|
25573
|
+
}
|
|
25574
|
+
async getTokenExpiresAt(endpoint) {
|
|
25575
|
+
const expiresAtStr = await this.get(endpoint + CODY_TOKEN_EXPIRES_AT);
|
|
25576
|
+
return expiresAtStr ? Number.parseInt(expiresAtStr, 10) : void 0;
|
|
25150
25577
|
}
|
|
25151
25578
|
async delete(key2) {
|
|
25152
25579
|
await this.secretStorage.delete(key2);
|
|
@@ -25169,10 +25596,12 @@ async function getAccessTokenFromFsPath(fsPath) {
|
|
|
25169
25596
|
if (!json2.token) {
|
|
25170
25597
|
throw new Error(`Failed to retrieve token from: ${fsPath}`);
|
|
25171
25598
|
}
|
|
25172
|
-
logDebug("VSCodeSecretStorage:getAccessTokenFromFsPath", "retrieved");
|
|
25599
|
+
outputChannelLogger.logDebug("VSCodeSecretStorage:getAccessTokenFromFsPath", "retrieved");
|
|
25173
25600
|
return json2.token;
|
|
25174
25601
|
} catch (error) {
|
|
25175
|
-
logError
|
|
25602
|
+
outputChannelLogger.logError("VSCodeSecretStorage:getAccessTokenFromFsPath", "failed", {
|
|
25603
|
+
verbose: error
|
|
25604
|
+
});
|
|
25176
25605
|
return null;
|
|
25177
25606
|
}
|
|
25178
25607
|
}
|
|
@@ -25673,7 +26102,7 @@ function sanitizeCodebase(codebase) {
|
|
|
25673
26102
|
const trailingSlashRegexp = /\/$/;
|
|
25674
26103
|
return codebase.replace(protocolRegexp, "").trim().replace(trailingSlashRegexp, "");
|
|
25675
26104
|
}
|
|
25676
|
-
var define_process_default$
|
|
26105
|
+
var define_process_default$i = { env: {} };
|
|
25677
26106
|
const CODY_OUTPUT_CHANNEL = "Cody by Sourcegraph";
|
|
25678
26107
|
class OutputChannelManager {
|
|
25679
26108
|
constructor() {
|
|
@@ -25681,7 +26110,8 @@ class OutputChannelManager {
|
|
|
25681
26110
|
__publicField2(this, "outputChannels", /* @__PURE__ */ new Map());
|
|
25682
26111
|
}
|
|
25683
26112
|
getOutputChannel(feature2) {
|
|
25684
|
-
|
|
26113
|
+
const shouldCreateChannel = feature2 === "auth";
|
|
26114
|
+
if (!this.outputChannels.has(feature2) && shouldCreateChannel) {
|
|
25685
26115
|
const channel2 = window$1.createOutputChannel(`Cody ${feature2}`, { log: true });
|
|
25686
26116
|
this.outputChannels.set(feature2, channel2);
|
|
25687
26117
|
}
|
|
@@ -25706,7 +26136,7 @@ class OutputChannelManager {
|
|
|
25706
26136
|
channel2 == null ? void 0 : channel2.debug(text2);
|
|
25707
26137
|
}
|
|
25708
26138
|
}
|
|
25709
|
-
const path2 = define_process_default$
|
|
26139
|
+
const path2 = define_process_default$i.env.CODY_LOG_FILE;
|
|
25710
26140
|
if (path2) {
|
|
25711
26141
|
appendFileSync();
|
|
25712
26142
|
}
|
|
@@ -25771,15 +26201,6 @@ class Logger {
|
|
|
25771
26201
|
}
|
|
25772
26202
|
}
|
|
25773
26203
|
const outputChannelLogger = new Logger();
|
|
25774
|
-
function logDebug(filterLabel, text2, ...args2) {
|
|
25775
|
-
outputChannelLogger.logDebug(filterLabel, text2, ...args2);
|
|
25776
|
-
}
|
|
25777
|
-
function logInfo(filterLabel, text2, ...args2) {
|
|
25778
|
-
outputChannelLogger.logInfo(filterLabel, text2, ...args2);
|
|
25779
|
-
}
|
|
25780
|
-
function logError$1(filterLabel, text2, ...args2) {
|
|
25781
|
-
outputChannelLogger.logError(filterLabel, text2, ...args2);
|
|
25782
|
-
}
|
|
25783
26204
|
function formatMessage({
|
|
25784
26205
|
prefix,
|
|
25785
26206
|
feature: feature2,
|
|
@@ -25797,7 +26218,9 @@ function formatMessage({
|
|
|
25797
26218
|
const isVerboseLastArg = lastArg && typeof lastArg === "object" && "verbose" in lastArg;
|
|
25798
26219
|
const argsToLog = isVerboseLastArg ? args2.slice(0, -1) : args2;
|
|
25799
26220
|
if (argsToLog.length > 0) {
|
|
25800
|
-
messageParts.push(
|
|
26221
|
+
messageParts.push(
|
|
26222
|
+
argsToLog.map((arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)).join(" ")
|
|
26223
|
+
);
|
|
25801
26224
|
}
|
|
25802
26225
|
if (isVerboseLastArg && debugVerbose) {
|
|
25803
26226
|
messageParts.push(JSON.stringify(lastArg.verbose, null, 2));
|
|
@@ -25837,13 +26260,14 @@ function isRunningInsideAgent() {
|
|
|
25837
26260
|
}
|
|
25838
26261
|
const version = ((_i = (_h = extensions.getExtension("sourcegraph.cody-ai")) == null ? void 0 : _h.packageJSON) == null ? void 0 : _i.version) ?? version$2;
|
|
25839
26262
|
setExtensionVersion(version);
|
|
26263
|
+
var define_process_default$h = { env: {} };
|
|
25840
26264
|
const HAS_AUTHENTICATED_BEFORE_KEY = "has-authenticated-before";
|
|
25841
26265
|
class AuthProvider {
|
|
25842
26266
|
constructor(setAuthStatusObservable$1 = setAuthStatusObservable) {
|
|
25843
26267
|
__publicField2(this, "status", new MulticastSubject());
|
|
25844
26268
|
/**
|
|
25845
26269
|
* Credentials that were already validated with
|
|
25846
|
-
* {@link AuthProvider
|
|
26270
|
+
* {@link AuthProvider["validateAndStoreCredentials"]}.
|
|
25847
26271
|
*/
|
|
25848
26272
|
__publicField2(this, "lastValidated", { credentials: null, auth: null });
|
|
25849
26273
|
__publicField2(this, "subscriptions", []);
|
|
@@ -25887,7 +26311,11 @@ class AuthProvider {
|
|
|
25887
26311
|
authStatus2.endpoint
|
|
25888
26312
|
);
|
|
25889
26313
|
} catch (error) {
|
|
25890
|
-
logError
|
|
26314
|
+
outputChannelLogger.logError(
|
|
26315
|
+
"AuthProvider",
|
|
26316
|
+
"Unexpected error while setting context",
|
|
26317
|
+
error
|
|
26318
|
+
);
|
|
25891
26319
|
}
|
|
25892
26320
|
})
|
|
25893
26321
|
);
|
|
@@ -25896,7 +26324,11 @@ class AuthProvider {
|
|
|
25896
26324
|
try {
|
|
25897
26325
|
this.reportAuthTelemetryEvent(authStatus2);
|
|
25898
26326
|
} catch (error) {
|
|
25899
|
-
logError
|
|
26327
|
+
outputChannelLogger.logError(
|
|
26328
|
+
"AuthProvider",
|
|
26329
|
+
"Unexpected error while reporting auth telemetry",
|
|
26330
|
+
error
|
|
26331
|
+
);
|
|
25900
26332
|
}
|
|
25901
26333
|
})
|
|
25902
26334
|
);
|
|
@@ -25919,6 +26351,42 @@ class AuthProvider {
|
|
|
25919
26351
|
})
|
|
25920
26352
|
);
|
|
25921
26353
|
}
|
|
26354
|
+
async waitForResolvedConfigEndpointMatch(expectedEndpoint, timeoutMs = 3e3) {
|
|
26355
|
+
const normalized2 = normalizeServerEndpointURL(expectedEndpoint);
|
|
26356
|
+
const startTime = Date.now();
|
|
26357
|
+
try {
|
|
26358
|
+
await Promise.race([
|
|
26359
|
+
firstValueFrom$1(
|
|
26360
|
+
resolvedConfig.pipe(
|
|
26361
|
+
map$1(
|
|
26362
|
+
(config) => config.auth.serverEndpoint ? normalizeServerEndpointURL(config.auth.serverEndpoint) : void 0
|
|
26363
|
+
),
|
|
26364
|
+
filter$3((endpoint) => endpoint === normalized2),
|
|
26365
|
+
take$2(1)
|
|
26366
|
+
)
|
|
26367
|
+
),
|
|
26368
|
+
new Promise(
|
|
26369
|
+
(_2, reject) => setTimeout(() => reject(new Error("Timeout waiting for resolvedConfig")), timeoutMs)
|
|
26370
|
+
)
|
|
26371
|
+
]);
|
|
26372
|
+
outputChannelLogger.logDebug("AuthProvider", "resolvedConfig endpoint matched", {
|
|
26373
|
+
endpoint: normalized2,
|
|
26374
|
+
waitTime: Date.now() - startTime,
|
|
26375
|
+
timestamp: Date.now()
|
|
26376
|
+
});
|
|
26377
|
+
} catch (error) {
|
|
26378
|
+
outputChannelLogger.logDebug(
|
|
26379
|
+
"AuthProvider",
|
|
26380
|
+
"Timeout waiting for resolvedConfig endpoint match",
|
|
26381
|
+
{
|
|
26382
|
+
endpoint: normalized2,
|
|
26383
|
+
waitTime: Date.now() - startTime,
|
|
26384
|
+
error: String(error),
|
|
26385
|
+
timestamp: Date.now()
|
|
26386
|
+
}
|
|
26387
|
+
);
|
|
26388
|
+
}
|
|
26389
|
+
}
|
|
25922
26390
|
async validateAndStoreCredentials(config, mode) {
|
|
25923
26391
|
var _a3;
|
|
25924
26392
|
let credentials;
|
|
@@ -25943,12 +26411,21 @@ class AuthProvider {
|
|
|
25943
26411
|
localStorage.saveEndpointAndToken(credentials.auth),
|
|
25944
26412
|
this.serializeUninstallerInfo(authStatus2)
|
|
25945
26413
|
]);
|
|
26414
|
+
if (credentials.auth.serverEndpoint && !define_process_default$h.env.VITEST) {
|
|
26415
|
+
await this.waitForResolvedConfigEndpointMatch(credentials.auth.serverEndpoint);
|
|
26416
|
+
}
|
|
25946
26417
|
} else if (!authStatus2.authenticated && !authStatus2.pendingValidation) {
|
|
25947
26418
|
const status = authStatus2;
|
|
25948
26419
|
if (status.endpoint && isInvalidAccessTokenError(status.error)) {
|
|
25949
26420
|
await localStorage.deleteEndpointAndToken(status.endpoint);
|
|
25950
26421
|
}
|
|
25951
26422
|
}
|
|
26423
|
+
if (!authStatus2.authenticated && !authStatus2.pendingValidation) {
|
|
26424
|
+
const status = authStatus2;
|
|
26425
|
+
if ((isInvalidAccessTokenError(status.error) || isOAuthProviderError(status.error)) && status.endpoint) {
|
|
26426
|
+
await localStorage.deleteEndpointAndToken(status.endpoint);
|
|
26427
|
+
}
|
|
26428
|
+
}
|
|
25952
26429
|
this.lastValidated = { credentials, auth: authStatus2 };
|
|
25953
26430
|
this.status.next(authStatus2);
|
|
25954
26431
|
return authStatus2;
|
|
@@ -26040,11 +26517,6 @@ class AuthProvider {
|
|
|
26040
26517
|
}
|
|
26041
26518
|
}
|
|
26042
26519
|
const authProvider = new AuthProvider();
|
|
26043
|
-
let runningAuthProgressIndicator = null;
|
|
26044
|
-
function closeAuthProgressIndicator() {
|
|
26045
|
-
runningAuthProgressIndicator == null ? void 0 : runningAuthProgressIndicator();
|
|
26046
|
-
runningAuthProgressIndicator = null;
|
|
26047
|
-
}
|
|
26048
26520
|
async function showEnterpriseInstanceUrlFlow(endpoint) {
|
|
26049
26521
|
const { configuration } = await currentResolvedConfig();
|
|
26050
26522
|
const auth2 = await resolveAuth(endpoint, configuration, secretStorage);
|
|
@@ -26063,7 +26535,7 @@ async function showEnterpriseInstanceUrlFlow(endpoint) {
|
|
|
26063
26535
|
async function showSignInMenu() {
|
|
26064
26536
|
const authStatus2 = currentAuthStatus();
|
|
26065
26537
|
const mode = authStatus2.authenticated ? "switch" : "signin";
|
|
26066
|
-
logDebug("AuthProvider:signinMenu", mode);
|
|
26538
|
+
outputChannelLogger.logDebug("AuthProvider:signinMenu", mode);
|
|
26067
26539
|
telemetryRecorder.recordEvent("cody.auth.login", "clicked");
|
|
26068
26540
|
const item = await showAuthMenu(mode);
|
|
26069
26541
|
if (!item) {
|
|
@@ -26111,7 +26583,7 @@ async function showSignInMenu() {
|
|
|
26111
26583
|
);
|
|
26112
26584
|
}
|
|
26113
26585
|
await showAuthResultMessage(selectedEndpoint, authStatus3);
|
|
26114
|
-
logDebug("AuthProvider:signinMenu", mode, selectedEndpoint);
|
|
26586
|
+
outputChannelLogger.logDebug("AuthProvider:signinMenu", mode, selectedEndpoint);
|
|
26115
26587
|
}
|
|
26116
26588
|
}
|
|
26117
26589
|
}
|
|
@@ -26264,7 +26736,6 @@ async function showAuthFailureMessage(endpoint, authStatus2) {
|
|
|
26264
26736
|
}
|
|
26265
26737
|
}
|
|
26266
26738
|
async function tokenCallbackHandler(uri) {
|
|
26267
|
-
closeAuthProgressIndicator();
|
|
26268
26739
|
const params = new URLSearchParams(uri.query);
|
|
26269
26740
|
const token = params.get("code") || params.get("token");
|
|
26270
26741
|
const endpoint = currentAuthStatus().endpoint;
|
|
@@ -26324,17 +26795,21 @@ async function showSignOutMenu() {
|
|
|
26324
26795
|
const { endpoint } = currentAuthStatus();
|
|
26325
26796
|
if (endpoint) {
|
|
26326
26797
|
await signOut(endpoint);
|
|
26327
|
-
logDebug("AuthProvider:signoutMenu", endpoint);
|
|
26798
|
+
outputChannelLogger.logDebug("AuthProvider:signoutMenu", endpoint);
|
|
26328
26799
|
}
|
|
26329
26800
|
}
|
|
26330
26801
|
async function signOut(endpoint) {
|
|
26331
|
-
Promise.all([
|
|
26332
|
-
(
|
|
26333
|
-
|
|
26334
|
-
|
|
26335
|
-
|
|
26802
|
+
await Promise.all([
|
|
26803
|
+
secretStorage.getToken(endpoint),
|
|
26804
|
+
secretStorage.getRefreshToken(endpoint),
|
|
26805
|
+
secretStorage.getTokenSource(endpoint)
|
|
26806
|
+
]).then(async ([token, refreshToken, tokenSource]) => {
|
|
26807
|
+
if (token && tokenSource === "redirect") {
|
|
26808
|
+
void graphqlClient.DeleteAccessToken(token);
|
|
26809
|
+
} else if (token && refreshToken && tokenSource === "oauth") {
|
|
26810
|
+
await revokeOAuthTokens(endpoint, refreshToken, token);
|
|
26336
26811
|
}
|
|
26337
|
-
);
|
|
26812
|
+
});
|
|
26338
26813
|
authProvider.signout(endpoint);
|
|
26339
26814
|
await firstResultFromOperation(authStatus.filter((status) => status.authenticated === false));
|
|
26340
26815
|
await localStorage.deleteEndpointAndToken(endpoint);
|
|
@@ -26342,7 +26817,7 @@ async function signOut(endpoint) {
|
|
|
26342
26817
|
async function validateCredentials(config) {
|
|
26343
26818
|
var _a3;
|
|
26344
26819
|
if (config.auth.error !== void 0) {
|
|
26345
|
-
logDebug(
|
|
26820
|
+
outputChannelLogger.logDebug(
|
|
26346
26821
|
"auth",
|
|
26347
26822
|
`Failed to authenticate to ${config.auth.serverEndpoint} due to configuration error`,
|
|
26348
26823
|
config.auth.error
|
|
@@ -26364,7 +26839,7 @@ async function validateCredentials(config) {
|
|
|
26364
26839
|
if (!config.auth.credentials && !clientCapabilities().isCodyWeb) {
|
|
26365
26840
|
return { authenticated: false, endpoint: config.auth.serverEndpoint, pendingValidation: false };
|
|
26366
26841
|
}
|
|
26367
|
-
logDebug("auth", `Authenticating to ${config.auth.serverEndpoint}...`);
|
|
26842
|
+
outputChannelLogger.logDebug("auth", `Authenticating to ${config.auth.serverEndpoint}...`);
|
|
26368
26843
|
const apiClientConfig = {
|
|
26369
26844
|
configuration: {
|
|
26370
26845
|
customHeaders: config.configuration.customHeaders,
|
|
@@ -26377,8 +26852,8 @@ async function validateCredentials(config) {
|
|
|
26377
26852
|
try {
|
|
26378
26853
|
const userInfo = await client.getCurrentUserInfo();
|
|
26379
26854
|
if (isError$3(userInfo)) {
|
|
26380
|
-
if (
|
|
26381
|
-
logDebug("auth", userInfo.message);
|
|
26855
|
+
if (isExternalAuthProviderError(userInfo) || isOAuthProviderError(userInfo)) {
|
|
26856
|
+
outputChannelLogger.logDebug("auth", userInfo.message);
|
|
26382
26857
|
return {
|
|
26383
26858
|
authenticated: false,
|
|
26384
26859
|
error: userInfo,
|
|
@@ -26388,7 +26863,7 @@ async function validateCredentials(config) {
|
|
|
26388
26863
|
}
|
|
26389
26864
|
const needsAuthChallenge = isNeedsAuthChallengeError(userInfo);
|
|
26390
26865
|
if (isNetworkLikeError(userInfo) || needsAuthChallenge) {
|
|
26391
|
-
logDebug(
|
|
26866
|
+
outputChannelLogger.logDebug(
|
|
26392
26867
|
"auth",
|
|
26393
26868
|
`Failed to authenticate to ${config.auth.serverEndpoint} due to likely network or endpoint availability error`,
|
|
26394
26869
|
userInfo.message
|
|
@@ -26402,7 +26877,7 @@ async function validateCredentials(config) {
|
|
|
26402
26877
|
}
|
|
26403
26878
|
}
|
|
26404
26879
|
if (!userInfo || isError$3(userInfo)) {
|
|
26405
|
-
logDebug(
|
|
26880
|
+
outputChannelLogger.logDebug(
|
|
26406
26881
|
"auth",
|
|
26407
26882
|
`Failed to authenticate to ${config.auth.serverEndpoint} due to invalid credentials or other endpoint error`,
|
|
26408
26883
|
userInfo == null ? void 0 : userInfo.message
|
|
@@ -26414,7 +26889,10 @@ async function validateCredentials(config) {
|
|
|
26414
26889
|
pendingValidation: false
|
|
26415
26890
|
};
|
|
26416
26891
|
}
|
|
26417
|
-
logDebug(
|
|
26892
|
+
outputChannelLogger.logDebug(
|
|
26893
|
+
"auth",
|
|
26894
|
+
`Authentication succeed to endpoint ${config.auth.serverEndpoint}`
|
|
26895
|
+
);
|
|
26418
26896
|
return newAuthStatus({
|
|
26419
26897
|
...userInfo,
|
|
26420
26898
|
endpoint: config.auth.serverEndpoint,
|
|
@@ -35734,7 +36212,7 @@ class IndentationBasedFoldingRangeProvider {
|
|
|
35734
36212
|
result.push(new FoldingRange(start2.startLine, document2.lineCount));
|
|
35735
36213
|
}
|
|
35736
36214
|
} catch (error) {
|
|
35737
|
-
logError$
|
|
36215
|
+
logError$1("IndentationBasedFoldingRanges", "error", error);
|
|
35738
36216
|
}
|
|
35739
36217
|
return result;
|
|
35740
36218
|
}
|
|
@@ -35960,7 +36438,7 @@ async function getContextFileFromCurrentFile() {
|
|
|
35960
36438
|
source: ContextItemSource.Editor
|
|
35961
36439
|
};
|
|
35962
36440
|
} catch (error) {
|
|
35963
|
-
logError$
|
|
36441
|
+
logError$1("getContextFileFromCurrentFile", "failed", { verbose: error });
|
|
35964
36442
|
return null;
|
|
35965
36443
|
}
|
|
35966
36444
|
});
|
|
@@ -36207,11 +36685,19 @@ async function gitLocallyModifiedFiles(uri, signal2) {
|
|
|
36207
36685
|
var _a3, _b2;
|
|
36208
36686
|
const repo = vscodeGitAPI == null ? void 0 : vscodeGitAPI.getRepository(uri);
|
|
36209
36687
|
if (!repo) {
|
|
36210
|
-
logDebug(
|
|
36688
|
+
outputChannelLogger.logDebug(
|
|
36689
|
+
"gitLocallyModifiedFiles",
|
|
36690
|
+
"no git repository found at",
|
|
36691
|
+
uri.toString()
|
|
36692
|
+
);
|
|
36211
36693
|
return [];
|
|
36212
36694
|
}
|
|
36213
36695
|
if (!((_a3 = repo.state.HEAD) == null ? void 0 : _a3.commit)) {
|
|
36214
|
-
logDebug(
|
|
36696
|
+
outputChannelLogger.logDebug(
|
|
36697
|
+
"gitLocallyModifiedFiles",
|
|
36698
|
+
"HEAD commit was undefined for git repo at",
|
|
36699
|
+
uri.toString()
|
|
36700
|
+
);
|
|
36215
36701
|
return [];
|
|
36216
36702
|
}
|
|
36217
36703
|
let diffBase = repo.state.HEAD.commit;
|
|
@@ -36406,7 +36892,9 @@ class RepoNameResolver {
|
|
|
36406
36892
|
}),
|
|
36407
36893
|
map$1((value) => {
|
|
36408
36894
|
if (isError$3(value)) {
|
|
36409
|
-
logDebug("RepoNameResolver:getRepoNamesContainingUri", "error", {
|
|
36895
|
+
outputChannelLogger.logDebug("RepoNameResolver:getRepoNamesContainingUri", "error", {
|
|
36896
|
+
verbose: value
|
|
36897
|
+
});
|
|
36410
36898
|
return [];
|
|
36411
36899
|
}
|
|
36412
36900
|
return value;
|
|
@@ -36418,7 +36906,7 @@ class RepoNameResolver {
|
|
|
36418
36906
|
let remoteUrlsInfo = this.fsPathToRemoteUrlsInfo.get(key2);
|
|
36419
36907
|
if (!remoteUrlsInfo) {
|
|
36420
36908
|
remoteUrlsInfo = gitRemoteUrlsForUri(uri, signal2).catch((error) => {
|
|
36421
|
-
logError$
|
|
36909
|
+
logError$1("RepoNameResolver:getRemoteUrlsInfoCached", "error", {
|
|
36422
36910
|
verbose: error
|
|
36423
36911
|
});
|
|
36424
36912
|
return [];
|
|
@@ -36448,7 +36936,9 @@ class RepoNameResolver {
|
|
|
36448
36936
|
),
|
|
36449
36937
|
map$1((value) => {
|
|
36450
36938
|
if (isError$3(value)) {
|
|
36451
|
-
logDebug("RepoNameResolver:getRepoNameCached", "error", {
|
|
36939
|
+
outputChannelLogger.logDebug("RepoNameResolver:getRepoNameCached", "error", {
|
|
36940
|
+
verbose: value
|
|
36941
|
+
});
|
|
36452
36942
|
return null;
|
|
36453
36943
|
}
|
|
36454
36944
|
return value;
|
|
@@ -36495,7 +36985,7 @@ async function getContextFileFromCursor(newCursorPosition) {
|
|
|
36495
36985
|
size
|
|
36496
36986
|
};
|
|
36497
36987
|
} catch (error) {
|
|
36498
|
-
logError$
|
|
36988
|
+
logError$1("getContextFileFromCursor", "failed", { verbose: error });
|
|
36499
36989
|
return null;
|
|
36500
36990
|
}
|
|
36501
36991
|
});
|
|
@@ -36631,7 +37121,7 @@ async function executeDocChatCommand(args2) {
|
|
|
36631
37121
|
return wrapInActiveSpan("command.doc", async (span2) => {
|
|
36632
37122
|
var _a3;
|
|
36633
37123
|
span2.setAttribute("sampled", true);
|
|
36634
|
-
logDebug
|
|
37124
|
+
logDebug("executeDocCommand", "executing", { verbose: args2 });
|
|
36635
37125
|
const editor = (args2 == null ? void 0 : args2.uri) ? await window$1.showTextDocument(args2.uri) : (_a3 = getEditor()) == null ? void 0 : _a3.active;
|
|
36636
37126
|
const document2 = editor == null ? void 0 : editor.document;
|
|
36637
37127
|
if (!document2) {
|
|
@@ -36657,7 +37147,7 @@ async function executeDocCommand(args2) {
|
|
|
36657
37147
|
return wrapInActiveSpan("command.doc", async (span2) => {
|
|
36658
37148
|
var _a3;
|
|
36659
37149
|
span2.setAttribute("sampled", true);
|
|
36660
|
-
logDebug
|
|
37150
|
+
logDebug("executeDocCommand", "executing", { verbose: args2 });
|
|
36661
37151
|
let prompt = PromptString.fromDefaultCommands(commands, "doc");
|
|
36662
37152
|
if (args2 == null ? void 0 : args2.additionalInstruction) {
|
|
36663
37153
|
span2.addEvent("additionalInstruction");
|
|
@@ -36676,7 +37166,7 @@ async function executeDocCommand(args2) {
|
|
|
36676
37166
|
if (!(selectionText == null ? void 0 : selectionText.trim())) {
|
|
36677
37167
|
throw new Error("Cannot document an empty selection.");
|
|
36678
37168
|
}
|
|
36679
|
-
logDebug
|
|
37169
|
+
logDebug(
|
|
36680
37170
|
"executeDocCommand",
|
|
36681
37171
|
`selectionText: ${selectionText ? selectionText.slice(0, 70) + (selectionText.length > 70 ? "..." : "") : "null"}`
|
|
36682
37172
|
);
|
|
@@ -36722,7 +37212,7 @@ async function explainCommand(span2, args2) {
|
|
|
36722
37212
|
async function executeExplainCommand(args2) {
|
|
36723
37213
|
return wrapInActiveSpan("command.explain", async (span2) => {
|
|
36724
37214
|
span2.setAttribute("sampled", true);
|
|
36725
|
-
logDebug
|
|
37215
|
+
logDebug("executeExplainCommand", "executing", { args: args2 });
|
|
36726
37216
|
const editor = getEditor();
|
|
36727
37217
|
if (editor.active && await isUriIgnoredByContextFilterWithNotification(editor.active.document.uri, "command")) {
|
|
36728
37218
|
return;
|
|
@@ -36786,7 +37276,7 @@ async function executeSmellCommand(args2) {
|
|
|
36786
37276
|
if (editor.active && await isUriIgnoredByContextFilterWithNotification(editor.active.document.uri, "command")) {
|
|
36787
37277
|
return;
|
|
36788
37278
|
}
|
|
36789
|
-
logDebug
|
|
37279
|
+
logDebug("executeSmellCommand", "executing", { args: args2 });
|
|
36790
37280
|
telemetryRecorder.recordEvent("cody.command.smell", "executed", {
|
|
36791
37281
|
metadata: {
|
|
36792
37282
|
useCodebaseContex: 0
|
|
@@ -36915,7 +37405,7 @@ async function getWorkspaceFilesContext(globalPattern, excludePattern, maxResult
|
|
|
36915
37405
|
})
|
|
36916
37406
|
)).filter(isDefined);
|
|
36917
37407
|
} catch (error) {
|
|
36918
|
-
logError$
|
|
37408
|
+
logError$1("getWorkspaceFilesContext failed", `${error}`);
|
|
36919
37409
|
return [];
|
|
36920
37410
|
}
|
|
36921
37411
|
});
|
|
@@ -36973,7 +37463,7 @@ async function executeTestEditCommand(args2) {
|
|
|
36973
37463
|
return wrapInActiveSpan("command.test", async (span2) => {
|
|
36974
37464
|
var _a3, _b2;
|
|
36975
37465
|
span2.setAttribute("sampled", true);
|
|
36976
|
-
logDebug
|
|
37466
|
+
logDebug("executeTestEditCommand", "executing", { verbose: args2 });
|
|
36977
37467
|
const newTestFilePrompt = PromptString.fromDefaultCommands(commands, "test");
|
|
36978
37468
|
const newTestSuitePrompt = ps`Review the shared code context to identify the testing framework and libraries in use. Then, create a new test suite with multiple new unit tests for my selected code following the same patterns, testing framework, conventions, and libraries as shown in the shared context. Pay attention to the shared context to ensure that your response code does not contain cases that have already been covered. Focus on generating new unit tests for uncovered cases. Respond only with the fully completed code for the new tests without any added comments, fragments, or TODO. The new tests should validate the expected functionality and cover edge cases for the selected code. The goal is to provide me with a new test suite that I can add to the end of the existing test file. Enclose only the new test suite without any import statements or modules in your response. Do not repeat tests from the shared context.`;
|
|
36979
37469
|
const editor = (_a3 = getEditor()) == null ? void 0 : _a3.active;
|
|
@@ -36988,7 +37478,7 @@ async function executeTestEditCommand(args2) {
|
|
|
36988
37478
|
throw new Error("Cannot generate unit test on empty selection.");
|
|
36989
37479
|
}
|
|
36990
37480
|
const contextFiles = await getContextFilesForUnitTestCommand(uri).catch((error) => {
|
|
36991
|
-
logError$
|
|
37481
|
+
logError$1("executeNewTestCommand", "failed to fetch context", { verbose: error });
|
|
36992
37482
|
return [];
|
|
36993
37483
|
});
|
|
36994
37484
|
const destinationFile = (_b2 = contextFiles.find(
|
|
@@ -37100,7 +37590,7 @@ async function getContextFileFromDirectory(directory) {
|
|
|
37100
37590
|
}
|
|
37101
37591
|
}
|
|
37102
37592
|
} catch (error) {
|
|
37103
|
-
logError$
|
|
37593
|
+
logError$1("getContextFileFromDirectory", "failed", { verbose: error });
|
|
37104
37594
|
}
|
|
37105
37595
|
return contextFiles;
|
|
37106
37596
|
});
|
|
@@ -37145,7 +37635,7 @@ async function executeTestCaseEditCommand(args2) {
|
|
|
37145
37635
|
const files = await getContextFilesForAddingUnitTestCases(document2.uri);
|
|
37146
37636
|
contextFiles.push(...files);
|
|
37147
37637
|
} catch (error) {
|
|
37148
|
-
logError$
|
|
37638
|
+
logError$1("executeNewTestCommand", "failed to fetch context", { verbose: error });
|
|
37149
37639
|
}
|
|
37150
37640
|
const startLine = editor.selection.start.line + 1;
|
|
37151
37641
|
const endLine = Math.max(startLine, editor.selection.end.line - 1);
|
|
@@ -37171,7 +37661,7 @@ async function executeExplainOutput(args2) {
|
|
|
37171
37661
|
return wrapInActiveSpan("command.terminal", async (span2) => {
|
|
37172
37662
|
var _a3;
|
|
37173
37663
|
span2.setAttribute("sampled", true);
|
|
37174
|
-
logDebug
|
|
37664
|
+
logDebug("executeExplainOutput", "executing", { args: args2 });
|
|
37175
37665
|
const requestID = v4();
|
|
37176
37666
|
const source = "terminal";
|
|
37177
37667
|
telemetryRecorder.recordEvent("cody.command.terminal", "executed", {
|
|
@@ -37264,7 +37754,7 @@ function createOrUpdateTelemetryRecorderProvider(isExtensionModeDevOrTest) {
|
|
|
37264
37754
|
resolvedConfig.subscribe(({ configuration, auth: auth2, clientState, isReinstall: isReinstall2 }) => {
|
|
37265
37755
|
const initialize = telemetryRecorderProvider === void 0;
|
|
37266
37756
|
if (isExtensionModeDevOrTest) {
|
|
37267
|
-
logDebug(
|
|
37757
|
+
outputChannelLogger.logDebug(
|
|
37268
37758
|
debugLogLabel,
|
|
37269
37759
|
"using telemetry recorder for dev mode (whitelisted events only)"
|
|
37270
37760
|
);
|
|
@@ -37294,8 +37784,6 @@ function createOrUpdateTelemetryRecorderProvider(isExtensionModeDevOrTest) {
|
|
|
37294
37784
|
}
|
|
37295
37785
|
}
|
|
37296
37786
|
);
|
|
37297
|
-
} else if (!configuration.isRunningInsideAgent || configuration.agentHasPersistentStorage) {
|
|
37298
|
-
telemetryRecorder.recordEvent("cody.extension", "savedLogin");
|
|
37299
37787
|
}
|
|
37300
37788
|
}
|
|
37301
37789
|
})
|
|
@@ -37645,9 +38133,7 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
37645
38133
|
if (!isFileProvided) {
|
|
37646
38134
|
return fallbackUri;
|
|
37647
38135
|
}
|
|
37648
|
-
|
|
37649
|
-
const hasExistingRoot = await doesFileExist(rootDir);
|
|
37650
|
-
if (hasExistingRoot) {
|
|
38136
|
+
if (path$1.isAbsolute(uri)) {
|
|
37651
38137
|
return Uri.file(uri);
|
|
37652
38138
|
}
|
|
37653
38139
|
if (!baseDirUri) {
|
|
@@ -37661,11 +38147,22 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
37661
38147
|
return smartJoinPath(baseDirUri, uri);
|
|
37662
38148
|
}
|
|
37663
38149
|
function smartJoinPath(baseDirUri, relativeFileUri) {
|
|
38150
|
+
if (path$1.isAbsolute(relativeFileUri)) {
|
|
38151
|
+
return Uri.file(relativeFileUri);
|
|
38152
|
+
}
|
|
37664
38153
|
const workspacePath = baseDirUri.path.split(separatorsRegex).filter((segment) => segment.length > 0);
|
|
37665
38154
|
const filePath = relativeFileUri.split(separatorsRegex).filter((segment) => segment.length > 0);
|
|
37666
|
-
const
|
|
37667
|
-
|
|
37668
|
-
|
|
38155
|
+
const maxOverlap = Math.min(workspacePath.length, filePath.length);
|
|
38156
|
+
let overlapLength = 0;
|
|
38157
|
+
for (let k = maxOverlap; k >= 1; k--) {
|
|
38158
|
+
const workspaceSuffix = workspacePath.slice(-k);
|
|
38159
|
+
const filePrefix = filePath.slice(0, k);
|
|
38160
|
+
if (isEqual(workspaceSuffix, filePrefix)) {
|
|
38161
|
+
overlapLength = k;
|
|
38162
|
+
break;
|
|
38163
|
+
}
|
|
38164
|
+
}
|
|
38165
|
+
const uniqueFilePath = overlapLength > 0 ? filePath.slice(overlapLength) : filePath;
|
|
37669
38166
|
const resultPath = path$1.join(baseDirUri.path, ...uniqueFilePath);
|
|
37670
38167
|
return Uri.file(resultPath);
|
|
37671
38168
|
}
|
|
@@ -37762,10 +38259,6 @@ async function getSmartApplyModel(authStatus2) {
|
|
|
37762
38259
|
if (isInstantModeEnabled) {
|
|
37763
38260
|
return SMART_APPLY_MODEL_IDENTIFIERS.FireworksQwenCodeDefault;
|
|
37764
38261
|
}
|
|
37765
|
-
if (isS2(authStatus2)) {
|
|
37766
|
-
const defaultModel = "anthropic::2024-10-22::claude-3-5-sonnet-latest";
|
|
37767
|
-
return defaultModel;
|
|
37768
|
-
}
|
|
37769
38262
|
return void 0;
|
|
37770
38263
|
}
|
|
37771
38264
|
async function handleSmartApply({
|
|
@@ -37804,7 +38297,7 @@ async function handleSmartApply({
|
|
|
37804
38297
|
id,
|
|
37805
38298
|
document: document2,
|
|
37806
38299
|
instruction: PromptString.unsafe_fromUserQuery(instruction || ""),
|
|
37807
|
-
model: await getSmartApplyModel(
|
|
38300
|
+
model: await getSmartApplyModel(),
|
|
37808
38301
|
replacement: code18,
|
|
37809
38302
|
isNewFile,
|
|
37810
38303
|
traceparent
|
|
@@ -37827,7 +38320,7 @@ async function handleSmartApply({
|
|
|
37827
38320
|
id,
|
|
37828
38321
|
document: document2,
|
|
37829
38322
|
instruction: PromptString.unsafe_fromUserQuery(instruction || ""),
|
|
37830
|
-
model: await getSmartApplyModel(
|
|
38323
|
+
model: await getSmartApplyModel(),
|
|
37831
38324
|
replacement: code18,
|
|
37832
38325
|
isNewFile,
|
|
37833
38326
|
traceparent
|
|
@@ -37879,7 +38372,7 @@ async function isCodeFromChatCodeBlockAction(newCode) {
|
|
|
37879
38372
|
}
|
|
37880
38373
|
return { ...storedCode, operation: "paste" };
|
|
37881
38374
|
}
|
|
37882
|
-
const LOG_INTERVAL
|
|
38375
|
+
const LOG_INTERVAL = 30 * 60 * 1e3;
|
|
37883
38376
|
const RAPID_CHANGE_TIMEOUT = 15;
|
|
37884
38377
|
const SELECTION_TIMEOUT = 5e3;
|
|
37885
38378
|
const changeBoundaries = {
|
|
@@ -37955,7 +38448,7 @@ const _CharactersLogger = class _CharactersLogger {
|
|
|
37955
38448
|
);
|
|
37956
38449
|
this.windowFocused = window2.state.focused;
|
|
37957
38450
|
this.activeTextEditor = window2.activeTextEditor;
|
|
37958
|
-
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL
|
|
38451
|
+
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL);
|
|
37959
38452
|
}
|
|
37960
38453
|
flush() {
|
|
37961
38454
|
try {
|
|
@@ -37973,7 +38466,7 @@ const _CharactersLogger = class _CharactersLogger {
|
|
|
37973
38466
|
} finally {
|
|
37974
38467
|
this.changeCounters = { ...DEFAULT_COUNTERS };
|
|
37975
38468
|
if (!this.isDisposed) {
|
|
37976
|
-
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL
|
|
38469
|
+
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL);
|
|
37977
38470
|
}
|
|
37978
38471
|
}
|
|
37979
38472
|
}
|
|
@@ -38195,14 +38688,14 @@ class UpstreamHealthProvider {
|
|
|
38195
38688
|
});
|
|
38196
38689
|
if ("error" in upstreamResult) {
|
|
38197
38690
|
this.lastUpstreamLatency = void 0;
|
|
38198
|
-
logDebug
|
|
38691
|
+
logDebug("UpstreamHealth", "Failed to ping upstream host", {
|
|
38199
38692
|
verbose: {
|
|
38200
38693
|
error: upstreamResult.error
|
|
38201
38694
|
}
|
|
38202
38695
|
});
|
|
38203
38696
|
} else {
|
|
38204
38697
|
this.lastUpstreamLatency = upstreamResult.latency;
|
|
38205
|
-
logDebug
|
|
38698
|
+
logDebug(
|
|
38206
38699
|
"UpstreamHealth",
|
|
38207
38700
|
`Ping took ${Math.round(upstreamResult.latency)}ms ${this.lastGatewayLatency ? `(Gateway: ${Math.round(this.lastGatewayLatency)}ms)` : ""}`,
|
|
38208
38701
|
{
|
|
@@ -38235,63 +38728,6 @@ async function measureLatencyToUri(headers, uri) {
|
|
|
38235
38728
|
return { error };
|
|
38236
38729
|
}
|
|
38237
38730
|
}
|
|
38238
|
-
const LOG_INTERVAL = 30 * 60 * 1e3;
|
|
38239
|
-
const AUTOCOMPLETE_STAGE_COUNTER_INITIAL_STATE = {
|
|
38240
|
-
preLastCandidate: 0,
|
|
38241
|
-
preCache: 0,
|
|
38242
|
-
preSmartThrottle: 0,
|
|
38243
|
-
preDebounce: 0,
|
|
38244
|
-
preContextRetrieval: 0,
|
|
38245
|
-
preNetworkRequest: 0,
|
|
38246
|
-
preFinalCancellationCheck: 0,
|
|
38247
|
-
preVisibilityCheck: 0
|
|
38248
|
-
};
|
|
38249
|
-
class AutocompleteStageCounter {
|
|
38250
|
-
constructor() {
|
|
38251
|
-
__publicField2(this, "nextTimeoutId", null);
|
|
38252
|
-
__publicField2(this, "providerModel", null);
|
|
38253
|
-
__publicField2(this, "currentState", { ...AUTOCOMPLETE_STAGE_COUNTER_INITIAL_STATE });
|
|
38254
|
-
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL);
|
|
38255
|
-
}
|
|
38256
|
-
setProviderModel(providerModel) {
|
|
38257
|
-
if (this.providerModel !== null && this.providerModel !== providerModel) {
|
|
38258
|
-
this.flush();
|
|
38259
|
-
}
|
|
38260
|
-
this.providerModel = providerModel;
|
|
38261
|
-
}
|
|
38262
|
-
//
|
|
38263
|
-
//
|
|
38264
|
-
flush() {
|
|
38265
|
-
this.nextTimeoutId = null;
|
|
38266
|
-
const stateToLog = this.currentState;
|
|
38267
|
-
this.currentState = { ...AUTOCOMPLETE_STAGE_COUNTER_INITIAL_STATE };
|
|
38268
|
-
if (Object.values(stateToLog).some((count) => count > 0)) {
|
|
38269
|
-
telemetryRecorder.recordEvent("cody.completion.stageCounter", "flush", {
|
|
38270
|
-
metadata: stateToLog,
|
|
38271
|
-
privateMetadata: { providerModel: this.providerModel }
|
|
38272
|
-
});
|
|
38273
|
-
}
|
|
38274
|
-
this.nextTimeoutId = setTimeout(() => this.flush(), LOG_INTERVAL);
|
|
38275
|
-
}
|
|
38276
|
-
/**
|
|
38277
|
-
* Records the occurrence of a specific stage in the autocompletion generation pipeline.
|
|
38278
|
-
*/
|
|
38279
|
-
record(state2) {
|
|
38280
|
-
if (!this.providerModel) {
|
|
38281
|
-
return;
|
|
38282
|
-
}
|
|
38283
|
-
this.currentState[state2]++;
|
|
38284
|
-
}
|
|
38285
|
-
//
|
|
38286
|
-
// Like the code above, you can reuse the code outside the XML tags to detect the functionality, formats, style, patterns, and logics in use. Then, use what you detect and reuse methods/libraries to complete and enclose completed code only inside XML tags precisely without duplicating existing implementations. Here is the code:
|
|
38287
|
-
dispose() {
|
|
38288
|
-
this.flush();
|
|
38289
|
-
if (this.nextTimeoutId) {
|
|
38290
|
-
clearTimeout(this.nextTimeoutId);
|
|
38291
|
-
}
|
|
38292
|
-
}
|
|
38293
|
-
}
|
|
38294
|
-
new AutocompleteStageCounter();
|
|
38295
38731
|
function getLanguageConfig(languageId) {
|
|
38296
38732
|
switch (languageId) {
|
|
38297
38733
|
case "astro":
|
|
@@ -39040,7 +39476,7 @@ class ProtocolTextDocumentWithUri {
|
|
|
39040
39476
|
this.uri = uri;
|
|
39041
39477
|
this.underlying = underlying ?? { uri: uri.toString() };
|
|
39042
39478
|
if (this.underlying.uri !== uri.toString()) {
|
|
39043
|
-
logDebug(
|
|
39479
|
+
outputChannelLogger.logDebug(
|
|
39044
39480
|
"ProtocolTextDocumentWithUri",
|
|
39045
39481
|
"correcting invariant violation",
|
|
39046
39482
|
`${this.uri} (this.uri) !== ${this.underlying.uri} (this.underlying.uri)`
|
|
@@ -39090,17 +39526,17 @@ class AgentAuthHandler {
|
|
|
39090
39526
|
}
|
|
39091
39527
|
this.startServer(url);
|
|
39092
39528
|
} catch (error) {
|
|
39093
|
-
logDebug
|
|
39529
|
+
logDebug("AgentAuthHandler", `Invalid callback URL: ${error}`);
|
|
39094
39530
|
}
|
|
39095
39531
|
}
|
|
39096
39532
|
startServer(callbackUri) {
|
|
39097
39533
|
var _a3;
|
|
39098
39534
|
if (!((_a3 = this.tokenCallbackHandlers) == null ? void 0 : _a3.length)) {
|
|
39099
|
-
logDebug
|
|
39535
|
+
logDebug("AgentAuthHandler", "Token callback handler is not set.");
|
|
39100
39536
|
return;
|
|
39101
39537
|
}
|
|
39102
39538
|
if (this.server && this.port) {
|
|
39103
|
-
logDebug
|
|
39539
|
+
logDebug("AgentAuthHandler", "Server already running");
|
|
39104
39540
|
this.redirectToEndpointLoginPage(callbackUri);
|
|
39105
39541
|
return;
|
|
39106
39542
|
}
|
|
@@ -39137,17 +39573,17 @@ class AgentAuthHandler {
|
|
|
39137
39573
|
server.listen(0, "127.0.0.1", () => {
|
|
39138
39574
|
this.port = server.address().port;
|
|
39139
39575
|
this.server = server;
|
|
39140
|
-
logDebug
|
|
39576
|
+
logDebug("AgentAuthHandler", `Server listening on port ${this.port}`);
|
|
39141
39577
|
this.redirectToEndpointLoginPage(callbackUri);
|
|
39142
39578
|
setTimeout(() => this.closeServer(), SIX_MINUTES);
|
|
39143
39579
|
});
|
|
39144
39580
|
server.on("error", (error) => {
|
|
39145
|
-
logDebug
|
|
39581
|
+
logDebug("AgentAuthHandler", `Server error: ${error}`);
|
|
39146
39582
|
});
|
|
39147
39583
|
}
|
|
39148
39584
|
closeServer() {
|
|
39149
39585
|
if (this.server) {
|
|
39150
|
-
logDebug
|
|
39586
|
+
logDebug("AgentAuthHandler", "Auth server closed");
|
|
39151
39587
|
this.server.close();
|
|
39152
39588
|
}
|
|
39153
39589
|
this.server = null;
|
|
@@ -39176,8 +39612,14 @@ class AgentAuthHandler {
|
|
|
39176
39612
|
} else {
|
|
39177
39613
|
const params = new URLSearchParams(decodeURIComponent(uri.search));
|
|
39178
39614
|
const requestFrom = params.get("requestFrom");
|
|
39615
|
+
const user_code = params.get("user_code");
|
|
39179
39616
|
if (requestFrom) {
|
|
39180
39617
|
params.set("requestFrom", `${requestFrom}-${this.port}`);
|
|
39618
|
+
}
|
|
39619
|
+
if (user_code) {
|
|
39620
|
+
params.set("user_code", user_code);
|
|
39621
|
+
}
|
|
39622
|
+
if (requestFrom || user_code) {
|
|
39181
39623
|
uri.search = params.toString();
|
|
39182
39624
|
}
|
|
39183
39625
|
}
|
|
@@ -39198,7 +39640,7 @@ function getValidCallbackUri(uri) {
|
|
|
39198
39640
|
}
|
|
39199
39641
|
return URI.parse(endpointUri.href);
|
|
39200
39642
|
} catch (error) {
|
|
39201
|
-
logDebug
|
|
39643
|
+
logDebug("Invalid URL: ", `${error}`);
|
|
39202
39644
|
return null;
|
|
39203
39645
|
}
|
|
39204
39646
|
}
|
|
@@ -39274,7 +39716,7 @@ function createFileSystemRuleProvider() {
|
|
|
39274
39716
|
return rules;
|
|
39275
39717
|
} catch (error) {
|
|
39276
39718
|
if (!(error && typeof error === "object" && "code" in error && error.code === "FileNotFound")) {
|
|
39277
|
-
logDebug
|
|
39719
|
+
logDebug(
|
|
39278
39720
|
"rules",
|
|
39279
39721
|
`Error reading rules for ${searchPath}: ${error}`
|
|
39280
39722
|
);
|
|
@@ -39355,7 +39797,7 @@ async function listRulesApplyingToRemoteFile(client, repoName, filePath, signal2
|
|
|
39355
39797
|
}
|
|
39356
39798
|
return resp.rules ?? [];
|
|
39357
39799
|
} catch (error) {
|
|
39358
|
-
logDebug
|
|
39800
|
+
logDebug(
|
|
39359
39801
|
"rules",
|
|
39360
39802
|
`Error listing rules for remote file ${filePath} in repository ${repoName}: ${error}`
|
|
39361
39803
|
);
|
|
@@ -39679,7 +40121,7 @@ async function getContextFileFromUri(file, range) {
|
|
|
39679
40121
|
size
|
|
39680
40122
|
};
|
|
39681
40123
|
} catch (error) {
|
|
39682
|
-
logError$
|
|
40124
|
+
logError$1("getContextFileFromUri", "failed", { verbose: error });
|
|
39683
40125
|
return null;
|
|
39684
40126
|
}
|
|
39685
40127
|
});
|
|
@@ -39712,7 +40154,7 @@ async function getContextFromRelativePath(path2) {
|
|
|
39712
40154
|
size
|
|
39713
40155
|
};
|
|
39714
40156
|
} catch (error) {
|
|
39715
|
-
logError$
|
|
40157
|
+
logError$1("getContextFileFromUri", "failed", { verbose: error });
|
|
39716
40158
|
return null;
|
|
39717
40159
|
}
|
|
39718
40160
|
}
|
|
@@ -40530,7 +40972,7 @@ async function resolveContextMentionProviderContextItem({ provider: providerUri,
|
|
|
40530
40972
|
return [];
|
|
40531
40973
|
}
|
|
40532
40974
|
if (!item.mention) {
|
|
40533
|
-
logError$
|
|
40975
|
+
logError$1("OpenCtx", "resolving context item is missing mention parameter", item);
|
|
40534
40976
|
return [];
|
|
40535
40977
|
}
|
|
40536
40978
|
const mention = {
|
|
@@ -40543,15 +40985,16 @@ async function resolveContextMentionProviderContextItem({ provider: providerUri,
|
|
|
40543
40985
|
);
|
|
40544
40986
|
signal2 == null ? void 0 : signal2.throwIfAborted();
|
|
40545
40987
|
return items.map(
|
|
40546
|
-
(
|
|
40988
|
+
(openCtxItem) => {
|
|
40547
40989
|
var _a3;
|
|
40548
|
-
return ((_a3 =
|
|
40990
|
+
return ((_a3 = openCtxItem.ai) == null ? void 0 : _a3.content) ? {
|
|
40549
40991
|
type: "openctx",
|
|
40550
|
-
title:
|
|
40551
|
-
uri: URI.parse(
|
|
40552
|
-
providerUri:
|
|
40553
|
-
content:
|
|
40554
|
-
provider: "openctx"
|
|
40992
|
+
title: openCtxItem.title,
|
|
40993
|
+
uri: URI.parse(openCtxItem.url || openCtxItem.providerUri),
|
|
40994
|
+
providerUri: openCtxItem.providerUri,
|
|
40995
|
+
content: openCtxItem.ai.content,
|
|
40996
|
+
provider: "openctx",
|
|
40997
|
+
source: item.source
|
|
40555
40998
|
} : null;
|
|
40556
40999
|
}
|
|
40557
41000
|
).filter((context2) => context2 !== null);
|
|
@@ -42741,6 +43184,9 @@ const objectivec = [
|
|
|
42741
43184
|
"m",
|
|
42742
43185
|
"mm"
|
|
42743
43186
|
];
|
|
43187
|
+
const matlab = [
|
|
43188
|
+
"m"
|
|
43189
|
+
];
|
|
42744
43190
|
const ocaml = [
|
|
42745
43191
|
"ml",
|
|
42746
43192
|
"eliom",
|
|
@@ -43048,6 +43494,7 @@ const extensionMapping = {
|
|
|
43048
43494
|
markdown,
|
|
43049
43495
|
nginx,
|
|
43050
43496
|
objectivec,
|
|
43497
|
+
matlab,
|
|
43051
43498
|
ocaml,
|
|
43052
43499
|
pascal,
|
|
43053
43500
|
perl,
|
|
@@ -43090,17 +43537,25 @@ function getMapping() {
|
|
|
43090
43537
|
mapping = /* @__PURE__ */ new Map();
|
|
43091
43538
|
for (const [language, extensions2] of Object.entries(extensionMapping)) {
|
|
43092
43539
|
for (const extension of extensions2) {
|
|
43093
|
-
mapping.set(extension, language);
|
|
43540
|
+
mapping.set(extension.toLowerCase(), language);
|
|
43094
43541
|
}
|
|
43095
43542
|
}
|
|
43096
43543
|
return mapping;
|
|
43097
43544
|
}
|
|
43098
43545
|
function getLanguageForFileName(filePath) {
|
|
43099
43546
|
const fileName = path$1.basename(filePath);
|
|
43100
|
-
const extension = fileName.split(".").pop() || fileName;
|
|
43547
|
+
const extension = (fileName.split(".").pop() || fileName).toLowerCase();
|
|
43101
43548
|
const language = getMapping().get(extension);
|
|
43102
43549
|
return language || extension;
|
|
43103
43550
|
}
|
|
43551
|
+
function getLanguageForFileNameAndContent(filePath, content) {
|
|
43552
|
+
const fileName = path$1.basename(filePath);
|
|
43553
|
+
const extension = (fileName.split(".").pop() || fileName).toLowerCase();
|
|
43554
|
+
if (extension === "m") {
|
|
43555
|
+
return isMatlabFile(content) ? "matlab" : "objectivec";
|
|
43556
|
+
}
|
|
43557
|
+
return getLanguageForFileName(filePath);
|
|
43558
|
+
}
|
|
43104
43559
|
class DocumentOffsets {
|
|
43105
43560
|
constructor(document2) {
|
|
43106
43561
|
__publicField2(this, "lines", []);
|
|
@@ -43170,7 +43625,10 @@ class AgentTextDocument {
|
|
|
43170
43625
|
__publicField2(this, "isClosed", false);
|
|
43171
43626
|
__publicField2(this, "eol", EndOfLine.LF);
|
|
43172
43627
|
this.protocolDocument = protocolDocument;
|
|
43173
|
-
this.languageId =
|
|
43628
|
+
this.languageId = getLanguageForFileNameAndContent(
|
|
43629
|
+
this.fileName,
|
|
43630
|
+
this.protocolDocument.underlying.content ?? ""
|
|
43631
|
+
);
|
|
43174
43632
|
this.offsets = new DocumentOffsets(protocolDocument.underlying);
|
|
43175
43633
|
this.lineCount = this.offsets.lineCount();
|
|
43176
43634
|
}
|
|
@@ -43289,7 +43747,7 @@ class AgentTextEditor {
|
|
|
43289
43747
|
if ((_a3 = this.params) == null ? void 0 : _a3.edit) {
|
|
43290
43748
|
return this.params.edit(this.agentDocument.uri, callback, options);
|
|
43291
43749
|
}
|
|
43292
|
-
logDebug
|
|
43750
|
+
logDebug("AgentTextEditor:edit()", "not supported");
|
|
43293
43751
|
return Promise.resolve(false);
|
|
43294
43752
|
});
|
|
43295
43753
|
this.agentDocument = agentDocument;
|
|
@@ -43929,7 +44387,7 @@ class AgentWorkspaceDocuments {
|
|
|
43929
44387
|
if (uri.scheme === "untitled") {
|
|
43930
44388
|
document2.underlying.content = "";
|
|
43931
44389
|
} else if (!await doesFileExist(uri)) {
|
|
43932
|
-
logError$
|
|
44390
|
+
logError$1(
|
|
43933
44391
|
"AgentWorkspaceDocuments.openTextDocument()",
|
|
43934
44392
|
"File does not exist",
|
|
43935
44393
|
uri.toString()
|
|
@@ -43938,7 +44396,7 @@ class AgentWorkspaceDocuments {
|
|
|
43938
44396
|
const buffer2 = await fs.readFile(uri.fsPath, "utf8");
|
|
43939
44397
|
document2.underlying.content = buffer2.toString();
|
|
43940
44398
|
} else {
|
|
43941
|
-
logError$
|
|
44399
|
+
logError$1("vscode.workspace.openTextDocument", `unable to read non-file URI: ${uri}`);
|
|
43942
44400
|
}
|
|
43943
44401
|
}
|
|
43944
44402
|
return Promise.resolve(this.loadAndUpdateDocument(document2));
|
|
@@ -45505,14 +45963,14 @@ function copyExtensionRelativeResources(extensionPath, extensionClient) {
|
|
|
45505
45963
|
return;
|
|
45506
45964
|
}
|
|
45507
45965
|
} catch {
|
|
45508
|
-
logDebug
|
|
45966
|
+
logDebug("copyExtensionRelativeResources", `Failed to find ${source}, skipping copy`);
|
|
45509
45967
|
return;
|
|
45510
45968
|
}
|
|
45511
45969
|
try {
|
|
45512
45970
|
mkdirSync(path$1.dirname(target), { recursive: true });
|
|
45513
45971
|
copySync(source, target);
|
|
45514
45972
|
} catch (err2) {
|
|
45515
|
-
logDebug
|
|
45973
|
+
logDebug("copyExtensionRelativeResources", `Failed to copy ${source} to dist ${target}`, err2);
|
|
45516
45974
|
}
|
|
45517
45975
|
};
|
|
45518
45976
|
copySources("win-ca-roots.exe");
|
|
@@ -45583,7 +46041,7 @@ class Agent extends MessageHandler {
|
|
|
45583
46041
|
edit: (uri, callback, options) => {
|
|
45584
46042
|
var _a3, _b2;
|
|
45585
46043
|
if (((_b2 = (_a3 = this.clientInfo) == null ? void 0 : _a3.capabilities) == null ? void 0 : _b2.edit) !== "enabled") {
|
|
45586
|
-
logDebug
|
|
46044
|
+
logDebug("CodyAgent", "client does not support operation: textDocument/edit");
|
|
45587
46045
|
return Promise.resolve(false);
|
|
45588
46046
|
}
|
|
45589
46047
|
const edits = [];
|
|
@@ -45764,7 +46222,6 @@ class Agent extends MessageHandler {
|
|
|
45764
46222
|
const textDocument = this.workspace.loadDocument(documentWithUri);
|
|
45765
46223
|
onDidOpenTextDocument.fire(textDocument);
|
|
45766
46224
|
this.pushPendingPromise(this.workspace.fireVisibleTextEditorsDidChange());
|
|
45767
|
-
this.workspace.setActiveTextEditor(this.workspace.newTextEditor(textDocument));
|
|
45768
46225
|
});
|
|
45769
46226
|
this.registerNotification("textDocument/didChange", async (document2) => {
|
|
45770
46227
|
this.handleDocumentChange(document2);
|
|
@@ -46118,12 +46575,12 @@ class Agent extends MessageHandler {
|
|
|
46118
46575
|
var _a3, _b2, _c2;
|
|
46119
46576
|
const provider = await completionProvider();
|
|
46120
46577
|
if (!provider) {
|
|
46121
|
-
logError$
|
|
46578
|
+
logError$1("Agent", "autocomplete/execute", "Completion provider is not initialized");
|
|
46122
46579
|
return { items: [], inlineCompletionItems: [], decoratedEditItems: [] };
|
|
46123
46580
|
}
|
|
46124
46581
|
const uri = typeof params2.uri === "string" ? Uri.parse(params2.uri) : (params2 == null ? void 0 : params2.filePath) ? Uri.file(params2.filePath) : void 0;
|
|
46125
46582
|
if (!uri) {
|
|
46126
|
-
logError$
|
|
46583
|
+
logError$1(
|
|
46127
46584
|
"Agent",
|
|
46128
46585
|
"autocomplete/execute",
|
|
46129
46586
|
`No uri provided for autocomplete request ${JSON.stringify(
|
|
@@ -46134,7 +46591,7 @@ class Agent extends MessageHandler {
|
|
|
46134
46591
|
}
|
|
46135
46592
|
const document2 = this.workspace.getDocument(uri);
|
|
46136
46593
|
if (!document2) {
|
|
46137
|
-
logError$
|
|
46594
|
+
logError$1(
|
|
46138
46595
|
"Agent",
|
|
46139
46596
|
"autocomplete/execute",
|
|
46140
46597
|
"No document found for file path",
|
|
@@ -46329,7 +46786,7 @@ class Agent extends MessageHandler {
|
|
|
46329
46786
|
);
|
|
46330
46787
|
const document2 = this.workspace.getDocument(uri);
|
|
46331
46788
|
if (!document2) {
|
|
46332
|
-
logError$
|
|
46789
|
+
logError$1(
|
|
46333
46790
|
"Agent",
|
|
46334
46791
|
"editTask/getFoldingRanges",
|
|
46335
46792
|
"No document found for file path",
|
|
@@ -46751,7 +47208,7 @@ class Agent extends MessageHandler {
|
|
|
46751
47208
|
metadata: metadata2
|
|
46752
47209
|
});
|
|
46753
47210
|
}
|
|
46754
|
-
logError$
|
|
47211
|
+
logError$1(
|
|
46755
47212
|
"Agent",
|
|
46756
47213
|
'client does not support vscode.workspace.applyEdit() yet. If you are a client author, enable this operation by setting the client capability `editWorkspace: "enabled"`',
|
|
46757
47214
|
new Error().stack
|
|
@@ -46840,7 +47297,7 @@ async function explainHistoryCommand(span2, commandsProvider, args2) {
|
|
|
46840
47297
|
if (isFailure(historyOptions)) {
|
|
46841
47298
|
return historyOptions;
|
|
46842
47299
|
}
|
|
46843
|
-
logDebug
|
|
47300
|
+
logDebug("explainHistoryCommand", "computed history options", JSON.stringify(historyOptions));
|
|
46844
47301
|
let contextItems = [];
|
|
46845
47302
|
try {
|
|
46846
47303
|
contextItems = await commandsProvider.history(historyOptions.uri, historyOptions);
|
|
@@ -46868,7 +47325,7 @@ async function explainHistoryCommand(span2, commandsProvider, args2) {
|
|
|
46868
47325
|
async function executeExplainHistoryCommand(commandsProvider, args2 = {}) {
|
|
46869
47326
|
return wrapInActiveSpan("command.explain-history", async (span2) => {
|
|
46870
47327
|
span2.setAttribute("sampled", true);
|
|
46871
|
-
logDebug
|
|
47328
|
+
logDebug("executeExplainHistoryCommand", "executing", args2);
|
|
46872
47329
|
telemetryRecorder.recordEvent("cody.command.explain-history", "executed", {
|
|
46873
47330
|
interactionID: args2 == null ? void 0 : args2.requestID,
|
|
46874
47331
|
privateMetadata: {
|
|
@@ -46924,7 +47381,7 @@ function isFailure(object) {
|
|
|
46924
47381
|
function handleFailure(span2, result) {
|
|
46925
47382
|
span2.setAttribute("failure-reason", result.reason);
|
|
46926
47383
|
if (result.level === "error") {
|
|
46927
|
-
logError$
|
|
47384
|
+
logError$1(
|
|
46928
47385
|
"executeExplainHistoryCommand",
|
|
46929
47386
|
"error fetching history context",
|
|
46930
47387
|
result.reason,
|
|
@@ -46934,7 +47391,7 @@ function handleFailure(span2, result) {
|
|
|
46934
47391
|
window$1.showErrorMessage(errorMessage);
|
|
46935
47392
|
throw new Error(errorMessage);
|
|
46936
47393
|
}
|
|
46937
|
-
logDebug
|
|
47394
|
+
logDebug(
|
|
46938
47395
|
"executeExplainHistoryCommand",
|
|
46939
47396
|
"failed to explaining history context",
|
|
46940
47397
|
result.reason,
|
|
@@ -47319,7 +47776,7 @@ class CustomCommandsManager {
|
|
|
47319
47776
|
const buildWorkspaceCommands = workspace.isTrusted ? this.build(CustomCommandType.Workspace) : Promise.resolve();
|
|
47320
47777
|
await Promise.all([buildUserCommands, buildWorkspaceCommands]);
|
|
47321
47778
|
} catch (error) {
|
|
47322
|
-
logError
|
|
47779
|
+
outputChannelLogger.logError("CustomCommandsProvider:refresh", "failed", { verbose: error });
|
|
47323
47780
|
}
|
|
47324
47781
|
return { commands: this.customCommandsMap };
|
|
47325
47782
|
}
|
|
@@ -47349,7 +47806,7 @@ class CustomCommandsManager {
|
|
|
47349
47806
|
);
|
|
47350
47807
|
}
|
|
47351
47808
|
} catch (error) {
|
|
47352
|
-
logError
|
|
47809
|
+
outputChannelLogger.logError("CustomCommandsProvider:build", "failed", { verbose: error });
|
|
47353
47810
|
}
|
|
47354
47811
|
return this.customCommandsMap;
|
|
47355
47812
|
}
|
|
@@ -47363,7 +47820,7 @@ class CustomCommandsManager {
|
|
|
47363
47820
|
return;
|
|
47364
47821
|
}
|
|
47365
47822
|
await this.save(newCommand.key, newCommand.prompt, newCommand.type);
|
|
47366
|
-
logDebug("CustomCommandsProvider:newCustomCommandQuickPick:", "saved", {
|
|
47823
|
+
outputChannelLogger.logDebug("CustomCommandsProvider:newCustomCommandQuickPick:", "saved", {
|
|
47367
47824
|
verbose: newCommand
|
|
47368
47825
|
});
|
|
47369
47826
|
}
|
|
@@ -47438,7 +47895,7 @@ class CustomCommandsManager {
|
|
|
47438
47895
|
}
|
|
47439
47896
|
}
|
|
47440
47897
|
showSystemError(title, error) {
|
|
47441
|
-
logDebug("CustomCommandsProvider", title, { verbose: error });
|
|
47898
|
+
outputChannelLogger.logDebug("CustomCommandsProvider", title, { verbose: error });
|
|
47442
47899
|
void window$1.showErrorMessage(`${title} ${error}`);
|
|
47443
47900
|
}
|
|
47444
47901
|
/**
|
|
@@ -47890,7 +48347,7 @@ class CommandsProvider {
|
|
|
47890
48347
|
if (!isFileURI(uri)) {
|
|
47891
48348
|
throw new Error("history only supported on local file paths");
|
|
47892
48349
|
}
|
|
47893
|
-
const { getContextFileFromGitLog } = await import("./git-log-
|
|
48350
|
+
const { getContextFileFromGitLog } = await import("./git-log-DjCz8t7A.mjs");
|
|
47894
48351
|
return getContextFileFromGitLog(uri, options);
|
|
47895
48352
|
}
|
|
47896
48353
|
dispose() {
|
|
@@ -48077,6 +48534,418 @@ ${authStatus2.endpoint}`;
|
|
|
48077
48534
|
return void 0;
|
|
48078
48535
|
}
|
|
48079
48536
|
}
|
|
48537
|
+
async function abortableDelay(ms, signal2) {
|
|
48538
|
+
return new Promise((resolve) => {
|
|
48539
|
+
const timeoutId = setTimeout(() => resolve(false), ms);
|
|
48540
|
+
if (signal2.aborted) {
|
|
48541
|
+
clearTimeout(timeoutId);
|
|
48542
|
+
resolve(true);
|
|
48543
|
+
return;
|
|
48544
|
+
}
|
|
48545
|
+
const onAbort2 = () => {
|
|
48546
|
+
clearTimeout(timeoutId);
|
|
48547
|
+
resolve(true);
|
|
48548
|
+
};
|
|
48549
|
+
signal2.addEventListener("abort", onAbort2);
|
|
48550
|
+
});
|
|
48551
|
+
}
|
|
48552
|
+
let debugDisableDeviceAuth = false;
|
|
48553
|
+
function setDebugDisableDeviceAuth(disabled) {
|
|
48554
|
+
debugDisableDeviceAuth = disabled;
|
|
48555
|
+
outputChannelLogger.logDebug("device-auth", "Debug device auth override", { disabled });
|
|
48556
|
+
}
|
|
48557
|
+
function getDebugDisableDeviceAuth() {
|
|
48558
|
+
return debugDisableDeviceAuth;
|
|
48559
|
+
}
|
|
48560
|
+
async function getOIDCConfiguration(endpoint) {
|
|
48561
|
+
if (debugDisableDeviceAuth) {
|
|
48562
|
+
outputChannelLogger.logDebug("device-auth", "Device auth disabled via debug flag", { endpoint });
|
|
48563
|
+
return null;
|
|
48564
|
+
}
|
|
48565
|
+
const config = await getOIDCConfiguration$1(endpoint);
|
|
48566
|
+
if (!config) {
|
|
48567
|
+
outputChannelLogger.logDebug("device-auth", "OIDC configuration not available", { endpoint });
|
|
48568
|
+
return null;
|
|
48569
|
+
}
|
|
48570
|
+
return config;
|
|
48571
|
+
}
|
|
48572
|
+
async function initiateDeviceAuth(oidcConfig) {
|
|
48573
|
+
if (!(oidcConfig == null ? void 0 : oidcConfig.device_authorization_endpoint)) {
|
|
48574
|
+
return null;
|
|
48575
|
+
}
|
|
48576
|
+
const clientId = getOAuthClientId();
|
|
48577
|
+
try {
|
|
48578
|
+
const response = await fetch(oidcConfig.device_authorization_endpoint, {
|
|
48579
|
+
method: "POST",
|
|
48580
|
+
headers: {
|
|
48581
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
48582
|
+
},
|
|
48583
|
+
body: new URLSearchParams({
|
|
48584
|
+
client_id: clientId,
|
|
48585
|
+
scope: "user:all"
|
|
48586
|
+
})
|
|
48587
|
+
});
|
|
48588
|
+
if (!response.ok) {
|
|
48589
|
+
throw new Error(`Device auth initiation failed: ${response.status} ${response.statusText}`);
|
|
48590
|
+
}
|
|
48591
|
+
const deviceAuth = await response.json();
|
|
48592
|
+
outputChannelLogger.logDebug("device-auth", "Device auth initiated", {
|
|
48593
|
+
device_authorization_endpoint: oidcConfig == null ? void 0 : oidcConfig.device_authorization_endpoint,
|
|
48594
|
+
user_code: deviceAuth.user_code,
|
|
48595
|
+
expires_in: deviceAuth.expires_in
|
|
48596
|
+
});
|
|
48597
|
+
return deviceAuth;
|
|
48598
|
+
} catch (error) {
|
|
48599
|
+
outputChannelLogger.logError("device-auth", "Failed to initiate device auth", error);
|
|
48600
|
+
return null;
|
|
48601
|
+
}
|
|
48602
|
+
}
|
|
48603
|
+
async function pollForToken(oidcConfig, deviceCode, interval2, expiresIn, abortSignal) {
|
|
48604
|
+
const clientId = getOAuthClientId();
|
|
48605
|
+
const startTime = Date.now();
|
|
48606
|
+
const expirationTime = startTime + expiresIn * 1e3;
|
|
48607
|
+
let attempts = 0;
|
|
48608
|
+
const maxAttempts = Math.ceil(expiresIn / interval2);
|
|
48609
|
+
while (Date.now() < expirationTime && attempts < maxAttempts && !abortSignal.aborted) {
|
|
48610
|
+
attempts++;
|
|
48611
|
+
try {
|
|
48612
|
+
const response = await fetch(oidcConfig.token_endpoint, {
|
|
48613
|
+
method: "POST",
|
|
48614
|
+
headers: {
|
|
48615
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
48616
|
+
},
|
|
48617
|
+
body: new URLSearchParams({
|
|
48618
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
48619
|
+
device_code: deviceCode,
|
|
48620
|
+
client_id: clientId
|
|
48621
|
+
})
|
|
48622
|
+
});
|
|
48623
|
+
if (response.ok) {
|
|
48624
|
+
const tokenResponse = await response.json();
|
|
48625
|
+
outputChannelLogger.logDebug("device-auth", "Token received successfully");
|
|
48626
|
+
return tokenResponse;
|
|
48627
|
+
}
|
|
48628
|
+
if (response.status === 400) {
|
|
48629
|
+
const error = await response.json();
|
|
48630
|
+
if (error.error === "authorization_pending") {
|
|
48631
|
+
outputChannelLogger.logDebug(
|
|
48632
|
+
"device-auth",
|
|
48633
|
+
"Authorization pending, continuing to poll",
|
|
48634
|
+
{ attempts }
|
|
48635
|
+
);
|
|
48636
|
+
} else if (error.error === "slow_down") {
|
|
48637
|
+
interval2 = Math.min(interval2 * 2, 60);
|
|
48638
|
+
outputChannelLogger.logDebug("device-auth", "Slowing down polling", {
|
|
48639
|
+
newInterval: interval2
|
|
48640
|
+
});
|
|
48641
|
+
} else if (error.error === "expired_token") {
|
|
48642
|
+
outputChannelLogger.logDebug("device-auth", "Device code expired");
|
|
48643
|
+
return null;
|
|
48644
|
+
} else if (error.error === "access_denied") {
|
|
48645
|
+
outputChannelLogger.logDebug("device-auth", "User denied authorization");
|
|
48646
|
+
return null;
|
|
48647
|
+
} else {
|
|
48648
|
+
outputChannelLogger.logError(
|
|
48649
|
+
"device-auth",
|
|
48650
|
+
"Unknown error during token polling",
|
|
48651
|
+
error
|
|
48652
|
+
);
|
|
48653
|
+
return null;
|
|
48654
|
+
}
|
|
48655
|
+
} else {
|
|
48656
|
+
outputChannelLogger.logError("device-auth", "Unexpected response during token polling", {
|
|
48657
|
+
status: response.status,
|
|
48658
|
+
statusText: response.statusText
|
|
48659
|
+
});
|
|
48660
|
+
return null;
|
|
48661
|
+
}
|
|
48662
|
+
} catch (error) {
|
|
48663
|
+
outputChannelLogger.logError("device-auth", "Error during token polling", error);
|
|
48664
|
+
return null;
|
|
48665
|
+
}
|
|
48666
|
+
const wasCancelled = await abortableDelay(interval2 * 1e3, abortSignal);
|
|
48667
|
+
if (wasCancelled) {
|
|
48668
|
+
return null;
|
|
48669
|
+
}
|
|
48670
|
+
}
|
|
48671
|
+
outputChannelLogger.logDebug("device-auth", "Token polling timed out", { attempts, expiresIn });
|
|
48672
|
+
return null;
|
|
48673
|
+
}
|
|
48674
|
+
async function startDeviceAuthFlow(uri, onUserCode, abortSignal) {
|
|
48675
|
+
const endpoint = formatURL(uri);
|
|
48676
|
+
if (!endpoint) {
|
|
48677
|
+
return { type: "failed" };
|
|
48678
|
+
}
|
|
48679
|
+
telemetryRecorder.recordEvent("cody.auth.device.initiated", "started");
|
|
48680
|
+
const oidcConfig = await getOIDCConfiguration(endpoint);
|
|
48681
|
+
if (!oidcConfig) {
|
|
48682
|
+
outputChannelLogger.logDebug("device-auth", "Failed to get OIDC configuration", { endpoint });
|
|
48683
|
+
return { type: "failed" };
|
|
48684
|
+
}
|
|
48685
|
+
const deviceAuth = await initiateDeviceAuth(oidcConfig);
|
|
48686
|
+
if (!deviceAuth) {
|
|
48687
|
+
outputChannelLogger.logDebug("device-auth", "Device auth not supported", { endpoint });
|
|
48688
|
+
return { type: "failed" };
|
|
48689
|
+
}
|
|
48690
|
+
const deviceUrl = deviceAuth.verification_uri_complete || `${deviceAuth.verification_uri}?user_code=${encodeURIComponent(deviceAuth.user_code)}`;
|
|
48691
|
+
onUserCode(deviceAuth.user_code, deviceUrl);
|
|
48692
|
+
return window$1.withProgress(
|
|
48693
|
+
{
|
|
48694
|
+
location: ProgressLocation.Notification,
|
|
48695
|
+
title: "Waiting for authorization...",
|
|
48696
|
+
cancellable: true
|
|
48697
|
+
},
|
|
48698
|
+
async (progress, cancellationToken) => {
|
|
48699
|
+
const combinedController = new AbortController();
|
|
48700
|
+
cancellationToken.onCancellationRequested(() => {
|
|
48701
|
+
combinedController.abort();
|
|
48702
|
+
outputChannelLogger.logDebug("device-auth", "Device auth cancelled via notification");
|
|
48703
|
+
});
|
|
48704
|
+
if (abortSignal) {
|
|
48705
|
+
abortSignal.addEventListener("abort", () => {
|
|
48706
|
+
combinedController.abort();
|
|
48707
|
+
outputChannelLogger.logDebug("device-auth", "Device auth aborted via webview");
|
|
48708
|
+
});
|
|
48709
|
+
}
|
|
48710
|
+
const tokenResponse = await pollForToken(
|
|
48711
|
+
oidcConfig,
|
|
48712
|
+
deviceAuth.device_code,
|
|
48713
|
+
deviceAuth.interval,
|
|
48714
|
+
deviceAuth.expires_in,
|
|
48715
|
+
combinedController.signal
|
|
48716
|
+
);
|
|
48717
|
+
if (combinedController.signal.aborted) {
|
|
48718
|
+
telemetryRecorder.recordEvent("cody.auth.device.cancelled", "cancelled");
|
|
48719
|
+
const status = { pendingValidation: false };
|
|
48720
|
+
return Promise.resolve({ type: "cancelled", authStatus: status });
|
|
48721
|
+
}
|
|
48722
|
+
if (!tokenResponse) {
|
|
48723
|
+
telemetryRecorder.recordEvent("cody.auth.device.failed", "failed");
|
|
48724
|
+
return { type: "failed" };
|
|
48725
|
+
}
|
|
48726
|
+
if (tokenResponse.refresh_token) {
|
|
48727
|
+
await secretStorage.storeRefreshToken(endpoint, tokenResponse.refresh_token);
|
|
48728
|
+
}
|
|
48729
|
+
if (tokenResponse.expires_in) {
|
|
48730
|
+
const expiresAt = Date.now() + tokenResponse.expires_in * 1e3;
|
|
48731
|
+
await secretStorage.storeTokenExpiresAt(endpoint, expiresAt);
|
|
48732
|
+
}
|
|
48733
|
+
if (tokenResponse.access_token) {
|
|
48734
|
+
await secretStorage.storeToken(endpoint, tokenResponse.access_token, "oauth");
|
|
48735
|
+
}
|
|
48736
|
+
await secretStorage.store(endpoint + "cody.access-token.source", "oauth");
|
|
48737
|
+
const deviceAuthCredential = new OAuthCredential(endpoint, secretStorage);
|
|
48738
|
+
if (!deviceAuthCredential) {
|
|
48739
|
+
telemetryRecorder.recordEvent("cody.auth.device.failed", "failed");
|
|
48740
|
+
return { type: "failed" };
|
|
48741
|
+
}
|
|
48742
|
+
const authStatus2 = await authProvider.validateAndStoreCredentials(
|
|
48743
|
+
{
|
|
48744
|
+
serverEndpoint: endpoint,
|
|
48745
|
+
credentials: deviceAuthCredential
|
|
48746
|
+
},
|
|
48747
|
+
"store-if-valid"
|
|
48748
|
+
);
|
|
48749
|
+
telemetryRecorder.recordEvent("cody.auth.device.completed", "completed", {
|
|
48750
|
+
metadata: {
|
|
48751
|
+
success: authStatus2.authenticated ? 1 : 0
|
|
48752
|
+
}
|
|
48753
|
+
});
|
|
48754
|
+
return { type: "success", authStatus: authStatus2 };
|
|
48755
|
+
}
|
|
48756
|
+
);
|
|
48757
|
+
}
|
|
48758
|
+
function registerAuthDebugCommands(disposables) {
|
|
48759
|
+
disposables.push(
|
|
48760
|
+
// Set token expiry for testing refresh logic
|
|
48761
|
+
commands$1.registerCommand("cody.debug.auth.setTokenExpiry", async () => {
|
|
48762
|
+
const authStatus2 = currentAuthStatus();
|
|
48763
|
+
if (!authStatus2.authenticated) {
|
|
48764
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48765
|
+
return;
|
|
48766
|
+
}
|
|
48767
|
+
const options = [
|
|
48768
|
+
{ label: "1 hour ago (expired)", value: Date.now() - 60 * 60 * 1e3 },
|
|
48769
|
+
{ label: "10 minutes from now", value: Date.now() + 10 * 60 * 1e3 },
|
|
48770
|
+
{ label: "2 minutes from now", value: Date.now() + 2 * 60 * 1e3 },
|
|
48771
|
+
{ label: "30 seconds from now", value: Date.now() + 30 * 1e3 },
|
|
48772
|
+
{ label: "No expiry (remove)", value: null }
|
|
48773
|
+
];
|
|
48774
|
+
const selection = await window$1.showQuickPick(options, {
|
|
48775
|
+
title: "Set Token Expiry",
|
|
48776
|
+
placeHolder: "Choose when the token should expire"
|
|
48777
|
+
});
|
|
48778
|
+
if (!selection) return;
|
|
48779
|
+
const endpoint = authStatus2.endpoint;
|
|
48780
|
+
if (selection.value === null) {
|
|
48781
|
+
await secretStorage.delete(endpoint + "cody.token.expires-at");
|
|
48782
|
+
void window$1.showInformationMessage("Token expiry removed");
|
|
48783
|
+
} else {
|
|
48784
|
+
await secretStorage.storeTokenExpiresAt(endpoint, selection.value);
|
|
48785
|
+
const timeStr = new Date(selection.value).toLocaleString();
|
|
48786
|
+
void window$1.showInformationMessage(`Token expiry set to: ${timeStr}`);
|
|
48787
|
+
}
|
|
48788
|
+
}),
|
|
48789
|
+
// Check current token expiry
|
|
48790
|
+
commands$1.registerCommand("cody.debug.auth.checkTokenExpiry", async () => {
|
|
48791
|
+
const authStatus2 = currentAuthStatus();
|
|
48792
|
+
if (!authStatus2.authenticated) {
|
|
48793
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48794
|
+
return;
|
|
48795
|
+
}
|
|
48796
|
+
const endpoint = authStatus2.endpoint;
|
|
48797
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48798
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48799
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48800
|
+
if (!expiresAt) {
|
|
48801
|
+
void window$1.showInformationMessage("No token expiry set");
|
|
48802
|
+
return;
|
|
48803
|
+
}
|
|
48804
|
+
const now = Date.now();
|
|
48805
|
+
const timeUntilExpiry = expiresAt - now;
|
|
48806
|
+
const isExpired = timeUntilExpiry <= 0;
|
|
48807
|
+
const needsRefresh = timeUntilExpiry <= 5 * 60 * 1e3;
|
|
48808
|
+
const expiryTime = new Date(expiresAt).toLocaleString();
|
|
48809
|
+
const status = isExpired ? "🔴 EXPIRED" : needsRefresh ? "🟡 NEEDS REFRESH" : "🟢 VALID";
|
|
48810
|
+
const info2 = [
|
|
48811
|
+
`Status: ${status}`,
|
|
48812
|
+
`Expires: ${expiryTime}`,
|
|
48813
|
+
`Time until expiry: ${Math.round(timeUntilExpiry / 1e3)}s`,
|
|
48814
|
+
`Has refresh token: ${refreshToken ? "Yes" : "No"}`,
|
|
48815
|
+
`Token source: ${tokenSource || "Unknown"}`
|
|
48816
|
+
].join("\n");
|
|
48817
|
+
void window$1.showInformationMessage(info2, { modal: true });
|
|
48818
|
+
}),
|
|
48819
|
+
// Set invalid token to test error handling
|
|
48820
|
+
commands$1.registerCommand("cody.debug.auth.setInvalidRefreshToken", async () => {
|
|
48821
|
+
const authStatus2 = currentAuthStatus();
|
|
48822
|
+
if (!authStatus2.authenticated) {
|
|
48823
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48824
|
+
return;
|
|
48825
|
+
}
|
|
48826
|
+
const endpoint = authStatus2.endpoint;
|
|
48827
|
+
await secretStorage.storeRefreshToken(endpoint, "invalid_token_for_testing");
|
|
48828
|
+
void window$1.showInformationMessage(
|
|
48829
|
+
"Invalid refresh token set - auth will fail on next request"
|
|
48830
|
+
);
|
|
48831
|
+
}),
|
|
48832
|
+
// Clear all auth data
|
|
48833
|
+
commands$1.registerCommand("cody.debug.auth.clearAll", async () => {
|
|
48834
|
+
const confirmation = await window$1.showWarningMessage(
|
|
48835
|
+
"This will clear all stored authentication data. Continue?",
|
|
48836
|
+
{ modal: true },
|
|
48837
|
+
"Clear All"
|
|
48838
|
+
);
|
|
48839
|
+
if (confirmation !== "Clear All") return;
|
|
48840
|
+
const endpoints = JSON.parse(localStorage.get("CODY_ENDPOINT_HISTORY") || "[]");
|
|
48841
|
+
for (const endpoint of endpoints) {
|
|
48842
|
+
await secretStorage.deleteToken(endpoint);
|
|
48843
|
+
}
|
|
48844
|
+
void window$1.showInformationMessage("All auth data cleared");
|
|
48845
|
+
}),
|
|
48846
|
+
// Show stored auth data (works even when not authenticated)
|
|
48847
|
+
commands$1.registerCommand("cody.debug.auth.showStoredData", async () => {
|
|
48848
|
+
const endpoints = localStorage.getEndpointHistory() || [];
|
|
48849
|
+
if (endpoints.length === 0) {
|
|
48850
|
+
void window$1.showInformationMessage("No stored endpoints found");
|
|
48851
|
+
return;
|
|
48852
|
+
}
|
|
48853
|
+
const results = [];
|
|
48854
|
+
for (const endpoint of endpoints) {
|
|
48855
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48856
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48857
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48858
|
+
let token = await secretStorage.getToken(endpoint);
|
|
48859
|
+
let tokenInfo = "None";
|
|
48860
|
+
if (tokenSource === "oauth") {
|
|
48861
|
+
const authStatus2 = currentAuthStatus();
|
|
48862
|
+
if (authStatus2.authenticated && authStatus2.endpoint === endpoint) {
|
|
48863
|
+
tokenInfo = "In memory (HeaderCredential)";
|
|
48864
|
+
try {
|
|
48865
|
+
const config = await import("./index-CQZWUrDD.mjs").then(
|
|
48866
|
+
(m) => m.currentResolvedConfig()
|
|
48867
|
+
);
|
|
48868
|
+
const currentConfig = await config;
|
|
48869
|
+
if (currentConfig.auth.credentials && "getHeaders" in currentConfig.auth.credentials) {
|
|
48870
|
+
const headers = await currentConfig.auth.credentials.getHeaders();
|
|
48871
|
+
const authHeader = headers.Authorization;
|
|
48872
|
+
if (authHeader == null ? void 0 : authHeader.startsWith("Bearer ")) {
|
|
48873
|
+
token = authHeader.slice(7);
|
|
48874
|
+
tokenInfo = token;
|
|
48875
|
+
}
|
|
48876
|
+
}
|
|
48877
|
+
} catch {
|
|
48878
|
+
}
|
|
48879
|
+
}
|
|
48880
|
+
} else if (token) {
|
|
48881
|
+
tokenInfo = token;
|
|
48882
|
+
}
|
|
48883
|
+
if (token || refreshToken || tokenSource) {
|
|
48884
|
+
const expiryStr = expiresAt ? new Date(expiresAt).toLocaleString() : "No expiry";
|
|
48885
|
+
results.push(
|
|
48886
|
+
[
|
|
48887
|
+
`Endpoint: ${endpoint}`,
|
|
48888
|
+
`Token: ${tokenInfo}`,
|
|
48889
|
+
`Refresh Token: ${refreshToken || "None"}`,
|
|
48890
|
+
`Token Source: ${tokenSource || "Unknown"}`,
|
|
48891
|
+
`Expires: ${expiryStr}`,
|
|
48892
|
+
"---"
|
|
48893
|
+
].join("\n")
|
|
48894
|
+
);
|
|
48895
|
+
}
|
|
48896
|
+
}
|
|
48897
|
+
if (results.length === 0) {
|
|
48898
|
+
void window$1.showInformationMessage("No stored tokens found");
|
|
48899
|
+
} else {
|
|
48900
|
+
void window$1.showInformationMessage(
|
|
48901
|
+
`Found ${results.length} stored token(s). Check "Cody auth" output channel for details.`,
|
|
48902
|
+
"Open Output Channel"
|
|
48903
|
+
).then((action) => {
|
|
48904
|
+
if (action === "Open Output Channel") {
|
|
48905
|
+
commands$1.executeCommand("workbench.action.output.toggleOutput");
|
|
48906
|
+
}
|
|
48907
|
+
});
|
|
48908
|
+
}
|
|
48909
|
+
}),
|
|
48910
|
+
// Show current auth info (masked) - requires being authenticated
|
|
48911
|
+
commands$1.registerCommand("cody.debug.auth.showInfo", async () => {
|
|
48912
|
+
const authStatus2 = currentAuthStatus();
|
|
48913
|
+
if (!authStatus2.authenticated) {
|
|
48914
|
+
void window$1.showInformationMessage(
|
|
48915
|
+
'Not authenticated - use "Show Stored Data" instead'
|
|
48916
|
+
);
|
|
48917
|
+
return;
|
|
48918
|
+
}
|
|
48919
|
+
const endpoint = authStatus2.endpoint;
|
|
48920
|
+
const token = await secretStorage.getToken(endpoint);
|
|
48921
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48922
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48923
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48924
|
+
const maskedToken = refreshToken ? `${refreshToken.slice(0, 8)}...${refreshToken.slice(-4)}` : "None";
|
|
48925
|
+
const expiryStr = expiresAt ? new Date(expiresAt).toLocaleString() : "No expiry";
|
|
48926
|
+
const info2 = [
|
|
48927
|
+
`Endpoint: ${endpoint}`,
|
|
48928
|
+
`Username: ${authStatus2.username}`,
|
|
48929
|
+
`Token: ${token || "Unknown"}`,
|
|
48930
|
+
`Token source: ${tokenSource || "Unknown"}`,
|
|
48931
|
+
`Refresh token: ${maskedToken}`,
|
|
48932
|
+
`Expires: ${expiryStr}`,
|
|
48933
|
+
`Auth method: ${refreshToken ? "Device/OAuth" : "Manual token"}`
|
|
48934
|
+
].join("\n");
|
|
48935
|
+
void window$1.showInformationMessage(info2, { modal: true });
|
|
48936
|
+
}),
|
|
48937
|
+
// Toggle device auth support (for testing fallback)
|
|
48938
|
+
commands$1.registerCommand("cody.debug.auth.toggleDeviceAuth", async () => {
|
|
48939
|
+
const currentState = getDebugDisableDeviceAuth();
|
|
48940
|
+
const newState = !currentState;
|
|
48941
|
+
setDebugDisableDeviceAuth(newState);
|
|
48942
|
+
const status = newState ? "DISABLED" : "ENABLED";
|
|
48943
|
+
const emoji = newState ? "🔴" : "🟢";
|
|
48944
|
+
const fallbackMsg = newState ? " (will fallback to old auth flow)" : "";
|
|
48945
|
+
void window$1.showInformationMessage(`${emoji} Device Auth: ${status}${fallbackMsg}`);
|
|
48946
|
+
})
|
|
48947
|
+
);
|
|
48948
|
+
}
|
|
48080
48949
|
const RRF_K = 60;
|
|
48081
48950
|
function fuseResults(retrievedSets, rankingIdentities) {
|
|
48082
48951
|
const resultsByDocument = /* @__PURE__ */ new Map();
|
|
@@ -48405,7 +49274,7 @@ class CachedRetriever {
|
|
|
48405
49274
|
*/
|
|
48406
49275
|
__publicField2(this, "addDependency", (dep) => {
|
|
48407
49276
|
if (!this.currentKey) {
|
|
48408
|
-
logError$
|
|
49277
|
+
logError$1(this.constructor.name, "Cannot add dependency outside of retrieval function");
|
|
48409
49278
|
return;
|
|
48410
49279
|
}
|
|
48411
49280
|
const keys2 = this.dependencies.get(dep);
|
|
@@ -150452,7 +151321,7 @@ const _ContextRetrieverDataCollection = class _ContextRetrieverDataCollection {
|
|
|
150452
151321
|
case RetrieverIdentifier.JaccardSimilarityRetriever:
|
|
150453
151322
|
return new JaccardSimilarityRetriever();
|
|
150454
151323
|
default:
|
|
150455
|
-
logDebug(
|
|
151324
|
+
outputChannelLogger.logDebug(
|
|
150456
151325
|
"ContextRetrieverDataCollection",
|
|
150457
151326
|
"createRetriever",
|
|
150458
151327
|
`Unhandled RetrieverIdentifier: ${config.identifier}`
|
|
@@ -154538,15 +155407,24 @@ class AutoeditAnalyticsLogger {
|
|
|
154538
155407
|
telemetryParams
|
|
154539
155408
|
}) {
|
|
154540
155409
|
autoeditsOutputChannelLogger.logDebug("writeAutoeditEvent", action, ...logDebugArgs);
|
|
154541
|
-
|
|
154542
|
-
|
|
154543
|
-
|
|
154544
|
-
|
|
154545
|
-
|
|
154546
|
-
|
|
154547
|
-
|
|
154548
|
-
|
|
155410
|
+
const skippedActions = [
|
|
155411
|
+
"discarded",
|
|
155412
|
+
"invalidTransitionToAccepted",
|
|
155413
|
+
"invalidTransitionToDiscarded",
|
|
155414
|
+
"invalidTransitionToLoaded",
|
|
155415
|
+
"invalidTransitionToRejected",
|
|
155416
|
+
"invalidTransitionToPostProcessed"
|
|
155417
|
+
];
|
|
155418
|
+
if (skippedActions.includes(action)) {
|
|
155419
|
+
return;
|
|
154549
155420
|
}
|
|
155421
|
+
telemetryRecorder.recordEvent("cody.autoedit", action, {
|
|
155422
|
+
...telemetryParams,
|
|
155423
|
+
billingMetadata: action === "accepted" || action === "suggested" ? {
|
|
155424
|
+
product: "cody",
|
|
155425
|
+
category: action === "accepted" ? "core" : "billable"
|
|
155426
|
+
} : void 0
|
|
155427
|
+
});
|
|
154550
155428
|
}
|
|
154551
155429
|
/**
|
|
154552
155430
|
* Rate-limited error logging, capturing exceptions with Sentry and grouping repeated logs.
|
|
@@ -171223,7 +172101,7 @@ function migrateAndNotifyForOutdatedModels(model2) {
|
|
|
171223
172101
|
if (!model2 || isRunningInsideAgent() || !deprecatedModelSet.has(model2)) {
|
|
171224
172102
|
return model2;
|
|
171225
172103
|
}
|
|
171226
|
-
const newModel = "anthropic/claude-
|
|
172104
|
+
const newModel = "anthropic/claude-sonnet-4-5-20250929";
|
|
171227
172105
|
if (modelsService.getModelByID(newModel)) {
|
|
171228
172106
|
showNotificationIfNotShownYet(
|
|
171229
172107
|
"Claude 2 model support has been removed in favor of the newer Claude 3 models. All chats that used Claude 2 have been upgraded to Claude 3.",
|
|
@@ -171259,7 +172137,7 @@ async function getContextFileFromTabs() {
|
|
|
171259
172137
|
})
|
|
171260
172138
|
)).filter(isDefined);
|
|
171261
172139
|
} catch (error) {
|
|
171262
|
-
logError$
|
|
172140
|
+
logError$1("getContextFileFromTabs", "failed", { verbose: error });
|
|
171263
172141
|
return [];
|
|
171264
172142
|
}
|
|
171265
172143
|
});
|
|
@@ -172593,7 +173471,11 @@ const getCommandContextFiles = async (config) => {
|
|
|
172593
173471
|
}
|
|
172594
173472
|
return contextFiles;
|
|
172595
173473
|
} catch (error) {
|
|
172596
|
-
logDebug(
|
|
173474
|
+
outputChannelLogger.logDebug(
|
|
173475
|
+
"getCommandContextFiles",
|
|
173476
|
+
"Error getting command context files",
|
|
173477
|
+
error
|
|
173478
|
+
);
|
|
172597
173479
|
return [];
|
|
172598
173480
|
}
|
|
172599
173481
|
};
|
|
@@ -172603,7 +173485,7 @@ class CommandRunner {
|
|
|
172603
173485
|
this.span = span2;
|
|
172604
173486
|
this.command = command;
|
|
172605
173487
|
this.args = args2;
|
|
172606
|
-
logDebug("CommandRunner", command.key, { verbose: { command, args: args2 } });
|
|
173488
|
+
outputChannelLogger.logDebug("CommandRunner", command.key, { verbose: { command, args: args2 } });
|
|
172607
173489
|
command.mode = args2.runInChatMode ? "ask" : command.mode ?? "ask";
|
|
172608
173490
|
this.command = command;
|
|
172609
173491
|
}
|
|
@@ -172658,7 +173540,7 @@ class CommandRunner {
|
|
|
172658
173540
|
*/
|
|
172659
173541
|
async handleChatRequest() {
|
|
172660
173542
|
this.span.setAttribute("mode", "chat");
|
|
172661
|
-
logDebug("CommandRunner:handleChatRequest", "chat request
|
|
173543
|
+
outputChannelLogger.logDebug("CommandRunner:handleChatRequest", "chat request detected");
|
|
172662
173544
|
const prompt = PromptString.unsafe_fromUserQuery(this.command.prompt);
|
|
172663
173545
|
const contextItems = await this.getContextFiles();
|
|
172664
173546
|
return {
|
|
@@ -172677,7 +173559,7 @@ class CommandRunner {
|
|
|
172677
173559
|
*/
|
|
172678
173560
|
async handleEditRequest() {
|
|
172679
173561
|
this.span.setAttribute("mode", "edit");
|
|
172680
|
-
logDebug("CommandRunner:handleEditRequest", "fixup request detected");
|
|
173562
|
+
outputChannelLogger.logDebug("CommandRunner:handleEditRequest", "fixup request detected");
|
|
172681
173563
|
const userContextFiles = await this.getContextFiles();
|
|
172682
173564
|
return {
|
|
172683
173565
|
type: "edit",
|
|
@@ -172750,7 +173632,10 @@ class CommandsController {
|
|
|
172750
173632
|
}
|
|
172751
173633
|
const command = (_b2 = this.provider) == null ? void 0 : _b2.get(commandKey);
|
|
172752
173634
|
if (!command || command.mode !== "ask" && !this.isEditEnabled) {
|
|
172753
|
-
logDebug(
|
|
173635
|
+
outputChannelLogger.logDebug(
|
|
173636
|
+
"CommandsController:execute",
|
|
173637
|
+
`${commandKey} command not found/supported`
|
|
173638
|
+
);
|
|
172754
173639
|
return void 0;
|
|
172755
173640
|
}
|
|
172756
173641
|
span2.setAttribute("sampled", true);
|
|
@@ -172766,7 +173651,7 @@ class CommandsController {
|
|
|
172766
173651
|
disposable.dispose();
|
|
172767
173652
|
}
|
|
172768
173653
|
this.disposables = [];
|
|
172769
|
-
logDebug("CommandsController:dispose", "disposed");
|
|
173654
|
+
outputChannelLogger.logDebug("CommandsController:dispose", "disposed");
|
|
172770
173655
|
}
|
|
172771
173656
|
}
|
|
172772
173657
|
const controller = new CommandsController();
|
|
@@ -172943,14 +173828,14 @@ async function getLocalCommands(input) {
|
|
|
172943
173828
|
const TraceSender = {
|
|
172944
173829
|
send(spanData) {
|
|
172945
173830
|
void doSendTraceData(spanData).catch((error) => {
|
|
172946
|
-
logError
|
|
173831
|
+
outputChannelLogger.logError("TraceSender", `Error sending trace data: ${error}`);
|
|
172947
173832
|
});
|
|
172948
173833
|
}
|
|
172949
173834
|
};
|
|
172950
173835
|
async function doSendTraceData(spanData) {
|
|
172951
173836
|
const { auth: auth2 } = await currentResolvedConfig();
|
|
172952
173837
|
if (!auth2.credentials) {
|
|
172953
|
-
logError
|
|
173838
|
+
outputChannelLogger.logError("TraceSender", "Cannot send trace data: not authenticated");
|
|
172954
173839
|
throw new Error("Not authenticated");
|
|
172955
173840
|
}
|
|
172956
173841
|
const traceUrl = new URL("/-/debug/otlp/v1/traces", auth2.serverEndpoint);
|
|
@@ -172962,10 +173847,10 @@ async function doSendTraceData(spanData) {
|
|
|
172962
173847
|
body: spanData
|
|
172963
173848
|
});
|
|
172964
173849
|
if (!response.ok) {
|
|
172965
|
-
logError
|
|
173850
|
+
outputChannelLogger.logError("TraceSender", `Failed to send trace data: ${response.statusText}`);
|
|
172966
173851
|
throw new Error(`Failed to send trace data: ${response.statusText}`);
|
|
172967
173852
|
}
|
|
172968
|
-
logDebug("TraceSender", "Trace data sent successfully");
|
|
173853
|
+
outputChannelLogger.logDebug("TraceSender", "Trace data sent successfully");
|
|
172969
173854
|
}
|
|
172970
173855
|
async function openExternalLinks(uri) {
|
|
172971
173856
|
try {
|
|
@@ -173170,7 +174055,10 @@ async function searchSymf(symf, editor, workspaceRoot, userText, blockOnIndex =
|
|
|
173170
174055
|
text2 = await editor.getTextEditorContentForFile(result.file, range);
|
|
173171
174056
|
text2 = truncateSymfResult(text2);
|
|
173172
174057
|
} catch (error) {
|
|
173173
|
-
logError
|
|
174058
|
+
outputChannelLogger.logError(
|
|
174059
|
+
"ChatController.searchSymf",
|
|
174060
|
+
`Error getting file contents: ${error}`
|
|
174061
|
+
);
|
|
173174
174062
|
return [];
|
|
173175
174063
|
}
|
|
173176
174064
|
const metadata2 = [
|
|
@@ -173197,17 +174085,17 @@ async function searchSymf(symf, editor, workspaceRoot, userText, blockOnIndex =
|
|
|
173197
174085
|
}
|
|
173198
174086
|
async function retrieveContextGracefully(promise2, strategy) {
|
|
173199
174087
|
try {
|
|
173200
|
-
logDebug("ChatController", `resolveContext > ${strategy} (start)`);
|
|
174088
|
+
outputChannelLogger.logDebug("ChatController", `resolveContext > ${strategy} (start)`);
|
|
173201
174089
|
return await promise2;
|
|
173202
174090
|
} catch (error) {
|
|
173203
174091
|
if (isAbortError(error)) {
|
|
173204
|
-
logError
|
|
174092
|
+
outputChannelLogger.logError("ChatController", `resolveContext > ${strategy}' (aborted)`);
|
|
173205
174093
|
throw error;
|
|
173206
174094
|
}
|
|
173207
|
-
logError
|
|
174095
|
+
outputChannelLogger.logError("ChatController", `resolveContext > ${strategy} (error)`, error);
|
|
173208
174096
|
return [];
|
|
173209
174097
|
} finally {
|
|
173210
|
-
logDebug("ChatController", `resolveContext > ${strategy} (end)`);
|
|
174098
|
+
outputChannelLogger.logDebug("ChatController", `resolveContext > ${strategy} (end)`);
|
|
173211
174099
|
}
|
|
173212
174100
|
}
|
|
173213
174101
|
const maxSymfBytes = 2048;
|
|
@@ -173280,7 +174168,11 @@ async function codebaseRootsFromMentions({ repos, trees }, signal2) {
|
|
|
173280
174168
|
const localRepoNames = treesToRepoNames.flatMap((t) => t.names);
|
|
173281
174169
|
let localRepoIDs = localRepoNames.length === 0 ? [] : await graphqlClient.getRepoIds(localRepoNames, localRepoNames.length, signal2);
|
|
173282
174170
|
if (isError$1(localRepoIDs)) {
|
|
173283
|
-
logError
|
|
174171
|
+
outputChannelLogger.logError(
|
|
174172
|
+
"codebaseRootFromMentions",
|
|
174173
|
+
"Failed to get repo IDs from Sourcegraph",
|
|
174174
|
+
localRepoIDs
|
|
174175
|
+
);
|
|
173284
174176
|
localRepoIDs = [];
|
|
173285
174177
|
}
|
|
173286
174178
|
const uriToId = {};
|
|
@@ -173348,7 +174240,7 @@ class ContextRetriever {
|
|
|
173348
174240
|
);
|
|
173349
174241
|
changedFiles = changedFilesByRoot.flat();
|
|
173350
174242
|
} catch (error) {
|
|
173351
|
-
logDebug(
|
|
174243
|
+
outputChannelLogger.logDebug(
|
|
173352
174244
|
"ContextRetriever",
|
|
173353
174245
|
"Failed to get locally modified files, falling back to indexed context only",
|
|
173354
174246
|
error
|
|
@@ -173371,7 +174263,7 @@ class ContextRetriever {
|
|
|
173371
174263
|
return [];
|
|
173372
174264
|
}
|
|
173373
174265
|
if (!this.symf) {
|
|
173374
|
-
logDebug("ContextRetriever", "symf not available, skipping live context");
|
|
174266
|
+
outputChannelLogger.logDebug("ContextRetriever", "symf not available, skipping live context");
|
|
173375
174267
|
return [];
|
|
173376
174268
|
}
|
|
173377
174269
|
const results = await this.symf.getLiveResults(originalQuery, rewrittenQuery, files, signal2);
|
|
@@ -173389,7 +174281,10 @@ class ContextRetriever {
|
|
|
173389
174281
|
text2 = await this.editor.getTextEditorContentForFile(r2.file, range);
|
|
173390
174282
|
text2 = truncateSymfResult(text2);
|
|
173391
174283
|
} catch (error) {
|
|
173392
|
-
logError
|
|
174284
|
+
outputChannelLogger.logError(
|
|
174285
|
+
"ChatController.searchSymf",
|
|
174286
|
+
`Error getting file contents: ${error}`
|
|
174287
|
+
);
|
|
173393
174288
|
return [];
|
|
173394
174289
|
}
|
|
173395
174290
|
return {
|
|
@@ -173494,7 +174389,7 @@ class ContextRetriever {
|
|
|
173494
174389
|
}
|
|
173495
174390
|
function contextSearchResultToContextItem(result) {
|
|
173496
174391
|
if (result.startLine < 0 || result.endLine < 0) {
|
|
173497
|
-
logDebug(
|
|
174392
|
+
outputChannelLogger.logDebug(
|
|
173498
174393
|
"ContextRetriever",
|
|
173499
174394
|
"ignoring server context result with invalid range",
|
|
173500
174395
|
result.repoName,
|
|
@@ -173962,7 +174857,7 @@ class DefaultPrompter {
|
|
|
173962
174857
|
reverseTranscript[0] = PromptMixin.mixInto(reverseTranscript[0], chat2.selectedModel, mixins);
|
|
173963
174858
|
const messagesIgnored = promptBuilder.tryAddMessages(reverseTranscript);
|
|
173964
174859
|
if (messagesIgnored) {
|
|
173965
|
-
logDebug(
|
|
174860
|
+
outputChannelLogger.logDebug(
|
|
173966
174861
|
"DefaultPrompter.makePrompt",
|
|
173967
174862
|
`Ignored ${messagesIgnored} chat messages due to context limit`
|
|
173968
174863
|
);
|
|
@@ -173985,7 +174880,7 @@ class DefaultPrompter {
|
|
|
173985
174880
|
const historyContext = await promptBuilder.tryAddContext("history", historyItems.reverse());
|
|
173986
174881
|
ignoredContext.transcript += historyContext.ignored.length;
|
|
173987
174882
|
if (ignoredContext.user + ignoredContext.corpus + ignoredContext.transcript > 0) {
|
|
173988
|
-
logDebug(
|
|
174883
|
+
outputChannelLogger.logDebug(
|
|
173989
174884
|
"DefaultPrompter.makePrompt",
|
|
173990
174885
|
`Ignored context due to context limit: user=${ignoredContext.user}, corpus=${ignoredContext.corpus}, previous=${ignoredContext.transcript}`
|
|
173991
174886
|
);
|
|
@@ -174390,7 +175285,7 @@ async function getContextFileFromShell(command) {
|
|
|
174390
175285
|
}
|
|
174391
175286
|
];
|
|
174392
175287
|
} catch (error) {
|
|
174393
|
-
logError
|
|
175288
|
+
outputChannelLogger.logError("getContextFileFromShell", "failed", { verbose: error });
|
|
174394
175289
|
const errorContent = `Failed to run ${command} in terminal:
|
|
174395
175290
|
${error}`;
|
|
174396
175291
|
const size = await TokenCounterUtils.countTokens(errorContent);
|
|
@@ -180764,14 +181659,14 @@ ${error}` : error;
|
|
|
180764
181659
|
this.connections.push(connection);
|
|
180765
181660
|
this.statusChangeEmitter.fire({ serverName: name2, status: "connecting" });
|
|
180766
181661
|
transport.onclose = () => {
|
|
180767
|
-
logDebug
|
|
181662
|
+
logDebug("MCPConnectionManager", `Transport closed for "${name2}"`);
|
|
180768
181663
|
const conn2 = this.getConnection(name2);
|
|
180769
181664
|
if (conn2 && conn2.server.status !== "disconnected") {
|
|
180770
181665
|
this.updateConnectionStatus(conn2, "disconnected", "Transport closed");
|
|
180771
181666
|
}
|
|
180772
181667
|
};
|
|
180773
181668
|
transport.onerror = (error) => {
|
|
180774
|
-
logDebug
|
|
181669
|
+
logDebug("MCPConnectionManager", `Transport error for "${name2}"`, {
|
|
180775
181670
|
verbose: { error }
|
|
180776
181671
|
});
|
|
180777
181672
|
const conn2 = this.getConnection(name2);
|
|
@@ -180781,11 +181676,11 @@ ${error}` : error;
|
|
|
180781
181676
|
};
|
|
180782
181677
|
await transport.start();
|
|
180783
181678
|
if (config.transportType === "stdio" && transport instanceof StdioClientTransport) {
|
|
180784
|
-
logDebug
|
|
181679
|
+
logDebug("MCPConnectionManager", `Connecting to stdio server "${name2}"...`, {
|
|
180785
181680
|
verbose: { config }
|
|
180786
181681
|
});
|
|
180787
181682
|
} else if (config.transportType === "sse") {
|
|
180788
|
-
logDebug
|
|
181683
|
+
logDebug("MCPConnectionManager", `Connecting to SSE server "${name2}"...`, {
|
|
180789
181684
|
verbose: { config }
|
|
180790
181685
|
});
|
|
180791
181686
|
}
|
|
@@ -180794,13 +181689,13 @@ ${error}` : error;
|
|
|
180794
181689
|
await client.connect(transport);
|
|
180795
181690
|
connection.server.status = "connected";
|
|
180796
181691
|
connection.server.error = "";
|
|
180797
|
-
logDebug
|
|
181692
|
+
logDebug("MCPConnectionManager", `Connected to MCP server: ${name2}`);
|
|
180798
181693
|
this.statusChangeEmitter.fire({ serverName: name2, status: "connected" });
|
|
180799
181694
|
this.notifyServerChanged(name2);
|
|
180800
181695
|
return connection;
|
|
180801
181696
|
} catch (error) {
|
|
180802
181697
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
180803
|
-
logDebug
|
|
181698
|
+
logDebug("MCPConnectionManager", `Failed to connect to MCP server ${name2}`, {
|
|
180804
181699
|
verbose: { error }
|
|
180805
181700
|
});
|
|
180806
181701
|
const conn2 = this.getConnection(name2) ?? connection;
|
|
@@ -180809,14 +181704,14 @@ ${error}` : error;
|
|
|
180809
181704
|
}
|
|
180810
181705
|
await Promise.allSettled([
|
|
180811
181706
|
transport == null ? void 0 : transport.close().catch(
|
|
180812
|
-
(closeError) => logDebug
|
|
181707
|
+
(closeError) => logDebug(
|
|
180813
181708
|
"MCPConnectionManager",
|
|
180814
181709
|
`Error closing transport for ${name2} after connection failure`,
|
|
180815
181710
|
{ verbose: { closeError } }
|
|
180816
181711
|
)
|
|
180817
181712
|
),
|
|
180818
181713
|
client == null ? void 0 : client.close().catch(
|
|
180819
|
-
(closeError) => logDebug
|
|
181714
|
+
(closeError) => logDebug(
|
|
180820
181715
|
"MCPConnectionManager",
|
|
180821
181716
|
`Error closing client for ${name2} after connection failure`,
|
|
180822
181717
|
{ verbose: { closeError } }
|
|
@@ -180833,9 +181728,9 @@ ${error}` : error;
|
|
|
180833
181728
|
this.connections.splice(index2, 1);
|
|
180834
181729
|
try {
|
|
180835
181730
|
await Promise.all([connection.transport.close(), connection.client.close()]);
|
|
180836
|
-
logDebug
|
|
181731
|
+
logDebug("MCPConnectionManager", `Closed connection for ${name2}`);
|
|
180837
181732
|
} catch (error) {
|
|
180838
|
-
logDebug
|
|
181733
|
+
logDebug("MCPConnectionManager", `Failed to cleanly close connection for ${name2}:`, {
|
|
180839
181734
|
verbose: { error }
|
|
180840
181735
|
});
|
|
180841
181736
|
}
|
|
@@ -180896,7 +181791,7 @@ class MCPServerManager {
|
|
|
180896
181791
|
// Add disabled status
|
|
180897
181792
|
};
|
|
180898
181793
|
})) || [];
|
|
180899
|
-
logDebug
|
|
181794
|
+
logDebug("MCPServerManager", `Fetched ${tools.length} tools for ${serverName}`, {
|
|
180900
181795
|
verbose: { tools }
|
|
180901
181796
|
});
|
|
180902
181797
|
try {
|
|
@@ -180908,7 +181803,7 @@ class MCPServerManager {
|
|
|
180908
181803
|
CodyToolProvider.updateToolDisabledState(codyToolName, true);
|
|
180909
181804
|
}
|
|
180910
181805
|
} catch (error) {
|
|
180911
|
-
logDebug
|
|
181806
|
+
logDebug(
|
|
180912
181807
|
"MCPServerManager",
|
|
180913
181808
|
`Failed to register tools with CodyToolProvider: ${error}`,
|
|
180914
181809
|
{
|
|
@@ -180919,12 +181814,12 @@ class MCPServerManager {
|
|
|
180919
181814
|
await this.registerAgentTools(serverName, tools);
|
|
180920
181815
|
return tools;
|
|
180921
181816
|
} catch (error) {
|
|
180922
|
-
logDebug
|
|
181817
|
+
logDebug("MCPServerManager", `Failed to fetch tools for ${serverName}:`, {
|
|
180923
181818
|
verbose: { error }
|
|
180924
181819
|
});
|
|
180925
181820
|
return [];
|
|
180926
181821
|
} finally {
|
|
180927
|
-
logDebug
|
|
181822
|
+
logDebug("MCPServerManager", `Tool list retrieval process completed for ${serverName}`);
|
|
180928
181823
|
this.connectionManager.notifyToolChanged(serverName);
|
|
180929
181824
|
}
|
|
180930
181825
|
}
|
|
@@ -180948,17 +181843,17 @@ class MCPServerManager {
|
|
|
180948
181843
|
mimeType: r2.mimeType,
|
|
180949
181844
|
title: `${r2.title}`
|
|
180950
181845
|
}));
|
|
180951
|
-
logDebug
|
|
181846
|
+
logDebug("MCPServerManager", `Fetched ${resources.length} resources for ${serverName}`, {
|
|
180952
181847
|
verbose: { resources }
|
|
180953
181848
|
});
|
|
180954
181849
|
return resources;
|
|
180955
181850
|
} catch (error) {
|
|
180956
|
-
logDebug
|
|
181851
|
+
logDebug("MCPServerManager", `Failed to fetch resources for ${serverName}:`, {
|
|
180957
181852
|
verbose: { error }
|
|
180958
181853
|
});
|
|
180959
181854
|
return [];
|
|
180960
181855
|
} finally {
|
|
180961
|
-
logDebug
|
|
181856
|
+
logDebug("MCPServerManager", `Resource list retrieval process completed for ${serverName}`);
|
|
180962
181857
|
}
|
|
180963
181858
|
}
|
|
180964
181859
|
/**
|
|
@@ -180984,7 +181879,7 @@ class MCPServerManager {
|
|
|
180984
181879
|
uri: t.uriTemplate
|
|
180985
181880
|
}));
|
|
180986
181881
|
} catch (error) {
|
|
180987
|
-
logDebug
|
|
181882
|
+
logDebug("MCPServerManager", `Failed to fetch resource templates for ${serverName}:`, {
|
|
180988
181883
|
verbose: { error }
|
|
180989
181884
|
});
|
|
180990
181885
|
return [];
|
|
@@ -181008,7 +181903,7 @@ class MCPServerManager {
|
|
|
181008
181903
|
try {
|
|
181009
181904
|
return this.executeTool(serverName, tool.name, args2);
|
|
181010
181905
|
} catch (error) {
|
|
181011
|
-
logDebug
|
|
181906
|
+
logDebug("MCPServerManager", `Error executing tool ${tool.name}:`, {
|
|
181012
181907
|
verbose: { error }
|
|
181013
181908
|
});
|
|
181014
181909
|
return createMCPToolState(
|
|
@@ -181034,7 +181929,7 @@ class MCPServerManager {
|
|
|
181034
181929
|
});
|
|
181035
181930
|
}
|
|
181036
181931
|
} catch (error) {
|
|
181037
|
-
logDebug
|
|
181932
|
+
logDebug("MCPServerManager", `Error creating agent tool for ${tool.name || ""}`, {
|
|
181038
181933
|
verbose: { error }
|
|
181039
181934
|
});
|
|
181040
181935
|
}
|
|
@@ -181043,7 +181938,7 @@ class MCPServerManager {
|
|
|
181043
181938
|
[...this.tools.filter((t) => !t.spec.name.startsWith(`${serverName}_`)), ..._agentTools],
|
|
181044
181939
|
serverName
|
|
181045
181940
|
);
|
|
181046
|
-
logDebug
|
|
181941
|
+
logDebug("MCPServerManager", `Created ${_agentTools.length} agent tools from ${serverName}`, {
|
|
181047
181942
|
verbose: { _agentTools }
|
|
181048
181943
|
});
|
|
181049
181944
|
this.connectionManager.notifyToolChanged(serverName);
|
|
@@ -181097,12 +181992,12 @@ class MCPServerManager {
|
|
|
181097
181992
|
throw new Error("unexpected response");
|
|
181098
181993
|
}
|
|
181099
181994
|
const { context: context2, contents } = transforMCPToolResult(result.content, toolName);
|
|
181100
|
-
logDebug
|
|
181995
|
+
logDebug("MCPServerManager", `Tool ${toolName} executed successfully`, {
|
|
181101
181996
|
verbose: { context: context2, contents }
|
|
181102
181997
|
});
|
|
181103
181998
|
return createMCPToolState(serverName, toolName, contents, context2);
|
|
181104
181999
|
} catch (error) {
|
|
181105
|
-
logDebug
|
|
182000
|
+
logDebug("MCPServerManager", `Error calling tool ${toolName} on server ${serverName}`, {
|
|
181106
182001
|
verbose: error
|
|
181107
182002
|
});
|
|
181108
182003
|
return createMCPToolState(
|
|
@@ -181140,7 +182035,7 @@ class MCPServerManager {
|
|
|
181140
182035
|
);
|
|
181141
182036
|
return result.content;
|
|
181142
182037
|
} catch (error) {
|
|
181143
|
-
logDebug
|
|
182038
|
+
logDebug("MCPServerManager", `Error reading resource ${uri} from server ${serverName}`, {
|
|
181144
182039
|
verbose: { error }
|
|
181145
182040
|
});
|
|
181146
182041
|
throw error;
|
|
@@ -181178,7 +182073,7 @@ class MCPServerManager {
|
|
|
181178
182073
|
const codyToolName = ToolFactory.getCodyToolName(toolName, serverName);
|
|
181179
182074
|
CodyToolProvider.updateToolDisabledState(codyToolName, disabled);
|
|
181180
182075
|
} catch (error) {
|
|
181181
|
-
logDebug
|
|
182076
|
+
logDebug("MCPServerManager", `Failed to update tool state in CodyToolProvider: ${error}`, {
|
|
181182
182077
|
verbose: { error }
|
|
181183
182078
|
});
|
|
181184
182079
|
}
|
|
@@ -181229,7 +182124,7 @@ class MCPServerManager {
|
|
|
181229
182124
|
}
|
|
181230
182125
|
}
|
|
181231
182126
|
} catch (error) {
|
|
181232
|
-
logDebug
|
|
182127
|
+
logDebug("MCPServerManager", "Failed to update tool states in CodyToolProvider", {
|
|
181233
182128
|
verbose: { error }
|
|
181234
182129
|
});
|
|
181235
182130
|
}
|
|
@@ -181241,7 +182136,7 @@ class MCPServerManager {
|
|
|
181241
182136
|
this.toolsChangeNotifications.next({
|
|
181242
182137
|
serverName: affectedServers.size === 1 ? Array.from(affectedServers)[0] : ""
|
|
181243
182138
|
});
|
|
181244
|
-
logDebug
|
|
182139
|
+
logDebug("MCPServerManager", `Loaded ${tools.length} disabled tools`, {
|
|
181245
182140
|
verbose: { disabled: tools }
|
|
181246
182141
|
});
|
|
181247
182142
|
}
|
|
@@ -181353,15 +182248,15 @@ const _MCPManager = class _MCPManager {
|
|
|
181353
182248
|
this.observeConfigChanges();
|
|
181354
182249
|
this.setupToolStateListeners();
|
|
181355
182250
|
} catch (error) {
|
|
181356
|
-
logDebug
|
|
182251
|
+
logDebug("MCPManager", "Failed to initialize MCP manager", { verbose: { error } });
|
|
181357
182252
|
_MCPManager.instance = void 0;
|
|
181358
182253
|
}
|
|
181359
182254
|
}
|
|
181360
182255
|
async handleConnectionStatusChange(event2) {
|
|
181361
|
-
logDebug
|
|
182256
|
+
logDebug("MCPManager", `Connection status changed for ${event2.serverName}: ${event2.status}`);
|
|
181362
182257
|
if (event2.status === "connected") {
|
|
181363
182258
|
await this.initializeServerData(event2.serverName).catch((error) => {
|
|
181364
|
-
logDebug
|
|
182259
|
+
logDebug("MCPManager", `Error initializing server data for ${event2.serverName}`, {
|
|
181365
182260
|
verbose: { error }
|
|
181366
182261
|
});
|
|
181367
182262
|
});
|
|
@@ -181371,7 +182266,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181371
182266
|
this.serverManager.onToolStateChanged(async (event2) => {
|
|
181372
182267
|
await this.updateToolStateInConfig(event2.serverName, event2.toolName, event2.disabled).catch(
|
|
181373
182268
|
(e) => {
|
|
181374
|
-
logDebug
|
|
182269
|
+
logDebug("MCPManager", `Failed to update ${event2.serverName} config`, { verbose: e });
|
|
181375
182270
|
}
|
|
181376
182271
|
);
|
|
181377
182272
|
});
|
|
@@ -181380,12 +182275,12 @@ const _MCPManager = class _MCPManager {
|
|
|
181380
182275
|
const configWatcher = workspace.onDidChangeConfiguration(async (event2) => {
|
|
181381
182276
|
if (event2.affectsConfiguration(`${_MCPManager.CONFIG_SECTION}.${_MCPManager.MCP_SERVERS_KEY}`)) {
|
|
181382
182277
|
if (this.programmaticConfigChangeInProgress) {
|
|
181383
|
-
logDebug
|
|
182278
|
+
logDebug("MCPManager", "Ignoring programmatic configuration change");
|
|
181384
182279
|
return;
|
|
181385
182280
|
}
|
|
181386
|
-
logDebug
|
|
182281
|
+
logDebug("MCPManager", "Configuration change detected");
|
|
181387
182282
|
await this.loadServersFromConfig().catch((e) => {
|
|
181388
|
-
logDebug
|
|
182283
|
+
logDebug("MCPManager", "Error reloading servers from config", { verbose: e });
|
|
181389
182284
|
});
|
|
181390
182285
|
}
|
|
181391
182286
|
});
|
|
@@ -181402,7 +182297,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181402
182297
|
const result = McpSettingsSchema.safeParse({ mcpServers });
|
|
181403
182298
|
if (result.success) {
|
|
181404
182299
|
await this.sync(mcpServers);
|
|
181405
|
-
logDebug
|
|
182300
|
+
logDebug("MCPManager", "MCP servers initialized successfully from configuration");
|
|
181406
182301
|
} else {
|
|
181407
182302
|
throw new Error("Invalid MCP server configuration: " + result.error.format());
|
|
181408
182303
|
}
|
|
@@ -181411,14 +182306,14 @@ const _MCPManager = class _MCPManager {
|
|
|
181411
182306
|
* Sync servers with configuration
|
|
181412
182307
|
*/
|
|
181413
182308
|
async sync(mcpServers) {
|
|
181414
|
-
logDebug
|
|
182309
|
+
logDebug("MCPManager", "Syncing MCP servers", { verbose: { mcpServers } });
|
|
181415
182310
|
const currentConnections = this.connectionManager.getAllConnections();
|
|
181416
182311
|
const currentNames = new Set(currentConnections.map((conn2) => conn2.server.name));
|
|
181417
182312
|
const newNames = new Set(Object.keys(mcpServers));
|
|
181418
182313
|
for (const name2 of currentNames) {
|
|
181419
182314
|
if (!newNames.has(name2)) {
|
|
181420
182315
|
await this.connectionManager.removeConnection(name2);
|
|
181421
|
-
logDebug
|
|
182316
|
+
logDebug("MCPManager", `Deleted MCP server: ${name2}`);
|
|
181422
182317
|
}
|
|
181423
182318
|
}
|
|
181424
182319
|
const allDisabledTools = [];
|
|
@@ -181440,7 +182335,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181440
182335
|
allDisabledTools.push(...toolsWithPrefix);
|
|
181441
182336
|
}
|
|
181442
182337
|
} catch (error) {
|
|
181443
|
-
logDebug
|
|
182338
|
+
logDebug("MCPManager", `Failed to reconnect MCP server ${name2}`, {
|
|
181444
182339
|
verbose: { error }
|
|
181445
182340
|
});
|
|
181446
182341
|
}
|
|
@@ -181460,7 +182355,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181460
182355
|
const parsedConfig = result.data;
|
|
181461
182356
|
await this.connectionManager.addConnection(name2, parsedConfig, parsedConfig == null ? void 0 : parsedConfig.disabled);
|
|
181462
182357
|
} catch (error) {
|
|
181463
|
-
logDebug
|
|
182358
|
+
logDebug("MCPManager", `Error adding connection for ${name2}`, { verbose: { error } });
|
|
181464
182359
|
}
|
|
181465
182360
|
}
|
|
181466
182361
|
/**
|
|
@@ -181470,14 +182365,14 @@ const _MCPManager = class _MCPManager {
|
|
|
181470
182365
|
const connection = this.connectionManager.getConnection(serverName);
|
|
181471
182366
|
if (!connection) return;
|
|
181472
182367
|
try {
|
|
181473
|
-
logDebug
|
|
182368
|
+
logDebug("MCPManager", `Initializing tools for server: ${serverName}`);
|
|
181474
182369
|
connection.server.tools = await this.serverManager.getToolList(serverName) || [];
|
|
181475
|
-
logDebug
|
|
182370
|
+
logDebug("MCPManager", `Initialized tools for server: ${serverName}`, {
|
|
181476
182371
|
verbose: { toolCount: connection.server.tools.length }
|
|
181477
182372
|
});
|
|
181478
182373
|
this.connectionManager.notifyServerChanged(serverName);
|
|
181479
182374
|
} catch (error) {
|
|
181480
|
-
logDebug
|
|
182375
|
+
logDebug("MCPManager", `Failed to initialize ${serverName}`, { verbose: error });
|
|
181481
182376
|
}
|
|
181482
182377
|
}
|
|
181483
182378
|
static get tools() {
|
|
@@ -181559,7 +182454,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181559
182454
|
}
|
|
181560
182455
|
});
|
|
181561
182456
|
} catch (error) {
|
|
181562
|
-
logDebug
|
|
182457
|
+
logDebug("MCPManager", `Failed to update tool state in config: ${error}`, {
|
|
181563
182458
|
verbose: { error }
|
|
181564
182459
|
});
|
|
181565
182460
|
throw error;
|
|
@@ -181582,7 +182477,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181582
182477
|
mcpServers[(config == null ? void 0 : config.name) ?? name2] = config;
|
|
181583
182478
|
} else if (operation === "update") {
|
|
181584
182479
|
if (!mcpServers[name2] || !mcpServers[config == null ? void 0 : config.name]) {
|
|
181585
|
-
logDebug
|
|
182480
|
+
logDebug("", `MCP server "${name2}" does not exist`);
|
|
181586
182481
|
}
|
|
181587
182482
|
const mergedConfig = {
|
|
181588
182483
|
...mcpServers[name2],
|
|
@@ -181601,29 +182496,29 @@ const _MCPManager = class _MCPManager {
|
|
|
181601
182496
|
if (mcpServers[name2]) {
|
|
181602
182497
|
delete mcpServers[name2];
|
|
181603
182498
|
} else {
|
|
181604
|
-
logDebug
|
|
182499
|
+
logDebug("MCPManager", `${name2} not found in MCP configuration`);
|
|
181605
182500
|
}
|
|
181606
182501
|
}
|
|
181607
182502
|
await this.updateMcpServerConfig(mcpServers);
|
|
181608
182503
|
if (operation === "delete") {
|
|
181609
182504
|
await this.connectionManager.removeConnection(name2);
|
|
181610
|
-
logDebug
|
|
182505
|
+
logDebug("MCPManager", `Deleted MCP server: ${name2}`);
|
|
181611
182506
|
} else if (operation === "update") {
|
|
181612
182507
|
await this.connectionManager.removeConnection(name2);
|
|
181613
182508
|
await this.addConnection(name2, mcpServers[name2]);
|
|
181614
|
-
logDebug
|
|
182509
|
+
logDebug("MCPManager", `Updated ${name2}`, {
|
|
181615
182510
|
verbose: { config: mcpServers[name2] }
|
|
181616
182511
|
});
|
|
181617
182512
|
} else if (operation === "add") {
|
|
181618
182513
|
await this.addConnection(name2, config);
|
|
181619
|
-
logDebug
|
|
182514
|
+
logDebug("MCPManager", `Added MCP server: ${name2}`, { verbose: { config } });
|
|
181620
182515
|
const connection = this.connectionManager.getConnection(name2);
|
|
181621
182516
|
if ((connection == null ? void 0 : connection.server.status) === "connected") {
|
|
181622
182517
|
await this.initializeServerData(name2);
|
|
181623
182518
|
}
|
|
181624
182519
|
}
|
|
181625
182520
|
} catch (error) {
|
|
181626
|
-
logDebug
|
|
182521
|
+
logDebug("MCPManager", `Failed to ${operation} MCP server: ${name2}`, { verbose: { error } });
|
|
181627
182522
|
if (operation === "update") {
|
|
181628
182523
|
window$1.showErrorMessage(
|
|
181629
182524
|
`Failed to update MCP server: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -181660,15 +182555,15 @@ const _MCPManager = class _MCPManager {
|
|
|
181660
182555
|
if (enabled) {
|
|
181661
182556
|
try {
|
|
181662
182557
|
await this.addConnection(name2, mcpServers[name2]);
|
|
181663
|
-
logDebug
|
|
182558
|
+
logDebug("MCPManager", `Enabled and connected to MCP server: ${name2}`);
|
|
181664
182559
|
} catch (error) {
|
|
181665
|
-
logDebug
|
|
182560
|
+
logDebug("MCPManager", `Enabled MCP server but failed to connect: ${name2}`, {
|
|
181666
182561
|
verbose: { error }
|
|
181667
182562
|
});
|
|
181668
182563
|
}
|
|
181669
182564
|
} else {
|
|
181670
182565
|
await this.connectionManager.removeConnection(name2);
|
|
181671
|
-
logDebug
|
|
182566
|
+
logDebug("MCPManager", `Disabled MCP server: ${name2}`);
|
|
181672
182567
|
}
|
|
181673
182568
|
} catch (error) {
|
|
181674
182569
|
const action = enabled ? "enable" : "disable";
|
|
@@ -181729,7 +182624,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181729
182624
|
cleanedServers,
|
|
181730
182625
|
ConfigurationTarget.Global
|
|
181731
182626
|
);
|
|
181732
|
-
logDebug
|
|
182627
|
+
logDebug("MCPManager", "Updated MCP servers configuration", {
|
|
181733
182628
|
verbose: { serverCount: Object.keys(cleanedServers).length }
|
|
181734
182629
|
});
|
|
181735
182630
|
} finally {
|
|
@@ -181744,12 +182639,12 @@ const _MCPManager = class _MCPManager {
|
|
|
181744
182639
|
}
|
|
181745
182640
|
this.disposables = [];
|
|
181746
182641
|
_MCPManager.instance = void 0;
|
|
181747
|
-
logDebug
|
|
182642
|
+
logDebug("MCPManager", "disposed");
|
|
181748
182643
|
}
|
|
181749
182644
|
static dispose() {
|
|
181750
182645
|
var _a3;
|
|
181751
182646
|
(_a3 = _MCPManager.instance) == null ? void 0 : _a3.dispose().catch((error) => {
|
|
181752
|
-
logDebug
|
|
182647
|
+
logDebug("MCPManager", "Error disposing MCPManager", { verbose: { error } });
|
|
181753
182648
|
});
|
|
181754
182649
|
}
|
|
181755
182650
|
};
|
|
@@ -181965,7 +182860,7 @@ function getCorpusContextItemsForEditorState() {
|
|
|
181965
182860
|
return pendingOperation;
|
|
181966
182861
|
}
|
|
181967
182862
|
if (isError$3(remoteReposForAllWorkspaceFolders2)) {
|
|
181968
|
-
logError$
|
|
182863
|
+
logError$1(
|
|
181969
182864
|
"initialContext",
|
|
181970
182865
|
"Failed to get remote repos for all workspace folders"
|
|
181971
182866
|
);
|
|
@@ -182092,7 +182987,7 @@ const _CodyTool = class _CodyTool {
|
|
|
182092
182987
|
}
|
|
182093
182988
|
return ps`${prompt}\n\t- ${RawTextProcessor.join(examples, ps`\n\t- `)}`;
|
|
182094
182989
|
} catch (error) {
|
|
182095
|
-
logDebug
|
|
182990
|
+
logDebug("Cody Tool", `failed to getInstruction for ${tag2}`, { verbose: { error } });
|
|
182096
182991
|
return ps``;
|
|
182097
182992
|
}
|
|
182098
182993
|
}
|
|
@@ -182193,7 +183088,7 @@ class CliTool extends CodyTool {
|
|
|
182193
183088
|
throw new Error("No commands approved for execution");
|
|
182194
183089
|
}
|
|
182195
183090
|
callback.onUpdate(toolID, { content: [...approvedCommands].join(", ") });
|
|
182196
|
-
logDebug
|
|
183091
|
+
logDebug("CodyTool", `executing ${approvedCommands.size} commands...`);
|
|
182197
183092
|
return Promise.all([...approvedCommands].map(getContextFileFromShell)).then(
|
|
182198
183093
|
(results) => results.flat()
|
|
182199
183094
|
);
|
|
@@ -182219,7 +183114,7 @@ class FileTool extends CodyTool {
|
|
|
182219
183114
|
async execute(span2, filePaths) {
|
|
182220
183115
|
span2.addEvent("executeFileTool");
|
|
182221
183116
|
if (filePaths.length === 0) return [];
|
|
182222
|
-
logDebug
|
|
183117
|
+
logDebug("CodyTool", `requesting ${filePaths.length} files`);
|
|
182223
183118
|
return Promise.all(filePaths.map(getContextFromRelativePath)).then((results) => results.filter((item) => item !== null)).catch(() => []);
|
|
182224
183119
|
}
|
|
182225
183120
|
}
|
|
@@ -182256,7 +183151,7 @@ class SearchTool extends CodyTool {
|
|
|
182256
183151
|
if (!repo) {
|
|
182257
183152
|
return [];
|
|
182258
183153
|
}
|
|
182259
|
-
logDebug
|
|
183154
|
+
logDebug("SearchTool", `searching codebase for ${query2}`);
|
|
182260
183155
|
const context2 = await this.contextRetriever.retrieveContext(
|
|
182261
183156
|
toStructuredMentions([repo]),
|
|
182262
183157
|
PromptString.unsafe_fromLLMResponse(query2),
|
|
@@ -182316,11 +183211,11 @@ class OpenCtxTool extends CodyTool {
|
|
|
182316
183211
|
);
|
|
182317
183212
|
results.push(...itemsWithContent.flat());
|
|
182318
183213
|
}
|
|
182319
|
-
logDebug
|
|
183214
|
+
logDebug("OpenCtxTool", `${this.provider.title} returned ${results.length} items`, {
|
|
182320
183215
|
verbose: { results, provider: this.provider.title }
|
|
182321
183216
|
});
|
|
182322
183217
|
} catch {
|
|
182323
|
-
logDebug
|
|
183218
|
+
logDebug("CodyTool", `OpenCtx item retrieval failed for ${queries}`);
|
|
182324
183219
|
}
|
|
182325
183220
|
return results;
|
|
182326
183221
|
}
|
|
@@ -182365,7 +183260,7 @@ class McpToolImpl extends CodyTool {
|
|
|
182365
183260
|
}
|
|
182366
183261
|
handleMcpToolError(error) {
|
|
182367
183262
|
const displayToolName = this.toolName || this.tool.name;
|
|
182368
|
-
logDebug
|
|
183263
|
+
logDebug("CodyToolProvider", `Error executing ${displayToolName}`, {
|
|
182369
183264
|
verbose: error
|
|
182370
183265
|
});
|
|
182371
183266
|
const errorStr = error instanceof Error ? error.message : String(error);
|
|
@@ -182675,11 +183570,11 @@ const _CodyToolProvider = class _CodyToolProvider {
|
|
|
182675
183570
|
*/
|
|
182676
183571
|
static registerMcpTools(serverName, tools) {
|
|
182677
183572
|
if (!_CodyToolProvider.instance) {
|
|
182678
|
-
logDebug
|
|
183573
|
+
logDebug("CodyToolProvider", "Cannot register MCP tools - instance not initialized");
|
|
182679
183574
|
return [];
|
|
182680
183575
|
}
|
|
182681
183576
|
const createdTools = _CodyToolProvider.instance.factory.createMcpTools(tools, serverName);
|
|
182682
|
-
logDebug
|
|
183577
|
+
logDebug("CodyToolProvider", `Registered ${createdTools.length} MCP tools successfully`);
|
|
182683
183578
|
return createdTools;
|
|
182684
183579
|
}
|
|
182685
183580
|
/**
|
|
@@ -182690,14 +183585,14 @@ const _CodyToolProvider = class _CodyToolProvider {
|
|
|
182690
183585
|
*/
|
|
182691
183586
|
static updateToolDisabledState(toolName, disabled) {
|
|
182692
183587
|
if (!_CodyToolProvider.instance) {
|
|
182693
|
-
logDebug
|
|
183588
|
+
logDebug("CodyToolProvider", "Cannot update tool state - instance not initialized");
|
|
182694
183589
|
return false;
|
|
182695
183590
|
}
|
|
182696
183591
|
const result = _CodyToolProvider.instance.factory.updateToolDisabledState(toolName, disabled);
|
|
182697
183592
|
if (result) {
|
|
182698
|
-
logDebug
|
|
183593
|
+
logDebug("CodyToolProvider", `Updated tool ${toolName} disabled state to ${disabled}`);
|
|
182699
183594
|
} else {
|
|
182700
|
-
logDebug
|
|
183595
|
+
logDebug("CodyToolProvider", `Failed to update tool ${toolName} - not found`);
|
|
182701
183596
|
}
|
|
182702
183597
|
return result;
|
|
182703
183598
|
}
|
|
@@ -183069,7 +183964,7 @@ const _DeepCodyAgent = class _DeepCodyAgent {
|
|
|
183069
183964
|
return newContext;
|
|
183070
183965
|
} catch (error) {
|
|
183071
183966
|
await this.multiplexer.notifyTurnComplete();
|
|
183072
|
-
logDebug
|
|
183967
|
+
logDebug("Deep Cody", `context review failed: ${error}`, { verbose: { prompt, error } });
|
|
183073
183968
|
return [];
|
|
183074
183969
|
}
|
|
183075
183970
|
}
|
|
@@ -183111,7 +184006,7 @@ const _DeepCodyAgent = class _DeepCodyAgent {
|
|
|
183111
184006
|
const file = item.uri.scheme === "file" ? await getContextFromRelativePath(contextName) : item;
|
|
183112
184007
|
reviewed.push({ ...file || item, source: ContextItemSource.Agentic });
|
|
183113
184008
|
} catch (error) {
|
|
183114
|
-
logDebug
|
|
184009
|
+
logDebug("Deep Cody", `failed to get context from ${contextName}`, {
|
|
183115
184010
|
verbose: { error, contextName }
|
|
183116
184011
|
});
|
|
183117
184012
|
}
|
|
@@ -183219,7 +184114,7 @@ class ChatsController {
|
|
|
183219
184114
|
this.contextRetriever = contextRetriever;
|
|
183220
184115
|
this.guardrails = guardrails;
|
|
183221
184116
|
this.extensionClient = extensionClient;
|
|
183222
|
-
logDebug("ChatsController:constructor", "init");
|
|
184117
|
+
outputChannelLogger.logDebug("ChatsController:constructor", "init");
|
|
183223
184118
|
this.panel = this.createChatController();
|
|
183224
184119
|
this.disposables.push(
|
|
183225
184120
|
subscriptionDisposable(
|
|
@@ -183238,7 +184133,7 @@ class ChatsController {
|
|
|
183238
184133
|
try {
|
|
183239
184134
|
await this.getOrCreateEditorChatController(chatID, panel2.title, panel2);
|
|
183240
184135
|
} catch (error) {
|
|
183241
|
-
logDebug("ChatsController", "restoreToPanel", { error });
|
|
184136
|
+
outputChannelLogger.logDebug("ChatsController", "restoreToPanel", { error });
|
|
183242
184137
|
await this.getOrCreateEditorChatController(chatID, panel2.title);
|
|
183243
184138
|
panel2.dispose();
|
|
183244
184139
|
}
|
|
@@ -183289,10 +184184,10 @@ class ChatsController {
|
|
|
183289
184184
|
);
|
|
183290
184185
|
const restoreToEditor = async (chatID, chatQuestion) => {
|
|
183291
184186
|
try {
|
|
183292
|
-
logDebug("ChatsController", "debouncedRestorePanel");
|
|
184187
|
+
outputChannelLogger.logDebug("ChatsController", "debouncedRestorePanel");
|
|
183293
184188
|
return await this.getOrCreateEditorChatController(chatID, chatQuestion);
|
|
183294
184189
|
} catch (error) {
|
|
183295
|
-
logDebug("ChatsController", "debouncedRestorePanel", "failed", error);
|
|
184190
|
+
outputChannelLogger.logDebug("ChatsController", "debouncedRestorePanel", "failed", error);
|
|
183296
184191
|
return void 0;
|
|
183297
184192
|
}
|
|
183298
184193
|
};
|
|
@@ -183526,7 +184421,11 @@ class ChatsController {
|
|
|
183526
184421
|
}
|
|
183527
184422
|
});
|
|
183528
184423
|
} catch (error) {
|
|
183529
|
-
logError
|
|
184424
|
+
outputChannelLogger.logError(
|
|
184425
|
+
"ChatsController:exportHistory",
|
|
184426
|
+
"Failed to export chat history",
|
|
184427
|
+
error
|
|
184428
|
+
);
|
|
183530
184429
|
}
|
|
183531
184430
|
}
|
|
183532
184431
|
}
|
|
@@ -183577,7 +184476,7 @@ class ChatsController {
|
|
|
183577
184476
|
}
|
|
183578
184477
|
});
|
|
183579
184478
|
} catch (error) {
|
|
183580
|
-
logError
|
|
184479
|
+
outputChannelLogger.logError(
|
|
183581
184480
|
"ChatsController:exportAllChatsUnauthenticated",
|
|
183582
184481
|
"Failed to export all chat history",
|
|
183583
184482
|
error
|
|
@@ -183877,7 +184776,7 @@ const _GitHubDotComRepoMetadata = class _GitHubDotComRepoMetadata {
|
|
|
183877
184776
|
metadata2.isPublic = response.ok;
|
|
183878
184777
|
} catch (error) {
|
|
183879
184778
|
if (!isAbortError(error)) {
|
|
183880
|
-
logDebug(
|
|
184779
|
+
outputChannelLogger.logDebug(
|
|
183881
184780
|
"queryGitHubApi",
|
|
183882
184781
|
"error querying GitHub API (assuming repository is non-public",
|
|
183883
184782
|
`${owner2}/${repoName}`,
|
|
@@ -183949,11 +184848,7 @@ const publicRepoMetadataIfAllWorkspaceReposArePublic = remoteReposForAllWorkspac
|
|
|
183949
184848
|
return allReposArePublic ? { isPublic: true, repoMetadata: repoMetadatas.filter(isDefined) } : NO_PUBLIC_METADATA;
|
|
183950
184849
|
}),
|
|
183951
184850
|
catchError$1((error) => {
|
|
183952
|
-
logDebug(
|
|
183953
|
-
"publicRepoMetadataIfAllWorkspaceReposArePublic",
|
|
183954
|
-
"error getting repository metadata",
|
|
183955
|
-
error
|
|
183956
|
-
);
|
|
184851
|
+
outputChannelLogger.logDebug("error getting repository metadata", error);
|
|
183957
184852
|
return Observable.of(NO_PUBLIC_METADATA);
|
|
183958
184853
|
})
|
|
183959
184854
|
);
|
|
@@ -183984,7 +184879,7 @@ class OmniboxTelemetry {
|
|
|
183984
184879
|
}
|
|
183985
184880
|
recordChatQuestionExecuted(context2, spans) {
|
|
183986
184881
|
if (!this.intentInfo) {
|
|
183987
|
-
logError$
|
|
184882
|
+
logError$1(
|
|
183988
184883
|
"AgentTelemetry",
|
|
183989
184884
|
"failed to log cody.chat-question/executed because intent info was not set"
|
|
183990
184885
|
);
|
|
@@ -184645,7 +185540,7 @@ function validateWithZod(schema2, input, toolName) {
|
|
|
184645
185540
|
const parsed = schema2.safeParse(sanitizeToolInput(input));
|
|
184646
185541
|
if (!parsed.success) {
|
|
184647
185542
|
const errorMsg = parsed.error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
|
|
184648
|
-
logDebug
|
|
185543
|
+
logDebug("validateWithZod", `Validation error for ${toolName}: ${errorMsg}`);
|
|
184649
185544
|
throw new Error(`${toolName} validation failed: ${errorMsg}`);
|
|
184650
185545
|
}
|
|
184651
185546
|
return parsed.data;
|
|
@@ -184656,13 +185551,13 @@ function sanitizeToolInput(input) {
|
|
|
184656
185551
|
return JSON.parse(input);
|
|
184657
185552
|
} catch (e) {
|
|
184658
185553
|
try {
|
|
184659
|
-
logDebug
|
|
185554
|
+
logDebug("sanitizeToolInput", `Attempting to repair malformed JSON: ${input}`);
|
|
184660
185555
|
const repairedJson = jsonrepair(input);
|
|
184661
185556
|
const result = JSON.parse(repairedJson);
|
|
184662
|
-
logDebug
|
|
185557
|
+
logDebug("sanitizeToolInput", `Successfully repaired JSON: ${repairedJson}`);
|
|
184663
185558
|
return result;
|
|
184664
185559
|
} catch (repairError) {
|
|
184665
|
-
logDebug
|
|
185560
|
+
logDebug("sanitizeToolInput", `Failed to repair JSON: ${input}`);
|
|
184666
185561
|
}
|
|
184667
185562
|
}
|
|
184668
185563
|
}
|
|
@@ -185834,7 +186729,7 @@ const fileOps = {
|
|
|
185834
186729
|
const doc2 = await workspace.openTextDocument(uri);
|
|
185835
186730
|
await doc2.save();
|
|
185836
186731
|
} catch (error) {
|
|
185837
|
-
logDebug
|
|
186732
|
+
logDebug("file_operations", `Failed to create file ${uri.toString()}: ${error.message}`);
|
|
185838
186733
|
throw error;
|
|
185839
186734
|
}
|
|
185840
186735
|
},
|
|
@@ -186022,7 +186917,7 @@ async function createFile(uri, fileText) {
|
|
|
186022
186917
|
}
|
|
186023
186918
|
return createEditToolState(toolId, UIToolStatus.Done, uri, output2.join("\n"), "file-view");
|
|
186024
186919
|
} catch (error) {
|
|
186025
|
-
logDebug
|
|
186920
|
+
logDebug("text_editor", `Failed to create file ${displayPath(uri)}: ${error.message}`);
|
|
186026
186921
|
return createEditToolState(
|
|
186027
186922
|
toolId,
|
|
186028
186923
|
UIToolStatus.Error,
|
|
@@ -186073,7 +186968,7 @@ async function replaceInFile(uri, oldStr, newStr) {
|
|
|
186073
186968
|
const diffMarkdown = diffWithLineNum(content, newContent);
|
|
186074
186969
|
const output2 = [`Edited ${fileName}`, diffMarkdown];
|
|
186075
186970
|
const historyUri = uri.with({ scheme: "cody-checkpoint" });
|
|
186076
|
-
logDebug
|
|
186971
|
+
logDebug("text_editor", "New content created", { uri: historyUri });
|
|
186077
186972
|
const diagnosticsOnEnd = getErrorDiagnostics(uri);
|
|
186078
186973
|
if (diagnosticsOnEnd.length) {
|
|
186079
186974
|
output2.push("[Error detected - Action required]");
|
|
@@ -186559,7 +187454,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186559
187454
|
const contextItems = (contextResult == null ? void 0 : contextResult.contextItems) ?? [];
|
|
186560
187455
|
this.tools = await AgentToolGroup.getToolsByAgentId(this.contextRetriever, span2);
|
|
186561
187456
|
const startTime = Date.now();
|
|
186562
|
-
logDebug
|
|
187457
|
+
logDebug("AgenticHandler", `Starting agent session ${sessionID}`);
|
|
186563
187458
|
recorder2.recordChatQuestionExecuted(contextItems, { addMetadata: true, current: span2 });
|
|
186564
187459
|
try {
|
|
186565
187460
|
await this.runConversationLoop(chatBuilder, delegate, recorder2, span2, signal2, contextItems);
|
|
@@ -186567,8 +187462,8 @@ class AgenticHandler extends ChatHandler {
|
|
|
186567
187462
|
this.handleError(sessionID, error, delegate, signal2);
|
|
186568
187463
|
} finally {
|
|
186569
187464
|
delegate.postDone();
|
|
186570
|
-
logDebug
|
|
186571
|
-
logDebug
|
|
187465
|
+
logDebug("AgenticHandler", `Ending agent session ${sessionID}`);
|
|
187466
|
+
logDebug("AgenticHandler", `Session ${sessionID} duration: ${Date.now() - startTime}ms`);
|
|
186572
187467
|
}
|
|
186573
187468
|
}
|
|
186574
187469
|
/**
|
|
@@ -186596,13 +187491,13 @@ class AgenticHandler extends ChatHandler {
|
|
|
186596
187491
|
);
|
|
186597
187492
|
if (!(toolCalls == null ? void 0 : toolCalls.size)) {
|
|
186598
187493
|
chatBuilder.addBotMessage(botResponse, model2);
|
|
186599
|
-
logDebug
|
|
187494
|
+
logDebug("AgenticHandler", "No tool calls, ending conversation");
|
|
186600
187495
|
break;
|
|
186601
187496
|
}
|
|
186602
187497
|
const content = Array.from(toolCalls.values());
|
|
186603
187498
|
delegate.postMessageInProgress(botResponse);
|
|
186604
187499
|
const results = await this.executeTools(content, model2).catch(() => {
|
|
186605
|
-
logDebug
|
|
187500
|
+
logDebug("AgenticHandler", "Error executing tools");
|
|
186606
187501
|
return [];
|
|
186607
187502
|
});
|
|
186608
187503
|
const toolResults = results == null ? void 0 : results.map((result) => result.tool_result).filter(isDefined);
|
|
@@ -186617,7 +187512,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186617
187512
|
contextFiles: toolOutputs
|
|
186618
187513
|
});
|
|
186619
187514
|
if (turnCount >= this.MAX_TURN - 1) {
|
|
186620
|
-
logDebug
|
|
187515
|
+
logDebug("AgenticHandler", "Max turns reached, ending conversation");
|
|
186621
187516
|
break;
|
|
186622
187517
|
}
|
|
186623
187518
|
turnCount++;
|
|
@@ -186634,7 +187529,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186634
187529
|
var _a3, _b2;
|
|
186635
187530
|
const prompter2 = new AgenticChatPrompter(this.SYSTEM_PROMPT);
|
|
186636
187531
|
const prompt = await prompter2.makePrompt(chatBuilder, contextItems);
|
|
186637
|
-
logDebug
|
|
187532
|
+
logDebug("AgenticHandler", "Prompt created", { verbose: prompt });
|
|
186638
187533
|
const params = {
|
|
186639
187534
|
maxTokensToSample: 8e3,
|
|
186640
187535
|
messages: JSON.stringify(prompt),
|
|
@@ -186721,7 +187616,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186721
187616
|
var _a3, _b2, _c2;
|
|
186722
187617
|
const existingCall = toolCalls.get((_a3 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _a3.id);
|
|
186723
187618
|
if (!existingCall) {
|
|
186724
|
-
logDebug
|
|
187619
|
+
logDebug("AgenticHandler", `Calling ${(_b2 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _b2.name}`, { verbose: toolCall });
|
|
186725
187620
|
}
|
|
186726
187621
|
const updatedCall = { ...existingCall, ...toolCall };
|
|
186727
187622
|
toolCalls.set((_c2 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _c2.id, updatedCall);
|
|
@@ -186731,7 +187626,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186731
187626
|
*/
|
|
186732
187627
|
async executeTools(toolCalls, model2) {
|
|
186733
187628
|
try {
|
|
186734
|
-
logDebug
|
|
187629
|
+
logDebug("AgenticHandler", `Executing ${toolCalls.length} tools`);
|
|
186735
187630
|
const results = await Promise.allSettled(
|
|
186736
187631
|
toolCalls.map(async (toolCall) => {
|
|
186737
187632
|
var _a3, _b2, _c2, _d2;
|
|
@@ -186748,12 +187643,12 @@ class AgenticHandler extends ChatHandler {
|
|
|
186748
187643
|
type: "builtin"
|
|
186749
187644
|
}
|
|
186750
187645
|
});
|
|
186751
|
-
logDebug
|
|
187646
|
+
logDebug("AgenticHandler", `Executing ${(_c2 = toolCall.tool_call) == null ? void 0 : _c2.name}`, {
|
|
186752
187647
|
verbose: toolCall
|
|
186753
187648
|
});
|
|
186754
187649
|
return await this.executeSingleTool(toolCall, model2);
|
|
186755
187650
|
} catch (error) {
|
|
186756
|
-
logDebug
|
|
187651
|
+
logDebug("AgenticHandler", `Error executing tool ${(_d2 = toolCall.tool_call) == null ? void 0 : _d2.name}`, {
|
|
186757
187652
|
verbose: error
|
|
186758
187653
|
});
|
|
186759
187654
|
return null;
|
|
@@ -186762,7 +187657,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186762
187657
|
);
|
|
186763
187658
|
return results.filter((result) => result.status === "fulfilled" && result.value).map((result) => result.value);
|
|
186764
187659
|
} catch (error) {
|
|
186765
|
-
logDebug
|
|
187660
|
+
logDebug("AgenticHandler", "Error executing tools", { verbose: error });
|
|
186766
187661
|
return [];
|
|
186767
187662
|
}
|
|
186768
187663
|
}
|
|
@@ -186802,7 +187697,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186802
187697
|
type: "builtin"
|
|
186803
187698
|
}
|
|
186804
187699
|
});
|
|
186805
|
-
logDebug
|
|
187700
|
+
logDebug("AgenticHandler", `Error executing tool ${toolCall.tool_call.name}`, {
|
|
186806
187701
|
verbose: error
|
|
186807
187702
|
});
|
|
186808
187703
|
return null;
|
|
@@ -186811,7 +187706,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186811
187706
|
throw new Error(`Tool ${toolCall.tool_call.name} failed`);
|
|
186812
187707
|
}
|
|
186813
187708
|
tool_result.tool_result.content = result.content || "Empty result";
|
|
186814
|
-
logDebug
|
|
187709
|
+
logDebug("AgenticHandler", `Executed ${toolCall.tool_call.name}`, { verbose: result });
|
|
186815
187710
|
telemetryRecorder.recordEvent("cody.tool-use", "executed", {
|
|
186816
187711
|
billingMetadata: {
|
|
186817
187712
|
product: "cody",
|
|
@@ -186846,7 +187741,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186846
187741
|
type: "builtin"
|
|
186847
187742
|
}
|
|
186848
187743
|
});
|
|
186849
|
-
logDebug
|
|
187744
|
+
logDebug("AgenticHandler", `${toolCall.tool_call.name} failed`, { verbose: error });
|
|
186850
187745
|
return {
|
|
186851
187746
|
tool_result,
|
|
186852
187747
|
output: {
|
|
@@ -186864,7 +187759,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186864
187759
|
* Handle errors with consistent logging and reporting
|
|
186865
187760
|
*/
|
|
186866
187761
|
handleError(sessionID, error, delegate, signal2) {
|
|
186867
|
-
logDebug
|
|
187762
|
+
logDebug("AgenticHandler", `Error in agent session ${sessionID}`, {
|
|
186868
187763
|
verbose: error instanceof Error ? { message: error.message, stack: error.stack } : String(error)
|
|
186869
187764
|
});
|
|
186870
187765
|
if (!signal2.aborted) {
|
|
@@ -187412,6 +188307,7 @@ class ChatController {
|
|
|
187412
188307
|
__publicField2(this, "guardrails");
|
|
187413
188308
|
__publicField2(this, "lastKnownTokenUsage");
|
|
187414
188309
|
__publicField2(this, "disposables", []);
|
|
188310
|
+
__publicField2(this, "deviceAuthController", null);
|
|
187415
188311
|
__publicField2(this, "clientBroadcast", new MulticastSubject());
|
|
187416
188312
|
__publicField2(this, "initDoer", new InitDoer());
|
|
187417
188313
|
__publicField2(this, "submitOrEditOperation");
|
|
@@ -187595,7 +188491,7 @@ class ChatController {
|
|
|
187595
188491
|
case "mcp": {
|
|
187596
188492
|
const mcpManager = MCPManager.instance;
|
|
187597
188493
|
if (!mcpManager) {
|
|
187598
|
-
logDebug("ChatController", "MCP Manager is not initialized");
|
|
188494
|
+
outputChannelLogger.logDebug("ChatController", "MCP Manager is not initialized");
|
|
187599
188495
|
break;
|
|
187600
188496
|
}
|
|
187601
188497
|
const serverName = message.name;
|
|
@@ -187649,11 +188545,18 @@ class ChatController {
|
|
|
187649
188545
|
break;
|
|
187650
188546
|
}
|
|
187651
188547
|
default:
|
|
187652
|
-
logDebug(
|
|
188548
|
+
outputChannelLogger.logDebug(
|
|
188549
|
+
"ChatController",
|
|
188550
|
+
`Unknown MCP operation: ${message.type}`
|
|
188551
|
+
);
|
|
187653
188552
|
}
|
|
187654
188553
|
} catch (error) {
|
|
187655
188554
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
187656
|
-
logDebug(
|
|
188555
|
+
outputChannelLogger.logDebug(
|
|
188556
|
+
"ChatController",
|
|
188557
|
+
`Failed to ${message.type} server`,
|
|
188558
|
+
errorMessage
|
|
188559
|
+
);
|
|
187657
188560
|
void this.postMessage({
|
|
187658
188561
|
type: "clientAction",
|
|
187659
188562
|
mcpServerError: {
|
|
@@ -187700,6 +188603,49 @@ class ChatController {
|
|
|
187700
188603
|
auth2 = await resolveAuth(endpoint, configuration, secretStorage);
|
|
187701
188604
|
}
|
|
187702
188605
|
if (!auth2 || !auth2.credentials) {
|
|
188606
|
+
this.deviceAuthController = new AbortController();
|
|
188607
|
+
const deviceAuthResult = await startDeviceAuthFlow(
|
|
188608
|
+
endpoint,
|
|
188609
|
+
(userCode, verificationUri) => {
|
|
188610
|
+
void this.postMessage({
|
|
188611
|
+
type: "device-flow-status",
|
|
188612
|
+
status: "code-ready",
|
|
188613
|
+
userCode,
|
|
188614
|
+
verificationUri
|
|
188615
|
+
});
|
|
188616
|
+
},
|
|
188617
|
+
this.deviceAuthController.signal
|
|
188618
|
+
);
|
|
188619
|
+
this.deviceAuthController = null;
|
|
188620
|
+
if (deviceAuthResult.type === "success") {
|
|
188621
|
+
await this.postMessage({
|
|
188622
|
+
type: "device-flow-status",
|
|
188623
|
+
status: "success",
|
|
188624
|
+
message: "Authentication successful!"
|
|
188625
|
+
});
|
|
188626
|
+
await showAuthResultMessage(endpoint, deviceAuthResult.authStatus);
|
|
188627
|
+
return;
|
|
188628
|
+
}
|
|
188629
|
+
if (deviceAuthResult.type === "cancelled") {
|
|
188630
|
+
await this.postMessage({
|
|
188631
|
+
type: "device-flow-status",
|
|
188632
|
+
status: "cancelled",
|
|
188633
|
+
message: "Device auth cancelled"
|
|
188634
|
+
});
|
|
188635
|
+
return;
|
|
188636
|
+
}
|
|
188637
|
+
if (deviceAuthResult.type === "failed") {
|
|
188638
|
+
await this.postMessage({
|
|
188639
|
+
type: "device-flow-status",
|
|
188640
|
+
status: "error",
|
|
188641
|
+
message: "Device auth failed"
|
|
188642
|
+
});
|
|
188643
|
+
outputChannelLogger.logDebug(
|
|
188644
|
+
"auth",
|
|
188645
|
+
"Device auth not available, falling back to traditional auth",
|
|
188646
|
+
{ endpoint }
|
|
188647
|
+
);
|
|
188648
|
+
}
|
|
187703
188649
|
return redirectToEndpointLogin(endpoint);
|
|
187704
188650
|
}
|
|
187705
188651
|
await authProvider.validateAndStoreCredentials(auth2, "always-store");
|
|
@@ -187723,12 +188669,26 @@ class ChatController {
|
|
|
187723
188669
|
await showSignInMenu();
|
|
187724
188670
|
break;
|
|
187725
188671
|
}
|
|
188672
|
+
if (message.authKind === "cancel") {
|
|
188673
|
+
if (this.deviceAuthController) {
|
|
188674
|
+
this.deviceAuthController.abort();
|
|
188675
|
+
this.deviceAuthController = null;
|
|
188676
|
+
outputChannelLogger.logDebug(
|
|
188677
|
+
"ChatController",
|
|
188678
|
+
"Device auth cancelled by user"
|
|
188679
|
+
);
|
|
188680
|
+
}
|
|
188681
|
+
break;
|
|
188682
|
+
}
|
|
187726
188683
|
await commands$1.executeCommand(`cody.auth.${message.authKind}`);
|
|
187727
188684
|
break;
|
|
187728
188685
|
}
|
|
187729
188686
|
case "log": {
|
|
187730
|
-
|
|
187731
|
-
|
|
188687
|
+
if (message.level === "debug") {
|
|
188688
|
+
outputChannelLogger.logDebug(message.filterLabel, message.message);
|
|
188689
|
+
} else {
|
|
188690
|
+
outputChannelLogger.logError(message.filterLabel, message.message);
|
|
188691
|
+
}
|
|
187732
188692
|
break;
|
|
187733
188693
|
}
|
|
187734
188694
|
case "devicePixelRatio": {
|
|
@@ -187811,7 +188771,7 @@ class ChatController {
|
|
|
187811
188771
|
workspaceFolderUris,
|
|
187812
188772
|
siteHasCodyEnabled
|
|
187813
188773
|
});
|
|
187814
|
-
logDebug("ChatController", "updateViewConfig", {
|
|
188774
|
+
outputChannelLogger.logDebug("ChatController", "updateViewConfig", {
|
|
187815
188775
|
verbose: configForWebview
|
|
187816
188776
|
});
|
|
187817
188777
|
}
|
|
@@ -187820,7 +188780,7 @@ class ChatController {
|
|
|
187820
188780
|
type: "clientConfig",
|
|
187821
188781
|
clientConfig
|
|
187822
188782
|
});
|
|
187823
|
-
logDebug("ChatController", "updateClientConfig", {
|
|
188783
|
+
outputChannelLogger.logDebug("ChatController", "updateClientConfig", {
|
|
187824
188784
|
verbose: clientConfig
|
|
187825
188785
|
});
|
|
187826
188786
|
}
|
|
@@ -187933,6 +188893,7 @@ class ChatController {
|
|
|
187933
188893
|
this.postEmptyMessageInProgress(model2);
|
|
187934
188894
|
let messageInProgress = { speaker: "assistant", model: model2 };
|
|
187935
188895
|
try {
|
|
188896
|
+
const chatBuilder = this.chatBuilder;
|
|
187936
188897
|
await agent2.handle(
|
|
187937
188898
|
{
|
|
187938
188899
|
requestID,
|
|
@@ -187940,7 +188901,7 @@ class ChatController {
|
|
|
187940
188901
|
mentions,
|
|
187941
188902
|
editorState,
|
|
187942
188903
|
signal: signal2,
|
|
187943
|
-
chatBuilder
|
|
188904
|
+
chatBuilder,
|
|
187944
188905
|
span: span2,
|
|
187945
188906
|
recorder: recorder2,
|
|
187946
188907
|
model: model2
|
|
@@ -187954,7 +188915,7 @@ class ChatController {
|
|
|
187954
188915
|
this.postViewTranscript(message);
|
|
187955
188916
|
},
|
|
187956
188917
|
postStatuses: (steps) => {
|
|
187957
|
-
|
|
188918
|
+
chatBuilder.setLastMessageProcesses(steps);
|
|
187958
188919
|
this.postViewTranscript(messageInProgress);
|
|
187959
188920
|
},
|
|
187960
188921
|
experimentalPostMessageInProgress: (subMessages) => {
|
|
@@ -188264,26 +189225,12 @@ class ChatController {
|
|
|
188264
189225
|
revealWebviewViewOrPanel(this._webviewPanelOrView);
|
|
188265
189226
|
}
|
|
188266
189227
|
}
|
|
188267
|
-
async handleResubmitLastUserInput() {
|
|
188268
|
-
var _a3;
|
|
188269
|
-
const lastHumanMessage = this.chatBuilder.getLastHumanMessage();
|
|
188270
|
-
const getLastHumanMessageText = (_a3 = lastHumanMessage == null ? void 0 : lastHumanMessage.text) == null ? void 0 : _a3.toString();
|
|
188271
|
-
if (getLastHumanMessageText) {
|
|
188272
|
-
await this.clearAndRestartSession();
|
|
188273
|
-
void this.postMessage({
|
|
188274
|
-
type: "clientAction",
|
|
188275
|
-
appendTextToLastPromptEditor: getLastHumanMessageText
|
|
188276
|
-
});
|
|
188277
|
-
}
|
|
188278
|
-
}
|
|
188279
189228
|
async handleSmartApplyResult(result) {
|
|
188280
189229
|
void this.postMessage({
|
|
188281
189230
|
type: "clientAction",
|
|
188282
189231
|
smartApplyResult: result
|
|
188283
189232
|
});
|
|
188284
189233
|
}
|
|
188285
|
-
fireClientAction() {
|
|
188286
|
-
}
|
|
188287
189234
|
async handleAttributionSearch(snippet) {
|
|
188288
189235
|
try {
|
|
188289
189236
|
const attribution = await this.guardrails.searchAttribution(snippet);
|
|
@@ -188378,19 +189325,8 @@ class ChatController {
|
|
|
188378
189325
|
}
|
|
188379
189326
|
}
|
|
188380
189327
|
} catch (error) {
|
|
188381
|
-
logDebug("ChatController", "setCustomChatTitle", { verbose: error });
|
|
189328
|
+
outputChannelLogger.logDebug("ChatController", "setCustomChatTitle", { verbose: error });
|
|
188382
189329
|
}
|
|
188383
|
-
telemetryRecorder.recordEvent("cody.chat.customTitle", "generated", {
|
|
188384
|
-
privateMetadata: {
|
|
188385
|
-
requestID,
|
|
188386
|
-
model: model2,
|
|
188387
|
-
traceId: span2.spanContext().traceId
|
|
188388
|
-
},
|
|
188389
|
-
metadata: {
|
|
188390
|
-
titleLength: title.length,
|
|
188391
|
-
inputLength: inputText.length
|
|
188392
|
-
}
|
|
188393
|
-
});
|
|
188394
189330
|
});
|
|
188395
189331
|
}
|
|
188396
189332
|
/**
|
|
@@ -188400,13 +189336,15 @@ class ChatController {
|
|
|
188400
189336
|
if (isRateLimitError(error)) {
|
|
188401
189337
|
handleRateLimitError();
|
|
188402
189338
|
}
|
|
188403
|
-
|
|
189339
|
+
const traceId = isNetworkError(error) ? error.traceId : void 0;
|
|
189340
|
+
const errorMessage = traceId ? `${error.message} (trace ID: ${traceId})` : error.message;
|
|
189341
|
+
outputChannelLogger.logDebug("ChatController: postError", errorMessage);
|
|
188404
189342
|
if (type === "transcript") {
|
|
188405
189343
|
this.chatBuilder.addErrorAsBotMessage(error, ChatBuilder.NO_MODEL);
|
|
188406
189344
|
this.postViewTranscript();
|
|
188407
189345
|
return;
|
|
188408
189346
|
}
|
|
188409
|
-
void this.postMessage({ type: "errors", errors:
|
|
189347
|
+
void this.postMessage({ type: "errors", errors: errorMessage });
|
|
188410
189348
|
captureException(error);
|
|
188411
189349
|
}
|
|
188412
189350
|
/**
|
|
@@ -188505,7 +189443,7 @@ class ChatController {
|
|
|
188505
189443
|
}
|
|
188506
189444
|
}
|
|
188507
189445
|
} catch (error) {
|
|
188508
|
-
logDebug("ChatController", "Failed");
|
|
189446
|
+
outputChannelLogger.logDebug("ChatController", "Failed");
|
|
188509
189447
|
}
|
|
188510
189448
|
}
|
|
188511
189449
|
async duplicateSession(sessionID) {
|
|
@@ -188569,7 +189507,7 @@ class ChatController {
|
|
|
188569
189507
|
* Revives the chat panel when the extension is reactivated.
|
|
188570
189508
|
*/
|
|
188571
189509
|
async revive(webviewPanel) {
|
|
188572
|
-
logDebug("ChatController:revive", "registering webview panel");
|
|
189510
|
+
outputChannelLogger.logDebug("ChatController:revive", "registering webview panel");
|
|
188573
189511
|
await this.registerWebviewPanel(webviewPanel);
|
|
188574
189512
|
}
|
|
188575
189513
|
async resolveWebviewView(webviewView, _context, _token) {
|
|
@@ -189481,7 +190419,6 @@ const HINT_DECORATIONS = {
|
|
|
189481
190419
|
};
|
|
189482
190420
|
const DOCUMENTABLE_SYMBOL_THROTTLE = 10;
|
|
189483
190421
|
const GHOST_TEXT_THROTTLE = 250;
|
|
189484
|
-
const TELEMETRY_THROTTLE = 30 * 1e3;
|
|
189485
190422
|
class GhostHintDecorator {
|
|
189486
190423
|
constructor(options) {
|
|
189487
190424
|
// permanentDisposables are disposed when this instance is disposed.
|
|
@@ -189491,7 +190428,6 @@ class GhostHintDecorator {
|
|
|
189491
190428
|
__publicField2(this, "isActive", false);
|
|
189492
190429
|
__publicField2(this, "activeDecorationRange", null);
|
|
189493
190430
|
__publicField2(this, "setThrottledGhostText");
|
|
189494
|
-
__publicField2(this, "fireThrottledDisplayEvent");
|
|
189495
190431
|
__publicField2(this, "getThrottledDocumentableSymbol");
|
|
189496
190432
|
/** Store the last line that the user typed on, we want to avoid showing the text here */
|
|
189497
190433
|
__publicField2(this, "lastLineTyped", null);
|
|
@@ -189500,14 +190436,6 @@ class GhostHintDecorator {
|
|
|
189500
190436
|
leading: false,
|
|
189501
190437
|
trailing: true
|
|
189502
190438
|
});
|
|
189503
|
-
this.fireThrottledDisplayEvent = lodashExports.throttle(
|
|
189504
|
-
this._fireDisplayEvent.bind(this),
|
|
189505
|
-
TELEMETRY_THROTTLE,
|
|
189506
|
-
{
|
|
189507
|
-
leading: true,
|
|
189508
|
-
trailing: false
|
|
189509
|
-
}
|
|
189510
|
-
);
|
|
189511
190439
|
this.getThrottledDocumentableSymbol = lodashExports.throttle(
|
|
189512
190440
|
this.getDocumentableSymbol.bind(this),
|
|
189513
190441
|
DOCUMENTABLE_SYMBOL_THROTTLE,
|
|
@@ -189617,7 +190545,6 @@ class GhostHintDecorator {
|
|
|
189617
190545
|
if (this.hasConflictingDecorations(editor, position)) {
|
|
189618
190546
|
return;
|
|
189619
190547
|
}
|
|
189620
|
-
this.fireThrottledDisplayEvent(variant);
|
|
189621
190548
|
const decorationHint = HINT_DECORATIONS[variant];
|
|
189622
190549
|
const decorationText = UNICODE_SPACE$1.repeat(textPadding) + decorationHint.text;
|
|
189623
190550
|
this.activeDecorationRange = new Range(position, position);
|
|
@@ -189666,9 +190593,6 @@ class GhostHintDecorator {
|
|
|
189666
190593
|
editor.setDecorations(decoration, []);
|
|
189667
190594
|
});
|
|
189668
190595
|
}
|
|
189669
|
-
_fireDisplayEvent(variant) {
|
|
189670
|
-
telemetryRecorder.recordEvent("cody.ghostText", "visible", { privateMetadata: { variant } });
|
|
189671
|
-
}
|
|
189672
190596
|
async updateEnablement(authStatus2) {
|
|
189673
190597
|
const featureEnablement = await getGhostHintEnablement();
|
|
189674
190598
|
if (!authStatus2.authenticated || !(featureEnablement.Document || featureEnablement.EditOrChat || featureEnablement.Generate)) {
|
|
@@ -189717,7 +190641,7 @@ async function unitTestCommand(span2, args2) {
|
|
|
189717
190641
|
);
|
|
189718
190642
|
}
|
|
189719
190643
|
const sharedContext = await getContextFilesForUnitTestCommand(document2.uri).catch((error) => {
|
|
189720
|
-
logError$
|
|
190644
|
+
logError$1("executeNewTestCommand", "failed to fetch context", { verbose: error });
|
|
189721
190645
|
return [];
|
|
189722
190646
|
});
|
|
189723
190647
|
prompt = prompt.replaceAll("<selected>", selectedCodePromptWithExtraFiles(cursorContext, []));
|
|
@@ -189730,7 +190654,7 @@ async function unitTestCommand(span2, args2) {
|
|
|
189730
190654
|
contextItems.push(cursorContext);
|
|
189731
190655
|
contextItems.push(...sharedContext);
|
|
189732
190656
|
} catch (error) {
|
|
189733
|
-
logError$
|
|
190657
|
+
logError$1("testCommand", "failed to fetch context", { verbose: error });
|
|
189734
190658
|
}
|
|
189735
190659
|
}
|
|
189736
190660
|
return {
|
|
@@ -189747,7 +190671,7 @@ async function executeTestChatCommand(args2) {
|
|
|
189747
190671
|
if (editor.active && await isUriIgnoredByContextFilterWithNotification(editor.active.document.uri, "test")) {
|
|
189748
190672
|
return;
|
|
189749
190673
|
}
|
|
189750
|
-
logDebug
|
|
190674
|
+
logDebug("executeTestEditCommand", "executing", { args: args2 });
|
|
189751
190675
|
telemetryRecorder.recordEvent("cody.command.test", "executed", {
|
|
189752
190676
|
metadata: {
|
|
189753
190677
|
useCodebaseContex: 0
|
|
@@ -190275,7 +191199,7 @@ async function getGitInfoForMentions(settings) {
|
|
|
190275
191199
|
);
|
|
190276
191200
|
return { cwd: dir, defaultBranch: defaultBranch.trim() };
|
|
190277
191201
|
} catch (error) {
|
|
190278
|
-
logDebug
|
|
191202
|
+
logDebug("gitMentionsProvider", "getGitInfoForMentions", {
|
|
190279
191203
|
dir: dir.toString(),
|
|
190280
191204
|
error
|
|
190281
191205
|
});
|
|
@@ -190303,13 +191227,13 @@ function parseMentionURI(uri) {
|
|
|
190303
191227
|
}
|
|
190304
191228
|
return data;
|
|
190305
191229
|
} catch (error) {
|
|
190306
|
-
logDebug
|
|
191230
|
+
logDebug("gitMentionsProvider", "invalid Git mention URI", uri.toString(), error);
|
|
190307
191231
|
return null;
|
|
190308
191232
|
}
|
|
190309
191233
|
}
|
|
190310
191234
|
async function execFileAsync(program2, args2, { cwd }) {
|
|
190311
|
-
const { promisify } = await import("./util-
|
|
190312
|
-
const { execFile } = await import("./vscode-shim-
|
|
191235
|
+
const { promisify } = await import("./util-Ci-ROool.mjs").then((n) => n.u);
|
|
191236
|
+
const { execFile } = await import("./vscode-shim-CdmSM8Q0.mjs").then((n) => n.gz);
|
|
190313
191237
|
return promisify(execFile)(program2, args2, { cwd });
|
|
190314
191238
|
}
|
|
190315
191239
|
var __create = Object.create;
|
|
@@ -192544,7 +193468,7 @@ function observeOpenCtxController(context2, createOpenCtxController) {
|
|
|
192544
193468
|
});
|
|
192545
193469
|
return controller2;
|
|
192546
193470
|
} catch (error) {
|
|
192547
|
-
logDebug("openctx", `Failed to load OpenCtx client: ${error}`);
|
|
193471
|
+
outputChannelLogger.logDebug("openctx", `Failed to load OpenCtx client: ${error}`);
|
|
192548
193472
|
throw error;
|
|
192549
193473
|
}
|
|
192550
193474
|
}),
|
|
@@ -192704,7 +193628,7 @@ async function getViewerSettingsProviders() {
|
|
|
192704
193628
|
}
|
|
192705
193629
|
return providers;
|
|
192706
193630
|
} catch (error) {
|
|
192707
|
-
logError$
|
|
193631
|
+
logError$1("OpenCtx", "failed to fetch viewer settings from Sourcegraph", error);
|
|
192708
193632
|
return void 0;
|
|
192709
193633
|
}
|
|
192710
193634
|
}
|
|
@@ -193426,7 +194350,7 @@ function matchJavascriptFormatting(incoming, original) {
|
|
|
193426
194350
|
return incoming;
|
|
193427
194351
|
}
|
|
193428
194352
|
function matchLanguage(incoming, original, uri) {
|
|
193429
|
-
const language =
|
|
194353
|
+
const language = languageFromFilenameAndContent(uri, original);
|
|
193430
194354
|
switch (language) {
|
|
193431
194355
|
case ProgrammingLanguage.TypeScript:
|
|
193432
194356
|
case ProgrammingLanguage.JavaScript:
|
|
@@ -194304,7 +195228,7 @@ class EditProvider {
|
|
|
194304
195228
|
}
|
|
194305
195229
|
case "error": {
|
|
194306
195230
|
let err2 = message.error;
|
|
194307
|
-
logError
|
|
195231
|
+
outputChannelLogger.logError("EditProvider:onError", err2.message);
|
|
194308
195232
|
if (isAbortError(err2)) {
|
|
194309
195233
|
if (session.state === "streaming") {
|
|
194310
195234
|
void this.handleResponse(text2, false);
|
|
@@ -194685,7 +195609,7 @@ class EditManager {
|
|
|
194685
195609
|
} catch (error) {
|
|
194686
195610
|
const errorObject = error instanceof Error ? error : new Error(typeof error === "string" ? error : String(error));
|
|
194687
195611
|
this.options.fixupController.error(task.id, errorObject);
|
|
194688
|
-
logError$
|
|
195612
|
+
logError$1("EditManager", "startStreamingEditTask", errorObject);
|
|
194689
195613
|
}
|
|
194690
195614
|
}
|
|
194691
195615
|
dispose() {
|
|
@@ -195680,9 +196604,9 @@ function getOverriddenModelForIntent(intent, currentModel, authStatus2) {
|
|
|
195680
196604
|
}
|
|
195681
196605
|
switch (intent) {
|
|
195682
196606
|
case "fix":
|
|
195683
|
-
return "anthropic::2024-10-22::claude-
|
|
196607
|
+
return "anthropic::2024-10-22::claude-sonnet-4-5-latest";
|
|
195684
196608
|
case "doc":
|
|
195685
|
-
return "anthropic::2024-10-22::claude-
|
|
196609
|
+
return "anthropic::2024-10-22::claude-haiku-4-5-latest";
|
|
195686
196610
|
case "test":
|
|
195687
196611
|
case "add":
|
|
195688
196612
|
case "edit":
|
|
@@ -196762,7 +197686,7 @@ class FixupController {
|
|
|
196762
197686
|
}
|
|
196763
197687
|
// Apply single fixup from task ID. Public for testing.
|
|
196764
197688
|
async apply(id) {
|
|
196765
|
-
logDebug("FixupController:apply", "applying", { verbose: { id } });
|
|
197689
|
+
outputChannelLogger.logDebug("FixupController:apply", "applying", { verbose: { id } });
|
|
196766
197690
|
const task = this.tasks.get(id);
|
|
196767
197691
|
if (!task) {
|
|
196768
197692
|
return;
|
|
@@ -197005,7 +197929,7 @@ class FixupController {
|
|
|
197005
197929
|
}
|
|
197006
197930
|
// Replace edit returned by Cody at task selection range
|
|
197007
197931
|
async replaceEdit(edit, diff2, task, options) {
|
|
197008
|
-
logDebug("FixupController:edit", "replacing ");
|
|
197932
|
+
outputChannelLogger.logDebug("FixupController:edit", "replacing ");
|
|
197009
197933
|
const suitableDiffForEditing = makeDiffEditBuilderCompatible(diff2);
|
|
197010
197934
|
if (edit instanceof AgentWorkspaceEdit) {
|
|
197011
197935
|
for (const change of suitableDiffForEditing) {
|
|
@@ -197033,7 +197957,7 @@ class FixupController {
|
|
|
197033
197957
|
}
|
|
197034
197958
|
// Insert edit returned by Cody at task selection range
|
|
197035
197959
|
async insertEdit(edit, document2, task, options) {
|
|
197036
|
-
logDebug("FixupController:edit", "inserting");
|
|
197960
|
+
outputChannelLogger.logDebug("FixupController:edit", "inserting");
|
|
197037
197961
|
const text2 = task.replacement;
|
|
197038
197962
|
if (!text2) {
|
|
197039
197963
|
return false;
|
|
@@ -197307,7 +198231,6 @@ const showSetupNotification = async (auth2) => {
|
|
|
197307
198231
|
await commands$1.executeCommand("cody.chat.focus");
|
|
197308
198232
|
return;
|
|
197309
198233
|
}
|
|
197310
|
-
telemetryRecorder.recordEvent("cody.signInNotification", "shown");
|
|
197311
198234
|
return showActionNotification({
|
|
197312
198235
|
message: "Sign in to Cody to get started",
|
|
197313
198236
|
actions: [
|
|
@@ -197511,12 +198434,6 @@ const FeedbackOptionItems = [
|
|
|
197511
198434
|
await env.openExternal(Uri.parse(CODY_DOC_URL.href));
|
|
197512
198435
|
}
|
|
197513
198436
|
},
|
|
197514
|
-
{
|
|
197515
|
-
label: "$(feedback) Cody Feedback",
|
|
197516
|
-
async onSelect() {
|
|
197517
|
-
await env.openExternal(Uri.parse(CODY_FEEDBACK_URL.href));
|
|
197518
|
-
}
|
|
197519
|
-
},
|
|
197520
198437
|
{
|
|
197521
198438
|
label: "$(organization) Cody Discord Channel",
|
|
197522
198439
|
async onSelect() {
|
|
@@ -198575,10 +199492,6 @@ function registerSidebarCommands() {
|
|
|
198575
199492
|
logSidebarClick("support");
|
|
198576
199493
|
void commands$1.executeCommand("vscode.open", CODY_SUPPORT_URL.href);
|
|
198577
199494
|
}),
|
|
198578
|
-
commands$1.registerCommand("cody.sidebar.feedback", () => {
|
|
198579
|
-
logSidebarClick("feedback");
|
|
198580
|
-
void commands$1.executeCommand("vscode.open", CODY_FEEDBACK_URL.href);
|
|
198581
|
-
}),
|
|
198582
199495
|
commands$1.registerCommand("cody.sidebar.discord", () => {
|
|
198583
199496
|
logSidebarClick("discord");
|
|
198584
199497
|
void commands$1.executeCommand("vscode.open", DISCORD_URL.href);
|
|
@@ -198976,7 +199889,7 @@ function interactDefault({
|
|
|
198976
199889
|
try {
|
|
198977
199890
|
(_a3 = error.onShow) == null ? void 0 : _a3.call(error);
|
|
198978
199891
|
} catch (e) {
|
|
198979
|
-
logError$
|
|
199892
|
+
logError$1("Status Bar Interaction", "Error during show handler");
|
|
198980
199893
|
}
|
|
198981
199894
|
}
|
|
198982
199895
|
const createFeatureToggle = featureToggleBuilder(
|
|
@@ -199058,17 +199971,7 @@ function interactDefault({
|
|
|
199058
199971
|
},
|
|
199059
199972
|
{ label: "feedback & support", kind: QuickPickItemKind.Separator },
|
|
199060
199973
|
...SupportOptionItems,
|
|
199061
|
-
...FeedbackOptionItems
|
|
199062
|
-
{ label: `v${version}`, kind: QuickPickItemKind.Separator },
|
|
199063
|
-
{
|
|
199064
|
-
label: "$(cody-logo) Cody Release Blog",
|
|
199065
|
-
async onSelect() {
|
|
199066
|
-
await commands$1.executeCommand(
|
|
199067
|
-
"vscode.open",
|
|
199068
|
-
getReleaseNotesURLByIDE(version, CodyIDE.VSCode)
|
|
199069
|
-
);
|
|
199070
|
-
}
|
|
199071
|
-
}
|
|
199974
|
+
...FeedbackOptionItems
|
|
199072
199975
|
].filter(Boolean);
|
|
199073
199976
|
quickPick.title = "Cody Settings";
|
|
199074
199977
|
quickPick.placeholder = "Choose an option";
|
|
@@ -199420,7 +200323,7 @@ async function* getSupercompletions({
|
|
|
199420
200323
|
if (!supercompletion) {
|
|
199421
200324
|
continue;
|
|
199422
200325
|
}
|
|
199423
|
-
logDebug
|
|
200326
|
+
logDebug("supercompletions", "candidate", { verbose: supercompletion });
|
|
199424
200327
|
yield supercompletion;
|
|
199425
200328
|
}
|
|
199426
200329
|
}
|
|
@@ -199442,7 +200345,7 @@ async function* generateRawChanges(chat2, messages, abortSignal) {
|
|
|
199442
200345
|
const summaryMatch = change.match(/<summary>(.*)<\/summary>/s);
|
|
199443
200346
|
const changeMatch = change.match(/<change>(.*)<\/change>/s);
|
|
199444
200347
|
if (!summaryMatch || !changeMatch) {
|
|
199445
|
-
logDebug
|
|
200348
|
+
logDebug("supercompletions", "error", "invalid change block", {
|
|
199446
200349
|
verbose: change
|
|
199447
200350
|
});
|
|
199448
200351
|
continue;
|
|
@@ -199499,7 +200402,7 @@ function parseRawChange(document2, { change, summary }) {
|
|
|
199499
200402
|
}
|
|
199500
200403
|
}
|
|
199501
200404
|
if (state2 !== "complete") {
|
|
199502
|
-
logDebug
|
|
200405
|
+
logDebug(
|
|
199503
200406
|
"supercompletions",
|
|
199504
200407
|
"error",
|
|
199505
200408
|
"could not find change deliminators",
|
|
@@ -199928,7 +200831,7 @@ async function start(context2, platform2) {
|
|
|
199928
200831
|
if (secretStorage instanceof VSCodeSecretStorage) {
|
|
199929
200832
|
secretStorage.setStorage(context2.secrets);
|
|
199930
200833
|
}
|
|
199931
|
-
setLogger(
|
|
200834
|
+
setLogger(outputChannelLogger);
|
|
199932
200835
|
setClientCapabilities({
|
|
199933
200836
|
configuration: getConfiguration(),
|
|
199934
200837
|
agentCapabilities: platform2.extensionClient.capabilities
|
|
@@ -199959,7 +200862,7 @@ async function start(context2, platform2) {
|
|
|
199959
200862
|
isReinstalling,
|
|
199960
200863
|
onReinstall: async () => {
|
|
199961
200864
|
if (hasReinstallCleanupRun) return;
|
|
199962
|
-
logDebug("start", "Reinstalling Cody");
|
|
200865
|
+
outputChannelLogger.logDebug("start", "Reinstalling Cody");
|
|
199963
200866
|
const history = await localStorage.deleteEndpointHistory();
|
|
199964
200867
|
const additionalEndpointsToClear = [
|
|
199965
200868
|
clientConfiguration.overrideServerEndpoint,
|
|
@@ -200048,6 +200951,7 @@ const register = async (context2, platform2, isExtensionModeDevOrTest) => {
|
|
|
200048
200951
|
}
|
|
200049
200952
|
if (isExtensionModeDevOrTest) {
|
|
200050
200953
|
await registerTestCommands(context2, disposables);
|
|
200954
|
+
registerAuthDebugCommands(disposables);
|
|
200051
200955
|
}
|
|
200052
200956
|
registerDebugCommands(context2, disposables);
|
|
200053
200957
|
registerAuthenticationHandlers(disposables);
|
|
@@ -200113,11 +201017,6 @@ ${retryMessage}`
|
|
|
200113
201017
|
void env.openExternal(Uri.parse(ACCOUNT_LIMITS_INFO_URL.toString()));
|
|
200114
201018
|
}
|
|
200115
201019
|
}
|
|
200116
|
-
),
|
|
200117
|
-
// Walkthrough / Support
|
|
200118
|
-
commands$1.registerCommand(
|
|
200119
|
-
"cody.feedback",
|
|
200120
|
-
() => env.openExternal(Uri.parse(CODY_FEEDBACK_URL.href))
|
|
200121
201020
|
)
|
|
200122
201021
|
);
|
|
200123
201022
|
}
|
|
@@ -200133,7 +201032,7 @@ async function registerCodyCommands({
|
|
|
200133
201032
|
if (error instanceof Error) {
|
|
200134
201033
|
console.log(error.stack);
|
|
200135
201034
|
}
|
|
200136
|
-
logError
|
|
201035
|
+
outputChannelLogger.logError("executeCommand", commandKey, args2, error);
|
|
200137
201036
|
return void 0;
|
|
200138
201037
|
});
|
|
200139
201038
|
};
|
|
@@ -200409,7 +201308,7 @@ function registerAutocomplete(platform2, statusBar, disposables) {
|
|
|
200409
201308
|
}),
|
|
200410
201309
|
catchError$1((error) => {
|
|
200411
201310
|
finishLoading();
|
|
200412
|
-
logError
|
|
201311
|
+
outputChannelLogger.logError("registerAutocomplete", "Error", error);
|
|
200413
201312
|
return NEVER$1;
|
|
200414
201313
|
})
|
|
200415
201314
|
).subscribe({})
|
|
@@ -200441,7 +201340,10 @@ function registerChat({ context: context2, platform: platform2, chatClient, guar
|
|
|
200441
201340
|
window$1.registerWebviewPanelSerializer(CodyChatEditorViewType, {
|
|
200442
201341
|
async deserializeWebviewPanel(webviewPanel, chatID) {
|
|
200443
201342
|
if (chatID && webviewPanel.title) {
|
|
200444
|
-
logDebug(
|
|
201343
|
+
outputChannelLogger.logDebug(
|
|
201344
|
+
"main:deserializeWebviewPanel",
|
|
201345
|
+
"reviving last unclosed chat panel"
|
|
201346
|
+
);
|
|
200445
201347
|
await chatsController.restoreToPanel(webviewPanel, chatID);
|
|
200446
201348
|
}
|
|
200447
201349
|
}
|
|
@@ -202168,5 +203070,95 @@ agent.registerNotification("debug/message", (params) => {
|
|
|
202168
203070
|
});
|
|
202169
203071
|
conn.listen();
|
|
202170
203072
|
export {
|
|
202171
|
-
|
|
203073
|
+
getCompletionsModelConfig as $,
|
|
203074
|
+
ANSWER_TOKENS as A,
|
|
203075
|
+
BotResponseMultiplexer as B,
|
|
203076
|
+
CompletionStopReason as C,
|
|
203077
|
+
DEFAULT_EVENT_SOURCE as D,
|
|
203078
|
+
EventSourceTelemetryMetadataMapping as E,
|
|
203079
|
+
FIXTURE_MODEL as F,
|
|
203080
|
+
PromptMixin as G,
|
|
203081
|
+
newPromptMixin as H,
|
|
203082
|
+
truncateTextNearestLine as I,
|
|
203083
|
+
truncatePromptStringStart as J,
|
|
203084
|
+
truncatePromptString as K,
|
|
203085
|
+
SourcegraphBrowserCompletionsClient as L,
|
|
203086
|
+
ModelUsage as M,
|
|
203087
|
+
NUM_CODE_RESULTS as N,
|
|
203088
|
+
Ollama$1 as O,
|
|
203089
|
+
ProcessType as P,
|
|
203090
|
+
SourcegraphCompletionsClient as Q,
|
|
203091
|
+
ClientConfigSingleton as R,
|
|
203092
|
+
SourcegraphGuardrailsClient as S,
|
|
203093
|
+
Typewriter as T,
|
|
203094
|
+
RestClient as U,
|
|
203095
|
+
events$1 as V,
|
|
203096
|
+
TokenCounter as W,
|
|
203097
|
+
getTokenCounterUtils as X,
|
|
203098
|
+
TokenCounterUtils as Y,
|
|
203099
|
+
tokensToChars as Z,
|
|
203100
|
+
charsToTokens as _,
|
|
203101
|
+
createModel as a,
|
|
203102
|
+
getSerializedParams as a0,
|
|
203103
|
+
fetchLocalOllamaModels as a1,
|
|
203104
|
+
siteVersion as a2,
|
|
203105
|
+
currentSiteVersion as a3,
|
|
203106
|
+
isValidVersion as a4,
|
|
203107
|
+
checkVersion as a5,
|
|
203108
|
+
configOverwrites as a6,
|
|
203109
|
+
createRuleService as a7,
|
|
203110
|
+
isRulesEnabled as a8,
|
|
203111
|
+
ModelsService as a9,
|
|
203112
|
+
editorWindowIsFocused as aA,
|
|
203113
|
+
modelsService as aa,
|
|
203114
|
+
TestLocalStorageForModelPreferences as ab,
|
|
203115
|
+
mockModelsService as ac,
|
|
203116
|
+
codyPaths as ad,
|
|
203117
|
+
populateCodeContextTemplate as ae,
|
|
203118
|
+
populateCurrentEditorDiagnosticsTemplate as af,
|
|
203119
|
+
populateTerminalOutputContextTemplate as ag,
|
|
203120
|
+
populateCurrentSelectedCodeContextTemplate as ah,
|
|
203121
|
+
populateListOfFilesContextTemplate as ai,
|
|
203122
|
+
populateContextTemplateFromText as aj,
|
|
203123
|
+
populateImportListContextTemplate as ak,
|
|
203124
|
+
populateCodeGenerationContextTemplate as al,
|
|
203125
|
+
getClientPromptString as am,
|
|
203126
|
+
InvisibleStatusBarTag as an,
|
|
203127
|
+
dotcomTokenToGatewayToken as ao,
|
|
203128
|
+
getCodyAuthReferralCode as ap,
|
|
203129
|
+
createSSEIterator as aq,
|
|
203130
|
+
googleChatClient as ar,
|
|
203131
|
+
groqChatClient as as,
|
|
203132
|
+
parseCompletionJSON as at,
|
|
203133
|
+
ContextFiltersProvider as au,
|
|
203134
|
+
getContextForChatMessage as av,
|
|
203135
|
+
Mutable as aw,
|
|
203136
|
+
singletonNotYetSet as ax,
|
|
203137
|
+
setSingleton as ay,
|
|
203138
|
+
setEditorWindowIsFocused as az,
|
|
203139
|
+
base64Js as b,
|
|
203140
|
+
contextFiltersProvider as c,
|
|
203141
|
+
createModelFromServerModel as d,
|
|
203142
|
+
enableMapSet as e,
|
|
203143
|
+
getModelInfo as f,
|
|
203144
|
+
getProviderName as g,
|
|
203145
|
+
handleRateLimitError as h,
|
|
203146
|
+
isCustomModel as i,
|
|
203147
|
+
toModelRefStr as j,
|
|
203148
|
+
ChatClient as k,
|
|
203149
|
+
getDefaultSystemPrompt as l,
|
|
203150
|
+
modelTier as m,
|
|
203151
|
+
getChatPreamble as n,
|
|
203152
|
+
getSimplePreamble as o,
|
|
203153
|
+
parseModelRef as p,
|
|
203154
|
+
errorToChatError as q,
|
|
203155
|
+
parseEvents as r,
|
|
203156
|
+
serializeChatMessage as s,
|
|
203157
|
+
toLegacyModel as t,
|
|
203158
|
+
ollamaChatClient as u,
|
|
203159
|
+
OLLAMA_DEFAULT_URL as v,
|
|
203160
|
+
MAX_BYTES_PER_FILE as w,
|
|
203161
|
+
MAX_CURRENT_FILE_TOKENS as x,
|
|
203162
|
+
NUM_TEXT_RESULTS as y,
|
|
203163
|
+
SURROUNDING_LINES as z
|
|
202172
203164
|
};
|