merge main
This commit is contained in:
commit
f4233aebdd
115 changed files with 2729 additions and 2241 deletions
79
.continue/prompts/update-llm-info.prompt
Normal file
79
.continue/prompts/update-llm-info.prompt
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
name: Update LLM Info
|
||||
description: Updates Gemini blocks with latest information
|
||||
version: 2
|
||||
---
|
||||
I need you to update this repo with the latest information about large language models from certain providers.
|
||||
The information is stored in the `packages/llm-info` directory, which operates as its own npm package.
|
||||
Information is stored in a simple JSON format, with one file of models per "provider" (e.g. gemini, ollama, openai, etc).
|
||||
For example, Gemini model information is stored in `packages/llm-info/src/providers/gemini.ts`.
|
||||
|
||||
To make these updates for a given provider, perform the following steps one at a time:
|
||||
|
||||
1. VIEW CURRENT INFORMATION
|
||||
|
||||
To view the current llm info, read the file (e.g. `packages/llm-info/src/providers/gemini.ts`) using the read_file tool.
|
||||
If you do not see a tool for reading files, let me know.
|
||||
|
||||
For reference, here is the LLMInfo interface used to store the information:
|
||||
|
||||
```typescript
|
||||
export interface LlmInfo {
|
||||
model: string; // the model name used to distinguish the model at the API layer, e.g. "gemini-2.5-pro-preview-05-06"
|
||||
displayName?: string; // A fitting display name, e.g. "Gemini 2.5 Pro Preview"
|
||||
description?: string; // A short description of the model, as similar as possible to descriptions found on the provider's website
|
||||
contextLength?: number; // The size of the context window in tokens, often called "max input tokens" or "context length"
|
||||
maxCompletionTokens?: number; // The maximum number of tokens the model can output
|
||||
regex?: RegExp; // A regex expression to uniquely match the model name if it had some slight modifications/upgrades, e.g. /gemini-2\.5-pro-preview/i
|
||||
mediaTypes?: MediaType[]; // Input/output types supported by the model, e.g. [MediaType.Text, MediaType.Image]
|
||||
}
|
||||
|
||||
export enum MediaType {
|
||||
Text = "text",
|
||||
Image = "image",
|
||||
Audio = "audio",
|
||||
Video = "video",
|
||||
}
|
||||
|
||||
export const AllMediaTypes = [
|
||||
MediaType.Text,
|
||||
MediaType.Image,
|
||||
MediaType.Audio,
|
||||
MediaType.Video,
|
||||
];
|
||||
```
|
||||
|
||||
2. EXTRACT NEW INFORMATION
|
||||
|
||||
New information will be pulled from the internet.
|
||||
If you do not see a web search tool, let me know.
|
||||
|
||||
Retrieve the following sites per these providers, and consider these notes on how to extract the information:
|
||||
- "gemini": https://ai.google.dev/gemini-api/docs/models - maxCompletionTokens is called "Output token limit", contextLength is called "Input token limit"
|
||||
// TODO: add info for openai, ollama, etc
|
||||
|
||||
For any other providers, search the web for "latest [provider] models" and find the most relevant model information using your best judgement.
|
||||
Generally, ignore models that do not support text output. These models will be used in a coding assistant client that only supports text/image input and text/output, so extraneous capabilities can be ignored.
|
||||
Sometimes, "Experimental", "Preview", or similar versions of models are available. The latest-date version of each should have its own information maintained.
|
||||
|
||||
3. UPDATE THE INFORMATION
|
||||
|
||||
Use the edit file tool to submit updates to the relevant provider file (e.g. `packages/llm-info/src/providers/gemini.ts`).
|
||||
Let me know if you do not see a tool for editing files.
|
||||
|
||||
Generally, avoid making changes to existing information, as it is probably up to date.
|
||||
Primarily, focus on adding new models or adding missing information to existing models.
|
||||
NEVER delete any existing models, but let me know if you think one should be removed.
|
||||
Stop to ask me if you are unsure about any changes, and let me know if there are updates that seem nuanced, complex, or extremely notable.
|
||||
Provide a summary of changes after the fact.
|
||||
|
||||
4. ASK IF I WANT TO PUBLISH TO NPM
|
||||
After you are done updating everything, remind me that I need to publish the changes to npm.
|
||||
|
||||
// TODO too sensitive for now
|
||||
// If yes, update `packages/llm-info/package.json` with the new version number and then
|
||||
// - use the terminal tool to commit the changes
|
||||
// - use the terminal tool to publish changes to npm
|
||||
// If you do not see a tool for running terminal commands, let me know.
|
||||
|
||||
// User input
|
||||
Please update LLM Info for the following providers. If "all", update all providers mentioned above:
|
||||
10
.continue/rules/gui-link-opening.md
Normal file
10
.continue/rules/gui-link-opening.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
globs: gui/**/*
|
||||
description: Ensures consistent URL opening behavior in GUI components using the
|
||||
IDE messenger pattern
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# GUI Link Opening
|
||||
|
||||
When adding functionality to open external links in GUI components, use `ideMessenger.post("openUrl", url)` where `ideMessenger` is obtained from `useContext(IdeMessengerContext)`
|
||||
2
.github/workflows/pr_checks.yaml
vendored
2
.github/workflows/pr_checks.yaml
vendored
|
|
@ -435,6 +435,8 @@ jobs:
|
|||
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
|
||||
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
|
||||
AZURE_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}
|
||||
AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }}
|
||||
AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }}
|
||||
|
||||
package-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -146,6 +146,7 @@ Icon?
|
|||
|
||||
*.notes.md
|
||||
notes.md
|
||||
*.notes.md
|
||||
|
||||
manual-testing-sandbox/.idea/**
|
||||
manual-testing-sandbox/.continue/**
|
||||
|
|
|
|||
|
|
@ -114,11 +114,12 @@ export class CompletionProvider {
|
|||
this.loggingService.markDisplayed(completionId, outcome);
|
||||
}
|
||||
|
||||
private async _getAutocompleteOptions() {
|
||||
private async _getAutocompleteOptions(llm: ILLM) {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
const options = {
|
||||
...DEFAULT_AUTOCOMPLETE_OPTS,
|
||||
...config?.tabAutocompleteOptions,
|
||||
...llm.autocompleteOptions,
|
||||
};
|
||||
return options;
|
||||
}
|
||||
|
|
@ -136,18 +137,19 @@ export class CompletionProvider {
|
|||
token = controller.signal;
|
||||
}
|
||||
const startTime = Date.now();
|
||||
const options = await this._getAutocompleteOptions();
|
||||
|
||||
// Debounce
|
||||
if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const llm = await this._prepareLlm();
|
||||
if (!llm) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const options = await this._getAutocompleteOptions(llm);
|
||||
|
||||
// Debounce
|
||||
if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (llm.promptTemplates?.autocomplete) {
|
||||
options.template = llm.promptTemplates.autocomplete as string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import ignore from "ignore";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import {
|
||||
getGlobalContinueIgArray,
|
||||
getWorkspaceContinueIgArray,
|
||||
} from "../../indexing/ignore";
|
||||
import { getConfigJsonPath } from "../../util/paths";
|
||||
import { findUriInDirs } from "../../util/uri";
|
||||
import { HelperVars } from "../util/HelperVars";
|
||||
|
|
@ -50,7 +54,12 @@ export async function shouldPrefilter(
|
|||
}
|
||||
|
||||
// Check whether autocomplete is disabled for this file
|
||||
const disableInFiles = [...(helper.options.disableInFiles ?? []), "*.prompt"];
|
||||
const disableInFiles = [
|
||||
...(helper.options.disableInFiles ?? []),
|
||||
"*.prompt",
|
||||
...getGlobalContinueIgArray(),
|
||||
...(await getWorkspaceContinueIgArray(ide)),
|
||||
];
|
||||
if (await isDisabledForFile(helper.filepath, disableInFiles, ide)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,6 +640,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
|
|||
capabilities: llm.capabilities,
|
||||
roles: llm.roles,
|
||||
configurationStatus: llm.getConfigurationStatus(),
|
||||
apiKeyLocation: llm.apiKeyLocation,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,21 @@ export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
|||
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
|
||||
|
||||
const ANTHROPIC_MODEL_CONFIG = {
|
||||
slugs: ["anthropic/claude-3-7-sonnet", "anthropic/claude-4-sonnet"],
|
||||
apiKeyInputName: "ANTHROPIC_API_KEY",
|
||||
};
|
||||
const OPENAI_MODEL_CONFIG = {
|
||||
slugs: ["openai/gpt-4.1", "openai/o3", "openai/gpt-4.1-mini"],
|
||||
apiKeyInputName: "OPENAI_API_KEY",
|
||||
};
|
||||
|
||||
// TODO: These need updating on the hub
|
||||
const GEMINI_MODEL_CONFIG = {
|
||||
slugs: ["google/gemini-2.5-pro", "google/gemini-2.0-flash"],
|
||||
apiKeyInputName: "GEMINI_API_KEY",
|
||||
};
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
* whenever a user doesn't have a config.json
|
||||
|
|
@ -49,3 +64,45 @@ export function setupLocalConfig(config: ConfigYaml): ConfigYaml {
|
|||
export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml {
|
||||
return config;
|
||||
}
|
||||
|
||||
export function setupProviderConfig(
|
||||
config: ConfigYaml,
|
||||
provider: string,
|
||||
apiKey: string,
|
||||
): ConfigYaml {
|
||||
let newModels;
|
||||
|
||||
switch (provider) {
|
||||
case "openai":
|
||||
newModels = OPENAI_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[OPENAI_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
break;
|
||||
case "anthropic":
|
||||
newModels = ANTHROPIC_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[ANTHROPIC_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
break;
|
||||
case "gemini":
|
||||
newModels = GEMINI_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[GEMINI_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown provider: ${provider}`);
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
models: [...(config.models ?? []), ...newModels],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
|
|||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { getConfigDependentToolDefinitions } from "../../tools";
|
||||
import { encodeMCPToolUri } from "../../tools/callTool";
|
||||
import { getMCPToolName } from "../../tools/mcpToolName";
|
||||
import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
|
||||
import { localPathOrUriToPath } from "../../util/pathToUri";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
|
|
@ -156,7 +157,7 @@ export default async function doLoadConfig(options: {
|
|||
displayTitle: server.name + " " + tool.name,
|
||||
function: {
|
||||
description: tool.description,
|
||||
name: tool.name,
|
||||
name: getMCPToolName(server, tool),
|
||||
parameters: tool.inputSchema,
|
||||
},
|
||||
faviconUrl: server.faviconUrl,
|
||||
|
|
@ -164,6 +165,7 @@ export default async function doLoadConfig(options: {
|
|||
type: "function" as const,
|
||||
uri: encodeMCPToolUri(server.id, tool.name),
|
||||
group: server.name,
|
||||
originalFunctionName: tool.name,
|
||||
}));
|
||||
newConfig.tools.push(...serverTools);
|
||||
|
||||
|
|
|
|||
|
|
@ -117,10 +117,15 @@ async function loadConfigYaml(options: {
|
|||
// `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`,
|
||||
// );
|
||||
|
||||
let config =
|
||||
overrideConfigYaml ??
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
let config: AssistantUnrolled | undefined;
|
||||
|
||||
if (overrideConfigYaml) {
|
||||
config = overrideConfigYaml;
|
||||
} else {
|
||||
// This is how we allow use of blocks locally
|
||||
(await unrollAssistant(
|
||||
const unrollResult = await unrollAssistant(
|
||||
packageIdentifier,
|
||||
new RegistryClient({
|
||||
accessToken: await controlPlaneClient.getAccessToken(),
|
||||
|
|
@ -139,17 +144,23 @@ async function loadConfigYaml(options: {
|
|||
),
|
||||
renderSecrets: true,
|
||||
injectBlocks: allLocalBlocks,
|
||||
asConfigResult: true,
|
||||
},
|
||||
));
|
||||
);
|
||||
config = unrollResult.config;
|
||||
if (unrollResult.errors) {
|
||||
errors.push(...unrollResult.errors);
|
||||
}
|
||||
}
|
||||
|
||||
const errors = isAssistantUnrolledNonNullable(config)
|
||||
? validateConfigYaml(config)
|
||||
: [
|
||||
{
|
||||
if (config) {
|
||||
isAssistantUnrolledNonNullable(config)
|
||||
? errors.push(...validateConfigYaml(config))
|
||||
: errors.push({
|
||||
fatal: true,
|
||||
message: "Assistant includes blocks that don't exist",
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
if (errors?.some((error) => error.fatal)) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ async function modelConfigToBaseLLM({
|
|||
tools: model.capabilities?.includes("tool_use"),
|
||||
uploadImage: model.capabilities?.includes("image_input"),
|
||||
},
|
||||
autocompleteOptions: model.autocompleteOptions,
|
||||
};
|
||||
|
||||
// Model capabilities - need to be undefined if not found
|
||||
|
|
|
|||
33
core/core.ts
33
core/core.ts
|
|
@ -34,6 +34,7 @@ import { getSymbolsForManyFiles } from "./util/treeSitter";
|
|||
import { TTS } from "./util/tts";
|
||||
|
||||
import {
|
||||
CompleteOnboardingPayload,
|
||||
ContextItemWithId,
|
||||
IdeSettings,
|
||||
ModelDescription,
|
||||
|
|
@ -47,8 +48,8 @@ import { ConfigYaml } from "@continuedev/config-yaml";
|
|||
import { getDiffFn, GitDiffCache } from "./autocomplete/snippets/gitDiffCache";
|
||||
import { isLocalAssistantFile } from "./config/loadLocalAssistants";
|
||||
import {
|
||||
setupBestConfig,
|
||||
setupLocalConfig,
|
||||
setupProviderConfig,
|
||||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { createNewWorkspaceBlockFile } from "./config/workspace/workspaceBlocks";
|
||||
|
|
@ -60,6 +61,7 @@ import { walkDirCache } from "./indexing/walkDir";
|
|||
import { LLMLogger } from "./llm/logger";
|
||||
import { llmStreamChat } from "./llm/streamChat";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import { OnboardingModes } from "./protocol/core";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
import { StreamAbortManager } from "./util/abortManager";
|
||||
|
||||
|
|
@ -184,7 +186,7 @@ export class Core {
|
|||
return;
|
||||
}
|
||||
|
||||
await this.codeBaseIndexer.refreshCodebaseIndex(dirs);
|
||||
void this.codeBaseIndexer.refreshCodebaseIndex(dirs);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -509,7 +511,7 @@ export class Core {
|
|||
abortManager.clear();
|
||||
});
|
||||
|
||||
on("completeOnboarding", this.handleCompleteOnboarding.bind(this));
|
||||
on("onboarding/complete", this.handleCompleteOnboarding.bind(this));
|
||||
|
||||
on("addAutocompleteModel", this.handleAddAutocompleteModel.bind(this));
|
||||
|
||||
|
|
@ -876,26 +878,25 @@ export class Core {
|
|||
}
|
||||
}
|
||||
|
||||
private async handleCompleteOnboarding(msg: Message<{ mode: string }>) {
|
||||
const mode = msg.data.mode;
|
||||
|
||||
if (mode === "Custom") {
|
||||
return;
|
||||
}
|
||||
private async handleCompleteOnboarding(
|
||||
msg: Message<CompleteOnboardingPayload>,
|
||||
) {
|
||||
const { mode, provider, apiKey } = msg.data;
|
||||
|
||||
let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml;
|
||||
|
||||
switch (mode) {
|
||||
case "Local":
|
||||
case OnboardingModes.LOCAL:
|
||||
editConfigYamlCallback = setupLocalConfig;
|
||||
break;
|
||||
|
||||
case "Quickstart":
|
||||
editConfigYamlCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "Best":
|
||||
editConfigYamlCallback = setupBestConfig;
|
||||
case OnboardingModes.API_KEY:
|
||||
if (provider && apiKey) {
|
||||
editConfigYamlCallback = (config: ConfigYaml) =>
|
||||
setupProviderConfig(config, provider, apiKey);
|
||||
} else {
|
||||
editConfigYamlCallback = setupQuickstartConfig;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
0
core/core_temp.ts
Normal file
0
core/core_temp.ts
Normal file
11
core/index.d.ts
vendored
11
core/index.d.ts
vendored
|
|
@ -94,6 +94,8 @@ export interface ILLM
|
|||
get providerName(): string;
|
||||
get underlyingProviderName(): string;
|
||||
|
||||
autocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
|
||||
complete(
|
||||
prompt: string,
|
||||
signal: AbortSignal,
|
||||
|
|
@ -563,6 +565,7 @@ export interface LLMOptions {
|
|||
uniqueId?: string;
|
||||
baseAgentSystemMessage?: string;
|
||||
baseChatSystemMessage?: string;
|
||||
autocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
contextLength?: number;
|
||||
maxStopWords?: number;
|
||||
completionOptions?: CompletionOptions;
|
||||
|
|
@ -989,6 +992,7 @@ export interface Tool {
|
|||
uri?: string;
|
||||
faviconUrl?: string;
|
||||
group: string;
|
||||
originalFunctionName?: string;
|
||||
}
|
||||
|
||||
interface ToolChoice {
|
||||
|
|
@ -1090,6 +1094,7 @@ export interface RerankerDescription {
|
|||
params?: { [key: string]: any };
|
||||
}
|
||||
|
||||
// TODO: We should consider renaming this to AutocompleteOptions.
|
||||
export interface TabAutocompleteOptions {
|
||||
disable: boolean;
|
||||
maxPromptTokens: number;
|
||||
|
|
@ -1573,3 +1578,9 @@ export interface RuleWithSource {
|
|||
ruleFile?: string;
|
||||
alwaysApply?: boolean;
|
||||
}
|
||||
|
||||
export interface CompleteOnboardingPayload {
|
||||
mode: OnboardingModes;
|
||||
provider?: string;
|
||||
apiKey?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import fs from "fs";
|
|||
|
||||
import ignore from "ignore";
|
||||
|
||||
import { IDE } from "..";
|
||||
import { getGlobalContinueIgnorePath } from "../util/paths";
|
||||
|
||||
export const DEFAULT_IGNORE_FILETYPES = [
|
||||
|
|
@ -129,3 +130,20 @@ export const getGlobalContinueIgArray = () => {
|
|||
const contents = fs.readFileSync(getGlobalContinueIgnorePath(), "utf8");
|
||||
return gitIgArrayFromFile(contents);
|
||||
};
|
||||
|
||||
export const getWorkspaceContinueIgArray = async (ide: IDE) => {
|
||||
const dirs = await ide.getWorkspaceDirs();
|
||||
return await dirs.reduce(
|
||||
async (accPromise, dir) => {
|
||||
const acc = await accPromise;
|
||||
try {
|
||||
const contents = await ide.readFile(`${dir}/.continueignore`);
|
||||
return [...acc, ...gitIgArrayFromFile(contents)];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return acc;
|
||||
}
|
||||
},
|
||||
Promise.resolve([] as string[]),
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
PromptLog,
|
||||
PromptTemplate,
|
||||
RequestOptions,
|
||||
TabAutocompleteOptions,
|
||||
TemplateType,
|
||||
} from "../index.js";
|
||||
import mergeJson from "../util/merge.js";
|
||||
|
|
@ -96,6 +97,8 @@ export abstract class BaseLLM implements ILLM {
|
|||
return this.providerName;
|
||||
}
|
||||
|
||||
autocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
|
||||
supportsFim(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -275,6 +278,8 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.maxEmbeddingChunkSize =
|
||||
options.maxEmbeddingChunkSize ?? DEFAULT_MAX_CHUNK_SIZE;
|
||||
this.embeddingId = `${this.constructor.name}::${this.model}::${this.maxEmbeddingChunkSize}`;
|
||||
|
||||
this.autocompleteOptions = options.autocompleteOptions;
|
||||
}
|
||||
|
||||
getConfigurationStatus() {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,13 @@ class ContinueProxy extends OpenAI {
|
|||
}
|
||||
|
||||
supportsCompletions(): boolean {
|
||||
return true;
|
||||
// This was a hotfix and contains duplicate logic from class-specific completion support methods
|
||||
if (this.underlyingProviderName === "vllm") {
|
||||
return true;
|
||||
}
|
||||
// other providers that don't support completions include groq, mistral, nvidia, deepseek, etc.
|
||||
// For now disabling all except vllm
|
||||
return false;
|
||||
}
|
||||
|
||||
supportsFim(): boolean {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
* Extracts file paths from markdown code blocks
|
||||
*/
|
||||
export function extractPathsFromCodeBlocks(content: string): string[] {
|
||||
console.log("CONTENT", content);
|
||||
|
||||
const paths: string[] = [];
|
||||
|
||||
// Match code block opening patterns:
|
||||
|
|
|
|||
66
core/package-lock.json
generated
66
core/package-lock.json
generated
|
|
@ -14,9 +14,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.25",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
@ -949,22 +949,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@azure-rest/core-client": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure-rest/core-client/-/core-client-1.4.0.tgz",
|
||||
"integrity": "sha512-ozTDPBVUDR5eOnMIwhggbnVmOrka4fXCs8n8mvUo4WLLc38kki6bAOByDoVZZPz/pZy2jMt2kwfpvy/UjALj6w==",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^2.0.0",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-rest-pipeline": "^1.5.0",
|
||||
"@azure/core-tracing": "^1.0.1",
|
||||
"@azure/core-util": "^1.0.0",
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/abort-controller": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz",
|
||||
|
|
@ -1062,17 +1046,6 @@
|
|||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-sse": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-sse/-/core-sse-2.1.3.tgz",
|
||||
"integrity": "sha512-KSSdIKy8kvWCpYr8Hzpu22j3wcXsVTYE0IlgmI1T/aHvBDsLgV91y90UTfVWnuiuApRLCCVC4gS09ApBGOmYQA==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-tracing": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.2.0.tgz",
|
||||
|
|
@ -1211,24 +1184,6 @@
|
|||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/openai": {
|
||||
"version": "1.0.0-beta.13",
|
||||
"resolved": "https://registry.npmjs.org/@azure/openai/-/openai-1.0.0-beta.13.tgz",
|
||||
"integrity": "sha512-oHE5ScnPTXALmyEBgqokZlYVT7F76EfrKjMWF+YcFJdUxk9Adhvht2iL5v+QpmlAIMdkih1q8DkTs/tApDjBpw==",
|
||||
"deprecated": "The Azure OpenAI client library for JavaScript beta has been retired. Please migrate to the stable OpenAI SDK for JavaScript using the migration guide: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/openai/openai/MIGRATION.md.",
|
||||
"dependencies": {
|
||||
"@azure-rest/core-client": "^1.1.7",
|
||||
"@azure/core-auth": "^1.4.0",
|
||||
"@azure/core-rest-pipeline": "^1.13.0",
|
||||
"@azure/core-sse": "^2.0.0",
|
||||
"@azure/core-util": "^1.4.0",
|
||||
"@azure/logger": "^1.0.3",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.26.2",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",
|
||||
|
|
@ -2928,10 +2883,9 @@
|
|||
"link": true
|
||||
},
|
||||
"node_modules/@continuedev/fetch": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.10.tgz",
|
||||
"integrity": "sha512-RBUXtm/VDz+9Itgw+CxrHXwVXoHCAedGzPOgA7gS5HZ9lObaeCJgEfzmfbln1ocFsfqSFmn5X5wSE7DHgfxpVA==",
|
||||
"license": "Apache-2.0",
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.13.tgz",
|
||||
"integrity": "sha512-7vwsefFBozsutv355zD7mEhFfl6UT4KXRH1QXRzjdbCaYneiRdFLe6UAwV2wGnH71Lj76gOLnTlcGoTV357OZg==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"follow-redirects": "^1.15.6",
|
||||
|
|
@ -2946,15 +2900,13 @@
|
|||
"integrity": "sha512-/htL7p4li3zQSwn9bXkI23WRpZNklWTPzRSSG3Fd5gvYW8cizjhlf7OzeDdKxBfi1S0lpqMm0VwHlx3KjMKLpw=="
|
||||
},
|
||||
"node_modules/@continuedev/openai-adapters": {
|
||||
"version": "1.0.25",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/openai-adapters/-/openai-adapters-1.0.25.tgz",
|
||||
"integrity": "sha512-YG7bcAlUk3BnqIOZw+ClmxmZU6G3OaaZqbhfqgiCnJem5i7oDy0pkAVHjig4iRTQkpvDokKmBXCH9wmQNRbWNw==",
|
||||
"license": "Apache-2.0",
|
||||
"version": "1.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/openai-adapters/-/openai-adapters-1.0.32.tgz",
|
||||
"integrity": "sha512-teNzbpcsa7Y0eBk+dxlLDo0m43sWI5txTYMIk6ezyS0cZAKFJODDB0Gkp3aEHXbD8mDE7H5dDSlM23ohKCirAA==",
|
||||
"dependencies": {
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"@continuedev/config-yaml": "^1.0.51",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.11",
|
||||
"dotenv": "^16.5.0",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.25",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { GlobalContextModelSelections } from "../util/GlobalContext";
|
|||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
CompleteOnboardingPayload,
|
||||
ContextItem,
|
||||
ContextItemWithId,
|
||||
ContextSubmenuItem,
|
||||
|
|
@ -36,7 +37,10 @@ import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager";
|
|||
import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes";
|
||||
import { FreeTrialStatus } from "../control-plane/client";
|
||||
|
||||
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
|
||||
export enum OnboardingModes {
|
||||
API_KEY = "API Key",
|
||||
LOCAL = "Local",
|
||||
}
|
||||
|
||||
export interface ListHistoryOptions {
|
||||
offset?: number;
|
||||
|
|
@ -169,12 +173,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
void,
|
||||
];
|
||||
"index/indexingProgressBarInitialized": [undefined, void];
|
||||
completeOnboarding: [
|
||||
{
|
||||
mode: OnboardingModes;
|
||||
},
|
||||
void,
|
||||
];
|
||||
"onboarding/complete": [CompleteOnboardingPayload, void];
|
||||
|
||||
// File changes
|
||||
"files/changed": [{ uris?: string[] }, void];
|
||||
|
|
@ -198,7 +197,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
{ contextItems: ContextItem[]; errorMessage?: string },
|
||||
];
|
||||
"clipboardCache/add": [{ content: string }, void];
|
||||
"controlPlane/openUrl": [{ path: string; orgSlug: string | undefined }, void];
|
||||
"controlPlane/openUrl": [{ path: string; orgSlug?: string }, void];
|
||||
"controlPlane/getFreeTrialStatus": [undefined, FreeTrialStatus | null];
|
||||
isItemTooBig: [{ item: ContextItemWithId }, boolean];
|
||||
didChangeControlPlaneSessionInfo: [
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"docs/initStatuses",
|
||||
"docs/getDetails",
|
||||
//
|
||||
"completeOnboarding",
|
||||
"onboarding/complete",
|
||||
"addAutocompleteModel",
|
||||
"didChangeSelectedProfile",
|
||||
"didChangeSelectedOrg",
|
||||
|
|
@ -64,6 +64,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"isItemTooBig",
|
||||
"process/markAsBackgrounded",
|
||||
"process/isBackgrounded",
|
||||
"controlPlane/getFreeTrialStatus",
|
||||
];
|
||||
|
||||
// Message types to pass through from core to webview
|
||||
|
|
|
|||
|
|
@ -10,13 +10,25 @@ import {
|
|||
|
||||
const asyncExec = util.promisify(childProcess.exec);
|
||||
|
||||
const ENABLED_FOR_REMOTES = [
|
||||
"",
|
||||
"local",
|
||||
"wsl",
|
||||
"dev-container",
|
||||
"devcontainer",
|
||||
"ssh-remote",
|
||||
"attached-container",
|
||||
"codespaces",
|
||||
"tunnel",
|
||||
];
|
||||
|
||||
export const runTerminalCommandImpl: ToolImpl = async (args, extras) => {
|
||||
// Default to waiting for completion if not specified
|
||||
const waitForCompletion = args.waitForCompletion !== false;
|
||||
const ideInfo = await extras.ide.getIdeInfo();
|
||||
const toolCallId = extras.toolCallId || "";
|
||||
|
||||
if (ideInfo.remoteName === "local" || ideInfo.remoteName === "") {
|
||||
if (ENABLED_FOR_REMOTES.includes(ideInfo.remoteName)) {
|
||||
// For streaming output
|
||||
if (extras.onPartialOutput) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
9
core/tools/mcpToolName.ts
Normal file
9
core/tools/mcpToolName.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { MCPServerStatus, MCPTool } from "..";
|
||||
|
||||
export function getMCPToolName(server: MCPServerStatus, tool: MCPTool) {
|
||||
const serverPrefix = server.name.split(" ").join("_").toLowerCase();
|
||||
if (tool.name.startsWith(serverPrefix)) {
|
||||
return tool.name;
|
||||
}
|
||||
return `${serverPrefix}_${tool.name}`;
|
||||
}
|
||||
57
core/tools/mcpToolName.vitest.ts
Normal file
57
core/tools/mcpToolName.vitest.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { expect, test } from "vitest";
|
||||
import { MCPServerStatus, MCPTool } from "..";
|
||||
import { getMCPToolName } from "./mcpToolName";
|
||||
|
||||
const createMcpServer = (name: string): MCPServerStatus => ({
|
||||
name,
|
||||
errors: [],
|
||||
prompts: [],
|
||||
tools: [],
|
||||
resources: [],
|
||||
resourceTemplates: [],
|
||||
status: "connected",
|
||||
id: "",
|
||||
transport: {
|
||||
type: "sse",
|
||||
url: "",
|
||||
},
|
||||
});
|
||||
|
||||
const createMCPTool = (name: string): MCPTool => ({
|
||||
name,
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
},
|
||||
});
|
||||
|
||||
test("getMCPToolName - adds server prefix to tool name when not present", () => {
|
||||
const server = createMcpServer("Github");
|
||||
const tool = createMCPTool("create_pull_request");
|
||||
|
||||
const result = getMCPToolName(server, tool);
|
||||
expect(result).toBe("github_create_pull_request");
|
||||
});
|
||||
|
||||
test("getMCPToolName - preserves tool name when it already starts with server prefix", () => {
|
||||
const server = createMcpServer("Github");
|
||||
const tool = createMCPTool("github_create_pull_request");
|
||||
|
||||
const result = getMCPToolName(server, tool);
|
||||
expect(result).toBe("github_create_pull_request");
|
||||
});
|
||||
|
||||
test("getMCPToolName - handles server names with spaces", () => {
|
||||
const server = createMcpServer("Azure DevOps");
|
||||
const tool = createMCPTool("create_pipeline");
|
||||
|
||||
const result = getMCPToolName(server, tool);
|
||||
expect(result).toBe("azure_devops_create_pipeline");
|
||||
});
|
||||
|
||||
test("getMCPToolName - handles mixed case in server names", () => {
|
||||
const server = createMcpServer("GitLab");
|
||||
const tool = createMCPTool("create_merge_request");
|
||||
|
||||
const result = getMCPToolName(server, tool);
|
||||
expect(result).toBe("gitlab_create_merge_request");
|
||||
});
|
||||
|
|
@ -5,6 +5,12 @@ keywords: [customize, chat]
|
|||
sidebar_position: 5
|
||||
---
|
||||
|
||||
## Add Rules Blocks
|
||||
|
||||
Adding Rules can be done in your assistant locally or in the Hub.
|
||||
|
||||
[Explore Rules on the Hub](https://hub.continue.dev/explore/rules) and see the [Rules deep dive](../customize/deep-dives/rules.md) for more details and tips on creating rules.
|
||||
|
||||
## Add MCP tools
|
||||
|
||||
You can add MCP servers to your assistant to give Agent access to more tools. [Explore MCP Servers on the Hub](https://hub.continue.dev/explore/mcp) and see the [MCP guide](../customize/deep-dives/mcp.mdx) for more details.
|
||||
|
|
|
|||
|
|
@ -6,13 +6,19 @@ keywords: [rules, blocks, standards, practices, guardrails]
|
|||
sidebar_position: 5
|
||||
---
|
||||
|
||||
Rules allow you to provide specific instructions that guide how the AI assistant behaves when working with your code. Instead of the AI making assumptions about your coding standards, architecture patterns, or project-specific requirements, you can explicitly define guidelines that ensure consistent, contextually appropriate responses.
|
||||
|
||||
Think of these as the guardrails for your AI coding assistants:
|
||||
|
||||
- **Enforce company-specific coding standards** and security practices
|
||||
- **Implement quality checks** that match your engineering culture
|
||||
- **Create paved paths** for developers to follow organizational best practices
|
||||
|
||||

|
||||
By implementing rules, you transform the AI from a generic coding assistant into a knowledgeable team member that understands your project's unique requirements and constraints.
|
||||
|
||||
### How Rules Work
|
||||
|
||||
Your assistant detects rule blocks and applies the specified rules while in [Agent](../agent/how-to-use-it), [Chat](../chat/how-to-use-it), and [Edit](../edit/how-to-use-it) modes.
|
||||
|
||||
## Learn More
|
||||
|
||||
|
|
|
|||
|
|
@ -84,5 +84,3 @@ export function modifyConfig(config: Config): Config {
|
|||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
For examples of how to use `config.ts`, see [writing custom slash commands](../tutorials/build-your-own-slash-command.md#custom-slash-commands) or [writing custom context providers](../tutorials/build-your-own-context-provider.mdx).
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ keywords: [rules, .continuerules, system, prompt, message]
|
|||
|
||||
# Rules
|
||||
|
||||
Rules are used to provide instructions to the model for [Chat](../../chat/how-to-use-it.md), [Edit](../../edit/how-to-use-it.md), and [Agent](../../agent/how-to-use-it.md) requests.
|
||||
Rules provide instructions to the model for [Chat](../../chat/how-to-use-it.md), [Edit](../../edit/how-to-use-it.md), and [Agent](../../agent/how-to-use-it.md) requests.
|
||||
|
||||
Rules are not included in most other requests, such as [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx).
|
||||
:::info Rules are not included in [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx).
|
||||
:::
|
||||
|
||||
## How it works
|
||||
|
||||
You can view the current rules by clicking the pen icon above the main toolbar:
|
||||
|
||||
|
|
@ -15,25 +18,52 @@ You can view the current rules by clicking the pen icon above the main toolbar:
|
|||
|
||||
To form the system message, rules are joined with new lines, in the order they appear in the toolbar. This includes the base chat system message ([see below](#chat-system-message)).
|
||||
|
||||
## `rules` blocks
|
||||
## Quick Start
|
||||
|
||||
Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally.
|
||||
Below is a quick example of setting up a new rule file:
|
||||
|
||||
1. Create a folder called `.continue/rules` at the top level of your workspace
|
||||
2. Add a file called `pirates-rule.yaml` to this folder.
|
||||
3. Write the following contents to `pirates-rule.prompt` and save.
|
||||
|
||||
```yaml title=".continue/rules/pirates-rule.yaml"
|
||||
name: Pirate rule
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
rules:
|
||||
- Talk like a pirate.
|
||||
```
|
||||
|
||||
Now test your rules by asking a question about a file in chat.
|
||||
|
||||

|
||||
|
||||
## Creating `rules` blocks
|
||||
|
||||
Rules can be added locally using the "Add Rules" button while viewing the Local Assistant's rules.
|
||||
|
||||

|
||||
|
||||
:::info Automatically create local rule blocks
|
||||
When in Agent mode, you can simply prompt the agent to create a rule for you using the `builtin_create_rule_block` tool if enabled.
|
||||
When in Agent mode, you can prompt the agent to create a rule for you using the `builtin_create_rule_block` tool if enabled.
|
||||
|
||||
For example, you can say "Create a rule for this", and a rule will be created for you in `.continue/rules` based on your conversation.
|
||||
:::
|
||||
|
||||
Rules can also be added to an Assistant on the Continue Hub.
|
||||
|
||||
Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally.
|
||||
|
||||
### Syntax
|
||||
|
||||
Rules blocks can be simple text, written in YAML configuration files, or as Markdown (`.md`) files. They can have the following properties:
|
||||
|
||||
- `name` (**required**): A display name/title for the rule
|
||||
- `rule` (**required**): The text content of the rule
|
||||
- `schema` (**required**): The schema version of the YAML file (e.g., `v1`)
|
||||
- `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`).
|
||||
|
||||
```yaml title="config.yaml"
|
||||
```yaml title=".config.yaml"
|
||||
rules:
|
||||
- Always annotate Python functions with their parameter and return types
|
||||
|
||||
|
|
@ -52,7 +82,47 @@ rules:
|
|||
TONE: concise
|
||||
```
|
||||
|
||||
## Chat System Message
|
||||
### `.continue/rules` folder
|
||||
|
||||
You can create project-specific rules by adding a `.continue/rules` folder to the root of your project and adding new rule files.
|
||||
|
||||
```yaml title=".continue/rules/new-rule.yaml"
|
||||
name: New rule
|
||||
version: 0.0.1
|
||||
schema: v1
|
||||
rules:
|
||||
- Always give concise responses
|
||||
```
|
||||
|
||||
This is also done when selecting "Add Rule" in the Assistant settings. This will create a new folder in `.continue/rules` with a default file named `new-rule.yaml`.
|
||||
|
||||
### Examples
|
||||
|
||||
If you want concise answers:
|
||||
|
||||
```yaml title=".continue/rules/concise-rule.yaml"
|
||||
rules:
|
||||
- name: Always give concise answers
|
||||
rule: |
|
||||
Please provide concise answers. Don't explain obvious concepts.
|
||||
You can assume that I am knowledgable about most programming topics.
|
||||
```
|
||||
|
||||
If you want to ensure certain practices are followed, for example in React:
|
||||
|
||||
```yaml title=".continue/rules/functional-rule.yaml"
|
||||
rules:
|
||||
- name: Always use functional components
|
||||
rule: |
|
||||
Whenever you are writing React code, make sure to
|
||||
- use functional components instead of class components
|
||||
- use hooks for state management
|
||||
- define an interface for your component props
|
||||
- use Tailwind CSS for styling
|
||||
- modularize components into smaller, reusable pieces
|
||||
```
|
||||
|
||||
### Chat System Message
|
||||
|
||||
Continue includes a simple default system message for [Chat](../../chat/how-to-use-it.md) and [Agent](../../agent/how-to-use-it.md) requests, to help the model provide reliable codeblock formats in its output.
|
||||
|
||||
|
|
@ -60,25 +130,12 @@ This can be viewed in the rules section of the toolbar (see above), or visit the
|
|||
|
||||
Advanced users can override this system message for a specific model if needed by using `chatOptions.baseSystemMessage`. See the [`config.yaml` reference](../../reference.md#models).
|
||||
|
||||
## `.continuerules`
|
||||
### `.continuerules`
|
||||
|
||||
:::warning
|
||||
|
||||
`.contninuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead.
|
||||
|
||||
:::
|
||||
|
||||
You can create project-specific rules by adding a `.continuerules` file to the root of your project. This file is raw text and its full contents will be used as rules.
|
||||
|
||||
### Simple Examples
|
||||
|
||||
- If you want concise answers:
|
||||
|
||||
```title=.continuerules
|
||||
Please provide concise answers. Don't explain obvious concepts. You can assume that I am knowledgable about most programming topics.
|
||||
```
|
||||
|
||||
- If you want to ensure certain practices are followed, for example in React:
|
||||
|
||||
```title=.continuerules
|
||||
Whenever you are writing React code, make sure to
|
||||
- use functional components instead of class components
|
||||
- use hooks for state management
|
||||
- define an interface for your component props
|
||||
- use Tailwind CSS for styling
|
||||
- modularize components into smaller, reusable pieces
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
---
|
||||
title: Apply Role
|
||||
description: Apply model role
|
||||
keywords: [apply, model, role]
|
||||
---
|
||||
|
||||
When editing code, Chat and Edit model output often doesn't clearly align with existing code. A model with the `apply` role is used to generate a more precise diff to apply changes to a file.
|
||||
|
||||
## Recommended Apply models
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
---
|
||||
title: Build your own slash command
|
||||
---
|
||||
|
||||
:::info
|
||||
Slash commands can currently only be added using [`config.json`](../../json-reference.md) or `config.ts`. The [`YAML Config Format`](../../reference.md) is the new and preferred format. We recommend looking into [Prompt Files](../deep-dives/prompts.md) to achieve similar functionality.
|
||||
:::
|
||||
|
||||
There are two ways to add custom slash commands:
|
||||
|
||||
1. With natural language prompts - this is simpler and only requires writing a string or string template.
|
||||
2. With a custom function - this gives you full access to the Continue SDK and allows you to write arbitrary Typescript code.
|
||||
|
||||
### "Custom Commands" (Use Natural Language)
|
||||
|
||||
You can add custom slash commands by adding to the `customCommands` property in `config.json`.
|
||||
|
||||
- `name`: the name of the command, which will be invoked with `/name`
|
||||
- `description`: a short description of the command, which will appear in the dropdown
|
||||
- `prompt`: a templated prompt to send to the LLM
|
||||
|
||||
Custom commands are great when you are frequently reusing a prompt. For example, if you've crafted a great prompt and frequently ask the LLM to check for mistakes in your code, you could add a command like this:
|
||||
|
||||
```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."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Templating
|
||||
|
||||
The `prompt` property supports templating with Handlebars syntax. You can use the following variables:
|
||||
|
||||
- `input` (used in the example above): any additional input entered with the slash command. For example, if you type `/test only write one test`, `input` will be `only write one test`. This will also include highlighted code blocks.
|
||||
- File names: You can reference any file by providing an absolute path or a path relative to the current working directory.
|
||||
|
||||
### Custom Slash Commands
|
||||
|
||||
If you want to go a step further than writing custom commands with natural language, you can write a custom function that returns the response. This requires using `config.ts` instead of `config.json`.
|
||||
|
||||
To do this, push a new `SlashCommand` object to the `slashCommands` list. This object contains "name", the name that you will type to invoke the slash command, "description", the description seen in the dropdown menu, and "run". The `run` function is any async generator that should yield strings as you want them to be streamed to the UI. As an argument to the function, you have access to a `ContinueSDK` object with utilities such as access to certain information/actions within the IDE, the current language model, and a few other utilities. For example, here is a slash command that generates a commit message:
|
||||
|
||||
```typescript title="~/.continue/config.ts"
|
||||
export function modifyConfig(config: Config): Config {
|
||||
config.slashCommands?.push({
|
||||
name: "commit",
|
||||
description: "Write a commit message",
|
||||
run: async function* (sdk) {
|
||||
// The getDiff function takes a boolean parameter that indicates whether
|
||||
// to include unstaged changes in the diff or not.
|
||||
const diff = await sdk.ide.getDiff(false); // Pass false to exclude unstaged changes
|
||||
for await (const message of sdk.llm.streamComplete(
|
||||
`${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`,
|
||||
new AbortController().signal,
|
||||
{
|
||||
maxTokens: 20,
|
||||
},
|
||||
)) {
|
||||
yield message;
|
||||
}
|
||||
},
|
||||
});
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
|
@ -385,8 +385,6 @@ Example:
|
|||
}
|
||||
```
|
||||
|
||||
You can also add your own slash command by following [this tutorial](./customize/tutorials/build-your-own-slash-command.md).
|
||||
|
||||
### `customCommands`
|
||||
|
||||
User-defined commands for prompt shortcuts in the sidebar, allowing quick access to common actions.
|
||||
|
|
|
|||
BIN
docs/static/img/add-local-rules.png
vendored
Normal file
BIN
docs/static/img/add-local-rules.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/static/img/pirate-rule-test.png
vendored
Normal file
BIN
docs/static/img/pirate-rule-test.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
|
|
@ -121,7 +121,7 @@ class MessageTypes {
|
|||
"docs/initStatuses",
|
||||
"docs/getDetails",
|
||||
//
|
||||
"completeOnboarding",
|
||||
"onboarding/complete",
|
||||
"addAutocompleteModel",
|
||||
"didChangeSelectedProfile",
|
||||
"didChangeSelectedOrg",
|
||||
|
|
|
|||
|
|
@ -232,7 +232,8 @@
|
|||
"relace",
|
||||
"morph",
|
||||
"ovhcloud",
|
||||
"venice"
|
||||
"venice",
|
||||
"inception"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
|
||||
|
|
@ -281,7 +282,8 @@
|
|||
"### Relace\n Relace provides a fast apply model. To get started, obtain an API key from [here](https://app.relace.ai/settings/api-keys).",
|
||||
"### Morph\nMorph provides a fast apply model. To get started, obtain an API key from [here](https://morphllm.com/dashboard).",
|
||||
"### OVHcloud AI Endpoints is a serverless inference API that provides access to a curated selection of models (e.g., Llama, Mistral, Qwen, Deepseek). It is designed with security and data privacy in mind and is compliant with GDPR. To get started, create an API key on the OVHcloud [AI Endpoints website](https://endpoints.ai.cloud.ovh.net/). For more information, including pricing, visit the OVHcloud [AI Endpoints product page](https://www.ovhcloud.com/en/public-cloud/ai-endpoints/).",
|
||||
"### Venice\n Venice.AI is a privacy-focused generative AI platform, allowing users to interact with open-source LLMs without storing any private user data.\nHosted models support the OpenAI API standard, providing seamless integration for users seeking privacy and flexibility.\nTo get started with the Venice API, either purchase a pro account, stake $VVV for daily inference allotments, or fund your account with USD.\nVisit the [API settings page](https://venice.ai/settings/api) or learn more at the [Venice API documentation](https://venice.ai/api)."
|
||||
"### Venice\n Venice.AI is a privacy-focused generative AI platform, allowing users to interact with open-source LLMs without storing any private user data.\nHosted models support the OpenAI API standard, providing seamless integration for users seeking privacy and flexibility.\nTo get started with the Venice API, either purchase a pro account, stake $VVV for daily inference allotments, or fund your account with USD.\nVisit the [API settings page](https://venice.ai/settings/api) or learn more at the [Venice API documentation](https://venice.ai/api).",
|
||||
"### Inception\n Inception Labs offer a new generation of diffusion-based LLMs.\nVisit the [API settings page](https://platform.inceptionlabs.ai/) or learn more at the [Inception docs](https://platform.inceptionlabs.ai/docs)."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
|||
8
extensions/vscode/package-lock.json
generated
8
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.41",
|
||||
"version": "1.1.45",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.41",
|
||||
"version": "1.1.45",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
@ -107,9 +107,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.25",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.1.42",
|
||||
"version": "1.1.46",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
"homepage": "https://continue.dev",
|
||||
"qna": "https://github.com/continuedev/continue/issues/new/choose",
|
||||
"license": "Apache-2.0",
|
||||
"displayName": "Continue - Codestral, Claude, and more",
|
||||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "The leading open-source AI code assistant",
|
||||
"publisher": "Continue",
|
||||
|
|
@ -41,15 +41,14 @@
|
|||
],
|
||||
"keywords": [
|
||||
"chatgpt",
|
||||
"cline",
|
||||
"roo",
|
||||
"github",
|
||||
"copilot",
|
||||
"claude",
|
||||
"sonnet",
|
||||
"mistral",
|
||||
"codestral",
|
||||
"codegpt",
|
||||
"ai",
|
||||
"llama"
|
||||
"ai"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onUri",
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
get redirectUri() {
|
||||
if (WorkOsAuthProvider.useOnboardingUri) {
|
||||
const url = new URL(controlPlaneEnv.APP_URL);
|
||||
url.pathname = `/onboarding/redirect/${env.uriScheme}`;
|
||||
url.pathname = `/auth/${env.uriScheme}-redirect`;
|
||||
return url.toString();
|
||||
}
|
||||
return this.ideRedirectUri;
|
||||
|
|
@ -393,6 +393,9 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
|
|||
code_challenge: codeChallenge,
|
||||
code_challenge_method: "S256",
|
||||
provider: "authkit",
|
||||
screen_hint: WorkOsAuthProvider.useOnboardingUri
|
||||
? "sign-up"
|
||||
: "sign-in",
|
||||
};
|
||||
|
||||
Object.keys(params).forEach((key) =>
|
||||
|
|
|
|||
41
gui/package-lock.json
generated
41
gui/package-lock.json
generated
|
|
@ -111,9 +111,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.25",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
@ -232,6 +232,16 @@
|
|||
"zod-to-json-schema": "^3.24.5"
|
||||
}
|
||||
},
|
||||
"../packages/llm-info": {
|
||||
"name": "@continuedev/llm-info",
|
||||
"version": "1.0.9",
|
||||
"extraneous": true,
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.15.29",
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@adobe/css-tools": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz",
|
||||
|
|
@ -9800,9 +9810,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/react-hook-form": {
|
||||
"version": "7.53.0",
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.53.0.tgz",
|
||||
"integrity": "sha512-M1n3HhqCww6S2hxLxciEXy2oISPnAzxY7gvwVPrtlczTM/1dDadXgUxDpHMrMTblDOcm/AXtXxHwZ3jpg1mqKQ==",
|
||||
"version": "7.57.0",
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.57.0.tgz",
|
||||
"integrity": "sha512-RbEks3+cbvTP84l/VXGUZ+JMrKOS8ykQCRYdm5aYsxnDquL0vspsyNhGRO7pcH6hsZqWlPOjLye7rJqdtdAmlg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
|
|
@ -12377,9 +12388,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.3.4",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.4.tgz",
|
||||
"integrity": "sha512-BiReIiMS2fyFqbqNT/Qqt4CVITDU9M9vE+DKcVAsB+ZV0wvTKd+3hMbkpxz1b+NmEDMegpVbisKiAZOnvO92Sw==",
|
||||
"version": "6.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
|
||||
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -12879,10 +12890,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vite-node/node_modules/vite": {
|
||||
"version": "5.4.18",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.18.tgz",
|
||||
"integrity": "sha512-1oDcnEp3lVyHCuQ2YFelM4Alm2o91xNoMncRm1U7S+JdYfYOvbiGZ3/CxGttrOu2M/KcGz7cRC2DoNUA6urmMA==",
|
||||
"version": "5.4.19",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
|
||||
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
|
|
@ -13461,10 +13473,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vitest/node_modules/vite": {
|
||||
"version": "5.4.18",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.18.tgz",
|
||||
"integrity": "sha512-1oDcnEp3lVyHCuQ2YFelM4Alm2o91xNoMncRm1U7S+JdYfYOvbiGZ3/CxGttrOu2M/KcGz7cRC2DoNUA6urmMA==",
|
||||
"version": "5.4.19",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.19.tgz",
|
||||
"integrity": "sha512-qO3aKv3HoQC8QKiNSTuUM1l9o/XX3+c+VTgLHbJWHZGeTPVAg2XwazI9UWzoxjIJCGCV2zU60uqMzjeLZuULqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
import { useContext } from "react";
|
||||
import { ButtonSubtext } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
||||
function AddModelButtonSubtext() {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
return (
|
||||
<ButtonSubtext>
|
||||
This will update your{" "}
|
||||
<span
|
||||
className="cursor-pointer underline"
|
||||
onClick={() =>
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: undefined,
|
||||
})
|
||||
}
|
||||
>
|
||||
config file
|
||||
</span>
|
||||
</ButtonSubtext>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddModelButtonSubtext;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useContext, useEffect } from "react";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
|
|
@ -131,7 +132,7 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"openOnboardingCard",
|
||||
async () => {
|
||||
onboardingCard.open("Best");
|
||||
onboardingCard.open(OnboardingModes.API_KEY);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
@ -139,7 +140,7 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"setupLocalConfig",
|
||||
async () => {
|
||||
onboardingCard.open("Local");
|
||||
onboardingCard.open(OnboardingModes.LOCAL);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
@ -179,7 +180,6 @@ const Layout = () => {
|
|||
if (isMetaEquivalentKeyPressed(event) && event.code === "KeyC") {
|
||||
const selection = window.getSelection()?.toString();
|
||||
if (selection) {
|
||||
// Copy to clipboard
|
||||
setTimeout(() => {
|
||||
void navigator.clipboard.writeText(selection);
|
||||
}, 100);
|
||||
|
|
@ -199,7 +199,7 @@ const Layout = () => {
|
|||
isNewUserOnboarding() &&
|
||||
(location.pathname === "/" || location.pathname === "/index.html")
|
||||
) {
|
||||
onboardingCard.open("Quickstart");
|
||||
onboardingCard.open();
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export function ModeSelect() {
|
|||
<div className="relative">
|
||||
<ListboxButton
|
||||
data-testid="mode-select-button"
|
||||
className="xs:px-2 text-description gap-1 rounded-full border-none px-1.5 py-0.5 transition-colors duration-200 hover:brightness-110"
|
||||
className="xs:px-2 text-description bg-lightgray/20 gap-1 rounded-full border-none px-1.5 py-0.5 transition-colors duration-200 hover:brightness-110"
|
||||
>
|
||||
<ModeIcon mode={mode} />
|
||||
<span className="hidden sm:block">
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { ReusableCard } from "../ReusableCard";
|
||||
import { OnboardingCardTabs, TabTitle } from "./components/OnboardingCardTabs";
|
||||
import { useOnboardingCard } from "./hooks/useOnboardingCard";
|
||||
import * as Tabs from "./tabs";
|
||||
import {
|
||||
OnboardingCardLanding,
|
||||
OnboardingCardTabs,
|
||||
OnboardingLocalTab,
|
||||
OnboardingProvidersTab,
|
||||
} from "./components";
|
||||
import { useOnboardingCard } from "./hooks";
|
||||
|
||||
export interface OnboardingCardState {
|
||||
show?: boolean;
|
||||
activeTab?: TabTitle;
|
||||
activeTab?: OnboardingModes;
|
||||
}
|
||||
|
||||
interface OnboardingCardProps {
|
||||
|
|
@ -15,37 +20,48 @@ interface OnboardingCardProps {
|
|||
}
|
||||
|
||||
export function OnboardingCard({ isDialog }: OnboardingCardProps) {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const { activeTab, close, setActiveTab } = useOnboardingCard();
|
||||
const config = useAppSelector((store) => store.config.config);
|
||||
|
||||
function renderTabContent() {
|
||||
switch (onboardingCard.activeTab) {
|
||||
case "Quickstart":
|
||||
return <Tabs.Quickstart />;
|
||||
case "Best":
|
||||
return <Tabs.Best />;
|
||||
case "Local":
|
||||
return <Tabs.Local />;
|
||||
default:
|
||||
return <Tabs.Quickstart />;
|
||||
}
|
||||
}
|
||||
|
||||
if (getLocalStorage("onboardingStatus") === undefined) {
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
function renderTabContent() {
|
||||
switch (activeTab) {
|
||||
case OnboardingModes.API_KEY:
|
||||
return <OnboardingProvidersTab />;
|
||||
case OnboardingModes.LOCAL:
|
||||
return <OnboardingLocalTab />;
|
||||
default:
|
||||
return <OnboardingProvidersTab />;
|
||||
}
|
||||
}
|
||||
|
||||
if (activeTab) {
|
||||
return (
|
||||
<ReusableCard
|
||||
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
|
||||
onClose={close}
|
||||
testId="onboarding-card"
|
||||
>
|
||||
<OnboardingCardTabs activeTab={activeTab} onTabClick={setActiveTab} />
|
||||
{renderTabContent()}
|
||||
</ReusableCard>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ReusableCard
|
||||
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
|
||||
onClose={() => onboardingCard.close()}
|
||||
testId="onboarding-card"
|
||||
onClose={close}
|
||||
>
|
||||
<OnboardingCardTabs
|
||||
activeTab={onboardingCard.activeTab || "Best"}
|
||||
onTabClick={onboardingCard.setActiveTab}
|
||||
/>
|
||||
{renderTabContent()}
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<OnboardingCardLanding
|
||||
onSelectConfigure={() => setActiveTab(OnboardingModes.API_KEY)}
|
||||
isDialog={isDialog}
|
||||
/>
|
||||
</div>
|
||||
</ReusableCard>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,171 +0,0 @@
|
|||
import { CubeIcon } from "@heroicons/react/24/outline";
|
||||
import { FormEventHandler, useContext, useState } from "react";
|
||||
import { Button, Input, InputSubtext, lightGray } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { models } from "../../../pages/AddNewModel/configs/models";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { updateSelectedModelByRole } from "../../../redux/thunks";
|
||||
import AddModelButtonSubtext from "../../AddModelButtonSubtext";
|
||||
|
||||
const { anthropic, mistral } = providers;
|
||||
const chatProvider = anthropic!;
|
||||
const autocompleteProvider = mistral!;
|
||||
|
||||
const {
|
||||
claude35Sonnet: chatModel,
|
||||
claude35Haiku: repoMapModel,
|
||||
codestral: autocompleteModel,
|
||||
} = models;
|
||||
|
||||
interface BestExperienceConfigFormProps {
|
||||
onComplete: () => void;
|
||||
}
|
||||
|
||||
function BestExperienceConfigForm({
|
||||
onComplete,
|
||||
}: BestExperienceConfigFormProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const { selectedProfile } = useAuth();
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [autocompleteApiKey, setAutocompleteApiKey] = useState("");
|
||||
const [chatApiKey, setChatApiKey] = useState("");
|
||||
|
||||
const handleSubmit: FormEventHandler<HTMLFormElement> = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const chatModelConfig = {
|
||||
model: chatModel.params.model,
|
||||
provider: chatProvider.provider,
|
||||
underlyingProviderName: chatProvider.provider,
|
||||
apiKey: chatApiKey,
|
||||
title: chatModel.params.title,
|
||||
};
|
||||
|
||||
const repoMapConfig = {
|
||||
model: repoMapModel.params.model,
|
||||
provider: chatProvider.provider,
|
||||
underlyingProviderName: chatProvider.provider,
|
||||
apiKey: chatApiKey,
|
||||
title: repoMapModel.params.title,
|
||||
};
|
||||
|
||||
const autocompleteModelConfig = {
|
||||
title: autocompleteModel.params.title,
|
||||
provider: autocompleteProvider.provider,
|
||||
underlyingProviderName: autocompleteProvider.provider,
|
||||
model: autocompleteModel.params.model,
|
||||
apiKey: autocompleteApiKey,
|
||||
};
|
||||
|
||||
ideMessenger.post("config/addModel", { model: chatModelConfig });
|
||||
ideMessenger.post("config/addModel", {
|
||||
model: repoMapConfig,
|
||||
role: "repoMapFileSelection",
|
||||
});
|
||||
|
||||
dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
modelTitle: chatModelConfig.title,
|
||||
}),
|
||||
);
|
||||
|
||||
if (!!autocompleteApiKey) {
|
||||
await ideMessenger.request("addAutocompleteModel", {
|
||||
model: autocompleteModelConfig,
|
||||
});
|
||||
}
|
||||
|
||||
onComplete();
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<div>
|
||||
<div className="mb-1 flex flex-row justify-between gap-4 text-lg font-bold">
|
||||
<label className="text-lg font-bold">Chat model</label>
|
||||
<div
|
||||
className="hidden items-center justify-end text-xs font-semibold sm:flex"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="mr-1 h-4 w-4 flex-shrink-0" />
|
||||
<span className="inline text-right italic">
|
||||
{chatModel.title}{" "}
|
||||
<span className="hidden md:inline">by Anthropic</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col pb-4">
|
||||
<Input
|
||||
placeholder="Enter your Anthropic API Key"
|
||||
value={chatApiKey}
|
||||
onChange={(e) => setChatApiKey(e.target.value)}
|
||||
data-testid="best-chat-api-key-input"
|
||||
/>
|
||||
<InputSubtext>
|
||||
<a
|
||||
href={chatProvider.apiKeyUrl}
|
||||
target="_blank"
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create an Anthropic API key
|
||||
</InputSubtext>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="mb-1 flex flex-row justify-between gap-4 text-lg font-bold">
|
||||
<label className="text-lg font-bold">Autocomplete model</label>
|
||||
<div
|
||||
className="flex hidden items-center text-xs font-semibold sm:flex"
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<CubeIcon className="mr-1 inline h-4 w-4 flex-shrink-0" />
|
||||
<span className="text-right italic">
|
||||
{autocompleteModel.title}{" "}
|
||||
<span className="hidden md:inline">by Mistral</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col pb-4">
|
||||
<Input
|
||||
placeholder="Enter your Mistral API Key"
|
||||
value={autocompleteApiKey}
|
||||
onChange={(e) => setAutocompleteApiKey(e.target.value)}
|
||||
data-testid="best-autocomplete-api-key-input"
|
||||
/>
|
||||
<InputSubtext>
|
||||
<a
|
||||
href={autocompleteProvider.apiKeyUrl}
|
||||
target="_blank"
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a Mistral API key
|
||||
</InputSubtext>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full">
|
||||
<Button className="w-full" type="submit" disabled={!chatApiKey}>
|
||||
Connect
|
||||
</Button>
|
||||
<AddModelButtonSubtext />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default BestExperienceConfigForm;
|
||||
|
|
@ -27,7 +27,7 @@ function OllamaModelDownload({
|
|||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-1 mt-4 text-base font-semibold">{title}</p>
|
||||
<p className="mb-0 mt-4 text-base font-semibold">{title}</p>
|
||||
{hasDownloaded ? (
|
||||
<OllamaCompletedStep text={command} />
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
import { useContext } from "react";
|
||||
import { Button, SecondaryButton } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { selectCurrentOrg } from "../../../redux";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import { selectFirstHubProfile } from "../../../redux/thunks";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
import ContinueLogo from "../../gui/ContinueLogo";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
import { useOnboardingCard } from "../hooks";
|
||||
|
||||
export function OnboardingCardLanding({
|
||||
onSelectConfigure,
|
||||
isDialog,
|
||||
}: {
|
||||
onSelectConfigure: () => void;
|
||||
isDialog?: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
function onGetStarted() {
|
||||
void auth.login(true).then((success) => {
|
||||
if (success) {
|
||||
onboardingCard.close(isDialog);
|
||||
|
||||
// A new assistant is created when the account is created
|
||||
// We want to switch to this immediately
|
||||
void dispatch(selectFirstHubProfile());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openPastFreeTrialOnboarding() {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
onboardingCard.close(isDialog);
|
||||
}
|
||||
|
||||
const pastFreeTrialLimit = hasPassedFTL();
|
||||
|
||||
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>
|
||||
|
||||
{pastFreeTrialLimit ? (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
You've reached the free trial limit. Visit the Continue Platform to
|
||||
select a Coding Assistant.
|
||||
</p>
|
||||
<Button
|
||||
onClick={openPastFreeTrialOnboarding}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Go to Continue Platform
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="mb-5 mt-0 w-full text-sm">
|
||||
Log in to access a free trial of the
|
||||
<br />
|
||||
<span
|
||||
className="cursor-pointer underline hover:brightness-125"
|
||||
data-tooltip-id="models-addon-tooltip"
|
||||
onClick={() =>
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "pricing",
|
||||
})
|
||||
}
|
||||
>
|
||||
Models Add-On
|
||||
</span>
|
||||
<ToolTip id="models-addon-tooltip" place="bottom">
|
||||
Free trial includes 50 Chat requests and 2,000 autocomplete
|
||||
requests
|
||||
</ToolTip>
|
||||
</p>
|
||||
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Log in to Continue Hub
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
<SecondaryButton onClick={onSelectConfigure} className="w-full">
|
||||
Or, configure your own models
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,74 +1,32 @@
|
|||
import styled from "styled-components";
|
||||
import { vscForeground } from "../..";
|
||||
import { hasPassedFTL } from "../../../util/freeTrial";
|
||||
import { KeyIcon } from "@heroicons/react/24/outline";
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
|
||||
interface OnboardingCardTabsProps {
|
||||
activeTab: TabTitle;
|
||||
onTabClick: (tabName: TabTitle) => void;
|
||||
/** The currently active tab */
|
||||
activeTab: OnboardingModes;
|
||||
/** Callback function called when a tab is clicked */
|
||||
onTabClick: (tabName: OnboardingModes) => void;
|
||||
}
|
||||
|
||||
export type TabTitle = "Quickstart" | "Best" | "Local" | "ExistingUserHubIntro";
|
||||
|
||||
export const TabTitles: { [k in TabTitle]: { md: string; default: string } } = {
|
||||
Quickstart: {
|
||||
md: "Quickstart",
|
||||
default: "Quickstart",
|
||||
},
|
||||
Best: {
|
||||
md: "Best",
|
||||
default: "Best experience",
|
||||
},
|
||||
Local: {
|
||||
md: "Local",
|
||||
default: "Local with Ollama",
|
||||
},
|
||||
ExistingUserHubIntro: {
|
||||
md: "Try out hub.continue.dev",
|
||||
default: "Try out hub.continue.dev",
|
||||
},
|
||||
const getTabIcon = (tabTitle: OnboardingModes) => {
|
||||
if (tabTitle === OnboardingModes.API_KEY) {
|
||||
return <KeyIcon className="h-4 w-4" />;
|
||||
}
|
||||
if (tabTitle === OnboardingModes.LOCAL) {
|
||||
return (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/ollama.png`}
|
||||
alt="Ollama"
|
||||
className="h-4 w-4 object-contain"
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const StyledSelect = styled.select`
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
background-color: transparent;
|
||||
color: ${vscForeground};
|
||||
border: none;
|
||||
border-bottom: 1px solid ${vscForeground};
|
||||
border-radius: 0;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const TabButton = styled.button<{ isActive: boolean }>`
|
||||
margin-bottom: -1px;
|
||||
focus: outline-none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
color: ${vscForeground};
|
||||
border: none;
|
||||
|
||||
${({ isActive }) =>
|
||||
isActive &&
|
||||
`
|
||||
border-style: solid;
|
||||
border-width: 0 0 2.5px 0;
|
||||
border-color: ${vscForeground};
|
||||
font-weight: bold;
|
||||
`}
|
||||
`;
|
||||
|
||||
const TabList = styled.div`
|
||||
border-style: solid;
|
||||
border-width: 0 0 0.5px 0;
|
||||
border-color: ${vscForeground};
|
||||
`;
|
||||
|
||||
/**
|
||||
* Tab navigation component for onboarding modes with responsive design
|
||||
*/
|
||||
export function OnboardingCardTabs({
|
||||
activeTab,
|
||||
onTabClick,
|
||||
|
|
@ -76,46 +34,41 @@ export function OnboardingCardTabs({
|
|||
return (
|
||||
<div>
|
||||
<div className="xs:block hidden">
|
||||
<TabList>
|
||||
{Object.entries(TabTitles).map(([tabType, titles]) => {
|
||||
if (hasPassedFTL() && tabType === "Quickstart") {
|
||||
return undefined;
|
||||
}
|
||||
<div className="border-foreground border-x-0 border-b border-t-0 border-solid">
|
||||
{Object.values(OnboardingModes).map((tabTitle) => {
|
||||
const isActive = activeTab === tabTitle;
|
||||
|
||||
return (
|
||||
<TabButton
|
||||
className="xs:py-2 xs:px-3 rounded-t-sm px-6 py-2 hover:brightness-125 sm:px-5"
|
||||
key={tabType}
|
||||
isActive={activeTab === tabType}
|
||||
onClick={() => onTabClick(tabType as TabTitle)}
|
||||
data-testid={`onboarding-tab-${tabType}`}
|
||||
<button
|
||||
className={`xs:py-2 xs:px-3 text-foreground -mb-px cursor-pointer rounded-t-sm border-none bg-transparent px-6 py-2 font-medium hover:brightness-125 focus:outline-none sm:px-5 ${isActive ? "font-semibold" : ""}`}
|
||||
key={tabTitle}
|
||||
onClick={() => onTabClick(tabTitle as OnboardingModes)}
|
||||
data-testid={`onboarding-tab-${tabTitle}`}
|
||||
>
|
||||
<p className="m-0 hidden font-medium md:block">
|
||||
{titles.default}
|
||||
<p className="m-0 flex items-center gap-2">
|
||||
{getTabIcon(tabTitle)}
|
||||
{tabTitle}
|
||||
</p>
|
||||
<p className="m-0 block font-medium md:hidden">{titles.md}</p>
|
||||
</TabButton>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</TabList>
|
||||
</div>
|
||||
</div>
|
||||
<div className="xs:hidden block">
|
||||
<StyledSelect
|
||||
value={activeTab}
|
||||
onChange={(e) => onTabClick(e.target.value as TabTitle)}
|
||||
>
|
||||
{Object.entries(TabTitles).map(([tabType, titles]) => {
|
||||
if (hasPassedFTL() && tabType === "Quickstart") {
|
||||
return null;
|
||||
}
|
||||
|
||||
<div className="xs:hidden block">
|
||||
<select
|
||||
className="text-foreground border-foreground w-full cursor-pointer rounded-none border-b border-none bg-transparent p-2 text-base focus:outline-none"
|
||||
value={activeTab}
|
||||
onChange={(e) => onTabClick(e.target.value as OnboardingModes)}
|
||||
>
|
||||
{Object.values(OnboardingModes).map((tabTitle) => {
|
||||
return (
|
||||
<option key={tabType} value={tabType}>
|
||||
{titles.md}
|
||||
<option key={tabTitle} value={tabTitle}>
|
||||
{tabTitle}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</StyledSelect>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ import {
|
|||
LOCAL_ONBOARDING_FIM_MODEL,
|
||||
LOCAL_ONBOARDING_PROVIDER_TITLE,
|
||||
} from "core/config/onboarding";
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
import { Button } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
|
|
@ -22,10 +23,13 @@ interface OnboardingLocalTabProps {
|
|||
isDialog?: boolean;
|
||||
}
|
||||
|
||||
function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
||||
export function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { submitOnboarding } = useSubmitOnboarding("Local", isDialog);
|
||||
const { submitOnboarding } = useSubmitOnboarding(
|
||||
OnboardingModes.LOCAL,
|
||||
isDialog,
|
||||
);
|
||||
const [hasLoadedChatModel, setHasLoadedChatModel] = useState(false);
|
||||
const [downloadedOllamaModels, setDownloadedOllamaModels] = useState<
|
||||
string[]
|
||||
|
|
@ -109,7 +113,7 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
dispatch(setShowDialog(false));
|
||||
}
|
||||
|
||||
dispatch(
|
||||
void dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
|
|
@ -132,48 +136,53 @@ function OnboardingLocalTab({ isDialog }: OnboardingLocalTabProps) {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="mt-3 flex flex-col gap-1 px-2">
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-0 pb-1 text-base font-bold leading-tight">
|
||||
Install Ollama
|
||||
</p>
|
||||
<OllamaStatus isOllamaConnected={isOllamaConnected} />
|
||||
</div>
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<div className="w-full max-w-md">
|
||||
<div className="mt-3 flex flex-col gap-1 px-2">
|
||||
<div className="flex flex-col">
|
||||
<p className="mb-0 text-base font-bold leading-tight">
|
||||
Install Ollama
|
||||
</p>
|
||||
<OllamaStatus isOllamaConnected={isOllamaConnected} />
|
||||
</div>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Chat model"
|
||||
modelName={LOCAL_ONBOARDING_CHAT_MODEL}
|
||||
hasDownloaded={hasDownloadedChatModel}
|
||||
/>
|
||||
<OllamaModelDownload
|
||||
title="Download Chat model"
|
||||
modelName={LOCAL_ONBOARDING_CHAT_MODEL}
|
||||
hasDownloaded={hasDownloadedChatModel}
|
||||
/>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Autocomplete model"
|
||||
modelName={LOCAL_ONBOARDING_FIM_MODEL}
|
||||
hasDownloaded={hasDownloadedAutocompleteModel}
|
||||
/>
|
||||
<OllamaModelDownload
|
||||
title="Download Autocomplete model"
|
||||
modelName={LOCAL_ONBOARDING_FIM_MODEL}
|
||||
hasDownloaded={hasDownloadedAutocompleteModel}
|
||||
/>
|
||||
|
||||
<OllamaModelDownload
|
||||
title="Download Embeddings model"
|
||||
modelName={LOCAL_ONBOARDING_EMBEDDINGS_MODEL}
|
||||
hasDownloaded={hasDownloadedEmbeddingsModel}
|
||||
/>
|
||||
<OllamaModelDownload
|
||||
title="Download Embeddings model"
|
||||
modelName={LOCAL_ONBOARDING_EMBEDDINGS_MODEL}
|
||||
hasDownloaded={hasDownloadedEmbeddingsModel}
|
||||
/>
|
||||
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onClickSubmitOnboarding}
|
||||
className="w-full"
|
||||
disabled={!allDownloaded}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
<ButtonSubtext>
|
||||
<span className="cursor-pointer underline" onClick={onClickSkip}>
|
||||
Skip and configure manually
|
||||
</span>
|
||||
</ButtonSubtext>
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onClickSubmitOnboarding}
|
||||
className="w-full"
|
||||
disabled={!allDownloaded}
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
<div className="w-full text-center">
|
||||
<span
|
||||
className="text-description-muted cursor-pointer underline"
|
||||
onClick={onClickSkip}
|
||||
>
|
||||
Skip and configure manually
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingLocalTab;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { AddModelForm } from "../../../forms";
|
||||
import { providers } from "../../../pages/AddNewModel/configs/providers";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { Button, Input } from "../../index";
|
||||
import { useSubmitOnboarding } from "../hooks/useSubmitOnboarding";
|
||||
|
||||
interface OnboardingProvidersTabProps {
|
||||
/** Whether this is being shown in a dialog context */
|
||||
isDialog?: boolean;
|
||||
}
|
||||
|
||||
export function OnboardingProvidersTab({
|
||||
isDialog,
|
||||
}: OnboardingProvidersTabProps) {
|
||||
const formMethods = useForm();
|
||||
const dispatch = useAppDispatch();
|
||||
const { submitOnboarding } = useSubmitOnboarding(
|
||||
OnboardingModes.API_KEY,
|
||||
isDialog,
|
||||
);
|
||||
|
||||
const providerConfigs = [
|
||||
providers["openai"],
|
||||
providers["anthropic"],
|
||||
providers["gemini"],
|
||||
];
|
||||
|
||||
const handleFormSubmit = () => {
|
||||
// Find the first provider with an API key entered
|
||||
for (const config of providerConfigs) {
|
||||
const apiKey = formMethods.watch(`${config?.provider}_apiKey`);
|
||||
if (apiKey?.trim()) {
|
||||
submitOnboarding(config?.provider, apiKey);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleClickMoreProviders = () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
submitOnboarding();
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const hasAnyApiKey = providerConfigs.some((config) => {
|
||||
const apiKey = formMethods.watch(`${config?.provider}_apiKey`);
|
||||
return apiKey?.trim();
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<div className="w-full max-w-md">
|
||||
<FormProvider {...formMethods}>
|
||||
<div className="mt-5 space-y-6">
|
||||
<div className="space-y-4">
|
||||
{providerConfigs.map((config) => (
|
||||
<div key={config?.provider}>
|
||||
<label className="mb-1 flex items-center gap-3 text-sm font-medium">
|
||||
{window.vscMediaUrl && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${config?.icon}`}
|
||||
alt={config?.provider}
|
||||
className="h-4 w-4 object-contain"
|
||||
/>
|
||||
)}
|
||||
{config?.title}
|
||||
</label>
|
||||
<Input
|
||||
id={`${config?.provider}_apiKey`}
|
||||
type="password"
|
||||
placeholder={`Enter your ${config?.title} API key`}
|
||||
className="w-full"
|
||||
{...formMethods.register(`${config?.provider}_apiKey`)}
|
||||
/>
|
||||
<span className="text-description-muted mt-1 block text-xs">
|
||||
<a
|
||||
href={config?.apiKeyUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit hover:brightness-125"
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to create a {config?.title} API key
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleFormSubmit}
|
||||
disabled={!hasAnyApiKey}
|
||||
className="w-full"
|
||||
>
|
||||
Connect
|
||||
</Button>
|
||||
|
||||
<div className="w-full text-center">
|
||||
<span className="text-description-muted">
|
||||
<span
|
||||
className="cursor-pointer underline hover:brightness-125"
|
||||
onClick={handleClickMoreProviders}
|
||||
>
|
||||
Click here
|
||||
</span>{" "}
|
||||
to view more providers
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</FormProvider>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import Alert from "../../gui/Alert";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
function ProviderAlert() {
|
||||
const dispatch = useDispatch();
|
||||
const { submitOnboarding } = useSubmitOnboarding("Custom");
|
||||
|
||||
function onClick() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddModelForm onDone={submitOnboarding} />));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<Alert type="info">
|
||||
<p className="m-0 text-sm font-semibold">
|
||||
Prefer to use a different provider like OpenAI?
|
||||
</p>
|
||||
<p className="m-0 mt-1 text-xs">
|
||||
<a
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit"
|
||||
onClick={onClick}
|
||||
>
|
||||
Click here
|
||||
</a>{" "}
|
||||
to add a Chat model from OpenAI, Gemini, and more
|
||||
</p>
|
||||
</Alert>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProviderAlert;
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
interface QuickstartSubmitButtonProps {
|
||||
isDialog?: boolean;
|
||||
}
|
||||
|
||||
function QuickstartSubmitButton({ isDialog }: QuickstartSubmitButtonProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const { submitOnboarding } = useSubmitOnboarding("Quickstart", isDialog);
|
||||
|
||||
function onComplete() {
|
||||
submitOnboarding();
|
||||
}
|
||||
|
||||
async function onClick() {
|
||||
// REMOVED THIS LOGIC TO GET GITHUB TOKEN
|
||||
// SINCE NOW USES THE HUB FOR FREE TRIAL
|
||||
// AND COMPONENT IS CURRENTLY UNUSED
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-4 w-full">
|
||||
<Button
|
||||
onClick={onClick}
|
||||
className="grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started using our API keys
|
||||
</Button>
|
||||
<ButtonSubtext>Try 50 chat and 2k autocomplete requests</ButtonSubtext>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default QuickstartSubmitButton;
|
||||
7
gui/src/components/OnboardingCard/components/index.ts
Normal file
7
gui/src/components/OnboardingCard/components/index.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export * from "./OllamaCompletedStep";
|
||||
export * from "./OllamaModelDownload";
|
||||
export * from "./OllamaStatus";
|
||||
export * from "./OnboardingCardLanding";
|
||||
export * from "./OnboardingCardTabs";
|
||||
export * from "./OnboardingLocalTab";
|
||||
export * from "./OnboardingProvidersTab";
|
||||
|
|
@ -1,21 +1,19 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import { OnboardingCardState } from "..";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setOnboardingCard,
|
||||
setShowDialog,
|
||||
} from "../../../redux/slices/uiSlice";
|
||||
import { OnboardingCardState } from "..";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import { saveCurrentSession } from "../../../redux/thunks/session";
|
||||
|
||||
export interface UseOnboardingCard {
|
||||
show: OnboardingCardState["show"];
|
||||
activeTab: OnboardingCardState["activeTab"];
|
||||
setActiveTab: (tab: TabTitle) => void;
|
||||
open: (tab: TabTitle) => void;
|
||||
setActiveTab: (tab: OnboardingModes) => void;
|
||||
open: (tab?: OnboardingModes) => void;
|
||||
close: (isDialog?: boolean) => void;
|
||||
}
|
||||
|
||||
|
|
@ -40,9 +38,14 @@ export function useOnboardingCard(): UseOnboardingCard {
|
|||
show = onboardingStatus !== "Completed" && !hasDismissedOnboardingCard;
|
||||
}
|
||||
|
||||
async function open(tab: TabTitle) {
|
||||
async function open(tab?: OnboardingModes) {
|
||||
navigate("/");
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
dispatch(
|
||||
setOnboardingCard({
|
||||
show: true,
|
||||
activeTab: tab ?? OnboardingModes.API_KEY,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function close(isDialog = false) {
|
||||
|
|
@ -54,7 +57,7 @@ export function useOnboardingCard(): UseOnboardingCard {
|
|||
}
|
||||
}
|
||||
|
||||
function setActiveTab(tab: TabTitle) {
|
||||
function setActiveTab(tab: OnboardingModes) {
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: tab }));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,20 +3,25 @@ import { usePostHog } from "posthog-js/react";
|
|||
import { useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import { useLump } from "../../mainInput/Lump/LumpContext";
|
||||
import { useOnboardingCard } from "./useOnboardingCard";
|
||||
|
||||
export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) {
|
||||
const posthog = usePostHog();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { close: closeOnboardingCard } = useOnboardingCard();
|
||||
const { setSelectedSection } = useLump();
|
||||
|
||||
function submitOnboarding() {
|
||||
function submitOnboarding(provider?: string, apiKey?: string) {
|
||||
const onboardingStatus = getLocalStorage("onboardingStatus");
|
||||
|
||||
// Always close the onboarding card and update config.json
|
||||
// Always close the onboarding card and update config.yaml
|
||||
closeOnboardingCard(isDialog);
|
||||
ideMessenger.post("completeOnboarding", {
|
||||
|
||||
ideMessenger.post("onboarding/complete", {
|
||||
mode,
|
||||
provider,
|
||||
apiKey,
|
||||
});
|
||||
|
||||
if (onboardingStatus === "Started") {
|
||||
|
|
@ -32,6 +37,9 @@ export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) {
|
|||
// Move to next step in onboarding
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}
|
||||
|
||||
ideMessenger.post("config/openProfile", { profileId: undefined });
|
||||
setSelectedSection("models");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
import { useState } from "react";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { getLocalStorage, setLocalStorage } from "../../../util/localStorage";
|
||||
import Alert from "../../gui/Alert";
|
||||
import { ReusableCard } from "../../ReusableCard";
|
||||
import { TabTitle } from "../components/OnboardingCardTabs";
|
||||
import OnboardingLocalTab from "../components/OnboardingLocalTab";
|
||||
import { useOnboardingCard } from "../hooks";
|
||||
import MainTab from "./tabs/main";
|
||||
|
||||
export interface OnboardingCardState {
|
||||
show?: boolean;
|
||||
activeTab?: TabTitle;
|
||||
}
|
||||
|
||||
interface OnboardingCardProps {
|
||||
isDialog: boolean;
|
||||
}
|
||||
|
||||
export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const config = useAppSelector((store) => store.config.config);
|
||||
const auth = useAuth();
|
||||
const [currentTab, setCurrentTab] = useState<"main" | "local">("main");
|
||||
|
||||
if (getLocalStorage("onboardingStatus") === undefined) {
|
||||
setLocalStorage("onboardingStatus", "Started");
|
||||
}
|
||||
|
||||
function onGetStarted() {
|
||||
auth.login(true).then((success) => {
|
||||
if (success) {
|
||||
onboardingCard.close(isDialog);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<ReusableCard
|
||||
showCloseButton={!isDialog && !!config.modelsByRole.chat.length}
|
||||
onClose={() => onboardingCard.close()}
|
||||
>
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
{currentTab === "main" ? (
|
||||
<MainTab
|
||||
onRemainLocal={() => setCurrentTab("local")}
|
||||
isDialog={isDialog}
|
||||
/>
|
||||
) : (
|
||||
<div className="mt-4 flex flex-col">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local
|
||||
config.yaml file. If you're just looking to use Ollama and still
|
||||
want to manage your configuration through Continue, click{" "}
|
||||
<a href="#" onClick={onGetStarted}>
|
||||
here
|
||||
</a>
|
||||
</Alert>
|
||||
<OnboardingLocalTab isDialog={isDialog} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ReusableCard>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { Button, ButtonSubtext } from "../../..";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { selectCurrentOrg } from "../../../../redux";
|
||||
import { useAppSelector } from "../../../../redux/hooks";
|
||||
import { hasPassedFTL } from "../../../../util/freeTrial";
|
||||
import ContinueLogo from "../../../gui/ContinueLogo";
|
||||
import { useOnboardingCard } from "../../hooks";
|
||||
|
||||
export default function MainTab({
|
||||
onRemainLocal,
|
||||
isDialog,
|
||||
}: {
|
||||
onRemainLocal: () => void;
|
||||
isDialog: boolean;
|
||||
}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const onboardingCard = useOnboardingCard();
|
||||
const auth = useAuth();
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
|
||||
function onGetStarted() {
|
||||
auth.login(true).then((success) => {
|
||||
if (success) {
|
||||
onboardingCard.close(isDialog);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openPastFreeTrialOnboarding() {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
onboardingCard.close(isDialog);
|
||||
}
|
||||
|
||||
const pastFreeTrialLimit = hasPassedFTL();
|
||||
|
||||
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>
|
||||
|
||||
{pastFreeTrialLimit ? (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
You've reached the free trial limit. Visit the Continue Platform to
|
||||
select a Coding Assistant.
|
||||
</p>
|
||||
<Button
|
||||
onClick={openPastFreeTrialOnboarding}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Go to Continue Platform
|
||||
</Button>
|
||||
</>
|
||||
) : onboardingCard.activeTab === "ExistingUserHubIntro" ? (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
You can now browse and create custom AI code assistants at{" "}
|
||||
<code>hub.continue.dev</code>
|
||||
</p>
|
||||
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
Log in to quickly build your first custom AI code assistant
|
||||
</p>
|
||||
|
||||
<Button
|
||||
onClick={onGetStarted}
|
||||
className="mt-4 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{onboardingCard.activeTab === "ExistingUserHubIntro" ? (
|
||||
<ButtonSubtext onClick={() => onboardingCard.close(isDialog)}>
|
||||
<div className="mt-4 flex cursor-pointer items-center justify-center gap-1">
|
||||
<span>Or, use Continue as usual</span>
|
||||
<ChevronRightIcon className="h-3 w-3" />
|
||||
</div>
|
||||
</ButtonSubtext>
|
||||
) : (
|
||||
<ButtonSubtext onClick={onRemainLocal}>
|
||||
<div className="flex cursor-pointer items-center justify-center gap-1 hover:brightness-125">
|
||||
<span>Or, remain local</span>
|
||||
<ChevronRightIcon className="h-3 w-3" />
|
||||
</div>
|
||||
</ButtonSubtext>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import BestExperienceConfigForm from "../components/BestExperienceConfigForm";
|
||||
import ProviderAlert from "../components/ProviderAlert";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
|
||||
interface OnboardingBestTabProps {
|
||||
isDialog?: boolean;
|
||||
}
|
||||
|
||||
function OnboardingBestTab({ isDialog }: OnboardingBestTabProps) {
|
||||
const { submitOnboarding } = useSubmitOnboarding("Best", isDialog);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="xs:flex hidden w-full">
|
||||
<ProviderAlert />
|
||||
</div>
|
||||
<BestExperienceConfigForm onComplete={submitOnboarding} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingBestTab;
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
import ContinueLogo from "../../gui/ContinueLogo";
|
||||
import QuickStartSubmitButton from "../components/QuickStartSubmitButton";
|
||||
|
||||
interface OnboardingQuickstartTabProps {
|
||||
isDialog?: boolean;
|
||||
}
|
||||
|
||||
function OnboardingQuickstartTab({ isDialog }: OnboardingQuickstartTabProps) {
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<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">
|
||||
Quickly get up and running using our API keys. After this trial, we'll
|
||||
help you set up your own models.
|
||||
</p>
|
||||
|
||||
<p className="xs:w-3/4 w-full text-sm">
|
||||
To prevent abuse, we'll ask you to sign in to GitHub.
|
||||
</p>
|
||||
|
||||
<QuickStartSubmitButton isDialog={isDialog} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OnboardingQuickstartTab;
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export { default as Local } from "../components/OnboardingLocalTab";
|
||||
export { default as Best } from "./OnboardingBestTab";
|
||||
export { default as Quickstart } from "./OnboardingQuickstartTab";
|
||||
|
|
@ -24,7 +24,7 @@ export function isNewUserOnboarding() {
|
|||
|
||||
export const defaultOnboardingCardState: OnboardingCardState = {
|
||||
show: false,
|
||||
activeTab: "Quickstart",
|
||||
activeTab: undefined,
|
||||
};
|
||||
|
||||
export enum OllamaConnectionStatuses {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { fontSize } from "../util";
|
||||
import { useFontSize } from "./ui/font";
|
||||
|
||||
export interface PageHeaderProps {
|
||||
onTitleClick?: () => void;
|
||||
|
|
@ -14,9 +14,11 @@ export function PageHeader({
|
|||
rightContent,
|
||||
showBorder,
|
||||
}: PageHeaderProps) {
|
||||
const fontSize = useFontSize(-1);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`bg-vsc-background sticky top-0 z-20 m-0 flex items-center justify-between bg-inherit ${
|
||||
className={`sticky top-0 z-20 m-0 flex items-center justify-between bg-inherit py-1 ${
|
||||
showBorder
|
||||
? "border-0 border-b-[1px] border-solid border-b-zinc-700"
|
||||
: ""
|
||||
|
|
@ -24,14 +26,14 @@ export function PageHeader({
|
|||
>
|
||||
{title ? (
|
||||
<div
|
||||
className="flex cursor-pointer items-center transition-colors duration-200 hover:text-zinc-100"
|
||||
className="flex cursor-pointer items-center transition-colors duration-200 hover:brightness-125"
|
||||
onClick={onTitleClick}
|
||||
>
|
||||
<ArrowLeftIcon className="ml-3 inline-block h-3 w-3" />
|
||||
<span
|
||||
className="mx-2 inline-block text-base font-bold"
|
||||
className="mx-2 inline-block text-lg font-bold"
|
||||
style={{
|
||||
fontSize: fontSize(-2),
|
||||
fontSize,
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { Button, SecondaryButton } from "..";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { Button } from "../ui/Button";
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
onConfirm: () => void;
|
||||
|
|
@ -26,8 +25,8 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
|
|||
|
||||
<div className="w/1/2 flex justify-end gap-2">
|
||||
{!!props.hideCancelButton || (
|
||||
<SecondaryButton
|
||||
className="text-lightgray"
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
|
|
@ -35,7 +34,7 @@ function ConfirmationDialog(props: ConfirmationDialogProps) {
|
|||
}}
|
||||
>
|
||||
Cancel
|
||||
</SecondaryButton>
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { useEffect } from "react";
|
|||
import { useDispatch } from "react-redux";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { PlatformOnboardingCard } from "../OnboardingCard/platform/PlatformOnboardingCard";
|
||||
import { OnboardingCard } from "../OnboardingCard";
|
||||
|
||||
function FreeTrialOverDialog() {
|
||||
const dispatch = useDispatch();
|
||||
|
|
@ -17,7 +17,7 @@ function FreeTrialOverDialog() {
|
|||
|
||||
return (
|
||||
<div className="flex-1">
|
||||
<PlatformOnboardingCard isDialog />
|
||||
<OnboardingCard isDialog />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ export const SecondaryButton = styled.button`
|
|||
|
||||
export const GhostButton = styled.button`
|
||||
padding: 6px 8px;
|
||||
margin: 6px 0;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
|
||||
border: none;
|
||||
|
|
@ -86,13 +85,6 @@ export const GhostButton = styled.button`
|
|||
}
|
||||
`;
|
||||
|
||||
export const InputSubtext = styled.span`
|
||||
font-size: 0.75rem;
|
||||
line-height: 1rem;
|
||||
color: ${lightGray};
|
||||
margin-top: 0.25rem;
|
||||
`;
|
||||
|
||||
export const ButtonSubtext = styled.span`
|
||||
display: block;
|
||||
margin-top: 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ExclamationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import { AddModelForm } from "../../forms";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ import {
|
|||
} from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { exitEdit } from "../../redux/thunks/edit";
|
||||
import {
|
||||
getAltKeyLabel,
|
||||
getMetaKeyLabel,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import { getAltKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import { ModeSelect } from "../ModeSelect";
|
||||
|
|
@ -160,32 +156,28 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
<div
|
||||
className={`${toolsSupported ? "md:flex" : "int:flex"} hover:underline" hidden transition-colors duration-200`}
|
||||
>
|
||||
{props.activeKey === "Alt" ? (
|
||||
<HoverItem className="underline">
|
||||
{`${getAltKeyLabel()}⏎
|
||||
${useActiveFile ? "No active file" : "Active file"}`}
|
||||
</HoverItem>
|
||||
) : (
|
||||
<HoverItem
|
||||
className={props.activeKey === "Meta" ? "underline" : ""}
|
||||
onClick={(e) =>
|
||||
props.onEnter?.({
|
||||
useCodebase: true,
|
||||
noContext: !useActiveFile,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span data-tooltip-id="add-codebase-context-tooltip">
|
||||
{getMetaKeyLabel()}⏎ @codebase
|
||||
</span>
|
||||
<ToolTip id="add-codebase-context-tooltip" place="top-end">
|
||||
Send With Codebase as Context ({getMetaKeyLabel()}⏎)
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
)}
|
||||
<HoverItem
|
||||
className={props.activeKey === "Alt" ? "underline" : ""}
|
||||
onClick={(e) =>
|
||||
props.onEnter?.({
|
||||
useCodebase: false,
|
||||
noContext: !useActiveFile,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span data-tooltip-id="add-active-file-context-tooltip">
|
||||
{getAltKeyLabel()}⏎{" "}
|
||||
{useActiveFile ? "No active file" : "Active file"}
|
||||
</span>
|
||||
<ToolTip id="add-active-file-context-tooltip" place="top-end">
|
||||
{useActiveFile
|
||||
? "Send Without Active File"
|
||||
: "Send With Active File"}{" "}
|
||||
({getAltKeyLabel()}⏎)
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isInEdit && (
|
||||
<HoverItem
|
||||
className="hidden hover:underline sm:flex"
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ function BlockSettingsToolbarIcon(
|
|||
? "bg-error"
|
||||
: "bg-badge"
|
||||
: undefined
|
||||
} relative flex select-none items-center rounded-full px-[3px] transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 sm:px-1 ${props.className || ""}`}
|
||||
} relative flex select-none items-center rounded-full px-[3px] py-0.5 transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 sm:px-1 ${props.className || ""}`}
|
||||
>
|
||||
<props.icon
|
||||
className={`h-[13px] w-[13px] flex-shrink-0 hover:brightness-125 ${
|
||||
|
|
@ -154,15 +154,31 @@ export function BlockSettingsTopToolbar() {
|
|||
const isUsingFreeTrial = usesFreeTrialApiKey(config);
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger
|
||||
.request("controlPlane/getFreeTrialStatus", undefined)
|
||||
.then((resp) => {
|
||||
if (resp.status === "success") {
|
||||
setFreeTrialStatus(resp.content);
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
const fetchFreeTrialStatus = () => {
|
||||
ideMessenger
|
||||
.request("controlPlane/getFreeTrialStatus", undefined)
|
||||
.then((resp) => {
|
||||
if (resp.status === "success") {
|
||||
setFreeTrialStatus(resp.content);
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
fetchFreeTrialStatus();
|
||||
|
||||
let intervalId: NodeJS.Timeout | null = null;
|
||||
|
||||
if (isUsingFreeTrial) {
|
||||
intervalId = setInterval(fetchFreeTrialStatus, 15000);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
};
|
||||
}, [ideMessenger, isUsingFreeTrial]);
|
||||
|
||||
const handleEllipsisClick = () => {
|
||||
if (isToolbarExpanded) {
|
||||
|
|
@ -180,7 +196,7 @@ export function BlockSettingsTopToolbar() {
|
|||
return (
|
||||
<div className="flex flex-1 items-center justify-between gap-2">
|
||||
<div className="flex flex-row">
|
||||
<div className="xs:flex text-description hidden items-center justify-center">
|
||||
<div className="xs:flex text-description hidden items-center justify-center gap-0.5">
|
||||
<BlockSettingsToolbarIcon
|
||||
className="-ml-1.5"
|
||||
icon={isToolbarExpanded ? ChevronLeftIcon : EllipsisHorizontalIcon}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import ModelRoleSelector from "../../../../pages/config/ModelRoleSelector";
|
|||
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
|
||||
import { updateSelectedModelByRole } from "../../../../redux/thunks";
|
||||
import { isJetBrains } from "../../../../util";
|
||||
import { ExploreBlocksButton } from "./ExploreBlocksButton";
|
||||
|
||||
export function ModelsSection() {
|
||||
const { selectedProfile } = useAuth();
|
||||
|
|
@ -19,7 +18,7 @@ export function ModelsSection() {
|
|||
return;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
void dispatch(
|
||||
updateSelectedModelByRole({
|
||||
role,
|
||||
selectedProfile,
|
||||
|
|
@ -30,13 +29,14 @@ export function ModelsSection() {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<div className="text-[${getFontSize() - 1}px] grid grid-cols-1 gap-x-2 gap-y-1 pb-2 sm:grid-cols-[auto_1fr]">
|
||||
<div className="text-[${getFontSize() - 1}px] grid grid-cols-1 gap-x-2 gap-y-1 sm:grid-cols-[auto_1fr]">
|
||||
<ModelRoleSelector
|
||||
displayName="Chat"
|
||||
description="Used in the chat interface"
|
||||
models={config.modelsByRole.chat}
|
||||
selectedModel={config.selectedModelByRole.chat}
|
||||
onSelect={(model) => handleRoleUpdate("chat", model)}
|
||||
setupURL="https://docs.continue.dev/chat/model-setup"
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Autocomplete"
|
||||
|
|
@ -44,6 +44,7 @@ export function ModelsSection() {
|
|||
models={config.modelsByRole.autocomplete}
|
||||
selectedModel={config.selectedModelByRole.autocomplete}
|
||||
onSelect={(model) => handleRoleUpdate("autocomplete", model)}
|
||||
setupURL="https://docs.continue.dev/autocomplete/model-setup"
|
||||
/>
|
||||
{/* Jetbrains has a model selector inline */}
|
||||
{!jetbrains && (
|
||||
|
|
@ -53,6 +54,7 @@ export function ModelsSection() {
|
|||
models={config.modelsByRole.edit}
|
||||
selectedModel={config.selectedModelByRole.edit}
|
||||
onSelect={(model) => handleRoleUpdate("edit", model)}
|
||||
setupURL="https://docs.continue.dev/edit/model-setup"
|
||||
/>
|
||||
)}
|
||||
<ModelRoleSelector
|
||||
|
|
@ -61,6 +63,7 @@ export function ModelsSection() {
|
|||
models={config.modelsByRole.apply}
|
||||
selectedModel={config.selectedModelByRole.apply}
|
||||
onSelect={(model) => handleRoleUpdate("apply", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/apply"
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Embed"
|
||||
|
|
@ -68,6 +71,7 @@ export function ModelsSection() {
|
|||
models={config.modelsByRole.embed}
|
||||
selectedModel={config.selectedModelByRole.embed}
|
||||
onSelect={(model) => handleRoleUpdate("embed", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/embeddings"
|
||||
/>
|
||||
<ModelRoleSelector
|
||||
displayName="Rerank"
|
||||
|
|
@ -75,9 +79,9 @@ export function ModelsSection() {
|
|||
models={config.modelsByRole.rerank}
|
||||
selectedModel={config.selectedModelByRole.rerank}
|
||||
onSelect={(model) => handleRoleUpdate("rerank", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/reranking"
|
||||
/>
|
||||
</div>
|
||||
<ExploreBlocksButton blockType={"models"} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ import {
|
|||
} from "@heroicons/react/24/outline";
|
||||
import { RuleWithSource } from "core";
|
||||
import {
|
||||
DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
DEFAULT_CHAT_SYSTEM_MESSAGE_URL,
|
||||
DEFAULT_AGENT_SYSTEM_MESSAGE,
|
||||
DEFAULT_AGENT_SYSTEM_MESSAGE_URL,
|
||||
DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
DEFAULT_CHAT_SYSTEM_MESSAGE_URL,
|
||||
} from "core/llm/constructMessages";
|
||||
import { useContext, useMemo } from "react";
|
||||
import { defaultBorderRadius, vscCommandCenterActiveBorder } from "../../..";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
|
||||
|
|
@ -91,13 +90,7 @@ const RuleCard: React.FC<RuleCardProps> = ({ rule }) => {
|
|||
const smallFont = useFontSize(-2);
|
||||
const tinyFont = useFontSize(-3);
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
borderRadius: defaultBorderRadius,
|
||||
border: `1px solid ${vscCommandCenterActiveBorder}`,
|
||||
}}
|
||||
className="flex flex-col px-2 py-1.5 transition-colors"
|
||||
>
|
||||
<div className="border-border flex flex-col rounded-sm px-2 py-1.5 transition-colors">
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-row justify-between gap-1">
|
||||
<span
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ export function ErrorSection() {
|
|||
}`}
|
||||
>
|
||||
{error.fatal ? (
|
||||
<ExclamationCircleIcon className="mr-2 mt-1 h-3.5 w-3.5" />
|
||||
<ExclamationCircleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
|
||||
) : (
|
||||
<ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5" />
|
||||
<ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
|
||||
)}
|
||||
<p
|
||||
className="m-0 whitespace-pre-wrap text-wrap"
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
|
|||
/>
|
||||
)}
|
||||
<span className="line-clamp-1 break-all">
|
||||
{props.tool.function.name}
|
||||
{props.tool.originalFunctionName ?? props.tool.function.name}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -124,16 +124,16 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
|
|||
</>
|
||||
) : policy === "allowedWithoutPermission" ? (
|
||||
<>
|
||||
<span className="text-green-500 sm:hidden">Auto</span>
|
||||
<span className="hidden text-green-500 sm:inline-block">
|
||||
<span className="text-success sm:hidden">Auto</span>
|
||||
<span className="text-success hidden sm:inline-block">
|
||||
Automatic
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
// allowedWithPermission
|
||||
<>
|
||||
<span className="text-yellow-500 sm:hidden">Ask</span>
|
||||
<span className="hidden text-yellow-500 sm:inline-block">
|
||||
<span className="text-warning sm:hidden">Ask</span>
|
||||
<span className="text-warning hidden sm:inline-block">
|
||||
Ask First
|
||||
</span>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
CheckIcon,
|
||||
ChevronDownIcon,
|
||||
Cog6ToothIcon,
|
||||
|
|
@ -6,14 +7,18 @@ import {
|
|||
PlusIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { lightGray } from "..";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import AddModelForm from "../../forms/AddModelForm";
|
||||
import { AddModelForm } from "../../forms";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { EMPTY_CONFIG } from "../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { updateSelectedModelByRole } from "../../redux/thunks";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import {
|
||||
fontSize,
|
||||
getMetaKeyLabel,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../util";
|
||||
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui";
|
||||
|
||||
interface ModelOptionProps {
|
||||
|
|
@ -48,15 +53,6 @@ function ModelOption({
|
|||
}: ModelOptionProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
function onClickGear(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ideMessenger.post("config/openProfile", { profileId: undefined });
|
||||
}
|
||||
|
||||
function handleOptionClick(e: any) {
|
||||
if (showMissingApiKeyMsg) {
|
||||
e.preventDefault();
|
||||
|
|
@ -69,33 +65,21 @@ function ModelOption({
|
|||
key={idx}
|
||||
disabled={showMissingApiKeyMsg}
|
||||
value={option.value}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
onClick={handleOptionClick}
|
||||
>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<div className="flex flex-1 flex-row items-center justify-between gap-2">
|
||||
<div className="flex flex-1 flex-row items-center gap-2">
|
||||
<CubeIcon className="h-3 w-3 flex-shrink-0" />
|
||||
<span className="line-clamp-1 flex-1">
|
||||
{option.title}
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-shrink-0 flex-row items-center gap-1">
|
||||
{isSelected && <CheckIcon className="h-3 w-3 flex-shrink-0" />}
|
||||
{hovered && (
|
||||
<Cog6ToothIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
onClick={onClickGear}
|
||||
/>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<CubeIcon className="h-3 w-3 flex-shrink-0" />
|
||||
<span className="line-clamp-1">
|
||||
{option.title}
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-2 text-[10px] italic">(Missing API key)</span>
|
||||
)}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<CheckIcon
|
||||
className={`h-3 w-3 flex-shrink-0 ${isSelected ? "" : "invisible"}`}
|
||||
/>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
|
|
@ -106,6 +90,11 @@ function ModelSelect() {
|
|||
|
||||
const isInEdit = useAppSelector((store) => store.session.isInEdit);
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
|
||||
const { selectedProfile } = useAuth();
|
||||
|
||||
let selectedModel = null;
|
||||
let allModels = null;
|
||||
|
|
@ -120,11 +109,6 @@ function ModelSelect() {
|
|||
allModels = config.modelsByRole.chat;
|
||||
}
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<Option[]>([]);
|
||||
const { selectedProfile } = useAuth();
|
||||
|
||||
// Sort so that options without an API key are at the end
|
||||
useEffect(() => {
|
||||
const alphaSort = options.sort((a, b) => a.title.localeCompare(b.title));
|
||||
|
|
@ -203,6 +187,9 @@ function ModelSelect() {
|
|||
);
|
||||
}
|
||||
|
||||
const isConfigLoading = config === EMPTY_CONFIG;
|
||||
const hasNoModels = allModels?.length === 0;
|
||||
|
||||
return (
|
||||
<Listbox
|
||||
onChange={async (val: string) => {
|
||||
|
|
@ -230,39 +217,69 @@ function ModelSelect() {
|
|||
aria-hidden="true"
|
||||
/>
|
||||
</ListboxButton>
|
||||
<ListboxOptions className={"min-w-[160px]"}>
|
||||
<div className={`no-scrollbar max-h-[300px] overflow-y-auto`}>
|
||||
{sortedOptions.map((option, idx) => (
|
||||
<ModelOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showMissingApiKeyMsg={option.apiKey === ""}
|
||||
isSelected={option.value === selectedModel?.title}
|
||||
/>
|
||||
))}
|
||||
<ListboxOptions className="min-w-[160px]">
|
||||
<div className="flex items-center justify-between gap-1 px-2 py-1">
|
||||
<span className="font-semibold">Models</span>
|
||||
<Cog6ToothIcon
|
||||
className="text-description h-3 w-3 cursor-pointer hover:brightness-125"
|
||||
onClick={() =>
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: undefined,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="">
|
||||
{selectedProfile?.profileType === "local" && (
|
||||
<>
|
||||
<ListboxOption
|
||||
key={options.length}
|
||||
onClick={onClickAddModel}
|
||||
value={"addModel" as any}
|
||||
>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-3 w-3" />
|
||||
Add Chat model
|
||||
</div>
|
||||
</ListboxOption>
|
||||
</>
|
||||
<div className="no-scrollbar max-h-[300px] overflow-y-auto">
|
||||
{isConfigLoading ? (
|
||||
<div className="text-description flex items-center gap-2 px-2 pb-2 pt-1 text-xs">
|
||||
<ArrowPathIcon className="animate-spin-slow h-3 w-3" />
|
||||
<span>Loading config</span>
|
||||
</div>
|
||||
) : hasNoModels ? (
|
||||
<div className="text-description-muted px-2 py-4 text-center text-sm">
|
||||
No models configured
|
||||
</div>
|
||||
) : (
|
||||
sortedOptions.map((option, idx) => (
|
||||
<ModelOption
|
||||
option={option}
|
||||
idx={idx}
|
||||
key={idx}
|
||||
showMissingApiKeyMsg={option.apiKey === ""}
|
||||
isSelected={option.value === selectedModel?.title}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
|
||||
<span className="block px-2 py-1" style={{ color: lightGray }}>
|
||||
{getMetaKeyLabel()}' to toggle model
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{!isConfigLoading && selectedProfile?.profileType === "local" && (
|
||||
<ListboxOption
|
||||
key={options.length}
|
||||
onClick={onClickAddModel}
|
||||
value={"addModel" as any}
|
||||
className="border-border border-x-0 border-y border-solid"
|
||||
>
|
||||
<div
|
||||
className="text-description flex items-center py-0.5 hover:text-inherit"
|
||||
style={{
|
||||
fontSize: fontSize(-3),
|
||||
}}
|
||||
>
|
||||
<PlusIcon className="mr-2 h-3 w-3" />
|
||||
Add Chat model
|
||||
</div>
|
||||
</ListboxOption>
|
||||
)}
|
||||
|
||||
{!isConfigLoading && (
|
||||
<div
|
||||
className="text-description-muted px-2 py-1"
|
||||
style={{ fontSize: fontSize(-3) }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}'</code> to toggle model
|
||||
</div>
|
||||
)}
|
||||
</ListboxOptions>
|
||||
</div>
|
||||
</Listbox>
|
||||
|
|
|
|||
|
|
@ -4,16 +4,6 @@ import {
|
|||
CubeIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Fragment } from "react";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscBackground,
|
||||
vscForeground,
|
||||
vscInputBackground,
|
||||
vscListActiveBackground,
|
||||
vscListActiveForeground,
|
||||
} from "..";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
|
|
@ -22,85 +12,9 @@ import {
|
|||
Transition,
|
||||
} from "../../components/ui";
|
||||
import { DisplayInfo } from "../../pages/AddNewModel/configs/models";
|
||||
export const StyledListbox = styled(Listbox)`
|
||||
background-color: ${vscBackground};
|
||||
`;
|
||||
|
||||
export const StyledListboxButton = styled(ListboxButton)`
|
||||
cursor: pointer;
|
||||
background-color: ${vscBackground};
|
||||
text-align: left;
|
||||
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 2.5rem;
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
|
||||
border-radius: 0.5em;
|
||||
border: 1px solid ${lightGray};
|
||||
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
position: relative;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
|
||||
color: ${vscForeground};
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscInputBackground};
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOptions = styled(ListboxOptions)`
|
||||
background-color: ${vscInputBackground};
|
||||
padding: 0;
|
||||
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
|
||||
margin-top: 0.25rem;
|
||||
|
||||
height: fit-content;
|
||||
max-height: 15rem;
|
||||
width: 60%;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: auto;
|
||||
z-index: 10;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
export const StyledListboxOption = styled(ListboxOption)<{
|
||||
selected: boolean;
|
||||
}>`
|
||||
background-color: ${({ selected }) =>
|
||||
selected ? vscListActiveBackground : vscInputBackground};
|
||||
cursor: pointer;
|
||||
padding: 6px 8px 6px 12px;
|
||||
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
background-color: ${vscListActiveBackground};
|
||||
color: ${vscListActiveForeground};
|
||||
}
|
||||
`;
|
||||
|
||||
interface ModelSelectionListboxProps {
|
||||
/** Model selection listbox for choosing AI providers */
|
||||
selectedProvider: DisplayInfo;
|
||||
setSelectedProvider: (val: DisplayInfo) => void;
|
||||
topOptions?: DisplayInfo[];
|
||||
|
|
@ -114,9 +28,9 @@ function ModelSelectionListbox({
|
|||
otherOptions = [],
|
||||
}: ModelSelectionListboxProps) {
|
||||
return (
|
||||
<StyledListbox value={selectedProvider} onChange={setSelectedProvider}>
|
||||
<Listbox value={selectedProvider} onChange={setSelectedProvider}>
|
||||
<div className="relative mb-2 mt-1">
|
||||
<StyledListboxButton>
|
||||
<ListboxButton className="bg-background border-border text-foreground hover:bg-input relative m-0 grid h-full w-full cursor-pointer grid-cols-[1fr_auto] items-center rounded-lg border border-solid py-2 pl-3 pr-10 text-left focus:outline-none">
|
||||
<span className="flex items-center">
|
||||
{window.vscMediaUrl && selectedProvider.icon && (
|
||||
<img
|
||||
|
|
@ -128,97 +42,103 @@ function ModelSelectionListbox({
|
|||
</span>
|
||||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
className="text-description-muted h-5 w-5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
</StyledListboxButton>
|
||||
</ListboxButton>
|
||||
|
||||
<Transition
|
||||
as={Fragment}
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<StyledListboxOptions>
|
||||
<ListboxOptions className="bg-input rounded-default absolute left-0 top-full z-10 mt-1 h-fit w-3/5 overflow-y-auto p-0 focus:outline-none [&]:!max-h-[30vh]">
|
||||
{topOptions.length > 0 && (
|
||||
<div className="py-1">
|
||||
<div className="text-description-muted px-3 py-1 text-xs font-medium uppercase tracking-wider">
|
||||
Popular
|
||||
</div>
|
||||
{topOptions.map((option, index) => (
|
||||
<StyledListboxOption
|
||||
selected={selectedProvider.title === option.title}
|
||||
<ListboxOption
|
||||
key={index}
|
||||
className="relative cursor-default select-none py-2 pr-4 text-gray-400"
|
||||
className={({ selected }: { selected: boolean }) =>
|
||||
` ${selected ? "bg-list-active" : "bg-input"} hover:bg-list-active hover:text-list-active-foreground relative flex cursor-default cursor-pointer select-none items-center justify-between gap-2 p-1.5 px-3 py-2 pr-4`
|
||||
}
|
||||
value={option}
|
||||
>
|
||||
{({ selected }) => (
|
||||
<>
|
||||
{option.title === "Autodetect" ? (
|
||||
<CubeIcon className="mr-2 h-4 w-4 text-gray-400" />
|
||||
) : (
|
||||
window.vscMediaUrl &&
|
||||
option.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${option.icon}`}
|
||||
className="mr-1 h-4 w-4 object-contain object-center"
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<span className="text-xs">{option.title}</span>
|
||||
|
||||
<div className="flex items-center">
|
||||
{option.title === "Autodetect" ? (
|
||||
<CubeIcon className="mr-2 h-4 w-4" />
|
||||
) : (
|
||||
window.vscMediaUrl &&
|
||||
option.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${option.icon}`}
|
||||
className="mr-2 h-4 w-4 object-contain object-center"
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<span className="text-xs">{option.title}</span>
|
||||
</div>
|
||||
{selected && (
|
||||
<span className="inset-y-0 ml-auto flex items-center pl-3">
|
||||
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>
|
||||
<CheckIcon className="h-3 w-3" aria-hidden="true" />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</StyledListboxOption>
|
||||
</ListboxOption>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{topOptions.length > 0 && otherOptions.length > 0 && (
|
||||
<div className="my-1 h-px bg-zinc-500" />
|
||||
<div className="bg-border my-1 h-px min-h-px" />
|
||||
)}
|
||||
|
||||
{otherOptions.length > 0 && (
|
||||
<div className="py-1">
|
||||
<div className="text-description-muted px-3 py-1 text-xs font-medium uppercase tracking-wider">
|
||||
Additional providers
|
||||
</div>
|
||||
{otherOptions.map((option, index) => (
|
||||
<StyledListboxOption
|
||||
selected={selectedProvider.title === option.title}
|
||||
<ListboxOption
|
||||
key={index}
|
||||
className="relative cursor-default select-none py-2 pr-4 text-gray-400"
|
||||
className={({ selected }: { selected: boolean }) =>
|
||||
` ${selected ? "bg-list-active" : "bg-input"} hover:bg-list-active hover:text-list-active-foreground relative flex cursor-default cursor-pointer select-none items-center justify-between gap-2 p-1.5 px-3 py-2 pr-4`
|
||||
}
|
||||
value={option}
|
||||
>
|
||||
{({ selected }) => (
|
||||
<>
|
||||
{option.title === "Autodetect" ? (
|
||||
<CubeIcon className="mr-2 h-4 w-4 text-gray-400" />
|
||||
) : (
|
||||
window.vscMediaUrl &&
|
||||
option.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${option.icon}`}
|
||||
className="mr-1 h-4 w-4 object-contain object-center"
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<span className="text-xs">{option.title}</span>
|
||||
<div className="flex items-center">
|
||||
{option.title === "Autodetect" ? (
|
||||
<CubeIcon className="mr-2 h-4 w-4" />
|
||||
) : (
|
||||
window.vscMediaUrl &&
|
||||
option.icon && (
|
||||
<img
|
||||
src={`${window.vscMediaUrl}/logos/${option.icon}`}
|
||||
className="mr-2 h-4 w-4 object-contain object-center"
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<span className="text-xs">{option.title}</span>
|
||||
</div>
|
||||
|
||||
{selected && (
|
||||
<span className="inset-y-0 ml-auto flex items-center pl-3">
|
||||
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</span>
|
||||
<CheckIcon className="h-3 w-3" aria-hidden="true" />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</StyledListboxOption>
|
||||
</ListboxOption>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</StyledListboxOptions>
|
||||
</ListboxOptions>
|
||||
</Transition>
|
||||
</div>
|
||||
</StyledListbox>
|
||||
</Listbox>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import {
|
|||
|
||||
import type { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { vscCommandCenterInactiveBorder } from "../..";
|
||||
import { cn } from "../../../util/cn";
|
||||
import { ROUTES } from "../../../util/navigation";
|
||||
import { useLump } from "../../mainInput/Lump/LumpContext";
|
||||
|
|
@ -115,7 +114,7 @@ const AssistantSelectOption = ({
|
|||
{profile.errors && profile.errors?.length > 0 && (
|
||||
<ExclamationTriangleIcon
|
||||
data-tooltip-id={`${profile.id}-errors-tooltip`}
|
||||
className="h-3 w-3 flex-shrink-0 cursor-pointer text-red-500"
|
||||
className="text-error h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
@ -290,7 +289,7 @@ export default function AssistantSelect() {
|
|||
<Transition>
|
||||
<ListboxOptions className="pb-0">
|
||||
<div className="flex gap-1.5 px-2.5 py-1">
|
||||
<span>Assistants</span>
|
||||
<span className="font-semibold">Assistants</span>
|
||||
<div
|
||||
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
|
||||
onClick={async (e) => {
|
||||
|
|
@ -326,18 +325,11 @@ export default function AssistantSelect() {
|
|||
</div>
|
||||
|
||||
<div className="flex flex-col">
|
||||
<div
|
||||
className="my-0 h-[0.5px]"
|
||||
style={{
|
||||
backgroundColor: vscCommandCenterInactiveBorder,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="flex flex-row items-center">
|
||||
<ListboxOption
|
||||
className="w-full"
|
||||
value={"new-assistant"}
|
||||
fontSizeModifier={-2}
|
||||
className="border-border w-full border-x-0 border-y border-solid"
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
>
|
||||
<div
|
||||
|
|
@ -352,13 +344,6 @@ export default function AssistantSelect() {
|
|||
</ListboxOption>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="my-0 h-[0.5px]"
|
||||
style={{
|
||||
backgroundColor: vscCommandCenterInactiveBorder,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div
|
||||
className="text-description flex items-center justify-between gap-1.5 px-2 py-1"
|
||||
style={{
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export default function FreeTrialButton({
|
|||
<span
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/pricing",
|
||||
path: "pricing",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}}
|
||||
|
|
@ -141,7 +141,7 @@ export default function FreeTrialButton({
|
|||
className="flex-1"
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/setup-models",
|
||||
path: "setup-models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}}
|
||||
|
|
@ -152,7 +152,7 @@ export default function FreeTrialButton({
|
|||
className="flex-1"
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/settings/billing",
|
||||
path: "settings/billing",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}}
|
||||
|
|
|
|||
49
gui/src/components/ui/Button.tsx
Normal file
49
gui/src/components/ui/Button.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import * as React from "react";
|
||||
import { cn } from "../../util/cn";
|
||||
import { FontSizeModifier, useFontSize } from "./font";
|
||||
|
||||
type ButtonVariant = "ghost" | "primary" | "secondary" | "outline";
|
||||
|
||||
type ButtonProps = React.ComponentProps<"button"> & {
|
||||
variant?: ButtonVariant;
|
||||
fontSizeModifier?: FontSizeModifier;
|
||||
};
|
||||
|
||||
const buttonVariants = {
|
||||
primary:
|
||||
"px-3 py-1.5 border-none text-background bg-foreground hover:enabled:brightness-125",
|
||||
secondary:
|
||||
"px-3 py-1.5 border border-input-border text-foreground bg-input hover:enabled:bg-background hover:enabled:opacity-90",
|
||||
outline:
|
||||
"px-3 py-1.5 border-[0.5px] border-foreground text-foreground bg-transparent hover:enabled:bg-foreground/10",
|
||||
ghost:
|
||||
"px-2 py-1.5 border-none text-foreground bg-gray-500/40 hover:enabled:brightness-125",
|
||||
};
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ variant = "primary", fontSizeModifier = 0, className, ...props }, ref) => {
|
||||
const fontSize = useFontSize(fontSizeModifier);
|
||||
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"my-1.5 cursor-pointer rounded transition-all duration-200",
|
||||
"hover:enabled:cursor-pointer",
|
||||
"disabled:text-description-muted disabled:pointer-events-none disabled:opacity-50",
|
||||
buttonVariants[variant],
|
||||
className,
|
||||
)}
|
||||
style={{
|
||||
fontSize,
|
||||
...props.style,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button };
|
||||
|
|
@ -21,7 +21,7 @@ const ListboxButton = React.forwardRef<HTMLButtonElement, ListboxButtonProps>(
|
|||
ref={ref}
|
||||
{...props}
|
||||
className={cn(
|
||||
"border-vsc-input-border bg-vsc-input-background text-vsc-foreground m-0 flex flex-1 cursor-pointer flex-row items-center gap-1 border border-solid px-1 py-0.5 text-left transition-colors duration-200",
|
||||
"bg-vsc-input-background text-vsc-foreground border-border m-0 flex flex-1 cursor-pointer flex-row items-center gap-1 border border-solid px-1 py-0.5 text-left transition-colors duration-200",
|
||||
props.className,
|
||||
)}
|
||||
style={{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { Button, Input, InputSubtext, StyledActionButton } from "../components";
|
||||
import AddModelButtonSubtext from "../components/AddModelButtonSubtext";
|
||||
import { Button, Input, StyledActionButton } from "../components";
|
||||
import Alert from "../components/gui/Alert";
|
||||
import ModelSelectionListbox from "../components/modelSelection/ModelSelectionListbox";
|
||||
import { useAuth } from "../context/Auth";
|
||||
|
|
@ -16,7 +15,7 @@ import {
|
|||
import { useAppDispatch } from "../redux/hooks";
|
||||
import { updateSelectedModelByRole } from "../redux/thunks";
|
||||
|
||||
interface QuickModelSetupProps {
|
||||
interface AddModelFormProps {
|
||||
onDone: () => void;
|
||||
hideFreeTrialLimitMessage?: boolean;
|
||||
}
|
||||
|
|
@ -26,20 +25,18 @@ const MODEL_PROVIDERS_URL =
|
|||
const CODESTRAL_URL = "https://console.mistral.ai/codestral";
|
||||
const CONTINUE_SETUP_URL = "https://docs.continue.dev/setup/overview";
|
||||
|
||||
function AddModelForm({
|
||||
export function AddModelForm({
|
||||
onDone,
|
||||
hideFreeTrialLimitMessage,
|
||||
}: QuickModelSetupProps) {
|
||||
}: AddModelFormProps) {
|
||||
const [selectedProvider, setSelectedProvider] = useState<ProviderInfo>(
|
||||
providers["openai"]!,
|
||||
);
|
||||
const dispatch = useAppDispatch();
|
||||
const { selectedProfile } = useAuth();
|
||||
|
||||
const [selectedModel, setSelectedModel] = useState(
|
||||
selectedProvider.packages[0],
|
||||
);
|
||||
|
||||
const formMethods = useForm();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
|
|
@ -94,6 +91,7 @@ function AddModelForm({
|
|||
function onSubmit() {
|
||||
const apiKey = formMethods.watch("apiKey");
|
||||
const hasValidApiKey = apiKey !== undefined && apiKey !== "";
|
||||
|
||||
const reqInputFields: Record<string, any> = {};
|
||||
for (let input of selectedProvider.collectInputFor ?? []) {
|
||||
reqInputFields[input.key] = formMethods.watch(input.key);
|
||||
|
|
@ -109,11 +107,12 @@ function AddModelForm({
|
|||
};
|
||||
|
||||
ideMessenger.post("config/addModel", { model });
|
||||
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: "local",
|
||||
});
|
||||
|
||||
dispatch(
|
||||
void dispatch(
|
||||
updateSelectedModelByRole({
|
||||
selectedProfile,
|
||||
role: "chat",
|
||||
|
|
@ -134,6 +133,7 @@ function AddModelForm({
|
|||
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
|
||||
<div className="mx-auto max-w-md p-6">
|
||||
<h1 className="mb-0 text-center text-2xl">Add Chat model</h1>
|
||||
|
||||
{/* TODO sync free trial limit with hub */}
|
||||
{/* {!hideFreeTrialLimitMessage && hasPassedFTL() && (
|
||||
<p className="text-sm text-gray-400">
|
||||
|
|
@ -166,7 +166,7 @@ function AddModelForm({
|
|||
topOptions={popularProviders}
|
||||
otherOptions={otherProviders}
|
||||
/>
|
||||
<InputSubtext className="mb-0">
|
||||
<span className="text-description-muted mt-1 block text-xs">
|
||||
Don't see your provider?{" "}
|
||||
<a
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit"
|
||||
|
|
@ -177,7 +177,7 @@ function AddModelForm({
|
|||
Click here
|
||||
</a>{" "}
|
||||
to view the full list
|
||||
</InputSubtext>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{selectedProvider.downloadUrl && (
|
||||
|
|
@ -185,7 +185,6 @@ function AddModelForm({
|
|||
<label className="mb-1 block text-sm font-medium">
|
||||
Install provider
|
||||
</label>
|
||||
|
||||
<StyledActionButton onClick={onClickDownloadProvider}>
|
||||
<p className="text-sm underline">
|
||||
{selectedProvider.downloadUrl}
|
||||
|
|
@ -212,7 +211,7 @@ function AddModelForm({
|
|||
setSelectedModel(match);
|
||||
}
|
||||
}}
|
||||
otherOptions={
|
||||
topOptions={
|
||||
Object.entries(providers).find(
|
||||
([, provider]) =>
|
||||
provider?.title === selectedProvider.title,
|
||||
|
|
@ -242,12 +241,13 @@ function AddModelForm({
|
|||
<Input
|
||||
id="apiKey"
|
||||
className="w-full"
|
||||
type="password"
|
||||
placeholder={`Enter your ${selectedProvider.title} API key`}
|
||||
{...formMethods.register("apiKey")}
|
||||
/>
|
||||
<InputSubtext className="mb-0">
|
||||
<span className="text-description-muted mt-1 block text-xs">
|
||||
<a
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit"
|
||||
className="cursor-pointer text-inherit underline hover:text-inherit hover:brightness-125"
|
||||
onClick={() => {
|
||||
if (selectedProviderApiKeyUrl) {
|
||||
ideMessenger.post(
|
||||
|
|
@ -260,7 +260,7 @@ function AddModelForm({
|
|||
Click here
|
||||
</a>{" "}
|
||||
to create a {selectedProvider.title} API key
|
||||
</InputSubtext>
|
||||
</span>
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -276,7 +276,7 @@ function AddModelForm({
|
|||
field.key !== "apiKey",
|
||||
)
|
||||
.map((field) => (
|
||||
<div>
|
||||
<div key={field.key}>
|
||||
<>
|
||||
<label className="mb-1 block text-sm font-medium">
|
||||
{field.label}
|
||||
|
|
@ -297,7 +297,20 @@ function AddModelForm({
|
|||
<Button type="submit" className="w-full" disabled={isDisabled()}>
|
||||
Connect
|
||||
</Button>
|
||||
<AddModelButtonSubtext />
|
||||
|
||||
<span className="text-description-muted block w-full text-center text-xs">
|
||||
This will update your{" "}
|
||||
<span
|
||||
className="cursor-pointer underline hover:brightness-125"
|
||||
onClick={() =>
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: undefined,
|
||||
})
|
||||
}
|
||||
>
|
||||
config file
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
1
gui/src/forms/index.ts
Normal file
1
gui/src/forms/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./AddModelForm";
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
import { UserCircleIcon } from "@heroicons/react/24/solid";
|
||||
|
||||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { SecondaryButton } from "../../components";
|
||||
import {
|
||||
Popover,
|
||||
PopoverButton,
|
||||
PopoverPanel,
|
||||
Transition,
|
||||
} from "../../components/ui";
|
||||
import { Button } from "../../components/ui/Button";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { selectCurrentOrg } from "../../redux";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
|
|
@ -19,12 +18,13 @@ export function AccountButton() {
|
|||
|
||||
if (!session) {
|
||||
return (
|
||||
<SecondaryButton
|
||||
className="whitespace-nowrap"
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mb-1 whitespace-nowrap py-1"
|
||||
onClick={() => login(false)}
|
||||
>
|
||||
Sign in
|
||||
</SecondaryButton>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ export function AccountButton() {
|
|||
<span className="font-medium">
|
||||
{selectedOrg === null ? "Personal" : selectedOrg.name}
|
||||
</span>
|
||||
<UserCircleIcon className="h-6 w-6" />{" "}
|
||||
<UserCircleIcon className="h-6 w-6" />
|
||||
</div>
|
||||
</PopoverButton>
|
||||
|
||||
|
|
@ -65,9 +65,13 @@ export function AccountButton() {
|
|||
</div>
|
||||
)}
|
||||
|
||||
<SecondaryButton onClick={logout} className="!mx-0 w-full">
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={logout}
|
||||
className="!mx-0 w-full"
|
||||
>
|
||||
Sign out
|
||||
</SecondaryButton>
|
||||
</Button>
|
||||
</div>
|
||||
</PopoverPanel>
|
||||
</Transition>
|
||||
|
|
|
|||
|
|
@ -81,7 +81,12 @@ export function HelpCenterSection() {
|
|||
generateTitle: true,
|
||||
}),
|
||||
);
|
||||
dispatch(setOnboardingCard({ show: true, activeTab: "Best" }));
|
||||
dispatch(
|
||||
setOnboardingCard({
|
||||
show: true,
|
||||
activeTab: undefined,
|
||||
}),
|
||||
);
|
||||
ideMessenger.post("showTutorial", undefined);
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ interface KeyboardShortcutProps {
|
|||
function KeyboardShortcut(props: KeyboardShortcutProps) {
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col items-start p-2 py-2 sm:flex-row sm:items-center ${props.isEven ? "" : "bg-table-oddRow"}`}
|
||||
className={`flex flex-col items-start p-2 sm:flex-row sm:items-center ${props.isEven ? "" : "bg-table-oddRow"}`}
|
||||
>
|
||||
<div className="w-full flex-grow pb-1 pr-4 sm:w-auto sm:pb-0">
|
||||
<span className="block break-words text-xs">{props.description}:</span>
|
||||
|
|
@ -132,8 +132,8 @@ function KeyboardShortcuts() {
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<div className="h-full overflow-auto p-5">
|
||||
<h3 className="mb-5 text-xl">Keyboard shortcuts</h3>
|
||||
<div className="h-full overflow-auto">
|
||||
<h3 className="mb-3 text-xl">Keyboard shortcuts</h3>
|
||||
<div>
|
||||
{shortcuts.map((shortcut, i) => {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ interface ModelRoleSelectorProps {
|
|||
onSelect: (model: ModelDescription | null) => void;
|
||||
displayName: string;
|
||||
description: string;
|
||||
setupURL: string;
|
||||
}
|
||||
|
||||
const ModelRoleSelector = ({
|
||||
|
|
@ -34,6 +35,7 @@ const ModelRoleSelector = ({
|
|||
onSelect,
|
||||
displayName,
|
||||
description,
|
||||
setupURL,
|
||||
}: ModelRoleSelectorProps) => {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [hoveredIdx, setHoveredIdx] = useState<number | null>(null);
|
||||
|
|
@ -65,102 +67,111 @@ const ModelRoleSelector = ({
|
|||
return (
|
||||
<>
|
||||
<div className="mt-2 flex flex-row items-center gap-1 sm:mt-0">
|
||||
<span
|
||||
style={{
|
||||
fontSize: fontSize(-3),
|
||||
}}
|
||||
>
|
||||
{displayName}
|
||||
</span>
|
||||
<span style={{ fontSize: fontSize(-3) }}>{displayName}</span>
|
||||
<InfoHover size="3" id={displayName} msg={description} />
|
||||
<ToolTip id={`${displayName}-description`} place={"bottom"}>
|
||||
{description}
|
||||
</ToolTip>
|
||||
</div>
|
||||
|
||||
<Listbox value={selectedModel?.title ?? null} onChange={handleSelect}>
|
||||
<div className="relative">
|
||||
<ListboxButton
|
||||
disabled={models.length === 0}
|
||||
className={`bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground w-full justify-between`}
|
||||
>
|
||||
{models.length === 0 || noConfiguredModels ? (
|
||||
<span className="text-lightgray line-clamp-1 italic">
|
||||
{`No ${models.length === 0 ? "" : "valid "}${displayName} models${
|
||||
["Chat", "Apply", "Edit"].includes(displayName)
|
||||
? ". Using Chat model"
|
||||
: ""
|
||||
}`}
|
||||
</span>
|
||||
) : (
|
||||
<span className="line-clamp-1">
|
||||
{selectedModel?.title ?? `Select ${displayName} model`}
|
||||
</span>
|
||||
)}
|
||||
{models.length ? (
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon className="h-3 w-3" aria-hidden="true" />
|
||||
</div>
|
||||
) : null}
|
||||
</ListboxButton>
|
||||
|
||||
<Transition>
|
||||
<ListboxOptions
|
||||
style={{ borderRadius: defaultBorderRadius }}
|
||||
className="min-w-40"
|
||||
{models.length === 0 ? (
|
||||
<ListboxButton
|
||||
onClick={() => ideMessenger.post("openUrl", setupURL)}
|
||||
className="bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between px-2 py-1 underline hover:underline"
|
||||
>
|
||||
{[...models]
|
||||
.sort((a, b) => a.title.localeCompare(b.title))
|
||||
.map((option, idx) => {
|
||||
const showMissingApiKeyMsg =
|
||||
option.configurationStatus ===
|
||||
LLMConfigurationStatuses.MISSING_API_KEY;
|
||||
<span className="line-clamp-1" style={{ fontSize: fontSize(-3) }}>
|
||||
Setup {displayName} model
|
||||
</span>
|
||||
</ListboxButton>
|
||||
) : (
|
||||
<>
|
||||
<ListboxButton
|
||||
disabled={models.length === 0}
|
||||
className="bg-vsc-editor-background hover:bg-list-active hover:text-list-active-foreground w-full justify-between px-2 py-1"
|
||||
>
|
||||
{models.length === 0 || noConfiguredModels ? (
|
||||
<span className="text-lightgray line-clamp-1 italic">
|
||||
{`No ${models.length === 0 ? "" : "valid "}${displayName} models${
|
||||
["Chat", "Apply", "Edit"].includes(displayName)
|
||||
? ". Using Chat model"
|
||||
: ""
|
||||
}`}
|
||||
</span>
|
||||
) : (
|
||||
<span className="line-clamp-1">
|
||||
{selectedModel?.title ?? `Select ${displayName} model`}
|
||||
</span>
|
||||
)}
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
key={idx}
|
||||
value={option.title}
|
||||
disabled={showMissingApiKeyMsg}
|
||||
onMouseEnter={() => setHoveredIdx(idx)}
|
||||
onMouseLeave={() => setHoveredIdx(null)}
|
||||
onClick={(e: any) =>
|
||||
handleOptionClick(showMissingApiKeyMsg, e)
|
||||
}
|
||||
className={""}
|
||||
>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<div className="flex flex-1 flex-row items-center justify-between gap-2">
|
||||
<div className="flex flex-1 flex-row items-center gap-2">
|
||||
<CubeIcon className="h-3 w-3 flex-shrink-0" />
|
||||
<span
|
||||
className="line-clamp-1 flex-1"
|
||||
style={{ fontSize: fontSize(-3) }}
|
||||
>
|
||||
{option.title}
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
{models.length > 0 && (
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon className="h-3 w-3" aria-hidden="true" />
|
||||
</div>
|
||||
)}
|
||||
</ListboxButton>
|
||||
<Transition>
|
||||
<ListboxOptions
|
||||
style={{ borderRadius: defaultBorderRadius }}
|
||||
className="min-w-40"
|
||||
>
|
||||
{[...models]
|
||||
.sort((a, b) => a.title.localeCompare(b.title))
|
||||
.map((option, idx) => {
|
||||
const showMissingApiKeyMsg =
|
||||
option.configurationStatus ===
|
||||
LLMConfigurationStatuses.MISSING_API_KEY;
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
key={idx}
|
||||
value={option.title}
|
||||
disabled={showMissingApiKeyMsg}
|
||||
onMouseEnter={() => setHoveredIdx(idx)}
|
||||
onMouseLeave={() => setHoveredIdx(null)}
|
||||
onClick={(e: any) =>
|
||||
handleOptionClick(showMissingApiKeyMsg, e)
|
||||
}
|
||||
className=""
|
||||
>
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<div className="flex flex-1 flex-row items-center justify-between gap-2">
|
||||
<div className="flex flex-1 flex-row items-center gap-2">
|
||||
<CubeIcon className="h-3 w-3 flex-shrink-0" />
|
||||
<span
|
||||
className="line-clamp-1 flex-1"
|
||||
style={{ fontSize: fontSize(-3) }}
|
||||
>
|
||||
{option.title}
|
||||
{showMissingApiKeyMsg && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-shrink-0 flex-row items-center gap-1">
|
||||
{hoveredIdx === idx && (
|
||||
<Cog6ToothIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
onClick={onClickGear}
|
||||
/>
|
||||
)}
|
||||
{option.title === selectedModel?.title && (
|
||||
<CheckIcon className="h-3 w-3 flex-shrink-0" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-shrink-0 flex-row items-center gap-1">
|
||||
{hoveredIdx === idx && (
|
||||
<Cog6ToothIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
onClick={onClickGear}
|
||||
/>
|
||||
)}
|
||||
{option.title === selectedModel?.title && (
|
||||
<CheckIcon className="h-3 w-3 flex-shrink-0" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
})}
|
||||
</ListboxOptions>
|
||||
</Transition>
|
||||
</ListboxOption>
|
||||
);
|
||||
})}
|
||||
</ListboxOptions>
|
||||
</Transition>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Listbox>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import { streamEditThunk } from "../../redux/thunks/edit";
|
|||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
||||
|
||||
import { OnboardingModes } from "core/protocol/core";
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { EmptyChatBody } from "./EmptyChatBody";
|
||||
import { ExploreDialogWatcher } from "./ExploreDialogWatcher";
|
||||
|
|
@ -201,9 +202,9 @@ export function Chat() {
|
|||
// "You've reached the free trial limit. Please configure a model to continue.",
|
||||
// );
|
||||
|
||||
// // Card in chat will only show if no history
|
||||
// // Also, note that platform card ignore the "Best", always opens to main tab
|
||||
// onboardingCard.open("Best");
|
||||
// Card in chat will only show if no history
|
||||
// Also, note that platform card ignore the "Best", always opens to main tab
|
||||
onboardingCard.open(OnboardingModes.API_KEY);
|
||||
|
||||
// // If history, show the dialog, which will automatically close if there is not history
|
||||
// if (history.length) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { ConversationStarterCards } from "../../components/ConversationStarters";
|
||||
import { ExploreHubCard } from "../../components/ExploreHubCard";
|
||||
import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { PlatformOnboardingCard } from "../../components/OnboardingCard/platform/PlatformOnboardingCard";
|
||||
|
||||
export interface EmptyChatBodyProps {
|
||||
showOnboardingCard?: boolean;
|
||||
|
|
@ -11,12 +10,7 @@ export function EmptyChatBody({ showOnboardingCard }: EmptyChatBodyProps) {
|
|||
if (showOnboardingCard) {
|
||||
return (
|
||||
<div className="mx-2 mt-6">
|
||||
{true ? (
|
||||
// For now we are excluding local onboarding options other than ollama
|
||||
<PlatformOnboardingCard isDialog={false} />
|
||||
) : (
|
||||
<OnboardingCard isDialog={false} />
|
||||
)}
|
||||
<OnboardingCard />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export type ConfigState = {
|
|||
config: BrowserSerializedContinueConfig;
|
||||
};
|
||||
|
||||
const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
||||
export const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
||||
slashCommands: [
|
||||
{
|
||||
name: "share",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ export * from "./cancelStream";
|
|||
export * from "./edit";
|
||||
export * from "./gatherContext";
|
||||
export * from "./resetStateForNewMessage";
|
||||
export * from "./selectFirstHubProfile";
|
||||
export * from "./streamNormalInput";
|
||||
export * from "./streamResponse";
|
||||
export * from "./streamResponseAfterToolCall";
|
||||
|
|
|
|||
56
gui/src/redux/thunks/selectFirstHubProfile.ts
Normal file
56
gui/src/redux/thunks/selectFirstHubProfile.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { setSelectedProfile } from "../slices";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
||||
/**
|
||||
* If there is a hub profile, select it.
|
||||
* Used primarily after onboarding when a new profile is created and we
|
||||
* want to switch to it immediately
|
||||
*/
|
||||
export const selectFirstHubProfile = createAsyncThunk<
|
||||
void,
|
||||
undefined,
|
||||
ThunkApiType
|
||||
>("selectFirstHubProfile", async (_, { dispatch, extra, getState }) => {
|
||||
let attempts = 0;
|
||||
const maxAttempts = 3;
|
||||
|
||||
const findAndSelectProfile = () => {
|
||||
const state = getState();
|
||||
|
||||
const currentOrgProfiles = state.profiles.organizations.find(
|
||||
(org) => org.id === (state.profiles.selectedOrganizationId ?? "personal"),
|
||||
);
|
||||
|
||||
const firstHubProfile = currentOrgProfiles?.profiles.find(
|
||||
(profile) => profile.profileType === "platform",
|
||||
);
|
||||
|
||||
if (firstHubProfile) {
|
||||
dispatch(setSelectedProfile(firstHubProfile.id));
|
||||
extra.ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: firstHubProfile.id,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// Try immediately first
|
||||
if (findAndSelectProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If not found, poll every second for up to maxAttempts
|
||||
return new Promise<void>((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
attempts++;
|
||||
|
||||
if (findAndSelectProfile() || attempts >= maxAttempts) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
|
@ -57,6 +57,129 @@ describe("addToolCallDeltaToState", () => {
|
|||
expect(result.toolCall.function.name).toBe("searchFiles");
|
||||
});
|
||||
|
||||
it("should handle name streaming in full progressive chunks", () => {
|
||||
// Test case where model streams the name progressively but includes full prefix each time
|
||||
// e.g. "readFi" -> "readFil" -> "readFile"
|
||||
const currentState: ToolCallState = {
|
||||
status: "generating",
|
||||
toolCall: {
|
||||
id: "call123",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "readFi",
|
||||
arguments: "{}",
|
||||
},
|
||||
},
|
||||
toolCallId: "call123",
|
||||
parsedArgs: {},
|
||||
};
|
||||
|
||||
const delta: ToolCallDelta = {
|
||||
function: {
|
||||
name: "readFil",
|
||||
},
|
||||
};
|
||||
|
||||
const result = addToolCallDeltaToState(delta, currentState);
|
||||
expect(result.toolCall.function.name).toBe("readFil");
|
||||
|
||||
// Continue the streaming
|
||||
const nextDelta: ToolCallDelta = {
|
||||
function: {
|
||||
name: "readFile",
|
||||
},
|
||||
};
|
||||
|
||||
const finalResult = addToolCallDeltaToState(nextDelta, result);
|
||||
expect(finalResult.toolCall.function.name).toBe("readFile");
|
||||
});
|
||||
|
||||
it("should keep original name when receiving duplicate name chunks", () => {
|
||||
// Test case where model streams the complete name multiple times
|
||||
// e.g. "readFile" -> "readFile" -> "readFile"
|
||||
const currentState: ToolCallState = {
|
||||
status: "generating",
|
||||
toolCall: {
|
||||
id: "call123",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "readFile",
|
||||
arguments: "{}",
|
||||
},
|
||||
},
|
||||
toolCallId: "call123",
|
||||
parsedArgs: {},
|
||||
};
|
||||
|
||||
const delta: ToolCallDelta = {
|
||||
function: {
|
||||
name: "readFile",
|
||||
},
|
||||
};
|
||||
|
||||
const result = addToolCallDeltaToState(delta, currentState);
|
||||
expect(result.toolCall.function.name).toBe("readFile");
|
||||
});
|
||||
|
||||
it("should handle partial name streaming", () => {
|
||||
// Test case where model streams the name in parts
|
||||
// e.g. "read" -> "File"
|
||||
const currentState: ToolCallState = {
|
||||
status: "generating",
|
||||
toolCall: {
|
||||
id: "call123",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "read",
|
||||
arguments: "{}",
|
||||
},
|
||||
},
|
||||
toolCallId: "call123",
|
||||
parsedArgs: {},
|
||||
};
|
||||
|
||||
const delta: ToolCallDelta = {
|
||||
function: {
|
||||
name: "File",
|
||||
},
|
||||
};
|
||||
|
||||
const result = addToolCallDeltaToState(delta, currentState);
|
||||
expect(result.toolCall.function.name).toBe("readFile");
|
||||
});
|
||||
|
||||
it("should ignore new tool calls with different IDs", () => {
|
||||
const currentState: ToolCallState = {
|
||||
status: "generating",
|
||||
toolCall: {
|
||||
id: "call123",
|
||||
type: "function",
|
||||
function: {
|
||||
name: "searchFiles",
|
||||
arguments: '{"query":"test"}',
|
||||
},
|
||||
},
|
||||
toolCallId: "call123",
|
||||
parsedArgs: { query: "test" },
|
||||
};
|
||||
|
||||
const delta: ToolCallDelta = {
|
||||
id: "call456", // Different ID
|
||||
type: "function",
|
||||
function: {
|
||||
name: "readFile",
|
||||
arguments: '{"path":"file.txt"}',
|
||||
},
|
||||
};
|
||||
|
||||
const result = addToolCallDeltaToState(delta, currentState);
|
||||
|
||||
// Should keep the original state and ignore the new call
|
||||
expect(result).toBe(currentState);
|
||||
expect(result.toolCall.id).toBe("call123");
|
||||
expect(result.toolCall.function.name).toBe("searchFiles");
|
||||
});
|
||||
|
||||
it("should merge function argument deltas correctly", () => {
|
||||
const currentState: ToolCallState = {
|
||||
status: "generating",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,15 @@ export function addToolCallDeltaToState(
|
|||
toolCallDelta: ToolCallDelta,
|
||||
currentState: ToolCallState | undefined,
|
||||
): ToolCallState {
|
||||
// This prevents multiple tool calls for now, by ignoring new tool call ids
|
||||
if (
|
||||
toolCallDelta.id &&
|
||||
currentState?.toolCallId &&
|
||||
toolCallDelta.id !== currentState?.toolCallId
|
||||
) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
const currentCall = currentState?.toolCall;
|
||||
|
||||
// These will/should not be partially streamed
|
||||
|
|
@ -21,9 +30,18 @@ export function addToolCallDeltaToState(
|
|||
const nameDelta = toolCallDelta.function?.name ?? "";
|
||||
const argsDelta = toolCallDelta.function?.arguments ?? "";
|
||||
|
||||
// Some models may include the name repeatedly. This doesn't account for an edge case where the name is like "dothisdothis" and it happens to stream name in chunks "dothis" and "dothis" but that's a super edge case
|
||||
const mergedName =
|
||||
currentName === nameDelta ? currentName : currentName + nameDelta;
|
||||
let mergedName = currentName;
|
||||
if (nameDelta.startsWith(currentName)) {
|
||||
// Case where model progresssively streams name but full name each time e.g. "readFi" -> "readFil" -> "readFile"
|
||||
mergedName = nameDelta;
|
||||
} else if (currentName.startsWith(nameDelta)) {
|
||||
// Case where model streams in full name each time e.g. readFile -> readFile -> readFile
|
||||
// do nothing
|
||||
} else {
|
||||
// Case where model streams in name in parts e.g. "read" -> "File"
|
||||
mergedName = currentName + nameDelta;
|
||||
}
|
||||
|
||||
const mergedArgs = currentArgs + argsDelta;
|
||||
|
||||
const [_, parsedArgs] = incrementalParseJson(mergedArgs || "{}");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ scipy==1.7.1
|
|||
|
||||
# Web development
|
||||
flask==2.0.2
|
||||
django==3.2.7
|
||||
django==4.2.22
|
||||
|
||||
# Request handling
|
||||
requests==2.26.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as YAML from "yaml";
|
||||
import { ZodError } from "zod";
|
||||
import { PlatformClient, Registry } from "../interfaces/index.js";
|
||||
import { encodeSecretLocation } from "../interfaces/SecretResult.js";
|
||||
import {
|
||||
|
|
@ -17,6 +18,7 @@ import {
|
|||
configYamlSchema,
|
||||
Rule,
|
||||
} from "../schemas/index.js";
|
||||
import { ConfigResult, ConfigValidationError } from "../validation.js";
|
||||
import {
|
||||
packageIdentifierToShorthandSlug,
|
||||
useProxyForUnrenderedSecrets,
|
||||
|
|
@ -30,16 +32,25 @@ export function parseConfigYaml(configYaml: string): ConfigYaml {
|
|||
if (result.success) {
|
||||
return result.data;
|
||||
}
|
||||
throw new Error(
|
||||
result.error.errors
|
||||
.map((e) => `${e.path.join(".")}: ${e.message}`)
|
||||
.join(""),
|
||||
);
|
||||
|
||||
throw new Error(formatZodError(result.error), {
|
||||
cause: "result.success was false",
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("Failed to parse rolled assistant:", configYaml);
|
||||
throw new Error(
|
||||
`Failed to parse assistant:\n${e instanceof Error ? e.message : e}`,
|
||||
);
|
||||
console.error("Failed to parse rolled assistant:", configYaml);
|
||||
if (
|
||||
e instanceof Error &&
|
||||
"cause" in e &&
|
||||
e.cause === "result.success was false"
|
||||
) {
|
||||
throw new Error(`Failed to parse assistant: ${e.message}`);
|
||||
} else if (e instanceof ZodError) {
|
||||
throw new Error(`Failed to parse assistant: ${formatZodError(e)}`);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Failed to parse assistant: ${e instanceof Error ? e.message : e}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,9 +60,10 @@ export function parseAssistantUnrolled(configYaml: string): AssistantUnrolled {
|
|||
const result = assistantUnrolledSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(
|
||||
console.error(
|
||||
`Failed to parse unrolled assistant: ${e.message}\n\n${configYaml}`,
|
||||
);
|
||||
throw new Error(`Failed to parse unrolled assistant: ${formatZodError(e)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +73,7 @@ export function parseBlock(configYaml: string): Block {
|
|||
const result = blockSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse block: ${e.message}`);
|
||||
throw new Error(`Failed to parse block: ${formatZodError(e)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +195,7 @@ async function extractRenderedSecretsMap(
|
|||
export interface BaseUnrollAssistantOptions {
|
||||
renderSecrets: boolean;
|
||||
injectBlocks?: PackageIdentifier[];
|
||||
asConfigResult?: true;
|
||||
}
|
||||
|
||||
export interface DoNotRenderSecretsUnrollAssistantOptions
|
||||
|
|
@ -204,14 +217,30 @@ export type UnrollAssistantOptions =
|
|||
| DoNotRenderSecretsUnrollAssistantOptions
|
||||
| RenderSecretsUnrollAssistantOptions;
|
||||
|
||||
// Overload to satisfy existing consumers of unrollAssistant.
|
||||
export async function unrollAssistant(
|
||||
id: PackageIdentifier,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions & { asConfigResult: true },
|
||||
): Promise<ConfigResult<AssistantUnrolled>>;
|
||||
|
||||
export async function unrollAssistant(
|
||||
id: PackageIdentifier,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions,
|
||||
): Promise<AssistantUnrolled> {
|
||||
): Promise<AssistantUnrolled>;
|
||||
|
||||
export async function unrollAssistant(
|
||||
id: PackageIdentifier,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions,
|
||||
): Promise<AssistantUnrolled | ConfigResult<AssistantUnrolled>> {
|
||||
// Request the content from the registry
|
||||
const rawContent = await registry.getContent(id);
|
||||
return unrollAssistantFromContent(id, rawContent, registry, options);
|
||||
|
||||
const result = unrollAssistantFromContent(id, rawContent, registry, options);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function renderTemplateData(
|
||||
|
|
@ -236,7 +265,7 @@ export async function unrollAssistantFromContent(
|
|||
rawYaml: string,
|
||||
registry: Registry,
|
||||
options: UnrollAssistantOptions,
|
||||
): Promise<AssistantUnrolled> {
|
||||
): Promise<AssistantUnrolled | ConfigResult<AssistantUnrolled>> {
|
||||
// Parse string to Zod-validated YAML
|
||||
let parsedYaml = parseConfigYaml(rawYaml);
|
||||
|
||||
|
|
@ -245,10 +274,15 @@ export async function unrollAssistantFromContent(
|
|||
parsedYaml,
|
||||
registry,
|
||||
options.injectBlocks,
|
||||
options.asConfigResult ?? false,
|
||||
);
|
||||
|
||||
// Back to a string so we can fill in template variables
|
||||
const rawUnrolledYaml = YAML.stringify(unrolledAssistant);
|
||||
const rawUnrolledYaml = options.asConfigResult
|
||||
? YAML.stringify(
|
||||
(unrolledAssistant as ConfigResult<AssistantUnrolled>).config,
|
||||
)
|
||||
: YAML.stringify(unrolledAssistant);
|
||||
|
||||
// Convert all of the template variables to FQSNs
|
||||
// Secrets from the block will have the assistant slug prepended to the FQSN
|
||||
|
|
@ -277,6 +311,17 @@ export async function unrollAssistantFromContent(
|
|||
options.orgScopeId,
|
||||
options.onPremProxyUrl,
|
||||
);
|
||||
|
||||
if (options.asConfigResult) {
|
||||
return {
|
||||
config: finalConfig,
|
||||
errors: (unrolledAssistant as ConfigResult<AssistantUnrolled>).errors,
|
||||
configLoadInterrupted: (
|
||||
unrolledAssistant as ConfigResult<AssistantUnrolled>
|
||||
).configLoadInterrupted,
|
||||
};
|
||||
}
|
||||
|
||||
return finalConfig;
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +329,10 @@ export async function unrollBlocks(
|
|||
assistant: ConfigYaml,
|
||||
registry: Registry,
|
||||
injectBlocks: PackageIdentifier[] | undefined,
|
||||
): Promise<AssistantUnrolled> {
|
||||
asConfigError: boolean,
|
||||
): Promise<AssistantUnrolled | ConfigResult<AssistantUnrolled>> {
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
const unrolledAssistant: AssistantUnrolled = {
|
||||
name: assistant.name,
|
||||
version: assistant.version,
|
||||
|
|
@ -316,8 +364,23 @@ export async function unrollBlocks(
|
|||
);
|
||||
}
|
||||
} catch (err) {
|
||||
let msg = "";
|
||||
if (
|
||||
typeof unrolledBlock.uses !== "string" &&
|
||||
"filePath" in unrolledBlock.uses
|
||||
) {
|
||||
msg = `${(err as Error).message}.\n> ${unrolledBlock.uses.filePath}`;
|
||||
} else {
|
||||
msg = `${(err as Error).message}.\n> ${JSON.stringify(unrolledBlock.uses)}`;
|
||||
}
|
||||
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: msg,
|
||||
});
|
||||
|
||||
console.error(
|
||||
`Failed to unroll block ${unrolledBlock.uses}: ${(err as Error).message}`,
|
||||
`Failed to unroll block ${JSON.stringify(unrolledBlock.uses)}: ${(err as Error).message}`,
|
||||
);
|
||||
sectionBlocks.push(null);
|
||||
}
|
||||
|
|
@ -349,6 +412,11 @@ export async function unrollBlocks(
|
|||
rules.push(block);
|
||||
}
|
||||
} catch (err) {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: `${(err as Error).message}:\n${rule.uses}`,
|
||||
});
|
||||
|
||||
console.error(
|
||||
`Failed to unroll block ${rule.uses}: ${(err as Error).message}`,
|
||||
);
|
||||
|
|
@ -381,12 +449,36 @@ export async function unrollBlocks(
|
|||
);
|
||||
}
|
||||
} catch (err) {
|
||||
let msg = "";
|
||||
if (injectBlock.uriType === "file") {
|
||||
msg = `${(err as Error).message}.\n> ${injectBlock.filePath}`;
|
||||
} else {
|
||||
msg = `${(err as Error).message}.\n> ${injectBlock.fullSlug}`;
|
||||
}
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message: msg,
|
||||
});
|
||||
|
||||
console.error(
|
||||
`Failed to unroll block ${injectBlock}: ${(err as Error).message}`,
|
||||
`Failed to unroll block ${JSON.stringify(injectBlock)}: ${(err as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (asConfigError) {
|
||||
const configResult: ConfigResult<AssistantUnrolled> = {
|
||||
config: undefined,
|
||||
errors: undefined,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
configResult.config = unrolledAssistant;
|
||||
if (errors.length > 0) {
|
||||
configResult.errors = errors;
|
||||
}
|
||||
return configResult;
|
||||
}
|
||||
|
||||
return unrolledAssistant;
|
||||
}
|
||||
|
||||
|
|
@ -439,3 +531,15 @@ export function mergeOverrides<T extends Record<string, any>>(
|
|||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
function formatZodError(error: any): string {
|
||||
if (error.errors && Array.isArray(error.errors)) {
|
||||
return error.errors
|
||||
.map((e: any) => {
|
||||
const path = e.path.length > 0 ? `${e.path.join(".")}: ` : "";
|
||||
return `${path}${e.message}`;
|
||||
})
|
||||
.join(", ");
|
||||
}
|
||||
return error.message || "Validation failed";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const contextSchema = z.object({
|
|||
const mcpServerSchema = z.object({
|
||||
name: z.string(),
|
||||
command: z.string().optional(),
|
||||
type: z.enum(["sse", "stdio"]).optional(),
|
||||
type: z.enum(["sse", "stdio", "streamable-http"]).optional(),
|
||||
url: z.string().optional(),
|
||||
faviconUrl: z.string().optional(),
|
||||
args: z.array(z.string()).optional(),
|
||||
|
|
|
|||
|
|
@ -106,6 +106,17 @@ const templateSchema = z.enum([
|
|||
"codestral",
|
||||
]);
|
||||
|
||||
export const autocompleteOptionsSchema = z.object({
|
||||
disable: z.boolean().optional(),
|
||||
maxPromptTokens: z.number().optional(),
|
||||
debounceDelay: z.number().optional(),
|
||||
modelTimeout: z.number().optional(),
|
||||
maxSuffixPercentage: z.number().optional(),
|
||||
prefixPercentage: z.number().optional(),
|
||||
template: z.string().optional(),
|
||||
onlyMyCode: z.boolean().optional(),
|
||||
});
|
||||
|
||||
/** Prompt templates use Handlebars syntax */
|
||||
const promptTemplatesSchema = z.object({
|
||||
apply: z.string().optional(),
|
||||
|
|
@ -133,6 +144,7 @@ const baseModelFields = {
|
|||
env: z
|
||||
.record(z.string(), z.union([z.string(), z.boolean(), z.number()]))
|
||||
.optional(),
|
||||
autocompleteOptions: autocompleteOptionsSchema.optional(),
|
||||
};
|
||||
|
||||
export const modelSchema = z.union([
|
||||
|
|
|
|||
267
packages/fetch/package-lock.json
generated
267
packages/fetch/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@continuedev/fetch",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/fetch",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
|
|
@ -17,8 +17,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/follow-redirects": "^1.14.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"vitest": "^3.2.0"
|
||||
}
|
||||
},
|
||||
|
|
@ -30,28 +28,6 @@
|
|||
"zod": "^3.23.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-support": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
||||
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
||||
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.0.3",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.5",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz",
|
||||
|
|
@ -452,15 +428,6 @@
|
|||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/resolve-uri": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
|
||||
|
|
@ -727,30 +694,6 @@
|
|||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@tsconfig/node10": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
||||
"integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@tsconfig/node12": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
|
||||
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@tsconfig/node14": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
|
||||
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@tsconfig/node16": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
||||
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/chai": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.2.tgz",
|
||||
|
|
@ -897,30 +840,6 @@
|
|||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.14.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz",
|
||||
"integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-walk": {
|
||||
"version": "8.3.4",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
|
||||
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.11.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz",
|
||||
|
|
@ -932,12 +851,6 @@
|
|||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/arg": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
||||
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/assertion-error": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||
|
|
@ -981,44 +894,6 @@
|
|||
"node": ">= 16"
|
||||
}
|
||||
},
|
||||
"node_modules/create-require": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
|
||||
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"cross-env": "src/bin/cross-env.js",
|
||||
"cross-env-shell": "src/bin/cross-env-shell.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.14",
|
||||
"npm": ">=6",
|
||||
"yarn": ">=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"path-key": "^3.1.0",
|
||||
"shebang-command": "^2.0.0",
|
||||
"which": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
|
|
@ -1052,15 +927,6 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-module-lexer": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
|
||||
|
|
@ -1215,12 +1081,6 @@
|
|||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/loupe": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz",
|
||||
|
|
@ -1236,12 +1096,6 @@
|
|||
"@jridgewell/sourcemap-codec": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/make-error": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
|
|
@ -1300,15 +1154,6 @@
|
|||
"url": "https://opencollective.com/node-fetch"
|
||||
}
|
||||
},
|
||||
"node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pathe": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
|
||||
|
|
@ -1397,27 +1242,6 @@
|
|||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"shebang-regex": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/siginfo": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
|
||||
|
|
@ -1526,75 +1350,12 @@
|
|||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-node": {
|
||||
"version": "10.9.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
|
||||
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-support": "^0.8.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@tsconfig/node14": "^1.0.0",
|
||||
"@tsconfig/node16": "^1.0.2",
|
||||
"acorn": "^8.4.1",
|
||||
"acorn-walk": "^8.1.1",
|
||||
"arg": "^4.1.0",
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"v8-compile-cache-lib": "^3.0.1",
|
||||
"yn": "3.1.1"
|
||||
},
|
||||
"bin": {
|
||||
"ts-node": "dist/bin.js",
|
||||
"ts-node-cwd": "dist/bin-cwd.js",
|
||||
"ts-node-esm": "dist/bin-esm.js",
|
||||
"ts-node-script": "dist/bin-script.js",
|
||||
"ts-node-transpile-only": "dist/bin-transpile.js",
|
||||
"ts-script": "dist/bin-script-deprecated.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@swc/core": ">=1.2.50",
|
||||
"@swc/wasm": ">=1.2.50",
|
||||
"@types/node": "*",
|
||||
"typescript": ">=2.7"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@swc/core": {
|
||||
"optional": true
|
||||
},
|
||||
"@swc/wasm": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/v8-compile-cache-lib": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
|
||||
|
|
@ -1809,21 +1570,6 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"isexe": "^2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"node-which": "bin/node-which"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/why-is-node-running": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
|
||||
|
|
@ -1840,15 +1586,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/yn": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
|
||||
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/fetch",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ import { RequestOptions } from "@continuedev/config-types";
|
|||
import * as followRedirects from "follow-redirects";
|
||||
import { HttpProxyAgent } from "http-proxy-agent";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
import fetch, { BodyInit, RequestInit, Response } from "node-fetch";
|
||||
import { BodyInit, RequestInit, Response } from "node-fetch";
|
||||
import { getAgentOptions } from "./getAgentOptions.js";
|
||||
import fetch from "./node-fetch-patch.js";
|
||||
import { getProxyFromEnv, shouldBypassProxy } from "./util.js";
|
||||
|
||||
const { http, https } = (followRedirects as any).default;
|
||||
|
|
|
|||
518
packages/fetch/src/node-fetch-patch.js
Normal file
518
packages/fetch/src/node-fetch-patch.js
Normal file
|
|
@ -0,0 +1,518 @@
|
|||
/*
|
||||
This is a patched version of index.js from node-fetch 3.3.2 (see packages/fetch/node_modules/node-fetch/src/index.js)
|
||||
This is to fix "Premature close" errors caused by chunked encoding assumptions - see https://github.com/continuedev/continue/issues/5502
|
||||
The patch adjusts boundary chunk detection logic (see "PATCH" comment next to patch)
|
||||
And is based on https://github.com/node-fetch/node-fetch/issues/1576
|
||||
*/
|
||||
|
||||
/**
|
||||
* Index.js
|
||||
*
|
||||
* a request API compatible with window.fetch
|
||||
*
|
||||
* All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
|
||||
*/
|
||||
|
||||
import { Buffer } from "node:buffer";
|
||||
import http from "node:http";
|
||||
import https from "node:https";
|
||||
import Stream, { PassThrough, pipeline as pump } from "node:stream";
|
||||
import zlib from "node:zlib";
|
||||
|
||||
import dataUriToBuffer from "data-uri-to-buffer";
|
||||
|
||||
import {
|
||||
Blob,
|
||||
blobFrom,
|
||||
blobFromSync,
|
||||
File,
|
||||
fileFrom,
|
||||
fileFromSync,
|
||||
} from "fetch-blob/from.js";
|
||||
import { FormData } from "formdata-polyfill/esm.min.js";
|
||||
import { clone, writeToStream } from "node-fetch/src/body.js";
|
||||
import { AbortError } from "node-fetch/src/errors/abort-error.js";
|
||||
import { FetchError } from "node-fetch/src/errors/fetch-error.js";
|
||||
import Headers, { fromRawHeaders } from "node-fetch/src/headers.js";
|
||||
import Request, { getNodeRequestOptions } from "node-fetch/src/request.js";
|
||||
import Response from "node-fetch/src/response.js";
|
||||
import { isRedirect } from "node-fetch/src/utils/is-redirect.js";
|
||||
import {
|
||||
isDomainOrSubdomain,
|
||||
isSameProtocol,
|
||||
} from "node-fetch/src/utils/is.js";
|
||||
import { parseReferrerPolicyFromHeader } from "node-fetch/src/utils/referrer.js";
|
||||
|
||||
export {
|
||||
AbortError,
|
||||
Blob,
|
||||
blobFrom,
|
||||
blobFromSync,
|
||||
FetchError,
|
||||
File,
|
||||
fileFrom,
|
||||
fileFromSync,
|
||||
FormData,
|
||||
Headers,
|
||||
isRedirect,
|
||||
Request,
|
||||
Response,
|
||||
};
|
||||
|
||||
const supportedSchemas = new Set(["data:", "http:", "https:"]);
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*
|
||||
* @param {string | URL | import('./request').default} url - Absolute url or Request instance
|
||||
* @param {*} [options_] - Fetch options
|
||||
* @return {Promise<import('./response').default>}
|
||||
*/
|
||||
export default async function fetch(url, options_) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Build request object
|
||||
const request = new Request(url, options_);
|
||||
const { parsedURL, options } = getNodeRequestOptions(request);
|
||||
if (!supportedSchemas.has(parsedURL.protocol)) {
|
||||
throw new TypeError(
|
||||
`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (parsedURL.protocol === "data:") {
|
||||
const data = dataUriToBuffer(request.url);
|
||||
const response = new Response(data, {
|
||||
headers: { "Content-Type": data.typeFull },
|
||||
});
|
||||
resolve(response);
|
||||
return;
|
||||
}
|
||||
|
||||
// Wrap http.request into fetch
|
||||
const send = (parsedURL.protocol === "https:" ? https : http).request;
|
||||
const { signal } = request;
|
||||
let response = null;
|
||||
|
||||
const abort = () => {
|
||||
const error = new AbortError("The operation was aborted.");
|
||||
reject(error);
|
||||
if (request.body && request.body instanceof Stream.Readable) {
|
||||
request.body.destroy(error);
|
||||
}
|
||||
|
||||
if (!response || !response.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
response.body.emit("error", error);
|
||||
};
|
||||
|
||||
if (signal && signal.aborted) {
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
||||
const abortAndFinalize = () => {
|
||||
abort();
|
||||
finalize();
|
||||
};
|
||||
|
||||
// Send request
|
||||
const request_ = send(parsedURL.toString(), options);
|
||||
|
||||
if (signal) {
|
||||
signal.addEventListener("abort", abortAndFinalize);
|
||||
}
|
||||
|
||||
const finalize = () => {
|
||||
request_.abort();
|
||||
if (signal) {
|
||||
signal.removeEventListener("abort", abortAndFinalize);
|
||||
}
|
||||
};
|
||||
|
||||
request_.on("error", (error) => {
|
||||
reject(
|
||||
new FetchError(
|
||||
`request to ${request.url} failed, reason: ${error.message}`,
|
||||
"system",
|
||||
error,
|
||||
),
|
||||
);
|
||||
finalize();
|
||||
});
|
||||
|
||||
fixResponseChunkedTransferBadEnding(request_, (error) => {
|
||||
if (response && response.body) {
|
||||
response.body.destroy(error);
|
||||
}
|
||||
});
|
||||
|
||||
/* c8 ignore next 18 */
|
||||
if (process.version < "v14") {
|
||||
// Before Node.js 14, pipeline() does not fully support async iterators and does not always
|
||||
// properly handle when the socket close/end events are out of order.
|
||||
request_.on("socket", (s) => {
|
||||
let endedWithEventsCount;
|
||||
s.prependListener("end", () => {
|
||||
endedWithEventsCount = s._eventsCount;
|
||||
});
|
||||
s.prependListener("close", (hadError) => {
|
||||
// if end happened before close but the socket didn't emit an error, do it now
|
||||
if (response && endedWithEventsCount < s._eventsCount && !hadError) {
|
||||
const error = new Error("Premature close");
|
||||
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
||||
response.body.emit("error", error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
request_.on("response", (response_) => {
|
||||
request_.setTimeout(0);
|
||||
const headers = fromRawHeaders(response_.rawHeaders);
|
||||
|
||||
// HTTP fetch step 5
|
||||
if (isRedirect(response_.statusCode)) {
|
||||
// HTTP fetch step 5.2
|
||||
const location = headers.get("Location");
|
||||
|
||||
// HTTP fetch step 5.3
|
||||
let locationURL = null;
|
||||
try {
|
||||
locationURL =
|
||||
location === null ? null : new URL(location, request.url);
|
||||
} catch {
|
||||
// error here can only be invalid URL in Location: header
|
||||
// do not throw when options.redirect == manual
|
||||
// let the user extract the errorneous redirect URL
|
||||
if (request.redirect !== "manual") {
|
||||
reject(
|
||||
new FetchError(
|
||||
`uri requested responds with an invalid redirect URL: ${location}`,
|
||||
"invalid-redirect",
|
||||
),
|
||||
);
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP fetch step 5.5
|
||||
switch (request.redirect) {
|
||||
case "error":
|
||||
reject(
|
||||
new FetchError(
|
||||
`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`,
|
||||
"no-redirect",
|
||||
),
|
||||
);
|
||||
finalize();
|
||||
return;
|
||||
case "manual":
|
||||
// Nothing to do
|
||||
break;
|
||||
case "follow": {
|
||||
// HTTP-redirect fetch step 2
|
||||
if (locationURL === null) {
|
||||
break;
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 5
|
||||
if (request.counter >= request.follow) {
|
||||
reject(
|
||||
new FetchError(
|
||||
`maximum redirect reached at: ${request.url}`,
|
||||
"max-redirect",
|
||||
),
|
||||
);
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 6 (counter increment)
|
||||
// Create a new Request object.
|
||||
const requestOptions = {
|
||||
headers: new Headers(request.headers),
|
||||
follow: request.follow,
|
||||
counter: request.counter + 1,
|
||||
agent: request.agent,
|
||||
compress: request.compress,
|
||||
method: request.method,
|
||||
body: clone(request),
|
||||
signal: request.signal,
|
||||
size: request.size,
|
||||
referrer: request.referrer,
|
||||
referrerPolicy: request.referrerPolicy,
|
||||
};
|
||||
|
||||
// when forwarding sensitive headers like "Authorization",
|
||||
// "WWW-Authenticate", and "Cookie" to untrusted targets,
|
||||
// headers will be ignored when following a redirect to a domain
|
||||
// that is not a subdomain match or exact match of the initial domain.
|
||||
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
|
||||
// will forward the sensitive headers, but a redirect to "bar.com" will not.
|
||||
// headers will also be ignored when following a redirect to a domain using
|
||||
// a different protocol. For example, a redirect from "https://foo.com" to "http://foo.com"
|
||||
// will not forward the sensitive headers
|
||||
if (
|
||||
!isDomainOrSubdomain(request.url, locationURL) ||
|
||||
!isSameProtocol(request.url, locationURL)
|
||||
) {
|
||||
for (const name of [
|
||||
"authorization",
|
||||
"www-authenticate",
|
||||
"cookie",
|
||||
"cookie2",
|
||||
]) {
|
||||
requestOptions.headers.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 9
|
||||
if (
|
||||
response_.statusCode !== 303 &&
|
||||
request.body &&
|
||||
options_.body instanceof Stream.Readable
|
||||
) {
|
||||
reject(
|
||||
new FetchError(
|
||||
"Cannot follow redirect with body being a readable stream",
|
||||
"unsupported-redirect",
|
||||
),
|
||||
);
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 11
|
||||
if (
|
||||
response_.statusCode === 303 ||
|
||||
((response_.statusCode === 301 || response_.statusCode === 302) &&
|
||||
request.method === "POST")
|
||||
) {
|
||||
requestOptions.method = "GET";
|
||||
requestOptions.body = undefined;
|
||||
requestOptions.headers.delete("content-length");
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 14
|
||||
const responseReferrerPolicy =
|
||||
parseReferrerPolicyFromHeader(headers);
|
||||
if (responseReferrerPolicy) {
|
||||
requestOptions.referrerPolicy = responseReferrerPolicy;
|
||||
}
|
||||
|
||||
// HTTP-redirect fetch step 15
|
||||
resolve(fetch(new Request(locationURL, requestOptions)));
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
return reject(
|
||||
new TypeError(
|
||||
`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare response
|
||||
if (signal) {
|
||||
response_.once("end", () => {
|
||||
signal.removeEventListener("abort", abortAndFinalize);
|
||||
});
|
||||
}
|
||||
|
||||
let body = pump(response_, new PassThrough(), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
// see https://github.com/nodejs/node/pull/29376
|
||||
/* c8 ignore next 3 */
|
||||
if (process.version < "v12.10") {
|
||||
response_.on("aborted", abortAndFinalize);
|
||||
}
|
||||
|
||||
const responseOptions = {
|
||||
url: request.url,
|
||||
status: response_.statusCode,
|
||||
statusText: response_.statusMessage,
|
||||
headers,
|
||||
size: request.size,
|
||||
counter: request.counter,
|
||||
highWaterMark: request.highWaterMark,
|
||||
};
|
||||
|
||||
// HTTP-network fetch step 12.1.1.3
|
||||
const codings = headers.get("Content-Encoding");
|
||||
|
||||
// HTTP-network fetch step 12.1.1.4: handle content codings
|
||||
|
||||
// in following scenarios we ignore compression support
|
||||
// 1. compression support is disabled
|
||||
// 2. HEAD request
|
||||
// 3. no Content-Encoding header
|
||||
// 4. no content response (204)
|
||||
// 5. content not modified response (304)
|
||||
if (
|
||||
!request.compress ||
|
||||
request.method === "HEAD" ||
|
||||
codings === null ||
|
||||
response_.statusCode === 204 ||
|
||||
response_.statusCode === 304
|
||||
) {
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
return;
|
||||
}
|
||||
|
||||
// For Node v6+
|
||||
// Be less strict when decoding compressed responses, since sometimes
|
||||
// servers send slightly invalid responses that are still accepted
|
||||
// by common browsers.
|
||||
// Always using Z_SYNC_FLUSH is what cURL does.
|
||||
const zlibOptions = {
|
||||
flush: zlib.Z_SYNC_FLUSH,
|
||||
finishFlush: zlib.Z_SYNC_FLUSH,
|
||||
};
|
||||
|
||||
// For gzip
|
||||
if (codings === "gzip" || codings === "x-gzip") {
|
||||
body = pump(body, zlib.createGunzip(zlibOptions), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
return;
|
||||
}
|
||||
|
||||
// For deflate
|
||||
if (codings === "deflate" || codings === "x-deflate") {
|
||||
// Handle the infamous raw deflate response from old servers
|
||||
// a hack for old IIS and Apache servers
|
||||
const raw = pump(response_, new PassThrough(), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
raw.once("data", (chunk) => {
|
||||
// See http://stackoverflow.com/questions/37519828
|
||||
if ((chunk[0] & 0x0f) === 0x08) {
|
||||
body = pump(body, zlib.createInflate(), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
body = pump(body, zlib.createInflateRaw(), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
});
|
||||
raw.once("end", () => {
|
||||
// Some old IIS servers return zero-length OK deflate responses, so
|
||||
// 'data' is never emitted. See https://github.com/node-fetch/node-fetch/pull/903
|
||||
if (!response) {
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// For br
|
||||
if (codings === "br") {
|
||||
body = pump(body, zlib.createBrotliDecompress(), (error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, use response as-is
|
||||
response = new Response(body, responseOptions);
|
||||
resolve(response);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line promise/prefer-await-to-then
|
||||
writeToStream(request_, request).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
||||
const LAST_CHUNK = Buffer.from("0\r\n\r\n");
|
||||
|
||||
let isChunkedTransfer = false;
|
||||
let properLastChunkReceived = false;
|
||||
let previousChunk;
|
||||
|
||||
request.on("response", (response) => {
|
||||
const { headers } = response;
|
||||
isChunkedTransfer =
|
||||
headers["transfer-encoding"] === "chunked" && !headers["content-length"];
|
||||
});
|
||||
|
||||
request.on("socket", (socket) => {
|
||||
const onSocketClose = () => {
|
||||
if (isChunkedTransfer && !properLastChunkReceived) {
|
||||
const error = new Error("Premature close");
|
||||
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
||||
errorCallback(error);
|
||||
}
|
||||
};
|
||||
|
||||
// const onData = buf => {
|
||||
// properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
||||
|
||||
// // Sometimes final 0-length chunk and end of message code are in separate packets
|
||||
// if (!properLastChunkReceived && previousChunk) {
|
||||
// properLastChunkReceived = (
|
||||
// Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
|
||||
// Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0
|
||||
// );
|
||||
// }
|
||||
|
||||
// previousChunk = buf;
|
||||
// };
|
||||
|
||||
// PATCH - THIS IS WHERE THE PATCH IS - FIXES BOUNDARY CHUNKING ISSUE
|
||||
// See https://github.com/node-fetch/node-fetch/issues/1576
|
||||
const onData = (buf) => {
|
||||
properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0;
|
||||
|
||||
// Sometimes final 0-length chunk and end of message code are in separate packets
|
||||
if (!properLastChunkReceived && previousChunk) {
|
||||
if (buf.length < 5) {
|
||||
properLastChunkReceived =
|
||||
Buffer.compare(
|
||||
Buffer.from([...previousChunk.slice(-5), ...buf]).slice(-5),
|
||||
LAST_CHUNK,
|
||||
) === 0;
|
||||
}
|
||||
}
|
||||
|
||||
previousChunk = buf;
|
||||
};
|
||||
|
||||
socket.prependListener("close", onSocketClose);
|
||||
socket.on("data", onData);
|
||||
|
||||
request.on("close", () => {
|
||||
socket.removeListener("close", onSocketClose);
|
||||
socket.removeListener("data", onData);
|
||||
});
|
||||
});
|
||||
}
|
||||
67
packages/fetch/src/node-fetch-patch.test.js
Normal file
67
packages/fetch/src/node-fetch-patch.test.js
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Buffer } from "node:buffer";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
// Tests the boundary chunking patch to node fetch made in node-fetch-patch.js (see that file for details).
|
||||
describe("Chunked Transfer Encoding Patch Logic", () => {
|
||||
// The LAST_CHUNK marker "0\r\n\r\n"
|
||||
const LAST_CHUNK = Buffer.from("0\r\n\r\n");
|
||||
|
||||
it("should detect complete marker at the end (normal case)", () => {
|
||||
const normalCase = Buffer.from("data data data 0\r\n\r\n");
|
||||
const result = Buffer.compare(normalCase.slice(-5), LAST_CHUNK) === 0;
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle chunks split across original pattern (0\\r\\n | \\r\\n)", () => {
|
||||
const previousChunk = Buffer.from("data data 0\r\n");
|
||||
const lastChunk = Buffer.from("\r\n");
|
||||
|
||||
const result =
|
||||
Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
|
||||
Buffer.compare(lastChunk.slice(-2), LAST_CHUNK.slice(3)) === 0;
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle problematic case from issue #1576 with new patch", () => {
|
||||
// The problematic case: data ends with "0\r\n0\r" and the next chunk is "\n\r\n"
|
||||
const previousChunk = Buffer.from([
|
||||
...Array(10).fill(42),
|
||||
48,
|
||||
13,
|
||||
10,
|
||||
48,
|
||||
13,
|
||||
]); // some data + "0\r\n0\r"
|
||||
const lastChunk = Buffer.from([10, 13, 10]); // "\n\r\n"
|
||||
|
||||
// Check 1: Direct check for complete marker (should fail)
|
||||
const check1 = Buffer.compare(lastChunk.slice(-5), LAST_CHUNK) === 0;
|
||||
expect(check1).toBe(false);
|
||||
|
||||
// Check 2: Original split pattern check (should fail)
|
||||
const check2 =
|
||||
Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 &&
|
||||
Buffer.compare(lastChunk.slice(-2), LAST_CHUNK.slice(3)) === 0;
|
||||
expect(check2).toBe(false);
|
||||
|
||||
// Check 3: New patch check (should pass)
|
||||
const lastChunkLength = lastChunk.length;
|
||||
const newPatchCheck =
|
||||
lastChunkLength < 5 &&
|
||||
Buffer.compare(
|
||||
Buffer.from([...previousChunk.slice(-5), ...lastChunk]).slice(-5),
|
||||
LAST_CHUNK,
|
||||
) === 0;
|
||||
expect(newPatchCheck).toBe(true);
|
||||
|
||||
// Verification of the combined buffer
|
||||
const combinedBuffer = Buffer.from([
|
||||
...previousChunk.slice(-5),
|
||||
...lastChunk,
|
||||
]);
|
||||
const combinedResult =
|
||||
Buffer.compare(combinedBuffer.slice(-5), LAST_CHUNK) === 0;
|
||||
expect(combinedResult).toBe(true);
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue