Merge branch 'main' into dallin/content-bug
This commit is contained in:
commit
53584b6bcc
113 changed files with 2603 additions and 663 deletions
18
.github/workflows/pr_checks.yaml
vendored
18
.github/workflows/pr_checks.yaml
vendored
|
|
@ -5,6 +5,7 @@ on:
|
|||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "extensions/intellij/**"
|
||||
- "extensions/vscode/**"
|
||||
- "core/**"
|
||||
- "gui/**"
|
||||
|
|
@ -274,6 +275,11 @@ jobs:
|
|||
run: |
|
||||
cd core
|
||||
npm test
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
|
||||
|
||||
vscode-get-test-file-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -370,7 +376,7 @@ jobs:
|
|||
path: extensions/vscode/e2e/storage
|
||||
|
||||
vscode-e2e-tests:
|
||||
name: ${{ matrix.test_file }}"
|
||||
name: ${{ matrix.test_file }} (${{ matrix.command }})
|
||||
needs:
|
||||
[
|
||||
vscode-download-e2e-dependencies,
|
||||
|
|
@ -384,6 +390,7 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }}
|
||||
command: [ "e2e:ci:run", "e2e:ci:run-yaml" ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -432,8 +439,7 @@ jobs:
|
|||
- name: Run e2e tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
TEST_FILE="${{ matrix.test_file }}" npm run e2e:ci:run
|
||||
|
||||
TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
env:
|
||||
DISPLAY: :99
|
||||
|
||||
|
|
@ -546,7 +552,7 @@ jobs:
|
|||
with:
|
||||
url: http://127.0.0.1:8082
|
||||
max-attempts: 15
|
||||
retry-delay: 5s
|
||||
retry-delay: 30s
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
|
|
@ -572,6 +578,4 @@ jobs:
|
|||
with:
|
||||
name: jb-failure-report
|
||||
path: |
|
||||
${{ github.workspace }}/extensions/intellij/build/reports
|
||||
|
||||
|
||||
${{ github.workspace }}/extensions/intellij/build/reports
|
||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
|
@ -20,10 +20,10 @@
|
|||
"outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"],
|
||||
"preLaunchTask": "vscode-extension:build",
|
||||
"env": {
|
||||
// "CONTROL_PLANE_ENV": "local",
|
||||
"CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug"
|
||||
// "staging" for the preview deployment "CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug"
|
||||
// "local" for entirely local development of control plane/proxy
|
||||
// "CONTROL_PLANE_ENV": "staging"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -118,6 +118,22 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
}
|
||||
|
||||
(async () => {
|
||||
// Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
// This is only needed for our `pkg` command at build time
|
||||
fs.writeFileSync(
|
||||
"out/package.json",
|
||||
JSON.stringify(
|
||||
{
|
||||
name: "binary",
|
||||
version: "1.0.0",
|
||||
author: "Continue Dev, Inc",
|
||||
license: "Apache-2.0",
|
||||
},
|
||||
undefined,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
console.log("[info] Downloading prebuilt lancedb...");
|
||||
for (const target of targets) {
|
||||
if (targetToLanceDb[target]) {
|
||||
|
|
@ -263,9 +279,12 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
|
||||
// Informs the `continue-binary` of where to look for node_sqlite3.node
|
||||
// https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
fs.writeFileSync(`${targetDir}/package.json`, "");
|
||||
// fs.writeFileSync(`${targetDir}/package.json`, "");
|
||||
}
|
||||
|
||||
// Cleanup - this is needed when running locally
|
||||
fs.rmSync("out/package.json");
|
||||
|
||||
const pathsToVerify = [];
|
||||
for (const target of targets) {
|
||||
const exe = target.startsWith("win") ? ".exe" : "";
|
||||
|
|
|
|||
2
binary/package-lock.json
generated
2
binary/package-lock.json
generated
|
|
@ -48,7 +48,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -1,158 +0,0 @@
|
|||
# Tab Autocomplete (beta)
|
||||
|
||||
Continue now provides support for tab autocomplete in [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains IDEs](https://plugins.jetbrains.com/plugin/22707-continue/edit). We will be greatly improving the experience over the next few releases, and it is always helpful to hear feedback. If you have any problems or suggestions, please let us know in our [Discord](https://discord.gg/vapESyrFmJ).
|
||||
|
||||
## Setting up with Ollama (default)
|
||||
|
||||
We recommend setting up tab-autocomplete with a local Ollama instance. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model:
|
||||
|
||||
```bash
|
||||
ollama run qwen2.5-coder:1.5b-base
|
||||
```
|
||||
|
||||
Once it has been downloaded, you should begin to see completions in VS Code.
|
||||
|
||||
## Setting up with LM Studio
|
||||
|
||||
You can also set up tab-autocomplete with a local LM Studio instance by following these steps:
|
||||
|
||||
1. Download the latest version of LM Studio from [here](https://lmstudio.ai/)
|
||||
2. Download a model (e.g. search for `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF` and choose one of the options there)
|
||||
3. Go to the server section (button is on the left), select your model from the dropdown at the top, and click "Start Server"
|
||||
4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf`); this will be used as the "model" attribute in Continue
|
||||
5. Go to Continue and modify the configurations for a [custom model](#setting-up-a-custom-model)
|
||||
6. Set the "provider" to `lmstudio` and the "model" to the path copied earlier
|
||||
|
||||
Example:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Qwen2.5-Coder 1.5b",
|
||||
"model": "Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF",
|
||||
"provider": "lmstudio"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Setting up a custom model
|
||||
|
||||
All of the configuration options available for chat models are available to use for tab-autocomplete. For example, if you wanted to use a remote vLLM instance you would edit your `config.json` like this (note that it is not inside the models array), filling in the correct model name and vLLM endpoint:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "openai",
|
||||
"model": "<MODEL_NAME>",
|
||||
"apiBase": "<VLLM_ENDPOINT_URL>"
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
As another example, say you want to use a different model, `deepseek-coder:6.7b-base`, with Ollama:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "deepseek-coder:6.7b-base"
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
If you aren't yet familiar with the available options, you can learn more in our [overview](../setup/overview.md).
|
||||
|
||||
### What model should I use?
|
||||
|
||||
If you are running the model locally, we recommend `qwen2.5-coder:1.5b`.
|
||||
|
||||
If you have a bit more compute, or are running a model in the cloud, you can upgrade to `qwen2.5-coder:7b`.
|
||||
|
||||
Regardless of what you are willing to spend, we do not recommend using GPT or Claude for autocomplete. Learn why [below](#i-want-better-completions-should-i-use-gpt-4).
|
||||
|
||||
## Configuration Options
|
||||
|
||||
The following can be configured in `config.json`:
|
||||
|
||||
### `tabAutocompleteModel`
|
||||
|
||||
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `qwen2.5-coder:1.5b`, or `starcoder-3b`.
|
||||
|
||||
### `tabAutocompleteOptions`
|
||||
|
||||
This object allows you to customize the behavior of tab-autocomplete. The available options are:
|
||||
|
||||
- `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean)
|
||||
- `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number)
|
||||
- `debounceDelay`: The delay in milliseconds before triggering autocomplete after a keystroke. (Number)
|
||||
- `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number)
|
||||
- `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number)
|
||||
- `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String)
|
||||
- `multilineCompletions`: Whether to enable multiline completions ("always", "never", or "auto"). Defaults to "auto".
|
||||
|
||||
### Full example
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "qwen2.5-coder:1.5b-base",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
"tabAutocompleteOptions": {
|
||||
"maxPromptTokens": 400,
|
||||
"prefixPercentage": 0.5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### I want better completions, should I use GPT-4?
|
||||
|
||||
Perhaps surprisingly, the answer is no. The models that we suggest for autocomplete are trained with a highly specific prompt format, which allows them to respond to requests for completing code (see examples of these prompts [here](https://github.com/continuedev/continue/blob/main/core/autocomplete/templates.ts)). Some of the best commercial models like GPT-4 or Claude are not trained with this prompt format, which means that they won't generate useful completions. Luckily, a huge model is not required for great autocomplete. Most of the state-of-the-art autocomplete models are no more than 10b parameters, and increasing beyond this does not significantly improve performance.
|
||||
|
||||
### I'm not seeing any completions
|
||||
|
||||
Follow these steps to ensure that everything is set up correctly:
|
||||
|
||||
1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar).
|
||||
2. Make sure you have downloaded Ollama.
|
||||
3. Run `ollama run qwen2.5-coder:1.5b-base` to verify that the model is downloaded.
|
||||
4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere.
|
||||
5. If you are using another Ollama model for chat and your resources are limited, this will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both. A resolution for this could be using the same model for chat and autocomplete.
|
||||
6. Check the output of the logs to find any potential errors (cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains).
|
||||
7. If you are still having issues, please let us know in our [Discord](https://discord.gg/vapESyrFmJ) and we'll help as soon as possible.
|
||||
|
||||
### Completions are slow
|
||||
|
||||
Depending on your hardware, you may want to try a smaller, faster model. If 3b isn't working for you we recommend trying `deepseek-coder:1.3b-base`.
|
||||
|
||||
### Completions don't know about my code
|
||||
|
||||
We are working on this! Right now Continue uses the Language Server Protocol to add definitions to the prompt, as well as using similarity search over recently edited files. We will be improving the accuracy of this system greatly over the next few weeks.
|
||||
|
||||
### Completions contain formatting errors
|
||||
|
||||
If you're seeing a common pattern of mistake that might be helpful to report, please share in Discord. We will do our best to fix it as soon as possible.
|
||||
|
||||
## How to turn off autocomplete
|
||||
|
||||
### VS Code
|
||||
|
||||
Click the "Continue" button in the status panel at the bottom right of the screen. The checkmark will become a "cancel" symbol and you will no longer see completions. You can click again to turn it back on.
|
||||
|
||||
Alternatively, open VS Code settings, search for "Continue" and uncheck the box for "Enable Tab Autocomplete".
|
||||
|
||||
### JetBrains
|
||||
|
||||
Open Settings -> Tools -> Continue and uncheck the box for "Enable Tab Autocomplete".
|
||||
|
||||
### Feedback
|
||||
|
||||
If you're turning off autocomplete, we'd love to hear how we can improve! Please let us know in our [Discord](https://discord.gg/vapESyrFmJ) or file an issue on GitHub.
|
||||
|
|
@ -14,7 +14,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
expect(profiles[0].id).toBe("local");
|
||||
|
||||
const currentProfile = testConfigHandler.currentProfile;
|
||||
expect(currentProfile.profileId).toBe("local");
|
||||
expect(currentProfile.profileDescription.id).toBe("local");
|
||||
});
|
||||
|
||||
test("should load the default config successfully", async () => {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,21 @@ import Ollama from "../llm/llms/Ollama.js";
|
|||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
import { getConfigJsonPath } from "../util/paths.js";
|
||||
|
||||
import { ConfigResult } from "./load.js";
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { controlPlaneEnv } from "../control-plane/env.js";
|
||||
import { usePlatform } from "../control-plane/flags.js";
|
||||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
} from "./onboarding.js";
|
||||
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
|
||||
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
|
||||
import PlatformProfileLoader from "./profile/PlatformProfileLoader.js";
|
||||
import {
|
||||
ProfileDescription,
|
||||
ProfileLifecycleManager,
|
||||
} from "./ProfileLifecycleManager.js";
|
||||
import { pathToFileURL } from "url";
|
||||
import { localPathToUri } from "../util/pathToUri.js";
|
||||
|
||||
export type { ProfileDescription };
|
||||
|
||||
|
|
@ -57,7 +60,7 @@ export class ConfigHandler {
|
|||
writeLog,
|
||||
);
|
||||
this.profiles = [new ProfileLifecycleManager(localProfileLoader)];
|
||||
this.selectedProfileId = localProfileLoader.profileId;
|
||||
this.selectedProfileId = localProfileLoader.description.id;
|
||||
|
||||
// Always load local profile immediately in case control plane doesn't load
|
||||
try {
|
||||
|
|
@ -77,39 +80,40 @@ export class ConfigHandler {
|
|||
|
||||
get currentProfile() {
|
||||
return (
|
||||
this.profiles.find((p) => p.profileId === this.selectedProfileId) ??
|
||||
this.fallbackProfile
|
||||
this.profiles.find(
|
||||
(p) => p.profileDescription.id === this.selectedProfileId,
|
||||
) ?? this.fallbackProfile
|
||||
);
|
||||
}
|
||||
|
||||
get inactiveProfiles() {
|
||||
return this.profiles.filter((p) => p.profileId !== this.selectedProfileId);
|
||||
return this.profiles.filter(
|
||||
(p) => p.profileDescription.id !== this.selectedProfileId,
|
||||
);
|
||||
}
|
||||
|
||||
async openConfigProfile(profileId?: string) {
|
||||
let openProfileId = profileId || this.selectedProfileId;
|
||||
if (openProfileId === "local") {
|
||||
await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString());
|
||||
await this.ide.openFile(localPathToUri(getConfigJsonPath()));
|
||||
} else {
|
||||
await this.ide.openUrl(
|
||||
"https://app.continue.dev/",
|
||||
// `https://app.continue.dev/workspaces/${openProfileId}/chat`,
|
||||
);
|
||||
await this.ide.openUrl(`${controlPlaneEnv.APP_URL}${openProfileId}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchControlPlaneProfiles() {
|
||||
private async loadPlatformProfiles() {
|
||||
// Get the profiles and create their lifecycle managers
|
||||
this.controlPlaneClient
|
||||
.listWorkspaces()
|
||||
.then(async (workspaces) => {
|
||||
.listAssistants()
|
||||
.then(async (assistants) => {
|
||||
this.profiles = this.profiles.filter(
|
||||
(profile) => profile.profileId === "local",
|
||||
(profile) => profile.profileDescription.id === "local",
|
||||
);
|
||||
workspaces.forEach((workspace) => {
|
||||
const profileLoader = new ControlPlaneProfileLoader(
|
||||
workspace.id,
|
||||
workspace.name,
|
||||
assistants.forEach((assistant) => {
|
||||
const profileLoader = new PlatformProfileLoader(
|
||||
assistant.configResult,
|
||||
assistant.ownerSlug,
|
||||
assistant.packageSlug,
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
|
|
@ -141,10 +145,67 @@ export class ConfigHandler {
|
|||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
console.error("Failed to list assistants: ", e);
|
||||
});
|
||||
}
|
||||
|
||||
private platformProfilesRefreshInterval: NodeJS.Timeout | undefined;
|
||||
|
||||
private async fetchControlPlaneProfiles() {
|
||||
if (usePlatform()) {
|
||||
clearInterval(this.platformProfilesRefreshInterval);
|
||||
await this.loadPlatformProfiles();
|
||||
this.platformProfilesRefreshInterval = setInterval(
|
||||
this.loadPlatformProfiles.bind(this),
|
||||
PlatformProfileLoader.RELOAD_INTERVAL,
|
||||
);
|
||||
} else {
|
||||
this.controlPlaneClient
|
||||
.listWorkspaces()
|
||||
.then(async (workspaces) => {
|
||||
this.profiles = this.profiles.filter(
|
||||
(profile) => profile.profileDescription.id === "local",
|
||||
);
|
||||
workspaces.forEach((workspace) => {
|
||||
const profileLoader = new ControlPlaneProfileLoader(
|
||||
workspace.id,
|
||||
workspace.name,
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.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;
|
||||
await this.loadConfig();
|
||||
} else {
|
||||
// Otherwise we stick with local profile, and record choice
|
||||
lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId;
|
||||
this.globalContext.update(
|
||||
"lastSelectedProfileForWorkspace",
|
||||
lastSelectedWorkspaceIds,
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async setSelectedProfile(profileId: string) {
|
||||
this.selectedProfileId = profileId;
|
||||
const result = await this.loadConfig();
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
IContextProvider,
|
||||
} from "../index.js";
|
||||
|
||||
import { ConfigResult, finalToBrowserConfig } from "./load.js";
|
||||
import { finalToBrowserConfig } from "./load.js";
|
||||
import { IProfileLoader } from "./profile/IProfileLoader.js";
|
||||
|
||||
export interface ProfileDescription {
|
||||
title: string;
|
||||
id: string;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
}
|
||||
|
||||
export class ProfileLifecycleManager {
|
||||
|
|
@ -19,19 +21,8 @@ export class ProfileLifecycleManager {
|
|||
|
||||
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,
|
||||
};
|
||||
return this.profileLoader.description;
|
||||
}
|
||||
|
||||
clearConfig() {
|
||||
|
|
@ -71,14 +62,10 @@ export class ProfileLifecycleManager {
|
|||
result.config.contextProviders = (
|
||||
result.config.contextProviders ?? []
|
||||
).concat(additionalContextProviders);
|
||||
|
||||
this.savedConfigResult = result;
|
||||
resolve(result);
|
||||
} else if (result.errors) {
|
||||
reject(
|
||||
`Error in config.json: ${result.errors.map((item) => item.message).join(" | ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
this.savedConfigResult = result;
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
// Wait for the config promise to resolve
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ import {
|
|||
getEsbuildBinaryPath,
|
||||
} from "../util/paths";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { usePlatform } from "../control-plane/flags";
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
|
|
@ -70,13 +72,8 @@ import {
|
|||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
// import { isSupportedLanceDbCpuTarget } from "./util";
|
||||
import { ConfigValidationError, validateConfig } from "./validation.js";
|
||||
|
||||
export interface ConfigResult<T> {
|
||||
config: T | undefined;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
configLoadInterrupted: boolean;
|
||||
}
|
||||
import { validateConfig } from "./validation.js";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
let content = fs.readFileSync(filepath, "utf8");
|
||||
|
|
@ -229,7 +226,7 @@ function isModelDescription(
|
|||
return (llm as ModelDescription).title !== undefined;
|
||||
}
|
||||
|
||||
function isContextProviderWithParams(
|
||||
export function isContextProviderWithParams(
|
||||
contextProvider: CustomContextProvider | ContextProviderWithParams,
|
||||
): contextProvider is ContextProviderWithParams {
|
||||
return (contextProvider as ContextProviderWithParams).name !== undefined;
|
||||
|
|
@ -582,6 +579,7 @@ function finalToBrowserConfig(
|
|||
experimental: final.experimental,
|
||||
docs: final.docs,
|
||||
tools: final.tools,
|
||||
usePlatform: usePlatform(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -816,7 +814,7 @@ async function loadFullConfigNode(
|
|||
"Could not load config.ts as absolute path, retrying as file url ...",
|
||||
);
|
||||
try {
|
||||
module = await import(`file://${configJsPath}`);
|
||||
module = await import(localPathToUri(configJsPath));
|
||||
} catch (e) {
|
||||
throw new Error("Could not load config.ts as file url either", {
|
||||
cause: e,
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ import {
|
|||
IdeSettings,
|
||||
SerializedContinueConfig,
|
||||
} from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
export default class ControlPlaneProfileLoader implements IProfileLoader {
|
||||
private static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes
|
||||
|
||||
readonly profileId: string;
|
||||
profileTitle: string;
|
||||
description: ProfileDescription;
|
||||
|
||||
workspaceSettings: ConfigJson | undefined;
|
||||
|
||||
|
|
@ -29,12 +29,17 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
private writeLog: (message: string) => Promise<void>,
|
||||
private readonly onReload: () => void,
|
||||
) {
|
||||
this.profileId = workspaceId;
|
||||
this.profileTitle = workspaceTitle;
|
||||
this.description = {
|
||||
id: workspaceId,
|
||||
title: workspaceTitle,
|
||||
errors: undefined,
|
||||
};
|
||||
|
||||
setInterval(async () => {
|
||||
this.workspaceSettings =
|
||||
await this.controlPlaneClient.getSettingsForWorkspace(this.profileId);
|
||||
await this.controlPlaneClient.getSettingsForWorkspace(
|
||||
this.description.id,
|
||||
);
|
||||
this.onReload();
|
||||
}, ControlPlaneProfileLoader.RELOAD_INTERVAL);
|
||||
}
|
||||
|
|
@ -43,7 +48,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
const settings =
|
||||
this.workspaceSettings ??
|
||||
((await this.controlPlaneClient.getSettingsForWorkspace(
|
||||
this.profileId,
|
||||
this.description.id,
|
||||
)) as any);
|
||||
const serializedConfig: SerializedContinueConfig = settings;
|
||||
|
||||
|
|
@ -53,6 +58,8 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
serializedConfig,
|
||||
undefined,
|
||||
undefined,
|
||||
this.workspaceId,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// ProfileHandlers manage the loading of a config, allowing us to abstract over different ways of getting to a ContinueConfig
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ContinueConfig } from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
// After we have the ContinueConfig, the ConfigHandler takes care of everything else (loading models, lifecycle, etc.)
|
||||
export interface IProfileLoader {
|
||||
profileTitle: string;
|
||||
profileId: string;
|
||||
description: ProfileDescription;
|
||||
doLoadConfig(): Promise<ConfigResult<ContinueConfig>>;
|
||||
setIsActive(isActive: boolean): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
import { ConfigResult } from "../load.js";
|
||||
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
export default class LocalProfileLoader implements IProfileLoader {
|
||||
static ID = "local";
|
||||
profileId = LocalProfileLoader.ID;
|
||||
profileTitle = "Local Config";
|
||||
description: ProfileDescription = {
|
||||
id: LocalProfileLoader.ID,
|
||||
title: "Local Config",
|
||||
errors: undefined,
|
||||
};
|
||||
|
||||
constructor(
|
||||
private ide: IDE,
|
||||
|
|
@ -18,13 +22,19 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
) {}
|
||||
|
||||
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
return doLoadConfig(
|
||||
const result = await doLoadConfig(
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
|
||||
this.description.errors = result.errors;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
|
|
|
|||
90
core/config/profile/PlatformProfileLoader.ts
Normal file
90
core/config/profile/PlatformProfileLoader.ts
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
/**
|
||||
* Metadata about the package that is currently being loaded
|
||||
* If this is `undefined`, it's not a config from the platform,
|
||||
* could be local for example.
|
||||
*/
|
||||
export interface PlatformConfigMetadata {
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
}
|
||||
|
||||
export default class PlatformProfileLoader implements IProfileLoader {
|
||||
static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes
|
||||
|
||||
description: ProfileDescription;
|
||||
|
||||
constructor(
|
||||
private configResult: ConfigResult<ClientConfigYaml>,
|
||||
private readonly ownerSlug: string,
|
||||
private readonly packageSlug: string,
|
||||
private readonly controlPlaneClient: ControlPlaneClient,
|
||||
private readonly ide: IDE,
|
||||
private ideSettingsPromise: Promise<IdeSettings>,
|
||||
private writeLog: (message: string) => Promise<void>,
|
||||
private readonly onReload: () => void,
|
||||
) {
|
||||
this.description = {
|
||||
id: `${ownerSlug}/${packageSlug}`,
|
||||
title: `${ownerSlug}/${packageSlug}`,
|
||||
errors: configResult.errors,
|
||||
};
|
||||
|
||||
setInterval(async () => {
|
||||
const assistants = await this.controlPlaneClient.listAssistants();
|
||||
const newConfigResult = assistants.find(
|
||||
(assistant) =>
|
||||
assistant.packageSlug === this.packageSlug &&
|
||||
assistant.ownerSlug === this.ownerSlug,
|
||||
)?.configResult;
|
||||
if (!newConfigResult) {
|
||||
return;
|
||||
}
|
||||
this.configResult = {
|
||||
config: newConfigResult.config,
|
||||
errors: newConfigResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
this.onReload();
|
||||
}, PlatformProfileLoader.RELOAD_INTERVAL);
|
||||
}
|
||||
|
||||
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
if (this.configResult.errors?.length) {
|
||||
return {
|
||||
config: undefined,
|
||||
errors: this.configResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
}
|
||||
|
||||
const results = await doLoadConfig(
|
||||
this.ide,
|
||||
this.ideSettingsPromise,
|
||||
this.controlPlaneClient,
|
||||
this.writeLog,
|
||||
undefined,
|
||||
this.configResult.config,
|
||||
{
|
||||
ownerSlug: this.ownerSlug,
|
||||
packageSlug: this.packageSlug,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...results,
|
||||
errors: [], // Don't do config validation here, it happens in admin panel
|
||||
};
|
||||
}
|
||||
|
||||
setIsActive(isActive: boolean): void {}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import fs from "fs";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
|
|
@ -15,9 +17,9 @@ import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
|||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { TTS } from "../../util/tts";
|
||||
import { ConfigResult, loadFullConfigNode } from "../load";
|
||||
import { ConfigValidationError } from "../validation";
|
||||
import { loadFullConfigNode } from "../load";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
|
|
@ -25,6 +27,8 @@ export default async function doLoadConfig(
|
|||
controlPlaneClient: ControlPlaneClient,
|
||||
writeLog: (message: string) => Promise<void>,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
workspaceId?: string,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const workspaceConfigs = await getWorkspaceConfigs(ide);
|
||||
|
|
@ -39,7 +43,7 @@ export default async function doLoadConfig(
|
|||
let errors: ConfigValidationError[] | undefined;
|
||||
let configLoadInterrupted = false;
|
||||
|
||||
if (fs.existsSync(configYamlPath)) {
|
||||
if (fs.existsSync(configYamlPath) || overrideConfigYaml) {
|
||||
const result = await loadContinueConfigFromYaml(
|
||||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
|
|
@ -48,8 +52,9 @@ export default async function doLoadConfig(
|
|||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
undefined,
|
||||
// overrideConfigYaml, TODO
|
||||
overrideConfigYaml,
|
||||
platformConfigMetadata,
|
||||
controlPlaneClient,
|
||||
);
|
||||
newConfig = result.config;
|
||||
errors = result.errors;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ModelDescription, SerializedContinueConfig } from "../";
|
||||
import { Telemetry } from "../util/posthog";
|
||||
|
||||
export interface ConfigValidationError {
|
||||
fatal: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a SerializedContinueConfig object to ensure all properties are correctly formed.
|
||||
* @param config The configuration object to validate.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export function convertConfigJsonToConfigYaml(
|
|||
): ConfigYaml {
|
||||
return {
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
models: [
|
||||
...configJson.models.map(
|
||||
(model): ModelConfig => ({
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ export const defaultConfigYaml: ConfigYaml = {
|
|||
models: [],
|
||||
context: [],
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
};
|
||||
|
||||
export const defaultConfigYamlJetBrains: ConfigYaml = {
|
||||
models: [],
|
||||
context: [],
|
||||
name: "Local Config",
|
||||
version: "1.0.0",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import fs from "node:fs";
|
||||
import path from "path";
|
||||
|
||||
import {
|
||||
extendConfig,
|
||||
ConfigResult,
|
||||
fillTemplateVariables,
|
||||
resolveSecretsOnClient,
|
||||
validateConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { ValidationLevel } from "@continuedev/config-yaml/dist/validation";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
|
|
@ -26,23 +25,17 @@ import { contextProviderClassFromName } from "../../context/providers/index";
|
|||
import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders";
|
||||
import FreeTrial from "../../llm/llms/FreeTrial";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import {
|
||||
getConfigYamlPath,
|
||||
getContinueDotEnv,
|
||||
readAllGlobalPromptFiles,
|
||||
} from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { ConfigValidationError } from "../validation.js";
|
||||
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { getConfigYamlPath, getContinueDotEnv } from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
export interface ConfigResult<T> {
|
||||
config: T | undefined;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
configLoadInterrupted: boolean;
|
||||
}
|
||||
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
|
||||
function renderTemplateVars(configYaml: string): string {
|
||||
const data: Record<string, string> = {};
|
||||
|
|
@ -60,36 +53,28 @@ function renderTemplateVars(configYaml: string): string {
|
|||
|
||||
function loadConfigYaml(
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
ideType: IdeType,
|
||||
rawYaml: string,
|
||||
): ConfigResult<ConfigYaml> {
|
||||
const renderedYaml = renderTemplateVars(rawYaml);
|
||||
let config = YAML.parse(renderedYaml) as ConfigYaml;
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
): ConfigResult<ClientConfigYaml> {
|
||||
let config =
|
||||
overrideConfigYaml ??
|
||||
(YAML.parse(renderTemplateVars(rawYaml)) as ClientConfigYaml);
|
||||
const errors = validateConfigYaml(config);
|
||||
|
||||
if (errors?.some((error) => error.level === ValidationLevel.Error)) {
|
||||
if (errors?.some((error) => error.fatal)) {
|
||||
return {
|
||||
errors: errors.map((error) => ({
|
||||
message: error.message,
|
||||
fatal: error.level === ValidationLevel.Error,
|
||||
})),
|
||||
errors,
|
||||
config: undefined,
|
||||
configLoadInterrupted: true,
|
||||
};
|
||||
}
|
||||
|
||||
for (const workspaceConfig of workspaceConfigs) {
|
||||
const rendered = renderTemplateVars(workspaceConfig);
|
||||
config = extendConfig(config, YAML.parse(rendered) as ConfigYaml);
|
||||
}
|
||||
|
||||
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
|
||||
return {
|
||||
config,
|
||||
errors: errors.map((error) => ({
|
||||
message: error.message,
|
||||
fatal: error.level === ValidationLevel.Error,
|
||||
fatal: error.fatal,
|
||||
})),
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
|
|
@ -113,12 +98,13 @@ async function slashCommandsFromV1PromptFiles(
|
|||
}
|
||||
|
||||
async function configYamlToContinueConfig(
|
||||
config: ConfigYaml,
|
||||
config: ClientConfigYaml,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
allowFreeTrial: boolean = true,
|
||||
): Promise<ContinueConfig> {
|
||||
const continueConfig: ContinueConfig = {
|
||||
|
|
@ -126,10 +112,24 @@ async function configYamlToContinueConfig(
|
|||
models: [],
|
||||
tabAutocompleteModels: [],
|
||||
tools: [],
|
||||
systemMessage: config.rules?.join("\n"),
|
||||
embeddingsProvider: new TransformersJsEmbeddingsProvider(),
|
||||
experimental: {
|
||||
modelContextProtocolServers: [],
|
||||
modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({
|
||||
transport: {
|
||||
type: "stdio",
|
||||
command: mcpServer.command,
|
||||
args: mcpServer.args ?? [],
|
||||
env: mcpServer.env,
|
||||
},
|
||||
})),
|
||||
},
|
||||
docs: config.docs?.map((doc) => ({
|
||||
title: doc.name,
|
||||
startUrl: doc.startUrl,
|
||||
rootUrl: doc.rootUrl,
|
||||
faviconUrl: doc.faviconUrl,
|
||||
})),
|
||||
};
|
||||
|
||||
// Models
|
||||
|
|
@ -146,9 +146,13 @@ async function configYamlToContinueConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.models.push(...llms);
|
||||
} else if (model.roles?.includes("autocomplete")) {
|
||||
}
|
||||
|
||||
if (model.roles?.includes("autocomplete")) {
|
||||
// Autocomplete models array
|
||||
const llms = await llmsFromModelConfig(
|
||||
model,
|
||||
|
|
@ -156,6 +160,8 @@ async function configYamlToContinueConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
continueConfig.systemMessage,
|
||||
);
|
||||
continueConfig.tabAutocompleteModels?.push(...llms);
|
||||
}
|
||||
|
|
@ -181,18 +187,33 @@ async function configYamlToContinueConfig(
|
|||
|
||||
// TODO: Split into model roles.
|
||||
|
||||
// Context
|
||||
// Context providers
|
||||
const codebaseContextParams: IContextProvider[] =
|
||||
(config.context || []).find((cp) => cp.uses === "codebase")?.with || {};
|
||||
const DEFAULT_CONTEXT_PROVIDERS = [
|
||||
new FileContextProvider({}),
|
||||
new CodebaseContextProvider(codebaseContextParams),
|
||||
new PromptFilesContextProvider({}),
|
||||
];
|
||||
|
||||
const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map(
|
||||
({ description: { title } }) => title,
|
||||
);
|
||||
|
||||
continueConfig.contextProviders = config.context
|
||||
?.map((context) => {
|
||||
const cls = contextProviderClassFromName(context.uses) as any;
|
||||
if (!cls) {
|
||||
console.warn(`Unknown context provider ${context.uses}`);
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.uses)) {
|
||||
console.warn(`Unknown context provider ${context.uses}`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const instance: IContextProvider = new cls(context.with ?? {});
|
||||
return instance;
|
||||
})
|
||||
.filter((p) => !!p) as IContextProvider[];
|
||||
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
|
||||
|
||||
// Embeddings Provider
|
||||
const embedConfig = config.models?.find((model) =>
|
||||
|
|
@ -283,16 +304,20 @@ export async function loadContinueConfigFromYaml(
|
|||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
overrideConfigYaml: string | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
const configYamlPath = getConfigYamlPath(ideType);
|
||||
const rawYaml = fs.readFileSync(configYamlPath, "utf-8");
|
||||
const rawYaml =
|
||||
overrideConfigYaml === undefined
|
||||
? fs.readFileSync(configYamlPath, "utf-8")
|
||||
: "";
|
||||
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
const configYamlResult = loadConfigYaml(
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideType,
|
||||
overrideConfigYaml ?? rawYaml,
|
||||
rawYaml,
|
||||
overrideConfigYaml,
|
||||
);
|
||||
|
||||
if (!configYamlResult.config || configYamlResult.configLoadInterrupted) {
|
||||
|
|
@ -303,13 +328,24 @@ export async function loadContinueConfigFromYaml(
|
|||
};
|
||||
}
|
||||
|
||||
const continueConfig = await configYamlToContinueConfig(
|
||||
const configYaml = await resolveSecretsOnClient(
|
||||
configYamlResult.config,
|
||||
ide.readSecrets.bind(ide),
|
||||
async (secretNames: string[]) => {
|
||||
const secretValues = await controlPlaneClient.syncSecrets(secretNames);
|
||||
await ide.writeSecrets(secretValues);
|
||||
return secretValues;
|
||||
},
|
||||
);
|
||||
|
||||
const continueConfig = await configYamlToContinueConfig(
|
||||
configYaml,
|
||||
ide,
|
||||
ideSettings,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
platformConfigMetadata,
|
||||
);
|
||||
|
||||
const systemPromptDotFile = await getSystemPromptDotFile(ide);
|
||||
|
|
|
|||
|
|
@ -3,21 +3,59 @@ import { ModelConfig } from "@continuedev/config-yaml";
|
|||
import { IDE, IdeSettings, LLMOptions } from "../..";
|
||||
import { BaseLLM } from "../../llm";
|
||||
import { LLMClasses } from "../../llm/llms";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
const AUTODETECT = "AUTODETECT";
|
||||
|
||||
function useContinueProxy(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): boolean {
|
||||
return !!platformConfigMetadata && model.apiKeySecret !== undefined;
|
||||
}
|
||||
|
||||
function getModelClass(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): (typeof LLMClasses)[number] | undefined {
|
||||
if (useContinueProxy(model, platformConfigMetadata)) {
|
||||
return ContinueProxy;
|
||||
}
|
||||
return LLMClasses.find((llm) => llm.providerName === model.provider);
|
||||
}
|
||||
|
||||
function getContinueProxyModelName(
|
||||
ownerSlug: string,
|
||||
packageSlug: string,
|
||||
model: ModelConfig,
|
||||
): string {
|
||||
return `${ownerSlug}/${packageSlug}/${model.provider}/${model.model}`;
|
||||
}
|
||||
|
||||
async function modelConfigToBaseLLM(
|
||||
model: ModelConfig,
|
||||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM | undefined> {
|
||||
const cls = LLMClasses.find((llm) => llm.providerName === model.provider);
|
||||
const cls = getModelClass(model, platformConfigMetadata);
|
||||
|
||||
if (!cls) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const usingContinueProxy = useContinueProxy(model, platformConfigMetadata);
|
||||
const modelName = usingContinueProxy
|
||||
? getContinueProxyModelName(
|
||||
platformConfigMetadata!.ownerSlug,
|
||||
platformConfigMetadata!.packageSlug,
|
||||
model,
|
||||
)
|
||||
: model.model;
|
||||
|
||||
let options: LLMOptions = {
|
||||
...model,
|
||||
completionOptions: {
|
||||
|
|
@ -30,6 +68,8 @@ async function modelConfigToBaseLLM(
|
|||
writeLog,
|
||||
uniqueId,
|
||||
title: model.name,
|
||||
model: modelName,
|
||||
systemMessage,
|
||||
};
|
||||
|
||||
const llm = new cls(options);
|
||||
|
|
@ -43,6 +83,8 @@ async function autodetectModels(
|
|||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM[]> {
|
||||
try {
|
||||
const modelNames = await llm.listModels();
|
||||
|
|
@ -62,6 +104,8 @@ async function autodetectModels(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
|
@ -78,12 +122,16 @@ export async function llmsFromModelConfig(
|
|||
uniqueId: string,
|
||||
ideSettings: IdeSettings,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM[]> {
|
||||
const baseLlm = await modelConfigToBaseLLM(
|
||||
model,
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
if (!baseLlm) {
|
||||
return [];
|
||||
|
|
@ -97,6 +145,8 @@ export async function llmsFromModelConfig(
|
|||
uniqueId,
|
||||
ideSettings,
|
||||
writeLog,
|
||||
platformConfigMetadata,
|
||||
systemMessage,
|
||||
);
|
||||
return models;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|||
import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
|
||||
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
||||
|
||||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ContinueConfig, MCPOptions, SlashCommand, Tool } from "../..";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcp";
|
||||
import { ConfigValidationError } from "../../config/validation";
|
||||
import { encodeMCPToolUri } from "../../tools/callTool";
|
||||
import MCPContextProvider from "../providers/MCPContextProvider";
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class RepoMapContextProvider extends BaseContextProvider {
|
|||
// Doesn't ALWAYS depend on indexing, so not setting dependsOnIndexing = true, just checking for it
|
||||
includeSignatures: extras.config.disableIndexing
|
||||
? false
|
||||
: (this.options?.includeSignatures ?? false),
|
||||
: (this.options?.includeSignatures ?? true),
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { controlPlaneEnv } from "../env";
|
||||
|
||||
const CLIENT_ID = "client_01J0FW6XN8N2XJAECF7NE0Y65J";
|
||||
// const CLIENT_ID = "client_01J0FW6XCPMJMQ3CG51RB4HBZQ"; // Staging
|
||||
|
||||
|
|
@ -8,7 +10,7 @@ export async function getAuthUrlForTokenPage(): Promise<string> {
|
|||
const params = {
|
||||
response_type: "code",
|
||||
client_id: CLIENT_ID,
|
||||
redirect_uri: "https://app.continue.dev/tokens/callback",
|
||||
redirect_uri: `${controlPlaneEnv.APP_URL}tokens/callback`,
|
||||
// redirect_uri: "http://localhost:3000/tokens/callback",
|
||||
state: uuidv4(),
|
||||
provider: "authkit",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
import { ModelDescription } from "../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { controlPlaneEnv } from "./env.js";
|
||||
|
||||
export interface ControlPlaneSessionInfo {
|
||||
|
|
@ -85,6 +87,29 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async listAssistants(): Promise<
|
||||
{
|
||||
configResult: ConfigResult<ClientConfigYaml>;
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
iconUrl: string;
|
||||
}[]
|
||||
> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await this.request("ide/list-assistants", {
|
||||
method: "GET",
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async getSettingsForWorkspace(workspaceId: string): Promise<ConfigJson> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
|
|
@ -96,4 +121,21 @@ export class ControlPlaneClient {
|
|||
});
|
||||
return ((await resp.json()) as any).settings;
|
||||
}
|
||||
|
||||
async syncSecrets(secretNames: string[]): Promise<Record<string, string>> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ secretNames }),
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
import { readUsePlatform } from "../util/paths";
|
||||
import { usePlatform } from "./flags";
|
||||
|
||||
interface ControlPlaneEnv {
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL: string;
|
||||
CONTROL_PLANE_URL: string;
|
||||
|
|
@ -21,7 +24,7 @@ const PRODUCTION_ENV: ControlPlaneEnv = {
|
|||
"https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_PRODUCTION,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_PRODUCTION,
|
||||
APP_URL: "https://app.continue.dev",
|
||||
APP_URL: "https://app.continue.dev/",
|
||||
};
|
||||
|
||||
const STAGING_ENV: ControlPlaneEnv = {
|
||||
|
|
@ -31,7 +34,15 @@ const STAGING_ENV: ControlPlaneEnv = {
|
|||
"https://control-plane-api-service-537175798139.us-central1.run.app/",
|
||||
AUTH_TYPE: WORKOS_CLIENT_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "https://app-preview.continue.dev",
|
||||
APP_URL: "https://app-preview.continue.dev/",
|
||||
};
|
||||
|
||||
const TEST_ENV: ControlPlaneEnv = {
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api-test.continue.dev/",
|
||||
CONTROL_PLANE_URL: "https://api-test.continue.dev/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "https://app-test.continue.dev/",
|
||||
};
|
||||
|
||||
const LOCAL_ENV: ControlPlaneEnv = {
|
||||
|
|
@ -39,12 +50,20 @@ const LOCAL_ENV: ControlPlaneEnv = {
|
|||
CONTROL_PLANE_URL: "http://localhost:3001/",
|
||||
AUTH_TYPE: WORKOS_ENV_ID_STAGING,
|
||||
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
|
||||
APP_URL: "http://localhost:3000",
|
||||
APP_URL: "http://localhost:3000/",
|
||||
};
|
||||
|
||||
export const controlPlaneEnv =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
function getControlPlaneEnv(): ControlPlaneEnv {
|
||||
const usePlatformFileEnv = readUsePlatform();
|
||||
const env = usePlatformFileEnv || process.env.CONTROL_PLANE_ENV;
|
||||
|
||||
return env === "local"
|
||||
? LOCAL_ENV
|
||||
: process.env.CONTROL_PLANE_ENV === "staging"
|
||||
: env === "staging"
|
||||
? STAGING_ENV
|
||||
: PRODUCTION_ENV;
|
||||
: env === "test" || usePlatform()
|
||||
? TEST_ENV
|
||||
: PRODUCTION_ENV;
|
||||
}
|
||||
|
||||
export const controlPlaneEnv = getControlPlaneEnv();
|
||||
|
|
|
|||
13
core/control-plane/flags.ts
Normal file
13
core/control-plane/flags.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { readUsePlatform, usePlatformPathExists } from "../util/paths";
|
||||
|
||||
export function usePlatform(): boolean {
|
||||
return usePlatformPathExists();
|
||||
}
|
||||
|
||||
export function getEnvFromUsePlatformFile(): string | undefined {
|
||||
const contents = readUsePlatform();
|
||||
if (contents && contents.trim().length > 0) {
|
||||
return contents.trim();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
@ -52,6 +52,7 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import { usePlatform } from "./control-plane/flags";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
|
||||
|
|
@ -110,6 +111,7 @@ export class Core {
|
|||
const ideSettingsPromise = messenger.request("getIdeSettings", undefined);
|
||||
const sessionInfoPromise = messenger.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
useOnboarding: usePlatform(),
|
||||
});
|
||||
|
||||
this.controlPlaneClient = new ControlPlaneClient(sessionInfoPromise);
|
||||
|
|
@ -131,7 +133,7 @@ export class Core {
|
|||
const serializedResult = await this.configHandler.getSerializedConfig();
|
||||
this.messenger.send("configUpdate", {
|
||||
result: serializedResult,
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -385,7 +387,7 @@ export class Core {
|
|||
on("config/getSerializedProfileInfo", async (msg) => {
|
||||
return {
|
||||
result: await this.configHandler.getSerializedConfig(),
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
22
core/index.d.ts
vendored
22
core/index.d.ts
vendored
|
|
@ -460,6 +460,7 @@ export interface LLMOptions {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
aiGatewaySlug?: string;
|
||||
apiBase?: string;
|
||||
cacheBehavior?: CacheBehavior;
|
||||
|
|
@ -683,6 +684,11 @@ export interface IDE {
|
|||
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined>;
|
||||
|
||||
// Secret Storage
|
||||
readSecrets(keys: string[]): Promise<Record<string, string>>;
|
||||
|
||||
writeSecrets(secrets: { [key: string]: string }): Promise<void>;
|
||||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
|
||||
|
|
@ -854,6 +860,13 @@ export interface Tool {
|
|||
uri?: string;
|
||||
}
|
||||
|
||||
interface ToolChoice {
|
||||
type: "function";
|
||||
function: {
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface BaseCompletionOptions {
|
||||
temperature?: number;
|
||||
topP?: number;
|
||||
|
|
@ -871,6 +884,7 @@ export interface BaseCompletionOptions {
|
|||
stream?: boolean;
|
||||
prediction?: Prediction;
|
||||
tools?: Tool[];
|
||||
toolChoice?: ToolChoice;
|
||||
}
|
||||
|
||||
export interface ModelCapability {
|
||||
|
|
@ -882,6 +896,7 @@ export interface ModelDescription {
|
|||
provider: string;
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
apiBase?: string;
|
||||
contextLength?: number;
|
||||
maxStopWords?: number;
|
||||
|
|
@ -1198,6 +1213,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
analytics?: AnalyticsConfig;
|
||||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
usePlatform: boolean;
|
||||
}
|
||||
|
||||
// DOCS SUGGESTIONS AND PACKAGE INFO
|
||||
|
|
@ -1235,9 +1251,9 @@ export type PackageDocsResult = {
|
|||
} & (
|
||||
| { error: string; details?: never }
|
||||
| { details: PackageDetailsSuccess; error?: never }
|
||||
);
|
||||
);
|
||||
|
||||
export interface TerminalOptions {
|
||||
reuseTerminal?: boolean,
|
||||
terminalName?: string,
|
||||
reuseTerminal?: boolean;
|
||||
terminalName?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ import {
|
|||
} from "../test/testDir.js";
|
||||
import { getIndexSqlitePath } from "../util/paths.js";
|
||||
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { CodebaseIndexer, PauseToken } from "./CodebaseIndexer.js";
|
||||
import { getComputeDeleteAddRemove } from "./refreshIndex.js";
|
||||
import { TestCodebaseIndex } from "./TestCodebaseIndex.js";
|
||||
import { CodebaseIndex } from "./types.js";
|
||||
import { walkDir } from "./walkDir.js";
|
||||
import { localPathToUri } from "../util/pathToUri.js";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ describe("CodebaseIndexer", () => {
|
|||
|
||||
test("should have created index folder with all necessary files", async () => {
|
||||
const exists = await testIde.fileExists(
|
||||
pathToFileURL(getIndexSqlitePath()).toString(),
|
||||
localPathToUri(getIndexSqlitePath()),
|
||||
);
|
||||
expect(exists).toBe(true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
||||
import { ConfigResult } from "../../config/load";
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { Article, chunkArticle, pageToArticle } from "./article";
|
||||
import DocsCrawler from "./DocsCrawler";
|
||||
import { runLanceMigrations, runSqliteMigrations } from "./migrations";
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { logDevData } from "../util/devdata.js";
|
|||
import { DevDataSqliteDb } from "../util/devdataSqlite.js";
|
||||
import mergeJson from "../util/merge.js";
|
||||
import { renderChatMessage } from "../util/messageContent.js";
|
||||
import { isOllamaInstalled } from "../util/ollamaHelper.js";
|
||||
import { Telemetry } from "../util/posthog.js";
|
||||
import { withExponentialBackoff } from "../util/withExponentialBackoff.js";
|
||||
|
||||
|
|
@ -55,7 +56,6 @@ import {
|
|||
toCompleteBody,
|
||||
toFimBody,
|
||||
} from "./openaiTypeConverters.js";
|
||||
import { isOllamaInstalled } from "../util/ollamaHelper.js";
|
||||
|
||||
export abstract class BaseLLM implements ILLM {
|
||||
static providerName: string;
|
||||
|
|
@ -117,6 +117,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
writeLog?: (str: string) => Promise<void>;
|
||||
llmRequestHook?: (model: string, prompt: string) => any;
|
||||
apiKey?: string;
|
||||
apiKeySecret?: string;
|
||||
apiBase?: string;
|
||||
cacheBehavior?: CacheBehavior;
|
||||
capabilities?: ModelCapability;
|
||||
|
|
@ -194,6 +195,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.writeLog = options.writeLog;
|
||||
this.llmRequestHook = options.llmRequestHook;
|
||||
this.apiKey = options.apiKey;
|
||||
this.apiKeySecret = options.apiKeySecret;
|
||||
this.aiGatewaySlug = options.aiGatewaySlug;
|
||||
this.apiBase = options.apiBase;
|
||||
this.cacheBehavior = options.cacheBehavior;
|
||||
|
|
@ -415,10 +417,9 @@ export abstract class BaseLLM implements ILLM {
|
|||
e.code === "ECONNREFUSED" &&
|
||||
e.message.includes("http://127.0.0.1:11434")
|
||||
) {
|
||||
const message = (await isOllamaInstalled()) ?
|
||||
"Unable to connect to local Ollama instance. Ollama may not be running." :
|
||||
"Unable to connect to local Ollama instance. Ollama may not be installed or may not running."
|
||||
;
|
||||
const message = (await isOllamaInstalled())
|
||||
? "Unable to connect to local Ollama instance. Ollama may not be running."
|
||||
: "Unable to connect to local Ollama instance. Ollama may not be installed or may not running.";
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -693,13 +694,28 @@ export abstract class BaseLLM implements ILLM {
|
|||
return body;
|
||||
}
|
||||
|
||||
private _modifyCompletionOptions(
|
||||
completionOptions: CompletionOptions,
|
||||
): CompletionOptions {
|
||||
// As of 01/14/25 streaming is currently not available with o1
|
||||
// See these threads:
|
||||
// - https://github.com/continuedev/continue/issues/3698
|
||||
// - https://community.openai.com/t/streaming-support-for-o1-o1-2024-12-17-resulting-in-400-unsupported-value/1085043
|
||||
if (completionOptions.model === "o1") {
|
||||
completionOptions.stream = false;
|
||||
}
|
||||
|
||||
return completionOptions;
|
||||
}
|
||||
|
||||
async *streamChat(
|
||||
_messages: ChatMessage[],
|
||||
signal: AbortSignal,
|
||||
options: LLMFullCompletionOptions = {},
|
||||
): AsyncGenerator<ChatMessage, PromptLog> {
|
||||
const { completionOptions, log, raw } =
|
||||
this._parseCompletionOptions(options);
|
||||
let { completionOptions, log } = this._parseCompletionOptions(options);
|
||||
|
||||
completionOptions = this._modifyCompletionOptions(completionOptions);
|
||||
|
||||
const messages = this._compileChatMessages(completionOptions, _messages);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
import * as dotenv from "dotenv";
|
||||
|
||||
import { CompletionOptions } from "..";
|
||||
import { AssistantChatMessage, CompletionOptions } from "..";
|
||||
|
||||
import { BaseLLM } from ".";
|
||||
import Anthropic from "./llms/Anthropic";
|
||||
import Gemini from "./llms/Gemini";
|
||||
import Mistral from "./llms/Mistral";
|
||||
import OpenAI from "./llms/OpenAI";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
||||
temperature: 0.5,
|
||||
// temperature: 0.5,
|
||||
topP: 1,
|
||||
topK: 40,
|
||||
presencePenalty: 0,
|
||||
|
|
@ -16,12 +20,23 @@ const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
|||
// maxTokens: 5,
|
||||
};
|
||||
|
||||
function testLLM(llm: BaseLLM) {
|
||||
function testLLM(
|
||||
llm: BaseLLM,
|
||||
{
|
||||
skip,
|
||||
testFim,
|
||||
testToolCall,
|
||||
}: { skip?: boolean; testFim?: boolean; testToolCall?: boolean },
|
||||
) {
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
llm.completionOptions = { ...llm.completionOptions, ...COMPLETION_OPTIONS };
|
||||
});
|
||||
|
||||
describe(llm.providerName, () => {
|
||||
describe(llm.providerName + "/" + llm.model, () => {
|
||||
test("Stream Chat works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamChat(
|
||||
|
|
@ -54,62 +69,119 @@ function testLLM(llm: BaseLLM) {
|
|||
expect(completion.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
if (testFim) {
|
||||
test("FIM works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamFim(
|
||||
"Hi",
|
||||
"name is ChatGPT.",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
if (testToolCall) {
|
||||
test("Tool Call works", async () => {
|
||||
let args = "";
|
||||
let isFirstChunk = true;
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi, my name is Nate." }],
|
||||
new AbortController().signal,
|
||||
{
|
||||
tools: [
|
||||
{
|
||||
displayTitle: "Say Hello",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
description: "Say Hello",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
description: "The name of the person to greet",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
type: "function",
|
||||
wouldLikeTo: "Say hello",
|
||||
readonly: true,
|
||||
},
|
||||
],
|
||||
toolChoice: {
|
||||
type: "function",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
},
|
||||
},
|
||||
},
|
||||
)) {
|
||||
const typedChunk = chunk as AssistantChatMessage;
|
||||
if (!typedChunk.toolCalls) {
|
||||
continue;
|
||||
}
|
||||
const toolCall = typedChunk.toolCalls[0];
|
||||
args += toolCall.function?.arguments ?? "";
|
||||
|
||||
expect(chunk.role).toBe("assistant");
|
||||
expect(chunk.content).toBe("");
|
||||
expect(typedChunk.toolCalls).toHaveLength(1);
|
||||
|
||||
if (isFirstChunk) {
|
||||
isFirstChunk = false;
|
||||
expect(toolCall.id).toBeDefined();
|
||||
expect(toolCall.function!.name).toBe("say_hello");
|
||||
}
|
||||
}
|
||||
|
||||
const parsedArgs = JSON.parse(args);
|
||||
expect(parsedArgs.name).toBe("Nate");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe.skip("LLM", () => {
|
||||
// testLLM(
|
||||
// new FreeTrial({
|
||||
// model: "gpt-3.5-turbo",
|
||||
// }),
|
||||
// );
|
||||
// testLLM(
|
||||
// new Anthropic({
|
||||
// model: "claude-2",
|
||||
// apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
// }),
|
||||
// );
|
||||
describe("LLM", () => {
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "gpt-3.5-turbo" }),
|
||||
new Anthropic({
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
}),
|
||||
{
|
||||
skip: false,
|
||||
testToolCall: true,
|
||||
},
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "gpt-4o" }), {
|
||||
skip: false,
|
||||
testToolCall: true,
|
||||
});
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1-preview" }),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1" }), {
|
||||
skip: false,
|
||||
});
|
||||
testLLM(
|
||||
new Gemini({
|
||||
model: "gemini-2.0-flash-exp",
|
||||
apiKey: process.env.GEMINI_API_KEY,
|
||||
}),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(
|
||||
new Mistral({
|
||||
apiKey: process.env.MISTRAL_API_KEY,
|
||||
model: "codestral-latest",
|
||||
}),
|
||||
{ testFim: true, skip: false },
|
||||
);
|
||||
// TODO: Fix Replicate
|
||||
// testLLM(
|
||||
// new Replicate({
|
||||
// apiKey: process.env.REPLICATE_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LMStudio({ model: "codellama-7b" }));
|
||||
// testLLM(new Ollama({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Together({
|
||||
// apiKey: process.env.TOGETHER_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LlamaCpp({ model: "deepseek-7b" }));
|
||||
// testLLM(new Llamafile({ model: "mistral-7b" }));
|
||||
// TODO: Test these
|
||||
// testLLM(new TextGenWebUI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceTGI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceInferenceAPI({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Gemini({
|
||||
// model: "gemini-pro",
|
||||
// // model: "chat-bison-001",
|
||||
// apiKey: process.env.GOOGLE_PALM_API_KEY,
|
||||
// })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Gemini({ model: "gemini-pro", apiKey: process.env.GOOGLE_PALM_API_KEY })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Mistral({ apiKey: process.env.MISTRAL_API_KEY, model: "mistral-small" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Flowise({ apiKey: process.env.FLOWISE_API_KEY, model: "gpt-3.5-turbo" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Nebius({ apiKey: process.env.NEBIUS_API_KEY, model: "llama3.1-8b" })
|
||||
// );
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ class Anthropic extends BaseLLM {
|
|||
description: tool.function.description,
|
||||
input_schema: tool.function.parameters,
|
||||
})),
|
||||
tool_choice: options.toolChoice
|
||||
? {
|
||||
type: "tool",
|
||||
name: options.toolChoice.function.name,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
|
||||
return finalOptions;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ChatMessage, CompletionOptions, LLMOptions } from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
|
||||
type MockMessage = ChatMessage | "REPEAT_LAST_MSG";
|
||||
type MockMessage = ChatMessage | "REPEAT_LAST_MSG" | "REPEAT_SYSTEM_MSG";
|
||||
|
||||
class MockLLM extends BaseLLM {
|
||||
public completion: string = "Test Completion";
|
||||
|
|
@ -42,6 +42,13 @@ class MockLLM extends BaseLLM {
|
|||
content: messages[messages.length - 1].content,
|
||||
};
|
||||
break;
|
||||
case "REPEAT_SYSTEM_MSG":
|
||||
yield {
|
||||
role: "assistant",
|
||||
content:
|
||||
messages.find((m) => m.role === "system")?.content || "",
|
||||
};
|
||||
break;
|
||||
default:
|
||||
yield message;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ class OpenAI extends BaseLLM {
|
|||
};
|
||||
}
|
||||
|
||||
protected extraBodyProperties(): Record<string, any> {
|
||||
return {};
|
||||
}
|
||||
|
||||
protected getMaxStopWords(): number {
|
||||
const url = new URL(this.apiBase!);
|
||||
|
||||
|
|
@ -150,6 +154,10 @@ class OpenAI extends BaseLLM {
|
|||
finalOptions.messages = formatMessageForO1(finalOptions.messages);
|
||||
}
|
||||
|
||||
if (options.model === "o1") {
|
||||
finalOptions.stream = false;
|
||||
}
|
||||
|
||||
if (options.prediction && this.supportsPrediction(options.model)) {
|
||||
if (finalOptions.presence_penalty) {
|
||||
// prediction doesn't support > 0
|
||||
|
|
@ -241,6 +249,11 @@ class OpenAI extends BaseLLM {
|
|||
body.messages = formatMessageForO1(body.messages);
|
||||
}
|
||||
|
||||
if (body.model === "o1") {
|
||||
// o1 doesn't support streaming
|
||||
body.stream = false;
|
||||
}
|
||||
|
||||
if (body.prediction && this.supportsPrediction(body.model)) {
|
||||
if (body.presence_penalty) {
|
||||
// prediction doesn't support > 0
|
||||
|
|
@ -278,6 +291,7 @@ class OpenAI extends BaseLLM {
|
|||
body: JSON.stringify({
|
||||
...args,
|
||||
stream: true,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
|
@ -319,7 +333,10 @@ class OpenAI extends BaseLLM {
|
|||
const response = await this.fetch(this._getEndpoint("chat/completions"), {
|
||||
method: "POST",
|
||||
headers: this._getHeaders(),
|
||||
body: JSON.stringify(body),
|
||||
body: JSON.stringify({
|
||||
...body,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
||||
|
|
@ -358,6 +375,7 @@ class OpenAI extends BaseLLM {
|
|||
presence_penalty: options.presencePenalty,
|
||||
stop: options.stop,
|
||||
stream: true,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -404,6 +422,7 @@ class OpenAI extends BaseLLM {
|
|||
body: JSON.stringify({
|
||||
input: chunks,
|
||||
model: this.model,
|
||||
...this.extraBodyProperties(),
|
||||
}),
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.apiKey}`,
|
||||
|
|
|
|||
|
|
@ -10,11 +10,33 @@ class ContinueProxy extends OpenAI {
|
|||
this.apiBase = new URL("openai/v1/", value.controlPlaneProxyUrl).toString();
|
||||
}
|
||||
|
||||
// The apiKey and apiBase are set to the values for the proxy,
|
||||
// but we need to keep track of the actual values that the proxy will use
|
||||
// to call whatever LLM API is chosen
|
||||
private actualApiBase?: string;
|
||||
private actualApiKey?: string;
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
this.actualApiBase = options.apiBase;
|
||||
this.actualApiKey = options.apiKey;
|
||||
}
|
||||
|
||||
static providerName = "continue-proxy";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
};
|
||||
|
||||
protected extraBodyProperties(): Record<string, any> {
|
||||
return {
|
||||
continueProperties: {
|
||||
apiKey: this.actualApiKey,
|
||||
apiBase: this.actualApiBase,
|
||||
apiKeySecret: this.apiKeySecret,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected _getHeaders() {
|
||||
const headers: any = super._getHeaders();
|
||||
headers["x-continue-unique-id"] = Telemetry.uniqueId;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ export function toChatBody(
|
|||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
prediction: options.prediction,
|
||||
tool_choice: options.toolChoice,
|
||||
};
|
||||
|
||||
if (options.tools?.length) {
|
||||
|
|
|
|||
15
core/package-lock.json
generated
15
core/package-lock.json
generated
|
|
@ -13,7 +13,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -3030,18 +3030,19 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.13.tgz",
|
||||
"integrity": "sha512-5Qmy2x58uhW1GYknypFT/7iwxEJSbt8gMgfQReV7d6xjbJ09ISOTki3hIfCilKrTCo0gIY6pzKEfCoQkUTEi6Q==",
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
|
||||
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.0.tgz",
|
||||
"integrity": "sha512-NwagzzpnPLbMC3delzFSjWiFv5fp8ReFjdMQF0ko0Xg+U0Myja90k/J7JWGegF/SZMABxc/OJchElJFr58TwGA==",
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ export async function getPromptFilesFromDir(
|
|||
return [];
|
||||
}
|
||||
|
||||
const paths = await walkDir(dir, ide, { ignoreFiles: [] });
|
||||
const promptFilePaths = paths.filter((p) => p.endsWith(".prompt"));
|
||||
const results = promptFilePaths.map(async (path) => {
|
||||
const content = await ide.readFile(path); // make a try catch
|
||||
return { path, content };
|
||||
const uris = await walkDir(dir, ide, { ignoreFiles: [] });
|
||||
const promptFilePaths = uris.filter((p) => p.endsWith(".prompt"));
|
||||
const results = promptFilePaths.map(async (uri) => {
|
||||
const content = await ide.readFile(uri); // make a try catch
|
||||
return { path: uri, content };
|
||||
});
|
||||
return Promise.all(results);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { ConfigResult } from "../config/load";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
|
|
@ -23,6 +20,8 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
|
||||
export type OnboardingModes =
|
||||
| "Local"
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import type {
|
|||
Problem,
|
||||
Range,
|
||||
RangeInFile,
|
||||
TerminalOptions,
|
||||
Thread,
|
||||
TerminalOptions
|
||||
} from "../";
|
||||
|
||||
export interface GetGhTokenArgs {
|
||||
|
|
@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
showVirtualFile: [{ name: string; content: string }, void];
|
||||
openFile: [{ path: string }, void];
|
||||
openUrl: [string, void];
|
||||
runCommand: [{ command: string, options?: TerminalOptions }, void];
|
||||
runCommand: [{ command: string; options?: TerminalOptions }, void];
|
||||
getSearchResults: [{ query: string }, string];
|
||||
subprocess: [{ command: string; cwd?: string }, [string, string]];
|
||||
saveFile: [{ filepath: string }, void];
|
||||
|
|
@ -72,6 +72,8 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
isTelemetryEnabled: [undefined, boolean];
|
||||
getUniqueId: [undefined, string];
|
||||
getTags: [string, IndexTag[]];
|
||||
readSecrets: [{ keys: string[] }, Record<string, string>];
|
||||
writeSecrets: [{ secrets: Record<string, string> }, void];
|
||||
// end methods from IDE type
|
||||
|
||||
getIdeSettings: [undefined, IdeSettings];
|
||||
|
|
@ -92,7 +94,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
|
||||
getGitHubAuthToken: [GetGhTokenArgs, string | undefined];
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean },
|
||||
{ silent: boolean; useOnboarding: boolean },
|
||||
ControlPlaneSessionInfo | undefined,
|
||||
];
|
||||
logoutOfControlPlane: [undefined, void];
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ export class MessageIde implements IDE {
|
|||
) => void,
|
||||
) {}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
return this.request("readSecrets", { keys });
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {
|
||||
return this.request("writeSecrets", { secrets });
|
||||
}
|
||||
|
||||
fileExists(fileUri: string): Promise<boolean> {
|
||||
return this.request("fileExists", { filepath: fileUri });
|
||||
}
|
||||
|
|
@ -152,7 +160,7 @@ export class MessageIde implements IDE {
|
|||
await this.request("openUrl", url);
|
||||
}
|
||||
|
||||
async runCommand(command: string, options?: TerminalOptions): Promise<void> {
|
||||
async runCommand(command: string, options?: TerminalOptions): Promise<void> {
|
||||
await this.request("runCommand", { command, options });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
import { ConfigResult } from "../config/load.js";
|
||||
import { ConfigValidationError } from "../config/validation.js";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContextItemWithId,
|
||||
ContextProviderName,
|
||||
ContextSubmenuItem,
|
||||
IndexingProgressUpdate,
|
||||
IndexingStatus,
|
||||
PackageDocsResult,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ import { GetGhTokenArgs } from "../protocol/ide.js";
|
|||
|
||||
class FileSystemIde implements IDE {
|
||||
constructor(private readonly workspaceDir: string) {}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {}
|
||||
|
||||
showToast(
|
||||
type: ToastType,
|
||||
message: string,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import * as URI from "uri-js";
|
|||
|
||||
// CAN ONLY BE USED IN CORE
|
||||
|
||||
// Converts a local path to a file:// URI
|
||||
// Converts a local path to a file:/// URI
|
||||
export function localPathToUri(path: string) {
|
||||
const url = pathToFileURL(path);
|
||||
return URI.normalize(url.toString());
|
||||
|
|
|
|||
|
|
@ -301,11 +301,18 @@ export function getPathToRemoteConfig(remoteConfigServerUrl: string): string {
|
|||
return dir;
|
||||
}
|
||||
|
||||
export function internalBetaPathExists(): boolean {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".internal_beta");
|
||||
export function usePlatformPathExists(): boolean {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".use_platform");
|
||||
return fs.existsSync(sPath);
|
||||
}
|
||||
|
||||
export function readUsePlatform(): string | undefined {
|
||||
const sPath = path.join(getContinueGlobalPath(), ".use_platform");
|
||||
if (fs.existsSync(sPath)) {
|
||||
return fs.readFileSync(sPath, "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
export function getConfigJsonPathForRemote(
|
||||
remoteConfigServerUrl: string,
|
||||
): string {
|
||||
|
|
|
|||
|
|
@ -261,9 +261,9 @@ Uses the top _n_ levels (defaulting to 3) of the call stack for that thread.
|
|||
|
||||
### `@Repository Map`
|
||||
|
||||
Reference the outline of your codebase.
|
||||
Reference the outline of your codebase. By default, signatures are included along with file in the repo map.
|
||||
|
||||
`includeSignatures` params can be used to include signatures for all files in the repo. Use with caution as will increase context size significantly. `includeSignatures` will not work if indexing is disabled.
|
||||
`includeSignatures` params can be set to false to exclude signatures. This could be necessary for large codebases and/or to reduce context size significantly. Signatures will not be included if indexing is disabled.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
|
|
@ -271,7 +271,7 @@ Reference the outline of your codebase.
|
|||
{
|
||||
"name": "repo-map",
|
||||
"params": {
|
||||
"includeSignatures": false
|
||||
"includeSignatures": false // default true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ We recommend configuring **Llama3.1 8B** as your chat model.
|
|||
{
|
||||
"title": "Llama3.1 8B Instruct",
|
||||
"provider": "vllm",
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
||||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
||||
"apiBase": "http://<vllm chat endpoint>/v1"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ To configure a remote instance of Ollama, add the `"apiBase"` property to your m
|
|||
{
|
||||
"title": "Llama3.1 8B",
|
||||
"provider": "ollama",
|
||||
"model": "llama3.1:8b"
|
||||
"model": "llama3.1:8b",
|
||||
"apiBase": "http://<my endpoint>:11434"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ See also
|
|||
- [JSON Continue Config Reference](/reference)
|
||||
- [YAML Continue Config Reference](/yaml-reference)
|
||||
|
||||
### 1. Create YAML file
|
||||
## Create YAML file
|
||||
|
||||
Create a `config.yaml` file in your Continue Global Directory (`~/.continue` on Mac, `%USERPROFILE%\.continue`) alongside your current `config.json` file. If a `config.yaml` file is present, it will be loaded instead of `config.json`.
|
||||
|
||||
|
|
@ -25,14 +25,14 @@ name: my-configuration
|
|||
version: 0.0.1
|
||||
```
|
||||
|
||||
### 2. Map Models
|
||||
### Models
|
||||
|
||||
Add all model configurations in `config.json`, including models in `models`, `tabAutocompleteModel`, `embeddingsProvider`, and `reranker`, to the `models` section of your new YAML config file. A new `roles` YAML field specifies which roles a model can be used for, with possible values `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`.
|
||||
|
||||
- `models` in config should have `roles: chat`
|
||||
- `tabAutocompleteModel`(s) in config should have `roles: autocomplete`
|
||||
- `embeddingsProvider` in config should have `roles: embed`
|
||||
- `reranker` in config should have `roles: rerank`
|
||||
- `models` in config should have `roles: [chat]`
|
||||
- `tabAutocompleteModel`(s) in config should have `roles: [autocomplete]`
|
||||
- `embeddingsProvider` in config should have `roles: [embed]`
|
||||
- `reranker` in config should have `roles: [rerank]`
|
||||
- `experimental.modelRoles` is replaced by simply adding roles to the model
|
||||
- `inlineEdit` -> e.g. `roles: [chat, edit]`
|
||||
- `applyCodeBlock` -> e.g. `roles: [chat, apply]`
|
||||
|
|
@ -103,46 +103,56 @@ models:
|
|||
- name: GPT-4
|
||||
provider: openai
|
||||
model: gpt-4
|
||||
apiKey: <API_KEY>
|
||||
defaultCompletionOptions:
|
||||
temperature: 0.5
|
||||
maxTokens: 2000'
|
||||
roles: [chat, edit]
|
||||
apiKey: <API_KEY>
|
||||
maxTokens: 2000
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
|
||||
- name: My Voyage Reranker
|
||||
provider: voyage
|
||||
roles: rerank
|
||||
apiKey: <API_KEY>
|
||||
roles:
|
||||
- rerank
|
||||
|
||||
- name: My Starcoder
|
||||
provider: ollama
|
||||
model: starcoder2:3b
|
||||
roles: autocomplete
|
||||
roles:
|
||||
- autocomplete
|
||||
|
||||
- name: My Ada Embedder
|
||||
provider: openai
|
||||
roles: embed
|
||||
apiKey: <API_KEY>
|
||||
roles:
|
||||
- embed
|
||||
|
||||
- name: Ollama Autodetect
|
||||
provider: ollama
|
||||
model: AUTODETECT
|
||||
|
||||
- name: My Open AI Compatible Model - Apply
|
||||
provider: openai
|
||||
apiBase: http://3.3.3.3/v1
|
||||
model: my-openai-compatible-model
|
||||
apiBase: http://3.3.3.3/v1
|
||||
requestOptions:
|
||||
headers:
|
||||
X-Auth-Token: <API_KEY>
|
||||
roles: [chat, apply]
|
||||
roles:
|
||||
- chat
|
||||
- apply
|
||||
```
|
||||
|
||||
Note that the `repoMapFileSelection` experimental model role has been deprecated.
|
||||
|
||||
### 3. Map Context Providers
|
||||
### Context Providers
|
||||
|
||||
The JSON `contextProviders` and `docs` fields are replaced by the YAML `context` array.
|
||||
The JSON `contextProviders` field is replaced by the YAML `context` array.
|
||||
|
||||
- JSON `name` maps to `uses`
|
||||
- JSON `params` map to `with`
|
||||
- Use multiple `docs` entries rather than the array of docs in the JSON format
|
||||
<!-- TODO is this docs not correct ?^ -->
|
||||
|
||||
**Before**
|
||||
|
||||
|
|
@ -150,10 +160,7 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "docs",
|
||||
"params": {
|
||||
"startUrl": "https://docs.continue.dev/intro"
|
||||
}
|
||||
"name": "docs"
|
||||
},
|
||||
{
|
||||
"name": "codebase",
|
||||
|
|
@ -166,7 +173,86 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
"name": "diff",
|
||||
"params": {}
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
context:
|
||||
- uses: docs
|
||||
|
||||
- uses: codebase
|
||||
with:
|
||||
nRetrieve: 30
|
||||
nFinal: 3
|
||||
|
||||
- uses: diff
|
||||
```
|
||||
|
||||
### System Message
|
||||
|
||||
The `systemMessage` property has been replaced with a `rules` property that takes an array of strings.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"systemMessage": "Always give concise responses"
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
rules:
|
||||
- Always give concise responses
|
||||
```
|
||||
|
||||
### Prompts
|
||||
|
||||
Rather than with `customCommands`, you can now use the `prompts` field to define custom prompts.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"customCommands": [
|
||||
{
|
||||
"name": "check",
|
||||
"description": "Check for mistakes in my code",
|
||||
"prompt": "{{{ input }}}\n\nPlease read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:\n- Syntax errors\n- Logic errors\n- Security vulnerabilities\n- Performance issues\n- Anything else that looks wrong\n\nOnce you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
prompts:
|
||||
- name: check
|
||||
description: Check for mistakes in my code
|
||||
prompt: |
|
||||
Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:
|
||||
- Syntax errors
|
||||
- Logic errors
|
||||
- Security vulnerabilities
|
||||
- Performance issues
|
||||
- Anything else that looks wrong
|
||||
|
||||
Once you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found.
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
Documentation is largely the same, but the `title` property has been replaced with `name`. The `startUrl`, `rootUrl`, and `faviconUrl` properties remain.
|
||||
|
||||
**Before**
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"docs": [
|
||||
{
|
||||
"startUrl": "https://docs.nestjs.com/",
|
||||
|
|
@ -183,23 +269,15 @@ The JSON `contextProviders` and `docs` fields are replaced by the YAML `context`
|
|||
**After**
|
||||
|
||||
```yaml title="config.yaml"
|
||||
context:
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://docs.nestjs.com/
|
||||
title: nest.js
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://mysite.com/docs/
|
||||
title: My Site
|
||||
- uses: codebase
|
||||
with:
|
||||
nRetrieve: 30
|
||||
nFinal: 3
|
||||
- uses: diff
|
||||
docs:
|
||||
- name: nest.js
|
||||
startUrl: https://docs.nestjs.com/
|
||||
|
||||
- name: My site
|
||||
startUrl: https://mysite.com/docs/
|
||||
```
|
||||
|
||||
## Map MCP Servers
|
||||
### MCP Servers
|
||||
|
||||
<!-- TODO this is definitely wrong -->
|
||||
|
||||
|
|
@ -220,7 +298,10 @@ context:
|
|||
"transport": {
|
||||
"type": "stdio",
|
||||
"command": "uvx",
|
||||
"args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"]
|
||||
"args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"],
|
||||
"env": {
|
||||
"KEY": "<VALUE>"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -238,13 +319,15 @@ mcpServers:
|
|||
- mcp-server-sqlite
|
||||
- --db-path
|
||||
- /Users/NAME/test.db
|
||||
env:
|
||||
KEY: <VALUE>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deprecated configuration options
|
||||
|
||||
The following top-level fields from `config.json` have been deprecated
|
||||
The following top-level fields from `config.json` have been deprecated. Most UI-related and user-specific options will move into a settings page in the UI
|
||||
|
||||
- Slash commands (JSON `slashCommands`)
|
||||
- top-level `requestOptions`
|
||||
|
|
@ -257,7 +340,6 @@ The following top-level fields from `config.json` have been deprecated
|
|||
- `allowAnonymousTelemetry` (moved to user/IDE level)
|
||||
- `ui` (moved to user/IDE level)
|
||||
- `userToken`
|
||||
- `systemMessage`
|
||||
- `disableIndexing` (moved to user/IDE level)
|
||||
|
||||
## New Configuration options
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ The top-level properties in the `config.yaml` configuration file are:
|
|||
- [`models`](#models)
|
||||
- [`context`](#context)
|
||||
- [`rules`](#rules)
|
||||
- [`prompts`](#prompts)
|
||||
- [`docs`](#docs)
|
||||
<!-- - [`data`](#data) -->
|
||||
<!-- - [`tools`](#tools) -->
|
||||
|
|
@ -153,6 +154,23 @@ rules:
|
|||
|
||||
---
|
||||
|
||||
### `prompts`
|
||||
|
||||
A list of custom prompts that can be invoked from the chat window. Each prompt has a name, description, and the actual prompt text.
|
||||
|
||||
```yaml title="config.yaml"
|
||||
prompts:
|
||||
- name: check
|
||||
description: Check for mistakes in my code
|
||||
prompt: |
|
||||
Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:
|
||||
- Syntax errors
|
||||
- Logic errors
|
||||
- Security vulnerabilities
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `docs`
|
||||
|
||||
List of documentation sites to index.
|
||||
|
|
@ -176,9 +194,7 @@ docs:
|
|||
|
||||
---
|
||||
|
||||
### `tools`
|
||||
|
||||
<!-- TODO how does this actually work -->
|
||||
<!-- ### `tools`
|
||||
|
||||
The `tools` section specifies external tools or APIs that can be used within your configuration.
|
||||
|
||||
|
|
@ -195,7 +211,7 @@ tools:
|
|||
apiKey: YOUR_API_KEY
|
||||
```
|
||||
|
||||
---
|
||||
--- -->
|
||||
|
||||
### `mcpServers`
|
||||
|
||||
|
|
@ -247,6 +263,7 @@ Putting it all together, here's a complete example of a `config.yaml` configurat
|
|||
|
||||
```yaml title="config.yaml"
|
||||
name: MyProject
|
||||
version: 0.0.1
|
||||
|
||||
models:
|
||||
- name: GPT-4
|
||||
|
|
@ -261,6 +278,7 @@ models:
|
|||
requestOptions:
|
||||
headers:
|
||||
Authorization: Bearer YOUR_OPENAI_API_KEY
|
||||
|
||||
- name: Ollama Starcoder
|
||||
provider: ollama
|
||||
model: starcoder
|
||||
|
|
@ -271,18 +289,27 @@ models:
|
|||
stop:
|
||||
- "\n"
|
||||
|
||||
rules:
|
||||
- Give concise responses
|
||||
- Always assume TypeScript rather than JavaScript
|
||||
|
||||
prompts:
|
||||
- name: test
|
||||
description: Unit test a function
|
||||
prompt: |
|
||||
Please write a complete suite of unit tests for this function. You should use the Jest testing framework. The tests should cover all possible edge cases and should be as thorough as possible. You should also include a description of each test case.
|
||||
|
||||
context:
|
||||
- uses: diff
|
||||
- uses: file
|
||||
- uses: codebase
|
||||
- uses: code
|
||||
- uses: docs
|
||||
with:
|
||||
startUrl: https://docs.example.com/introduction
|
||||
rootUrl: https://docs.example.com
|
||||
maxDepth: 3
|
||||
|
||||
tools:
|
||||
- url: https://api.exampletool.com
|
||||
apiKey: YOUR_TOOL_API_KEY
|
||||
|
||||
mcpServers:
|
||||
- name: DevServer
|
||||
command: npm
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/../../binary" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/binary" />
|
||||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
||||
<option name="INTERPRETER_PATH" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<option name="SCRIPT_PATH" value="" />
|
||||
<option name="SCRIPT_OPTIONS" value="" />
|
||||
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/../../gui" />
|
||||
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/gui" />
|
||||
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
||||
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ This will generate a .zip file in `./build/distributions` with the version defin
|
|||
The e2e tests are written using [intellij-ui-test-robot](`https://github.com/JetBrains/intellij-ui-test-robot`). The
|
||||
README for this project has a lot of helpful info on how to use the library.
|
||||
|
||||
Note that these tests fully take control of your mouse while executing.
|
||||
|
||||
#### Setup
|
||||
|
||||
If you are on macOS, you'll need to give IntelliJ permission to control your computer in order to run the e2e tests.
|
||||
|
|
@ -174,7 +176,18 @@ to run.
|
|||
|
||||
#### Identifying selectors
|
||||
|
||||
While the `runIdeForUiTests` task is runnung, you can visit the following URL
|
||||
While the `runIdeForUiTests` task is running, you can visit the following URL
|
||||
to view the UI hierarchy of the running IDE:
|
||||
|
||||
http://127.0.0.1:8082/
|
||||
http://127.0.0.1:8082/
|
||||
|
||||
#### Rebuilding the extension
|
||||
|
||||
To rebuild the extension with the latest source code, run the following:
|
||||
|
||||
```sh
|
||||
./gradlew buildPlugin
|
||||
```
|
||||
|
||||
This will update the contents of the extension that is loaded into the test IDE from
|
||||
`build/idea-sandbox/plugins-uiTest/continue-intellij-extension`
|
||||
|
|
|
|||
|
|
@ -47,6 +47,22 @@ dependencies {
|
|||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
||||
testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||||
implementation("com.automation-remarks:video-recorder-junit5:2.0")
|
||||
|
||||
|
||||
// Exclude vulnerable Log4j from all dependencies
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
eachDependency {
|
||||
if (requested.group == "log4j" && requested.name == "log4j") {
|
||||
useTarget("org.slf4j:log4j-over-slf4j:1.7.36")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add Log4j 2.x explicitly
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.20.0")
|
||||
}
|
||||
|
||||
// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for
|
||||
|
|
@ -105,13 +121,10 @@ tasks {
|
|||
wrapper { gradleVersion = properties("gradleVersion").get() }
|
||||
|
||||
patchPluginXml {
|
||||
version = properties("pluginVersion")
|
||||
sinceBuild = properties("pluginSinceBuild")
|
||||
untilBuild = properties("pluginUntilBuild")
|
||||
|
||||
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's
|
||||
// manifest
|
||||
pluginDescription =
|
||||
version.set(properties("pluginVersion"))
|
||||
sinceBuild.set(properties("pluginSinceBuild"))
|
||||
untilBuild.set(properties("pluginUntilBuild"))
|
||||
pluginDescription.set(
|
||||
providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
|
||||
val start = "<!-- Plugin description -->"
|
||||
val end = "<!-- Plugin description end -->"
|
||||
|
|
@ -125,6 +138,7 @@ tasks {
|
|||
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Configure UI tests plugin
|
||||
|
|
@ -149,9 +163,9 @@ tasks {
|
|||
// This is to ensure we load the GUI with OSR enabled. We have logic that
|
||||
// renders with OSR disabled below a particular IDE version.
|
||||
// See ContinueExtensionSettingsService.kt for more info.
|
||||
intellij {
|
||||
version.set("2024.1")
|
||||
}
|
||||
// intellij {
|
||||
// version.set("2024.1")
|
||||
// }
|
||||
}
|
||||
|
||||
signPlugin {
|
||||
|
|
|
|||
|
|
@ -297,13 +297,12 @@ class AutocompleteService(private val project: Project) {
|
|||
}
|
||||
|
||||
private fun isInjectedFile(editor: Editor): Boolean {
|
||||
return ApplicationManager.getApplication().executeOnPooledThread<Boolean> {
|
||||
ApplicationManager.getApplication().runReadAction<Boolean> {
|
||||
val psiFile =
|
||||
PsiDocumentManager.getInstance(project).getPsiFile(editor.document) ?: return@runReadAction false
|
||||
return@runReadAction psiFile.isInjectedText()
|
||||
}
|
||||
}.get()
|
||||
val psiFile = runReadAction { PsiDocumentManager.getInstance(project).getPsiFile(editor.document) }
|
||||
if (psiFile == null) {
|
||||
return false
|
||||
}
|
||||
val response = runReadAction { psiFile.isInjectedText() }
|
||||
return response
|
||||
}
|
||||
|
||||
fun hideCompletions(editor: Editor) {
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ class CoreMessengerManager(
|
|||
private fun setupCoreMessenger(continueCorePath: String) {
|
||||
coreMessenger = CoreMessenger(project, continueCorePath, ideProtocolClient, coroutineScope)
|
||||
|
||||
coreMessenger?.request("config/getSerializedProfileInfo", null, null) { resp ->
|
||||
val data = resp as? Map<String, Any>
|
||||
val profileInfo = data?.get("config") as? Map<String, Any>
|
||||
val allowAnonymousTelemetry = profileInfo?.get("allowAnonymousTelemetry") as? Boolean
|
||||
coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val result = (response as Map<String, Any>)["result"] as Map<String, Any>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
val allowAnonymousTelemetry = config?.get("allowAnonymousTelemetry") as? Boolean
|
||||
val telemetryService = service<TelemetryService>()
|
||||
if (allowAnonymousTelemetry == true || allowAnonymousTelemetry == null) {
|
||||
telemetryService.setup(getMachineUniqueID())
|
||||
|
|
|
|||
|
|
@ -439,7 +439,8 @@ class IdeProtocolClient(
|
|||
null,
|
||||
null
|
||||
) { response ->
|
||||
val config = (response as Map<String, Any>)["config"] as Map<String, Any>
|
||||
val result = (response as Map<String, Any>)["result"] as Map<String, Any>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
val applyCodeBlockModel = getModelByRole(config, "applyCodeBlock")
|
||||
|
||||
if (applyCodeBlockModel != null) {
|
||||
|
|
|
|||
|
|
@ -128,11 +128,14 @@ fun openInlineEdit(project: Project?, editor: Editor) {
|
|||
// Get list of model titles
|
||||
val continuePluginService = project.service<ContinuePluginService>()
|
||||
val modelTitles = mutableListOf<String>()
|
||||
|
||||
continuePluginService.coreMessenger?.request("config/getSerializedProfileInfo", null, null) { response ->
|
||||
val config = response as Map<String, Any>
|
||||
val models = (config["config"] as Map<String, Any>)["models"] as List<Map<String, Any>>
|
||||
val result = (response as Map<String, Any>)["result"] as Map<String, Any>
|
||||
val config = result["config"] as Map<String, Any>
|
||||
val models = config["models"] as List<Map<String, Any>>
|
||||
modelTitles.addAll(models.map { it["title"] as String })
|
||||
}
|
||||
|
||||
val maxWaitTime = 200
|
||||
val startTime = System.currentTimeMillis()
|
||||
while (modelTitles.isEmpty() && System.currentTimeMillis() - startTime < maxWaitTime) {
|
||||
|
|
@ -427,7 +430,7 @@ class CustomPanel(
|
|||
}
|
||||
|
||||
selectedIndex =
|
||||
if(itemCount == 0) -1 else continueSettingsService.continueState.lastSelectedInlineEditModel?.let {
|
||||
if (itemCount == 0) -1 else continueSettingsService.continueState.lastSelectedInlineEditModel?.let {
|
||||
if (modelTitles.isEmpty()) -1
|
||||
else {
|
||||
val index = modelTitles.indexOf(it)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Autocomplete {
|
|||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
@Video
|
||||
fun displayCompletion(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
|
|
@ -50,7 +50,7 @@ class Autocomplete {
|
|||
// Our "continue_tutorial.java.ft" tab loads first, but then "Main.java" takes focus.
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']")
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class Autocomplete {
|
|||
enterText(" ")
|
||||
}
|
||||
|
||||
waitFor(ofSeconds(10)) {
|
||||
waitFor(ofSeconds(20)) {
|
||||
editor.hasText("TEST_LLM_RESPONSE_0")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class GUI {
|
|||
@AfterEach
|
||||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
@Video
|
||||
fun highlightCode(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
|
|
@ -57,7 +57,7 @@ class GUI {
|
|||
// while the `continue_tutorial.java` is loading.
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']")
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Onboarding {
|
|||
fun closeProject(remoteRobot: RemoteRobot) = CommonSteps(remoteRobot).closeProject()
|
||||
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
@Video
|
||||
fun onboarding(remoteRobot: RemoteRobot): Unit = with(remoteRobot) {
|
||||
welcomeFrame {
|
||||
|
|
@ -53,7 +53,7 @@ class Onboarding {
|
|||
// So we need to wait for that to occur, and then focus on "continue_tutorial.java.ft"
|
||||
waitFor(ofSeconds(20)) {
|
||||
findAll<ComponentFixture>(
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='EditorTabLabel']")
|
||||
byXpath("//div[@accessiblename='Main.java' and @class='SingleHeightLabel']")
|
||||
).isNotEmpty()
|
||||
}
|
||||
|
||||
|
|
|
|||
4
extensions/vscode/.gitignore
vendored
4
extensions/vscode/.gitignore
vendored
|
|
@ -23,4 +23,6 @@ e2e/.test-extensions
|
|||
e2e/storage
|
||||
e2e/vsix
|
||||
e2e/test-continue/*
|
||||
!e2e/test-continue/config.json
|
||||
!e2e/test-continue/config.json
|
||||
e2e/test-continue-yaml/*
|
||||
!e2e/test-continue-yaml/config.yaml
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { By, WebDriver, WebView } from "vscode-extension-tester";
|
||||
|
||||
import { SelectorUtils } from "./SelectorUtils";
|
||||
|
||||
export class GUISelectors {
|
||||
|
|
@ -41,6 +42,24 @@ export class GUISelectors {
|
|||
return SelectorUtils.getElementByDataTestId(view, "model-select-button");
|
||||
}
|
||||
|
||||
public static getFirstContextProviderDropdownItem(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(
|
||||
view,
|
||||
"context-provider-dropdown-item",
|
||||
);
|
||||
}
|
||||
|
||||
public static getContextItemsPeek(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(view, "context-items-peek");
|
||||
}
|
||||
|
||||
public static getFirstContextItemsPeekItem(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(
|
||||
view,
|
||||
"context-items-peek-item",
|
||||
);
|
||||
}
|
||||
|
||||
public static getNthHistoryTableRow(view: WebView, index: number) {
|
||||
return SelectorUtils.getElementByDataTestId(view, `history-row-${index}`);
|
||||
}
|
||||
|
|
|
|||
76
extensions/vscode/e2e/test-continue-yaml/config.yaml
Normal file
76
extensions/vscode/e2e/test-continue-yaml/config.yaml
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
name: Test Config
|
||||
version: 0.0.1
|
||||
|
||||
rules:
|
||||
- TEST_SYS_MSG
|
||||
|
||||
models:
|
||||
- name: TEST LLM
|
||||
provider: test
|
||||
model: this field is not used
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
- autocomplete
|
||||
|
||||
- name: Mock
|
||||
provider: mock
|
||||
model: this field is not used
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: TOOL MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - role: assistant
|
||||
content: "I'm going to call a tool:"
|
||||
- role: assistant
|
||||
content: ""
|
||||
toolCalls:
|
||||
- id: test_id
|
||||
type: function
|
||||
function:
|
||||
name: builtin_exact_search
|
||||
arguments: '{"query": "test query"}'
|
||||
- REPEAT_LAST_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: SYSTEM MESSAGE MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - REPEAT_SYSTEM_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
- name: LAST MESSAGE MOCK LLM
|
||||
provider: mock
|
||||
model: claude-3-5-sonnet-latest
|
||||
requestOptions:
|
||||
extraBodyProperties:
|
||||
chatStream:
|
||||
- - REPEAT_LAST_MSG
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
|
||||
context:
|
||||
- uses: docs
|
||||
- uses: diff
|
||||
- uses: url
|
||||
- uses: folder
|
||||
- uses: terminal
|
||||
|
|
@ -44,8 +44,29 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"provider": "mock",
|
||||
"title": "SYSTEM MESSAGE MOCK LLM",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"requestOptions": {
|
||||
"extraBodyProperties": {
|
||||
"chatStream": [["REPEAT_SYSTEM_MSG"]]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"provider": "mock",
|
||||
"title": "LAST MESSAGE MOCK LLM",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"requestOptions": {
|
||||
"extraBodyProperties": {
|
||||
"chatStream": [["REPEAT_LAST_MSG"]]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"systemMessage": "TEST_SYS_MSG",
|
||||
"analytics": {
|
||||
"provider": "continue-proxy"
|
||||
},
|
||||
|
|
@ -69,6 +90,9 @@
|
|||
},
|
||||
{
|
||||
"name": "folder"
|
||||
},
|
||||
{
|
||||
"name": "terminal"
|
||||
}
|
||||
],
|
||||
"docs": []
|
||||
|
|
|
|||
|
|
@ -207,6 +207,53 @@ describe("GUI Test", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Context providers", () => {
|
||||
it("should successfully use the terminal context provider", async () => {
|
||||
await GUIActions.selectModelFromDropdown(view, "LAST MESSAGE MOCK LLM");
|
||||
|
||||
// Enter just the context provider in the input and send
|
||||
const [messageInput] = await GUISelectors.getMessageInputFields(view);
|
||||
await messageInput.sendKeys("@");
|
||||
await messageInput.sendKeys("terminal");
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
|
||||
// Open the context items peek
|
||||
const contextItemsPeek = await GUISelectors.getContextItemsPeek(view);
|
||||
await contextItemsPeek.click();
|
||||
|
||||
await TestUtils.waitForSuccess(async () => {
|
||||
const firstContextItemInPeek =
|
||||
await GUISelectors.getFirstContextItemsPeekItem(view);
|
||||
await firstContextItemInPeek.click();
|
||||
|
||||
// Check that item is there with correct name
|
||||
const description = await firstContextItemInPeek.getText();
|
||||
expect(description).to.include("Terminal");
|
||||
});
|
||||
|
||||
// Check that the contents match what we expect (repeated back by the mock LLM)
|
||||
await TestUtils.waitForSuccess(() => {
|
||||
return GUISelectors.getThreadMessageByText(
|
||||
view,
|
||||
"Current terminal contents:",
|
||||
);
|
||||
});
|
||||
}).timeout(DEFAULT_TIMEOUT.MD);
|
||||
});
|
||||
|
||||
describe("Repeat back the system message", () => {
|
||||
it("should repeat back the system message", async () => {
|
||||
await GUIActions.selectModelFromDropdown(view, "SYSTEM MESSAGE MOCK LLM");
|
||||
const [messageInput] = await GUISelectors.getMessageInputFields(view);
|
||||
await messageInput.sendKeys("Hello");
|
||||
await messageInput.sendKeys(Key.ENTER);
|
||||
await TestUtils.waitForSuccess(() =>
|
||||
GUISelectors.getThreadMessageByText(view, "TEST_SYS_MSG"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Chat Paths", () => {
|
||||
it("Send many messages → chat auto scrolls → go to history → open previous chat → it is scrolled to the bottom", async () => {
|
||||
for (let i = 0; i <= 20; i++) {
|
||||
|
|
|
|||
6
extensions/vscode/package-lock.json
generated
6
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.251",
|
||||
"version": "0.9.252",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -628,7 +628,8 @@
|
|||
"e2e:all": "npm run e2e:build && npm run e2e:compile && npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode && npm run e2e:sign-vscode && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean",
|
||||
"e2e:quick": "npm run e2e:compile && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test && npm run e2e:clean",
|
||||
"e2e:ci:download": "npm run e2e:create-storage && npm run e2e:get-chromedriver && npm run e2e:get-vscode",
|
||||
"e2e:ci:run": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test"
|
||||
"e2e:ci:run": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue npm run e2e:test",
|
||||
"e2e:ci:run-yaml": "npm run e2e:compile && npm run e2e:copy-vsix && npm run e2e:install-vsix && npm run e2e:install-extensions && CONTINUE_GLOBAL_DIR=e2e/test-continue-yaml npm run e2e:test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.6.4",
|
||||
|
|
|
|||
|
|
@ -28,15 +28,41 @@ import type {
|
|||
TerminalOptions,
|
||||
Thread,
|
||||
} from "core";
|
||||
import { SecretStorage } from "./stubs/SecretStorage";
|
||||
|
||||
class VsCodeIde implements IDE {
|
||||
ideUtils: VsCodeIdeUtils;
|
||||
secretStorage: SecretStorage;
|
||||
|
||||
constructor(
|
||||
private readonly vscodeWebviewProtocolPromise: Promise<VsCodeWebviewProtocol>,
|
||||
private readonly context: vscode.ExtensionContext,
|
||||
) {
|
||||
this.ideUtils = new VsCodeIdeUtils();
|
||||
this.secretStorage = new SecretStorage(context);
|
||||
}
|
||||
|
||||
async readSecrets(keys: string[]): Promise<Record<string, string>> {
|
||||
const secretValuePromises = keys.map((key) => this.secretStorage.get(key));
|
||||
const secretValues = await Promise.all(secretValuePromises);
|
||||
|
||||
return keys.reduce(
|
||||
(acc, key, index) => {
|
||||
if (secretValues[index] === undefined) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
acc[key] = secretValues[index];
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string>,
|
||||
);
|
||||
}
|
||||
|
||||
async writeSecrets(secrets: { [key: string]: string }): Promise<void> {
|
||||
for (const [key, value] of Object.entries(secrets)) {
|
||||
await this.secretStorage.store(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
async fileExists(uri: string): Promise<boolean> {
|
||||
|
|
@ -399,17 +425,22 @@ class VsCodeIde implements IDE {
|
|||
);
|
||||
}
|
||||
|
||||
async runCommand(command: string, options: TerminalOptions = {reuseTerminal: true}): Promise<void> {
|
||||
async runCommand(
|
||||
command: string,
|
||||
options: TerminalOptions = { reuseTerminal: true },
|
||||
): Promise<void> {
|
||||
let terminal: vscode.Terminal | undefined;
|
||||
if (vscode.window.terminals.length && options.reuseTerminal) {
|
||||
if (options.terminalName) {
|
||||
terminal = vscode.window.terminals.find(t => t?.name === options.terminalName);
|
||||
terminal = vscode.window.terminals.find(
|
||||
(t) => t?.name === options.terminalName,
|
||||
);
|
||||
} else {
|
||||
terminal = vscode.window.activeTerminal ?? vscode.window.terminals[0];
|
||||
}
|
||||
}
|
||||
|
||||
if( !terminal) {
|
||||
if (!terminal) {
|
||||
terminal = vscode.window.createTerminal(options?.terminalName);
|
||||
}
|
||||
terminal.show();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ export class VsCodeExtension {
|
|||
const result = await this.configHandler.getSerializedConfig();
|
||||
this.sidebar.webviewProtocol?.request("configUpdate", {
|
||||
result,
|
||||
profileId: this.configHandler.currentProfile.profileId,
|
||||
profileId: this.configHandler.currentProfile.profileDescription.id,
|
||||
});
|
||||
|
||||
this.tabAutocompleteModel.clearLlm();
|
||||
|
|
@ -301,7 +301,7 @@ export class VsCodeExtension {
|
|||
true,
|
||||
);
|
||||
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true);
|
||||
const sessionInfo = await getControlPlaneSessionInfo(true, false);
|
||||
this.webviewProtocolPromise.then(async (webviewProtocol) => {
|
||||
void webviewProtocol.request("didChangeControlPlaneSessionInfo", {
|
||||
sessionInfo,
|
||||
|
|
|
|||
|
|
@ -446,7 +446,10 @@ export class VsCodeMessenger {
|
|||
ide.getGitHubAuthToken(msg.data),
|
||||
);
|
||||
this.onWebviewOrCore("getControlPlaneSessionInfo", async (msg) => {
|
||||
return getControlPlaneSessionInfo(msg.data.silent);
|
||||
return getControlPlaneSessionInfo(
|
||||
msg.data.silent,
|
||||
msg.data.useOnboarding,
|
||||
);
|
||||
});
|
||||
this.onWebviewOrCore("logoutOfControlPlane", async (msg) => {
|
||||
const sessions = await this.workOsAuthProvider.getSessions();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
import crypto from "crypto";
|
||||
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { controlPlaneEnv } from "core/control-plane/env";
|
||||
import fetch from "node-fetch";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
|
|
@ -16,6 +20,7 @@ import {
|
|||
} from "vscode";
|
||||
|
||||
import { PromiseAdapter, promiseFromEvent } from "./promiseUtils";
|
||||
import { SecretStorage } from "./SecretStorage";
|
||||
|
||||
const AUTH_NAME = "Continue";
|
||||
|
||||
|
|
@ -26,14 +31,6 @@ class UriEventHandler extends EventEmitter<Uri> implements UriHandler {
|
|||
this.fire(uri);
|
||||
}
|
||||
}
|
||||
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { controlPlaneEnv } from "core/control-plane/env";
|
||||
|
||||
import crypto from "crypto";
|
||||
|
||||
import { SecretStorage } from "./SecretStorage";
|
||||
|
||||
// Function to generate a random string of specified length
|
||||
function generateRandomString(length: number): string {
|
||||
const possibleCharacters =
|
||||
|
|
@ -163,12 +160,6 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
}
|
||||
|
||||
get ideRedirectUri() {
|
||||
const publisher = this.context.extension.packageJSON.publisher;
|
||||
const name = this.context.extension.packageJSON.name;
|
||||
return `${env.uriScheme}://${publisher}.${name}`;
|
||||
}
|
||||
|
||||
get redirectUri() {
|
||||
if (
|
||||
env.uriScheme === "vscode-insiders" ||
|
||||
env.uriScheme === "vscode" ||
|
||||
|
|
@ -179,6 +170,18 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
url.pathname = `/auth/${env.uriScheme}-redirect`;
|
||||
return url.toString();
|
||||
}
|
||||
const publisher = this.context.extension.packageJSON.publisher;
|
||||
const name = this.context.extension.packageJSON.name;
|
||||
return `${env.uriScheme}://${publisher}.${name}`;
|
||||
}
|
||||
|
||||
public static useOnboardingUri: boolean = false;
|
||||
get redirectUri() {
|
||||
if (WorkOsAuthProvider.useOnboardingUri) {
|
||||
const url = new URL(controlPlaneEnv.APP_URL);
|
||||
url.pathname = `/onboarding/redirect/${env.uriScheme}`;
|
||||
return url.toString();
|
||||
}
|
||||
return this.ideRedirectUri;
|
||||
}
|
||||
|
||||
|
|
@ -407,8 +410,9 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
try {
|
||||
return await Promise.race([
|
||||
codeExchangePromise.promise,
|
||||
new Promise<string>((_, reject) =>
|
||||
setTimeout(() => reject("Cancelled"), 15 * 60 * 1_000),
|
||||
new Promise<string>(
|
||||
(_, reject) =>
|
||||
setTimeout(() => reject("Cancelled"), 60 * 60 * 1_000), // 60min timeout
|
||||
),
|
||||
promiseFromEvent<any, any>(
|
||||
token.onCancellationRequested,
|
||||
|
|
@ -488,20 +492,29 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
|
||||
export async function getControlPlaneSessionInfo(
|
||||
silent: boolean,
|
||||
useOnboarding: boolean,
|
||||
): Promise<ControlPlaneSessionInfo | undefined> {
|
||||
const session = await authentication.getSession(
|
||||
controlPlaneEnv.AUTH_TYPE,
|
||||
[],
|
||||
silent ? { silent: true } : { createIfNone: true },
|
||||
);
|
||||
if (!session) {
|
||||
return undefined;
|
||||
try {
|
||||
if (useOnboarding) {
|
||||
WorkOsAuthProvider.useOnboardingUri = true;
|
||||
}
|
||||
|
||||
const session = await authentication.getSession(
|
||||
controlPlaneEnv.AUTH_TYPE,
|
||||
[],
|
||||
silent ? { silent: true } : { createIfNone: true },
|
||||
);
|
||||
if (!session) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
accessToken: session.accessToken,
|
||||
account: {
|
||||
id: session.account.id,
|
||||
label: session.account.label,
|
||||
},
|
||||
};
|
||||
} finally {
|
||||
WorkOsAuthProvider.useOnboardingUri = false;
|
||||
}
|
||||
return {
|
||||
accessToken: session.accessToken,
|
||||
account: {
|
||||
id: session.account.id,
|
||||
label: session.account.label,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
21
gui/package-lock.json
generated
21
gui/package-lock.json
generated
|
|
@ -7,7 +7,7 @@
|
|||
"name": "gui",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -547,11 +547,20 @@
|
|||
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.0.tgz",
|
||||
"integrity": "sha512-NwagzzpnPLbMC3delzFSjWiFv5fp8ReFjdMQF0ko0Xg+U0Myja90k/J7JWGegF/SZMABxc/OJchElJFr58TwGA==",
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
|
||||
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.0",
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { ChevronUpDownIcon } from "@heroicons/react/24/outline";
|
||||
import { Fragment, useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -9,10 +10,9 @@ import {
|
|||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useAuth } from "../context/Auth";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { setSelectedProfileId } from "../redux/slices/sessionSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
|
||||
const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
|
||||
|
|
@ -46,7 +46,7 @@ export default function AccountDialog() {
|
|||
<span className="text-lightgray mb-4 block text-center">
|
||||
Signed out
|
||||
</span>
|
||||
<Button className="w-full" onClick={login}>
|
||||
<Button className="w-full" onClick={() => login(false)}>
|
||||
Sign in
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
import { XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { CloseButton, defaultBorderRadius, vscInputBackground } from "../..";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import Alert from "../../gui/Alert";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import { useOnboardingCard } from "../hooks";
|
||||
import OnboardingLocalTab from "../tabs/OnboardingLocalTab";
|
||||
import MainTab from "./tabs/main";
|
||||
|
||||
const StyledCard = styled.div`
|
||||
margin: auto;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
background-color: ${vscInputBackground};
|
||||
box-shadow:
|
||||
0 20px 25px -5px rgb(0 0 0 / 0.1),
|
||||
0 8px 10px -6px rgb(0 0 0 / 0.1);
|
||||
`;
|
||||
|
||||
export interface OnboardingCardState {
|
||||
show?: boolean;
|
||||
activeTab?: TabTitle;
|
||||
}
|
||||
|
||||
export function PlatformOnboardingCard() {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
|
||||
if (getLocalStorage("onboardingStatus") === undefined) {
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
const [currentTab, setCurrentTab] = useState<"main" | "local">("main");
|
||||
|
||||
return (
|
||||
<StyledCard className="xs:py-4 xs:px-4 relative px-2 py-3">
|
||||
<CloseButton onClick={onboardingCard.close}>
|
||||
<XMarkIcon className="mt-1.5 hidden h-5 w-5 hover:brightness-125 sm:flex" />
|
||||
</CloseButton>
|
||||
<div className="content py-4">
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
{currentTab === "main" ? (
|
||||
<MainTab onRemainLocal={() => setCurrentTab("local")} />
|
||||
) : (
|
||||
<div className="mt-4">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local{" "}
|
||||
<code>config.yaml</code> file. If you're just looking to use
|
||||
Ollama and still want to manage your configuration through
|
||||
Continue, click{" "}
|
||||
<a href="#" onClick={() => setCurrentTab("main")}>
|
||||
here
|
||||
</a>
|
||||
</Alert>
|
||||
|
||||
<OnboardingLocalTab />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</StyledCard>
|
||||
);
|
||||
}
|
||||
26
gui/src/components/OnboardingCard/platform/tabs/local.tsx
Normal file
26
gui/src/components/OnboardingCard/platform/tabs/local.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { useAuth } from "../../../../context/Auth";
|
||||
import ContinueLogo from "../../../gui/ContinueLogo";
|
||||
import { useOnboardingCard } from "../../hooks";
|
||||
|
||||
export default function LocalTab() {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
|
||||
return (
|
||||
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
|
||||
<div className="xs:flex hidden">
|
||||
<ContinueLogo height={75} />
|
||||
</div>
|
||||
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
Log in to quickly build your first custom AI code assistant
|
||||
</p>
|
||||
|
||||
{/* <p className="xs:w-3/4 w-full text-sm">
|
||||
To prevent abuse, we'll ask you to sign in to GitHub.
|
||||
</p> */}
|
||||
|
||||
<div className="mt-4 w-full"></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
49
gui/src/components/OnboardingCard/platform/tabs/main.tsx
Normal file
49
gui/src/components/OnboardingCard/platform/tabs/main.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { Button, ButtonSubtext } from "../../..";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import ContinueLogo from "../../../gui/ContinueLogo";
|
||||
import { useOnboardingCard } from "../../hooks";
|
||||
|
||||
export default function MainTab({
|
||||
onRemainLocal,
|
||||
}: {
|
||||
onRemainLocal: () => void;
|
||||
}) {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
|
||||
function onGetStarted() {
|
||||
auth.login(true).then((success) => {
|
||||
if (success) {
|
||||
onboardingCard.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
|
||||
<div className="xs:flex hidden">
|
||||
<ContinueLogo height={75} />
|
||||
</div>
|
||||
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
Log in to quickly build your first custom AI code assistant
|
||||
</p>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started
|
||||
</Button>
|
||||
<ButtonSubtext onClick={onRemainLocal}>
|
||||
<div className="mt-4 flex cursor-pointer items-center justify-center gap-1">
|
||||
<span>Or, remain local</span>
|
||||
<ChevronRightIcon className="h-3 w-3" />
|
||||
</div>
|
||||
</ButtonSubtext>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import { UserCircleIcon as UserCircleIconSolid } from "@heroicons/react/24/solid
|
|||
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 { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
|
|
@ -21,11 +21,10 @@ import {
|
|||
import { useAuth } from "../context/Auth";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
import { getFontSize } from "../util";
|
||||
import HeaderButtonWithToolTip from "./gui/HeaderButtonWithToolTip";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
|
||||
const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -148,9 +147,6 @@ function ProfileSwitcher() {
|
|||
|
||||
const shouldShowPopup =
|
||||
!lastControlServerBetaEnabledStatus && enableControlServerBeta;
|
||||
if (shouldShowPopup) {
|
||||
ideMessenger.ide.showToast("info", "Continue for Teams enabled");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
80
gui/src/components/dialogs/AboutAssistantDialog.tsx
Normal file
80
gui/src/components/dialogs/AboutAssistantDialog.tsx
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
export default function AboutAssistantDialog() {
|
||||
const configJson = useAppSelector((store: RootState) => store.config.config);
|
||||
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="h-[60vh] space-y-4 overflow-y-scroll px-4 pb-4">
|
||||
<h2>About {selectedProfileId} assistant</h2>
|
||||
{configJson.models?.length > 0 && (
|
||||
<details>
|
||||
<summary>Chat models</summary>
|
||||
<ul>
|
||||
{configJson.models.map((model, index) => (
|
||||
<li key={index}>{model.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.embeddingsProvider && (
|
||||
<details>
|
||||
<summary>Embedding model</summary>
|
||||
<p>{configJson.embeddingsProvider}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.reranker?.name && (
|
||||
<details>
|
||||
<summary>Rerank model</summary>
|
||||
<p>{configJson.reranker.name}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.systemMessage && (
|
||||
<details>
|
||||
<summary>Rules</summary>
|
||||
<p>{configJson.systemMessage}</p>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.contextProviders?.length ? (
|
||||
<details>
|
||||
<summary>Context</summary>
|
||||
<ul>
|
||||
{configJson.contextProviders.map((provider, index) => (
|
||||
<li key={index}>{provider.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
) : null}
|
||||
|
||||
{configJson.tools.length > 0 && (
|
||||
<details>
|
||||
<summary>Tools</summary>
|
||||
<ul>
|
||||
{configJson.tools.map((tool, index) => (
|
||||
<li key={index}>{tool.displayTitle}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
|
||||
{configJson.docs?.length ? (
|
||||
<details>
|
||||
<summary>Docs</summary>
|
||||
<ul>
|
||||
{configJson.docs.map((doc, index) => (
|
||||
<li key={index}>{doc.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import styled, { keyframes } from "styled-components";
|
||||
import styled from "styled-components";
|
||||
import { getFontSize, isJetBrains } from "../util";
|
||||
|
||||
export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background";
|
||||
|
|
@ -298,11 +298,6 @@ export const HeaderButton = styled.button<{
|
|||
padding: 2px;
|
||||
`;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 1px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
||||
export const StyledActionButton = styled.div`
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
|||
<div
|
||||
onClick={openContextItem}
|
||||
className="group mr-2 flex cursor-pointer items-center overflow-hidden text-ellipsis whitespace-nowrap rounded px-1.5 py-1 text-xs hover:bg-white/10"
|
||||
data-testid="context-items-peek-item"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
{getContextItemIcon()}
|
||||
|
|
@ -161,6 +162,7 @@ function ContextItemsPeek({
|
|||
<div
|
||||
className="flex cursor-pointer items-center justify-start text-xs text-gray-300"
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
data-testid="context-items-peek"
|
||||
>
|
||||
<div className="relative mr-1 h-4 w-4">
|
||||
<ChevronRightIcon
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
vscInputBackground,
|
||||
} from "..";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUseActiveFile } from "../../redux/selectors";
|
||||
import { selectUseActiveFile, selectUsePlatform } from "../../redux/selectors";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import {
|
||||
selectHasCodeToEdit,
|
||||
|
|
@ -26,6 +26,7 @@ import {
|
|||
} from "../../util";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import AssistantAndModelSelect from "../modelSelection/platform/AssistantAndModelSelect";
|
||||
import HoverItem from "./InputToolbar/HoverItem";
|
||||
import ToggleToolsButton from "./InputToolbar/ToggleToolsButton";
|
||||
|
||||
|
|
@ -96,6 +97,8 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
modelSupportsTools(defaultModel.model, defaultModel.provider) &&
|
||||
!props.toolbarOptions?.hideTools;
|
||||
|
||||
const usePlatform = useAppSelector(selectUsePlatform);
|
||||
|
||||
const supportsImages =
|
||||
defaultModel &&
|
||||
modelSupportsImages(
|
||||
|
|
@ -114,7 +117,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
className="find-widget-skip flex"
|
||||
>
|
||||
<div className="flex items-center justify-start gap-2 whitespace-nowrap">
|
||||
<ModelSelect />
|
||||
{usePlatform ? <AssistantAndModelSelect /> : <ModelSelect />}
|
||||
<div className="xs:flex -mb-1 hidden items-center text-gray-400 transition-colors duration-200">
|
||||
{props.toolbarOptions?.hideImageUpload ||
|
||||
(supportsImages && (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import { Transition } from "@headlessui/react";
|
||||
|
||||
export default function PopoverTransition({
|
||||
children,
|
||||
show,
|
||||
afterLeave,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
show?: boolean;
|
||||
afterLeave?: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Transition
|
||||
show={show}
|
||||
enter="transition duration-100 ease-out"
|
||||
enterFrom="transform scale-95 opacity-0"
|
||||
enterTo="transform scale-100 opacity-100"
|
||||
leave="transition duration-75 ease-out"
|
||||
leaveFrom="transform scale-100 opacity-100"
|
||||
leaveTo="transform scale-95 opacity-0"
|
||||
afterLeave={afterLeave}
|
||||
>
|
||||
{children}
|
||||
</Transition>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Listbox, Transition } from "@headlessui/react";
|
||||
import { Listbox } from "@headlessui/react";
|
||||
import {
|
||||
EllipsisHorizontalCircleIcon as EllipsisHorizontalIcon,
|
||||
WrenchScrewdriverIcon as WrenchScrewdriverIconOutline,
|
||||
|
|
@ -7,12 +7,13 @@ import { WrenchScrewdriverIcon as WrenchScrewdriverIconSolid } from "@heroicons/
|
|||
import { useEffect, useRef, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { lightGray, vscForeground } from "../..";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { toggleUseTools } from "../../../redux/slices/uiSlice";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
import InfoHover from "../../InfoHover";
|
||||
import HoverItem from "./HoverItem";
|
||||
import PopoverTransition from "./PopoverTransition";
|
||||
import ToolDropdownItem from "./ToolDropdownItem";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
|
||||
export default function ToolDropdown() {
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
|
|
@ -85,14 +86,8 @@ export default function ToolDropdown() {
|
|||
>
|
||||
<EllipsisHorizontalIcon className="h-3 w-3 cursor-pointer hover:brightness-125" />
|
||||
</Listbox.Button>
|
||||
<Transition
|
||||
<PopoverTransition
|
||||
show={open}
|
||||
enter="transition duration-100 ease-out"
|
||||
enterFrom="transform scale-95 opacity-0"
|
||||
enterTo="transform scale-100 opacity-100"
|
||||
leave="transition duration-75 ease-out"
|
||||
leaveFrom="transform scale-100 opacity-100"
|
||||
leaveTo="transform scale-95 opacity-0"
|
||||
afterLeave={() => setDropdownOpen(false)}
|
||||
>
|
||||
<Listbox.Options
|
||||
|
|
@ -151,7 +146,7 @@ export default function ToolDropdown() {
|
|||
))}
|
||||
</div>
|
||||
</Listbox.Options>
|
||||
</Transition>
|
||||
</PopoverTransition>
|
||||
</>
|
||||
)}
|
||||
</Listbox>
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ import FileIcon from "../FileIcon";
|
|||
import SafeImg from "../SafeImg";
|
||||
import AddDocsDialog from "../dialogs/AddDocsDialog";
|
||||
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
|
||||
import { ComboBoxItem, ComboBoxItemType } from "./types";
|
||||
import { DiscordIcon } from "../svg/DiscordIcon";
|
||||
import { GoogleIcon } from "../svg/GoogleIcon";
|
||||
import { GitlabIcon } from "../svg/GitlabIcon";
|
||||
import { GithubIcon } from "../svg/GithubIcon";
|
||||
import { GitlabIcon } from "../svg/GitlabIcon";
|
||||
import { GoogleIcon } from "../svg/GoogleIcon";
|
||||
import { ComboBoxItem, ComboBoxItemType } from "./types";
|
||||
|
||||
const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
|
||||
file: FolderIcon,
|
||||
|
|
@ -81,6 +81,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
|
|||
google: GoogleIcon,
|
||||
"gitlab-mr": GitlabIcon,
|
||||
http: GlobeAltIcon,
|
||||
trash: TrashIcon,
|
||||
};
|
||||
|
||||
export function getIconFromDropdownItem(
|
||||
|
|
@ -413,6 +414,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
|
|||
key={index}
|
||||
onClick={() => selectItem(index)}
|
||||
onMouseEnter={() => setSelectedIndex(index)}
|
||||
data-testid="context-provider-dropdown-item"
|
||||
>
|
||||
<span className="flex w-full items-center justify-between">
|
||||
<div className="flex items-center justify-center">
|
||||
|
|
@ -451,7 +453,10 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
|
|||
/>
|
||||
)}
|
||||
{item.subActions?.map((subAction) => {
|
||||
const Icon = ICONS_FOR_DROPDOWN[subAction.icon];
|
||||
const Icon = getIconFromDropdownItem(
|
||||
subAction.icon,
|
||||
"action",
|
||||
);
|
||||
return (
|
||||
<HeaderButtonWithToolTip
|
||||
onClick={(e) => {
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ import {
|
|||
PlusIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { MouseEvent, useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
Divider,
|
||||
lightGray,
|
||||
vscInputBackground,
|
||||
} from "..";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import {
|
||||
getFontSize,
|
||||
|
|
@ -24,11 +24,7 @@ import {
|
|||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../redux/slices/configSlice";
|
||||
import { Divider } from "./platform/shared";
|
||||
|
||||
interface ModelOptionProps {
|
||||
option: Option;
|
||||
|
|
@ -144,7 +140,7 @@ function ModelOption({
|
|||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
function onClickDelete(e: MouseEvent) {
|
||||
function onClickDelete(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
|
@ -164,7 +160,7 @@ function ModelOption({
|
|||
);
|
||||
}
|
||||
|
||||
function onClickGear(e: MouseEvent) {
|
||||
function onClickGear(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
|
@ -173,7 +169,7 @@ function ModelOption({
|
|||
});
|
||||
}
|
||||
|
||||
function handleOptionClick(e: MouseEvent) {
|
||||
function handleOptionClick(e: any) {
|
||||
if (showMissingApiKeyMsg) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,194 @@
|
|||
import { Popover } from "@headlessui/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
DocumentIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
cycleDefaultModel,
|
||||
selectDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { cycleProfile } from "../../../redux/thunks/cycleProfile";
|
||||
import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util";
|
||||
import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition";
|
||||
import { AssistantSelect } from "./AssistantSelect";
|
||||
import { ModelSelect, modelSelectTitle } from "./ModelSelect";
|
||||
import { MAX_HEIGHT_PX } from "./shared";
|
||||
|
||||
const StyledPopoverButton = styled(Popover.Button)`
|
||||
font-family: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: ${getFontSize() - 2}px;
|
||||
background: transparent;
|
||||
color: ${lightGray};
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledPopoverPanel = styled(Popover.Panel)<{ $showabove: boolean }>`
|
||||
margin-top: 4px;
|
||||
position: absolute;
|
||||
padding: 0px;
|
||||
cursor: default;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
border: 0.5px solid ${lightGray};
|
||||
background-color: ${vscInputBackground};
|
||||
|
||||
${(props) => (props.$showabove ? "bottom: 100%;" : "top: 100%;")}
|
||||
`;
|
||||
|
||||
function AssistantAndModelSelect() {
|
||||
const dispatch = useAppDispatch();
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => calculatePosition();
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
function calculatePosition() {
|
||||
if (!buttonRef.current) {
|
||||
return;
|
||||
}
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
}
|
||||
|
||||
function onClickAddModel(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
// Close the dropdown
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 500;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) {
|
||||
const now = Date.now();
|
||||
|
||||
if (event.shiftKey) {
|
||||
dispatch(cycleDefaultModel("next"));
|
||||
} else {
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
dispatch(cycleProfile());
|
||||
lastToggleTime = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<div className="relative">
|
||||
<StyledPopoverButton
|
||||
data-testid="model-select-button"
|
||||
ref={buttonRef}
|
||||
className="h-[18px] overflow-hidden"
|
||||
style={{ padding: 0 }}
|
||||
onClick={calculatePosition}
|
||||
>
|
||||
<div className="flex max-w-[33vw] items-center gap-0.5 text-gray-400 transition-colors duration-200">
|
||||
{selectedProfile?.id === "local" ? (
|
||||
<>
|
||||
<DocumentIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<SparklesIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{selectedProfile?.title || "Select assistant"}
|
||||
{" / "}
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledPopoverButton>
|
||||
<PopoverTransition>
|
||||
<StyledPopoverPanel
|
||||
$showabove={showAbove}
|
||||
className="flex max-w-[90vw] overflow-hidden"
|
||||
style={{ zIndex: 1000 }}
|
||||
>
|
||||
<AssistantSelect
|
||||
onClose={() => {
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ModelSelect
|
||||
selectedProfileId={selectedProfileId}
|
||||
onClickAddModel={onClickAddModel}
|
||||
/>
|
||||
</StyledPopoverPanel>
|
||||
</PopoverTransition>
|
||||
</div>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default AssistantAndModelSelect;
|
||||
111
gui/src/components/modelSelection/platform/AssistantSelect.tsx
Normal file
111
gui/src/components/modelSelection/platform/AssistantSelect.tsx
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import {
|
||||
DocumentIcon,
|
||||
PlusIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { setProfileId } from "../../../redux/thunks/setProfileId";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
interface AssistantSelectProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AssistantSelect(props: AssistantSelectProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
function onNewAssistant() {
|
||||
ideMessenger.post("openUrl", "https://app-test.continue.dev/new");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-lightgray flex min-w-0 flex-col overflow-x-hidden border-0 border-r-[0.5px] border-solid pt-0">
|
||||
<div className={`max-h-[300px]`}>
|
||||
{profiles.map((option, idx) => (
|
||||
<Option
|
||||
key={idx}
|
||||
idx={idx}
|
||||
disabled={!!option.errors?.length}
|
||||
showConfigure={true}
|
||||
selected={option.id === selectedProfile?.id}
|
||||
onLink={
|
||||
option.id !== "local"
|
||||
? (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onConfigure={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
if (option.id === "local") {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
} else {
|
||||
props.onClose();
|
||||
dispatch(setDialogMessage(<AboutAssistantDialog />));
|
||||
dispatch(setShowDialog(true));
|
||||
}
|
||||
}}
|
||||
errors={option.errors}
|
||||
onClickError={() => {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}}
|
||||
onClick={() => dispatch(setProfileId(option.id))}
|
||||
>
|
||||
<div className="flex min-w-0 items-center">
|
||||
{option.id === "local" ? (
|
||||
<DocumentIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
) : (
|
||||
<SparklesIcon
|
||||
className="mr-2 h-4 w-4 flex-shrink-0"
|
||||
color={
|
||||
option.id === selectedProfile?.id ? "yellow" : undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<span className="flex-1 truncate text-xs">{option.title}</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
New Assistant
|
||||
</div>
|
||||
</OptionDiv>
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}'</code> toggle assistant
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
121
gui/src/components/modelSelection/platform/ModelSelect.tsx
Normal file
121
gui/src/components/modelSelection/platform/ModelSelect.tsx
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
export interface ModelOption {
|
||||
value: string;
|
||||
title: string;
|
||||
apiKey?: string;
|
||||
}
|
||||
|
||||
export 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 ModelSelectProps {
|
||||
selectedProfileId: string;
|
||||
onClickAddModel: (e: any) => void;
|
||||
}
|
||||
|
||||
export function ModelSelect(props: ModelSelectProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const allModels = useAppSelector((state) => state.config.config.models);
|
||||
const [options, setOptions] = useState<ModelOption[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<ModelOption[]>([]);
|
||||
|
||||
// Sort so that options without an API key are at the end
|
||||
useEffect(() => {
|
||||
const enabledOptions = options.filter((option) => option.apiKey !== "");
|
||||
const disabledOptions = options.filter((option) => option.apiKey === "");
|
||||
|
||||
const sorted = [...enabledOptions, ...disabledOptions];
|
||||
|
||||
setSortedOptions(sorted);
|
||||
}, [options]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
apiKey: model.apiKey,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
function onModelChange(modelTitle: string) {
|
||||
if (modelTitle === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: modelTitle }));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xs:flex hidden min-w-0 flex-col">
|
||||
<div className={`max-h-[300px] overflow-y-scroll`}>
|
||||
{sortedOptions.map((option, idx) => (
|
||||
<Option
|
||||
idx={idx}
|
||||
key={idx}
|
||||
onClick={() => onModelChange(option.title)}
|
||||
disabled={option.apiKey === ""}
|
||||
selected={option.title === defaultModel?.title}
|
||||
showConfigure={false}
|
||||
onConfigure={() => {}}
|
||||
>
|
||||
<div className="flex flex-grow items-center">
|
||||
<CubeIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
<span className="flex-grow">
|
||||
{option.title}
|
||||
{option.apiKey === "" && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto">
|
||||
{props.selectedProfileId === "local" && (
|
||||
<>
|
||||
<OptionDiv key={options.length} onClick={props.onClickAddModel}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4" />
|
||||
Add Chat model
|
||||
</div>
|
||||
</OptionDiv>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}⇧'</code> toggle model
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
151
gui/src/components/modelSelection/platform/shared.tsx
Normal file
151
gui/src/components/modelSelection/platform/shared.tsx
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
import { ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
Cog6ToothIcon,
|
||||
ExclamationTriangleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray } from "../..";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
|
||||
export const OptionDiv = styled.div<{
|
||||
isDisabled?: boolean;
|
||||
isSelected?: boolean;
|
||||
}>`
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 6px 12px;
|
||||
|
||||
min-width: 0px;
|
||||
|
||||
${({ isDisabled, isSelected }) =>
|
||||
!isDisabled &&
|
||||
`
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: ${lightGray}33;
|
||||
}
|
||||
|
||||
${
|
||||
isSelected &&
|
||||
`
|
||||
background: ${lightGray}22;
|
||||
`
|
||||
}
|
||||
`}
|
||||
|
||||
${({ isDisabled }) =>
|
||||
isDisabled &&
|
||||
`
|
||||
opacity: 0.5;
|
||||
`}
|
||||
`;
|
||||
|
||||
export const MAX_HEIGHT_PX = 300;
|
||||
|
||||
export const Divider = styled.div`
|
||||
height: 0.5px;
|
||||
background-color: ${lightGray};
|
||||
`;
|
||||
|
||||
interface ModelOptionProps {
|
||||
children: React.ReactNode;
|
||||
idx: number;
|
||||
disabled: boolean;
|
||||
selected: boolean;
|
||||
showConfigure: boolean;
|
||||
onLink?: (e: any) => void;
|
||||
onConfigure: (e: any) => void;
|
||||
onClick: () => void;
|
||||
errors?: ConfigValidationError[];
|
||||
onClickError?: (e: any) => void;
|
||||
}
|
||||
|
||||
const IconBase = styled.div<{ $hovered: boolean }>`
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
|
||||
visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background-color: ${lightGray}33;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
|
||||
const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
|
||||
as: ArrowTopRightOnSquareIcon,
|
||||
})``;
|
||||
const StyledExclamationTriangleIcon = styled(IconBase).attrs({
|
||||
as: ExclamationTriangleIcon,
|
||||
})``;
|
||||
|
||||
export function Option({
|
||||
onConfigure,
|
||||
children,
|
||||
idx,
|
||||
disabled,
|
||||
onClick,
|
||||
showConfigure,
|
||||
onLink,
|
||||
selected,
|
||||
errors,
|
||||
onClickError,
|
||||
}: ModelOptionProps) {
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
function handleOptionClick(e: any) {
|
||||
if (disabled) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
onClick();
|
||||
}
|
||||
|
||||
return (
|
||||
<OptionDiv
|
||||
key={idx}
|
||||
isDisabled={disabled}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
isSelected={selected}
|
||||
onClick={!disabled ? handleOptionClick : undefined}
|
||||
>
|
||||
<div className="flex w-full flex-col gap-0.5">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
{children}
|
||||
<div className="ml-2 flex items-center">
|
||||
{!errors?.length && showConfigure && (
|
||||
<StyledCog6ToothIcon $hovered={hovered} onClick={onConfigure} />
|
||||
)}
|
||||
{!errors?.length && onLink && (
|
||||
<StyledArrowTopRightOnSquareIcon
|
||||
$hovered={hovered}
|
||||
onClick={onLink}
|
||||
/>
|
||||
)}
|
||||
{errors?.length ? (
|
||||
<>
|
||||
<StyledExclamationTriangleIcon
|
||||
data-tooltip-id={`${idx}-errors-tooltip`}
|
||||
$hovered={hovered}
|
||||
className="cursor-pointer text-red-500"
|
||||
onClick={onClickError}
|
||||
/>
|
||||
<ToolTip id={`${idx}-errors-tooltip`}>
|
||||
<div className="font-semibold">Errors</div>
|
||||
{JSON.stringify(errors, null, 2)}
|
||||
</ToolTip>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</OptionDiv>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +1,30 @@
|
|||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import { useDispatch } from "react-redux";
|
||||
import AccountDialog from "../components/AccountDialog";
|
||||
import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
|
||||
import { IdeMessengerContext } from "./IdeMessenger";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import {
|
||||
selectAvailableProfiles,
|
||||
setAvailableProfiles,
|
||||
} from "../redux/slices/sessionSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import AccountDialog from "../components/AccountDialog";
|
||||
import { useAppSelector } from "../redux/hooks";
|
||||
import { IdeMessengerContext } from "./IdeMessenger";
|
||||
|
||||
interface AuthContextType {
|
||||
session: ControlPlaneSessionInfo | undefined;
|
||||
logout: () => void;
|
||||
login: () => void;
|
||||
login: (useOnboarding: boolean) => Promise<boolean>;
|
||||
selectedProfile: ProfileDescription | undefined;
|
||||
profiles: ProfileDescription[];
|
||||
controlServerBetaEnabled: boolean;
|
||||
|
|
@ -34,7 +38,9 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
const [session, setSession] = useState<ControlPlaneSessionInfo | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const [profiles, setProfiles] = useState<ProfileDescription[]>([]);
|
||||
|
||||
const profiles = useAppSelector(selectAvailableProfiles);
|
||||
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
|
@ -49,33 +55,42 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
(state) => state.misc.lastControlServerBetaEnabledStatus,
|
||||
);
|
||||
|
||||
const login = () => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: false })
|
||||
.then((result) => {
|
||||
if (result.status === "error") {
|
||||
return;
|
||||
}
|
||||
const session = result.content;
|
||||
setSession(session);
|
||||
const login: AuthContextType["login"] = (useOnboarding: boolean) => {
|
||||
return new Promise((resolve) => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", {
|
||||
silent: false,
|
||||
useOnboarding,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.status === "error") {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is the first time the user has logged in, explain how profiles work
|
||||
if (!getLocalStorage("shownProfilesIntroduction")) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
title="Welcome to Continue for Teams!"
|
||||
text="You can switch between your local profile and team profile using the profile icon in the top right. Each profile defines a set of models, slash commands, context providers, and other settings to customize Continue."
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
setLocalStorage("shownProfilesIntroduction", true);
|
||||
}
|
||||
});
|
||||
const session = result.content;
|
||||
setSession(session);
|
||||
|
||||
// If this is the first time the user has logged in, explain how profiles work
|
||||
if (!getLocalStorage("shownProfilesIntroduction")) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
title="Welcome to Continue for Teams!"
|
||||
text="You can switch between your local profile and team profile using the profile icon in the top right. Each profile defines a set of models, slash commands, context providers, and other settings to customize Continue."
|
||||
hideCancelButton={true}
|
||||
confirmText="Ok"
|
||||
onConfirm={() => {}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
setLocalStorage("shownProfilesIntroduction", true);
|
||||
}
|
||||
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
|
|
@ -102,12 +117,15 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
});
|
||||
|
||||
useWebviewListener("signInToControlPlane", async () => {
|
||||
login();
|
||||
login(false);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger
|
||||
.request("getControlPlaneSessionInfo", { silent: true })
|
||||
.request("getControlPlaneSessionInfo", {
|
||||
silent: true,
|
||||
useOnboarding: false,
|
||||
})
|
||||
.then(
|
||||
(result) => result.status === "success" && setSession(result.content),
|
||||
);
|
||||
|
|
@ -123,9 +141,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
|
||||
const shouldShowPopup =
|
||||
!lastControlServerBetaEnabledStatus && enableControlServerBeta;
|
||||
if (shouldShowPopup) {
|
||||
ideMessenger.ide.showToast("info", "Continue for Teams enabled");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
@ -145,14 +160,16 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
ideMessenger
|
||||
.request("config/listProfiles", undefined)
|
||||
.then(
|
||||
(result) => result.status === "success" && setProfiles(result.content),
|
||||
(result) =>
|
||||
result.status === "success" &&
|
||||
dispatch(setAvailableProfiles(result.content)),
|
||||
);
|
||||
}, []);
|
||||
|
||||
useWebviewListener(
|
||||
"didChangeAvailableProfiles",
|
||||
async (data) => {
|
||||
setProfiles(data.profiles);
|
||||
dispatch(setAvailableProfiles(data.profiles));
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import { useCallback, useContext, useEffect, useRef } from "react";
|
|||
import { VSC_THEME_COLOR_VARS } from "../components";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { BrowserSerializedContinueConfig } from "core";
|
||||
import { ConfigResult } from "core/config/load";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { setConfigError, setConfigResult } from "../redux/slices/configSlice";
|
||||
import { updateIndexingStatus } from "../redux/slices/indexingSlice";
|
||||
|
|
@ -65,7 +65,6 @@ function useSetup() {
|
|||
if (result.status === "error") {
|
||||
return;
|
||||
}
|
||||
console.log("Config loaded", result.content);
|
||||
await handleConfigUpdate(initial, result.content);
|
||||
},
|
||||
[ideMessenger, handleConfigUpdate],
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import {
|
|||
OnboardingCard,
|
||||
useOnboardingCard,
|
||||
} from "../../components/OnboardingCard";
|
||||
import { PlatformOnboardingCard } from "../../components/OnboardingCard/platform/PlatformOnboardingCard";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import StepContainer from "../../components/StepContainer";
|
||||
import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons";
|
||||
|
|
@ -39,6 +40,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
|
|||
import { useTutorialCard } from "../../hooks/useTutorialCard";
|
||||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUsePlatform } from "../../redux/selectors";
|
||||
import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import { submitEdit } from "../../redux/slices/editModeState";
|
||||
|
|
@ -57,6 +59,7 @@ import {
|
|||
import { RootState } from "../../redux/store";
|
||||
import { cancelStream } from "../../redux/thunks/cancelStream";
|
||||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
||||
import {
|
||||
getFontSize,
|
||||
|
|
@ -70,7 +73,6 @@ import ConfigErrorIndicator from "./ConfigError";
|
|||
import { ToolCallDiv } from "./ToolCallDiv";
|
||||
import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
|
||||
import ToolOutput from "./ToolCallDiv/ToolOutput";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
|
||||
const StopButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -215,6 +217,7 @@ export function Chat() {
|
|||
selectIsSingleRangeEditOrInsertion,
|
||||
);
|
||||
const lastSessionId = useAppSelector((state) => state.session.lastSessionId);
|
||||
const usePlatform = useAppSelector(selectUsePlatform);
|
||||
|
||||
useEffect(() => {
|
||||
// Cmd + Backspace to delete current step
|
||||
|
|
@ -539,7 +542,11 @@ export function Chat() {
|
|||
<>
|
||||
{onboardingCard.show && (
|
||||
<div className="mx-2 mt-10">
|
||||
<OnboardingCard />
|
||||
{usePlatform ? (
|
||||
<PlatformOnboardingCard />
|
||||
) : (
|
||||
<OnboardingCard />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,3 +42,8 @@ export const selectUseActiveFile = createSelector(
|
|||
[(state: RootState) => state.config.config.experimental?.defaultContext],
|
||||
(defaultContext) => defaultContext?.includes("activeFile" as any),
|
||||
);
|
||||
|
||||
export const selectUsePlatform = createSelector(
|
||||
[(state: RootState) => state.config.config.usePlatform],
|
||||
(usePlatform) => usePlatform,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { BrowserSerializedContinueConfig } from "core";
|
||||
import { ConfigResult } from "core/config/load";
|
||||
import { ConfigValidationError } from "core/config/validation";
|
||||
import { DEFAULT_MAX_TOKENS } from "core/llm/constants";
|
||||
|
||||
export type ConfigState = {
|
||||
|
|
@ -27,6 +26,7 @@ const initialState: ConfigState = {
|
|||
contextProviders: [],
|
||||
models: [],
|
||||
tools: [],
|
||||
usePlatform: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -80,6 +80,20 @@ export const configSlice = createSlice({
|
|||
defaultModelTitle: payload.title,
|
||||
};
|
||||
},
|
||||
cycleDefaultModel: (state, { payload }: PayloadAction<"next" | "prev">) => {
|
||||
const currentIndex = state.config.models.findIndex(
|
||||
(model) => model.title === state.defaultModelTitle,
|
||||
);
|
||||
const nextIndex =
|
||||
(currentIndex +
|
||||
(payload === "next" ? 1 : -1) +
|
||||
state.config.models.length) %
|
||||
state.config.models.length;
|
||||
return {
|
||||
...state,
|
||||
defaultModelTitle: state.config.models[nextIndex].title,
|
||||
};
|
||||
},
|
||||
},
|
||||
selectors: {
|
||||
selectDefaultModel: (state) => {
|
||||
|
|
@ -101,6 +115,7 @@ export const configSlice = createSlice({
|
|||
|
||||
export const {
|
||||
setDefaultModel,
|
||||
cycleDefaultModel,
|
||||
updateConfig,
|
||||
setConfigResult,
|
||||
setConfigError,
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@ import {
|
|||
ToolCallDelta,
|
||||
ToolCallState,
|
||||
} from "core";
|
||||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { NEW_SESSION_TITLE } from "core/util/constants";
|
||||
import { incrementalParseJson } from "core/util/incrementalParseJson";
|
||||
import { renderChatMessage } from "core/util/messageContent";
|
||||
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { RootState } from "../store";
|
||||
import { streamResponseThunk } from "../thunks/streamResponse";
|
||||
import { findCurrentToolCall } from "../util";
|
||||
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
|
||||
|
||||
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
|
||||
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
|
||||
|
|
@ -44,6 +45,7 @@ type SessionState = {
|
|||
title: string;
|
||||
id: string;
|
||||
selectedProfileId: string;
|
||||
availableProfiles: ProfileDescription[];
|
||||
streamAborter: AbortController;
|
||||
codeToEdit: CodeToEdit[];
|
||||
curCheckpointIndex: number;
|
||||
|
|
@ -83,6 +85,13 @@ const initialState: SessionState = {
|
|||
title: NEW_SESSION_TITLE,
|
||||
id: uuidv4(),
|
||||
selectedProfileId: "local",
|
||||
availableProfiles: [
|
||||
{
|
||||
id: "local",
|
||||
title: "Local",
|
||||
errors: undefined,
|
||||
},
|
||||
],
|
||||
curCheckpointIndex: 0,
|
||||
streamAborter: new AbortController(),
|
||||
codeToEdit: [],
|
||||
|
|
@ -504,8 +513,19 @@ export const sessionSlice = createSlice({
|
|||
selectedProfileId: payload,
|
||||
};
|
||||
},
|
||||
setCurCheckpointIndex: (state, { payload }: PayloadAction<number>) => {
|
||||
state.curCheckpointIndex = payload;
|
||||
setAvailableProfiles: (
|
||||
state,
|
||||
{ payload }: PayloadAction<ProfileDescription[]>,
|
||||
) => {
|
||||
return {
|
||||
...state,
|
||||
availableProfiles: payload,
|
||||
selectedProfileId: payload.find(
|
||||
(profile) => profile.id === state.selectedProfileId,
|
||||
)
|
||||
? state.selectedProfileId
|
||||
: payload[0]?.id,
|
||||
};
|
||||
},
|
||||
updateCurCheckpoint: (
|
||||
state,
|
||||
|
|
@ -516,6 +536,9 @@ export const sessionSlice = createSlice({
|
|||
checkpoint[payload.filepath] = payload.content;
|
||||
}
|
||||
},
|
||||
setCurCheckpointIndex: (state, { payload }: PayloadAction<number>) => {
|
||||
state.curCheckpointIndex = payload;
|
||||
},
|
||||
updateApplyState: (state, { payload }: PayloadAction<ApplyState>) => {
|
||||
const applyState = state.codeBlockApplyStates.states.find(
|
||||
(state) => state.streamId === payload.streamId,
|
||||
|
|
@ -618,6 +641,9 @@ export const sessionSlice = createSlice({
|
|||
selectHasCodeToEdit: (state) => {
|
||||
return state.codeToEdit.length > 0;
|
||||
},
|
||||
selectAvailableProfiles: (state) => {
|
||||
return state.availableProfiles;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
addPassthroughCases(builder, [streamResponseThunk]);
|
||||
|
|
@ -681,6 +707,7 @@ export const {
|
|||
removeCodeToEdit,
|
||||
setCalling,
|
||||
cancelToolCall,
|
||||
setAvailableProfiles,
|
||||
acceptToolCall,
|
||||
setToolGenerated,
|
||||
setToolCallOutput,
|
||||
|
|
@ -696,6 +723,7 @@ export const {
|
|||
selectIsInEditMode,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
selectHasCodeToEdit,
|
||||
selectAvailableProfiles,
|
||||
} = sessionSlice.selectors;
|
||||
|
||||
export default sessionSlice.reducer;
|
||||
|
|
|
|||
21
gui/src/redux/thunks/cycleProfile.ts
Normal file
21
gui/src/redux/thunks/cycleProfile.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { setProfileId } from "./setProfileId";
|
||||
|
||||
export const cycleProfile = createAsyncThunk<void, undefined, ThunkApiType>(
|
||||
"profile/cycle",
|
||||
async (_, { dispatch, getState, extra }) => {
|
||||
const state = getState();
|
||||
const profileIds = state.session.availableProfiles.map(
|
||||
(profile) => profile.id,
|
||||
);
|
||||
const curIndex = profileIds.indexOf(state.session.selectedProfileId);
|
||||
const nextIndex = (curIndex + 1) % profileIds.length;
|
||||
const nextId = profileIds[nextIndex];
|
||||
dispatch(setProfileId(nextId));
|
||||
|
||||
extra.ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: nextId,
|
||||
});
|
||||
},
|
||||
);
|
||||
13
gui/src/redux/thunks/setProfileId.ts
Normal file
13
gui/src/redux/thunks/setProfileId.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { setSelectedProfileId } from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
||||
export const setProfileId = createAsyncThunk<void, string, ThunkApiType>(
|
||||
"profile/setId",
|
||||
async (id, { dispatch, extra }) => {
|
||||
dispatch(setSelectedProfileId(id));
|
||||
extra.ideMessenger.post("didChangeSelectedProfile", {
|
||||
id,
|
||||
});
|
||||
},
|
||||
);
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue