🪄 model dropdown, control plane (#1692)
* Nate/control plane client (#1691) * docs: add docs and schema for "OS" provider (#1536) * ignore .env * fix(gui): ctx rendering w/ renderInlineAs: "" (#1541) * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * fix codeqwen autocomplete leading space * add voyage rerank-1 * feat: `--noEmit` for tsc checks in CI (#1559) * docs: update CustomContextProvider docs (#1557) * add stop tokens to qwen prompt * update docs to reflect 3.5 sonnet being best * docs: comment out unused providers (#1561) * import Handlebars * feat: toast notification for config updates (#1560) * feat: toast notification for config updates * feat: only trigger toast on config.json save * displayRawMarkdown option * feat: open pane on install (#1564) * feat: open pane on activation * comment out testing code * update to reflect 16 stop words limit for deepseek * feat: only trigger config update toast in vscode (#1571) * docs(prompt-files): fix typos + clarify (#1575) * doc: prompt file typo + clarifications * fix: add back correct docs * chore: add telemetry for pageviews (#1576) * feat: update onboarding w/ embeddings model (#1570) * chore(gui): remove unused pages * feat: add embeddings step * feat: update styles * feat: copy button updates * fix: correct pull command for embed model * fix: remove commented code * fix: remove commented code * feat: simplify copy btn props * chore: rename onboarding selection event * feat: add provider config * fix: undo msg name * remove dead code * fix: invalid mode check * fix: remove testing logic * docs(telemetry): add pageviews to tracking list (#1581) * Add reranker configuration options to codebase embedding docs (#1584) - Introduce reranker concept - List available reranker options - Provide configuration instructions - Update keywords to include "reranker" * chore: update pr template with screenshots (#1590) * Refactor ConfirmationDialog to use SecondaryButton for cancel action (#1586) * Added instructions for running docs server locally (#1578) - Added NPM script method - Added VS Code task method - Update contributing guidelines * Update branch policy (#1577) - Change PR target to `dev` branch - Update `CONTRIBUTING.md` instructions * Consolidate example configurations into the main configuration guide (#1579) - Moved examples to configuration.md - Deleted the separate examples.md file - Updated sidebar order and links - Improved readability and structure in configuration.md * fix: fullscreen gui retains context when hidden, fixed fullscreen focusing (#1582) * Update completionProvider.ts (warning tab-autocomplete models) (#1566) * feat: enhanced IndexingProgressBar with blinking dot feature - Integrated BlinkingDot component - Added STATUS_COLORS for various states - Replaced CircleDiv with BlinkingDot in UI - Updated status messages and layout * small UI tweaks * feat(gui): enhance ModelCard, ModelProviderTag, and Toggle components (#1595) - add styling and adjustments to ModelCard - update ModelProviderTag font size - remove box shadow from Toggle component - tweak icon styles in ModelCard - improve alignment and spacing * media query * feat: add best experience onboarding * fix: file rename * stop movement on button hover by keeping same border thickness * fix mistake in setting cursor: pointer * fix when free trial option is shown * Support Node.js versions below 20 for streaming response handling (#1591) - Add fallback for Node < 20 - Implement toAsyncIterable for streaming - Use TextDecoder for manual decoding - Maintain existing streaming for Node 20+ * small fixes * feat: add free trial card to onboarding (#1600) * feat: add free trial card to onboarding * add import * fix hasPassedFTL * fix /edit cancellation from UI * feat: add `applyCodeBlock` experimental prop (#1601) * feat: add new model styling improvements (#1609) * feat: add new model styling improvements * better gap size * feat: update bug_report.yml (#1610) * chore: update bug_report.yml * typo fix * feat: add labels to "Add docs" dialog (#1612) * feat: add labels to "Add docs" dialog * remove autofocus * don't double load config * small fixes * speed up directory traversal, and use correct native path module * option not to show config update toast * merge air-gapped and recommended setup pages * chore: add telemetry for full screen toggle (#1618) * Fix headings in codebase-embeddings.md (#1617) * mention jetbrains * docs: update changie (#1619) * feat: updated changie config * hide toc and autogenerate * Update changelog.mdx * link to deeper explanation of embeddings models * ensure target="_blank" for all links in sidebar * fix gif links in intellij README.md * don't require rust in dependency installation * chore: fix padding on gh button (#1620) * chore: adjust button padding * Update tasks.json * escape colons in diff path * smoother lancedb indexing reporting * smooth progress updates for indexing * fix tsc err * rerank-lite-1 * remove doccs * basic tests for VS Code extension * improved testing of VS Code extension * docs: add docs and schema for "OS" provider (#1536) * ignore .env * 🚑 fix constant warnings when onboarding with Ollama * ✨ use and cache imports for autocomplete (#1456) * ✨ use and cache imports for autocomplete * fix tsc * team analytics * apply control plane settings * workos auth * ide protocol get session info * UI for auth * profile switching * small fixes * updates * refresh tokens * updates * fix tsc errs * model select in toolbar to make room for profile selector * prod client id * link to prod URL * internal beta option * profiles change listener --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> * temporary patch for type errs --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com> Co-authored-by: Priyash <38959321+priyashpatil@users.noreply.github.com> Co-authored-by: Jonah Wagner <jonahwagner231@gmail.com> Co-authored-by: YohannZe <99359799+YohannZe@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com>
This commit is contained in:
parent
875ab4cdcc
commit
ff57b0080d
72 changed files with 2395 additions and 475 deletions
24
.github/workflows/main.yaml
vendored
24
.github/workflows/main.yaml
vendored
|
|
@ -125,19 +125,19 @@ jobs:
|
|||
|
||||
# 4. Run tests for the extension
|
||||
# - name: Install Xvfb for Linux and run tests
|
||||
# run: |
|
||||
# sudo apt-get install -y xvfb # Install Xvfb
|
||||
# Xvfb :99 & # Start Xvfb
|
||||
# export DISPLAY=:99 # Export the display number to the environment
|
||||
# cd extensions/vscode
|
||||
# npm run test
|
||||
# if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get install -y xvfb # Install Xvfb
|
||||
Xvfb :99 & # Start Xvfb
|
||||
export DISPLAY=:99 # Export the display number to the environment
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
# - name: Run extension tests
|
||||
# run: |
|
||||
# cd extensions/vscode
|
||||
# npm run test
|
||||
# if: matrix.os != 'ubuntu-latest'
|
||||
- name: Run extension tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
|
||||
# 5. Package the extension
|
||||
- name: Package the extension
|
||||
|
|
|
|||
10
.github/workflows/preview.yaml
vendored
10
.github/workflows/preview.yaml
vendored
|
|
@ -124,11 +124,11 @@ jobs:
|
|||
# npm run test
|
||||
# if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
# - name: Run extension tests
|
||||
# run: |
|
||||
# cd extensions/vscode
|
||||
# npm run test
|
||||
# if: matrix.os != 'ubuntu-latest'
|
||||
- name: Run extension tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
npm run test
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
|
||||
# 5. Package the extension
|
||||
- name: Package the extension
|
||||
|
|
|
|||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
|
@ -12,7 +12,9 @@
|
|||
// To bundle the code the same way we do for publishing
|
||||
"vscode-extension:esbuild",
|
||||
// Start the React app that is used in the extension
|
||||
"gui:dev"
|
||||
"gui:dev",
|
||||
// Start the docs site, without opening the browser
|
||||
"docs:start"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ describe("Test Suite", () => {
|
|||
|
||||
// Many of the files are only created when trying to load the config
|
||||
const config = await messenger.request(
|
||||
"config/getBrowserSerialized",
|
||||
"config/getSerializedProfileInfo",
|
||||
undefined,
|
||||
);
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ describe("Test Suite", () => {
|
|||
});
|
||||
|
||||
it("should properly edit config", async () => {
|
||||
const config = await messenger.request(
|
||||
"config/getBrowserSerialized",
|
||||
const { config } = await messenger.request(
|
||||
"config/getSerializedProfileInfo",
|
||||
undefined,
|
||||
);
|
||||
expect(config).toHaveProperty("models");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import Handlebars from "handlebars";
|
||||
import ignore from "ignore";
|
||||
import OpenAI from "openai";
|
||||
import path from "path";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { RangeInFileWithContents } from "../commands/util.js";
|
||||
import { IConfigHandler } from "../config/IConfigHandler.js";
|
||||
import { ConfigHandler } from "../config/ConfigHandler.js";
|
||||
import { TRIAL_FIM_MODEL } from "../config/onboarding.js";
|
||||
import { streamLines } from "../diff/util.js";
|
||||
import {
|
||||
|
|
@ -145,7 +144,7 @@ export class CompletionProvider {
|
|||
private static lastUUID: string | undefined = undefined;
|
||||
|
||||
constructor(
|
||||
private readonly configHandler: IConfigHandler,
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly getLlm: () => Promise<ILLM | undefined>,
|
||||
private readonly _onError: (e: any) => void,
|
||||
|
|
@ -201,13 +200,17 @@ export class CompletionProvider {
|
|||
const outcome = this._outcomes.get(completionId)!;
|
||||
outcome.accepted = true;
|
||||
logDevData("autocomplete", outcome);
|
||||
Telemetry.capture("autocomplete", {
|
||||
accepted: outcome.accepted,
|
||||
modelName: outcome.modelName,
|
||||
modelProvider: outcome.modelProvider,
|
||||
time: outcome.time,
|
||||
cacheHit: outcome.cacheHit,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"autocomplete",
|
||||
{
|
||||
accepted: outcome.accepted,
|
||||
modelName: outcome.modelName,
|
||||
modelProvider: outcome.modelProvider,
|
||||
time: outcome.time,
|
||||
cacheHit: outcome.cacheHit,
|
||||
},
|
||||
true,
|
||||
);
|
||||
this._outcomes.delete(completionId);
|
||||
|
||||
this.bracketMatchingService.handleAcceptedCompletion(
|
||||
|
|
@ -358,9 +361,13 @@ export class CompletionProvider {
|
|||
outcome.accepted = false;
|
||||
logDevData("autocomplete", outcome);
|
||||
const { prompt, completion, ...restOfOutcome } = outcome;
|
||||
Telemetry.capture("autocomplete", {
|
||||
...restOfOutcome,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"autocomplete",
|
||||
{
|
||||
...restOfOutcome,
|
||||
},
|
||||
true,
|
||||
);
|
||||
this._logRejectionTimeouts.delete(completionId);
|
||||
}, COUNT_COMPLETION_REJECTED_AFTER);
|
||||
this._outcomes.set(completionId, outcome);
|
||||
|
|
|
|||
|
|
@ -1,116 +1,251 @@
|
|||
import { ControlPlaneClient } from "../control-plane/client.js";
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
IdeSettings,
|
||||
ILLM,
|
||||
} from "../index.js";
|
||||
import { Telemetry } from "../util/posthog.js";
|
||||
import { IConfigHandler } from "./IConfigHandler.js";
|
||||
import { finalToBrowserConfig, loadFullConfigNode } from "./load.js";
|
||||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
import { finalToBrowserConfig } from "./load.js";
|
||||
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
|
||||
import { IProfileLoader } from "./profile/IProfileLoader.js";
|
||||
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
|
||||
|
||||
export class ConfigHandler implements IConfigHandler {
|
||||
export interface ProfileDescription {
|
||||
title: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
// Separately manages saving/reloading each profile
|
||||
class ProfileLifecycleManager {
|
||||
private savedConfig: ContinueConfig | undefined;
|
||||
private savedBrowserConfig?: BrowserSerializedContinueConfig;
|
||||
private pendingConfigPromise?: Promise<ContinueConfig>;
|
||||
|
||||
constructor(private readonly profileLoader: IProfileLoader) {}
|
||||
|
||||
get profileId() {
|
||||
return this.profileLoader.profileId;
|
||||
}
|
||||
|
||||
get profileTitle() {
|
||||
return this.profileLoader.profileTitle;
|
||||
}
|
||||
|
||||
get profileDescription(): ProfileDescription {
|
||||
return {
|
||||
title: this.profileTitle,
|
||||
id: this.profileId,
|
||||
};
|
||||
}
|
||||
|
||||
clearConfig() {
|
||||
this.savedConfig = undefined;
|
||||
this.savedBrowserConfig = undefined;
|
||||
this.pendingConfigPromise = undefined;
|
||||
}
|
||||
|
||||
// Clear saved config and reload
|
||||
reloadConfig(): Promise<ContinueConfig> {
|
||||
this.savedConfig = undefined;
|
||||
this.savedBrowserConfig = undefined;
|
||||
this.pendingConfigPromise = undefined;
|
||||
|
||||
return this.profileLoader.doLoadConfig();
|
||||
}
|
||||
|
||||
async loadConfig(
|
||||
additionalContextProviders: IContextProvider[],
|
||||
): Promise<ContinueConfig> {
|
||||
// If we already have a config, return it
|
||||
if (this.savedConfig) {
|
||||
return this.savedConfig;
|
||||
} else if (this.pendingConfigPromise) {
|
||||
return this.pendingConfigPromise;
|
||||
}
|
||||
|
||||
// Set pending config promise
|
||||
this.pendingConfigPromise = new Promise(async (resolve, reject) => {
|
||||
const newConfig = await this.profileLoader.doLoadConfig();
|
||||
|
||||
// Add registered context providers
|
||||
newConfig.contextProviders = (newConfig.contextProviders ?? []).concat(
|
||||
additionalContextProviders,
|
||||
);
|
||||
|
||||
this.savedConfig = newConfig;
|
||||
resolve(newConfig);
|
||||
});
|
||||
|
||||
// Wait for the config promise to resolve
|
||||
this.savedConfig = await this.pendingConfigPromise;
|
||||
this.pendingConfigPromise = undefined;
|
||||
return this.savedConfig;
|
||||
}
|
||||
|
||||
async getSerializedConfig(
|
||||
additionalContextProviders: IContextProvider[],
|
||||
): Promise<BrowserSerializedContinueConfig> {
|
||||
if (!this.savedBrowserConfig) {
|
||||
const continueConfig = await this.loadConfig(additionalContextProviders);
|
||||
this.savedBrowserConfig = finalToBrowserConfig(continueConfig);
|
||||
}
|
||||
return this.savedBrowserConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfigHandler {
|
||||
private readonly globalContext = new GlobalContext();
|
||||
private additionalContextProviders: IContextProvider[] = [];
|
||||
private profiles: ProfileLifecycleManager[];
|
||||
private selectedProfileId: string;
|
||||
|
||||
// This will be the local profile
|
||||
private get fallbackProfile() {
|
||||
return this.profiles[0];
|
||||
}
|
||||
|
||||
get currentProfile() {
|
||||
return (
|
||||
this.profiles.find((p) => p.profileId === this.selectedProfileId) ??
|
||||
this.fallbackProfile
|
||||
);
|
||||
}
|
||||
|
||||
get inactiveProfiles() {
|
||||
return this.profiles.filter((p) => p.profileId !== this.selectedProfileId);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
private readonly writeLog: (text: string) => Promise<void>,
|
||||
private readonly controlPlaneClient: ControlPlaneClient,
|
||||
) {
|
||||
this.ide = ide;
|
||||
this.ideSettingsPromise = ideSettingsPromise;
|
||||
this.writeLog = writeLog;
|
||||
|
||||
// Set local profile as default
|
||||
const localProfileLoader = new LocalProfileLoader(
|
||||
ide,
|
||||
ideSettingsPromise,
|
||||
writeLog,
|
||||
);
|
||||
this.profiles = [new ProfileLifecycleManager(localProfileLoader)];
|
||||
this.selectedProfileId = localProfileLoader.profileId;
|
||||
|
||||
// Always load local profile immediately in case control plane doesn't load
|
||||
try {
|
||||
this.loadConfig();
|
||||
} catch (e) {
|
||||
console.error("Failed to load config: ", e);
|
||||
}
|
||||
|
||||
// Load control plane profiles
|
||||
// TODO
|
||||
// Get the profiles and create their lifecycle managers
|
||||
this.controlPlaneClient.listWorkspaces().then(async (workspaces) => {
|
||||
workspaces.forEach((workspace) => {
|
||||
const profileLoader = new ControlPlaneProfileLoader(
|
||||
workspace.id,
|
||||
workspace.name,
|
||||
this.controlPlaneClient,
|
||||
ide,
|
||||
ideSettingsPromise,
|
||||
writeLog,
|
||||
this.reloadConfig.bind(this),
|
||||
);
|
||||
this.profiles.push(new ProfileLifecycleManager(profileLoader));
|
||||
});
|
||||
|
||||
this.notifyProfileListeners(
|
||||
this.profiles.map((profile) => profile.profileDescription),
|
||||
);
|
||||
|
||||
// Check the last selected workspace, and reload if it isn't local
|
||||
const workspaceId = await this.getWorkspaceId();
|
||||
const lastSelectedWorkspaceIds =
|
||||
this.globalContext.get("lastSelectedProfileForWorkspace") ?? {};
|
||||
const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId];
|
||||
if (selectedWorkspaceId) {
|
||||
this.selectedProfileId = selectedWorkspaceId;
|
||||
this.loadConfig();
|
||||
} else {
|
||||
// Otherwise we stick with local profile, and record choice
|
||||
lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId;
|
||||
this.globalContext.update(
|
||||
"lastSelectedProfileForWorkspace",
|
||||
lastSelectedWorkspaceIds,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async setSelectedProfile(profileId: string) {
|
||||
this.selectedProfileId = profileId;
|
||||
const newConfig = await this.loadConfig();
|
||||
this.notifyConfigListerners(newConfig);
|
||||
}
|
||||
|
||||
// A unique ID for the current workspace, built from folder names
|
||||
private async getWorkspaceId(): Promise<string> {
|
||||
const dirs = await this.ide.getWorkspaceDirs();
|
||||
return dirs.join("&");
|
||||
}
|
||||
|
||||
// Automatically refresh config when Continue-related IDE (e.g. VS Code) settings are changed
|
||||
updateIdeSettings(ideSettings: IdeSettings) {
|
||||
this.ideSettingsPromise = Promise.resolve(ideSettings);
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
private profilesListeners: ((profiles: ProfileDescription[]) => void)[] = [];
|
||||
onDidChangeAvailableProfiles(
|
||||
listener: (profiles: ProfileDescription[]) => void,
|
||||
) {
|
||||
this.profilesListeners.push(listener);
|
||||
}
|
||||
|
||||
private notifyProfileListeners(profiles: ProfileDescription[]) {
|
||||
for (const listener of this.profilesListeners) {
|
||||
listener(profiles);
|
||||
}
|
||||
}
|
||||
|
||||
private notifyConfigListerners(newConfig: ContinueConfig) {
|
||||
// Notify listeners that config changed
|
||||
for (const listener of this.updateListeners) {
|
||||
listener(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private updateListeners: ((newConfig: ContinueConfig) => void)[] = [];
|
||||
onConfigUpdate(listener: (newConfig: ContinueConfig) => void) {
|
||||
this.updateListeners.push(listener);
|
||||
}
|
||||
|
||||
async reloadConfig() {
|
||||
this.savedConfig = undefined;
|
||||
this.savedBrowserConfig = undefined;
|
||||
this._pendingConfigPromise = undefined;
|
||||
|
||||
const newConfig = await this.loadConfig();
|
||||
|
||||
for (const listener of this.updateListeners) {
|
||||
listener(newConfig);
|
||||
}
|
||||
// TODO: this isn't right, there are two different senses in which you want to "reload"
|
||||
const newConfig = await this.currentProfile.reloadConfig();
|
||||
this.inactiveProfiles.forEach((profile) => profile.clearConfig());
|
||||
this.notifyConfigListerners(newConfig);
|
||||
}
|
||||
|
||||
async getSerializedConfig(): Promise<BrowserSerializedContinueConfig> {
|
||||
if (!this.savedBrowserConfig) {
|
||||
this.savedConfig = await this.loadConfig();
|
||||
this.savedBrowserConfig = finalToBrowserConfig(this.savedConfig);
|
||||
}
|
||||
return this.savedBrowserConfig;
|
||||
getSerializedConfig(): Promise<BrowserSerializedContinueConfig> {
|
||||
return this.currentProfile.getSerializedConfig(
|
||||
this.additionalContextProviders,
|
||||
);
|
||||
}
|
||||
|
||||
listProfiles(): ProfileDescription[] {
|
||||
return this.profiles.map((p) => p.profileDescription);
|
||||
}
|
||||
|
||||
private _pendingConfigPromise?: Promise<ContinueConfig>;
|
||||
async loadConfig(): Promise<ContinueConfig> {
|
||||
if (this.savedConfig) {
|
||||
return this.savedConfig;
|
||||
} else if (this._pendingConfigPromise) {
|
||||
return this._pendingConfigPromise;
|
||||
}
|
||||
|
||||
this._pendingConfigPromise = new Promise(async (resolve, reject) => {
|
||||
let workspaceConfigs: ContinueRcJson[] = [];
|
||||
try {
|
||||
workspaceConfigs = await this.ide.getWorkspaceConfigs();
|
||||
} catch (e) {
|
||||
console.warn("Failed to load workspace configs");
|
||||
}
|
||||
|
||||
const ideInfo = await this.ide.getIdeInfo();
|
||||
const uniqueId = await this.ide.getUniqueId();
|
||||
const ideSettings = await this.ideSettingsPromise;
|
||||
|
||||
const newConfig = await loadFullConfigNode(
|
||||
this.ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
this.writeLog,
|
||||
);
|
||||
newConfig.allowAnonymousTelemetry =
|
||||
newConfig.allowAnonymousTelemetry &&
|
||||
(await this.ide.isTelemetryEnabled());
|
||||
|
||||
// Setup telemetry only after (and if) we know it is enabled
|
||||
await Telemetry.setup(
|
||||
newConfig.allowAnonymousTelemetry ?? true,
|
||||
await this.ide.getUniqueId(),
|
||||
ideInfo.extensionVersion,
|
||||
);
|
||||
|
||||
(newConfig.contextProviders ?? []).push(
|
||||
...this.additionalContextProviders,
|
||||
);
|
||||
|
||||
this.savedConfig = newConfig;
|
||||
resolve(newConfig);
|
||||
});
|
||||
|
||||
this.savedConfig = await this._pendingConfigPromise;
|
||||
this._pendingConfigPromise = undefined;
|
||||
return this.savedConfig;
|
||||
return this.currentProfile.loadConfig(this.additionalContextProviders);
|
||||
}
|
||||
|
||||
async llmFromTitle(title?: string): Promise<ILLM> {
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
IContextProvider,
|
||||
IdeSettings,
|
||||
ILLM,
|
||||
} from "../index.js";
|
||||
|
||||
export interface IConfigHandler {
|
||||
updateIdeSettings(ideSettings: IdeSettings): void;
|
||||
onConfigUpdate(listener: (newConfig: ContinueConfig) => void): void;
|
||||
reloadConfig(): Promise<void>;
|
||||
getSerializedConfig(): Promise<BrowserSerializedContinueConfig>;
|
||||
loadConfig(): Promise<ContinueConfig>;
|
||||
llmFromTitle(title?: string): Promise<ILLM>;
|
||||
registerCustomContextProvider(contextProvider: IContextProvider): void;
|
||||
}
|
||||
|
|
@ -46,7 +46,6 @@ import {
|
|||
getConfigJsonPathForRemote,
|
||||
getConfigTsPath,
|
||||
getContinueDotEnv,
|
||||
migrate,
|
||||
readAllGlobalPromptFiles,
|
||||
} from "../util/paths.js";
|
||||
import {
|
||||
|
|
@ -108,19 +107,6 @@ function loadSerializedConfig(
|
|||
config.allowAnonymousTelemetry = true;
|
||||
}
|
||||
|
||||
migrate("codeContextProvider", () => {
|
||||
const gpt = config.models.find(
|
||||
(model) =>
|
||||
model.model.startsWith("gpt-4") && model.provider === "free-trial",
|
||||
);
|
||||
if (gpt) {
|
||||
gpt.systemMessage =
|
||||
"You are an expert software developer. You give helpful and concise responses.";
|
||||
}
|
||||
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, undefined, 2), "utf8");
|
||||
});
|
||||
|
||||
if (ideSettings.remoteConfigServerUrl) {
|
||||
try {
|
||||
const remoteConfigJson = resolveSerializedConfig(
|
||||
|
|
@ -157,6 +143,7 @@ function loadSerializedConfig(
|
|||
async function serializedToIntermediateConfig(
|
||||
initial: SerializedContinueConfig,
|
||||
ide: IDE,
|
||||
loadPromptFiles: boolean = true,
|
||||
): Promise<Config> {
|
||||
const slashCommands: SlashCommand[] = [];
|
||||
for (const command of initial.slashCommands || []) {
|
||||
|
|
@ -172,25 +159,27 @@ async function serializedToIntermediateConfig(
|
|||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
const promptFolder = initial.experimental?.promptPath;
|
||||
|
||||
let promptFiles: { path: string; content: string }[] = [];
|
||||
promptFiles = (
|
||||
await Promise.all(
|
||||
workspaceDirs.map((dir) =>
|
||||
getPromptFiles(
|
||||
ide,
|
||||
path.join(dir, promptFolder ?? DEFAULT_PROMPTS_FOLDER),
|
||||
if (loadPromptFiles) {
|
||||
let promptFiles: { path: string; content: string }[] = [];
|
||||
promptFiles = (
|
||||
await Promise.all(
|
||||
workspaceDirs.map((dir) =>
|
||||
getPromptFiles(
|
||||
ide,
|
||||
path.join(dir, promptFolder ?? DEFAULT_PROMPTS_FOLDER),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
.flat()
|
||||
.filter(({ path }) => path.endsWith(".prompt"));
|
||||
.flat()
|
||||
.filter(({ path }) => path.endsWith(".prompt"));
|
||||
|
||||
// Also read from ~/.continue/.prompts
|
||||
promptFiles.push(...readAllGlobalPromptFiles());
|
||||
// Also read from ~/.continue/.prompts
|
||||
promptFiles.push(...readAllGlobalPromptFiles());
|
||||
|
||||
for (const file of promptFiles) {
|
||||
slashCommands.push(slashCommandFromPromptFile(file.path, file.content));
|
||||
for (const file of promptFiles) {
|
||||
slashCommands.push(slashCommandFromPromptFile(file.path, file.content));
|
||||
}
|
||||
}
|
||||
|
||||
const config: Config = {
|
||||
|
|
@ -221,9 +210,10 @@ async function intermediateToFinalConfig(
|
|||
ideSettings: IdeSettings,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
allowFreeTrial: boolean = true,
|
||||
): Promise<ContinueConfig> {
|
||||
// Auto-detect models
|
||||
const models: BaseLLM[] = [];
|
||||
let models: BaseLLM[] = [];
|
||||
for (const desc of config.models) {
|
||||
if (isModelDescription(desc)) {
|
||||
const llm = await llmFromDescription(
|
||||
|
|
@ -304,15 +294,20 @@ async function intermediateToFinalConfig(
|
|||
};
|
||||
}
|
||||
|
||||
// Obtain auth token (only if free trial being used)
|
||||
const freeTrialModels = models.filter(
|
||||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
if (allowFreeTrial) {
|
||||
// Obtain auth token (iff free trial being used)
|
||||
const freeTrialModels = models.filter(
|
||||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove free trial models
|
||||
models = models.filter((model) => model.providerName !== "free-trial");
|
||||
}
|
||||
|
||||
// Tab autocomplete model
|
||||
|
|
@ -336,6 +331,10 @@ async function intermediateToFinalConfig(
|
|||
);
|
||||
|
||||
if (llm?.providerName === "free-trial") {
|
||||
if (!allowFreeTrial) {
|
||||
// This shouldn't happen
|
||||
throw new Error("Free trial cannot be used with control plane");
|
||||
}
|
||||
const ghAuthToken = await ide.getGitHubAuthToken();
|
||||
(llm as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
|
|
@ -538,9 +537,13 @@ async function loadFullConfigNode(
|
|||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
): Promise<ContinueConfig> {
|
||||
// Serialized config
|
||||
let serialized = loadSerializedConfig(workspaceConfigs, ideSettings, ideType);
|
||||
|
||||
// Convert serialized to intermediate config
|
||||
let intermediate = await serializedToIntermediateConfig(serialized, ide);
|
||||
|
||||
// Apply config.ts to modify intermediate config
|
||||
const configJsContents = await buildConfigTs();
|
||||
if (configJsContents) {
|
||||
try {
|
||||
|
|
@ -557,7 +560,7 @@ async function loadFullConfigNode(
|
|||
}
|
||||
}
|
||||
|
||||
// Remote config.js
|
||||
// Apply remote config.js to modify intermediate config
|
||||
if (ideSettings.remoteConfigServerUrl) {
|
||||
try {
|
||||
const configJsPathForRemote = getConfigJsPathForRemote(
|
||||
|
|
@ -574,6 +577,7 @@ async function loadFullConfigNode(
|
|||
}
|
||||
}
|
||||
|
||||
// Convert to final config format
|
||||
const finalConfig = await intermediateToFinalConfig(
|
||||
intermediate,
|
||||
ide,
|
||||
|
|
|
|||
101
core/config/profile/ControlPlaneProfileLoader.ts
Normal file
101
core/config/profile/ControlPlaneProfileLoader.ts
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import {
|
||||
ContinueConfig,
|
||||
IDE,
|
||||
IdeSettings,
|
||||
SerializedContinueConfig,
|
||||
} from "../..";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { ControlPlaneSettings } from "../../control-plane/schema";
|
||||
import { TeamAnalytics } from "../../control-plane/TeamAnalytics";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "../default";
|
||||
import {
|
||||
intermediateToFinalConfig,
|
||||
serializedToIntermediateConfig,
|
||||
} from "../load";
|
||||
import { IProfileLoader } from "./IProfileLoader";
|
||||
|
||||
export default class ControlPlaneProfileLoader implements IProfileLoader {
|
||||
private static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes
|
||||
|
||||
readonly profileId: string;
|
||||
profileTitle: string;
|
||||
|
||||
workspaceSettings: ControlPlaneSettings | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly workspaceId: string,
|
||||
private workspaceTitle: string,
|
||||
private readonly controlPlaneClient: ControlPlaneClient,
|
||||
private readonly ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
private writeLog: (message: string) => Promise<void>,
|
||||
private readonly onReload: () => void,
|
||||
) {
|
||||
this.profileId = workspaceId;
|
||||
this.profileTitle = workspaceTitle;
|
||||
|
||||
setInterval(async () => {
|
||||
this.workspaceSettings =
|
||||
await this.controlPlaneClient.getSettingsForWorkspace(this.profileId);
|
||||
this.onReload();
|
||||
}, ControlPlaneProfileLoader.RELOAD_INTERVAL);
|
||||
}
|
||||
|
||||
async doLoadConfig(): Promise<ContinueConfig> {
|
||||
const ideInfo = await this.ide.getIdeInfo();
|
||||
const settings =
|
||||
this.workspaceSettings ??
|
||||
((await this.controlPlaneClient.getSettingsForWorkspace(
|
||||
this.profileId,
|
||||
)) as any);
|
||||
|
||||
// First construct a SerializedContinueConfig from the ControlPlaneSettings
|
||||
const serializedConfig: SerializedContinueConfig = {
|
||||
models: settings.models,
|
||||
tabAutocompleteModel: settings.tabAutocompleteModel,
|
||||
embeddingsProvider: settings.embeddingsModel,
|
||||
reranker: settings.reranker,
|
||||
};
|
||||
|
||||
serializedConfig.contextProviders ??=
|
||||
ideInfo.ideType === "vscode"
|
||||
? defaultContextProvidersVsCode
|
||||
: defaultContextProvidersJetBrains;
|
||||
serializedConfig.slashCommands ??=
|
||||
ideInfo.ideType === "vscode"
|
||||
? defaultSlashCommandsVscode
|
||||
: defaultSlashCommandsJetBrains;
|
||||
|
||||
const intermediateConfig = await serializedToIntermediateConfig(
|
||||
serializedConfig,
|
||||
this.ide,
|
||||
);
|
||||
|
||||
const uniqueId = await this.ide.getUniqueId();
|
||||
const finalConfig = await intermediateToFinalConfig(
|
||||
intermediateConfig,
|
||||
this.ide,
|
||||
await this.ideSettingsPromise,
|
||||
uniqueId,
|
||||
this.writeLog,
|
||||
);
|
||||
|
||||
// Set up team analytics/telemetry
|
||||
await Telemetry.setup(true, uniqueId, ideInfo.extensionVersion);
|
||||
await TeamAnalytics.setup(
|
||||
settings.analytics,
|
||||
uniqueId,
|
||||
ideInfo.extensionVersion,
|
||||
);
|
||||
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
}
|
||||
11
core/config/profile/IProfileLoader.ts
Normal file
11
core/config/profile/IProfileLoader.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// ProfileHandlers manage the loading of a config, allowing us to abstract over different ways of getting to a ContinueConfig
|
||||
|
||||
import { ContinueConfig } from "../..";
|
||||
|
||||
// After we have the ContinueConfig, the ConfigHandler takes care of everything else (loading models, lifecycle, etc.)
|
||||
export interface IProfileLoader {
|
||||
profileTitle: string;
|
||||
profileId: string;
|
||||
doLoadConfig(): Promise<ContinueConfig>;
|
||||
setIsActive(isActive: boolean): void;
|
||||
}
|
||||
53
core/config/profile/LocalProfileLoader.ts
Normal file
53
core/config/profile/LocalProfileLoader.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { ContinueConfig, ContinueRcJson, IDE, IdeSettings } from "../..";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { loadFullConfigNode } from "../load";
|
||||
import { IProfileLoader } from "./IProfileLoader";
|
||||
|
||||
export default class LocalProfileLoader implements IProfileLoader {
|
||||
static ID = "local";
|
||||
profileId = LocalProfileLoader.ID;
|
||||
profileTitle = "config.json";
|
||||
|
||||
constructor(
|
||||
private ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
// private controlPlaneClient: ControlPlaneClient,
|
||||
private writeLog: (message: string) => Promise<void>,
|
||||
) {}
|
||||
|
||||
async doLoadConfig(): Promise<ContinueConfig> {
|
||||
let workspaceConfigs: ContinueRcJson[] = [];
|
||||
try {
|
||||
workspaceConfigs = await this.ide.getWorkspaceConfigs();
|
||||
} catch (e) {
|
||||
console.warn("Failed to load workspace configs");
|
||||
}
|
||||
|
||||
const ideInfo = await this.ide.getIdeInfo();
|
||||
const uniqueId = await this.ide.getUniqueId();
|
||||
const ideSettings = await this.ideSettingsPromise;
|
||||
|
||||
const newConfig = await loadFullConfigNode(
|
||||
this.ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
this.writeLog,
|
||||
);
|
||||
newConfig.allowAnonymousTelemetry =
|
||||
newConfig.allowAnonymousTelemetry &&
|
||||
(await this.ide.isTelemetryEnabled());
|
||||
|
||||
// Setup telemetry only after (and if) we know it is enabled
|
||||
await Telemetry.setup(
|
||||
newConfig.allowAnonymousTelemetry ?? true,
|
||||
await this.ide.getUniqueId(),
|
||||
ideInfo.extensionVersion,
|
||||
);
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
}
|
||||
48
core/control-plane/TeamAnalytics.ts
Normal file
48
core/control-plane/TeamAnalytics.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import os from "node:os";
|
||||
import { ControlPlaneAnalytics } from "./schema";
|
||||
|
||||
export class TeamAnalytics {
|
||||
static client: any = undefined;
|
||||
static uniqueId = "NOT_UNIQUE";
|
||||
static os: string | undefined = undefined;
|
||||
static extensionVersion: string | undefined = undefined;
|
||||
|
||||
static async capture(event: string, properties: { [key: string]: any }) {
|
||||
TeamAnalytics.client?.capture({
|
||||
distinctId: TeamAnalytics.uniqueId,
|
||||
event,
|
||||
properties: {
|
||||
...properties,
|
||||
os: TeamAnalytics.os,
|
||||
extensionVersion: TeamAnalytics.extensionVersion,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static shutdownPosthogClient() {
|
||||
TeamAnalytics.client?.shutdown();
|
||||
}
|
||||
|
||||
static async setup(
|
||||
config: ControlPlaneAnalytics,
|
||||
uniqueId: string,
|
||||
extensionVersion: string,
|
||||
) {
|
||||
TeamAnalytics.uniqueId = uniqueId;
|
||||
TeamAnalytics.os = os.platform();
|
||||
TeamAnalytics.extensionVersion = extensionVersion;
|
||||
|
||||
if (!config || !config.clientKey || !config.url) {
|
||||
TeamAnalytics.client = undefined;
|
||||
} else {
|
||||
try {
|
||||
const { PostHog } = await import("posthog-node");
|
||||
TeamAnalytics.client = new PostHog(config.clientKey, {
|
||||
host: config.url,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(`Failed to setup telemetry: ${e}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
94
core/control-plane/client.ts
Normal file
94
core/control-plane/client.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
import { ModelDescription } from "..";
|
||||
import { ControlPlaneSettings } from "./schema";
|
||||
|
||||
export interface ControlPlaneSessionInfo {
|
||||
accessToken: string;
|
||||
account: {
|
||||
label: string;
|
||||
id: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ControlPlaneWorkspace {
|
||||
id: string;
|
||||
name: string;
|
||||
settings: ControlPlaneSettings;
|
||||
}
|
||||
|
||||
export interface ControlPlaneModelDescription extends ModelDescription {}
|
||||
|
||||
// export const CONTROL_PLANE_URL = "http://localhost:3001";
|
||||
export const CONTROL_PLANE_URL =
|
||||
"https://control-plane-api-service-i3dqylpbqa-uc.a.run.app";
|
||||
|
||||
export class ControlPlaneClient {
|
||||
private static URL = CONTROL_PLANE_URL;
|
||||
private static ACCESS_TOKEN_VALID_FOR_MS = 1000 * 60 * 5; // 5 minutes
|
||||
|
||||
private lastAccessTokenRefresh = 0;
|
||||
|
||||
constructor(
|
||||
private readonly sessionInfoPromise: Promise<
|
||||
ControlPlaneSessionInfo | undefined
|
||||
>,
|
||||
) {}
|
||||
|
||||
get userId(): Promise<string | undefined> {
|
||||
return this.sessionInfoPromise.then(
|
||||
(sessionInfo) => sessionInfo?.account.id,
|
||||
);
|
||||
}
|
||||
|
||||
private async getAccessToken(): Promise<string | undefined> {
|
||||
return (await this.sessionInfoPromise)?.accessToken;
|
||||
}
|
||||
|
||||
private async request(path: string, init: RequestInit): Promise<Response> {
|
||||
const accessToken = await this.getAccessToken();
|
||||
if (!accessToken) {
|
||||
throw new Error("No access token");
|
||||
}
|
||||
const resp = await fetch(new URL(path, ControlPlaneClient.URL).toString(), {
|
||||
...init,
|
||||
headers: {
|
||||
...init.headers,
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(
|
||||
`Control plane request failed: ${resp.status} ${await resp.text()}`,
|
||||
);
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async listWorkspaces(): Promise<ControlPlaneWorkspace[]> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const resp = await this.request(`/workspaces`, {
|
||||
method: "GET",
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
}
|
||||
|
||||
async getSettingsForWorkspace(
|
||||
workspaceId: string,
|
||||
): Promise<ControlPlaneSettings> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
}
|
||||
|
||||
const resp = await this.request(`/workspaces/${workspaceId}`, {
|
||||
method: "GET",
|
||||
});
|
||||
return ((await resp.json()) as any).settings;
|
||||
}
|
||||
}
|
||||
128
core/control-plane/schema.ts
Normal file
128
core/control-plane/schema.ts
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import { z } from "zod";
|
||||
|
||||
const modelDescriptionSchema = z.object({
|
||||
title: z.string(),
|
||||
provider: z.enum([
|
||||
"openai",
|
||||
"anthropic",
|
||||
"cohere",
|
||||
"ollama",
|
||||
"huggingface-tgi",
|
||||
"huggingface-inference-api",
|
||||
"replicate",
|
||||
"gemini",
|
||||
"mistral",
|
||||
"bedrock",
|
||||
"cloudflare",
|
||||
"azure",
|
||||
]),
|
||||
model: z.string(),
|
||||
apiKey: z.string().optional(),
|
||||
apiBase: z.string().optional(),
|
||||
contextLength: z.number().optional(),
|
||||
template: z
|
||||
.enum([
|
||||
"llama2",
|
||||
"alpaca",
|
||||
"zephyr",
|
||||
"phi2",
|
||||
"phind",
|
||||
"anthropic",
|
||||
"chatml",
|
||||
"none",
|
||||
"openchat",
|
||||
"deepseek",
|
||||
"xwin-coder",
|
||||
"neural-chat",
|
||||
"codellama-70b",
|
||||
"llava",
|
||||
"gemma",
|
||||
"llama3",
|
||||
])
|
||||
.optional(),
|
||||
completionOptions: z
|
||||
.object({
|
||||
temperature: z.number().optional(),
|
||||
topP: z.number().optional(),
|
||||
topK: z.number().optional(),
|
||||
minP: z.number().optional(),
|
||||
presencePenalty: z.number().optional(),
|
||||
frequencyPenalty: z.number().optional(),
|
||||
mirostat: z.number().optional(),
|
||||
stop: z.array(z.string()).optional(),
|
||||
maxTokens: z.number().optional(),
|
||||
numThreads: z.number().optional(),
|
||||
keepAlive: z.number().optional(),
|
||||
raw: z.boolean().optional(),
|
||||
stream: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
systemMessage: z.string().optional(),
|
||||
requestOptions: z
|
||||
.object({
|
||||
timeout: z.number().optional(),
|
||||
verifySsl: z.boolean().optional(),
|
||||
caBundlePath: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
proxy: z.string().optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
extraBodyProperties: z.record(z.any()).optional(),
|
||||
noProxy: z.array(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
promptTemplates: z.record(z.string()).optional(),
|
||||
});
|
||||
|
||||
const embeddingsProviderSchema = z.object({
|
||||
provider: z.enum([
|
||||
"transformers.js",
|
||||
"ollama",
|
||||
"openai",
|
||||
"cohere",
|
||||
"free-trial",
|
||||
"gemini",
|
||||
]),
|
||||
apiBase: z.string().optional(),
|
||||
apiKey: z.string().optional(),
|
||||
model: z.string().optional(),
|
||||
engine: z.string().optional(),
|
||||
apiType: z.string().optional(),
|
||||
apiVersion: z.string().optional(),
|
||||
requestOptions: z
|
||||
.object({
|
||||
timeout: z.number().optional(),
|
||||
verifySsl: z.boolean().optional(),
|
||||
caBundlePath: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
proxy: z.string().optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
extraBodyProperties: z.record(z.any()).optional(),
|
||||
noProxy: z.array(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const rerankerSchema = z.object({
|
||||
name: z.enum(["cohere", "voyage", "llm"]),
|
||||
params: z.record(z.any()).optional(),
|
||||
});
|
||||
|
||||
const analyticsSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
clientKey: z.string().optional(),
|
||||
});
|
||||
|
||||
export type ControlPlaneAnalytics = z.infer<typeof analyticsSchema>;
|
||||
|
||||
const devDataSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
});
|
||||
|
||||
export const controlPlaneSettingsSchema = z.object({
|
||||
models: z.array(modelDescriptionSchema),
|
||||
tabAutocompleteModel: modelDescriptionSchema,
|
||||
embeddingsModel: embeddingsProviderSchema,
|
||||
reranker: rerankerSchema,
|
||||
analytics: analyticsSchema,
|
||||
devData: devDataSchema,
|
||||
});
|
||||
|
||||
export type ControlPlaneSettings = z.infer<typeof controlPlaneSettingsSchema>;
|
||||
55
core/core.ts
55
core/core.ts
|
|
@ -7,7 +7,6 @@ import type {
|
|||
} from ".";
|
||||
import { CompletionProvider } from "./autocomplete/completionProvider.js";
|
||||
import { ConfigHandler } from "./config/ConfigHandler.js";
|
||||
import { IConfigHandler } from "./config/IConfigHandler";
|
||||
import {
|
||||
setupApiKeysMode,
|
||||
setupFreeTrialMode,
|
||||
|
|
@ -17,6 +16,7 @@ import {
|
|||
import { createNewPromptFile } from "./config/promptFile.js";
|
||||
import { addModel, addOpenAIKey, deleteModel } from "./config/util.js";
|
||||
import { ContinueServerClient } from "./continueServer/stubs/client.js";
|
||||
import { ControlPlaneClient } from "./control-plane/client";
|
||||
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer.js";
|
||||
import { DocsService } from "./indexing/docs/DocsService";
|
||||
import TransformersJsEmbeddingsProvider from "./indexing/embeddings/TransformersJsEmbeddingsProvider.js";
|
||||
|
|
@ -34,11 +34,12 @@ import { streamDiffLines } from "./util/verticalEdit.js";
|
|||
|
||||
export class Core {
|
||||
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
|
||||
configHandler: IConfigHandler;
|
||||
configHandler: ConfigHandler;
|
||||
codebaseIndexerPromise: Promise<CodebaseIndexer>;
|
||||
completionProvider: CompletionProvider;
|
||||
continueServerClientPromise: Promise<ContinueServerClient>;
|
||||
indexingState: IndexingProgressUpdate;
|
||||
controlPlaneClient: ControlPlaneClient;
|
||||
private globalContext = new GlobalContext();
|
||||
private docsService = DocsService.getInstance();
|
||||
private readonly indexingPauseToken = new PauseToken(
|
||||
|
|
@ -73,14 +74,22 @@ export class Core {
|
|||
) {
|
||||
this.indexingState = { status: "loading", desc: "loading", progress: 0 };
|
||||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
const sessionInfoPromise = messenger.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
});
|
||||
this.controlPlaneClient = new ControlPlaneClient(sessionInfoPromise);
|
||||
this.configHandler = new ConfigHandler(
|
||||
this.ide,
|
||||
ideSettingsPromise,
|
||||
this.onWrite,
|
||||
this.controlPlaneClient,
|
||||
);
|
||||
this.configHandler.onConfigUpdate(
|
||||
(() => this.messenger.send("configUpdate", undefined)).bind(this),
|
||||
);
|
||||
this.configHandler.onDidChangeAvailableProfiles((profiles) =>
|
||||
this.messenger.send("didChangeAvailableProfiles", { profiles }),
|
||||
);
|
||||
|
||||
// Codebase Indexer and ContinueServerClient depend on IdeSettings
|
||||
let codebaseIndexerResolve: (_: any) => void | undefined;
|
||||
|
|
@ -206,6 +215,9 @@ export class Core {
|
|||
on("config/ideSettingsUpdate", (msg) => {
|
||||
this.configHandler.updateIdeSettings(msg.data);
|
||||
});
|
||||
on("config/listProfiles", (msg) => {
|
||||
return this.configHandler.listProfiles();
|
||||
});
|
||||
|
||||
// Context providers
|
||||
on("context/addDocs", async (msg) => {
|
||||
|
|
@ -268,9 +280,13 @@ export class Core {
|
|||
fetchwithRequestOptions(url, init, config.requestOptions),
|
||||
});
|
||||
|
||||
Telemetry.capture("useContextProvider", {
|
||||
name: provider.description.title,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"useContextProvider",
|
||||
{
|
||||
name: provider.description.title,
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
return items.map((item) => ({
|
||||
...item,
|
||||
|
|
@ -282,12 +298,15 @@ export class Core {
|
|||
}
|
||||
});
|
||||
|
||||
on("config/getBrowserSerialized", (msg) => {
|
||||
return this.configHandler.getSerializedConfig();
|
||||
on("config/getSerializedProfileInfo", async (msg) => {
|
||||
return {
|
||||
config: await this.configHandler.getSerializedConfig(),
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
};
|
||||
});
|
||||
|
||||
async function* llmStreamChat(
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<ToCoreProtocol["llm/streamChat"][0]>,
|
||||
) {
|
||||
|
|
@ -322,7 +341,7 @@ export class Core {
|
|||
);
|
||||
|
||||
async function* llmStreamComplete(
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
|
||||
msg: Message<ToCoreProtocol["llm/streamComplete"][0]>,
|
||||
|
|
@ -388,7 +407,7 @@ export class Core {
|
|||
});
|
||||
|
||||
async function* runNodeJsSlashCommand(
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<ToCoreProtocol["command/run"][0]>,
|
||||
messenger: IMessenger<ToCoreProtocol, FromCoreProtocol>,
|
||||
|
|
@ -413,9 +432,13 @@ export class Core {
|
|||
throw new Error(`Unknown slash command ${slashCommandName}`);
|
||||
}
|
||||
|
||||
Telemetry.capture("useSlashCommand", {
|
||||
name: slashCommandName,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"useSlashCommand",
|
||||
{
|
||||
name: slashCommandName,
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
const checkActiveInterval = setInterval(() => {
|
||||
if (abortedMessageIds.has(msg.messageId)) {
|
||||
|
|
@ -477,7 +500,7 @@ export class Core {
|
|||
});
|
||||
|
||||
async function* streamDiffLinesGenerator(
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<ToCoreProtocol["streamDiffLines"][0]>,
|
||||
) {
|
||||
|
|
@ -579,6 +602,10 @@ export class Core {
|
|||
this.messenger.request("indexProgress", this.indexingState);
|
||||
}
|
||||
});
|
||||
|
||||
on("didChangeSelectedProfile", (msg) => {
|
||||
this.configHandler.setSelectedProfile(msg.data.id);
|
||||
});
|
||||
}
|
||||
|
||||
private indexingCancellationController: AbortController | undefined;
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -419,6 +419,7 @@ export interface IdeSettings {
|
|||
remoteConfigServerUrl: string | undefined;
|
||||
remoteConfigSyncPeriod: number;
|
||||
userToken: string;
|
||||
enableControlServerBeta: boolean;
|
||||
}
|
||||
|
||||
export interface IDE {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { IConfigHandler } from "../config/IConfigHandler.js";
|
||||
import { ConfigHandler } from "../config/ConfigHandler.js";
|
||||
import { IContinueServerClient } from "../continueServer/interface.js";
|
||||
import { IDE, IndexTag, IndexingProgressUpdate } from "../index.js";
|
||||
import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js";
|
||||
|
|
@ -23,7 +23,7 @@ export class PauseToken {
|
|||
|
||||
export class CodebaseIndexer {
|
||||
constructor(
|
||||
private readonly configHandler: IConfigHandler,
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly pauseToken: PauseToken,
|
||||
private readonly continueServerClient: IContinueServerClient,
|
||||
|
|
|
|||
|
|
@ -235,12 +235,16 @@ ${prompt}`;
|
|||
) {
|
||||
let promptTokens = this.countTokens(prompt);
|
||||
let generatedTokens = this.countTokens(completion);
|
||||
Telemetry.capture("tokens_generated", {
|
||||
model: model,
|
||||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"tokens_generated",
|
||||
{
|
||||
model: model,
|
||||
provider: this.providerName,
|
||||
promptTokens: promptTokens,
|
||||
generatedTokens: generatedTokens,
|
||||
},
|
||||
true,
|
||||
);
|
||||
DevDataSqliteDb.logTokensGenerated(
|
||||
model,
|
||||
this.providerName,
|
||||
|
|
|
|||
11
core/package-lock.json
generated
11
core/package-lock.json
generated
|
|
@ -56,7 +56,8 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"yaml": "^2.4.2"
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
@ -14413,6 +14414,14 @@
|
|||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"yaml": "^2.4.2"
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"puppeteer": {
|
||||
"chromium_revision": "119.0.6045.105"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
} from "..";
|
||||
import type { AutocompleteInput } from "../autocomplete/completionProvider";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
|
||||
export type ProtocolGeneratorType<T> = AsyncGenerator<{
|
||||
done?: boolean;
|
||||
|
|
@ -47,9 +48,13 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
];
|
||||
"config/newPromptFile": [undefined, void];
|
||||
"config/ideSettingsUpdate": [IdeSettings, void];
|
||||
"config/getBrowserSerialized": [undefined, BrowserSerializedContinueConfig];
|
||||
"config/getSerializedProfileInfo": [
|
||||
undefined,
|
||||
{ config: BrowserSerializedContinueConfig; profileId: string },
|
||||
];
|
||||
"config/deleteModel": [{ title: string }, void];
|
||||
"config/reload": [undefined, BrowserSerializedContinueConfig];
|
||||
"config/listProfiles": [undefined, ProfileDescription[]];
|
||||
"context/getContextItems": [
|
||||
{
|
||||
name: string;
|
||||
|
|
@ -138,4 +143,6 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
void,
|
||||
];
|
||||
addAutocompleteModel: [{ model: ModelDescription }, void];
|
||||
|
||||
"profiles/switch": [{ id: string }, undefined];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
import { ProfileDescription } from "../config/ConfigHandler.js";
|
||||
import { ToCoreFromIdeOrWebviewProtocol } from "./core.js";
|
||||
import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";
|
||||
|
||||
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol;
|
||||
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol;
|
||||
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & {
|
||||
didChangeSelectedProfile: [{ id: string }, void];
|
||||
};
|
||||
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
||||
didChangeAvailableProfiles: [{ profiles: ProfileDescription[] }, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import type {
|
|||
RangeInFile,
|
||||
Thread,
|
||||
} from "..";
|
||||
import { ControlPlaneSessionInfo } from "../control-plane/client";
|
||||
|
||||
export type ToIdeFromWebviewOrCoreProtocol = {
|
||||
// Methods from IDE type
|
||||
|
|
@ -75,5 +76,17 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
gotoDefinition: [{ location: Location }, RangeInFile[]];
|
||||
|
||||
getGitHubAuthToken: [undefined, string | undefined];
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean },
|
||||
ControlPlaneSessionInfo | undefined,
|
||||
];
|
||||
pathSep: [undefined, string];
|
||||
};
|
||||
|
||||
export type ToWebviewOrCoreFromIdeProtocol = {
|
||||
didChangeActiveTextEditor: [{ filepath: string }, void];
|
||||
didChangeControlPlaneSessionInfo: [
|
||||
{ sessionInfo: ControlPlaneSessionInfo | undefined },
|
||||
void,
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
ToCoreFromWebviewProtocol,
|
||||
ToWebviewFromCoreProtocol,
|
||||
} from "./coreWebview.js";
|
||||
import { ToWebviewOrCoreFromIdeProtocol } from "./ide.js";
|
||||
import { ToCoreFromIdeProtocol, ToIdeFromCoreProtocol } from "./ideCore.js";
|
||||
import {
|
||||
ToIdeFromWebviewProtocol,
|
||||
|
|
@ -13,17 +14,19 @@ export type IProtocol = Record<string, [any, any]>;
|
|||
// IDE
|
||||
export type ToIdeProtocol = ToIdeFromWebviewProtocol & ToIdeFromCoreProtocol;
|
||||
export type FromIdeProtocol = ToWebviewFromIdeProtocol &
|
||||
ToCoreFromIdeProtocol & {
|
||||
didChangeActiveTextEditor: [{ filepath: string }, void];
|
||||
};
|
||||
ToCoreFromIdeProtocol &
|
||||
ToWebviewOrCoreFromIdeProtocol;
|
||||
|
||||
// Webview
|
||||
export type ToWebviewProtocol = ToWebviewFromIdeProtocol &
|
||||
ToWebviewFromCoreProtocol;
|
||||
ToWebviewFromCoreProtocol &
|
||||
ToWebviewOrCoreFromIdeProtocol;
|
||||
export type FromWebviewProtocol = ToIdeFromWebviewProtocol &
|
||||
ToCoreFromWebviewProtocol;
|
||||
|
||||
// Core
|
||||
export type ToCoreProtocol = ToCoreFromIdeProtocol | ToCoreFromWebviewProtocol;
|
||||
export type ToCoreProtocol = ToCoreFromIdeProtocol &
|
||||
ToCoreFromWebviewProtocol &
|
||||
ToWebviewOrCoreFromIdeProtocol;
|
||||
export type FromCoreProtocol = ToWebviewFromCoreProtocol &
|
||||
ToIdeFromCoreProtocol;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"config/addModel",
|
||||
"config/newPromptFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/getBrowserSerialized",
|
||||
"config/getSerializedProfileInfo",
|
||||
"config/deleteModel",
|
||||
"config/reload",
|
||||
"context/getContextItems",
|
||||
|
|
@ -41,6 +41,9 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"index/indexingProgressBarInitialized",
|
||||
"completeOnboarding",
|
||||
"addAutocompleteModel",
|
||||
"config/listProfiles",
|
||||
"profiles/switch",
|
||||
"didChangeSelectedProfile",
|
||||
];
|
||||
|
||||
// Message types to pass through from core to webview
|
||||
|
|
@ -51,4 +54,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
|
|||
"indexProgress",
|
||||
"addContextItem",
|
||||
"refreshSubmenuItems",
|
||||
"didChangeAvailableProfiles",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ describe.skip("CodebaseIndexer", () => {
|
|||
ide,
|
||||
ideSettingsPromise,
|
||||
async (text) => {},
|
||||
undefined as any, // TODO
|
||||
);
|
||||
const pauseToken = new PauseToken(false);
|
||||
const continueServerClient = new ContinueServerClient(undefined, undefined);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { getGlobalContextFilePath } from "./paths.js";
|
|||
export type GlobalContextType = {
|
||||
indexingPaused: boolean;
|
||||
selectedTabAutocompleteModel: string;
|
||||
lastSelectedProfileForWorkspace: { [workspaceIdentifier: string]: string };
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class FileSystemIde implements IDE {
|
|||
remoteConfigServerUrl: undefined,
|
||||
remoteConfigSyncPeriod: 60,
|
||||
userToken: "",
|
||||
enableControlServerBeta: false,
|
||||
};
|
||||
}
|
||||
async getGitHubAuthToken(): Promise<string | undefined> {
|
||||
|
|
|
|||
|
|
@ -235,6 +235,11 @@ export function getPathToRemoteConfig(remoteConfigServerUrl: string): string {
|
|||
return dir;
|
||||
}
|
||||
|
||||
export function internalBetaPathExists(): boolean {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".internal_beta");
|
||||
return fs.existsSync(sPath);
|
||||
}
|
||||
|
||||
export function getConfigJsonPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import os from "node:os";
|
||||
import { TeamAnalytics } from "../control-plane/TeamAnalytics";
|
||||
|
||||
export class Telemetry {
|
||||
// Set to undefined whenever telemetry is disabled
|
||||
|
|
@ -7,7 +8,11 @@ export class Telemetry {
|
|||
static os: string | undefined = undefined;
|
||||
static extensionVersion: string | undefined = undefined;
|
||||
|
||||
static async capture(event: string, properties: { [key: string]: any }) {
|
||||
static async capture(
|
||||
event: string,
|
||||
properties: { [key: string]: any },
|
||||
sendToTeam: boolean = false,
|
||||
) {
|
||||
Telemetry.client?.capture({
|
||||
distinctId: Telemetry.uniqueId,
|
||||
event,
|
||||
|
|
@ -17,6 +22,10 @@ export class Telemetry {
|
|||
extensionVersion: Telemetry.extensionVersion,
|
||||
},
|
||||
});
|
||||
|
||||
if (sendToTeam) {
|
||||
TeamAnalytics.capture(event, properties);
|
||||
}
|
||||
}
|
||||
|
||||
static shutdownPosthogClient() {
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ export async function getLanguageForFile(
|
|||
}
|
||||
let language = nameToLanguage.get(languageName);
|
||||
if (!language) {
|
||||
language = await loadLanguageForFileExt(extension);
|
||||
nameToLanguage.set(languageName, language);
|
||||
language = await loadLanguageForFileExt(extension);
|
||||
nameToLanguage.set(languageName, language);
|
||||
}
|
||||
return language;
|
||||
} catch (e) {
|
||||
|
|
@ -152,7 +152,9 @@ export async function getQueryForFile(
|
|||
return query;
|
||||
}
|
||||
|
||||
async function loadLanguageForFileExt(fileExtension: string): Promise<Language> {
|
||||
async function loadLanguageForFileExt(
|
||||
fileExtension: string,
|
||||
): Promise<Language> {
|
||||
const wasmPath = path.join(
|
||||
__dirname,
|
||||
...(process.env.NODE_ENV === "test"
|
||||
|
|
|
|||
|
|
@ -60,10 +60,14 @@ export async function* streamDiffLines(
|
|||
language: string | undefined,
|
||||
onlyOneInsertion?: boolean,
|
||||
): AsyncGenerator<DiffLine> {
|
||||
Telemetry.capture("inlineEdit", {
|
||||
model: llm.model,
|
||||
provider: llm.providerName,
|
||||
});
|
||||
Telemetry.capture(
|
||||
"inlineEdit",
|
||||
{
|
||||
model: llm.model,
|
||||
provider: llm.providerName,
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
// Strip common indentation for the LLM, then add back after generation
|
||||
let oldLines =
|
||||
|
|
|
|||
|
|
@ -4,34 +4,49 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||
|
||||
|
||||
## 0.0.42 - 2024-04-12
|
||||
|
||||
### Added
|
||||
* Inline cmd/ctrl+I in JetBrains
|
||||
|
||||
- Inline cmd/ctrl+I in JetBrains
|
||||
|
||||
### Fixed
|
||||
* Fixed character encoding error causing display issues
|
||||
* Fixed error causing input to constantly demand focus
|
||||
* Fixed automatic reloading of config.json
|
||||
|
||||
- Fixed character encoding error causing display issues
|
||||
- Fixed error causing input to constantly demand focus
|
||||
- Fixed automatic reloading of config.json
|
||||
|
||||
## 0.0.38 - 2024-03-15
|
||||
|
||||
### Added
|
||||
* Remote config server support
|
||||
* Autocomplete support in JetBrains
|
||||
|
||||
- Remote config server support
|
||||
- Autocomplete support in JetBrains
|
||||
|
||||
## 0.0.34 - 2024-03-03
|
||||
|
||||
### Added
|
||||
* diff context provider
|
||||
|
||||
- diff context provider
|
||||
|
||||
### Changed
|
||||
* Allow LLM servers to handle templating
|
||||
|
||||
- Allow LLM servers to handle templating
|
||||
|
||||
### Fixed
|
||||
* Fix a few context providers / slash commands
|
||||
* Fixed issues preventing proper extension startup
|
||||
|
||||
- Fix a few context providers / slash commands
|
||||
- Fixed issues preventing proper extension startup
|
||||
|
||||
## v0.0.26 - 2023-12-28
|
||||
|
||||
### Added
|
||||
* auto-reloading of config on save
|
||||
|
||||
- auto-reloading of config on save
|
||||
|
||||
### Fixed
|
||||
* Fixed /edit bug for versions without Python server
|
||||
|
||||
- Fixed /edit bug for versions without Python server
|
||||
|
||||
## v0.0.25 - 2023-12-25
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
"configUpdate",
|
||||
"getDefaultModelTitle",
|
||||
"indexProgress",
|
||||
"refreshSubmenuItems"
|
||||
"refreshSubmenuItems",
|
||||
"didChangeAvailableProfiles"
|
||||
)
|
||||
|
||||
private fun setPermissions(destination: String) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class InlineEditAction : AnAction(), DumbAware {
|
|||
// Get list of model titles
|
||||
val continuePluginService = project.service<ContinuePluginService>()
|
||||
val modelTitles = mutableListOf<String>()
|
||||
continuePluginService.coreMessenger?.request("config/getBrowserSerialized", null, null) { response ->
|
||||
continuePluginService.coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val config = response as Map<String, Any>
|
||||
val models = config["models"] as List<Map<String, Any>>
|
||||
modelTitles.addAll(models.map { it["title"] as String })
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class ContinueBrowser(val project: Project, url: String, useOsr: Boolean = false
|
|||
"config/addOpenAiKey",
|
||||
"config/addModel",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/getBrowserSerialized",
|
||||
"config/getSerializedProfileInfo",
|
||||
"config/deleteModel",
|
||||
"config/newPromptFile",
|
||||
"config/reload",
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ media
|
|||
models/**/*
|
||||
builtin-themes/
|
||||
**/textmate-syntaxes/
|
||||
**/*.scm
|
||||
**/*.scm
|
||||
|
|
|
|||
3
extensions/vscode/package-lock.json
generated
3
extensions/vscode/package-lock.json
generated
|
|
@ -141,7 +141,8 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"yaml": "^2.4.2"
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
|
|||
|
|
@ -559,6 +559,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"dbinfoz": "^0.1.4",
|
||||
"downshift": "^7.6.0",
|
||||
"esbuild": "^0.17.19",
|
||||
"express": "^4.18.2",
|
||||
"fkill": "^8.1.0",
|
||||
"follow-redirects": "^1.15.4",
|
||||
|
|
@ -589,7 +590,6 @@
|
|||
"uuid": "^9.0.1",
|
||||
"uuidv4": "^6.2.13",
|
||||
"vectordb": "^0.4.20",
|
||||
"esbuild": "^0.17.19",
|
||||
"vscode-languageclient": "^8.0.2",
|
||||
"ws": "^8.13.0",
|
||||
"yarn": "^1.22.21"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import path from "node:path";
|
|||
import * as vscode from "vscode";
|
||||
import { VsCodeExtension } from "../extension/VsCodeExtension";
|
||||
import registerQuickFixProvider from "../lang-server/codeActions";
|
||||
import { WorkOsAuthProvider } from "../stubs/WorkOsAuthProvider";
|
||||
import { getExtensionVersion } from "../util/util";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
import { VsCodeContinueApi } from "./api";
|
||||
|
|
@ -17,6 +18,11 @@ export async function activateExtension(context: vscode.ExtensionContext) {
|
|||
registerQuickFixProvider();
|
||||
setupInlineTips(context);
|
||||
|
||||
// Register auth provider
|
||||
const workOsAuthProvider = new WorkOsAuthProvider(context);
|
||||
await workOsAuthProvider.initialize();
|
||||
context.subscriptions.push(workOsAuthProvider);
|
||||
|
||||
const vscodeExtension = new VsCodeExtension(context);
|
||||
|
||||
migrate("showWelcome_1", () => {
|
||||
|
|
@ -33,9 +39,13 @@ export async function activateExtension(context: vscode.ExtensionContext) {
|
|||
// Load Continue configuration
|
||||
if (!context.globalState.get("hasBeenInstalled")) {
|
||||
context.globalState.update("hasBeenInstalled", true);
|
||||
Telemetry.capture("install", {
|
||||
extensionVersion: getExtensionVersion(),
|
||||
});
|
||||
Telemetry.capture(
|
||||
"install",
|
||||
{
|
||||
extensionVersion: getExtensionVersion(),
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
const api = new VsCodeContinueApi(vscodeExtension);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function startPythonLanguageServer(context: ExtensionContext): LanguageClient {
|
|||
configurationSection: "pyls",
|
||||
},
|
||||
};
|
||||
return new LanguageClient(command, serverOptions, clientOptions);
|
||||
return new LanguageClient(command, serverOptions, clientOptions)
|
||||
}
|
||||
|
||||
async function startPylance(context: ExtensionContext) {
|
||||
|
|
@ -112,3 +112,4 @@ async function startPylance(context: ExtensionContext) {
|
|||
);
|
||||
return client;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
CompletionProvider,
|
||||
type AutocompleteInput,
|
||||
} from "core/autocomplete/completionProvider";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import * as vscode from "vscode";
|
||||
import type { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
|
|
@ -48,7 +48,7 @@ export class ContinueCompletionProvider
|
|||
private recentlyEditedTracker = new RecentlyEditedTracker();
|
||||
|
||||
constructor(
|
||||
private readonly configHandler: IConfigHandler,
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly ide: IDE,
|
||||
private readonly tabAutocompleteModel: TabAutocompleteModel,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import * as vscode from "vscode";
|
|||
|
||||
import { ContextMenuConfig, IDE } from "core";
|
||||
import { CompletionProvider } from "core/autocomplete/completionProvider";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { ContinueServerClient } from "core/continueServer/stubs/client";
|
||||
import { GlobalContext } from "core/util/GlobalContext";
|
||||
import { getConfigJsonPath, getDevDataFilePath } from "core/util/paths";
|
||||
|
|
@ -165,7 +165,7 @@ const commandsMap: (
|
|||
ide: IDE,
|
||||
extensionContext: vscode.ExtensionContext,
|
||||
sidebar: ContinueGUIWebviewViewProvider,
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
diffManager: DiffManager,
|
||||
verticalDiffManager: VerticalPerLineDiffManager,
|
||||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
|
|
@ -675,7 +675,7 @@ export function registerAllCommands(
|
|||
ide: IDE,
|
||||
extensionContext: vscode.ExtensionContext,
|
||||
sidebar: ContinueGUIWebviewViewProvider,
|
||||
configHandler: IConfigHandler,
|
||||
configHandler: ConfigHandler,
|
||||
diffManager: DiffManager,
|
||||
verticalDiffManager: VerticalPerLineDiffManager,
|
||||
continueServerClientPromise: Promise<ContinueServerClient>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { FileEdit } from "core";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import * as vscode from "vscode";
|
||||
import { getTheme } from "./util/getTheme";
|
||||
import { getExtensionVersion } from "./util/util";
|
||||
|
|
@ -46,7 +46,7 @@ export class ContinueGUIWebviewViewProvider
|
|||
}
|
||||
|
||||
constructor(
|
||||
private readonly configHandlerPromise: Promise<IConfigHandler>,
|
||||
private readonly configHandlerPromise: Promise<ConfigHandler>,
|
||||
private readonly windowId: string,
|
||||
private readonly extensionContext: vscode.ExtensionContext,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { pruneLinesFromBottom, pruneLinesFromTop } from "core/llm/countTokens";
|
||||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
import { streamDiffLines } from "core/util/verticalEdit";
|
||||
|
|
@ -21,7 +21,7 @@ export class VerticalPerLineDiffManager {
|
|||
|
||||
private userChangeListener: vscode.Disposable | undefined;
|
||||
|
||||
constructor(private readonly configHandler: IConfigHandler) {
|
||||
constructor(private readonly configHandler: ConfigHandler) {
|
||||
this.userChangeListener = undefined;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,13 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}
|
||||
|
||||
export function deactivate() {
|
||||
Telemetry.capture("deactivate", {
|
||||
extensionVersion: getExtensionVersion(),
|
||||
});
|
||||
Telemetry.capture(
|
||||
"deactivate",
|
||||
{
|
||||
extensionVersion: getExtensionVersion(),
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
Telemetry.shutdownPosthogClient();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { IContextProvider } from "core";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { Core } from "core/core";
|
||||
import { FromCoreProtocol, ToCoreProtocol } from "core/protocol";
|
||||
import { InProcessMessenger } from "core/util/messenger";
|
||||
|
|
@ -21,16 +21,16 @@ import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
|||
import { VsCodeIde } from "../ideProtocol";
|
||||
import { registerAllCodeLensProviders } from "../lang-server/codeLens";
|
||||
import { setupRemoteConfigSync } from "../stubs/activation";
|
||||
import { getControlPlaneSessionInfo } from "../stubs/WorkOsAuthProvider";
|
||||
import { Battery } from "../util/battery";
|
||||
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
|
||||
import type { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
import { VsCodeMessenger } from "./VsCodeMessenger";
|
||||
import { CONTINUE_WORKSPACE_KEY } from "../util/workspaceConfig";
|
||||
|
||||
export class VsCodeExtension {
|
||||
// Currently some of these are public so they can be used in testing (test/test-suites)
|
||||
|
||||
private configHandler: IConfigHandler;
|
||||
private configHandler: ConfigHandler;
|
||||
private extensionContext: vscode.ExtensionContext;
|
||||
private ide: VsCodeIde;
|
||||
private tabAutocompleteModel: TabAutocompleteModel;
|
||||
|
|
@ -66,7 +66,7 @@ export class VsCodeExtension {
|
|||
},
|
||||
);
|
||||
let resolveConfigHandler: any = undefined;
|
||||
const configHandlerPromise = new Promise<IConfigHandler>((resolve) => {
|
||||
const configHandlerPromise = new Promise<ConfigHandler>((resolve) => {
|
||||
resolveConfigHandler = resolve;
|
||||
});
|
||||
this.sidebar = new ContinueGUIWebviewViewProvider(
|
||||
|
|
@ -243,6 +243,13 @@ export class VsCodeExtension {
|
|||
vscode.authentication.onDidChangeSessions((e) => {
|
||||
if (e.provider.id === "github") {
|
||||
this.configHandler.reloadConfig();
|
||||
} else if (e.provider.id === "continue") {
|
||||
this.webviewProtocolPromise.then(async (webviewProtocol) => {
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true);
|
||||
webviewProtocol.request("didChangeControlPlaneSessionInfo", {
|
||||
sessionInfo,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { FromCoreProtocol, ToCoreProtocol } from "core/protocol";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import {
|
||||
FromCoreProtocol,
|
||||
FromWebviewProtocol,
|
||||
ToCoreProtocol,
|
||||
} from "core/protocol";
|
||||
import { ToWebviewFromCoreProtocol } from "core/protocol/coreWebview";
|
||||
import { ToIdeFromWebviewOrCoreProtocol } from "core/protocol/ide";
|
||||
import { ToIdeFromCoreProtocol } from "core/protocol/ideCore";
|
||||
|
|
@ -14,11 +18,9 @@ import * as path from "node:path";
|
|||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
import { VsCodeIde } from "../ideProtocol";
|
||||
import { getControlPlaneSessionInfo } from "../stubs/WorkOsAuthProvider";
|
||||
import { getExtensionUri } from "../util/vscode";
|
||||
import {
|
||||
ToCoreOrIdeFromWebviewProtocol,
|
||||
VsCodeWebviewProtocol,
|
||||
} from "../webviewProtocol";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
/**
|
||||
* A shared messenger class between Core and Webview
|
||||
|
|
@ -28,13 +30,11 @@ type TODO = any;
|
|||
type ToIdeOrWebviewFromCoreProtocol = ToIdeFromCoreProtocol &
|
||||
ToWebviewFromCoreProtocol;
|
||||
export class VsCodeMessenger {
|
||||
onWebview<T extends keyof ToCoreOrIdeFromWebviewProtocol>(
|
||||
onWebview<T extends keyof FromWebviewProtocol>(
|
||||
messageType: T,
|
||||
handler: (
|
||||
message: Message<ToCoreOrIdeFromWebviewProtocol[T][0]>,
|
||||
) =>
|
||||
| Promise<ToCoreOrIdeFromWebviewProtocol[T][1]>
|
||||
| ToCoreOrIdeFromWebviewProtocol[T][1],
|
||||
message: Message<FromWebviewProtocol[T][0]>,
|
||||
) => Promise<FromWebviewProtocol[T][1]> | FromWebviewProtocol[T][1],
|
||||
): void {
|
||||
this.webviewProtocol.on(messageType, handler);
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ export class VsCodeMessenger {
|
|||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
private readonly ide: VsCodeIde,
|
||||
private readonly verticalDiffManagerPromise: Promise<VerticalPerLineDiffManager>,
|
||||
private readonly configHandlerPromise: Promise<IConfigHandler>,
|
||||
private readonly configHandlerPromise: Promise<ConfigHandler>,
|
||||
) {
|
||||
/** WEBVIEW ONLY LISTENERS **/
|
||||
this.onWebview("showFile", (msg) => {
|
||||
|
|
@ -291,5 +291,8 @@ export class VsCodeMessenger {
|
|||
this.onWebviewOrCore("getGitHubAuthToken", (msg) =>
|
||||
ide.getGitHubAuthToken(),
|
||||
);
|
||||
this.onWebviewOrCore("getControlPlaneSessionInfo", async (msg) => {
|
||||
return getControlPlaneSessionInfo(msg.data.silent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
editConfigJson,
|
||||
getConfigJsonPath,
|
||||
getContinueGlobalPath,
|
||||
internalBetaPathExists,
|
||||
} from "core/util/paths";
|
||||
import * as vscode from "vscode";
|
||||
import { executeGotoProvider } from "./autocomplete/lsp";
|
||||
|
|
@ -520,6 +521,11 @@ class VsCodeIde implements IDE {
|
|||
60,
|
||||
),
|
||||
userToken: settings.get<string>("userToken", ""),
|
||||
enableControlServerBeta: internalBetaPathExists(),
|
||||
// settings.get<boolean>(
|
||||
// "enableControlServerBeta",
|
||||
// false,
|
||||
// ),
|
||||
};
|
||||
return ideSettings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { IDE } from "core";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import { fetchwithRequestOptions } from "core/util/fetchWithOptions";
|
||||
import * as vscode from "vscode";
|
||||
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
|
||||
|
|
@ -17,7 +17,7 @@ interface QuickEditFlowStuff {
|
|||
export class QuickEdit {
|
||||
constructor(
|
||||
private readonly verticalDiffManager: VerticalPerLineDiffManager,
|
||||
private readonly configHandler: IConfigHandler,
|
||||
private readonly configHandler: ConfigHandler,
|
||||
private readonly webviewProtocol: VsCodeWebviewProtocol,
|
||||
private readonly ide: IDE,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
|
|
|
|||
418
extensions/vscode/src/stubs/WorkOsAuthProvider.ts
Normal file
418
extensions/vscode/src/stubs/WorkOsAuthProvider.ts
Normal file
|
|
@ -0,0 +1,418 @@
|
|||
import fetch from "node-fetch";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
authentication,
|
||||
AuthenticationProvider,
|
||||
AuthenticationProviderAuthenticationSessionsChangeEvent,
|
||||
AuthenticationSession,
|
||||
Disposable,
|
||||
env,
|
||||
EventEmitter,
|
||||
ExtensionContext,
|
||||
ProgressLocation,
|
||||
Uri,
|
||||
UriHandler,
|
||||
window,
|
||||
} from "vscode";
|
||||
import { PromiseAdapter, promiseFromEvent } from "./promiseUtils";
|
||||
|
||||
export const AUTH_TYPE = "continue";
|
||||
const AUTH_NAME = "Continue";
|
||||
const CLIENT_ID = "client_01J0FW6XN8N2XJAECF7NE0Y65J";
|
||||
const SESSIONS_SECRET_KEY = `${AUTH_TYPE}.sessions`;
|
||||
|
||||
class UriEventHandler extends EventEmitter<Uri> implements UriHandler {
|
||||
public handleUri(uri: Uri) {
|
||||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
|
||||
import {
|
||||
CONTROL_PLANE_URL,
|
||||
ControlPlaneSessionInfo,
|
||||
} from "core/control-plane/client";
|
||||
import crypto from "crypto";
|
||||
|
||||
// Function to generate a random string of specified length
|
||||
function generateRandomString(length: number): string {
|
||||
const possibleCharacters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
|
||||
let randomString = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * possibleCharacters.length);
|
||||
randomString += possibleCharacters[randomIndex];
|
||||
}
|
||||
return randomString;
|
||||
}
|
||||
|
||||
// Function to generate a code challenge from the code verifier
|
||||
|
||||
async function generateCodeChallenge(verifier: string) {
|
||||
// Create a SHA-256 hash of the verifier
|
||||
const hash = crypto.createHash("sha256").update(verifier).digest();
|
||||
|
||||
// Convert the hash to a base64 URL-encoded string
|
||||
const base64String = hash
|
||||
.toString("base64")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
|
||||
return base64String;
|
||||
}
|
||||
|
||||
interface ContinueAuthenticationSession extends AuthenticationSession {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
expiresIn: number;
|
||||
}
|
||||
|
||||
export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
||||
private _sessionChangeEmitter =
|
||||
new EventEmitter<AuthenticationProviderAuthenticationSessionsChangeEvent>();
|
||||
private _disposable: Disposable;
|
||||
private _pendingStates: string[] = [];
|
||||
private _codeExchangePromises = new Map<
|
||||
string,
|
||||
{ promise: Promise<string>; cancel: EventEmitter<void> }
|
||||
>();
|
||||
private _uriHandler = new UriEventHandler();
|
||||
private _sessions: ContinueAuthenticationSession[] = [];
|
||||
|
||||
private static EXPIRATION_TIME_MS = 1000 * 60 * 5; // 5 minutes
|
||||
|
||||
constructor(private readonly context: ExtensionContext) {
|
||||
this._disposable = Disposable.from(
|
||||
authentication.registerAuthenticationProvider(
|
||||
AUTH_TYPE,
|
||||
AUTH_NAME,
|
||||
this,
|
||||
{ supportsMultipleAccounts: false },
|
||||
),
|
||||
window.registerUriHandler(this._uriHandler),
|
||||
);
|
||||
}
|
||||
|
||||
get onDidChangeSessions() {
|
||||
return this._sessionChangeEmitter.event;
|
||||
}
|
||||
|
||||
get redirectUri() {
|
||||
const publisher = this.context.extension.packageJSON.publisher;
|
||||
const name = this.context.extension.packageJSON.name;
|
||||
return `${env.uriScheme}://${publisher}.${name}`;
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
let sessions = await this.context.secrets.get(SESSIONS_SECRET_KEY);
|
||||
this._sessions = sessions ? JSON.parse(sessions) : [];
|
||||
await this._refreshSessions();
|
||||
}
|
||||
|
||||
private async _refreshSessions(): Promise<void> {
|
||||
if (!this._sessions.length) {
|
||||
return;
|
||||
}
|
||||
for (const session of this._sessions) {
|
||||
try {
|
||||
const newSession = await this._refreshSession(session.refreshToken);
|
||||
session.accessToken = newSession.accessToken;
|
||||
session.refreshToken = newSession.refreshToken;
|
||||
session.expiresIn = newSession.expiresIn;
|
||||
} catch (e: any) {
|
||||
if (e.message === "Network failure") {
|
||||
setTimeout(() => this._refreshSessions(), 60 * 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.context.secrets.store(
|
||||
SESSIONS_SECRET_KEY,
|
||||
JSON.stringify(this._sessions),
|
||||
);
|
||||
this._sessionChangeEmitter.fire({
|
||||
added: [],
|
||||
removed: [],
|
||||
changed: this._sessions,
|
||||
});
|
||||
|
||||
if (this._sessions[0].expiresIn) {
|
||||
setTimeout(
|
||||
() => this._refreshSessions(),
|
||||
(this._sessions[0].expiresIn * 1000 * 2) / 3,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async _refreshSession(
|
||||
refreshToken: string,
|
||||
): Promise<{ accessToken: string; refreshToken: string; expiresIn: number }> {
|
||||
const response = await fetch(new URL("/auth/refresh", CONTROL_PLANE_URL), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
refreshToken,
|
||||
}),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Network failure");
|
||||
}
|
||||
const data = (await response.json()) as any;
|
||||
return {
|
||||
accessToken: data.accessToken,
|
||||
refreshToken: data.refreshToken,
|
||||
expiresIn: WorkOsAuthProvider.EXPIRATION_TIME_MS,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the existing sessions
|
||||
* @param scopes
|
||||
* @returns
|
||||
*/
|
||||
public async getSessions(
|
||||
scopes?: string[],
|
||||
): Promise<readonly ContinueAuthenticationSession[]> {
|
||||
const allSessions = await this.context.secrets.get(SESSIONS_SECRET_KEY);
|
||||
|
||||
if (allSessions) {
|
||||
return JSON.parse(allSessions) as ContinueAuthenticationSession[];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new auth session
|
||||
* @param scopes
|
||||
* @returns
|
||||
*/
|
||||
public async createSession(
|
||||
scopes: string[],
|
||||
): Promise<ContinueAuthenticationSession> {
|
||||
try {
|
||||
const codeVerifier = generateRandomString(64);
|
||||
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
||||
const token = await this.login(codeChallenge, scopes);
|
||||
if (!token) {
|
||||
throw new Error(`Continue login failure`);
|
||||
}
|
||||
|
||||
const userInfo = (await this.getUserInfo(token, codeVerifier)) as any;
|
||||
const { user, access_token, refresh_token } = userInfo;
|
||||
|
||||
const session: ContinueAuthenticationSession = {
|
||||
id: uuidv4(),
|
||||
accessToken: access_token,
|
||||
refreshToken: refresh_token,
|
||||
expiresIn: WorkOsAuthProvider.EXPIRATION_TIME_MS,
|
||||
account: {
|
||||
label: user.first_name + " " + user.last_name,
|
||||
id: user.email,
|
||||
},
|
||||
scopes: [],
|
||||
};
|
||||
|
||||
await this.context.secrets.store(
|
||||
SESSIONS_SECRET_KEY,
|
||||
JSON.stringify([session]),
|
||||
);
|
||||
|
||||
this._sessionChangeEmitter.fire({
|
||||
added: [session],
|
||||
removed: [],
|
||||
changed: [],
|
||||
});
|
||||
|
||||
return session;
|
||||
} catch (e) {
|
||||
window.showErrorMessage(`Sign in failed: ${e}`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an existing session
|
||||
* @param sessionId
|
||||
*/
|
||||
public async removeSession(sessionId: string): Promise<void> {
|
||||
const allSessions = await this.context.secrets.get(SESSIONS_SECRET_KEY);
|
||||
if (allSessions) {
|
||||
let sessions = JSON.parse(allSessions) as ContinueAuthenticationSession[];
|
||||
const sessionIdx = sessions.findIndex((s) => s.id === sessionId);
|
||||
const session = sessions[sessionIdx];
|
||||
sessions.splice(sessionIdx, 1);
|
||||
|
||||
await this.context.secrets.store(
|
||||
SESSIONS_SECRET_KEY,
|
||||
JSON.stringify(sessions),
|
||||
);
|
||||
|
||||
if (session) {
|
||||
this._sessionChangeEmitter.fire({
|
||||
added: [],
|
||||
removed: [session],
|
||||
changed: [],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the registered services
|
||||
*/
|
||||
public async dispose() {
|
||||
this._disposable.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log in to Continue
|
||||
*/
|
||||
private async login(codeChallenge: string, scopes: string[] = []) {
|
||||
return await window.withProgress<string>(
|
||||
{
|
||||
location: ProgressLocation.Notification,
|
||||
title: "Signing in to Continue...",
|
||||
cancellable: true,
|
||||
},
|
||||
async (_, token) => {
|
||||
const stateId = uuidv4();
|
||||
|
||||
this._pendingStates.push(stateId);
|
||||
|
||||
const scopeString = scopes.join(" ");
|
||||
|
||||
const url = new URL("https://api.workos.com/user_management/authorize");
|
||||
const params = {
|
||||
response_type: "code",
|
||||
client_id: CLIENT_ID,
|
||||
redirect_uri: this.redirectUri,
|
||||
state: stateId,
|
||||
code_challenge: codeChallenge,
|
||||
code_challenge_method: "S256",
|
||||
provider: "authkit",
|
||||
};
|
||||
|
||||
Object.keys(params).forEach((key) =>
|
||||
url.searchParams.append(key, params[key as keyof typeof params]),
|
||||
);
|
||||
|
||||
const oauthUrl = url;
|
||||
if (oauthUrl) {
|
||||
await env.openExternal(Uri.parse(oauthUrl.toString()));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
let codeExchangePromise = this._codeExchangePromises.get(scopeString);
|
||||
if (!codeExchangePromise) {
|
||||
codeExchangePromise = promiseFromEvent(
|
||||
this._uriHandler.event,
|
||||
this.handleUri(scopes),
|
||||
);
|
||||
this._codeExchangePromises.set(scopeString, codeExchangePromise);
|
||||
}
|
||||
|
||||
try {
|
||||
return await Promise.race([
|
||||
codeExchangePromise.promise,
|
||||
new Promise<string>((_, reject) =>
|
||||
setTimeout(() => reject("Cancelled"), 60000),
|
||||
),
|
||||
promiseFromEvent<any, any>(
|
||||
token.onCancellationRequested,
|
||||
(_, __, reject) => {
|
||||
reject("User Cancelled");
|
||||
},
|
||||
).promise,
|
||||
]);
|
||||
} finally {
|
||||
this._pendingStates = this._pendingStates.filter(
|
||||
(n) => n !== stateId,
|
||||
);
|
||||
codeExchangePromise?.cancel.fire();
|
||||
this._codeExchangePromises.delete(scopeString);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the redirect to VS Code (after sign in from Continue)
|
||||
* @param scopes
|
||||
* @returns
|
||||
*/
|
||||
private handleUri: (
|
||||
scopes: readonly string[],
|
||||
) => PromiseAdapter<Uri, string> =
|
||||
(scopes) => async (uri, resolve, reject) => {
|
||||
const query = new URLSearchParams(uri.query);
|
||||
const access_token = query.get("code");
|
||||
const state = query.get("state");
|
||||
|
||||
if (!access_token) {
|
||||
reject(new Error("No token"));
|
||||
return;
|
||||
}
|
||||
if (!state) {
|
||||
reject(new Error("No state"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it is a valid auth request started by the extension
|
||||
if (!this._pendingStates.some((n) => n === state)) {
|
||||
reject(new Error("State not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(access_token);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the user info from WorkOS
|
||||
* @param token
|
||||
* @returns
|
||||
*/
|
||||
private async getUserInfo(token: string, codeVerifier: string) {
|
||||
const resp = await fetch(
|
||||
"https://api.workos.com/user_management/authenticate",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
client_id: CLIENT_ID,
|
||||
code_verifier: codeVerifier,
|
||||
grant_type: "authorization_code",
|
||||
code: token,
|
||||
}),
|
||||
},
|
||||
);
|
||||
const text = await resp.text();
|
||||
const data = JSON.parse(text);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getControlPlaneSessionInfo(
|
||||
silent: boolean,
|
||||
): Promise<ControlPlaneSessionInfo | undefined> {
|
||||
const session = await authentication.getSession(
|
||||
"continue",
|
||||
[],
|
||||
silent ? { silent: true } : { createIfNone: true },
|
||||
);
|
||||
if (!session) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
accessToken: session.accessToken,
|
||||
account: {
|
||||
id: session.account.id,
|
||||
label: session.account.label,
|
||||
},
|
||||
};
|
||||
}
|
||||
57
extensions/vscode/src/stubs/promiseUtils.ts
Normal file
57
extensions/vscode/src/stubs/promiseUtils.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { Disposable, Event, EventEmitter } from "vscode";
|
||||
|
||||
export interface PromiseAdapter<T, U> {
|
||||
(
|
||||
value: T,
|
||||
resolve: (value: U | PromiseLike<U>) => void,
|
||||
reject: (reason: any) => void,
|
||||
): any;
|
||||
}
|
||||
|
||||
const passthrough = (value: any, resolve: (value?: any) => void) =>
|
||||
resolve(value);
|
||||
|
||||
/**
|
||||
* Return a promise that resolves with the next emitted event, or with some future
|
||||
* event as decided by an adapter.
|
||||
*
|
||||
* If specified, the adapter is a function that will be called with
|
||||
* `(event, resolve, reject)`. It will be called once per event until it resolves or
|
||||
* rejects.
|
||||
*
|
||||
* The default adapter is the passthrough function `(value, resolve) => resolve(value)`.
|
||||
*
|
||||
* @param event the event
|
||||
* @param adapter controls resolution of the returned promise
|
||||
* @returns a promise that resolves or rejects as specified by the adapter
|
||||
*/
|
||||
export function promiseFromEvent<T, U>(
|
||||
event: Event<T>,
|
||||
adapter: PromiseAdapter<T, U> = passthrough,
|
||||
): { promise: Promise<U>; cancel: EventEmitter<void> } {
|
||||
let subscription: Disposable;
|
||||
let cancel = new EventEmitter<void>();
|
||||
|
||||
return {
|
||||
promise: new Promise<U>((resolve, reject) => {
|
||||
cancel.event((_) => reject("Cancelled"));
|
||||
subscription = event((value: T) => {
|
||||
try {
|
||||
Promise.resolve(adapter(value, resolve, reject)).catch(reject);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}).then(
|
||||
(result: U) => {
|
||||
subscription.dispose();
|
||||
return result;
|
||||
},
|
||||
(error) => {
|
||||
subscription.dispose();
|
||||
throw error;
|
||||
},
|
||||
),
|
||||
cancel,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
import { getContinueGlobalPath } from "core/util/paths";
|
||||
import { ExtensionContext } from "vscode";
|
||||
import fs from "fs";
|
||||
|
||||
/**
|
||||
* Clear all Continue-related artifacts to simulate a brand new user
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { ILLM } from "core";
|
||||
import { IConfigHandler } from "core/config/IConfigHandler";
|
||||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import Ollama from "core/llm/llms/Ollama";
|
||||
import { GlobalContext } from "core/util/GlobalContext";
|
||||
import * as vscode from "vscode";
|
||||
|
|
@ -13,9 +13,9 @@ export class TabAutocompleteModel {
|
|||
private shownOllamaWarning = false;
|
||||
private shownDeepseekWarning = false;
|
||||
|
||||
private configHandler: IConfigHandler;
|
||||
private configHandler: ConfigHandler;
|
||||
|
||||
constructor(configHandler: IConfigHandler) {
|
||||
constructor(configHandler: ConfigHandler) {
|
||||
this.configHandler = configHandler;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,9 @@
|
|||
import { FromWebviewProtocol, ToWebviewProtocol } from "core/protocol";
|
||||
import { Message } from "core/util/messenger";
|
||||
import fs from "node:fs";
|
||||
import path from "path";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import * as vscode from "vscode";
|
||||
import {
|
||||
ToCoreFromWebviewProtocol,
|
||||
ToWebviewFromCoreProtocol,
|
||||
} from "../../../core/protocol/coreWebview";
|
||||
import {
|
||||
ToIdeFromWebviewProtocol,
|
||||
ToWebviewFromIdeProtocol,
|
||||
} from "../../../core/protocol/ideWebview";
|
||||
import { IMessenger } from "../../../core/util/messenger";
|
||||
import { getExtensionUri } from "./util/vscode";
|
||||
|
||||
|
|
@ -32,19 +25,11 @@ export async function showTutorial() {
|
|||
await vscode.window.showTextDocument(doc, { preview: false });
|
||||
}
|
||||
|
||||
export type ToCoreOrIdeFromWebviewProtocol = ToCoreFromWebviewProtocol &
|
||||
ToIdeFromWebviewProtocol;
|
||||
type FullToWebviewFromIdeOrCoreProtocol = ToWebviewFromIdeProtocol &
|
||||
ToWebviewFromCoreProtocol;
|
||||
export class VsCodeWebviewProtocol
|
||||
implements
|
||||
IMessenger<
|
||||
ToCoreOrIdeFromWebviewProtocol,
|
||||
FullToWebviewFromIdeOrCoreProtocol
|
||||
>
|
||||
implements IMessenger<FromWebviewProtocol, ToWebviewProtocol>
|
||||
{
|
||||
listeners = new Map<
|
||||
keyof ToCoreOrIdeFromWebviewProtocol,
|
||||
keyof FromWebviewProtocol,
|
||||
((message: Message) => any)[]
|
||||
>();
|
||||
|
||||
|
|
@ -58,13 +43,11 @@ export class VsCodeWebviewProtocol
|
|||
return id;
|
||||
}
|
||||
|
||||
on<T extends keyof ToCoreOrIdeFromWebviewProtocol>(
|
||||
on<T extends keyof FromWebviewProtocol>(
|
||||
messageType: T,
|
||||
handler: (
|
||||
message: Message<ToCoreOrIdeFromWebviewProtocol[T][0]>,
|
||||
) =>
|
||||
| Promise<ToCoreOrIdeFromWebviewProtocol[T][1]>
|
||||
| ToCoreOrIdeFromWebviewProtocol[T][1],
|
||||
message: Message<FromWebviewProtocol[T][0]>,
|
||||
) => Promise<FromWebviewProtocol[T][1]> | FromWebviewProtocol[T][1],
|
||||
): void {
|
||||
if (!this.listeners.has(messageType)) {
|
||||
this.listeners.set(messageType, []);
|
||||
|
|
@ -196,11 +179,11 @@ export class VsCodeWebviewProtocol
|
|||
}
|
||||
|
||||
constructor(private readonly reloadConfig: () => void) {}
|
||||
invoke<T extends keyof ToCoreOrIdeFromWebviewProtocol>(
|
||||
invoke<T extends keyof FromWebviewProtocol>(
|
||||
messageType: T,
|
||||
data: ToCoreOrIdeFromWebviewProtocol[T][0],
|
||||
data: FromWebviewProtocol[T][0],
|
||||
messageId?: string,
|
||||
): ToCoreOrIdeFromWebviewProtocol[T][1] {
|
||||
): FromWebviewProtocol[T][1] {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
|
|
@ -208,10 +191,10 @@ export class VsCodeWebviewProtocol
|
|||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
public request<T extends keyof FullToWebviewFromIdeOrCoreProtocol>(
|
||||
public request<T extends keyof ToWebviewProtocol>(
|
||||
messageType: T,
|
||||
data: FullToWebviewFromIdeOrCoreProtocol[T][0],
|
||||
): Promise<FullToWebviewFromIdeOrCoreProtocol[T][1]> {
|
||||
data: ToWebviewProtocol[T][0],
|
||||
): Promise<ToWebviewProtocol[T][1]> {
|
||||
const messageId = uuidv4();
|
||||
return new Promise(async (resolve) => {
|
||||
let i = 0;
|
||||
|
|
@ -227,7 +210,7 @@ export class VsCodeWebviewProtocol
|
|||
|
||||
this.send(messageType, data, messageId);
|
||||
const disposable = this.webview.onDidReceiveMessage(
|
||||
(msg: Message<FullToWebviewFromIdeOrCoreProtocol[T][1]>) => {
|
||||
(msg: Message<ToWebviewProtocol[T][1]>) => {
|
||||
if (msg.messageId === messageId) {
|
||||
resolve(msg.data);
|
||||
disposable?.dispose();
|
||||
|
|
|
|||
3
gui/package-lock.json
generated
3
gui/package-lock.json
generated
|
|
@ -133,7 +133,8 @@
|
|||
"vectordb": "^0.4.20",
|
||||
"web-tree-sitter": "^0.21.0",
|
||||
"win-ca": "^3.5.1",
|
||||
"yaml": "^2.4.2"
|
||||
"yaml": "^2.4.2",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
Cog6ToothIcon,
|
||||
QuestionMarkCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { IndexingProgressUpdate } from "core";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
|
@ -30,8 +27,8 @@ import TextDialog from "./dialogs";
|
|||
import HeaderButtonWithText from "./HeaderButtonWithText";
|
||||
import IndexingProgressBar from "./loaders/IndexingProgressBar";
|
||||
import ProgressBar from "./loaders/ProgressBar";
|
||||
import ModelSelect from "./modelSelection/ModelSelect";
|
||||
import PostHogPageView from "./PosthogPageView";
|
||||
import ProfileSwitcher from "./ProfileSwitcher";
|
||||
|
||||
// #region Styled Components
|
||||
const FOOTER_HEIGHT = "1.8em";
|
||||
|
|
@ -80,7 +77,7 @@ const GridDiv = styled.div`
|
|||
overflow-x: visible;
|
||||
`;
|
||||
|
||||
const DropdownPortalDiv = styled.div`
|
||||
const ModelDropdownPortalDiv = styled.div`
|
||||
background-color: ${vscInputBackground};
|
||||
position: relative;
|
||||
margin-left: 8px;
|
||||
|
|
@ -88,6 +85,14 @@ const DropdownPortalDiv = styled.div`
|
|||
font-size: ${getFontSize()};
|
||||
`;
|
||||
|
||||
const ProfileDropdownPortalDiv = styled.div`
|
||||
background-color: ${vscInputBackground};
|
||||
position: relative;
|
||||
margin-left: calc(100% - 190px);
|
||||
z-index: 200;
|
||||
font-size: ${getFontSize() - 2};
|
||||
`;
|
||||
|
||||
// #endregion
|
||||
|
||||
const HIDE_FOOTER_ON_PAGES = [
|
||||
|
|
@ -251,13 +256,11 @@ const Layout = () => {
|
|||
<GridDiv>
|
||||
<PostHogPageView />
|
||||
<Outlet />
|
||||
<DropdownPortalDiv id="model-select-top-div"></DropdownPortalDiv>
|
||||
<ModelDropdownPortalDiv id="model-select-top-div"></ModelDropdownPortalDiv>
|
||||
<ProfileDropdownPortalDiv id="profile-select-top-div"></ProfileDropdownPortalDiv>
|
||||
{HIDE_FOOTER_ON_PAGES.includes(location.pathname) || (
|
||||
<Footer>
|
||||
<div className="mr-auto flex flex-grow gap-2 items-center overflow-hidden">
|
||||
<div className="flex-shrink-0">
|
||||
<ModelSelect />
|
||||
</div>
|
||||
{indexingState.status !== "indexing" && // Would take up too much space together with indexing progress
|
||||
defaultModel?.provider === "free-trial" && (
|
||||
<ProgressBar
|
||||
|
|
@ -267,6 +270,8 @@ const Layout = () => {
|
|||
)}
|
||||
<IndexingProgressBar indexingState={indexingState} />
|
||||
</div>
|
||||
|
||||
<ProfileSwitcher />
|
||||
<HeaderButtonWithText
|
||||
text="Help"
|
||||
onClick={() => {
|
||||
|
|
@ -279,15 +284,6 @@ const Layout = () => {
|
|||
>
|
||||
<QuestionMarkCircleIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
// navigate("/settings");
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
}}
|
||||
text="Configure Continue"
|
||||
>
|
||||
<Cog6ToothIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
</Footer>
|
||||
)}
|
||||
</GridDiv>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect } from "react";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
import { useSearchParams, useLocation } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { useLocation, useSearchParams } from "react-router-dom";
|
||||
|
||||
/**
|
||||
* This is copied from here: https://posthog.com/tutorials/single-page-app-pageviews#tracking-pageviews-in-nextjs-app-router
|
||||
|
|
|
|||
259
gui/src/components/ProfileSwitcher.tsx
Normal file
259
gui/src/components/ProfileSwitcher.tsx
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
ChevronUpDownIcon,
|
||||
Cog6ToothIcon,
|
||||
UserCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useAuth } from "../hooks/useAuth";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { RootState } from "../redux/store";
|
||||
import { getFontSize, isJetBrains } from "../util";
|
||||
import HeaderButtonWithText from "./HeaderButtonWithText";
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
min-width: 80px;
|
||||
`;
|
||||
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
border: none;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
padding: 3px 6px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
|
||||
font-size: ${getFontSize() - 2}px;
|
||||
`;
|
||||
|
||||
const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
bottom: calc(100% - 16px);
|
||||
max-width: 100%;
|
||||
max-height: 80vh;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
`;
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
|
||||
function ListBoxOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
selected,
|
||||
}: {
|
||||
option: ProfileDescription;
|
||||
idx: number;
|
||||
showDelete?: boolean;
|
||||
selected: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
return (
|
||||
<StyledListboxOption
|
||||
key={idx}
|
||||
selected={selected}
|
||||
value={option.id}
|
||||
onMouseEnter={() => {
|
||||
setHovered(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setHovered(false);
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 h-5 relative">
|
||||
{option.title}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
);
|
||||
}
|
||||
|
||||
function ProfileSwitcher(props: {}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { session, logout, login } = useAuth();
|
||||
const [profiles, setProfiles] = useState<ProfileDescription[]>([]);
|
||||
|
||||
const selectedProfileId = useSelector(
|
||||
(store: RootState) => store.state.selectedProfileId,
|
||||
);
|
||||
|
||||
const [controlServerBetaEnabled, setControlServerBetaEnabled] =
|
||||
useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger.ide.getIdeSettings().then((settings) => {
|
||||
setControlServerBetaEnabled(settings.enableControlServerBeta);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger.request("config/listProfiles", undefined).then(setProfiles);
|
||||
}, []);
|
||||
|
||||
useWebviewListener(
|
||||
"didChangeAvailableProfiles",
|
||||
async (data) => {
|
||||
setProfiles(data.profiles);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const topDiv = document.getElementById("profile-select-top-div");
|
||||
|
||||
function selectedProfile() {
|
||||
return profiles.find((p) => p.id === selectedProfileId);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{controlServerBetaEnabled && profiles.length > 0 && (
|
||||
<StyledListbox
|
||||
value={"GPT-4"}
|
||||
onChange={(id: string) => {
|
||||
ideMessenger.request("didChangeSelectedProfile", { id });
|
||||
}}
|
||||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton>
|
||||
<div>{selectedProfile()?.title}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-4 w-4 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledListboxButton>
|
||||
{topDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
{profiles.map((option, idx) => (
|
||||
<ListBoxOption
|
||||
selected={option.id === selectedProfileId}
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={profiles.length > 1}
|
||||
/>
|
||||
))}
|
||||
<div
|
||||
className="px-2 py-1"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 2 }}
|
||||
>
|
||||
{profiles.length === 0 ? (
|
||||
<i>No profiles found</i>
|
||||
) : (
|
||||
"Select profile"
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOptions>
|
||||
</Transition>,
|
||||
topDiv,
|
||||
)}
|
||||
</div>
|
||||
</StyledListbox>
|
||||
)}
|
||||
|
||||
{/* Settings button (either opens config.json or /settings page in control plane) */}
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
if (selectedProfileId === "local") {
|
||||
ideMessenger.post("openConfigJson", undefined);
|
||||
} else {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
`http://app.continue.dev/workspaces/${selectedProfileId}/settings`,
|
||||
);
|
||||
}
|
||||
}}
|
||||
text="Configure Continue"
|
||||
>
|
||||
<Cog6ToothIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
|
||||
{/* Only show login if beta explicitly enabled */}
|
||||
{!isJetBrains() && controlServerBetaEnabled && (
|
||||
<HeaderButtonWithText
|
||||
text={
|
||||
session?.account
|
||||
? `Logged in as ${session.account.label}`
|
||||
: "Click to login to Continue"
|
||||
}
|
||||
onClick={() => {
|
||||
if (session.account) {
|
||||
logout();
|
||||
} else {
|
||||
login();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<UserCircleIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProfileSwitcher;
|
||||
34
gui/src/components/loaders/BlinkingDot.tsx
Normal file
34
gui/src/components/loaders/BlinkingDot.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import styled, { css, keyframes } from "styled-components";
|
||||
|
||||
const DEFAULT_DIAMETER = 6;
|
||||
|
||||
const blink = keyframes`
|
||||
0%, 100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.25;
|
||||
}
|
||||
`;
|
||||
|
||||
const blinkAnimation = css`
|
||||
animation: ${blink} 3s infinite;
|
||||
`;
|
||||
|
||||
const BlinkingDot = styled.div<{
|
||||
color: string;
|
||||
diameter?: number;
|
||||
shouldBlink?: boolean;
|
||||
}>`
|
||||
background-color: ${(props) => props.color};
|
||||
box-shadow: 0px 0px 2px 1px ${(props) => props.color};
|
||||
width: ${(props) => props.diameter ?? DEFAULT_DIAMETER}px;
|
||||
height: ${(props) => props.diameter ?? DEFAULT_DIAMETER}px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.75);
|
||||
margin: 0 2px;
|
||||
${(props) => (props.shouldBlink ?? false) && blinkAnimation};
|
||||
`;
|
||||
|
||||
export default BlinkingDot;
|
||||
|
|
@ -21,6 +21,7 @@ import {
|
|||
getMetaKeyLabel,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
|
||||
const StyledDiv = styled.div<{ hidden?: boolean }>`
|
||||
position: absolute;
|
||||
|
|
@ -85,6 +86,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
return (
|
||||
<StyledDiv hidden={props.hidden} onClick={props.onClick} id="input-toolbar">
|
||||
<span className="cursor-pointer mr-auto flex items-center">
|
||||
<ModelSelect />
|
||||
<span
|
||||
style={{
|
||||
color: lightGray,
|
||||
|
|
|
|||
305
gui/src/components/modelSelection/LegacyModelSelect.tsx
Normal file
305
gui/src/components/modelSelection/LegacyModelSelect.tsx
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
ChevronUpDownIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
const StyledPlusIcon = styled(PlusIcon)`
|
||||
background-color: ${vscBackground};
|
||||
cursor: pointer;
|
||||
margin: 0px;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
border-left: 0.5px solid ${lightGray};
|
||||
`;
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
padding: 0;
|
||||
min-width: 80px;
|
||||
`;
|
||||
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
border: none;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
padding: 4px 8px;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
bottom: calc(100% - 16px);
|
||||
max-width: 100%;
|
||||
max-height: 80vh;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
`;
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
|
||||
function ListBoxOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
}: {
|
||||
option: Option;
|
||||
idx: number;
|
||||
showDelete?: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
return (
|
||||
<StyledListboxOption
|
||||
key={idx}
|
||||
selected={
|
||||
option.value ===
|
||||
JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})
|
||||
}
|
||||
value={option.value}
|
||||
onMouseEnter={() => {
|
||||
setHovered(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setHovered(false);
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 h-5 relative">
|
||||
<span>{option.title}</span>
|
||||
{hovered && showDelete && (
|
||||
<HeaderButtonWithText
|
||||
text={undefined}
|
||||
onClick={(e) => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text={`Are you sure you want to delete this model? (${option.title})`}
|
||||
onConfirm={() => {
|
||||
ideMessenger.post("config/deleteModel", {
|
||||
title: option.title,
|
||||
});
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}}
|
||||
backgroundColor={vscInputBackground}
|
||||
hoverBackgroundColor={vscBackground}
|
||||
className="absolute right-0 p-1"
|
||||
>
|
||||
<TrashIcon width="1.2em" height="1.2em" />
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
);
|
||||
}
|
||||
|
||||
function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
value: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
function ModelSelect(props: {}) {
|
||||
const dispatch = useDispatch();
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
const allModels = useSelector(
|
||||
(state: RootState) => state.state.config.models,
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
const topDiv = document.getElementById("model-select-top-div");
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event)) {
|
||||
const direction = event.shiftKey ? -1 : 1;
|
||||
const currentIndex = options.findIndex(
|
||||
(option) => option.value === defaultModel?.title,
|
||||
);
|
||||
let nextIndex = (currentIndex + 1 * direction) % options.length;
|
||||
if (nextIndex < 0) nextIndex = options.length - 1;
|
||||
dispatch(setDefaultModel({ title: options[nextIndex].value }));
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [options, defaultModel]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<GridDiv>
|
||||
<StyledListbox
|
||||
value={"GPT-4"}
|
||||
onChange={(val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: val }));
|
||||
// TODO
|
||||
// client?.setModelForRoleFromTitle("default", val);
|
||||
}}
|
||||
defaultValue={"GPT-4"}
|
||||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton>
|
||||
<div>{modelSelectTitle(defaultModel)}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledListboxButton>
|
||||
{topDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
{options.map((option, idx) => (
|
||||
<ListBoxOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={options.length > 1}
|
||||
/>
|
||||
))}
|
||||
{options.length === 0 && <i>No models found</i>}
|
||||
<i className="text-xs ml-2" style={{ color: lightGray }}>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
</StyledListboxOptions>
|
||||
</Transition>,
|
||||
topDiv,
|
||||
)}
|
||||
</div>
|
||||
</StyledListbox>
|
||||
|
||||
<StyledPlusIcon
|
||||
width="1.3em"
|
||||
height="1.3em"
|
||||
onClick={() => {
|
||||
navigate("/addModel");
|
||||
}}
|
||||
/>
|
||||
</GridDiv>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ModelSelect;
|
||||
|
|
@ -1,23 +1,10 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import {
|
||||
ChevronUpDownIcon,
|
||||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Fragment, useContext, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Listbox } from "@headlessui/react";
|
||||
import { ChevronDownIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "..";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
|
|
@ -26,95 +13,66 @@ import {
|
|||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import {
|
||||
getFontSize,
|
||||
getMetaKeyLabel,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
border: 0.5px solid ${lightGray};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
const StyledPlusIcon = styled(PlusIcon)`
|
||||
background-color: ${vscBackground};
|
||||
cursor: pointer;
|
||||
margin: 0px;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
border-left: 0.5px solid ${lightGray};
|
||||
`;
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
padding: 0;
|
||||
min-width: 80px;
|
||||
`;
|
||||
|
||||
const StyledListboxButton = styled(Listbox.Button)`
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
border: none;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
max-width: 180px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
padding: 4px 8px;
|
||||
|
||||
gap: 4px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: ${(props) => `${getFontSize() - 4}px`};
|
||||
background: transparent;
|
||||
color: ${(props) => lightGray};
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledListboxOptions = styled(Listbox.Options)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
margin-top: 4px;
|
||||
position: absolute;
|
||||
bottom: calc(100% - 16px);
|
||||
max-width: 100%;
|
||||
max-height: 80vh;
|
||||
list-style: none;
|
||||
padding: 4px;
|
||||
white-space: nowrap;
|
||||
cursor: default;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
border: 0.5px solid ${lightGray};
|
||||
background-color: ${vscInputBackground};
|
||||
`;
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
const StyledListboxOption = styled(Listbox.Option)`
|
||||
cursor: pointer;
|
||||
padding: 6px 8px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
background: ${(props) => `${lightGray}33`};
|
||||
}
|
||||
`;
|
||||
|
||||
function ListBoxOption({
|
||||
const StyledTrashIcon = styled(TrashIcon)`
|
||||
position: absolute;
|
||||
padding: 4px;
|
||||
right: 0;
|
||||
background: ${vscInputBackground};
|
||||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
&:hover {
|
||||
color: red;
|
||||
}
|
||||
`;
|
||||
|
||||
function ModelOption({
|
||||
option,
|
||||
idx,
|
||||
showDelete,
|
||||
|
|
@ -131,13 +89,6 @@ function ListBoxOption({
|
|||
return (
|
||||
<StyledListboxOption
|
||||
key={idx}
|
||||
selected={
|
||||
option.value ===
|
||||
JSON.stringify({
|
||||
t: "default",
|
||||
idx: -1,
|
||||
})
|
||||
}
|
||||
value={option.value}
|
||||
onMouseEnter={() => {
|
||||
setHovered(true);
|
||||
|
|
@ -149,8 +100,9 @@ function ListBoxOption({
|
|||
<div className="flex items-center justify-between gap-3 h-5 relative">
|
||||
<span>{option.title}</span>
|
||||
{hovered && showDelete && (
|
||||
<HeaderButtonWithText
|
||||
text={undefined}
|
||||
<StyledTrashIcon
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
onClick={(e) => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
|
|
@ -168,12 +120,7 @@ function ListBoxOption({
|
|||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}}
|
||||
backgroundColor={vscInputBackground}
|
||||
hoverBackgroundColor={vscBackground}
|
||||
className="absolute right-0 p-1"
|
||||
>
|
||||
<TrashIcon width="1.2em" height="1.2em" />
|
||||
</HeaderButtonWithText>
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</StyledListboxOption>
|
||||
|
|
@ -218,8 +165,6 @@ function ModelSelect(props: {}) {
|
|||
);
|
||||
}, [allModels]);
|
||||
|
||||
const topDiv = document.getElementById("model-select-top-div");
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event)) {
|
||||
|
|
@ -240,65 +185,50 @@ function ModelSelect(props: {}) {
|
|||
}, [options, defaultModel]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<GridDiv>
|
||||
<StyledListbox
|
||||
value={"GPT-4"}
|
||||
onChange={(val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: val }));
|
||||
// TODO
|
||||
// client?.setModelForRoleFromTitle("default", val);
|
||||
}}
|
||||
defaultValue={"GPT-4"}
|
||||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton>
|
||||
<div>{modelSelectTitle(defaultModel)}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledListboxButton>
|
||||
{topDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
{options.map((option, idx) => (
|
||||
<ListBoxOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={options.length > 1}
|
||||
/>
|
||||
))}
|
||||
{options.length === 0 && <i>No models found</i>}
|
||||
<i className="text-xs ml-2" style={{ color: lightGray }}>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
</StyledListboxOptions>
|
||||
</Transition>,
|
||||
topDiv,
|
||||
)}
|
||||
<Listbox
|
||||
onChange={(val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: val }));
|
||||
}}
|
||||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton className="h-[18px] overflow-hidden">
|
||||
<div>{modelSelectTitle(defaultModel) || "Select model"}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronDownIcon
|
||||
className="h-2.5 w-2.5 text-gray-400"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledListbox>
|
||||
</StyledListboxButton>
|
||||
<StyledListboxOptions>
|
||||
{options.map((option, idx) => (
|
||||
<ModelOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showDelete={options.length > 1}
|
||||
/>
|
||||
))}
|
||||
<StyledListboxOption
|
||||
key={options.length}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
navigate("/addModel");
|
||||
}}
|
||||
value={"addModel" as any}
|
||||
className="font-bold"
|
||||
>
|
||||
+ Add Model
|
||||
</StyledListboxOption>
|
||||
|
||||
<StyledPlusIcon
|
||||
width="1.3em"
|
||||
height="1.3em"
|
||||
onClick={() => {
|
||||
navigate("/addModel");
|
||||
}}
|
||||
/>
|
||||
</GridDiv>
|
||||
</>
|
||||
<i style={{ color: lightGray, padding: "4px", marginTop: "4px" }}>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
</StyledListboxOptions>
|
||||
</div>
|
||||
</Listbox>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
54
gui/src/hooks/useAuth.tsx
Normal file
54
gui/src/hooks/useAuth.tsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiStateSlice";
|
||||
import { useWebviewListener } from "./useWebviewListener";
|
||||
|
||||
export function useAuth(): {
|
||||
session: ControlPlaneSessionInfo | undefined;
|
||||
logout: () => void;
|
||||
login: () => void;
|
||||
} {
|
||||
const [session, setSession] = useState<ControlPlaneSessionInfo | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useWebviewListener("didChangeControlPlaneSessionInfo", async (data) => {
|
||||
setSession(data.sessionInfo);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: true })
|
||||
.then(setSession);
|
||||
}, []);
|
||||
|
||||
const login = () => {
|
||||
console.log("login");
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: false })
|
||||
.then(setSession);
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text={"Click the user icon in the bottom left of VS Code to log out."}
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
session,
|
||||
logout,
|
||||
login,
|
||||
};
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
addContextItemsAtIndex,
|
||||
setConfig,
|
||||
setInactive,
|
||||
setSelectedProfileId,
|
||||
} from "../redux/slices/stateSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
|
||||
|
|
@ -22,11 +23,12 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const loadConfig = async () => {
|
||||
const config = await ideMessenger.request(
|
||||
"config/getBrowserSerialized",
|
||||
const { config, profileId } = await ideMessenger.request(
|
||||
"config/getSerializedProfileInfo",
|
||||
undefined,
|
||||
);
|
||||
dispatch(setConfig(config));
|
||||
dispatch(setSelectedProfileId(profileId));
|
||||
setConfigLoaded(true);
|
||||
|
||||
// Perform any actions needed with the config
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import QuickModelSetup from "../../components/modelSelection/quickSetup/QuickModelSetup";
|
||||
import { getLocalStorage } from "../../util/localStorage";
|
||||
import Toggle from "../../components/modelSelection/Toggle";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { getLocalStorage } from "../../util/localStorage";
|
||||
import DefaultModelConfigForm from "./DefaultModelConfigForm";
|
||||
import { useOnboarding } from "./utils";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { CheckMarkHeader } from "./CheckMarkHeader";
|
||||
import { StyledButton } from "./components";
|
||||
import { CopyToTerminalButton } from "./CopyToTerminalButton";
|
||||
import { CheckMarkHeader } from "./CheckMarkHeader";
|
||||
import { ONBOARDING_LOCAL_MODEL_TITLE } from "core/config/onboarding";
|
||||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { useOnboarding } from "./utils";
|
||||
|
||||
type OllamaConnectionStatuses =
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ type State = {
|
|||
sessionId: string;
|
||||
defaultModelTitle: string;
|
||||
mainEditorContent?: JSONContent;
|
||||
selectedProfileId: string;
|
||||
};
|
||||
|
||||
const initialState: State = {
|
||||
|
|
@ -135,6 +136,7 @@ const initialState: State = {
|
|||
title: "New Session",
|
||||
sessionId: v4(),
|
||||
defaultModelTitle: "GPT-4",
|
||||
selectedProfileId: "local",
|
||||
};
|
||||
|
||||
export const stateSlice = createSlice({
|
||||
|
|
@ -468,6 +470,12 @@ export const stateSlice = createSlice({
|
|||
defaultModelTitle: payload.title,
|
||||
};
|
||||
},
|
||||
setSelectedProfileId: (state, { payload }: PayloadAction<string>) => {
|
||||
return {
|
||||
...state,
|
||||
selectedProfileId: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -491,5 +499,6 @@ export const {
|
|||
setMessageAtIndex,
|
||||
clearLastResponse,
|
||||
consumeMainEditorContent,
|
||||
setSelectedProfileId,
|
||||
} = stateSlice.actions;
|
||||
export default stateSlice.reducer;
|
||||
|
|
|
|||
29
packages/control-plane-types/package-lock.json
generated
Normal file
29
packages/control-plane-types/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz",
|
||||
"integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
packages/control-plane-types/package.json
Normal file
15
packages/control-plane-types/package.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "control-plane-types",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Nate Sesti and Ty Dunn",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
}
|
||||
4
packages/control-plane-types/src/index.d.ts
vendored
Normal file
4
packages/control-plane-types/src/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export interface Test {
|
||||
a: string;
|
||||
b: number;
|
||||
}
|
||||
108
packages/control-plane-types/tsconfig.json
Normal file
108
packages/control-plane-types/tsconfig.json
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
||||
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
||||
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
||||
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
||||
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue