@sourcegraph/cody-web 0.36.0 → 0.37.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-DKy-Dvsz.mjs} +1459 -390
- package/dist/agent.worker.js +2 -2
- package/dist/{git-log-Dihxu1-Z.mjs → git-log-DigEy5-z.mjs} +1 -1
- package/dist/index-D8dVdFLY.mjs +1055 -0
- package/dist/index.js +17 -20
- package/dist/{lite-CQAWMpwn.mjs → lite-DPjR5uH7.mjs} +1 -1
- package/dist/style.css +15 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/util-BR3OBpy6.mjs +1811 -0
- package/dist/{vscode-shim-Csgwpsv8.mjs → vscode-shim-CqAb7AbA.mjs} +4859 -3729
- package/package.json +3 -3
- package/dist/util-D8ltdME7.mjs +0 -2033
|
@@ -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 {
|
|
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-CqAb7AbA.mjs";
|
|
22
|
+
import { a as util$5, i as inherits_browserExports } from "./util-BR3OBpy6.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-DPjR5uH7.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) {
|
|
@@ -22230,7 +22638,7 @@ function requireBuffer_list() {
|
|
|
22230
22638
|
return (hint === "string" ? String : Number)(input);
|
|
22231
22639
|
}
|
|
22232
22640
|
var _require = requireBuffer(), Buffer2 = _require.Buffer;
|
|
22233
|
-
var _require2 =
|
|
22641
|
+
var _require2 = util$5, inspect = _require2.inspect;
|
|
22234
22642
|
var custom2 = inspect && inspect.custom || "inspect";
|
|
22235
22643
|
function copyBuffer(src, target, offset2) {
|
|
22236
22644
|
Buffer2.prototype.copy.call(src, target, offset2);
|
|
@@ -23822,7 +24230,7 @@ function require_stream_readable() {
|
|
|
23822
24230
|
function _isUint8Array(obj) {
|
|
23823
24231
|
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
23824
24232
|
}
|
|
23825
|
-
var debugUtil =
|
|
24233
|
+
var debugUtil = util$5;
|
|
23826
24234
|
var debug2;
|
|
23827
24235
|
if (debugUtil && debugUtil.debuglog) {
|
|
23828
24236
|
debug2 = debugUtil.debuglog("stream");
|
|
@@ -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
|
);
|
|
@@ -37645,9 +38135,7 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
37645
38135
|
if (!isFileProvided) {
|
|
37646
38136
|
return fallbackUri;
|
|
37647
38137
|
}
|
|
37648
|
-
|
|
37649
|
-
const hasExistingRoot = await doesFileExist(rootDir);
|
|
37650
|
-
if (hasExistingRoot) {
|
|
38138
|
+
if (path$1.isAbsolute(uri)) {
|
|
37651
38139
|
return Uri.file(uri);
|
|
37652
38140
|
}
|
|
37653
38141
|
if (!baseDirUri) {
|
|
@@ -37661,11 +38149,22 @@ async function resolveRelativeOrAbsoluteUri(baseDirUri, uri, fallbackUri) {
|
|
|
37661
38149
|
return smartJoinPath(baseDirUri, uri);
|
|
37662
38150
|
}
|
|
37663
38151
|
function smartJoinPath(baseDirUri, relativeFileUri) {
|
|
38152
|
+
if (path$1.isAbsolute(relativeFileUri)) {
|
|
38153
|
+
return Uri.file(relativeFileUri);
|
|
38154
|
+
}
|
|
37664
38155
|
const workspacePath = baseDirUri.path.split(separatorsRegex).filter((segment) => segment.length > 0);
|
|
37665
38156
|
const filePath = relativeFileUri.split(separatorsRegex).filter((segment) => segment.length > 0);
|
|
37666
|
-
const
|
|
37667
|
-
|
|
37668
|
-
|
|
38157
|
+
const maxOverlap = Math.min(workspacePath.length, filePath.length);
|
|
38158
|
+
let overlapLength = 0;
|
|
38159
|
+
for (let k = maxOverlap; k >= 1; k--) {
|
|
38160
|
+
const workspaceSuffix = workspacePath.slice(-k);
|
|
38161
|
+
const filePrefix = filePath.slice(0, k);
|
|
38162
|
+
if (isEqual(workspaceSuffix, filePrefix)) {
|
|
38163
|
+
overlapLength = k;
|
|
38164
|
+
break;
|
|
38165
|
+
}
|
|
38166
|
+
}
|
|
38167
|
+
const uniqueFilePath = overlapLength > 0 ? filePath.slice(overlapLength) : filePath;
|
|
37669
38168
|
const resultPath = path$1.join(baseDirUri.path, ...uniqueFilePath);
|
|
37670
38169
|
return Uri.file(resultPath);
|
|
37671
38170
|
}
|
|
@@ -38195,14 +38694,14 @@ class UpstreamHealthProvider {
|
|
|
38195
38694
|
});
|
|
38196
38695
|
if ("error" in upstreamResult) {
|
|
38197
38696
|
this.lastUpstreamLatency = void 0;
|
|
38198
|
-
logDebug
|
|
38697
|
+
logDebug("UpstreamHealth", "Failed to ping upstream host", {
|
|
38199
38698
|
verbose: {
|
|
38200
38699
|
error: upstreamResult.error
|
|
38201
38700
|
}
|
|
38202
38701
|
});
|
|
38203
38702
|
} else {
|
|
38204
38703
|
this.lastUpstreamLatency = upstreamResult.latency;
|
|
38205
|
-
logDebug
|
|
38704
|
+
logDebug(
|
|
38206
38705
|
"UpstreamHealth",
|
|
38207
38706
|
`Ping took ${Math.round(upstreamResult.latency)}ms ${this.lastGatewayLatency ? `(Gateway: ${Math.round(this.lastGatewayLatency)}ms)` : ""}`,
|
|
38208
38707
|
{
|
|
@@ -39040,7 +39539,7 @@ class ProtocolTextDocumentWithUri {
|
|
|
39040
39539
|
this.uri = uri;
|
|
39041
39540
|
this.underlying = underlying ?? { uri: uri.toString() };
|
|
39042
39541
|
if (this.underlying.uri !== uri.toString()) {
|
|
39043
|
-
logDebug(
|
|
39542
|
+
outputChannelLogger.logDebug(
|
|
39044
39543
|
"ProtocolTextDocumentWithUri",
|
|
39045
39544
|
"correcting invariant violation",
|
|
39046
39545
|
`${this.uri} (this.uri) !== ${this.underlying.uri} (this.underlying.uri)`
|
|
@@ -39090,17 +39589,17 @@ class AgentAuthHandler {
|
|
|
39090
39589
|
}
|
|
39091
39590
|
this.startServer(url);
|
|
39092
39591
|
} catch (error) {
|
|
39093
|
-
logDebug
|
|
39592
|
+
logDebug("AgentAuthHandler", `Invalid callback URL: ${error}`);
|
|
39094
39593
|
}
|
|
39095
39594
|
}
|
|
39096
39595
|
startServer(callbackUri) {
|
|
39097
39596
|
var _a3;
|
|
39098
39597
|
if (!((_a3 = this.tokenCallbackHandlers) == null ? void 0 : _a3.length)) {
|
|
39099
|
-
logDebug
|
|
39598
|
+
logDebug("AgentAuthHandler", "Token callback handler is not set.");
|
|
39100
39599
|
return;
|
|
39101
39600
|
}
|
|
39102
39601
|
if (this.server && this.port) {
|
|
39103
|
-
logDebug
|
|
39602
|
+
logDebug("AgentAuthHandler", "Server already running");
|
|
39104
39603
|
this.redirectToEndpointLoginPage(callbackUri);
|
|
39105
39604
|
return;
|
|
39106
39605
|
}
|
|
@@ -39137,17 +39636,17 @@ class AgentAuthHandler {
|
|
|
39137
39636
|
server.listen(0, "127.0.0.1", () => {
|
|
39138
39637
|
this.port = server.address().port;
|
|
39139
39638
|
this.server = server;
|
|
39140
|
-
logDebug
|
|
39639
|
+
logDebug("AgentAuthHandler", `Server listening on port ${this.port}`);
|
|
39141
39640
|
this.redirectToEndpointLoginPage(callbackUri);
|
|
39142
39641
|
setTimeout(() => this.closeServer(), SIX_MINUTES);
|
|
39143
39642
|
});
|
|
39144
39643
|
server.on("error", (error) => {
|
|
39145
|
-
logDebug
|
|
39644
|
+
logDebug("AgentAuthHandler", `Server error: ${error}`);
|
|
39146
39645
|
});
|
|
39147
39646
|
}
|
|
39148
39647
|
closeServer() {
|
|
39149
39648
|
if (this.server) {
|
|
39150
|
-
logDebug
|
|
39649
|
+
logDebug("AgentAuthHandler", "Auth server closed");
|
|
39151
39650
|
this.server.close();
|
|
39152
39651
|
}
|
|
39153
39652
|
this.server = null;
|
|
@@ -39176,8 +39675,14 @@ class AgentAuthHandler {
|
|
|
39176
39675
|
} else {
|
|
39177
39676
|
const params = new URLSearchParams(decodeURIComponent(uri.search));
|
|
39178
39677
|
const requestFrom = params.get("requestFrom");
|
|
39678
|
+
const user_code = params.get("user_code");
|
|
39179
39679
|
if (requestFrom) {
|
|
39180
39680
|
params.set("requestFrom", `${requestFrom}-${this.port}`);
|
|
39681
|
+
}
|
|
39682
|
+
if (user_code) {
|
|
39683
|
+
params.set("user_code", user_code);
|
|
39684
|
+
}
|
|
39685
|
+
if (requestFrom || user_code) {
|
|
39181
39686
|
uri.search = params.toString();
|
|
39182
39687
|
}
|
|
39183
39688
|
}
|
|
@@ -39198,7 +39703,7 @@ function getValidCallbackUri(uri) {
|
|
|
39198
39703
|
}
|
|
39199
39704
|
return URI.parse(endpointUri.href);
|
|
39200
39705
|
} catch (error) {
|
|
39201
|
-
logDebug
|
|
39706
|
+
logDebug("Invalid URL: ", `${error}`);
|
|
39202
39707
|
return null;
|
|
39203
39708
|
}
|
|
39204
39709
|
}
|
|
@@ -39274,7 +39779,7 @@ function createFileSystemRuleProvider() {
|
|
|
39274
39779
|
return rules;
|
|
39275
39780
|
} catch (error) {
|
|
39276
39781
|
if (!(error && typeof error === "object" && "code" in error && error.code === "FileNotFound")) {
|
|
39277
|
-
logDebug
|
|
39782
|
+
logDebug(
|
|
39278
39783
|
"rules",
|
|
39279
39784
|
`Error reading rules for ${searchPath}: ${error}`
|
|
39280
39785
|
);
|
|
@@ -39355,7 +39860,7 @@ async function listRulesApplyingToRemoteFile(client, repoName, filePath, signal2
|
|
|
39355
39860
|
}
|
|
39356
39861
|
return resp.rules ?? [];
|
|
39357
39862
|
} catch (error) {
|
|
39358
|
-
logDebug
|
|
39863
|
+
logDebug(
|
|
39359
39864
|
"rules",
|
|
39360
39865
|
`Error listing rules for remote file ${filePath} in repository ${repoName}: ${error}`
|
|
39361
39866
|
);
|
|
@@ -39679,7 +40184,7 @@ async function getContextFileFromUri(file, range) {
|
|
|
39679
40184
|
size
|
|
39680
40185
|
};
|
|
39681
40186
|
} catch (error) {
|
|
39682
|
-
logError$
|
|
40187
|
+
logError$1("getContextFileFromUri", "failed", { verbose: error });
|
|
39683
40188
|
return null;
|
|
39684
40189
|
}
|
|
39685
40190
|
});
|
|
@@ -39712,7 +40217,7 @@ async function getContextFromRelativePath(path2) {
|
|
|
39712
40217
|
size
|
|
39713
40218
|
};
|
|
39714
40219
|
} catch (error) {
|
|
39715
|
-
logError$
|
|
40220
|
+
logError$1("getContextFileFromUri", "failed", { verbose: error });
|
|
39716
40221
|
return null;
|
|
39717
40222
|
}
|
|
39718
40223
|
}
|
|
@@ -40530,7 +41035,7 @@ async function resolveContextMentionProviderContextItem({ provider: providerUri,
|
|
|
40530
41035
|
return [];
|
|
40531
41036
|
}
|
|
40532
41037
|
if (!item.mention) {
|
|
40533
|
-
logError$
|
|
41038
|
+
logError$1("OpenCtx", "resolving context item is missing mention parameter", item);
|
|
40534
41039
|
return [];
|
|
40535
41040
|
}
|
|
40536
41041
|
const mention = {
|
|
@@ -42741,6 +43246,9 @@ const objectivec = [
|
|
|
42741
43246
|
"m",
|
|
42742
43247
|
"mm"
|
|
42743
43248
|
];
|
|
43249
|
+
const matlab = [
|
|
43250
|
+
"m"
|
|
43251
|
+
];
|
|
42744
43252
|
const ocaml = [
|
|
42745
43253
|
"ml",
|
|
42746
43254
|
"eliom",
|
|
@@ -43048,6 +43556,7 @@ const extensionMapping = {
|
|
|
43048
43556
|
markdown,
|
|
43049
43557
|
nginx,
|
|
43050
43558
|
objectivec,
|
|
43559
|
+
matlab,
|
|
43051
43560
|
ocaml,
|
|
43052
43561
|
pascal,
|
|
43053
43562
|
perl,
|
|
@@ -43090,17 +43599,25 @@ function getMapping() {
|
|
|
43090
43599
|
mapping = /* @__PURE__ */ new Map();
|
|
43091
43600
|
for (const [language, extensions2] of Object.entries(extensionMapping)) {
|
|
43092
43601
|
for (const extension of extensions2) {
|
|
43093
|
-
mapping.set(extension, language);
|
|
43602
|
+
mapping.set(extension.toLowerCase(), language);
|
|
43094
43603
|
}
|
|
43095
43604
|
}
|
|
43096
43605
|
return mapping;
|
|
43097
43606
|
}
|
|
43098
43607
|
function getLanguageForFileName(filePath) {
|
|
43099
43608
|
const fileName = path$1.basename(filePath);
|
|
43100
|
-
const extension = fileName.split(".").pop() || fileName;
|
|
43609
|
+
const extension = (fileName.split(".").pop() || fileName).toLowerCase();
|
|
43101
43610
|
const language = getMapping().get(extension);
|
|
43102
43611
|
return language || extension;
|
|
43103
43612
|
}
|
|
43613
|
+
function getLanguageForFileNameAndContent(filePath, content) {
|
|
43614
|
+
const fileName = path$1.basename(filePath);
|
|
43615
|
+
const extension = (fileName.split(".").pop() || fileName).toLowerCase();
|
|
43616
|
+
if (extension === "m") {
|
|
43617
|
+
return isMatlabFile(content) ? "matlab" : "objectivec";
|
|
43618
|
+
}
|
|
43619
|
+
return getLanguageForFileName(filePath);
|
|
43620
|
+
}
|
|
43104
43621
|
class DocumentOffsets {
|
|
43105
43622
|
constructor(document2) {
|
|
43106
43623
|
__publicField2(this, "lines", []);
|
|
@@ -43170,7 +43687,10 @@ class AgentTextDocument {
|
|
|
43170
43687
|
__publicField2(this, "isClosed", false);
|
|
43171
43688
|
__publicField2(this, "eol", EndOfLine.LF);
|
|
43172
43689
|
this.protocolDocument = protocolDocument;
|
|
43173
|
-
this.languageId =
|
|
43690
|
+
this.languageId = getLanguageForFileNameAndContent(
|
|
43691
|
+
this.fileName,
|
|
43692
|
+
this.protocolDocument.underlying.content ?? ""
|
|
43693
|
+
);
|
|
43174
43694
|
this.offsets = new DocumentOffsets(protocolDocument.underlying);
|
|
43175
43695
|
this.lineCount = this.offsets.lineCount();
|
|
43176
43696
|
}
|
|
@@ -43289,7 +43809,7 @@ class AgentTextEditor {
|
|
|
43289
43809
|
if ((_a3 = this.params) == null ? void 0 : _a3.edit) {
|
|
43290
43810
|
return this.params.edit(this.agentDocument.uri, callback, options);
|
|
43291
43811
|
}
|
|
43292
|
-
logDebug
|
|
43812
|
+
logDebug("AgentTextEditor:edit()", "not supported");
|
|
43293
43813
|
return Promise.resolve(false);
|
|
43294
43814
|
});
|
|
43295
43815
|
this.agentDocument = agentDocument;
|
|
@@ -43929,7 +44449,7 @@ class AgentWorkspaceDocuments {
|
|
|
43929
44449
|
if (uri.scheme === "untitled") {
|
|
43930
44450
|
document2.underlying.content = "";
|
|
43931
44451
|
} else if (!await doesFileExist(uri)) {
|
|
43932
|
-
logError$
|
|
44452
|
+
logError$1(
|
|
43933
44453
|
"AgentWorkspaceDocuments.openTextDocument()",
|
|
43934
44454
|
"File does not exist",
|
|
43935
44455
|
uri.toString()
|
|
@@ -43938,7 +44458,7 @@ class AgentWorkspaceDocuments {
|
|
|
43938
44458
|
const buffer2 = await fs.readFile(uri.fsPath, "utf8");
|
|
43939
44459
|
document2.underlying.content = buffer2.toString();
|
|
43940
44460
|
} else {
|
|
43941
|
-
logError$
|
|
44461
|
+
logError$1("vscode.workspace.openTextDocument", `unable to read non-file URI: ${uri}`);
|
|
43942
44462
|
}
|
|
43943
44463
|
}
|
|
43944
44464
|
return Promise.resolve(this.loadAndUpdateDocument(document2));
|
|
@@ -44703,7 +45223,7 @@ function requireLib() {
|
|
|
44703
45223
|
const MurmurHash3 = requireImurmurhash();
|
|
44704
45224
|
const { onExit } = requireCjs();
|
|
44705
45225
|
const path2 = pathBrowserify;
|
|
44706
|
-
const { promisify } =
|
|
45226
|
+
const { promisify } = util$5;
|
|
44707
45227
|
const activeFiles = {};
|
|
44708
45228
|
const threadId = function getId() {
|
|
44709
45229
|
try {
|
|
@@ -45505,14 +46025,14 @@ function copyExtensionRelativeResources(extensionPath, extensionClient) {
|
|
|
45505
46025
|
return;
|
|
45506
46026
|
}
|
|
45507
46027
|
} catch {
|
|
45508
|
-
logDebug
|
|
46028
|
+
logDebug("copyExtensionRelativeResources", `Failed to find ${source}, skipping copy`);
|
|
45509
46029
|
return;
|
|
45510
46030
|
}
|
|
45511
46031
|
try {
|
|
45512
46032
|
mkdirSync(path$1.dirname(target), { recursive: true });
|
|
45513
46033
|
copySync(source, target);
|
|
45514
46034
|
} catch (err2) {
|
|
45515
|
-
logDebug
|
|
46035
|
+
logDebug("copyExtensionRelativeResources", `Failed to copy ${source} to dist ${target}`, err2);
|
|
45516
46036
|
}
|
|
45517
46037
|
};
|
|
45518
46038
|
copySources("win-ca-roots.exe");
|
|
@@ -45583,7 +46103,7 @@ class Agent extends MessageHandler {
|
|
|
45583
46103
|
edit: (uri, callback, options) => {
|
|
45584
46104
|
var _a3, _b2;
|
|
45585
46105
|
if (((_b2 = (_a3 = this.clientInfo) == null ? void 0 : _a3.capabilities) == null ? void 0 : _b2.edit) !== "enabled") {
|
|
45586
|
-
logDebug
|
|
46106
|
+
logDebug("CodyAgent", "client does not support operation: textDocument/edit");
|
|
45587
46107
|
return Promise.resolve(false);
|
|
45588
46108
|
}
|
|
45589
46109
|
const edits = [];
|
|
@@ -45764,7 +46284,6 @@ class Agent extends MessageHandler {
|
|
|
45764
46284
|
const textDocument = this.workspace.loadDocument(documentWithUri);
|
|
45765
46285
|
onDidOpenTextDocument.fire(textDocument);
|
|
45766
46286
|
this.pushPendingPromise(this.workspace.fireVisibleTextEditorsDidChange());
|
|
45767
|
-
this.workspace.setActiveTextEditor(this.workspace.newTextEditor(textDocument));
|
|
45768
46287
|
});
|
|
45769
46288
|
this.registerNotification("textDocument/didChange", async (document2) => {
|
|
45770
46289
|
this.handleDocumentChange(document2);
|
|
@@ -46118,12 +46637,12 @@ class Agent extends MessageHandler {
|
|
|
46118
46637
|
var _a3, _b2, _c2;
|
|
46119
46638
|
const provider = await completionProvider();
|
|
46120
46639
|
if (!provider) {
|
|
46121
|
-
logError$
|
|
46640
|
+
logError$1("Agent", "autocomplete/execute", "Completion provider is not initialized");
|
|
46122
46641
|
return { items: [], inlineCompletionItems: [], decoratedEditItems: [] };
|
|
46123
46642
|
}
|
|
46124
46643
|
const uri = typeof params2.uri === "string" ? Uri.parse(params2.uri) : (params2 == null ? void 0 : params2.filePath) ? Uri.file(params2.filePath) : void 0;
|
|
46125
46644
|
if (!uri) {
|
|
46126
|
-
logError$
|
|
46645
|
+
logError$1(
|
|
46127
46646
|
"Agent",
|
|
46128
46647
|
"autocomplete/execute",
|
|
46129
46648
|
`No uri provided for autocomplete request ${JSON.stringify(
|
|
@@ -46134,7 +46653,7 @@ class Agent extends MessageHandler {
|
|
|
46134
46653
|
}
|
|
46135
46654
|
const document2 = this.workspace.getDocument(uri);
|
|
46136
46655
|
if (!document2) {
|
|
46137
|
-
logError$
|
|
46656
|
+
logError$1(
|
|
46138
46657
|
"Agent",
|
|
46139
46658
|
"autocomplete/execute",
|
|
46140
46659
|
"No document found for file path",
|
|
@@ -46329,7 +46848,7 @@ class Agent extends MessageHandler {
|
|
|
46329
46848
|
);
|
|
46330
46849
|
const document2 = this.workspace.getDocument(uri);
|
|
46331
46850
|
if (!document2) {
|
|
46332
|
-
logError$
|
|
46851
|
+
logError$1(
|
|
46333
46852
|
"Agent",
|
|
46334
46853
|
"editTask/getFoldingRanges",
|
|
46335
46854
|
"No document found for file path",
|
|
@@ -46751,7 +47270,7 @@ class Agent extends MessageHandler {
|
|
|
46751
47270
|
metadata: metadata2
|
|
46752
47271
|
});
|
|
46753
47272
|
}
|
|
46754
|
-
logError$
|
|
47273
|
+
logError$1(
|
|
46755
47274
|
"Agent",
|
|
46756
47275
|
'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
47276
|
new Error().stack
|
|
@@ -46840,7 +47359,7 @@ async function explainHistoryCommand(span2, commandsProvider, args2) {
|
|
|
46840
47359
|
if (isFailure(historyOptions)) {
|
|
46841
47360
|
return historyOptions;
|
|
46842
47361
|
}
|
|
46843
|
-
logDebug
|
|
47362
|
+
logDebug("explainHistoryCommand", "computed history options", JSON.stringify(historyOptions));
|
|
46844
47363
|
let contextItems = [];
|
|
46845
47364
|
try {
|
|
46846
47365
|
contextItems = await commandsProvider.history(historyOptions.uri, historyOptions);
|
|
@@ -46868,7 +47387,7 @@ async function explainHistoryCommand(span2, commandsProvider, args2) {
|
|
|
46868
47387
|
async function executeExplainHistoryCommand(commandsProvider, args2 = {}) {
|
|
46869
47388
|
return wrapInActiveSpan("command.explain-history", async (span2) => {
|
|
46870
47389
|
span2.setAttribute("sampled", true);
|
|
46871
|
-
logDebug
|
|
47390
|
+
logDebug("executeExplainHistoryCommand", "executing", args2);
|
|
46872
47391
|
telemetryRecorder.recordEvent("cody.command.explain-history", "executed", {
|
|
46873
47392
|
interactionID: args2 == null ? void 0 : args2.requestID,
|
|
46874
47393
|
privateMetadata: {
|
|
@@ -46924,7 +47443,7 @@ function isFailure(object) {
|
|
|
46924
47443
|
function handleFailure(span2, result) {
|
|
46925
47444
|
span2.setAttribute("failure-reason", result.reason);
|
|
46926
47445
|
if (result.level === "error") {
|
|
46927
|
-
logError$
|
|
47446
|
+
logError$1(
|
|
46928
47447
|
"executeExplainHistoryCommand",
|
|
46929
47448
|
"error fetching history context",
|
|
46930
47449
|
result.reason,
|
|
@@ -46934,7 +47453,7 @@ function handleFailure(span2, result) {
|
|
|
46934
47453
|
window$1.showErrorMessage(errorMessage);
|
|
46935
47454
|
throw new Error(errorMessage);
|
|
46936
47455
|
}
|
|
46937
|
-
logDebug
|
|
47456
|
+
logDebug(
|
|
46938
47457
|
"executeExplainHistoryCommand",
|
|
46939
47458
|
"failed to explaining history context",
|
|
46940
47459
|
result.reason,
|
|
@@ -47319,7 +47838,7 @@ class CustomCommandsManager {
|
|
|
47319
47838
|
const buildWorkspaceCommands = workspace.isTrusted ? this.build(CustomCommandType.Workspace) : Promise.resolve();
|
|
47320
47839
|
await Promise.all([buildUserCommands, buildWorkspaceCommands]);
|
|
47321
47840
|
} catch (error) {
|
|
47322
|
-
logError
|
|
47841
|
+
outputChannelLogger.logError("CustomCommandsProvider:refresh", "failed", { verbose: error });
|
|
47323
47842
|
}
|
|
47324
47843
|
return { commands: this.customCommandsMap };
|
|
47325
47844
|
}
|
|
@@ -47349,7 +47868,7 @@ class CustomCommandsManager {
|
|
|
47349
47868
|
);
|
|
47350
47869
|
}
|
|
47351
47870
|
} catch (error) {
|
|
47352
|
-
logError
|
|
47871
|
+
outputChannelLogger.logError("CustomCommandsProvider:build", "failed", { verbose: error });
|
|
47353
47872
|
}
|
|
47354
47873
|
return this.customCommandsMap;
|
|
47355
47874
|
}
|
|
@@ -47363,7 +47882,7 @@ class CustomCommandsManager {
|
|
|
47363
47882
|
return;
|
|
47364
47883
|
}
|
|
47365
47884
|
await this.save(newCommand.key, newCommand.prompt, newCommand.type);
|
|
47366
|
-
logDebug("CustomCommandsProvider:newCustomCommandQuickPick:", "saved", {
|
|
47885
|
+
outputChannelLogger.logDebug("CustomCommandsProvider:newCustomCommandQuickPick:", "saved", {
|
|
47367
47886
|
verbose: newCommand
|
|
47368
47887
|
});
|
|
47369
47888
|
}
|
|
@@ -47438,7 +47957,7 @@ class CustomCommandsManager {
|
|
|
47438
47957
|
}
|
|
47439
47958
|
}
|
|
47440
47959
|
showSystemError(title, error) {
|
|
47441
|
-
logDebug("CustomCommandsProvider", title, { verbose: error });
|
|
47960
|
+
outputChannelLogger.logDebug("CustomCommandsProvider", title, { verbose: error });
|
|
47442
47961
|
void window$1.showErrorMessage(`${title} ${error}`);
|
|
47443
47962
|
}
|
|
47444
47963
|
/**
|
|
@@ -47890,7 +48409,7 @@ class CommandsProvider {
|
|
|
47890
48409
|
if (!isFileURI(uri)) {
|
|
47891
48410
|
throw new Error("history only supported on local file paths");
|
|
47892
48411
|
}
|
|
47893
|
-
const { getContextFileFromGitLog } = await import("./git-log-
|
|
48412
|
+
const { getContextFileFromGitLog } = await import("./git-log-DigEy5-z.mjs");
|
|
47894
48413
|
return getContextFileFromGitLog(uri, options);
|
|
47895
48414
|
}
|
|
47896
48415
|
dispose() {
|
|
@@ -48077,6 +48596,418 @@ ${authStatus2.endpoint}`;
|
|
|
48077
48596
|
return void 0;
|
|
48078
48597
|
}
|
|
48079
48598
|
}
|
|
48599
|
+
async function abortableDelay(ms, signal2) {
|
|
48600
|
+
return new Promise((resolve) => {
|
|
48601
|
+
const timeoutId = setTimeout(() => resolve(false), ms);
|
|
48602
|
+
if (signal2.aborted) {
|
|
48603
|
+
clearTimeout(timeoutId);
|
|
48604
|
+
resolve(true);
|
|
48605
|
+
return;
|
|
48606
|
+
}
|
|
48607
|
+
const onAbort2 = () => {
|
|
48608
|
+
clearTimeout(timeoutId);
|
|
48609
|
+
resolve(true);
|
|
48610
|
+
};
|
|
48611
|
+
signal2.addEventListener("abort", onAbort2);
|
|
48612
|
+
});
|
|
48613
|
+
}
|
|
48614
|
+
let debugDisableDeviceAuth = false;
|
|
48615
|
+
function setDebugDisableDeviceAuth(disabled) {
|
|
48616
|
+
debugDisableDeviceAuth = disabled;
|
|
48617
|
+
outputChannelLogger.logDebug("device-auth", "Debug device auth override", { disabled });
|
|
48618
|
+
}
|
|
48619
|
+
function getDebugDisableDeviceAuth() {
|
|
48620
|
+
return debugDisableDeviceAuth;
|
|
48621
|
+
}
|
|
48622
|
+
async function getOIDCConfiguration(endpoint) {
|
|
48623
|
+
if (debugDisableDeviceAuth) {
|
|
48624
|
+
outputChannelLogger.logDebug("device-auth", "Device auth disabled via debug flag", { endpoint });
|
|
48625
|
+
return null;
|
|
48626
|
+
}
|
|
48627
|
+
const config = await getOIDCConfiguration$1(endpoint);
|
|
48628
|
+
if (!config) {
|
|
48629
|
+
outputChannelLogger.logDebug("device-auth", "OIDC configuration not available", { endpoint });
|
|
48630
|
+
return null;
|
|
48631
|
+
}
|
|
48632
|
+
return config;
|
|
48633
|
+
}
|
|
48634
|
+
async function initiateDeviceAuth(oidcConfig) {
|
|
48635
|
+
if (!(oidcConfig == null ? void 0 : oidcConfig.device_authorization_endpoint)) {
|
|
48636
|
+
return null;
|
|
48637
|
+
}
|
|
48638
|
+
const clientId = getOAuthClientId();
|
|
48639
|
+
try {
|
|
48640
|
+
const response = await fetch(oidcConfig.device_authorization_endpoint, {
|
|
48641
|
+
method: "POST",
|
|
48642
|
+
headers: {
|
|
48643
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
48644
|
+
},
|
|
48645
|
+
body: new URLSearchParams({
|
|
48646
|
+
client_id: clientId,
|
|
48647
|
+
scope: "user:all"
|
|
48648
|
+
})
|
|
48649
|
+
});
|
|
48650
|
+
if (!response.ok) {
|
|
48651
|
+
throw new Error(`Device auth initiation failed: ${response.status} ${response.statusText}`);
|
|
48652
|
+
}
|
|
48653
|
+
const deviceAuth = await response.json();
|
|
48654
|
+
outputChannelLogger.logDebug("device-auth", "Device auth initiated", {
|
|
48655
|
+
device_authorization_endpoint: oidcConfig == null ? void 0 : oidcConfig.device_authorization_endpoint,
|
|
48656
|
+
user_code: deviceAuth.user_code,
|
|
48657
|
+
expires_in: deviceAuth.expires_in
|
|
48658
|
+
});
|
|
48659
|
+
return deviceAuth;
|
|
48660
|
+
} catch (error) {
|
|
48661
|
+
outputChannelLogger.logError("device-auth", "Failed to initiate device auth", error);
|
|
48662
|
+
return null;
|
|
48663
|
+
}
|
|
48664
|
+
}
|
|
48665
|
+
async function pollForToken(oidcConfig, deviceCode, interval2, expiresIn, abortSignal) {
|
|
48666
|
+
const clientId = getOAuthClientId();
|
|
48667
|
+
const startTime = Date.now();
|
|
48668
|
+
const expirationTime = startTime + expiresIn * 1e3;
|
|
48669
|
+
let attempts = 0;
|
|
48670
|
+
const maxAttempts = Math.ceil(expiresIn / interval2);
|
|
48671
|
+
while (Date.now() < expirationTime && attempts < maxAttempts && !abortSignal.aborted) {
|
|
48672
|
+
attempts++;
|
|
48673
|
+
try {
|
|
48674
|
+
const response = await fetch(oidcConfig.token_endpoint, {
|
|
48675
|
+
method: "POST",
|
|
48676
|
+
headers: {
|
|
48677
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
48678
|
+
},
|
|
48679
|
+
body: new URLSearchParams({
|
|
48680
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
48681
|
+
device_code: deviceCode,
|
|
48682
|
+
client_id: clientId
|
|
48683
|
+
})
|
|
48684
|
+
});
|
|
48685
|
+
if (response.ok) {
|
|
48686
|
+
const tokenResponse = await response.json();
|
|
48687
|
+
outputChannelLogger.logDebug("device-auth", "Token received successfully");
|
|
48688
|
+
return tokenResponse;
|
|
48689
|
+
}
|
|
48690
|
+
if (response.status === 400) {
|
|
48691
|
+
const error = await response.json();
|
|
48692
|
+
if (error.error === "authorization_pending") {
|
|
48693
|
+
outputChannelLogger.logDebug(
|
|
48694
|
+
"device-auth",
|
|
48695
|
+
"Authorization pending, continuing to poll",
|
|
48696
|
+
{ attempts }
|
|
48697
|
+
);
|
|
48698
|
+
} else if (error.error === "slow_down") {
|
|
48699
|
+
interval2 = Math.min(interval2 * 2, 60);
|
|
48700
|
+
outputChannelLogger.logDebug("device-auth", "Slowing down polling", {
|
|
48701
|
+
newInterval: interval2
|
|
48702
|
+
});
|
|
48703
|
+
} else if (error.error === "expired_token") {
|
|
48704
|
+
outputChannelLogger.logDebug("device-auth", "Device code expired");
|
|
48705
|
+
return null;
|
|
48706
|
+
} else if (error.error === "access_denied") {
|
|
48707
|
+
outputChannelLogger.logDebug("device-auth", "User denied authorization");
|
|
48708
|
+
return null;
|
|
48709
|
+
} else {
|
|
48710
|
+
outputChannelLogger.logError(
|
|
48711
|
+
"device-auth",
|
|
48712
|
+
"Unknown error during token polling",
|
|
48713
|
+
error
|
|
48714
|
+
);
|
|
48715
|
+
return null;
|
|
48716
|
+
}
|
|
48717
|
+
} else {
|
|
48718
|
+
outputChannelLogger.logError("device-auth", "Unexpected response during token polling", {
|
|
48719
|
+
status: response.status,
|
|
48720
|
+
statusText: response.statusText
|
|
48721
|
+
});
|
|
48722
|
+
return null;
|
|
48723
|
+
}
|
|
48724
|
+
} catch (error) {
|
|
48725
|
+
outputChannelLogger.logError("device-auth", "Error during token polling", error);
|
|
48726
|
+
return null;
|
|
48727
|
+
}
|
|
48728
|
+
const wasCancelled = await abortableDelay(interval2 * 1e3, abortSignal);
|
|
48729
|
+
if (wasCancelled) {
|
|
48730
|
+
return null;
|
|
48731
|
+
}
|
|
48732
|
+
}
|
|
48733
|
+
outputChannelLogger.logDebug("device-auth", "Token polling timed out", { attempts, expiresIn });
|
|
48734
|
+
return null;
|
|
48735
|
+
}
|
|
48736
|
+
async function startDeviceAuthFlow(uri, onUserCode, abortSignal) {
|
|
48737
|
+
const endpoint = formatURL(uri);
|
|
48738
|
+
if (!endpoint) {
|
|
48739
|
+
return { type: "failed" };
|
|
48740
|
+
}
|
|
48741
|
+
telemetryRecorder.recordEvent("cody.auth.device.initiated", "started");
|
|
48742
|
+
const oidcConfig = await getOIDCConfiguration(endpoint);
|
|
48743
|
+
if (!oidcConfig) {
|
|
48744
|
+
outputChannelLogger.logDebug("device-auth", "Failed to get OIDC configuration", { endpoint });
|
|
48745
|
+
return { type: "failed" };
|
|
48746
|
+
}
|
|
48747
|
+
const deviceAuth = await initiateDeviceAuth(oidcConfig);
|
|
48748
|
+
if (!deviceAuth) {
|
|
48749
|
+
outputChannelLogger.logDebug("device-auth", "Device auth not supported", { endpoint });
|
|
48750
|
+
return { type: "failed" };
|
|
48751
|
+
}
|
|
48752
|
+
const deviceUrl = deviceAuth.verification_uri_complete || `${deviceAuth.verification_uri}?user_code=${encodeURIComponent(deviceAuth.user_code)}`;
|
|
48753
|
+
onUserCode(deviceAuth.user_code, deviceUrl);
|
|
48754
|
+
return window$1.withProgress(
|
|
48755
|
+
{
|
|
48756
|
+
location: ProgressLocation.Notification,
|
|
48757
|
+
title: "Waiting for authorization...",
|
|
48758
|
+
cancellable: true
|
|
48759
|
+
},
|
|
48760
|
+
async (progress, cancellationToken) => {
|
|
48761
|
+
const combinedController = new AbortController();
|
|
48762
|
+
cancellationToken.onCancellationRequested(() => {
|
|
48763
|
+
combinedController.abort();
|
|
48764
|
+
outputChannelLogger.logDebug("device-auth", "Device auth cancelled via notification");
|
|
48765
|
+
});
|
|
48766
|
+
if (abortSignal) {
|
|
48767
|
+
abortSignal.addEventListener("abort", () => {
|
|
48768
|
+
combinedController.abort();
|
|
48769
|
+
outputChannelLogger.logDebug("device-auth", "Device auth aborted via webview");
|
|
48770
|
+
});
|
|
48771
|
+
}
|
|
48772
|
+
const tokenResponse = await pollForToken(
|
|
48773
|
+
oidcConfig,
|
|
48774
|
+
deviceAuth.device_code,
|
|
48775
|
+
deviceAuth.interval,
|
|
48776
|
+
deviceAuth.expires_in,
|
|
48777
|
+
combinedController.signal
|
|
48778
|
+
);
|
|
48779
|
+
if (combinedController.signal.aborted) {
|
|
48780
|
+
telemetryRecorder.recordEvent("cody.auth.device.cancelled", "cancelled");
|
|
48781
|
+
const status = { pendingValidation: false };
|
|
48782
|
+
return Promise.resolve({ type: "cancelled", authStatus: status });
|
|
48783
|
+
}
|
|
48784
|
+
if (!tokenResponse) {
|
|
48785
|
+
telemetryRecorder.recordEvent("cody.auth.device.failed", "failed");
|
|
48786
|
+
return { type: "failed" };
|
|
48787
|
+
}
|
|
48788
|
+
if (tokenResponse.refresh_token) {
|
|
48789
|
+
await secretStorage.storeRefreshToken(endpoint, tokenResponse.refresh_token);
|
|
48790
|
+
}
|
|
48791
|
+
if (tokenResponse.expires_in) {
|
|
48792
|
+
const expiresAt = Date.now() + tokenResponse.expires_in * 1e3;
|
|
48793
|
+
await secretStorage.storeTokenExpiresAt(endpoint, expiresAt);
|
|
48794
|
+
}
|
|
48795
|
+
if (tokenResponse.access_token) {
|
|
48796
|
+
await secretStorage.storeToken(endpoint, tokenResponse.access_token, "oauth");
|
|
48797
|
+
}
|
|
48798
|
+
await secretStorage.store(endpoint + "cody.access-token.source", "oauth");
|
|
48799
|
+
const deviceAuthCredential = new OAuthCredential(endpoint, secretStorage);
|
|
48800
|
+
if (!deviceAuthCredential) {
|
|
48801
|
+
telemetryRecorder.recordEvent("cody.auth.device.failed", "failed");
|
|
48802
|
+
return { type: "failed" };
|
|
48803
|
+
}
|
|
48804
|
+
const authStatus2 = await authProvider.validateAndStoreCredentials(
|
|
48805
|
+
{
|
|
48806
|
+
serverEndpoint: endpoint,
|
|
48807
|
+
credentials: deviceAuthCredential
|
|
48808
|
+
},
|
|
48809
|
+
"store-if-valid"
|
|
48810
|
+
);
|
|
48811
|
+
telemetryRecorder.recordEvent("cody.auth.device.completed", "completed", {
|
|
48812
|
+
metadata: {
|
|
48813
|
+
success: authStatus2.authenticated ? 1 : 0
|
|
48814
|
+
}
|
|
48815
|
+
});
|
|
48816
|
+
return { type: "success", authStatus: authStatus2 };
|
|
48817
|
+
}
|
|
48818
|
+
);
|
|
48819
|
+
}
|
|
48820
|
+
function registerAuthDebugCommands(disposables) {
|
|
48821
|
+
disposables.push(
|
|
48822
|
+
// Set token expiry for testing refresh logic
|
|
48823
|
+
commands$1.registerCommand("cody.debug.auth.setTokenExpiry", async () => {
|
|
48824
|
+
const authStatus2 = currentAuthStatus();
|
|
48825
|
+
if (!authStatus2.authenticated) {
|
|
48826
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48827
|
+
return;
|
|
48828
|
+
}
|
|
48829
|
+
const options = [
|
|
48830
|
+
{ label: "1 hour ago (expired)", value: Date.now() - 60 * 60 * 1e3 },
|
|
48831
|
+
{ label: "10 minutes from now", value: Date.now() + 10 * 60 * 1e3 },
|
|
48832
|
+
{ label: "2 minutes from now", value: Date.now() + 2 * 60 * 1e3 },
|
|
48833
|
+
{ label: "30 seconds from now", value: Date.now() + 30 * 1e3 },
|
|
48834
|
+
{ label: "No expiry (remove)", value: null }
|
|
48835
|
+
];
|
|
48836
|
+
const selection = await window$1.showQuickPick(options, {
|
|
48837
|
+
title: "Set Token Expiry",
|
|
48838
|
+
placeHolder: "Choose when the token should expire"
|
|
48839
|
+
});
|
|
48840
|
+
if (!selection) return;
|
|
48841
|
+
const endpoint = authStatus2.endpoint;
|
|
48842
|
+
if (selection.value === null) {
|
|
48843
|
+
await secretStorage.delete(endpoint + "cody.token.expires-at");
|
|
48844
|
+
void window$1.showInformationMessage("Token expiry removed");
|
|
48845
|
+
} else {
|
|
48846
|
+
await secretStorage.storeTokenExpiresAt(endpoint, selection.value);
|
|
48847
|
+
const timeStr = new Date(selection.value).toLocaleString();
|
|
48848
|
+
void window$1.showInformationMessage(`Token expiry set to: ${timeStr}`);
|
|
48849
|
+
}
|
|
48850
|
+
}),
|
|
48851
|
+
// Check current token expiry
|
|
48852
|
+
commands$1.registerCommand("cody.debug.auth.checkTokenExpiry", async () => {
|
|
48853
|
+
const authStatus2 = currentAuthStatus();
|
|
48854
|
+
if (!authStatus2.authenticated) {
|
|
48855
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48856
|
+
return;
|
|
48857
|
+
}
|
|
48858
|
+
const endpoint = authStatus2.endpoint;
|
|
48859
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48860
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48861
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48862
|
+
if (!expiresAt) {
|
|
48863
|
+
void window$1.showInformationMessage("No token expiry set");
|
|
48864
|
+
return;
|
|
48865
|
+
}
|
|
48866
|
+
const now = Date.now();
|
|
48867
|
+
const timeUntilExpiry = expiresAt - now;
|
|
48868
|
+
const isExpired = timeUntilExpiry <= 0;
|
|
48869
|
+
const needsRefresh = timeUntilExpiry <= 5 * 60 * 1e3;
|
|
48870
|
+
const expiryTime = new Date(expiresAt).toLocaleString();
|
|
48871
|
+
const status = isExpired ? "🔴 EXPIRED" : needsRefresh ? "🟡 NEEDS REFRESH" : "🟢 VALID";
|
|
48872
|
+
const info2 = [
|
|
48873
|
+
`Status: ${status}`,
|
|
48874
|
+
`Expires: ${expiryTime}`,
|
|
48875
|
+
`Time until expiry: ${Math.round(timeUntilExpiry / 1e3)}s`,
|
|
48876
|
+
`Has refresh token: ${refreshToken ? "Yes" : "No"}`,
|
|
48877
|
+
`Token source: ${tokenSource || "Unknown"}`
|
|
48878
|
+
].join("\n");
|
|
48879
|
+
void window$1.showInformationMessage(info2, { modal: true });
|
|
48880
|
+
}),
|
|
48881
|
+
// Set invalid token to test error handling
|
|
48882
|
+
commands$1.registerCommand("cody.debug.auth.setInvalidRefreshToken", async () => {
|
|
48883
|
+
const authStatus2 = currentAuthStatus();
|
|
48884
|
+
if (!authStatus2.authenticated) {
|
|
48885
|
+
void window$1.showErrorMessage("Not authenticated");
|
|
48886
|
+
return;
|
|
48887
|
+
}
|
|
48888
|
+
const endpoint = authStatus2.endpoint;
|
|
48889
|
+
await secretStorage.storeRefreshToken(endpoint, "invalid_token_for_testing");
|
|
48890
|
+
void window$1.showInformationMessage(
|
|
48891
|
+
"Invalid refresh token set - auth will fail on next request"
|
|
48892
|
+
);
|
|
48893
|
+
}),
|
|
48894
|
+
// Clear all auth data
|
|
48895
|
+
commands$1.registerCommand("cody.debug.auth.clearAll", async () => {
|
|
48896
|
+
const confirmation = await window$1.showWarningMessage(
|
|
48897
|
+
"This will clear all stored authentication data. Continue?",
|
|
48898
|
+
{ modal: true },
|
|
48899
|
+
"Clear All"
|
|
48900
|
+
);
|
|
48901
|
+
if (confirmation !== "Clear All") return;
|
|
48902
|
+
const endpoints = JSON.parse(localStorage.get("CODY_ENDPOINT_HISTORY") || "[]");
|
|
48903
|
+
for (const endpoint of endpoints) {
|
|
48904
|
+
await secretStorage.deleteToken(endpoint);
|
|
48905
|
+
}
|
|
48906
|
+
void window$1.showInformationMessage("All auth data cleared");
|
|
48907
|
+
}),
|
|
48908
|
+
// Show stored auth data (works even when not authenticated)
|
|
48909
|
+
commands$1.registerCommand("cody.debug.auth.showStoredData", async () => {
|
|
48910
|
+
const endpoints = localStorage.getEndpointHistory() || [];
|
|
48911
|
+
if (endpoints.length === 0) {
|
|
48912
|
+
void window$1.showInformationMessage("No stored endpoints found");
|
|
48913
|
+
return;
|
|
48914
|
+
}
|
|
48915
|
+
const results = [];
|
|
48916
|
+
for (const endpoint of endpoints) {
|
|
48917
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48918
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48919
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48920
|
+
let token = await secretStorage.getToken(endpoint);
|
|
48921
|
+
let tokenInfo = "None";
|
|
48922
|
+
if (tokenSource === "oauth") {
|
|
48923
|
+
const authStatus2 = currentAuthStatus();
|
|
48924
|
+
if (authStatus2.authenticated && authStatus2.endpoint === endpoint) {
|
|
48925
|
+
tokenInfo = "In memory (HeaderCredential)";
|
|
48926
|
+
try {
|
|
48927
|
+
const config = await import("./index-D8dVdFLY.mjs").then(
|
|
48928
|
+
(m) => m.currentResolvedConfig()
|
|
48929
|
+
);
|
|
48930
|
+
const currentConfig = await config;
|
|
48931
|
+
if (currentConfig.auth.credentials && "getHeaders" in currentConfig.auth.credentials) {
|
|
48932
|
+
const headers = await currentConfig.auth.credentials.getHeaders();
|
|
48933
|
+
const authHeader = headers.Authorization;
|
|
48934
|
+
if (authHeader == null ? void 0 : authHeader.startsWith("Bearer ")) {
|
|
48935
|
+
token = authHeader.slice(7);
|
|
48936
|
+
tokenInfo = token;
|
|
48937
|
+
}
|
|
48938
|
+
}
|
|
48939
|
+
} catch {
|
|
48940
|
+
}
|
|
48941
|
+
}
|
|
48942
|
+
} else if (token) {
|
|
48943
|
+
tokenInfo = token;
|
|
48944
|
+
}
|
|
48945
|
+
if (token || refreshToken || tokenSource) {
|
|
48946
|
+
const expiryStr = expiresAt ? new Date(expiresAt).toLocaleString() : "No expiry";
|
|
48947
|
+
results.push(
|
|
48948
|
+
[
|
|
48949
|
+
`Endpoint: ${endpoint}`,
|
|
48950
|
+
`Token: ${tokenInfo}`,
|
|
48951
|
+
`Refresh Token: ${refreshToken || "None"}`,
|
|
48952
|
+
`Token Source: ${tokenSource || "Unknown"}`,
|
|
48953
|
+
`Expires: ${expiryStr}`,
|
|
48954
|
+
"---"
|
|
48955
|
+
].join("\n")
|
|
48956
|
+
);
|
|
48957
|
+
}
|
|
48958
|
+
}
|
|
48959
|
+
if (results.length === 0) {
|
|
48960
|
+
void window$1.showInformationMessage("No stored tokens found");
|
|
48961
|
+
} else {
|
|
48962
|
+
void window$1.showInformationMessage(
|
|
48963
|
+
`Found ${results.length} stored token(s). Check "Cody auth" output channel for details.`,
|
|
48964
|
+
"Open Output Channel"
|
|
48965
|
+
).then((action) => {
|
|
48966
|
+
if (action === "Open Output Channel") {
|
|
48967
|
+
commands$1.executeCommand("workbench.action.output.toggleOutput");
|
|
48968
|
+
}
|
|
48969
|
+
});
|
|
48970
|
+
}
|
|
48971
|
+
}),
|
|
48972
|
+
// Show current auth info (masked) - requires being authenticated
|
|
48973
|
+
commands$1.registerCommand("cody.debug.auth.showInfo", async () => {
|
|
48974
|
+
const authStatus2 = currentAuthStatus();
|
|
48975
|
+
if (!authStatus2.authenticated) {
|
|
48976
|
+
void window$1.showInformationMessage(
|
|
48977
|
+
'Not authenticated - use "Show Stored Data" instead'
|
|
48978
|
+
);
|
|
48979
|
+
return;
|
|
48980
|
+
}
|
|
48981
|
+
const endpoint = authStatus2.endpoint;
|
|
48982
|
+
const token = await secretStorage.getToken(endpoint);
|
|
48983
|
+
const refreshToken = await secretStorage.getRefreshToken(endpoint);
|
|
48984
|
+
const expiresAt = await secretStorage.getTokenExpiresAt(endpoint);
|
|
48985
|
+
const tokenSource = await secretStorage.getTokenSource(endpoint);
|
|
48986
|
+
const maskedToken = refreshToken ? `${refreshToken.slice(0, 8)}...${refreshToken.slice(-4)}` : "None";
|
|
48987
|
+
const expiryStr = expiresAt ? new Date(expiresAt).toLocaleString() : "No expiry";
|
|
48988
|
+
const info2 = [
|
|
48989
|
+
`Endpoint: ${endpoint}`,
|
|
48990
|
+
`Username: ${authStatus2.username}`,
|
|
48991
|
+
`Token: ${token || "Unknown"}`,
|
|
48992
|
+
`Token source: ${tokenSource || "Unknown"}`,
|
|
48993
|
+
`Refresh token: ${maskedToken}`,
|
|
48994
|
+
`Expires: ${expiryStr}`,
|
|
48995
|
+
`Auth method: ${refreshToken ? "Device/OAuth" : "Manual token"}`
|
|
48996
|
+
].join("\n");
|
|
48997
|
+
void window$1.showInformationMessage(info2, { modal: true });
|
|
48998
|
+
}),
|
|
48999
|
+
// Toggle device auth support (for testing fallback)
|
|
49000
|
+
commands$1.registerCommand("cody.debug.auth.toggleDeviceAuth", async () => {
|
|
49001
|
+
const currentState = getDebugDisableDeviceAuth();
|
|
49002
|
+
const newState = !currentState;
|
|
49003
|
+
setDebugDisableDeviceAuth(newState);
|
|
49004
|
+
const status = newState ? "DISABLED" : "ENABLED";
|
|
49005
|
+
const emoji = newState ? "🔴" : "🟢";
|
|
49006
|
+
const fallbackMsg = newState ? " (will fallback to old auth flow)" : "";
|
|
49007
|
+
void window$1.showInformationMessage(`${emoji} Device Auth: ${status}${fallbackMsg}`);
|
|
49008
|
+
})
|
|
49009
|
+
);
|
|
49010
|
+
}
|
|
48080
49011
|
const RRF_K = 60;
|
|
48081
49012
|
function fuseResults(retrievedSets, rankingIdentities) {
|
|
48082
49013
|
const resultsByDocument = /* @__PURE__ */ new Map();
|
|
@@ -48405,7 +49336,7 @@ class CachedRetriever {
|
|
|
48405
49336
|
*/
|
|
48406
49337
|
__publicField2(this, "addDependency", (dep) => {
|
|
48407
49338
|
if (!this.currentKey) {
|
|
48408
|
-
logError$
|
|
49339
|
+
logError$1(this.constructor.name, "Cannot add dependency outside of retrieval function");
|
|
48409
49340
|
return;
|
|
48410
49341
|
}
|
|
48411
49342
|
const keys2 = this.dependencies.get(dep);
|
|
@@ -150452,7 +151383,7 @@ const _ContextRetrieverDataCollection = class _ContextRetrieverDataCollection {
|
|
|
150452
151383
|
case RetrieverIdentifier.JaccardSimilarityRetriever:
|
|
150453
151384
|
return new JaccardSimilarityRetriever();
|
|
150454
151385
|
default:
|
|
150455
|
-
logDebug(
|
|
151386
|
+
outputChannelLogger.logDebug(
|
|
150456
151387
|
"ContextRetrieverDataCollection",
|
|
150457
151388
|
"createRetriever",
|
|
150458
151389
|
`Unhandled RetrieverIdentifier: ${config.identifier}`
|
|
@@ -171259,7 +172190,7 @@ async function getContextFileFromTabs() {
|
|
|
171259
172190
|
})
|
|
171260
172191
|
)).filter(isDefined);
|
|
171261
172192
|
} catch (error) {
|
|
171262
|
-
logError$
|
|
172193
|
+
logError$1("getContextFileFromTabs", "failed", { verbose: error });
|
|
171263
172194
|
return [];
|
|
171264
172195
|
}
|
|
171265
172196
|
});
|
|
@@ -172593,7 +173524,11 @@ const getCommandContextFiles = async (config) => {
|
|
|
172593
173524
|
}
|
|
172594
173525
|
return contextFiles;
|
|
172595
173526
|
} catch (error) {
|
|
172596
|
-
logDebug(
|
|
173527
|
+
outputChannelLogger.logDebug(
|
|
173528
|
+
"getCommandContextFiles",
|
|
173529
|
+
"Error getting command context files",
|
|
173530
|
+
error
|
|
173531
|
+
);
|
|
172597
173532
|
return [];
|
|
172598
173533
|
}
|
|
172599
173534
|
};
|
|
@@ -172603,7 +173538,7 @@ class CommandRunner {
|
|
|
172603
173538
|
this.span = span2;
|
|
172604
173539
|
this.command = command;
|
|
172605
173540
|
this.args = args2;
|
|
172606
|
-
logDebug("CommandRunner", command.key, { verbose: { command, args: args2 } });
|
|
173541
|
+
outputChannelLogger.logDebug("CommandRunner", command.key, { verbose: { command, args: args2 } });
|
|
172607
173542
|
command.mode = args2.runInChatMode ? "ask" : command.mode ?? "ask";
|
|
172608
173543
|
this.command = command;
|
|
172609
173544
|
}
|
|
@@ -172658,7 +173593,7 @@ class CommandRunner {
|
|
|
172658
173593
|
*/
|
|
172659
173594
|
async handleChatRequest() {
|
|
172660
173595
|
this.span.setAttribute("mode", "chat");
|
|
172661
|
-
logDebug("CommandRunner:handleChatRequest", "chat request
|
|
173596
|
+
outputChannelLogger.logDebug("CommandRunner:handleChatRequest", "chat request detected");
|
|
172662
173597
|
const prompt = PromptString.unsafe_fromUserQuery(this.command.prompt);
|
|
172663
173598
|
const contextItems = await this.getContextFiles();
|
|
172664
173599
|
return {
|
|
@@ -172677,7 +173612,7 @@ class CommandRunner {
|
|
|
172677
173612
|
*/
|
|
172678
173613
|
async handleEditRequest() {
|
|
172679
173614
|
this.span.setAttribute("mode", "edit");
|
|
172680
|
-
logDebug("CommandRunner:handleEditRequest", "fixup request detected");
|
|
173615
|
+
outputChannelLogger.logDebug("CommandRunner:handleEditRequest", "fixup request detected");
|
|
172681
173616
|
const userContextFiles = await this.getContextFiles();
|
|
172682
173617
|
return {
|
|
172683
173618
|
type: "edit",
|
|
@@ -172750,7 +173685,10 @@ class CommandsController {
|
|
|
172750
173685
|
}
|
|
172751
173686
|
const command = (_b2 = this.provider) == null ? void 0 : _b2.get(commandKey);
|
|
172752
173687
|
if (!command || command.mode !== "ask" && !this.isEditEnabled) {
|
|
172753
|
-
logDebug(
|
|
173688
|
+
outputChannelLogger.logDebug(
|
|
173689
|
+
"CommandsController:execute",
|
|
173690
|
+
`${commandKey} command not found/supported`
|
|
173691
|
+
);
|
|
172754
173692
|
return void 0;
|
|
172755
173693
|
}
|
|
172756
173694
|
span2.setAttribute("sampled", true);
|
|
@@ -172766,7 +173704,7 @@ class CommandsController {
|
|
|
172766
173704
|
disposable.dispose();
|
|
172767
173705
|
}
|
|
172768
173706
|
this.disposables = [];
|
|
172769
|
-
logDebug("CommandsController:dispose", "disposed");
|
|
173707
|
+
outputChannelLogger.logDebug("CommandsController:dispose", "disposed");
|
|
172770
173708
|
}
|
|
172771
173709
|
}
|
|
172772
173710
|
const controller = new CommandsController();
|
|
@@ -172943,14 +173881,14 @@ async function getLocalCommands(input) {
|
|
|
172943
173881
|
const TraceSender = {
|
|
172944
173882
|
send(spanData) {
|
|
172945
173883
|
void doSendTraceData(spanData).catch((error) => {
|
|
172946
|
-
logError
|
|
173884
|
+
outputChannelLogger.logError("TraceSender", `Error sending trace data: ${error}`);
|
|
172947
173885
|
});
|
|
172948
173886
|
}
|
|
172949
173887
|
};
|
|
172950
173888
|
async function doSendTraceData(spanData) {
|
|
172951
173889
|
const { auth: auth2 } = await currentResolvedConfig();
|
|
172952
173890
|
if (!auth2.credentials) {
|
|
172953
|
-
logError
|
|
173891
|
+
outputChannelLogger.logError("TraceSender", "Cannot send trace data: not authenticated");
|
|
172954
173892
|
throw new Error("Not authenticated");
|
|
172955
173893
|
}
|
|
172956
173894
|
const traceUrl = new URL("/-/debug/otlp/v1/traces", auth2.serverEndpoint);
|
|
@@ -172962,10 +173900,10 @@ async function doSendTraceData(spanData) {
|
|
|
172962
173900
|
body: spanData
|
|
172963
173901
|
});
|
|
172964
173902
|
if (!response.ok) {
|
|
172965
|
-
logError
|
|
173903
|
+
outputChannelLogger.logError("TraceSender", `Failed to send trace data: ${response.statusText}`);
|
|
172966
173904
|
throw new Error(`Failed to send trace data: ${response.statusText}`);
|
|
172967
173905
|
}
|
|
172968
|
-
logDebug("TraceSender", "Trace data sent successfully");
|
|
173906
|
+
outputChannelLogger.logDebug("TraceSender", "Trace data sent successfully");
|
|
172969
173907
|
}
|
|
172970
173908
|
async function openExternalLinks(uri) {
|
|
172971
173909
|
try {
|
|
@@ -173170,7 +174108,10 @@ async function searchSymf(symf, editor, workspaceRoot, userText, blockOnIndex =
|
|
|
173170
174108
|
text2 = await editor.getTextEditorContentForFile(result.file, range);
|
|
173171
174109
|
text2 = truncateSymfResult(text2);
|
|
173172
174110
|
} catch (error) {
|
|
173173
|
-
logError
|
|
174111
|
+
outputChannelLogger.logError(
|
|
174112
|
+
"ChatController.searchSymf",
|
|
174113
|
+
`Error getting file contents: ${error}`
|
|
174114
|
+
);
|
|
173174
174115
|
return [];
|
|
173175
174116
|
}
|
|
173176
174117
|
const metadata2 = [
|
|
@@ -173197,17 +174138,17 @@ async function searchSymf(symf, editor, workspaceRoot, userText, blockOnIndex =
|
|
|
173197
174138
|
}
|
|
173198
174139
|
async function retrieveContextGracefully(promise2, strategy) {
|
|
173199
174140
|
try {
|
|
173200
|
-
logDebug("ChatController", `resolveContext > ${strategy} (start)`);
|
|
174141
|
+
outputChannelLogger.logDebug("ChatController", `resolveContext > ${strategy} (start)`);
|
|
173201
174142
|
return await promise2;
|
|
173202
174143
|
} catch (error) {
|
|
173203
174144
|
if (isAbortError(error)) {
|
|
173204
|
-
logError
|
|
174145
|
+
outputChannelLogger.logError("ChatController", `resolveContext > ${strategy}' (aborted)`);
|
|
173205
174146
|
throw error;
|
|
173206
174147
|
}
|
|
173207
|
-
logError
|
|
174148
|
+
outputChannelLogger.logError("ChatController", `resolveContext > ${strategy} (error)`, error);
|
|
173208
174149
|
return [];
|
|
173209
174150
|
} finally {
|
|
173210
|
-
logDebug("ChatController", `resolveContext > ${strategy} (end)`);
|
|
174151
|
+
outputChannelLogger.logDebug("ChatController", `resolveContext > ${strategy} (end)`);
|
|
173211
174152
|
}
|
|
173212
174153
|
}
|
|
173213
174154
|
const maxSymfBytes = 2048;
|
|
@@ -173280,7 +174221,11 @@ async function codebaseRootsFromMentions({ repos, trees }, signal2) {
|
|
|
173280
174221
|
const localRepoNames = treesToRepoNames.flatMap((t) => t.names);
|
|
173281
174222
|
let localRepoIDs = localRepoNames.length === 0 ? [] : await graphqlClient.getRepoIds(localRepoNames, localRepoNames.length, signal2);
|
|
173282
174223
|
if (isError$1(localRepoIDs)) {
|
|
173283
|
-
logError
|
|
174224
|
+
outputChannelLogger.logError(
|
|
174225
|
+
"codebaseRootFromMentions",
|
|
174226
|
+
"Failed to get repo IDs from Sourcegraph",
|
|
174227
|
+
localRepoIDs
|
|
174228
|
+
);
|
|
173284
174229
|
localRepoIDs = [];
|
|
173285
174230
|
}
|
|
173286
174231
|
const uriToId = {};
|
|
@@ -173348,7 +174293,7 @@ class ContextRetriever {
|
|
|
173348
174293
|
);
|
|
173349
174294
|
changedFiles = changedFilesByRoot.flat();
|
|
173350
174295
|
} catch (error) {
|
|
173351
|
-
logDebug(
|
|
174296
|
+
outputChannelLogger.logDebug(
|
|
173352
174297
|
"ContextRetriever",
|
|
173353
174298
|
"Failed to get locally modified files, falling back to indexed context only",
|
|
173354
174299
|
error
|
|
@@ -173371,7 +174316,7 @@ class ContextRetriever {
|
|
|
173371
174316
|
return [];
|
|
173372
174317
|
}
|
|
173373
174318
|
if (!this.symf) {
|
|
173374
|
-
logDebug("ContextRetriever", "symf not available, skipping live context");
|
|
174319
|
+
outputChannelLogger.logDebug("ContextRetriever", "symf not available, skipping live context");
|
|
173375
174320
|
return [];
|
|
173376
174321
|
}
|
|
173377
174322
|
const results = await this.symf.getLiveResults(originalQuery, rewrittenQuery, files, signal2);
|
|
@@ -173389,7 +174334,10 @@ class ContextRetriever {
|
|
|
173389
174334
|
text2 = await this.editor.getTextEditorContentForFile(r2.file, range);
|
|
173390
174335
|
text2 = truncateSymfResult(text2);
|
|
173391
174336
|
} catch (error) {
|
|
173392
|
-
logError
|
|
174337
|
+
outputChannelLogger.logError(
|
|
174338
|
+
"ChatController.searchSymf",
|
|
174339
|
+
`Error getting file contents: ${error}`
|
|
174340
|
+
);
|
|
173393
174341
|
return [];
|
|
173394
174342
|
}
|
|
173395
174343
|
return {
|
|
@@ -173494,7 +174442,7 @@ class ContextRetriever {
|
|
|
173494
174442
|
}
|
|
173495
174443
|
function contextSearchResultToContextItem(result) {
|
|
173496
174444
|
if (result.startLine < 0 || result.endLine < 0) {
|
|
173497
|
-
logDebug(
|
|
174445
|
+
outputChannelLogger.logDebug(
|
|
173498
174446
|
"ContextRetriever",
|
|
173499
174447
|
"ignoring server context result with invalid range",
|
|
173500
174448
|
result.repoName,
|
|
@@ -173962,7 +174910,7 @@ class DefaultPrompter {
|
|
|
173962
174910
|
reverseTranscript[0] = PromptMixin.mixInto(reverseTranscript[0], chat2.selectedModel, mixins);
|
|
173963
174911
|
const messagesIgnored = promptBuilder.tryAddMessages(reverseTranscript);
|
|
173964
174912
|
if (messagesIgnored) {
|
|
173965
|
-
logDebug(
|
|
174913
|
+
outputChannelLogger.logDebug(
|
|
173966
174914
|
"DefaultPrompter.makePrompt",
|
|
173967
174915
|
`Ignored ${messagesIgnored} chat messages due to context limit`
|
|
173968
174916
|
);
|
|
@@ -173985,7 +174933,7 @@ class DefaultPrompter {
|
|
|
173985
174933
|
const historyContext = await promptBuilder.tryAddContext("history", historyItems.reverse());
|
|
173986
174934
|
ignoredContext.transcript += historyContext.ignored.length;
|
|
173987
174935
|
if (ignoredContext.user + ignoredContext.corpus + ignoredContext.transcript > 0) {
|
|
173988
|
-
logDebug(
|
|
174936
|
+
outputChannelLogger.logDebug(
|
|
173989
174937
|
"DefaultPrompter.makePrompt",
|
|
173990
174938
|
`Ignored context due to context limit: user=${ignoredContext.user}, corpus=${ignoredContext.corpus}, previous=${ignoredContext.transcript}`
|
|
173991
174939
|
);
|
|
@@ -174345,7 +175293,7 @@ function getDeepCodyModel(models) {
|
|
|
174345
175293
|
return matches2.find((m) => m !== void 0) || models.find((m) => m.tags.includes(ModelTag.Speed));
|
|
174346
175294
|
}
|
|
174347
175295
|
var define_process_default$4 = { env: {} };
|
|
174348
|
-
const execAsync =
|
|
175296
|
+
const execAsync = util$5.promisify(exec);
|
|
174349
175297
|
const HOME_DIR = define_process_default$4.env.HOME || define_process_default$4.env.USERPROFILE || "";
|
|
174350
175298
|
const OUTPUT_WRAPPER = `
|
|
174351
175299
|
Terminal output from the \`{command}\` command enclosed between <OUTPUT0412> tags:
|
|
@@ -174390,7 +175338,7 @@ async function getContextFileFromShell(command) {
|
|
|
174390
175338
|
}
|
|
174391
175339
|
];
|
|
174392
175340
|
} catch (error) {
|
|
174393
|
-
logError
|
|
175341
|
+
outputChannelLogger.logError("getContextFileFromShell", "failed", { verbose: error });
|
|
174394
175342
|
const errorContent = `Failed to run ${command} in terminal:
|
|
174395
175343
|
${error}`;
|
|
174396
175344
|
const size = await TokenCounterUtils.countTokens(errorContent);
|
|
@@ -180764,14 +181712,14 @@ ${error}` : error;
|
|
|
180764
181712
|
this.connections.push(connection);
|
|
180765
181713
|
this.statusChangeEmitter.fire({ serverName: name2, status: "connecting" });
|
|
180766
181714
|
transport.onclose = () => {
|
|
180767
|
-
logDebug
|
|
181715
|
+
logDebug("MCPConnectionManager", `Transport closed for "${name2}"`);
|
|
180768
181716
|
const conn2 = this.getConnection(name2);
|
|
180769
181717
|
if (conn2 && conn2.server.status !== "disconnected") {
|
|
180770
181718
|
this.updateConnectionStatus(conn2, "disconnected", "Transport closed");
|
|
180771
181719
|
}
|
|
180772
181720
|
};
|
|
180773
181721
|
transport.onerror = (error) => {
|
|
180774
|
-
logDebug
|
|
181722
|
+
logDebug("MCPConnectionManager", `Transport error for "${name2}"`, {
|
|
180775
181723
|
verbose: { error }
|
|
180776
181724
|
});
|
|
180777
181725
|
const conn2 = this.getConnection(name2);
|
|
@@ -180781,11 +181729,11 @@ ${error}` : error;
|
|
|
180781
181729
|
};
|
|
180782
181730
|
await transport.start();
|
|
180783
181731
|
if (config.transportType === "stdio" && transport instanceof StdioClientTransport) {
|
|
180784
|
-
logDebug
|
|
181732
|
+
logDebug("MCPConnectionManager", `Connecting to stdio server "${name2}"...`, {
|
|
180785
181733
|
verbose: { config }
|
|
180786
181734
|
});
|
|
180787
181735
|
} else if (config.transportType === "sse") {
|
|
180788
|
-
logDebug
|
|
181736
|
+
logDebug("MCPConnectionManager", `Connecting to SSE server "${name2}"...`, {
|
|
180789
181737
|
verbose: { config }
|
|
180790
181738
|
});
|
|
180791
181739
|
}
|
|
@@ -180794,13 +181742,13 @@ ${error}` : error;
|
|
|
180794
181742
|
await client.connect(transport);
|
|
180795
181743
|
connection.server.status = "connected";
|
|
180796
181744
|
connection.server.error = "";
|
|
180797
|
-
logDebug
|
|
181745
|
+
logDebug("MCPConnectionManager", `Connected to MCP server: ${name2}`);
|
|
180798
181746
|
this.statusChangeEmitter.fire({ serverName: name2, status: "connected" });
|
|
180799
181747
|
this.notifyServerChanged(name2);
|
|
180800
181748
|
return connection;
|
|
180801
181749
|
} catch (error) {
|
|
180802
181750
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
180803
|
-
logDebug
|
|
181751
|
+
logDebug("MCPConnectionManager", `Failed to connect to MCP server ${name2}`, {
|
|
180804
181752
|
verbose: { error }
|
|
180805
181753
|
});
|
|
180806
181754
|
const conn2 = this.getConnection(name2) ?? connection;
|
|
@@ -180809,14 +181757,14 @@ ${error}` : error;
|
|
|
180809
181757
|
}
|
|
180810
181758
|
await Promise.allSettled([
|
|
180811
181759
|
transport == null ? void 0 : transport.close().catch(
|
|
180812
|
-
(closeError) => logDebug
|
|
181760
|
+
(closeError) => logDebug(
|
|
180813
181761
|
"MCPConnectionManager",
|
|
180814
181762
|
`Error closing transport for ${name2} after connection failure`,
|
|
180815
181763
|
{ verbose: { closeError } }
|
|
180816
181764
|
)
|
|
180817
181765
|
),
|
|
180818
181766
|
client == null ? void 0 : client.close().catch(
|
|
180819
|
-
(closeError) => logDebug
|
|
181767
|
+
(closeError) => logDebug(
|
|
180820
181768
|
"MCPConnectionManager",
|
|
180821
181769
|
`Error closing client for ${name2} after connection failure`,
|
|
180822
181770
|
{ verbose: { closeError } }
|
|
@@ -180833,9 +181781,9 @@ ${error}` : error;
|
|
|
180833
181781
|
this.connections.splice(index2, 1);
|
|
180834
181782
|
try {
|
|
180835
181783
|
await Promise.all([connection.transport.close(), connection.client.close()]);
|
|
180836
|
-
logDebug
|
|
181784
|
+
logDebug("MCPConnectionManager", `Closed connection for ${name2}`);
|
|
180837
181785
|
} catch (error) {
|
|
180838
|
-
logDebug
|
|
181786
|
+
logDebug("MCPConnectionManager", `Failed to cleanly close connection for ${name2}:`, {
|
|
180839
181787
|
verbose: { error }
|
|
180840
181788
|
});
|
|
180841
181789
|
}
|
|
@@ -180896,7 +181844,7 @@ class MCPServerManager {
|
|
|
180896
181844
|
// Add disabled status
|
|
180897
181845
|
};
|
|
180898
181846
|
})) || [];
|
|
180899
|
-
logDebug
|
|
181847
|
+
logDebug("MCPServerManager", `Fetched ${tools.length} tools for ${serverName}`, {
|
|
180900
181848
|
verbose: { tools }
|
|
180901
181849
|
});
|
|
180902
181850
|
try {
|
|
@@ -180908,7 +181856,7 @@ class MCPServerManager {
|
|
|
180908
181856
|
CodyToolProvider.updateToolDisabledState(codyToolName, true);
|
|
180909
181857
|
}
|
|
180910
181858
|
} catch (error) {
|
|
180911
|
-
logDebug
|
|
181859
|
+
logDebug(
|
|
180912
181860
|
"MCPServerManager",
|
|
180913
181861
|
`Failed to register tools with CodyToolProvider: ${error}`,
|
|
180914
181862
|
{
|
|
@@ -180919,12 +181867,12 @@ class MCPServerManager {
|
|
|
180919
181867
|
await this.registerAgentTools(serverName, tools);
|
|
180920
181868
|
return tools;
|
|
180921
181869
|
} catch (error) {
|
|
180922
|
-
logDebug
|
|
181870
|
+
logDebug("MCPServerManager", `Failed to fetch tools for ${serverName}:`, {
|
|
180923
181871
|
verbose: { error }
|
|
180924
181872
|
});
|
|
180925
181873
|
return [];
|
|
180926
181874
|
} finally {
|
|
180927
|
-
logDebug
|
|
181875
|
+
logDebug("MCPServerManager", `Tool list retrieval process completed for ${serverName}`);
|
|
180928
181876
|
this.connectionManager.notifyToolChanged(serverName);
|
|
180929
181877
|
}
|
|
180930
181878
|
}
|
|
@@ -180948,17 +181896,17 @@ class MCPServerManager {
|
|
|
180948
181896
|
mimeType: r2.mimeType,
|
|
180949
181897
|
title: `${r2.title}`
|
|
180950
181898
|
}));
|
|
180951
|
-
logDebug
|
|
181899
|
+
logDebug("MCPServerManager", `Fetched ${resources.length} resources for ${serverName}`, {
|
|
180952
181900
|
verbose: { resources }
|
|
180953
181901
|
});
|
|
180954
181902
|
return resources;
|
|
180955
181903
|
} catch (error) {
|
|
180956
|
-
logDebug
|
|
181904
|
+
logDebug("MCPServerManager", `Failed to fetch resources for ${serverName}:`, {
|
|
180957
181905
|
verbose: { error }
|
|
180958
181906
|
});
|
|
180959
181907
|
return [];
|
|
180960
181908
|
} finally {
|
|
180961
|
-
logDebug
|
|
181909
|
+
logDebug("MCPServerManager", `Resource list retrieval process completed for ${serverName}`);
|
|
180962
181910
|
}
|
|
180963
181911
|
}
|
|
180964
181912
|
/**
|
|
@@ -180984,7 +181932,7 @@ class MCPServerManager {
|
|
|
180984
181932
|
uri: t.uriTemplate
|
|
180985
181933
|
}));
|
|
180986
181934
|
} catch (error) {
|
|
180987
|
-
logDebug
|
|
181935
|
+
logDebug("MCPServerManager", `Failed to fetch resource templates for ${serverName}:`, {
|
|
180988
181936
|
verbose: { error }
|
|
180989
181937
|
});
|
|
180990
181938
|
return [];
|
|
@@ -181008,7 +181956,7 @@ class MCPServerManager {
|
|
|
181008
181956
|
try {
|
|
181009
181957
|
return this.executeTool(serverName, tool.name, args2);
|
|
181010
181958
|
} catch (error) {
|
|
181011
|
-
logDebug
|
|
181959
|
+
logDebug("MCPServerManager", `Error executing tool ${tool.name}:`, {
|
|
181012
181960
|
verbose: { error }
|
|
181013
181961
|
});
|
|
181014
181962
|
return createMCPToolState(
|
|
@@ -181034,7 +181982,7 @@ class MCPServerManager {
|
|
|
181034
181982
|
});
|
|
181035
181983
|
}
|
|
181036
181984
|
} catch (error) {
|
|
181037
|
-
logDebug
|
|
181985
|
+
logDebug("MCPServerManager", `Error creating agent tool for ${tool.name || ""}`, {
|
|
181038
181986
|
verbose: { error }
|
|
181039
181987
|
});
|
|
181040
181988
|
}
|
|
@@ -181043,7 +181991,7 @@ class MCPServerManager {
|
|
|
181043
181991
|
[...this.tools.filter((t) => !t.spec.name.startsWith(`${serverName}_`)), ..._agentTools],
|
|
181044
181992
|
serverName
|
|
181045
181993
|
);
|
|
181046
|
-
logDebug
|
|
181994
|
+
logDebug("MCPServerManager", `Created ${_agentTools.length} agent tools from ${serverName}`, {
|
|
181047
181995
|
verbose: { _agentTools }
|
|
181048
181996
|
});
|
|
181049
181997
|
this.connectionManager.notifyToolChanged(serverName);
|
|
@@ -181097,12 +182045,12 @@ class MCPServerManager {
|
|
|
181097
182045
|
throw new Error("unexpected response");
|
|
181098
182046
|
}
|
|
181099
182047
|
const { context: context2, contents } = transforMCPToolResult(result.content, toolName);
|
|
181100
|
-
logDebug
|
|
182048
|
+
logDebug("MCPServerManager", `Tool ${toolName} executed successfully`, {
|
|
181101
182049
|
verbose: { context: context2, contents }
|
|
181102
182050
|
});
|
|
181103
182051
|
return createMCPToolState(serverName, toolName, contents, context2);
|
|
181104
182052
|
} catch (error) {
|
|
181105
|
-
logDebug
|
|
182053
|
+
logDebug("MCPServerManager", `Error calling tool ${toolName} on server ${serverName}`, {
|
|
181106
182054
|
verbose: error
|
|
181107
182055
|
});
|
|
181108
182056
|
return createMCPToolState(
|
|
@@ -181140,7 +182088,7 @@ class MCPServerManager {
|
|
|
181140
182088
|
);
|
|
181141
182089
|
return result.content;
|
|
181142
182090
|
} catch (error) {
|
|
181143
|
-
logDebug
|
|
182091
|
+
logDebug("MCPServerManager", `Error reading resource ${uri} from server ${serverName}`, {
|
|
181144
182092
|
verbose: { error }
|
|
181145
182093
|
});
|
|
181146
182094
|
throw error;
|
|
@@ -181178,7 +182126,7 @@ class MCPServerManager {
|
|
|
181178
182126
|
const codyToolName = ToolFactory.getCodyToolName(toolName, serverName);
|
|
181179
182127
|
CodyToolProvider.updateToolDisabledState(codyToolName, disabled);
|
|
181180
182128
|
} catch (error) {
|
|
181181
|
-
logDebug
|
|
182129
|
+
logDebug("MCPServerManager", `Failed to update tool state in CodyToolProvider: ${error}`, {
|
|
181182
182130
|
verbose: { error }
|
|
181183
182131
|
});
|
|
181184
182132
|
}
|
|
@@ -181229,7 +182177,7 @@ class MCPServerManager {
|
|
|
181229
182177
|
}
|
|
181230
182178
|
}
|
|
181231
182179
|
} catch (error) {
|
|
181232
|
-
logDebug
|
|
182180
|
+
logDebug("MCPServerManager", "Failed to update tool states in CodyToolProvider", {
|
|
181233
182181
|
verbose: { error }
|
|
181234
182182
|
});
|
|
181235
182183
|
}
|
|
@@ -181241,7 +182189,7 @@ class MCPServerManager {
|
|
|
181241
182189
|
this.toolsChangeNotifications.next({
|
|
181242
182190
|
serverName: affectedServers.size === 1 ? Array.from(affectedServers)[0] : ""
|
|
181243
182191
|
});
|
|
181244
|
-
logDebug
|
|
182192
|
+
logDebug("MCPServerManager", `Loaded ${tools.length} disabled tools`, {
|
|
181245
182193
|
verbose: { disabled: tools }
|
|
181246
182194
|
});
|
|
181247
182195
|
}
|
|
@@ -181353,15 +182301,15 @@ const _MCPManager = class _MCPManager {
|
|
|
181353
182301
|
this.observeConfigChanges();
|
|
181354
182302
|
this.setupToolStateListeners();
|
|
181355
182303
|
} catch (error) {
|
|
181356
|
-
logDebug
|
|
182304
|
+
logDebug("MCPManager", "Failed to initialize MCP manager", { verbose: { error } });
|
|
181357
182305
|
_MCPManager.instance = void 0;
|
|
181358
182306
|
}
|
|
181359
182307
|
}
|
|
181360
182308
|
async handleConnectionStatusChange(event2) {
|
|
181361
|
-
logDebug
|
|
182309
|
+
logDebug("MCPManager", `Connection status changed for ${event2.serverName}: ${event2.status}`);
|
|
181362
182310
|
if (event2.status === "connected") {
|
|
181363
182311
|
await this.initializeServerData(event2.serverName).catch((error) => {
|
|
181364
|
-
logDebug
|
|
182312
|
+
logDebug("MCPManager", `Error initializing server data for ${event2.serverName}`, {
|
|
181365
182313
|
verbose: { error }
|
|
181366
182314
|
});
|
|
181367
182315
|
});
|
|
@@ -181371,7 +182319,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181371
182319
|
this.serverManager.onToolStateChanged(async (event2) => {
|
|
181372
182320
|
await this.updateToolStateInConfig(event2.serverName, event2.toolName, event2.disabled).catch(
|
|
181373
182321
|
(e) => {
|
|
181374
|
-
logDebug
|
|
182322
|
+
logDebug("MCPManager", `Failed to update ${event2.serverName} config`, { verbose: e });
|
|
181375
182323
|
}
|
|
181376
182324
|
);
|
|
181377
182325
|
});
|
|
@@ -181380,12 +182328,12 @@ const _MCPManager = class _MCPManager {
|
|
|
181380
182328
|
const configWatcher = workspace.onDidChangeConfiguration(async (event2) => {
|
|
181381
182329
|
if (event2.affectsConfiguration(`${_MCPManager.CONFIG_SECTION}.${_MCPManager.MCP_SERVERS_KEY}`)) {
|
|
181382
182330
|
if (this.programmaticConfigChangeInProgress) {
|
|
181383
|
-
logDebug
|
|
182331
|
+
logDebug("MCPManager", "Ignoring programmatic configuration change");
|
|
181384
182332
|
return;
|
|
181385
182333
|
}
|
|
181386
|
-
logDebug
|
|
182334
|
+
logDebug("MCPManager", "Configuration change detected");
|
|
181387
182335
|
await this.loadServersFromConfig().catch((e) => {
|
|
181388
|
-
logDebug
|
|
182336
|
+
logDebug("MCPManager", "Error reloading servers from config", { verbose: e });
|
|
181389
182337
|
});
|
|
181390
182338
|
}
|
|
181391
182339
|
});
|
|
@@ -181402,7 +182350,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181402
182350
|
const result = McpSettingsSchema.safeParse({ mcpServers });
|
|
181403
182351
|
if (result.success) {
|
|
181404
182352
|
await this.sync(mcpServers);
|
|
181405
|
-
logDebug
|
|
182353
|
+
logDebug("MCPManager", "MCP servers initialized successfully from configuration");
|
|
181406
182354
|
} else {
|
|
181407
182355
|
throw new Error("Invalid MCP server configuration: " + result.error.format());
|
|
181408
182356
|
}
|
|
@@ -181411,14 +182359,14 @@ const _MCPManager = class _MCPManager {
|
|
|
181411
182359
|
* Sync servers with configuration
|
|
181412
182360
|
*/
|
|
181413
182361
|
async sync(mcpServers) {
|
|
181414
|
-
logDebug
|
|
182362
|
+
logDebug("MCPManager", "Syncing MCP servers", { verbose: { mcpServers } });
|
|
181415
182363
|
const currentConnections = this.connectionManager.getAllConnections();
|
|
181416
182364
|
const currentNames = new Set(currentConnections.map((conn2) => conn2.server.name));
|
|
181417
182365
|
const newNames = new Set(Object.keys(mcpServers));
|
|
181418
182366
|
for (const name2 of currentNames) {
|
|
181419
182367
|
if (!newNames.has(name2)) {
|
|
181420
182368
|
await this.connectionManager.removeConnection(name2);
|
|
181421
|
-
logDebug
|
|
182369
|
+
logDebug("MCPManager", `Deleted MCP server: ${name2}`);
|
|
181422
182370
|
}
|
|
181423
182371
|
}
|
|
181424
182372
|
const allDisabledTools = [];
|
|
@@ -181440,7 +182388,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181440
182388
|
allDisabledTools.push(...toolsWithPrefix);
|
|
181441
182389
|
}
|
|
181442
182390
|
} catch (error) {
|
|
181443
|
-
logDebug
|
|
182391
|
+
logDebug("MCPManager", `Failed to reconnect MCP server ${name2}`, {
|
|
181444
182392
|
verbose: { error }
|
|
181445
182393
|
});
|
|
181446
182394
|
}
|
|
@@ -181460,7 +182408,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181460
182408
|
const parsedConfig = result.data;
|
|
181461
182409
|
await this.connectionManager.addConnection(name2, parsedConfig, parsedConfig == null ? void 0 : parsedConfig.disabled);
|
|
181462
182410
|
} catch (error) {
|
|
181463
|
-
logDebug
|
|
182411
|
+
logDebug("MCPManager", `Error adding connection for ${name2}`, { verbose: { error } });
|
|
181464
182412
|
}
|
|
181465
182413
|
}
|
|
181466
182414
|
/**
|
|
@@ -181470,14 +182418,14 @@ const _MCPManager = class _MCPManager {
|
|
|
181470
182418
|
const connection = this.connectionManager.getConnection(serverName);
|
|
181471
182419
|
if (!connection) return;
|
|
181472
182420
|
try {
|
|
181473
|
-
logDebug
|
|
182421
|
+
logDebug("MCPManager", `Initializing tools for server: ${serverName}`);
|
|
181474
182422
|
connection.server.tools = await this.serverManager.getToolList(serverName) || [];
|
|
181475
|
-
logDebug
|
|
182423
|
+
logDebug("MCPManager", `Initialized tools for server: ${serverName}`, {
|
|
181476
182424
|
verbose: { toolCount: connection.server.tools.length }
|
|
181477
182425
|
});
|
|
181478
182426
|
this.connectionManager.notifyServerChanged(serverName);
|
|
181479
182427
|
} catch (error) {
|
|
181480
|
-
logDebug
|
|
182428
|
+
logDebug("MCPManager", `Failed to initialize ${serverName}`, { verbose: error });
|
|
181481
182429
|
}
|
|
181482
182430
|
}
|
|
181483
182431
|
static get tools() {
|
|
@@ -181559,7 +182507,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181559
182507
|
}
|
|
181560
182508
|
});
|
|
181561
182509
|
} catch (error) {
|
|
181562
|
-
logDebug
|
|
182510
|
+
logDebug("MCPManager", `Failed to update tool state in config: ${error}`, {
|
|
181563
182511
|
verbose: { error }
|
|
181564
182512
|
});
|
|
181565
182513
|
throw error;
|
|
@@ -181582,7 +182530,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181582
182530
|
mcpServers[(config == null ? void 0 : config.name) ?? name2] = config;
|
|
181583
182531
|
} else if (operation === "update") {
|
|
181584
182532
|
if (!mcpServers[name2] || !mcpServers[config == null ? void 0 : config.name]) {
|
|
181585
|
-
logDebug
|
|
182533
|
+
logDebug("", `MCP server "${name2}" does not exist`);
|
|
181586
182534
|
}
|
|
181587
182535
|
const mergedConfig = {
|
|
181588
182536
|
...mcpServers[name2],
|
|
@@ -181601,29 +182549,29 @@ const _MCPManager = class _MCPManager {
|
|
|
181601
182549
|
if (mcpServers[name2]) {
|
|
181602
182550
|
delete mcpServers[name2];
|
|
181603
182551
|
} else {
|
|
181604
|
-
logDebug
|
|
182552
|
+
logDebug("MCPManager", `${name2} not found in MCP configuration`);
|
|
181605
182553
|
}
|
|
181606
182554
|
}
|
|
181607
182555
|
await this.updateMcpServerConfig(mcpServers);
|
|
181608
182556
|
if (operation === "delete") {
|
|
181609
182557
|
await this.connectionManager.removeConnection(name2);
|
|
181610
|
-
logDebug
|
|
182558
|
+
logDebug("MCPManager", `Deleted MCP server: ${name2}`);
|
|
181611
182559
|
} else if (operation === "update") {
|
|
181612
182560
|
await this.connectionManager.removeConnection(name2);
|
|
181613
182561
|
await this.addConnection(name2, mcpServers[name2]);
|
|
181614
|
-
logDebug
|
|
182562
|
+
logDebug("MCPManager", `Updated ${name2}`, {
|
|
181615
182563
|
verbose: { config: mcpServers[name2] }
|
|
181616
182564
|
});
|
|
181617
182565
|
} else if (operation === "add") {
|
|
181618
182566
|
await this.addConnection(name2, config);
|
|
181619
|
-
logDebug
|
|
182567
|
+
logDebug("MCPManager", `Added MCP server: ${name2}`, { verbose: { config } });
|
|
181620
182568
|
const connection = this.connectionManager.getConnection(name2);
|
|
181621
182569
|
if ((connection == null ? void 0 : connection.server.status) === "connected") {
|
|
181622
182570
|
await this.initializeServerData(name2);
|
|
181623
182571
|
}
|
|
181624
182572
|
}
|
|
181625
182573
|
} catch (error) {
|
|
181626
|
-
logDebug
|
|
182574
|
+
logDebug("MCPManager", `Failed to ${operation} MCP server: ${name2}`, { verbose: { error } });
|
|
181627
182575
|
if (operation === "update") {
|
|
181628
182576
|
window$1.showErrorMessage(
|
|
181629
182577
|
`Failed to update MCP server: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -181660,15 +182608,15 @@ const _MCPManager = class _MCPManager {
|
|
|
181660
182608
|
if (enabled) {
|
|
181661
182609
|
try {
|
|
181662
182610
|
await this.addConnection(name2, mcpServers[name2]);
|
|
181663
|
-
logDebug
|
|
182611
|
+
logDebug("MCPManager", `Enabled and connected to MCP server: ${name2}`);
|
|
181664
182612
|
} catch (error) {
|
|
181665
|
-
logDebug
|
|
182613
|
+
logDebug("MCPManager", `Enabled MCP server but failed to connect: ${name2}`, {
|
|
181666
182614
|
verbose: { error }
|
|
181667
182615
|
});
|
|
181668
182616
|
}
|
|
181669
182617
|
} else {
|
|
181670
182618
|
await this.connectionManager.removeConnection(name2);
|
|
181671
|
-
logDebug
|
|
182619
|
+
logDebug("MCPManager", `Disabled MCP server: ${name2}`);
|
|
181672
182620
|
}
|
|
181673
182621
|
} catch (error) {
|
|
181674
182622
|
const action = enabled ? "enable" : "disable";
|
|
@@ -181729,7 +182677,7 @@ const _MCPManager = class _MCPManager {
|
|
|
181729
182677
|
cleanedServers,
|
|
181730
182678
|
ConfigurationTarget.Global
|
|
181731
182679
|
);
|
|
181732
|
-
logDebug
|
|
182680
|
+
logDebug("MCPManager", "Updated MCP servers configuration", {
|
|
181733
182681
|
verbose: { serverCount: Object.keys(cleanedServers).length }
|
|
181734
182682
|
});
|
|
181735
182683
|
} finally {
|
|
@@ -181744,12 +182692,12 @@ const _MCPManager = class _MCPManager {
|
|
|
181744
182692
|
}
|
|
181745
182693
|
this.disposables = [];
|
|
181746
182694
|
_MCPManager.instance = void 0;
|
|
181747
|
-
logDebug
|
|
182695
|
+
logDebug("MCPManager", "disposed");
|
|
181748
182696
|
}
|
|
181749
182697
|
static dispose() {
|
|
181750
182698
|
var _a3;
|
|
181751
182699
|
(_a3 = _MCPManager.instance) == null ? void 0 : _a3.dispose().catch((error) => {
|
|
181752
|
-
logDebug
|
|
182700
|
+
logDebug("MCPManager", "Error disposing MCPManager", { verbose: { error } });
|
|
181753
182701
|
});
|
|
181754
182702
|
}
|
|
181755
182703
|
};
|
|
@@ -181965,7 +182913,7 @@ function getCorpusContextItemsForEditorState() {
|
|
|
181965
182913
|
return pendingOperation;
|
|
181966
182914
|
}
|
|
181967
182915
|
if (isError$3(remoteReposForAllWorkspaceFolders2)) {
|
|
181968
|
-
logError$
|
|
182916
|
+
logError$1(
|
|
181969
182917
|
"initialContext",
|
|
181970
182918
|
"Failed to get remote repos for all workspace folders"
|
|
181971
182919
|
);
|
|
@@ -182092,7 +183040,7 @@ const _CodyTool = class _CodyTool {
|
|
|
182092
183040
|
}
|
|
182093
183041
|
return ps`${prompt}\n\t- ${RawTextProcessor.join(examples, ps`\n\t- `)}`;
|
|
182094
183042
|
} catch (error) {
|
|
182095
|
-
logDebug
|
|
183043
|
+
logDebug("Cody Tool", `failed to getInstruction for ${tag2}`, { verbose: { error } });
|
|
182096
183044
|
return ps``;
|
|
182097
183045
|
}
|
|
182098
183046
|
}
|
|
@@ -182193,7 +183141,7 @@ class CliTool extends CodyTool {
|
|
|
182193
183141
|
throw new Error("No commands approved for execution");
|
|
182194
183142
|
}
|
|
182195
183143
|
callback.onUpdate(toolID, { content: [...approvedCommands].join(", ") });
|
|
182196
|
-
logDebug
|
|
183144
|
+
logDebug("CodyTool", `executing ${approvedCommands.size} commands...`);
|
|
182197
183145
|
return Promise.all([...approvedCommands].map(getContextFileFromShell)).then(
|
|
182198
183146
|
(results) => results.flat()
|
|
182199
183147
|
);
|
|
@@ -182219,7 +183167,7 @@ class FileTool extends CodyTool {
|
|
|
182219
183167
|
async execute(span2, filePaths) {
|
|
182220
183168
|
span2.addEvent("executeFileTool");
|
|
182221
183169
|
if (filePaths.length === 0) return [];
|
|
182222
|
-
logDebug
|
|
183170
|
+
logDebug("CodyTool", `requesting ${filePaths.length} files`);
|
|
182223
183171
|
return Promise.all(filePaths.map(getContextFromRelativePath)).then((results) => results.filter((item) => item !== null)).catch(() => []);
|
|
182224
183172
|
}
|
|
182225
183173
|
}
|
|
@@ -182256,7 +183204,7 @@ class SearchTool extends CodyTool {
|
|
|
182256
183204
|
if (!repo) {
|
|
182257
183205
|
return [];
|
|
182258
183206
|
}
|
|
182259
|
-
logDebug
|
|
183207
|
+
logDebug("SearchTool", `searching codebase for ${query2}`);
|
|
182260
183208
|
const context2 = await this.contextRetriever.retrieveContext(
|
|
182261
183209
|
toStructuredMentions([repo]),
|
|
182262
183210
|
PromptString.unsafe_fromLLMResponse(query2),
|
|
@@ -182316,11 +183264,11 @@ class OpenCtxTool extends CodyTool {
|
|
|
182316
183264
|
);
|
|
182317
183265
|
results.push(...itemsWithContent.flat());
|
|
182318
183266
|
}
|
|
182319
|
-
logDebug
|
|
183267
|
+
logDebug("OpenCtxTool", `${this.provider.title} returned ${results.length} items`, {
|
|
182320
183268
|
verbose: { results, provider: this.provider.title }
|
|
182321
183269
|
});
|
|
182322
183270
|
} catch {
|
|
182323
|
-
logDebug
|
|
183271
|
+
logDebug("CodyTool", `OpenCtx item retrieval failed for ${queries}`);
|
|
182324
183272
|
}
|
|
182325
183273
|
return results;
|
|
182326
183274
|
}
|
|
@@ -182365,7 +183313,7 @@ class McpToolImpl extends CodyTool {
|
|
|
182365
183313
|
}
|
|
182366
183314
|
handleMcpToolError(error) {
|
|
182367
183315
|
const displayToolName = this.toolName || this.tool.name;
|
|
182368
|
-
logDebug
|
|
183316
|
+
logDebug("CodyToolProvider", `Error executing ${displayToolName}`, {
|
|
182369
183317
|
verbose: error
|
|
182370
183318
|
});
|
|
182371
183319
|
const errorStr = error instanceof Error ? error.message : String(error);
|
|
@@ -182675,11 +183623,11 @@ const _CodyToolProvider = class _CodyToolProvider {
|
|
|
182675
183623
|
*/
|
|
182676
183624
|
static registerMcpTools(serverName, tools) {
|
|
182677
183625
|
if (!_CodyToolProvider.instance) {
|
|
182678
|
-
logDebug
|
|
183626
|
+
logDebug("CodyToolProvider", "Cannot register MCP tools - instance not initialized");
|
|
182679
183627
|
return [];
|
|
182680
183628
|
}
|
|
182681
183629
|
const createdTools = _CodyToolProvider.instance.factory.createMcpTools(tools, serverName);
|
|
182682
|
-
logDebug
|
|
183630
|
+
logDebug("CodyToolProvider", `Registered ${createdTools.length} MCP tools successfully`);
|
|
182683
183631
|
return createdTools;
|
|
182684
183632
|
}
|
|
182685
183633
|
/**
|
|
@@ -182690,14 +183638,14 @@ const _CodyToolProvider = class _CodyToolProvider {
|
|
|
182690
183638
|
*/
|
|
182691
183639
|
static updateToolDisabledState(toolName, disabled) {
|
|
182692
183640
|
if (!_CodyToolProvider.instance) {
|
|
182693
|
-
logDebug
|
|
183641
|
+
logDebug("CodyToolProvider", "Cannot update tool state - instance not initialized");
|
|
182694
183642
|
return false;
|
|
182695
183643
|
}
|
|
182696
183644
|
const result = _CodyToolProvider.instance.factory.updateToolDisabledState(toolName, disabled);
|
|
182697
183645
|
if (result) {
|
|
182698
|
-
logDebug
|
|
183646
|
+
logDebug("CodyToolProvider", `Updated tool ${toolName} disabled state to ${disabled}`);
|
|
182699
183647
|
} else {
|
|
182700
|
-
logDebug
|
|
183648
|
+
logDebug("CodyToolProvider", `Failed to update tool ${toolName} - not found`);
|
|
182701
183649
|
}
|
|
182702
183650
|
return result;
|
|
182703
183651
|
}
|
|
@@ -183069,7 +184017,7 @@ const _DeepCodyAgent = class _DeepCodyAgent {
|
|
|
183069
184017
|
return newContext;
|
|
183070
184018
|
} catch (error) {
|
|
183071
184019
|
await this.multiplexer.notifyTurnComplete();
|
|
183072
|
-
logDebug
|
|
184020
|
+
logDebug("Deep Cody", `context review failed: ${error}`, { verbose: { prompt, error } });
|
|
183073
184021
|
return [];
|
|
183074
184022
|
}
|
|
183075
184023
|
}
|
|
@@ -183111,7 +184059,7 @@ const _DeepCodyAgent = class _DeepCodyAgent {
|
|
|
183111
184059
|
const file = item.uri.scheme === "file" ? await getContextFromRelativePath(contextName) : item;
|
|
183112
184060
|
reviewed.push({ ...file || item, source: ContextItemSource.Agentic });
|
|
183113
184061
|
} catch (error) {
|
|
183114
|
-
logDebug
|
|
184062
|
+
logDebug("Deep Cody", `failed to get context from ${contextName}`, {
|
|
183115
184063
|
verbose: { error, contextName }
|
|
183116
184064
|
});
|
|
183117
184065
|
}
|
|
@@ -183219,7 +184167,7 @@ class ChatsController {
|
|
|
183219
184167
|
this.contextRetriever = contextRetriever;
|
|
183220
184168
|
this.guardrails = guardrails;
|
|
183221
184169
|
this.extensionClient = extensionClient;
|
|
183222
|
-
logDebug("ChatsController:constructor", "init");
|
|
184170
|
+
outputChannelLogger.logDebug("ChatsController:constructor", "init");
|
|
183223
184171
|
this.panel = this.createChatController();
|
|
183224
184172
|
this.disposables.push(
|
|
183225
184173
|
subscriptionDisposable(
|
|
@@ -183238,7 +184186,7 @@ class ChatsController {
|
|
|
183238
184186
|
try {
|
|
183239
184187
|
await this.getOrCreateEditorChatController(chatID, panel2.title, panel2);
|
|
183240
184188
|
} catch (error) {
|
|
183241
|
-
logDebug("ChatsController", "restoreToPanel", { error });
|
|
184189
|
+
outputChannelLogger.logDebug("ChatsController", "restoreToPanel", { error });
|
|
183242
184190
|
await this.getOrCreateEditorChatController(chatID, panel2.title);
|
|
183243
184191
|
panel2.dispose();
|
|
183244
184192
|
}
|
|
@@ -183289,10 +184237,10 @@ class ChatsController {
|
|
|
183289
184237
|
);
|
|
183290
184238
|
const restoreToEditor = async (chatID, chatQuestion) => {
|
|
183291
184239
|
try {
|
|
183292
|
-
logDebug("ChatsController", "debouncedRestorePanel");
|
|
184240
|
+
outputChannelLogger.logDebug("ChatsController", "debouncedRestorePanel");
|
|
183293
184241
|
return await this.getOrCreateEditorChatController(chatID, chatQuestion);
|
|
183294
184242
|
} catch (error) {
|
|
183295
|
-
logDebug("ChatsController", "debouncedRestorePanel", "failed", error);
|
|
184243
|
+
outputChannelLogger.logDebug("ChatsController", "debouncedRestorePanel", "failed", error);
|
|
183296
184244
|
return void 0;
|
|
183297
184245
|
}
|
|
183298
184246
|
};
|
|
@@ -183526,7 +184474,11 @@ class ChatsController {
|
|
|
183526
184474
|
}
|
|
183527
184475
|
});
|
|
183528
184476
|
} catch (error) {
|
|
183529
|
-
logError
|
|
184477
|
+
outputChannelLogger.logError(
|
|
184478
|
+
"ChatsController:exportHistory",
|
|
184479
|
+
"Failed to export chat history",
|
|
184480
|
+
error
|
|
184481
|
+
);
|
|
183530
184482
|
}
|
|
183531
184483
|
}
|
|
183532
184484
|
}
|
|
@@ -183577,7 +184529,7 @@ class ChatsController {
|
|
|
183577
184529
|
}
|
|
183578
184530
|
});
|
|
183579
184531
|
} catch (error) {
|
|
183580
|
-
logError
|
|
184532
|
+
outputChannelLogger.logError(
|
|
183581
184533
|
"ChatsController:exportAllChatsUnauthenticated",
|
|
183582
184534
|
"Failed to export all chat history",
|
|
183583
184535
|
error
|
|
@@ -183877,7 +184829,7 @@ const _GitHubDotComRepoMetadata = class _GitHubDotComRepoMetadata {
|
|
|
183877
184829
|
metadata2.isPublic = response.ok;
|
|
183878
184830
|
} catch (error) {
|
|
183879
184831
|
if (!isAbortError(error)) {
|
|
183880
|
-
logDebug(
|
|
184832
|
+
outputChannelLogger.logDebug(
|
|
183881
184833
|
"queryGitHubApi",
|
|
183882
184834
|
"error querying GitHub API (assuming repository is non-public",
|
|
183883
184835
|
`${owner2}/${repoName}`,
|
|
@@ -183949,11 +184901,7 @@ const publicRepoMetadataIfAllWorkspaceReposArePublic = remoteReposForAllWorkspac
|
|
|
183949
184901
|
return allReposArePublic ? { isPublic: true, repoMetadata: repoMetadatas.filter(isDefined) } : NO_PUBLIC_METADATA;
|
|
183950
184902
|
}),
|
|
183951
184903
|
catchError$1((error) => {
|
|
183952
|
-
logDebug(
|
|
183953
|
-
"publicRepoMetadataIfAllWorkspaceReposArePublic",
|
|
183954
|
-
"error getting repository metadata",
|
|
183955
|
-
error
|
|
183956
|
-
);
|
|
184904
|
+
outputChannelLogger.logDebug("error getting repository metadata", error);
|
|
183957
184905
|
return Observable.of(NO_PUBLIC_METADATA);
|
|
183958
184906
|
})
|
|
183959
184907
|
);
|
|
@@ -183984,7 +184932,7 @@ class OmniboxTelemetry {
|
|
|
183984
184932
|
}
|
|
183985
184933
|
recordChatQuestionExecuted(context2, spans) {
|
|
183986
184934
|
if (!this.intentInfo) {
|
|
183987
|
-
logError$
|
|
184935
|
+
logError$1(
|
|
183988
184936
|
"AgentTelemetry",
|
|
183989
184937
|
"failed to log cody.chat-question/executed because intent info was not set"
|
|
183990
184938
|
);
|
|
@@ -184645,7 +185593,7 @@ function validateWithZod(schema2, input, toolName) {
|
|
|
184645
185593
|
const parsed = schema2.safeParse(sanitizeToolInput(input));
|
|
184646
185594
|
if (!parsed.success) {
|
|
184647
185595
|
const errorMsg = parsed.error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
|
|
184648
|
-
logDebug
|
|
185596
|
+
logDebug("validateWithZod", `Validation error for ${toolName}: ${errorMsg}`);
|
|
184649
185597
|
throw new Error(`${toolName} validation failed: ${errorMsg}`);
|
|
184650
185598
|
}
|
|
184651
185599
|
return parsed.data;
|
|
@@ -184656,13 +185604,13 @@ function sanitizeToolInput(input) {
|
|
|
184656
185604
|
return JSON.parse(input);
|
|
184657
185605
|
} catch (e) {
|
|
184658
185606
|
try {
|
|
184659
|
-
logDebug
|
|
185607
|
+
logDebug("sanitizeToolInput", `Attempting to repair malformed JSON: ${input}`);
|
|
184660
185608
|
const repairedJson = jsonrepair(input);
|
|
184661
185609
|
const result = JSON.parse(repairedJson);
|
|
184662
|
-
logDebug
|
|
185610
|
+
logDebug("sanitizeToolInput", `Successfully repaired JSON: ${repairedJson}`);
|
|
184663
185611
|
return result;
|
|
184664
185612
|
} catch (repairError) {
|
|
184665
|
-
logDebug
|
|
185613
|
+
logDebug("sanitizeToolInput", `Failed to repair JSON: ${input}`);
|
|
184666
185614
|
}
|
|
184667
185615
|
}
|
|
184668
185616
|
}
|
|
@@ -185834,7 +186782,7 @@ const fileOps = {
|
|
|
185834
186782
|
const doc2 = await workspace.openTextDocument(uri);
|
|
185835
186783
|
await doc2.save();
|
|
185836
186784
|
} catch (error) {
|
|
185837
|
-
logDebug
|
|
186785
|
+
logDebug("file_operations", `Failed to create file ${uri.toString()}: ${error.message}`);
|
|
185838
186786
|
throw error;
|
|
185839
186787
|
}
|
|
185840
186788
|
},
|
|
@@ -186022,7 +186970,7 @@ async function createFile(uri, fileText) {
|
|
|
186022
186970
|
}
|
|
186023
186971
|
return createEditToolState(toolId, UIToolStatus.Done, uri, output2.join("\n"), "file-view");
|
|
186024
186972
|
} catch (error) {
|
|
186025
|
-
logDebug
|
|
186973
|
+
logDebug("text_editor", `Failed to create file ${displayPath(uri)}: ${error.message}`);
|
|
186026
186974
|
return createEditToolState(
|
|
186027
186975
|
toolId,
|
|
186028
186976
|
UIToolStatus.Error,
|
|
@@ -186073,7 +187021,7 @@ async function replaceInFile(uri, oldStr, newStr) {
|
|
|
186073
187021
|
const diffMarkdown = diffWithLineNum(content, newContent);
|
|
186074
187022
|
const output2 = [`Edited ${fileName}`, diffMarkdown];
|
|
186075
187023
|
const historyUri = uri.with({ scheme: "cody-checkpoint" });
|
|
186076
|
-
logDebug
|
|
187024
|
+
logDebug("text_editor", "New content created", { uri: historyUri });
|
|
186077
187025
|
const diagnosticsOnEnd = getErrorDiagnostics(uri);
|
|
186078
187026
|
if (diagnosticsOnEnd.length) {
|
|
186079
187027
|
output2.push("[Error detected - Action required]");
|
|
@@ -186559,7 +187507,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186559
187507
|
const contextItems = (contextResult == null ? void 0 : contextResult.contextItems) ?? [];
|
|
186560
187508
|
this.tools = await AgentToolGroup.getToolsByAgentId(this.contextRetriever, span2);
|
|
186561
187509
|
const startTime = Date.now();
|
|
186562
|
-
logDebug
|
|
187510
|
+
logDebug("AgenticHandler", `Starting agent session ${sessionID}`);
|
|
186563
187511
|
recorder2.recordChatQuestionExecuted(contextItems, { addMetadata: true, current: span2 });
|
|
186564
187512
|
try {
|
|
186565
187513
|
await this.runConversationLoop(chatBuilder, delegate, recorder2, span2, signal2, contextItems);
|
|
@@ -186567,8 +187515,8 @@ class AgenticHandler extends ChatHandler {
|
|
|
186567
187515
|
this.handleError(sessionID, error, delegate, signal2);
|
|
186568
187516
|
} finally {
|
|
186569
187517
|
delegate.postDone();
|
|
186570
|
-
logDebug
|
|
186571
|
-
logDebug
|
|
187518
|
+
logDebug("AgenticHandler", `Ending agent session ${sessionID}`);
|
|
187519
|
+
logDebug("AgenticHandler", `Session ${sessionID} duration: ${Date.now() - startTime}ms`);
|
|
186572
187520
|
}
|
|
186573
187521
|
}
|
|
186574
187522
|
/**
|
|
@@ -186596,13 +187544,13 @@ class AgenticHandler extends ChatHandler {
|
|
|
186596
187544
|
);
|
|
186597
187545
|
if (!(toolCalls == null ? void 0 : toolCalls.size)) {
|
|
186598
187546
|
chatBuilder.addBotMessage(botResponse, model2);
|
|
186599
|
-
logDebug
|
|
187547
|
+
logDebug("AgenticHandler", "No tool calls, ending conversation");
|
|
186600
187548
|
break;
|
|
186601
187549
|
}
|
|
186602
187550
|
const content = Array.from(toolCalls.values());
|
|
186603
187551
|
delegate.postMessageInProgress(botResponse);
|
|
186604
187552
|
const results = await this.executeTools(content, model2).catch(() => {
|
|
186605
|
-
logDebug
|
|
187553
|
+
logDebug("AgenticHandler", "Error executing tools");
|
|
186606
187554
|
return [];
|
|
186607
187555
|
});
|
|
186608
187556
|
const toolResults = results == null ? void 0 : results.map((result) => result.tool_result).filter(isDefined);
|
|
@@ -186617,7 +187565,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186617
187565
|
contextFiles: toolOutputs
|
|
186618
187566
|
});
|
|
186619
187567
|
if (turnCount >= this.MAX_TURN - 1) {
|
|
186620
|
-
logDebug
|
|
187568
|
+
logDebug("AgenticHandler", "Max turns reached, ending conversation");
|
|
186621
187569
|
break;
|
|
186622
187570
|
}
|
|
186623
187571
|
turnCount++;
|
|
@@ -186634,7 +187582,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186634
187582
|
var _a3, _b2;
|
|
186635
187583
|
const prompter2 = new AgenticChatPrompter(this.SYSTEM_PROMPT);
|
|
186636
187584
|
const prompt = await prompter2.makePrompt(chatBuilder, contextItems);
|
|
186637
|
-
logDebug
|
|
187585
|
+
logDebug("AgenticHandler", "Prompt created", { verbose: prompt });
|
|
186638
187586
|
const params = {
|
|
186639
187587
|
maxTokensToSample: 8e3,
|
|
186640
187588
|
messages: JSON.stringify(prompt),
|
|
@@ -186721,7 +187669,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186721
187669
|
var _a3, _b2, _c2;
|
|
186722
187670
|
const existingCall = toolCalls.get((_a3 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _a3.id);
|
|
186723
187671
|
if (!existingCall) {
|
|
186724
|
-
logDebug
|
|
187672
|
+
logDebug("AgenticHandler", `Calling ${(_b2 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _b2.name}`, { verbose: toolCall });
|
|
186725
187673
|
}
|
|
186726
187674
|
const updatedCall = { ...existingCall, ...toolCall };
|
|
186727
187675
|
toolCalls.set((_c2 = toolCall == null ? void 0 : toolCall.tool_call) == null ? void 0 : _c2.id, updatedCall);
|
|
@@ -186731,7 +187679,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186731
187679
|
*/
|
|
186732
187680
|
async executeTools(toolCalls, model2) {
|
|
186733
187681
|
try {
|
|
186734
|
-
logDebug
|
|
187682
|
+
logDebug("AgenticHandler", `Executing ${toolCalls.length} tools`);
|
|
186735
187683
|
const results = await Promise.allSettled(
|
|
186736
187684
|
toolCalls.map(async (toolCall) => {
|
|
186737
187685
|
var _a3, _b2, _c2, _d2;
|
|
@@ -186748,12 +187696,12 @@ class AgenticHandler extends ChatHandler {
|
|
|
186748
187696
|
type: "builtin"
|
|
186749
187697
|
}
|
|
186750
187698
|
});
|
|
186751
|
-
logDebug
|
|
187699
|
+
logDebug("AgenticHandler", `Executing ${(_c2 = toolCall.tool_call) == null ? void 0 : _c2.name}`, {
|
|
186752
187700
|
verbose: toolCall
|
|
186753
187701
|
});
|
|
186754
187702
|
return await this.executeSingleTool(toolCall, model2);
|
|
186755
187703
|
} catch (error) {
|
|
186756
|
-
logDebug
|
|
187704
|
+
logDebug("AgenticHandler", `Error executing tool ${(_d2 = toolCall.tool_call) == null ? void 0 : _d2.name}`, {
|
|
186757
187705
|
verbose: error
|
|
186758
187706
|
});
|
|
186759
187707
|
return null;
|
|
@@ -186762,7 +187710,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186762
187710
|
);
|
|
186763
187711
|
return results.filter((result) => result.status === "fulfilled" && result.value).map((result) => result.value);
|
|
186764
187712
|
} catch (error) {
|
|
186765
|
-
logDebug
|
|
187713
|
+
logDebug("AgenticHandler", "Error executing tools", { verbose: error });
|
|
186766
187714
|
return [];
|
|
186767
187715
|
}
|
|
186768
187716
|
}
|
|
@@ -186802,7 +187750,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186802
187750
|
type: "builtin"
|
|
186803
187751
|
}
|
|
186804
187752
|
});
|
|
186805
|
-
logDebug
|
|
187753
|
+
logDebug("AgenticHandler", `Error executing tool ${toolCall.tool_call.name}`, {
|
|
186806
187754
|
verbose: error
|
|
186807
187755
|
});
|
|
186808
187756
|
return null;
|
|
@@ -186811,7 +187759,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186811
187759
|
throw new Error(`Tool ${toolCall.tool_call.name} failed`);
|
|
186812
187760
|
}
|
|
186813
187761
|
tool_result.tool_result.content = result.content || "Empty result";
|
|
186814
|
-
logDebug
|
|
187762
|
+
logDebug("AgenticHandler", `Executed ${toolCall.tool_call.name}`, { verbose: result });
|
|
186815
187763
|
telemetryRecorder.recordEvent("cody.tool-use", "executed", {
|
|
186816
187764
|
billingMetadata: {
|
|
186817
187765
|
product: "cody",
|
|
@@ -186846,7 +187794,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186846
187794
|
type: "builtin"
|
|
186847
187795
|
}
|
|
186848
187796
|
});
|
|
186849
|
-
logDebug
|
|
187797
|
+
logDebug("AgenticHandler", `${toolCall.tool_call.name} failed`, { verbose: error });
|
|
186850
187798
|
return {
|
|
186851
187799
|
tool_result,
|
|
186852
187800
|
output: {
|
|
@@ -186864,7 +187812,7 @@ class AgenticHandler extends ChatHandler {
|
|
|
186864
187812
|
* Handle errors with consistent logging and reporting
|
|
186865
187813
|
*/
|
|
186866
187814
|
handleError(sessionID, error, delegate, signal2) {
|
|
186867
|
-
logDebug
|
|
187815
|
+
logDebug("AgenticHandler", `Error in agent session ${sessionID}`, {
|
|
186868
187816
|
verbose: error instanceof Error ? { message: error.message, stack: error.stack } : String(error)
|
|
186869
187817
|
});
|
|
186870
187818
|
if (!signal2.aborted) {
|
|
@@ -187412,6 +188360,7 @@ class ChatController {
|
|
|
187412
188360
|
__publicField2(this, "guardrails");
|
|
187413
188361
|
__publicField2(this, "lastKnownTokenUsage");
|
|
187414
188362
|
__publicField2(this, "disposables", []);
|
|
188363
|
+
__publicField2(this, "deviceAuthController", null);
|
|
187415
188364
|
__publicField2(this, "clientBroadcast", new MulticastSubject());
|
|
187416
188365
|
__publicField2(this, "initDoer", new InitDoer());
|
|
187417
188366
|
__publicField2(this, "submitOrEditOperation");
|
|
@@ -187595,7 +188544,7 @@ class ChatController {
|
|
|
187595
188544
|
case "mcp": {
|
|
187596
188545
|
const mcpManager = MCPManager.instance;
|
|
187597
188546
|
if (!mcpManager) {
|
|
187598
|
-
logDebug("ChatController", "MCP Manager is not initialized");
|
|
188547
|
+
outputChannelLogger.logDebug("ChatController", "MCP Manager is not initialized");
|
|
187599
188548
|
break;
|
|
187600
188549
|
}
|
|
187601
188550
|
const serverName = message.name;
|
|
@@ -187649,11 +188598,18 @@ class ChatController {
|
|
|
187649
188598
|
break;
|
|
187650
188599
|
}
|
|
187651
188600
|
default:
|
|
187652
|
-
logDebug(
|
|
188601
|
+
outputChannelLogger.logDebug(
|
|
188602
|
+
"ChatController",
|
|
188603
|
+
`Unknown MCP operation: ${message.type}`
|
|
188604
|
+
);
|
|
187653
188605
|
}
|
|
187654
188606
|
} catch (error) {
|
|
187655
188607
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
187656
|
-
logDebug(
|
|
188608
|
+
outputChannelLogger.logDebug(
|
|
188609
|
+
"ChatController",
|
|
188610
|
+
`Failed to ${message.type} server`,
|
|
188611
|
+
errorMessage
|
|
188612
|
+
);
|
|
187657
188613
|
void this.postMessage({
|
|
187658
188614
|
type: "clientAction",
|
|
187659
188615
|
mcpServerError: {
|
|
@@ -187700,6 +188656,49 @@ class ChatController {
|
|
|
187700
188656
|
auth2 = await resolveAuth(endpoint, configuration, secretStorage);
|
|
187701
188657
|
}
|
|
187702
188658
|
if (!auth2 || !auth2.credentials) {
|
|
188659
|
+
this.deviceAuthController = new AbortController();
|
|
188660
|
+
const deviceAuthResult = await startDeviceAuthFlow(
|
|
188661
|
+
endpoint,
|
|
188662
|
+
(userCode, verificationUri) => {
|
|
188663
|
+
void this.postMessage({
|
|
188664
|
+
type: "device-flow-status",
|
|
188665
|
+
status: "code-ready",
|
|
188666
|
+
userCode,
|
|
188667
|
+
verificationUri
|
|
188668
|
+
});
|
|
188669
|
+
},
|
|
188670
|
+
this.deviceAuthController.signal
|
|
188671
|
+
);
|
|
188672
|
+
this.deviceAuthController = null;
|
|
188673
|
+
if (deviceAuthResult.type === "success") {
|
|
188674
|
+
await this.postMessage({
|
|
188675
|
+
type: "device-flow-status",
|
|
188676
|
+
status: "success",
|
|
188677
|
+
message: "Authentication successful!"
|
|
188678
|
+
});
|
|
188679
|
+
await showAuthResultMessage(endpoint, deviceAuthResult.authStatus);
|
|
188680
|
+
return;
|
|
188681
|
+
}
|
|
188682
|
+
if (deviceAuthResult.type === "cancelled") {
|
|
188683
|
+
await this.postMessage({
|
|
188684
|
+
type: "device-flow-status",
|
|
188685
|
+
status: "cancelled",
|
|
188686
|
+
message: "Device auth cancelled"
|
|
188687
|
+
});
|
|
188688
|
+
return;
|
|
188689
|
+
}
|
|
188690
|
+
if (deviceAuthResult.type === "failed") {
|
|
188691
|
+
await this.postMessage({
|
|
188692
|
+
type: "device-flow-status",
|
|
188693
|
+
status: "error",
|
|
188694
|
+
message: "Device auth failed"
|
|
188695
|
+
});
|
|
188696
|
+
outputChannelLogger.logDebug(
|
|
188697
|
+
"auth",
|
|
188698
|
+
"Device auth not available, falling back to traditional auth",
|
|
188699
|
+
{ endpoint }
|
|
188700
|
+
);
|
|
188701
|
+
}
|
|
187703
188702
|
return redirectToEndpointLogin(endpoint);
|
|
187704
188703
|
}
|
|
187705
188704
|
await authProvider.validateAndStoreCredentials(auth2, "always-store");
|
|
@@ -187723,12 +188722,26 @@ class ChatController {
|
|
|
187723
188722
|
await showSignInMenu();
|
|
187724
188723
|
break;
|
|
187725
188724
|
}
|
|
188725
|
+
if (message.authKind === "cancel") {
|
|
188726
|
+
if (this.deviceAuthController) {
|
|
188727
|
+
this.deviceAuthController.abort();
|
|
188728
|
+
this.deviceAuthController = null;
|
|
188729
|
+
outputChannelLogger.logDebug(
|
|
188730
|
+
"ChatController",
|
|
188731
|
+
"Device auth cancelled by user"
|
|
188732
|
+
);
|
|
188733
|
+
}
|
|
188734
|
+
break;
|
|
188735
|
+
}
|
|
187726
188736
|
await commands$1.executeCommand(`cody.auth.${message.authKind}`);
|
|
187727
188737
|
break;
|
|
187728
188738
|
}
|
|
187729
188739
|
case "log": {
|
|
187730
|
-
|
|
187731
|
-
|
|
188740
|
+
if (message.level === "debug") {
|
|
188741
|
+
outputChannelLogger.logDebug(message.filterLabel, message.message);
|
|
188742
|
+
} else {
|
|
188743
|
+
outputChannelLogger.logError(message.filterLabel, message.message);
|
|
188744
|
+
}
|
|
187732
188745
|
break;
|
|
187733
188746
|
}
|
|
187734
188747
|
case "devicePixelRatio": {
|
|
@@ -187811,7 +188824,7 @@ class ChatController {
|
|
|
187811
188824
|
workspaceFolderUris,
|
|
187812
188825
|
siteHasCodyEnabled
|
|
187813
188826
|
});
|
|
187814
|
-
logDebug("ChatController", "updateViewConfig", {
|
|
188827
|
+
outputChannelLogger.logDebug("ChatController", "updateViewConfig", {
|
|
187815
188828
|
verbose: configForWebview
|
|
187816
188829
|
});
|
|
187817
188830
|
}
|
|
@@ -187820,7 +188833,7 @@ class ChatController {
|
|
|
187820
188833
|
type: "clientConfig",
|
|
187821
188834
|
clientConfig
|
|
187822
188835
|
});
|
|
187823
|
-
logDebug("ChatController", "updateClientConfig", {
|
|
188836
|
+
outputChannelLogger.logDebug("ChatController", "updateClientConfig", {
|
|
187824
188837
|
verbose: clientConfig
|
|
187825
188838
|
});
|
|
187826
188839
|
}
|
|
@@ -187933,6 +188946,7 @@ class ChatController {
|
|
|
187933
188946
|
this.postEmptyMessageInProgress(model2);
|
|
187934
188947
|
let messageInProgress = { speaker: "assistant", model: model2 };
|
|
187935
188948
|
try {
|
|
188949
|
+
const chatBuilder = this.chatBuilder;
|
|
187936
188950
|
await agent2.handle(
|
|
187937
188951
|
{
|
|
187938
188952
|
requestID,
|
|
@@ -187940,7 +188954,7 @@ class ChatController {
|
|
|
187940
188954
|
mentions,
|
|
187941
188955
|
editorState,
|
|
187942
188956
|
signal: signal2,
|
|
187943
|
-
chatBuilder
|
|
188957
|
+
chatBuilder,
|
|
187944
188958
|
span: span2,
|
|
187945
188959
|
recorder: recorder2,
|
|
187946
188960
|
model: model2
|
|
@@ -187954,7 +188968,7 @@ class ChatController {
|
|
|
187954
188968
|
this.postViewTranscript(message);
|
|
187955
188969
|
},
|
|
187956
188970
|
postStatuses: (steps) => {
|
|
187957
|
-
|
|
188971
|
+
chatBuilder.setLastMessageProcesses(steps);
|
|
187958
188972
|
this.postViewTranscript(messageInProgress);
|
|
187959
188973
|
},
|
|
187960
188974
|
experimentalPostMessageInProgress: (subMessages) => {
|
|
@@ -188264,26 +189278,12 @@ class ChatController {
|
|
|
188264
189278
|
revealWebviewViewOrPanel(this._webviewPanelOrView);
|
|
188265
189279
|
}
|
|
188266
189280
|
}
|
|
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
189281
|
async handleSmartApplyResult(result) {
|
|
188280
189282
|
void this.postMessage({
|
|
188281
189283
|
type: "clientAction",
|
|
188282
189284
|
smartApplyResult: result
|
|
188283
189285
|
});
|
|
188284
189286
|
}
|
|
188285
|
-
fireClientAction() {
|
|
188286
|
-
}
|
|
188287
189287
|
async handleAttributionSearch(snippet) {
|
|
188288
189288
|
try {
|
|
188289
189289
|
const attribution = await this.guardrails.searchAttribution(snippet);
|
|
@@ -188378,7 +189378,7 @@ class ChatController {
|
|
|
188378
189378
|
}
|
|
188379
189379
|
}
|
|
188380
189380
|
} catch (error) {
|
|
188381
|
-
logDebug("ChatController", "setCustomChatTitle", { verbose: error });
|
|
189381
|
+
outputChannelLogger.logDebug("ChatController", "setCustomChatTitle", { verbose: error });
|
|
188382
189382
|
}
|
|
188383
189383
|
telemetryRecorder.recordEvent("cody.chat.customTitle", "generated", {
|
|
188384
189384
|
privateMetadata: {
|
|
@@ -188400,7 +189400,7 @@ class ChatController {
|
|
|
188400
189400
|
if (isRateLimitError(error)) {
|
|
188401
189401
|
handleRateLimitError();
|
|
188402
189402
|
}
|
|
188403
|
-
logDebug("ChatController: postError", error.message);
|
|
189403
|
+
outputChannelLogger.logDebug("ChatController: postError", error.message);
|
|
188404
189404
|
if (type === "transcript") {
|
|
188405
189405
|
this.chatBuilder.addErrorAsBotMessage(error, ChatBuilder.NO_MODEL);
|
|
188406
189406
|
this.postViewTranscript();
|
|
@@ -188505,7 +189505,7 @@ class ChatController {
|
|
|
188505
189505
|
}
|
|
188506
189506
|
}
|
|
188507
189507
|
} catch (error) {
|
|
188508
|
-
logDebug("ChatController", "Failed");
|
|
189508
|
+
outputChannelLogger.logDebug("ChatController", "Failed");
|
|
188509
189509
|
}
|
|
188510
189510
|
}
|
|
188511
189511
|
async duplicateSession(sessionID) {
|
|
@@ -188569,7 +189569,7 @@ class ChatController {
|
|
|
188569
189569
|
* Revives the chat panel when the extension is reactivated.
|
|
188570
189570
|
*/
|
|
188571
189571
|
async revive(webviewPanel) {
|
|
188572
|
-
logDebug("ChatController:revive", "registering webview panel");
|
|
189572
|
+
outputChannelLogger.logDebug("ChatController:revive", "registering webview panel");
|
|
188573
189573
|
await this.registerWebviewPanel(webviewPanel);
|
|
188574
189574
|
}
|
|
188575
189575
|
async resolveWebviewView(webviewView, _context, _token) {
|
|
@@ -189717,7 +190717,7 @@ async function unitTestCommand(span2, args2) {
|
|
|
189717
190717
|
);
|
|
189718
190718
|
}
|
|
189719
190719
|
const sharedContext = await getContextFilesForUnitTestCommand(document2.uri).catch((error) => {
|
|
189720
|
-
logError$
|
|
190720
|
+
logError$1("executeNewTestCommand", "failed to fetch context", { verbose: error });
|
|
189721
190721
|
return [];
|
|
189722
190722
|
});
|
|
189723
190723
|
prompt = prompt.replaceAll("<selected>", selectedCodePromptWithExtraFiles(cursorContext, []));
|
|
@@ -189730,7 +190730,7 @@ async function unitTestCommand(span2, args2) {
|
|
|
189730
190730
|
contextItems.push(cursorContext);
|
|
189731
190731
|
contextItems.push(...sharedContext);
|
|
189732
190732
|
} catch (error) {
|
|
189733
|
-
logError$
|
|
190733
|
+
logError$1("testCommand", "failed to fetch context", { verbose: error });
|
|
189734
190734
|
}
|
|
189735
190735
|
}
|
|
189736
190736
|
return {
|
|
@@ -189747,7 +190747,7 @@ async function executeTestChatCommand(args2) {
|
|
|
189747
190747
|
if (editor.active && await isUriIgnoredByContextFilterWithNotification(editor.active.document.uri, "test")) {
|
|
189748
190748
|
return;
|
|
189749
190749
|
}
|
|
189750
|
-
logDebug
|
|
190750
|
+
logDebug("executeTestEditCommand", "executing", { args: args2 });
|
|
189751
190751
|
telemetryRecorder.recordEvent("cody.command.test", "executed", {
|
|
189752
190752
|
metadata: {
|
|
189753
190753
|
useCodebaseContex: 0
|
|
@@ -190275,7 +191275,7 @@ async function getGitInfoForMentions(settings) {
|
|
|
190275
191275
|
);
|
|
190276
191276
|
return { cwd: dir, defaultBranch: defaultBranch.trim() };
|
|
190277
191277
|
} catch (error) {
|
|
190278
|
-
logDebug
|
|
191278
|
+
logDebug("gitMentionsProvider", "getGitInfoForMentions", {
|
|
190279
191279
|
dir: dir.toString(),
|
|
190280
191280
|
error
|
|
190281
191281
|
});
|
|
@@ -190303,13 +191303,13 @@ function parseMentionURI(uri) {
|
|
|
190303
191303
|
}
|
|
190304
191304
|
return data;
|
|
190305
191305
|
} catch (error) {
|
|
190306
|
-
logDebug
|
|
191306
|
+
logDebug("gitMentionsProvider", "invalid Git mention URI", uri.toString(), error);
|
|
190307
191307
|
return null;
|
|
190308
191308
|
}
|
|
190309
191309
|
}
|
|
190310
191310
|
async function execFileAsync(program2, args2, { cwd }) {
|
|
190311
|
-
const { promisify } = await import("./util-
|
|
190312
|
-
const { execFile } = await import("./vscode-shim-
|
|
191311
|
+
const { promisify } = await import("./util-BR3OBpy6.mjs").then((n) => n.u);
|
|
191312
|
+
const { execFile } = await import("./vscode-shim-CqAb7AbA.mjs").then((n) => n.gz);
|
|
190313
191313
|
return promisify(execFile)(program2, args2, { cwd });
|
|
190314
191314
|
}
|
|
190315
191315
|
var __create = Object.create;
|
|
@@ -192544,7 +193544,7 @@ function observeOpenCtxController(context2, createOpenCtxController) {
|
|
|
192544
193544
|
});
|
|
192545
193545
|
return controller2;
|
|
192546
193546
|
} catch (error) {
|
|
192547
|
-
logDebug("openctx", `Failed to load OpenCtx client: ${error}`);
|
|
193547
|
+
outputChannelLogger.logDebug("openctx", `Failed to load OpenCtx client: ${error}`);
|
|
192548
193548
|
throw error;
|
|
192549
193549
|
}
|
|
192550
193550
|
}),
|
|
@@ -192704,7 +193704,7 @@ async function getViewerSettingsProviders() {
|
|
|
192704
193704
|
}
|
|
192705
193705
|
return providers;
|
|
192706
193706
|
} catch (error) {
|
|
192707
|
-
logError$
|
|
193707
|
+
logError$1("OpenCtx", "failed to fetch viewer settings from Sourcegraph", error);
|
|
192708
193708
|
return void 0;
|
|
192709
193709
|
}
|
|
192710
193710
|
}
|
|
@@ -193426,7 +194426,7 @@ function matchJavascriptFormatting(incoming, original) {
|
|
|
193426
194426
|
return incoming;
|
|
193427
194427
|
}
|
|
193428
194428
|
function matchLanguage(incoming, original, uri) {
|
|
193429
|
-
const language =
|
|
194429
|
+
const language = languageFromFilenameAndContent(uri, original);
|
|
193430
194430
|
switch (language) {
|
|
193431
194431
|
case ProgrammingLanguage.TypeScript:
|
|
193432
194432
|
case ProgrammingLanguage.JavaScript:
|
|
@@ -194304,7 +195304,7 @@ class EditProvider {
|
|
|
194304
195304
|
}
|
|
194305
195305
|
case "error": {
|
|
194306
195306
|
let err2 = message.error;
|
|
194307
|
-
logError
|
|
195307
|
+
outputChannelLogger.logError("EditProvider:onError", err2.message);
|
|
194308
195308
|
if (isAbortError(err2)) {
|
|
194309
195309
|
if (session.state === "streaming") {
|
|
194310
195310
|
void this.handleResponse(text2, false);
|
|
@@ -194685,7 +195685,7 @@ class EditManager {
|
|
|
194685
195685
|
} catch (error) {
|
|
194686
195686
|
const errorObject = error instanceof Error ? error : new Error(typeof error === "string" ? error : String(error));
|
|
194687
195687
|
this.options.fixupController.error(task.id, errorObject);
|
|
194688
|
-
logError$
|
|
195688
|
+
logError$1("EditManager", "startStreamingEditTask", errorObject);
|
|
194689
195689
|
}
|
|
194690
195690
|
}
|
|
194691
195691
|
dispose() {
|
|
@@ -196762,7 +197762,7 @@ class FixupController {
|
|
|
196762
197762
|
}
|
|
196763
197763
|
// Apply single fixup from task ID. Public for testing.
|
|
196764
197764
|
async apply(id) {
|
|
196765
|
-
logDebug("FixupController:apply", "applying", { verbose: { id } });
|
|
197765
|
+
outputChannelLogger.logDebug("FixupController:apply", "applying", { verbose: { id } });
|
|
196766
197766
|
const task = this.tasks.get(id);
|
|
196767
197767
|
if (!task) {
|
|
196768
197768
|
return;
|
|
@@ -197005,7 +198005,7 @@ class FixupController {
|
|
|
197005
198005
|
}
|
|
197006
198006
|
// Replace edit returned by Cody at task selection range
|
|
197007
198007
|
async replaceEdit(edit, diff2, task, options) {
|
|
197008
|
-
logDebug("FixupController:edit", "replacing ");
|
|
198008
|
+
outputChannelLogger.logDebug("FixupController:edit", "replacing ");
|
|
197009
198009
|
const suitableDiffForEditing = makeDiffEditBuilderCompatible(diff2);
|
|
197010
198010
|
if (edit instanceof AgentWorkspaceEdit) {
|
|
197011
198011
|
for (const change of suitableDiffForEditing) {
|
|
@@ -197033,7 +198033,7 @@ class FixupController {
|
|
|
197033
198033
|
}
|
|
197034
198034
|
// Insert edit returned by Cody at task selection range
|
|
197035
198035
|
async insertEdit(edit, document2, task, options) {
|
|
197036
|
-
logDebug("FixupController:edit", "inserting");
|
|
198036
|
+
outputChannelLogger.logDebug("FixupController:edit", "inserting");
|
|
197037
198037
|
const text2 = task.replacement;
|
|
197038
198038
|
if (!text2) {
|
|
197039
198039
|
return false;
|
|
@@ -197511,12 +198511,6 @@ const FeedbackOptionItems = [
|
|
|
197511
198511
|
await env.openExternal(Uri.parse(CODY_DOC_URL.href));
|
|
197512
198512
|
}
|
|
197513
198513
|
},
|
|
197514
|
-
{
|
|
197515
|
-
label: "$(feedback) Cody Feedback",
|
|
197516
|
-
async onSelect() {
|
|
197517
|
-
await env.openExternal(Uri.parse(CODY_FEEDBACK_URL.href));
|
|
197518
|
-
}
|
|
197519
|
-
},
|
|
197520
198514
|
{
|
|
197521
198515
|
label: "$(organization) Cody Discord Channel",
|
|
197522
198516
|
async onSelect() {
|
|
@@ -198575,10 +199569,6 @@ function registerSidebarCommands() {
|
|
|
198575
199569
|
logSidebarClick("support");
|
|
198576
199570
|
void commands$1.executeCommand("vscode.open", CODY_SUPPORT_URL.href);
|
|
198577
199571
|
}),
|
|
198578
|
-
commands$1.registerCommand("cody.sidebar.feedback", () => {
|
|
198579
|
-
logSidebarClick("feedback");
|
|
198580
|
-
void commands$1.executeCommand("vscode.open", CODY_FEEDBACK_URL.href);
|
|
198581
|
-
}),
|
|
198582
199572
|
commands$1.registerCommand("cody.sidebar.discord", () => {
|
|
198583
199573
|
logSidebarClick("discord");
|
|
198584
199574
|
void commands$1.executeCommand("vscode.open", DISCORD_URL.href);
|
|
@@ -198976,7 +199966,7 @@ function interactDefault({
|
|
|
198976
199966
|
try {
|
|
198977
199967
|
(_a3 = error.onShow) == null ? void 0 : _a3.call(error);
|
|
198978
199968
|
} catch (e) {
|
|
198979
|
-
logError$
|
|
199969
|
+
logError$1("Status Bar Interaction", "Error during show handler");
|
|
198980
199970
|
}
|
|
198981
199971
|
}
|
|
198982
199972
|
const createFeatureToggle = featureToggleBuilder(
|
|
@@ -199058,17 +200048,7 @@ function interactDefault({
|
|
|
199058
200048
|
},
|
|
199059
200049
|
{ label: "feedback & support", kind: QuickPickItemKind.Separator },
|
|
199060
200050
|
...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
|
-
}
|
|
200051
|
+
...FeedbackOptionItems
|
|
199072
200052
|
].filter(Boolean);
|
|
199073
200053
|
quickPick.title = "Cody Settings";
|
|
199074
200054
|
quickPick.placeholder = "Choose an option";
|
|
@@ -199420,7 +200400,7 @@ async function* getSupercompletions({
|
|
|
199420
200400
|
if (!supercompletion) {
|
|
199421
200401
|
continue;
|
|
199422
200402
|
}
|
|
199423
|
-
logDebug
|
|
200403
|
+
logDebug("supercompletions", "candidate", { verbose: supercompletion });
|
|
199424
200404
|
yield supercompletion;
|
|
199425
200405
|
}
|
|
199426
200406
|
}
|
|
@@ -199442,7 +200422,7 @@ async function* generateRawChanges(chat2, messages, abortSignal) {
|
|
|
199442
200422
|
const summaryMatch = change.match(/<summary>(.*)<\/summary>/s);
|
|
199443
200423
|
const changeMatch = change.match(/<change>(.*)<\/change>/s);
|
|
199444
200424
|
if (!summaryMatch || !changeMatch) {
|
|
199445
|
-
logDebug
|
|
200425
|
+
logDebug("supercompletions", "error", "invalid change block", {
|
|
199446
200426
|
verbose: change
|
|
199447
200427
|
});
|
|
199448
200428
|
continue;
|
|
@@ -199499,7 +200479,7 @@ function parseRawChange(document2, { change, summary }) {
|
|
|
199499
200479
|
}
|
|
199500
200480
|
}
|
|
199501
200481
|
if (state2 !== "complete") {
|
|
199502
|
-
logDebug
|
|
200482
|
+
logDebug(
|
|
199503
200483
|
"supercompletions",
|
|
199504
200484
|
"error",
|
|
199505
200485
|
"could not find change deliminators",
|
|
@@ -199928,7 +200908,7 @@ async function start(context2, platform2) {
|
|
|
199928
200908
|
if (secretStorage instanceof VSCodeSecretStorage) {
|
|
199929
200909
|
secretStorage.setStorage(context2.secrets);
|
|
199930
200910
|
}
|
|
199931
|
-
setLogger(
|
|
200911
|
+
setLogger(outputChannelLogger);
|
|
199932
200912
|
setClientCapabilities({
|
|
199933
200913
|
configuration: getConfiguration(),
|
|
199934
200914
|
agentCapabilities: platform2.extensionClient.capabilities
|
|
@@ -199959,7 +200939,7 @@ async function start(context2, platform2) {
|
|
|
199959
200939
|
isReinstalling,
|
|
199960
200940
|
onReinstall: async () => {
|
|
199961
200941
|
if (hasReinstallCleanupRun) return;
|
|
199962
|
-
logDebug("start", "Reinstalling Cody");
|
|
200942
|
+
outputChannelLogger.logDebug("start", "Reinstalling Cody");
|
|
199963
200943
|
const history = await localStorage.deleteEndpointHistory();
|
|
199964
200944
|
const additionalEndpointsToClear = [
|
|
199965
200945
|
clientConfiguration.overrideServerEndpoint,
|
|
@@ -200048,6 +201028,7 @@ const register = async (context2, platform2, isExtensionModeDevOrTest) => {
|
|
|
200048
201028
|
}
|
|
200049
201029
|
if (isExtensionModeDevOrTest) {
|
|
200050
201030
|
await registerTestCommands(context2, disposables);
|
|
201031
|
+
registerAuthDebugCommands(disposables);
|
|
200051
201032
|
}
|
|
200052
201033
|
registerDebugCommands(context2, disposables);
|
|
200053
201034
|
registerAuthenticationHandlers(disposables);
|
|
@@ -200113,11 +201094,6 @@ ${retryMessage}`
|
|
|
200113
201094
|
void env.openExternal(Uri.parse(ACCOUNT_LIMITS_INFO_URL.toString()));
|
|
200114
201095
|
}
|
|
200115
201096
|
}
|
|
200116
|
-
),
|
|
200117
|
-
// Walkthrough / Support
|
|
200118
|
-
commands$1.registerCommand(
|
|
200119
|
-
"cody.feedback",
|
|
200120
|
-
() => env.openExternal(Uri.parse(CODY_FEEDBACK_URL.href))
|
|
200121
201097
|
)
|
|
200122
201098
|
);
|
|
200123
201099
|
}
|
|
@@ -200133,7 +201109,7 @@ async function registerCodyCommands({
|
|
|
200133
201109
|
if (error instanceof Error) {
|
|
200134
201110
|
console.log(error.stack);
|
|
200135
201111
|
}
|
|
200136
|
-
logError
|
|
201112
|
+
outputChannelLogger.logError("executeCommand", commandKey, args2, error);
|
|
200137
201113
|
return void 0;
|
|
200138
201114
|
});
|
|
200139
201115
|
};
|
|
@@ -200409,7 +201385,7 @@ function registerAutocomplete(platform2, statusBar, disposables) {
|
|
|
200409
201385
|
}),
|
|
200410
201386
|
catchError$1((error) => {
|
|
200411
201387
|
finishLoading();
|
|
200412
|
-
logError
|
|
201388
|
+
outputChannelLogger.logError("registerAutocomplete", "Error", error);
|
|
200413
201389
|
return NEVER$1;
|
|
200414
201390
|
})
|
|
200415
201391
|
).subscribe({})
|
|
@@ -200441,7 +201417,10 @@ function registerChat({ context: context2, platform: platform2, chatClient, guar
|
|
|
200441
201417
|
window$1.registerWebviewPanelSerializer(CodyChatEditorViewType, {
|
|
200442
201418
|
async deserializeWebviewPanel(webviewPanel, chatID) {
|
|
200443
201419
|
if (chatID && webviewPanel.title) {
|
|
200444
|
-
logDebug(
|
|
201420
|
+
outputChannelLogger.logDebug(
|
|
201421
|
+
"main:deserializeWebviewPanel",
|
|
201422
|
+
"reviving last unclosed chat panel"
|
|
201423
|
+
);
|
|
200445
201424
|
await chatsController.restoreToPanel(webviewPanel, chatID);
|
|
200446
201425
|
}
|
|
200447
201426
|
}
|
|
@@ -202168,5 +203147,95 @@ agent.registerNotification("debug/message", (params) => {
|
|
|
202168
203147
|
});
|
|
202169
203148
|
conn.listen();
|
|
202170
203149
|
export {
|
|
202171
|
-
|
|
203150
|
+
getCompletionsModelConfig as $,
|
|
203151
|
+
ANSWER_TOKENS as A,
|
|
203152
|
+
BotResponseMultiplexer as B,
|
|
203153
|
+
CompletionStopReason as C,
|
|
203154
|
+
DEFAULT_EVENT_SOURCE as D,
|
|
203155
|
+
EventSourceTelemetryMetadataMapping as E,
|
|
203156
|
+
FIXTURE_MODEL as F,
|
|
203157
|
+
PromptMixin as G,
|
|
203158
|
+
newPromptMixin as H,
|
|
203159
|
+
truncateTextNearestLine as I,
|
|
203160
|
+
truncatePromptStringStart as J,
|
|
203161
|
+
truncatePromptString as K,
|
|
203162
|
+
SourcegraphBrowserCompletionsClient as L,
|
|
203163
|
+
ModelUsage as M,
|
|
203164
|
+
NUM_CODE_RESULTS as N,
|
|
203165
|
+
Ollama$1 as O,
|
|
203166
|
+
ProcessType as P,
|
|
203167
|
+
SourcegraphCompletionsClient as Q,
|
|
203168
|
+
ClientConfigSingleton as R,
|
|
203169
|
+
SourcegraphGuardrailsClient as S,
|
|
203170
|
+
Typewriter as T,
|
|
203171
|
+
RestClient as U,
|
|
203172
|
+
events$1 as V,
|
|
203173
|
+
TokenCounter as W,
|
|
203174
|
+
getTokenCounterUtils as X,
|
|
203175
|
+
TokenCounterUtils as Y,
|
|
203176
|
+
tokensToChars as Z,
|
|
203177
|
+
charsToTokens as _,
|
|
203178
|
+
createModel as a,
|
|
203179
|
+
getSerializedParams as a0,
|
|
203180
|
+
fetchLocalOllamaModels as a1,
|
|
203181
|
+
siteVersion as a2,
|
|
203182
|
+
currentSiteVersion as a3,
|
|
203183
|
+
isValidVersion as a4,
|
|
203184
|
+
checkVersion as a5,
|
|
203185
|
+
configOverwrites as a6,
|
|
203186
|
+
createRuleService as a7,
|
|
203187
|
+
isRulesEnabled as a8,
|
|
203188
|
+
ModelsService as a9,
|
|
203189
|
+
editorWindowIsFocused as aA,
|
|
203190
|
+
modelsService as aa,
|
|
203191
|
+
TestLocalStorageForModelPreferences as ab,
|
|
203192
|
+
mockModelsService as ac,
|
|
203193
|
+
codyPaths as ad,
|
|
203194
|
+
populateCodeContextTemplate as ae,
|
|
203195
|
+
populateCurrentEditorDiagnosticsTemplate as af,
|
|
203196
|
+
populateTerminalOutputContextTemplate as ag,
|
|
203197
|
+
populateCurrentSelectedCodeContextTemplate as ah,
|
|
203198
|
+
populateListOfFilesContextTemplate as ai,
|
|
203199
|
+
populateContextTemplateFromText as aj,
|
|
203200
|
+
populateImportListContextTemplate as ak,
|
|
203201
|
+
populateCodeGenerationContextTemplate as al,
|
|
203202
|
+
getClientPromptString as am,
|
|
203203
|
+
InvisibleStatusBarTag as an,
|
|
203204
|
+
dotcomTokenToGatewayToken as ao,
|
|
203205
|
+
getCodyAuthReferralCode as ap,
|
|
203206
|
+
createSSEIterator as aq,
|
|
203207
|
+
googleChatClient as ar,
|
|
203208
|
+
groqChatClient as as,
|
|
203209
|
+
parseCompletionJSON as at,
|
|
203210
|
+
ContextFiltersProvider as au,
|
|
203211
|
+
getContextForChatMessage as av,
|
|
203212
|
+
Mutable as aw,
|
|
203213
|
+
singletonNotYetSet as ax,
|
|
203214
|
+
setSingleton as ay,
|
|
203215
|
+
setEditorWindowIsFocused as az,
|
|
203216
|
+
base64Js as b,
|
|
203217
|
+
contextFiltersProvider as c,
|
|
203218
|
+
createModelFromServerModel as d,
|
|
203219
|
+
enableMapSet as e,
|
|
203220
|
+
getModelInfo as f,
|
|
203221
|
+
getProviderName as g,
|
|
203222
|
+
handleRateLimitError as h,
|
|
203223
|
+
isCustomModel as i,
|
|
203224
|
+
toModelRefStr as j,
|
|
203225
|
+
ChatClient as k,
|
|
203226
|
+
getDefaultSystemPrompt as l,
|
|
203227
|
+
modelTier as m,
|
|
203228
|
+
getChatPreamble as n,
|
|
203229
|
+
getSimplePreamble as o,
|
|
203230
|
+
parseModelRef as p,
|
|
203231
|
+
errorToChatError as q,
|
|
203232
|
+
parseEvents as r,
|
|
203233
|
+
serializeChatMessage as s,
|
|
203234
|
+
toLegacyModel as t,
|
|
203235
|
+
ollamaChatClient as u,
|
|
203236
|
+
OLLAMA_DEFAULT_URL as v,
|
|
203237
|
+
MAX_BYTES_PER_FILE as w,
|
|
203238
|
+
MAX_CURRENT_FILE_TOKENS as x,
|
|
203239
|
+
NUM_TEXT_RESULTS as y,
|
|
203240
|
+
SURROUNDING_LINES as z
|
|
202172
203241
|
};
|