Changesets · Branches · Tags · Compare
| Changeset | a1c3c7aad6d47d3a4f31c02078d4085ab83e99adb3f130f2841e88d73e72b122 |
|---|---|
| Author | BekahHW <rhawrot@gmail.com> · 2025-09-18 07:50 -04:00 |
| Committer | BekahHW <rhawrot@gmail.com> · 2025-09-18 07:50 -04:00 |
| Parents | e9e21fbbba69, d4eec0630c2e |
93 files changed
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | timeout-minutes: 10 |
| 19 | 19 | steps: |
| 20 | 20 | - name: Run Detailed PR Review |
| 21 | - uses: continuedev/continue/actions/detailed-review@8373ac24010df1110cd00512f925b63813362da1 | |
| 21 | + uses: continuedev/continue/actions/detailed-review@3ebd8232440080aa8891909753f69d75a87b2c86 | |
| 22 | 22 | with: |
| 23 | 23 | continue-api-key: ${{ secrets.CONTINUE_API_KEY }} |
| 24 | 24 | continue-org: continuedev |
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | timeout-minutes: 10 |
| 19 | 19 | steps: |
| 20 | 20 | - name: Run Continue PR Review Action |
| 21 | - uses: continuedev/continue/actions/general-review@8373ac24010df1110cd00512f925b63813362da1 | |
| 21 | + uses: continuedev/continue/actions/general-review@3ebd8232440080aa8891909753f69d75a87b2c86 | |
| 22 | 22 | with: |
| 23 | 23 | continue-api-key: ${{ secrets.CONTINUE_API_KEY }} |
| 24 | 24 | continue-org: "continuedev" |
| @@ -84,6 +84,9 @@ | ||
| 84 | 84 | AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} |
| 85 | 85 | AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} |
| 86 | 86 | AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} |
| 87 | + VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} | |
| 88 | + RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 89 | + INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} | |
| 87 | 90 | |
| 88 | 91 | gui-checks: |
| 89 | 92 | runs-on: ubuntu-latest |
| @@ -217,6 +220,8 @@ | ||
| 217 | 220 | AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} |
| 218 | 221 | AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} |
| 219 | 222 | VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} |
| 223 | + RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 224 | + INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} | |
| 220 | 225 | |
| 221 | 226 | vscode-get-test-file-matrix: |
| 222 | 227 | runs-on: ubuntu-latest |
| @@ -32,3 +32,5 @@ | ||
| 32 | 32 | AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} |
| 33 | 33 | AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} |
| 34 | 34 | VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} |
| 35 | + RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 36 | + INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} |
| @@ -32,3 +32,5 @@ | ||
| 32 | 32 | AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} |
| 33 | 33 | AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} |
| 34 | 34 | VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} |
| 35 | + RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 36 | + INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} |
| @@ -23,4 +23,7 @@ | ||
| 23 | 23 | AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} |
| 24 | 24 | AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }} |
| 25 | 25 | AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }} |
| 26 | - AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} | |
| No newline at the end of the file | ||
| 26 | + AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }} | |
| 27 | + VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }} | |
| 28 | + RELACE_API_KEY: ${{ secrets.RELACE_API_KEY }} | |
| 29 | + INCEPTION_API_KEY: ${{ secrets.INCEPTION_API_KEY }} |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -215,8 +215,8 @@ | ||
| 215 | 215 | // Prepare models |
| 216 | 216 | for (const model of models) { |
| 217 | 217 | model.requestOptions = { |
| 218 | - ...model.requestOptions, | |
| 219 | 218 | ...config.requestOptions, |
| 219 | + ...model.requestOptions, | |
| 220 | 220 | }; |
| 221 | 221 | if (roles !== undefined) { |
| 222 | 222 | model.roles = model.roles ?? roles; |
| @@ -545,6 +545,7 @@ | ||
| 545 | 545 | |
| 546 | 546 | // Trigger MCP server refreshes (Config is reloaded again once connected!) |
| 547 | 547 | const mcpManager = MCPManagerSingleton.getInstance(); |
| 548 | + | |
| 548 | 549 | const orgPolicy = PolicySingleton.getInstance().policy; |
| 549 | 550 | if (orgPolicy?.policy?.allowMcpServers === false) { |
| 550 | 551 | await mcpManager.shutdown(); |
| @@ -555,6 +556,7 @@ | ||
| 555 | 556 | id: `continue-mcp-server-${index + 1}`, |
| 556 | 557 | name: `MCP Server`, |
| 557 | 558 | ...server, |
| 559 | + requestOptions: config.requestOptions, | |
| 558 | 560 | }), |
| 559 | 561 | ), |
| 560 | 562 | false, |
| @@ -187,7 +187,6 @@ | ||
| 187 | 187 | const mcpManager = MCPManagerSingleton.getInstance(); |
| 188 | 188 | const mcpServerStatuses = mcpManager.getStatuses(); |
| 189 | 189 | |
| 190 | - // Slightly hacky just need connection's client to make slash command for now | |
| 191 | 190 | const serializableStatuses = mcpServerStatuses.map((server) => { |
| 192 | 191 | const { client, ...rest } = server; |
| 193 | 192 | return rest; |
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | ConfigResult, |
| 5 | 5 | ConfigValidationError, |
| 6 | 6 | isAssistantUnrolledNonNullable, |
| 7 | + mergeConfigYamlRequestOptions, | |
| 7 | 8 | mergeUnrolledAssistants, |
| 8 | 9 | ModelRole, |
| 9 | 10 | PackageIdentifier, |
| @@ -34,10 +35,7 @@ | ||
| 34 | 35 | import { unrollLocalYamlBlocks } from "./loadLocalYamlBlocks"; |
| 35 | 36 | import { LocalPlatformClient } from "./LocalPlatformClient"; |
| 36 | 37 | import { llmsFromModelConfig } from "./models"; |
| 37 | -import { | |
| 38 | - convertYamlMcpToContinueMcp, | |
| 39 | - convertYamlRuleToContinueRule, | |
| 40 | -} from "./yamlToContinueConfig"; | |
| 38 | +import { convertYamlRuleToContinueRule } from "./yamlToContinueConfig"; | |
| 41 | 39 | |
| 42 | 40 | async function loadConfigYaml(options: { |
| 43 | 41 | overrideConfigYaml: AssistantUnrolled | undefined; |
| @@ -155,16 +153,15 @@ | ||
| 155 | 153 | }; |
| 156 | 154 | } |
| 157 | 155 | |
| 158 | -async function configYamlToContinueConfig(options: { | |
| 156 | +export async function configYamlToContinueConfig(options: { | |
| 159 | 157 | config: AssistantUnrolled; |
| 160 | 158 | ide: IDE; |
| 161 | - ideSettings: IdeSettings; | |
| 162 | 159 | ideInfo: IdeInfo; |
| 163 | 160 | uniqueId: string; |
| 164 | 161 | llmLogger: ILLMLogger; |
| 165 | 162 | workOsAccessToken: string | undefined; |
| 166 | 163 | }): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { |
| 167 | - let { config, ide, ideSettings, ideInfo, uniqueId, llmLogger } = options; | |
| 164 | + let { config, ide, ideInfo, uniqueId, llmLogger } = options; | |
| 168 | 165 | |
| 169 | 166 | const localErrors: ConfigValidationError[] = []; |
| 170 | 167 | |
| @@ -192,6 +189,7 @@ | ||
| 192 | 189 | summarize: null, |
| 193 | 190 | }, |
| 194 | 191 | rules: [], |
| 192 | + requestOptions: { ...config.requestOptions }, | |
| 195 | 193 | }; |
| 196 | 194 | |
| 197 | 195 | // Right now, if there are any missing packages in the config, then we will just throw an error |
| @@ -226,7 +224,13 @@ | ||
| 226 | 224 | } |
| 227 | 225 | } |
| 228 | 226 | |
| 229 | - continueConfig.data = config.data; | |
| 227 | + continueConfig.data = config.data?.map((d) => ({ | |
| 228 | + ...d, | |
| 229 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 230 | + d.requestOptions, | |
| 231 | + continueConfig.requestOptions, | |
| 232 | + ), | |
| 233 | + })); | |
| 230 | 234 | continueConfig.docs = config.docs?.map((doc) => ({ |
| 231 | 235 | title: doc.name, |
| 232 | 236 | startUrl: doc.startUrl, |
| @@ -250,12 +254,6 @@ | ||
| 250 | 254 | }); |
| 251 | 255 | }); |
| 252 | 256 | |
| 253 | - continueConfig.experimental = { | |
| 254 | - modelContextProtocolServers: config.mcpServers?.map( | |
| 255 | - convertYamlMcpToContinueMcp, | |
| 256 | - ), | |
| 257 | - }; | |
| 258 | - | |
| 259 | 257 | // Prompt files - |
| 260 | 258 | try { |
| 261 | 259 | const promptFiles = await getAllPromptFiles(ide, undefined, true); |
| @@ -307,9 +305,7 @@ | ||
| 307 | 305 | try { |
| 308 | 306 | const llms = await llmsFromModelConfig({ |
| 309 | 307 | model, |
| 310 | - ide, | |
| 311 | 308 | uniqueId, |
| 312 | - ideSettings, | |
| 313 | 309 | llmLogger, |
| 314 | 310 | config: continueConfig, |
| 315 | 311 | }); |
| @@ -394,6 +390,7 @@ | ||
| 394 | 390 | |
| 395 | 391 | // Trigger MCP server refreshes (Config is reloaded again once connected!) |
| 396 | 392 | const mcpManager = MCPManagerSingleton.getInstance(); |
| 393 | + | |
| 397 | 394 | const orgPolicy = PolicySingleton.getInstance().policy; |
| 398 | 395 | if (orgPolicy?.policy?.allowMcpServers === false) { |
| 399 | 396 | await mcpManager.shutdown(); |
| @@ -406,6 +403,10 @@ | ||
| 406 | 403 | transport: { |
| 407 | 404 | type: "stdio", |
| 408 | 405 | args: [], |
| 406 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 407 | + server.requestOptions, | |
| 408 | + config.requestOptions, | |
| 409 | + ), | |
| 409 | 410 | ...(server as any), // TODO: fix the types on mcpServers in config-yaml |
| 410 | 411 | }, |
| 411 | 412 | timeout: server.connectionTimeout, |
| @@ -464,7 +465,6 @@ | ||
| 464 | 465 | await configYamlToContinueConfig({ |
| 465 | 466 | config: configYamlResult.config, |
| 466 | 467 | ide, |
| 467 | - ideSettings, | |
| 468 | 468 | ideInfo, |
| 469 | 469 | uniqueId, |
| 470 | 470 | llmLogger, |
| @@ -1,12 +1,9 @@ | ||
| 1 | -import { ModelConfig } from "@continuedev/config-yaml"; | |
| 2 | - | |
| 3 | 1 | import { |
| 4 | - ContinueConfig, | |
| 5 | - IDE, | |
| 6 | - IdeSettings, | |
| 7 | - ILLMLogger, | |
| 8 | - LLMOptions, | |
| 9 | -} from "../.."; | |
| 2 | + mergeConfigYamlRequestOptions, | |
| 3 | + ModelConfig, | |
| 4 | +} from "@continuedev/config-yaml"; | |
| 5 | + | |
| 6 | +import { ContinueConfig, ILLMLogger, LLMOptions } from "../.."; | |
| 10 | 7 | import { BaseLLM } from "../../llm"; |
| 11 | 8 | import { LLMClasses } from "../../llm/llms"; |
| 12 | 9 | |
| @@ -29,14 +26,12 @@ | ||
| 29 | 26 | async function modelConfigToBaseLLM({ |
| 30 | 27 | model, |
| 31 | 28 | uniqueId, |
| 32 | - ideSettings, | |
| 33 | 29 | llmLogger, |
| 34 | 30 | config, |
| 35 | 31 | isFromAutoDetect, |
| 36 | 32 | }: { |
| 37 | 33 | model: ModelConfig; |
| 38 | 34 | uniqueId: string; |
| 39 | - ideSettings: IdeSettings; | |
| 40 | 35 | llmLogger: ILLMLogger; |
| 41 | 36 | config: ContinueConfig; |
| 42 | 37 | isFromAutoDetect?: boolean; |
| @@ -49,6 +44,11 @@ | ||
| 49 | 44 | |
| 50 | 45 | const { capabilities, ...rest } = model; |
| 51 | 46 | |
| 47 | + const mergedRequestOptions = mergeConfigYamlRequestOptions( | |
| 48 | + rest.requestOptions, | |
| 49 | + config.requestOptions, | |
| 50 | + ); | |
| 51 | + | |
| 52 | 52 | let options: LLMOptions = { |
| 53 | 53 | ...rest, |
| 54 | 54 | contextLength: model.defaultCompletionOptions?.contextLength, |
| @@ -74,6 +74,7 @@ | ||
| 74 | 74 | }, |
| 75 | 75 | autocompleteOptions: model.autocompleteOptions, |
| 76 | 76 | isFromAutoDetect, |
| 77 | + requestOptions: mergedRequestOptions, | |
| 77 | 78 | }; |
| 78 | 79 | |
| 79 | 80 | // Model capabilities - need to be undefined if not found |
| @@ -154,17 +155,13 @@ | ||
| 154 | 155 | async function autodetectModels({ |
| 155 | 156 | llm, |
| 156 | 157 | model, |
| 157 | - ide, | |
| 158 | 158 | uniqueId, |
| 159 | - ideSettings, | |
| 160 | 159 | llmLogger, |
| 161 | 160 | config, |
| 162 | 161 | }: { |
| 163 | 162 | llm: BaseLLM; |
| 164 | 163 | model: ModelConfig; |
| 165 | - ide: IDE; | |
| 166 | 164 | uniqueId: string; |
| 167 | - ideSettings: IdeSettings; | |
| 168 | 165 | llmLogger: ILLMLogger; |
| 169 | 166 | config: ContinueConfig; |
| 170 | 167 | }): Promise<BaseLLM[]> { |
| @@ -183,7 +180,6 @@ | ||
| 183 | 180 | name: modelName, |
| 184 | 181 | }, |
| 185 | 182 | uniqueId, |
| 186 | - ideSettings, | |
| 187 | 183 | llmLogger, |
| 188 | 184 | config, |
| 189 | 185 | isFromAutoDetect: true, |
| @@ -199,23 +195,18 @@ | ||
| 199 | 195 | |
| 200 | 196 | export async function llmsFromModelConfig({ |
| 201 | 197 | model, |
| 202 | - ide, | |
| 203 | 198 | uniqueId, |
| 204 | - ideSettings, | |
| 205 | 199 | llmLogger, |
| 206 | 200 | config, |
| 207 | 201 | }: { |
| 208 | 202 | model: ModelConfig; |
| 209 | - ide: IDE; | |
| 210 | 203 | uniqueId: string; |
| 211 | - ideSettings: IdeSettings; | |
| 212 | 204 | llmLogger: ILLMLogger; |
| 213 | 205 | config: ContinueConfig; |
| 214 | 206 | }): Promise<BaseLLM[]> { |
| 215 | 207 | const baseLlm = await modelConfigToBaseLLM({ |
| 216 | 208 | model, |
| 217 | 209 | uniqueId, |
| 218 | - ideSettings, | |
| 219 | 210 | llmLogger, |
| 220 | 211 | config, |
| 221 | 212 | }); |
| @@ -227,9 +218,7 @@ | ||
| 227 | 218 | const models = await autodetectModels({ |
| 228 | 219 | llm: baseLlm, |
| 229 | 220 | model, |
| 230 | - ide, | |
| 231 | 221 | uniqueId, |
| 232 | - ideSettings, | |
| 233 | 222 | llmLogger, |
| 234 | 223 | config, |
| 235 | 224 | }); |
| @@ -0,0 +1,355 @@ | ||
| 1 | +import { ModelConfig } from "@continuedev/config-yaml"; | |
| 2 | +import { beforeEach, describe, expect, it, vi } from "vitest"; | |
| 3 | + | |
| 4 | +import { ContinueConfig, ILLMLogger } from "../.."; | |
| 5 | +import { llmsFromModelConfig } from "./models"; | |
| 6 | + | |
| 7 | +// Mock the LLM classes | |
| 8 | +vi.mock("../../llm/llms", () => ({ | |
| 9 | + LLMClasses: [ | |
| 10 | + class MockOpenAI { | |
| 11 | + static providerName = "openai"; | |
| 12 | + static defaultOptions = { | |
| 13 | + completionOptions: { | |
| 14 | + maxTokens: 2048, | |
| 15 | + }, | |
| 16 | + }; | |
| 17 | + | |
| 18 | + constructor(options: any) { | |
| 19 | + Object.assign(this, options); | |
| 20 | + } | |
| 21 | + | |
| 22 | + async listModels() { | |
| 23 | + return ["gpt-4", "gpt-3.5-turbo"]; | |
| 24 | + } | |
| 25 | + }, | |
| 26 | + class MockAnthropic { | |
| 27 | + static providerName = "anthropic"; | |
| 28 | + static defaultOptions = { | |
| 29 | + completionOptions: { | |
| 30 | + maxTokens: 4096, | |
| 31 | + }, | |
| 32 | + }; | |
| 33 | + | |
| 34 | + constructor(options: any) { | |
| 35 | + Object.assign(this, options); | |
| 36 | + } | |
| 37 | + | |
| 38 | + async listModels() { | |
| 39 | + return ["claude-3-5-sonnet-20241022", "claude-3-haiku-20240307"]; | |
| 40 | + } | |
| 41 | + }, | |
| 42 | + ], | |
| 43 | +})); | |
| 44 | + | |
| 45 | +describe("llmsFromModelConfig requestOptions merging", () => { | |
| 46 | + let mockLLMLogger: ILLMLogger; | |
| 47 | + let mockConfig: ContinueConfig; | |
| 48 | + | |
| 49 | + beforeEach(() => { | |
| 50 | + mockLLMLogger = { log: vi.fn() } as any; | |
| 51 | + mockConfig = { | |
| 52 | + requestOptions: { | |
| 53 | + timeout: 30000, | |
| 54 | + headers: { | |
| 55 | + "User-Agent": "Continue/1.0.0", | |
| 56 | + }, | |
| 57 | + proxy: "global-proxy", | |
| 58 | + }, | |
| 59 | + contextProviders: [], | |
| 60 | + mcpServerStatuses: [], | |
| 61 | + rules: [], | |
| 62 | + selectedModelByRole: { | |
| 63 | + apply: null, | |
| 64 | + autocomplete: null, | |
| 65 | + chat: null, | |
| 66 | + edit: null, | |
| 67 | + embed: null, | |
| 68 | + rerank: null, | |
| 69 | + summarize: null, | |
| 70 | + }, | |
| 71 | + modelsByRole: { | |
| 72 | + apply: [], | |
| 73 | + autocomplete: [], | |
| 74 | + chat: [], | |
| 75 | + edit: [], | |
| 76 | + embed: [], | |
| 77 | + rerank: [], | |
| 78 | + summarize: [], | |
| 79 | + }, | |
| 80 | + slashCommands: [], | |
| 81 | + tools: [], | |
| 82 | + allowAnonymousTelemetry: false, | |
| 83 | + } as ContinueConfig; | |
| 84 | + vi.clearAllMocks(); | |
| 85 | + }); | |
| 86 | + | |
| 87 | + it("should merge model requestOptions with config requestOptions", async () => { | |
| 88 | + const model: ModelConfig = { | |
| 89 | + name: "test-openai", | |
| 90 | + provider: "openai", | |
| 91 | + model: "gpt-4", | |
| 92 | + requestOptions: { | |
| 93 | + timeout: 60000, | |
| 94 | + headers: { | |
| 95 | + Authorization: "Bearer token123", | |
| 96 | + }, | |
| 97 | + proxy: "model-proxy", | |
| 98 | + }, | |
| 99 | + }; | |
| 100 | + | |
| 101 | + const result = await llmsFromModelConfig({ | |
| 102 | + model, | |
| 103 | + uniqueId: "test-id", | |
| 104 | + llmLogger: mockLLMLogger, | |
| 105 | + config: mockConfig, | |
| 106 | + }); | |
| 107 | + | |
| 108 | + expect(result).toHaveLength(1); | |
| 109 | + const llm = result[0]; | |
| 110 | + | |
| 111 | + // The LLM should have merged requestOptions | |
| 112 | + expect(llm.requestOptions).toEqual({ | |
| 113 | + timeout: 60000, // model-specific takes precedence | |
| 114 | + headers: { | |
| 115 | + "User-Agent": "Continue/1.0.0", // from global request options | |
| 116 | + Authorization: "Bearer token123", // from model | |
| 117 | + }, | |
| 118 | + proxy: "model-proxy", // model-specific takes precedence | |
| 119 | + }); | |
| 120 | + }); | |
| 121 | + | |
| 122 | + it("should use config requestOptions when model has no requestOptions", async () => { | |
| 123 | + const model: ModelConfig = { | |
| 124 | + name: "test-openai", | |
| 125 | + provider: "openai", | |
| 126 | + model: "gpt-4", | |
| 127 | + // no requestOptions | |
| 128 | + }; | |
| 129 | + | |
| 130 | + const result = await llmsFromModelConfig({ | |
| 131 | + model, | |
| 132 | + uniqueId: "test-id", | |
| 133 | + llmLogger: mockLLMLogger, | |
| 134 | + config: mockConfig, | |
| 135 | + }); | |
| 136 | + | |
| 137 | + expect(result).toHaveLength(1); | |
| 138 | + const llm = result[0]; | |
| 139 | + | |
| 140 | + // The LLM should have config requestOptions | |
| 141 | + expect(llm.requestOptions).toEqual(mockConfig.requestOptions); | |
| 142 | + }); | |
| 143 | + | |
| 144 | + it("should use model requestOptions when config has no requestOptions", async () => { | |
| 145 | + const model: ModelConfig = { | |
| 146 | + name: "test-openai", | |
| 147 | + provider: "openai", | |
| 148 | + model: "gpt-4", | |
| 149 | + requestOptions: { | |
| 150 | + timeout: 45000, | |
| 151 | + headers: { | |
| 152 | + "API-Key": "secret", | |
| 153 | + }, | |
| 154 | + }, | |
| 155 | + }; | |
| 156 | + | |
| 157 | + const configWithoutOptions = { ...mockConfig }; | |
| 158 | + delete configWithoutOptions.requestOptions; | |
| 159 | + | |
| 160 | + const result = await llmsFromModelConfig({ | |
| 161 | + model, | |
| 162 | + uniqueId: "test-id", | |
| 163 | + llmLogger: mockLLMLogger, | |
| 164 | + config: configWithoutOptions, | |
| 165 | + }); | |
| 166 | + | |
| 167 | + expect(result).toHaveLength(1); | |
| 168 | + const llm = result[0]; | |
| 169 | + | |
| 170 | + // The LLM should have model requestOptions | |
| 171 | + expect(llm.requestOptions).toEqual(model.requestOptions); | |
| 172 | + }); | |
| 173 | + | |
| 174 | + it("should handle empty headers correctly in merge", async () => { | |
| 175 | + const model: ModelConfig = { | |
| 176 | + name: "test-openai", | |
| 177 | + provider: "openai", | |
| 178 | + model: "gpt-4", | |
| 179 | + requestOptions: { | |
| 180 | + timeout: 60000, | |
| 181 | + headers: {}, | |
| 182 | + }, | |
| 183 | + }; | |
| 184 | + | |
| 185 | + const configWithEmptyHeaders = { | |
| 186 | + ...mockConfig, | |
| 187 | + requestOptions: { | |
| 188 | + ...mockConfig.requestOptions!, | |
| 189 | + headers: {}, | |
| 190 | + }, | |
| 191 | + }; | |
| 192 | + | |
| 193 | + const result = await llmsFromModelConfig({ | |
| 194 | + model, | |
| 195 | + uniqueId: "test-id", | |
| 196 | + llmLogger: mockLLMLogger, | |
| 197 | + config: configWithEmptyHeaders, | |
| 198 | + }); | |
| 199 | + | |
| 200 | + expect(result).toHaveLength(1); | |
| 201 | + const llm = result[0]; | |
| 202 | + | |
| 203 | + // When headers merge to empty object, they should be undefined | |
| 204 | + expect(llm.requestOptions).toEqual({ | |
| 205 | + timeout: 60000, | |
| 206 | + proxy: "global-proxy", | |
| 207 | + headers: undefined, | |
| 208 | + }); | |
| 209 | + }); | |
| 210 | + | |
| 211 | + it("should handle autodetect models with merged requestOptions", async () => { | |
| 212 | + const model: ModelConfig = { | |
| 213 | + name: "autodetect-openai", | |
| 214 | + provider: "openai", | |
| 215 | + model: "AUTODETECT", | |
| 216 | + requestOptions: { | |
| 217 | + timeout: 120000, | |
| 218 | + headers: { | |
| 219 | + "X-Custom": "autodetect", | |
| 220 | + }, | |
| 221 | + }, | |
| 222 | + }; | |
| 223 | + | |
| 224 | + const result = await llmsFromModelConfig({ | |
| 225 | + model, | |
| 226 | + uniqueId: "test-id", | |
| 227 | + llmLogger: mockLLMLogger, | |
| 228 | + config: mockConfig, | |
| 229 | + }); | |
| 230 | + | |
| 231 | + // Should return multiple models from listModels() | |
| 232 | + expect(result.length).toBeGreaterThan(0); | |
| 233 | + | |
| 234 | + // Each detected model should have the merged requestOptions | |
| 235 | + result.forEach((llm) => { | |
| 236 | + expect(llm.requestOptions).toEqual({ | |
| 237 | + timeout: 120000, // model-specific takes precedence | |
| 238 | + headers: { | |
| 239 | + "User-Agent": "Continue/1.0.0", // from global request options | |
| 240 | + "X-Custom": "autodetect", // from model | |
| 241 | + }, | |
| 242 | + proxy: "global-proxy", // from global request options | |
| 243 | + }); | |
| 244 | + }); | |
| 245 | + }); | |
| 246 | + | |
| 247 | + it("should handle unknown provider gracefully", async () => { | |
| 248 | + const model: ModelConfig = { | |
| 249 | + name: "unknown-provider", | |
| 250 | + provider: "unknown", | |
| 251 | + model: "unknown-model", | |
| 252 | + requestOptions: { | |
| 253 | + timeout: 60000, | |
| 254 | + }, | |
| 255 | + }; | |
| 256 | + | |
| 257 | + const result = await llmsFromModelConfig({ | |
| 258 | + model, | |
| 259 | + uniqueId: "test-id", | |
| 260 | + llmLogger: mockLLMLogger, | |
| 261 | + config: mockConfig, | |
| 262 | + }); | |
| 263 | + | |
| 264 | + // Should return empty array for unknown provider | |
| 265 | + expect(result).toHaveLength(0); | |
| 266 | + }); | |
| 267 | + | |
| 268 | + it("should preserve other model properties while merging requestOptions", async () => { | |
| 269 | + const model: ModelConfig = { | |
| 270 | + name: "test-anthropic", | |
| 271 | + provider: "anthropic", | |
| 272 | + model: "claude-3-5-sonnet-20241022", | |
| 273 | + roles: ["chat", "summarize"], | |
| 274 | + capabilities: ["tool_use", "image_input"], | |
| 275 | + defaultCompletionOptions: { | |
| 276 | + temperature: 0.7, | |
| 277 | + maxTokens: 1000, | |
| 278 | + }, | |
| 279 | + requestOptions: { | |
| 280 | + timeout: 90000, | |
| 281 | + }, | |
| 282 | + }; | |
| 283 | + | |
| 284 | + const result = await llmsFromModelConfig({ | |
| 285 | + model, | |
| 286 | + uniqueId: "test-id", | |
| 287 | + llmLogger: mockLLMLogger, | |
| 288 | + config: mockConfig, | |
| 289 | + }); | |
| 290 | + | |
| 291 | + expect(result).toHaveLength(1); | |
| 292 | + const llm = result[0]; | |
| 293 | + | |
| 294 | + // Should preserve model properties | |
| 295 | + expect(llm.title).toBe("test-anthropic"); | |
| 296 | + expect(llm.completionOptions?.temperature).toBe(0.7); | |
| 297 | + expect(llm.completionOptions?.maxTokens).toBe(1000); | |
| 298 | + expect(llm.capabilities?.tools).toBe(true); | |
| 299 | + expect(llm.capabilities?.uploadImage).toBe(true); | |
| 300 | + | |
| 301 | + // Should have merged requestOptions | |
| 302 | + expect(llm.requestOptions).toEqual({ | |
| 303 | + timeout: 90000, | |
| 304 | + headers: { | |
| 305 | + "User-Agent": "Continue/1.0.0", | |
| 306 | + }, | |
| 307 | + proxy: "global-proxy", | |
| 308 | + }); | |
| 309 | + }); | |
| 310 | + | |
| 311 | + it("should handle complex header merging scenarios", async () => { | |
| 312 | + const model: ModelConfig = { | |
| 313 | + name: "complex-headers", | |
| 314 | + provider: "openai", | |
| 315 | + model: "gpt-4", | |
| 316 | + requestOptions: { | |
| 317 | + headers: { | |
| 318 | + Authorization: "Bearer model-token", | |
| 319 | + Accept: "application/json", // Should override config Accept | |
| 320 | + "X-Model-Specific": "true", | |
| 321 | + }, | |
| 322 | + }, | |
| 323 | + }; | |
| 324 | + | |
| 325 | + const configWithMoreHeaders = { | |
| 326 | + ...mockConfig, | |
| 327 | + requestOptions: { | |
| 328 | + ...mockConfig.requestOptions!, | |
| 329 | + headers: { | |
| 330 | + ...mockConfig.requestOptions!.headers, | |
| 331 | + Accept: "text/plain", // Should be overridden by model | |
| 332 | + "Cache-Control": "no-cache", | |
| 333 | + }, | |
| 334 | + }, | |
| 335 | + }; | |
| 336 | + | |
| 337 | + const result = await llmsFromModelConfig({ | |
| 338 | + model, | |
| 339 | + uniqueId: "test-id", | |
| 340 | + llmLogger: mockLLMLogger, | |
| 341 | + config: configWithMoreHeaders, | |
| 342 | + }); | |
| 343 | + | |
| 344 | + expect(result).toHaveLength(1); | |
| 345 | + const llm = result[0]; | |
| 346 | + | |
| 347 | + expect(llm.requestOptions?.headers).toEqual({ | |
| 348 | + "User-Agent": "Continue/1.0.0", // from global request options | |
| 349 | + "Cache-Control": "no-cache", // from global request options | |
| 350 | + Authorization: "Bearer model-token", // from model | |
| 351 | + Accept: "application/json", // from model (overrides config) | |
| 352 | + "X-Model-Specific": "true", // from model | |
| 353 | + }); | |
| 354 | + }); | |
| 355 | +}); |
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import DocsService from "./indexing/docs/DocsService"; |
| 19 | 19 | import { countTokens } from "./llm/countTokens"; |
| 20 | 20 | import Ollama from "./llm/llms/Ollama"; |
| 21 | +import Lemonade from "./llm/llms/Lemonade"; | |
| 21 | 22 | import { EditAggregator } from "./nextEdit/context/aggregateEdits"; |
| 22 | 23 | import { createNewPromptFileV2 } from "./promptFiles/createNewPromptFile"; |
| 23 | 24 | import { callTool } from "./tools/callTool"; |
| @@ -1263,6 +1264,9 @@ | ||
| 1263 | 1264 | if (msg.data.title === "Ollama") { |
| 1264 | 1265 | const models = await new Ollama({ model: "" }).listModels(); |
| 1265 | 1266 | return models; |
| 1267 | + } else if (msg.data.title === "Lemonade") { | |
| 1268 | + const models = await new Lemonade({ model: "" }).listModels(); | |
| 1269 | + return models; | |
| 1266 | 1270 | } else { |
| 1267 | 1271 | return undefined; |
| 1268 | 1272 | } |
| @@ -1348,6 +1352,8 @@ | ||
| 1348 | 1352 | selectedCode, |
| 1349 | 1353 | reranker: config.selectedModelByRole.rerank, |
| 1350 | 1354 | fetch: (url, init) => |
| 1355 | + // Important note: context providers fetch uses global request options not LLM request options | |
| 1356 | + // Because LLM calls are handled separately | |
| 1351 | 1357 | fetchwithRequestOptions(url, init, config.requestOptions), |
| 1352 | 1358 | isInAgentMode: msg.data.isInAgentMode, |
| 1353 | 1359 | }); |
| @@ -1099,6 +1099,7 @@ | ||
| 1099 | 1099 | exampleArgs?: Array<[string, string | number]>; |
| 1100 | 1100 | }; |
| 1101 | 1101 | defaultToolPolicy?: ToolPolicy; |
| 1102 | + toolCallIcon?: string; | |
| 1102 | 1103 | evaluateToolCallPolicy?: ( |
| 1103 | 1104 | basePolicy: ToolPolicy, |
| 1104 | 1105 | parsedArgs: Record<string, unknown>, |
| @@ -1281,6 +1282,7 @@ | ||
| 1281 | 1282 | transport: TransportOptions; |
| 1282 | 1283 | faviconUrl?: string; |
| 1283 | 1284 | timeout?: number; |
| 1285 | + requestOptions?: RequestOptions; | |
| 1284 | 1286 | } |
| 1285 | 1287 | |
| 1286 | 1288 | export type MCPConnectionStatus = |
| @@ -203,6 +203,13 @@ | ||
| 203 | 203 | ...ADDITIONAL_INDEXING_IGNORE_DIRS, |
| 204 | 204 | ]; |
| 205 | 205 | |
| 206 | +export const DEFAULT_IGNORES = [ | |
| 207 | + ...DEFAULT_IGNORE_FILETYPES, | |
| 208 | + ...DEFAULT_IGNORE_DIRS, | |
| 209 | +]; | |
| 210 | + | |
| 211 | +export const defaultIgnoresGlob = `!{${DEFAULT_IGNORES.join(",")}}`; | |
| 212 | + | |
| 206 | 213 | // Create ignore instances |
| 207 | 214 | export const defaultSecurityIgnoreFile = ignore().add( |
| 208 | 215 | DEFAULT_SECURITY_IGNORE_FILETYPES, |
| @@ -45,6 +45,7 @@ | ||
| 45 | 45 | |
| 46 | 46 | const PROVIDER_HANDLES_TEMPLATING: string[] = [ |
| 47 | 47 | "lmstudio", |
| 48 | + "lemonade", | |
| 48 | 49 | "openai", |
| 49 | 50 | "nvidia", |
| 50 | 51 | "ollama", |
| @@ -67,6 +68,7 @@ | ||
| 67 | 68 | const PROVIDER_SUPPORTS_IMAGES: string[] = [ |
| 68 | 69 | "openai", |
| 69 | 70 | "ollama", |
| 71 | + "lemonade", | |
| 70 | 72 | "cohere", |
| 71 | 73 | "gemini", |
| 72 | 74 | "msty", |
| @@ -85,7 +85,7 @@ | ||
| 85 | 85 | |
| 86 | 86 | function countImageTokens(content: MessagePart): number { |
| 87 | 87 | if (content.type === "imageUrl") { |
| 88 | - return 85; | |
| 88 | + return 1024; | |
| 89 | 89 | } |
| 90 | 90 | throw new Error("Non-image content type"); |
| 91 | 91 | } |
| @@ -30,6 +30,7 @@ | ||
| 30 | 30 | TemplateType, |
| 31 | 31 | Usage, |
| 32 | 32 | } from "../index.js"; |
| 33 | +import { isLemonadeInstalled } from "../util/lemonadeHelper.js"; | |
| 33 | 34 | import { Logger } from "../util/Logger.js"; |
| 34 | 35 | import mergeJson from "../util/merge.js"; |
| 35 | 36 | import { renderChatMessage } from "../util/messageContent.js"; |
| @@ -503,6 +504,24 @@ | ||
| 503 | 504 | : "Unable to connect to local Ollama instance. Ollama may not be installed or may not running."; |
| 504 | 505 | throw new Error(message); |
| 505 | 506 | } |
| 507 | + if ( | |
| 508 | + e.code === "ECONNREFUSED" && | |
| 509 | + e.message.includes("http://localhost:8000") | |
| 510 | + ) { | |
| 511 | + const isInstalled = await isLemonadeInstalled(); | |
| 512 | + let message: string; | |
| 513 | + if (process.platform === "linux") { | |
| 514 | + // On Linux, isLemonadeInstalled checks if it's running (via health endpoint) | |
| 515 | + message = | |
| 516 | + "Unable to connect to local Lemonade instance. Please ensure Lemonade is running. Visit http://lemonade-server.ai for setup instructions."; | |
| 517 | + } else { | |
| 518 | + // On Windows, we can check if it's installed | |
| 519 | + message = isInstalled | |
| 520 | + ? "Unable to connect to local Lemonade instance. Lemonade server may not be running." | |
| 521 | + : "Unable to connect to local Lemonade instance. Lemonade may not be installed or may not be running."; | |
| 522 | + } | |
| 523 | + throw new Error(message); | |
| 524 | + } | |
| 506 | 525 | } |
| 507 | 526 | throw e; |
| 508 | 527 | } |
| @@ -537,18 +556,14 @@ | ||
| 537 | 556 | } |
| 538 | 557 | |
| 539 | 558 | private _formatChatMessage(msg: ChatMessage): string { |
| 540 | - let contentToShow = ""; | |
| 541 | - if (msg.role === "tool") { | |
| 542 | - contentToShow = msg.content; | |
| 543 | - } else if (msg.role === "assistant" && msg.toolCalls?.length) { | |
| 544 | - contentToShow = msg.toolCalls | |
| 559 | + let contentToShow = renderChatMessage(msg); | |
| 560 | + if (msg.role === "assistant" && msg.toolCalls?.length) { | |
| 561 | + contentToShow += msg.toolCalls | |
| 545 | 562 | ?.map( |
| 546 | 563 | (toolCall) => |
| 547 | 564 | `${toolCall.function?.name}(${toolCall.function?.arguments})`, |
| 548 | 565 | ) |
| 549 | 566 | .join("\n"); |
| 550 | - } else if ("content" in msg) { | |
| 551 | - contentToShow = renderChatMessage(msg); | |
| 552 | 567 | } |
| 553 | 568 | |
| 554 | 569 | return `<${msg.role}>\n${contentToShow}\n\n`; |
| @@ -68,6 +68,17 @@ | ||
| 68 | 68 | return finalOptions; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | + private buildTextPart(text: string, addCaching: boolean) { | |
| 72 | + const part: any = { | |
| 73 | + type: "text", | |
| 74 | + text, | |
| 75 | + }; | |
| 76 | + if (addCaching) { | |
| 77 | + part.cache_control = { type: "ephemeral" }; | |
| 78 | + } | |
| 79 | + return part; | |
| 80 | + } | |
| 81 | + | |
| 71 | 82 | private convertMessage(message: ChatMessage, addCaching: boolean): any { |
| 72 | 83 | if (message.role === "tool") { |
| 73 | 84 | return { |
| @@ -81,14 +92,30 @@ | ||
| 81 | 92 | ], |
| 82 | 93 | }; |
| 83 | 94 | } else if (message.role === "assistant" && message.toolCalls) { |
| 84 | - return { | |
| 85 | - role: "assistant", | |
| 86 | - content: message.toolCalls.map((toolCall) => ({ | |
| 95 | + const parts: any[] = []; | |
| 96 | + if (message.content) { | |
| 97 | + if (typeof message.content === "string") { | |
| 98 | + parts.push(this.buildTextPart(message.content, addCaching)); | |
| 99 | + } else if (message.content.length > 0) { | |
| 100 | + const textContent = message.content.filter((p) => p.type === "text"); | |
| 101 | + const textParts = textContent.map((part, idx) => { | |
| 102 | + const cache = idx === textContent.length - 1 && addCaching; | |
| 103 | + return this.buildTextPart(part.text, cache); | |
| 104 | + }); | |
| 105 | + parts.push(...textParts); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + parts.push( | |
| 109 | + ...message.toolCalls.map((toolCall) => ({ | |
| 87 | 110 | type: "tool_use", |
| 88 | 111 | id: toolCall.id, |
| 89 | 112 | name: toolCall.function?.name, |
| 90 | 113 | input: safeParseToolCallArgs(toolCall), |
| 91 | 114 | })), |
| 115 | + ); | |
| 116 | + return { | |
| 117 | + role: "assistant", | |
| 118 | + content: parts, | |
| 92 | 119 | }; |
| 93 | 120 | } else if (message.role === "thinking" && !message.redactedThinking) { |
| 94 | 121 | return { |
| @@ -154,9 +181,7 @@ | ||
| 154 | 181 | |
| 155 | 182 | public convertMessages(msgs: ChatMessage[]): any[] { |
| 156 | 183 | // should be public for use within VertexAI |
| 157 | - const filteredmessages = msgs.filter( | |
| 158 | - (m) => m.role !== "system" && !!m.content, | |
| 159 | - ); | |
| 184 | + const filteredmessages = msgs.filter((m) => m.role !== "system"); | |
| 160 | 185 | const lastTwoUserMsgIndices = filteredmessages |
| 161 | 186 | .map((msg, index) => (msg.role === "user" ? index : -1)) |
| 162 | 187 | .filter((index) => index !== -1) |
| @@ -0,0 +1,12 @@ | ||
| 1 | +import { LLMOptions } from "../../index.js"; | |
| 2 | + | |
| 3 | +import OpenAI from "./OpenAI.js"; | |
| 4 | + | |
| 5 | +class Lemonade extends OpenAI { | |
| 6 | + static providerName = "lemonade"; | |
| 7 | + static defaultOptions: Partial<LLMOptions> = { | |
| 8 | + apiBase: "http://localhost:8000/api/v1/", | |
| 9 | + }; | |
| 10 | +} | |
| 11 | + | |
| 12 | +export default Lemonade; |
| @@ -269,6 +269,11 @@ | ||
| 269 | 269 | return this.modelMap[this.model] ?? this.model; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | + get contextLength() { | |
| 273 | + const DEFAULT_OLLAMA_CONTEXT_LENGTH = 8192; // twice of https://github.com/ollama/ollama/blob/29ddfc2cab7f5a83a96c3133094f67b22e4f27d1/envconfig/config.go#L185 | |
| 274 | + return this._contextLength ?? DEFAULT_OLLAMA_CONTEXT_LENGTH; | |
| 275 | + } | |
| 276 | + | |
| 272 | 277 | private _getModelFileParams( |
| 273 | 278 | options: CompletionOptions, |
| 274 | 279 | ): OllamaModelFileParams { |
| @@ -174,7 +174,7 @@ | ||
| 174 | 174 | protected _getHeaders() { |
| 175 | 175 | return { |
| 176 | 176 | "Content-Type": "application/json", |
| 177 | - Authorization: `Bearer ${this.apiKey}`, | |
| 177 | + ...(this.apiKey && { Authorization: `Bearer ${this.apiKey}` }), | |
| 178 | 178 | "api-key": this.apiKey ?? "", // For Azure |
| 179 | 179 | }; |
| 180 | 180 | } |
| @@ -33,6 +33,7 @@ | ||
| 33 | 33 | import LlamaCpp from "./LlamaCpp"; |
| 34 | 34 | import Llamafile from "./Llamafile"; |
| 35 | 35 | import LlamaStack from "./LlamaStack"; |
| 36 | +import Lemonade from "./Lemonade"; | |
| 36 | 37 | import LMStudio from "./LMStudio"; |
| 37 | 38 | import Mistral from "./Mistral"; |
| 38 | 39 | import MockLLM from "./Mock"; |
| @@ -82,6 +83,7 @@ | ||
| 82 | 83 | LlamaCpp, |
| 83 | 84 | OpenAI, |
| 84 | 85 | OVHcloud, |
| 86 | + Lemonade, | |
| 85 | 87 | LMStudio, |
| 86 | 88 | Mistral, |
| 87 | 89 | Bedrock, |
| @@ -95,7 +95,7 @@ | ||
| 95 | 95 | ...init, |
| 96 | 96 | signal: abortController.signal, |
| 97 | 97 | }, |
| 98 | - config.requestOptions, | |
| 98 | + model.requestOptions, | |
| 99 | 99 | ), |
| 100 | 100 | completionOptions, |
| 101 | 101 | abortController, |
| @@ -374,9 +374,8 @@ | ||
| 374 | 374 | [/o[134]/], |
| 375 | 375 | [/deepseek/, /r1|reasoner/], |
| 376 | 376 | [/gemini/, /2\.5/, /pro/], |
| 377 | - [/gpt/, /4/], | |
| 378 | 377 | [/gpt-5/], |
| 379 | - [/claude/, /sonnet/, /3\.5|3\.7|3-5|3-7|-4/], | |
| 378 | + [/claude/, /sonnet/, /3\.7|3-7|-4/], | |
| 380 | 379 | [/claude/, /opus/, /-4/], |
| 381 | 380 | ]; |
| 382 | 381 | for (const combo of recs) { |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -84,4 +84,5 @@ | ||
| 84 | 84 | ["alwaysApply", "false"], |
| 85 | 85 | ], |
| 86 | 86 | }, |
| 87 | + toolCallIcon: "PencilIcon", | |
| 87 | 88 | }; |
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | prefix: `To fetch the content of a URL, use the ${BuiltInToolNames.FetchUrlContent} tool. For example, to read the contents of a webpage, you might respond with:`, |
| 31 | 31 | exampleArgs: [["url", "https://example.com"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "GlobeAltIcon", | |
| 33 | 34 | }; |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | function: { |
| 14 | 14 | name: BuiltInToolNames.FileGlobSearch, |
| 15 | 15 | description: |
| 16 | - "Search for files recursively in the project using glob patterns. Supports ** for recursive directory search. Output may be truncated; use targeted patterns", | |
| 16 | + "Search for files recursively in the project using glob patterns. Supports ** for recursive directory search. Will not show many build, cache, secrets dirs/files (can use ls tool instead). Output may be truncated; use targeted patterns", | |
| 17 | 17 | parameters: { |
| 18 | 18 | type: "object", |
| 19 | 19 | required: ["pattern"], |
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | prefix: `To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`, |
| 31 | 31 | exampleArgs: [["pattern", "*.py"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "MagnifyingGlassIcon", | |
| 33 | 34 | }; |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | function: { |
| 14 | 14 | name: BuiltInToolNames.GrepSearch, |
| 15 | 15 | description: |
| 16 | - "Perform a search over the repository using ripgrep. Output may be truncated, so use targeted queries", | |
| 16 | + "Perform a search over the repository using ripgrep. Will not include results for many build, cache, secrets dirs/files. Output may be truncated, so use targeted queries", | |
| 17 | 17 | parameters: { |
| 18 | 18 | type: "object", |
| 19 | 19 | required: ["query"], |
| @@ -31,4 +31,5 @@ | ||
| 31 | 31 | prefix: `To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`, |
| 32 | 32 | exampleArgs: [["query", ".*main_services.*"]], |
| 33 | 33 | }, |
| 34 | + toolCallIcon: "MagnifyingGlassIcon", | |
| 34 | 35 | }; |
| @@ -38,4 +38,5 @@ | ||
| 38 | 38 | ["recursive", "false"], |
| 39 | 39 | ], |
| 40 | 40 | }, |
| 41 | + toolCallIcon: "FolderIcon", | |
| 41 | 42 | }; |
| @@ -24,4 +24,5 @@ | ||
| 24 | 24 | prefix: `To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool. |
| 25 | 25 | If the user is asking about a file and you don't see any code, use this to check the current file`, |
| 26 | 26 | }, |
| 27 | + toolCallIcon: "DocumentTextIcon", | |
| 27 | 28 | }; |
| @@ -31,4 +31,5 @@ | ||
| 31 | 31 | exampleArgs: [["filepath", "path/to/the_file.txt"]], |
| 32 | 32 | }, |
| 33 | 33 | defaultToolPolicy: "allowedWithoutPermission", |
| 34 | + toolCallIcon: "DocumentIcon", | |
| 34 | 35 | }; |
| @@ -48,4 +48,5 @@ | ||
| 48 | 48 | ], |
| 49 | 49 | }, |
| 50 | 50 | defaultToolPolicy: "allowedWithoutPermission", |
| 51 | + toolCallIcon: "DocumentIcon", | |
| 51 | 52 | }; |
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | prefix: `To search the web, use the ${BuiltInToolNames.SearchWeb} tool with a natural language query. For example, to search for the current weather, you would respond with:`, |
| 31 | 31 | exampleArgs: [["query", "What is the current weather in San Francisco?"]], |
| 32 | 32 | }, |
| 33 | + toolCallIcon: "GlobeAltIcon", | |
| 33 | 34 | }; |
| @@ -23,4 +23,5 @@ | ||
| 23 | 23 | prefix: `To view the current git diff, use the ${BuiltInToolNames.ViewDiff} tool. This will show you the changes made in the working directory compared to the last commit.`, |
| 24 | 24 | }, |
| 25 | 25 | defaultToolPolicy: "allowedWithoutPermission", |
| 26 | + toolCallIcon: "CodeBracketIcon", | |
| 26 | 27 | }; |
| @@ -23,4 +23,5 @@ | ||
| 23 | 23 | prefix: `To view the repository map, use the ${BuiltInToolNames.ViewRepoMap} tool. This will provide a visual representation of the project's structure and organization.`, |
| 24 | 24 | }, |
| 25 | 25 | defaultToolPolicy: "allowedWithPermission", |
| 26 | + toolCallIcon: "MapIcon", | |
| 26 | 27 | }; |
| @@ -30,4 +30,5 @@ | ||
| 30 | 30 | exampleArgs: [["directory_path", "path/to/subdirectory"]], |
| 31 | 31 | }, |
| 32 | 32 | defaultToolPolicy: "allowedWithPermission", |
| 33 | + toolCallIcon: "FolderOpenIcon", | |
| 33 | 34 | }; |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { ConfigDependentToolParams, Tool } from ".."; |
| 2 | +import { isRecommendedAgentModel } from "../llm/toolSupport"; | |
| 2 | 3 | import * as toolDefinitions from "./definitions"; |
| 3 | 4 | |
| 4 | 5 | // I'm writing these as functions because we've messed up 3 TIMES by pushing to const, causing duplicate tool definitions on subsequent config loads. |
| @@ -36,7 +37,7 @@ | ||
| 36 | 37 | ); |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | - if (modelName?.includes("claude") || modelName?.includes("gpt-5")) { | |
| 40 | + if (modelName && isRecommendedAgentModel(modelName)) { | |
| 40 | 41 | tools.push(toolDefinitions.multiEditTool); |
| 41 | 42 | } else { |
| 42 | 43 | tools.push(toolDefinitions.editFileTool); |
| @@ -0,0 +1,59 @@ | ||
| 1 | +import { exec } from "node:child_process"; | |
| 2 | +import { IDE } from ".."; | |
| 3 | + | |
| 4 | +export async function isLemonadeInstalled(): Promise<boolean> { | |
| 5 | + // On Windows, check if lemonade-server command exists | |
| 6 | + if (process.platform === "win32") { | |
| 7 | + return new Promise((resolve, _reject) => { | |
| 8 | + exec("where.exe lemonade-server", (error, _stdout, _stderr) => { | |
| 9 | + resolve(!error); | |
| 10 | + }); | |
| 11 | + }); | |
| 12 | + } | |
| 13 | + | |
| 14 | + // On Linux, check if the health endpoint is accessible | |
| 15 | + try { | |
| 16 | + const response = await fetch("http://localhost:8000/api/v1/health", { | |
| 17 | + method: "GET", | |
| 18 | + signal: AbortSignal.timeout(3000), // 3 second timeout | |
| 19 | + }); | |
| 20 | + | |
| 21 | + if (response.ok) { | |
| 22 | + const data = await response.json(); | |
| 23 | + return data.status === "ok"; | |
| 24 | + } | |
| 25 | + return false; | |
| 26 | + } catch { | |
| 27 | + return false; | |
| 28 | + } | |
| 29 | +} | |
| 30 | + | |
| 31 | +export async function startLocalLemonade(ide: IDE): Promise<any> { | |
| 32 | + let startCommand: string | undefined; | |
| 33 | + | |
| 34 | + switch (process.platform) { | |
| 35 | + case "linux": // Linux | |
| 36 | + // On Linux, direct users to start Lemonade manually | |
| 37 | + return ide.showToast( | |
| 38 | + "info", | |
| 39 | + "Please start Lemonade manually. Visit https://lemonade-server.ai for instructions.", | |
| 40 | + ); | |
| 41 | + | |
| 42 | + case "win32": // Windows | |
| 43 | + startCommand = "lemonade-server serve\n"; | |
| 44 | + break; | |
| 45 | + | |
| 46 | + default: | |
| 47 | + return ide.showToast( | |
| 48 | + "error", | |
| 49 | + "Cannot start Lemonade: platform not supported!", | |
| 50 | + ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + if (startCommand) { | |
| 54 | + return ide.runCommand(startCommand, { | |
| 55 | + reuseTerminal: true, | |
| 56 | + terminalName: "Start Lemonade", | |
| 57 | + }); | |
| 58 | + } | |
| 59 | +} |
Binary content is not shown. View the file.
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Binary content is not shown. View the file.
| @@ -0,0 +1,81 @@ | ||
| 1 | +--- | |
| 2 | +title: "Lemonade Server" | |
| 3 | +description: "Configure Lemonade Server with Continue for refreshingly fast local LLM inference on GPUs and NPUs" | |
| 4 | +--- | |
| 5 | + | |
| 6 | +<Info> | |
| 7 | + Get started with [Lemonade Server](https://lemonade-server.ai/) - Refreshingly fast LLMs on GPUs and NPUs with seamless Continue integration | |
| 8 | +</Info> | |
| 9 | + | |
| 10 | +## Overview | |
| 11 | + | |
| 12 | +Lemonade Server provides optimized local LLM inference with support for GPU and NPU hardware acceleration. It offers an OpenAI-compatible API that seamlessly integrates with Continue and other open-source platforms. | |
| 13 | + | |
| 14 | +## Installation | |
| 15 | + | |
| 16 | +Download and install Lemonade Server from [lemonade-server.ai](https://lemonade-server.ai/). | |
| 17 | + | |
| 18 | +## Configuration | |
| 19 | + | |
| 20 | +Lemonade Server is available directly in the Continue UI as a provider. You can select it from the model provider dropdown without manual configuration. | |
| 21 | + | |
| 22 | +### Option 1: Using the Continue UI (Recommended) | |
| 23 | + | |
| 24 | +1. Click on the model selector dropdown in Continue | |
| 25 | +2. Select "Add Model" | |
| 26 | +3. Choose "Lemonade Server" from the provider list | |
| 27 | +4. Continue will automatically configure the connection | |
| 28 | + | |
| 29 | +### Option 2: Manual Configuration | |
| 30 | + | |
| 31 | +If you need custom settings, you can manually configure Lemonade: | |
| 32 | + | |
| 33 | +<Tabs> | |
| 34 | + <Tab title="YAML"> | |
| 35 | + ```yaml title="config.yaml" | |
| 36 | + models: | |
| 37 | + - name: Lemonade | |
| 38 | + provider: lemonade | |
| 39 | + model: <MODEL_NAME> | |
| 40 | + apiBase: http://localhost:8000/api/v1/ | |
| 41 | + ``` | |
| 42 | + </Tab> | |
| 43 | + <Tab title="JSON (Deprecated)"> | |
| 44 | + ```json title="config.json" | |
| 45 | + { | |
| 46 | + "models": [ | |
| 47 | + { | |
| 48 | + "title": "Lemonade", | |
| 49 | + "provider": "lemonade", | |
| 50 | + "model": "<MODEL_NAME>", | |
| 51 | + "apiBase": "http://localhost:8000/api/v1/" | |
| 52 | + } | |
| 53 | + ] | |
| 54 | + } | |
| 55 | + ``` | |
| 56 | + </Tab> | |
| 57 | +</Tabs> | |
| 58 | + | |
| 59 | +## Getting Started | |
| 60 | + | |
| 61 | +1. **Install Lemonade Server**: Download from [lemonade-server.ai](https://lemonade-server.ai/) | |
| 62 | +2. **Start the server**: Launch Lemonade Server (runs on `http://localhost:8000/api/v1/` by default) | |
| 63 | +3. **Add to Continue**: Select Lemonade Server from the model provider dropdown in Continue | |
| 64 | +4. **Load a model**: Choose your preferred model through the interface | |
| 65 | + | |
| 66 | +## Hardware Support | |
| 67 | + | |
| 68 | +Lemonade Server automatically detects and optimizes for available hardware: | |
| 69 | +- **NPU**: Neural Processing Unit acceleration for efficient inference | |
| 70 | +- **GPU**: Full GPU acceleration support | |
| 71 | +- **CPU**: Optimized CPU fallback when accelerators are unavailable | |
| 72 | + | |
| 73 | +## Key Features | |
| 74 | + | |
| 75 | +- OpenAI-compatible API for seamless integration | |
| 76 | +- Support for popular model formats | |
| 77 | +- Automatic hardware detection and optimization | |
| 78 | +- Integration with Continue, Open WebUI, Gaia, and AnythingLLM | |
| 79 | +- Active open-source community | |
| 80 | + | |
| 81 | +[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Lemonade.ts) | |
| No newline at the end of the file |
| @@ -3,81 +3,250 @@ | ||
| 3 | 3 | sidebarTitle: "Tetrate Agent Router Service" |
| 4 | 4 | slug: ../tetrate-agent-router-service |
| 5 | 5 | --- |
| 6 | - | |
| 7 | -The **Tetrate Agent Router Service** provides a unified Gateway for accessing various AI models with fast inference capabilities as well as embedding services. | |
| 6 | +The **Tetrate Agent Router Service** provides a unified Gateway for accessing various AI models with fast inference capabilities. | |
| 8 | 7 | |
| 9 | 8 | This gateway acts as an intelligent router that can distribute requests across multiple model providers, offering enterprise-grade reliability and performance optimization. |
| 10 | 9 | |
| 11 | -## Getting Started | |
| 10 | +<Tip> | |
| 11 | +Want to get started quickly? Sign up for the [Tetrate Agent Router Service](https://router.tetrate.ai/) to get an API key, then use [Tetrate on Continue Hub](https://hub.continue.dev/tetrate) to get started fast. | |
| 12 | +</Tip> | |
| 12 | 13 | |
| 13 | -1. Obtain an API key from the [Agent Router Service portal](https://api.router.tetrate.ai/) | |
| 14 | -2. Configure Continue to use Agent Router Service as your model provider | |
| 14 | +## Setup | |
| 15 | 15 | |
| 16 | -## Configuring Models | |
| 16 | +<Steps> | |
| 17 | +<Step title="Sign in or sign up"> | |
| 18 | +Visit the [Agent Router Service portal](https://router.tetrate.ai/) and create an account to get your API key | |
| 19 | +<img src="../assets/tetrate-sign-in.png" alt="Tetrate sign in page" style={{width: '250px', maxWidth: '100%'}} /> | |
| 20 | +</Step> | |
| 17 | 21 | |
| 18 | -You can also quickly use models from Tetrate on the Cotninue Hub by visiting Tetrate on the Continue Hub [here](https://hub.continue.dev/tetrate). The easiest way if you don't see the model you want to use is to remix one of the models on the Tetrate page and change the model to the one you want to use. | |
| 22 | +<Step title="Get your API key"> | |
| 23 | +Go to the [API keys page](https://router.tetrate.ai/api-keys) to get your key | |
| 24 | +<img src="../assets/tetrate-get-api-key.png" alt="Tetrate get API key" style={{width: '250px', maxWidth: '100%'}} /> | |
| 25 | +</Step> | |
| 19 | 26 | |
| 20 | - | |
| 27 | +<Step title="Configure Continue"> | |
| 28 | +- Choose a configuration method below. | |
| 29 | +- If you use the Continue VS Code extension, install version `>=1.2.3`. | |
| 30 | +</Step> | |
| 31 | + | |
| 32 | +</Steps> | |
| 21 | 33 | |
| 22 | -### Available Models | |
| 23 | 34 | |
| 24 | -Agent Router Service supports routing to various models. | |
| 25 | -Go to the [Agent Router Service model catalog](https://router.tetrate.ai/models) for a full list of supported models. | |
| 35 | +### Quickstart with Continue Hub | |
| 26 | 36 | |
| 27 | -## Configuration Options | |
| 37 | +Fastest way: use preconfigured models from Tetrate on Continue Hub | |
| 28 | 38 | |
| 29 | -As Agent Router Service is an OpenAI API compatible provider, you can configure it like any other OpenAI API compatible provider. Therefore you will be setting `provider: openai` and `apiBase: https://api.router.tetrate.ai/v1`. | |
| 39 | +<Steps> | |
| 40 | +<Step title="Browse models"> | |
| 41 | +Open [Tetrate on Continue Hub](https://hub.continue.dev/tetrate) and pick a model (e.g., [Claude Sonnet 4](https://hub.continue.dev/tetrate/claude-sonnet-4)) | |
| 42 | +</Step> | |
| 30 | 43 | |
| 31 | -Update your Continue configuration file (`~/.continue/config.yaml`) with your Agent Router Service API key: | |
| 44 | +<Step title="Use or remix"> | |
| 45 | +Click "Use Model", or "Remix" to change the model ID if needed | |
| 46 | +</Step> | |
| 32 | 47 | |
| 33 | -### On your local machine | |
| 48 | +<Step title="Add your API key"> | |
| 49 | +Add your API key to Continue. See [adding secrets in Continue Hub](/hub/secrets/secret-types) and [managing local secrets in the FAQ](/faqs#managing-local-secrets-and-environment-variables) | |
| 50 | +<Tip> | |
| 51 | +Add it as a Continue Hub secret named `TETRATE_API_KEY` to reuse across projects. | |
| 52 | +</Tip> | |
| 53 | +</Step> | |
| 54 | +</Steps> | |
| 34 | 55 | |
| 35 | -#### In your config.yaml | |
| 56 | + | |
| 36 | 57 | |
| 37 | -```yaml title="config.yaml" | |
| 58 | +<Info> | |
| 59 | +If a model is missing, remix a similar one and set the `model` field to the target ID. | |
| 60 | +</Info> | |
| 61 | + | |
| 62 | +### Configuration Methods | |
| 63 | + | |
| 64 | +<CardGroup cols={1}> | |
| 65 | + <Card title="In Local Agent Configuration" icon="folder" vertical> | |
| 66 | + Use a Tetrate model block from the Hub or define it directly in your local agent configuration. | |
| 67 | + </Card> | |
| 68 | + <Card title="Continue Hub" icon="cloud" vertical> | |
| 69 | + Use a Tetrate model block from the Hub or define your own on the Hub. | |
| 70 | + </Card> | |
| 71 | + <Card title="Using Local Model Blocks" icon="file-lines" vertical> | |
| 72 | + Create a local model block for reuse across agents without publishing it to the Hub. | |
| 73 | + </Card> | |
| 74 | +</CardGroup> | |
| 75 | + | |
| 76 | + | |
| 77 | +### Configuration Examples | |
| 78 | +<Info> | |
| 79 | +**Click a tab** to see an example. | |
| 80 | +</Info> | |
| 81 | +<Tabs> | |
| 82 | +<Tab title="In Local Agent Configuration"> | |
| 83 | + | |
| 84 | +**When to use**: Simple local setups (like using the VS Code extension) when you don't need shared or published blocks. | |
| 85 | + | |
| 86 | +Use a Tetrate model block from the Hub in your local agent configuration: | |
| 87 | + | |
| 88 | +```yaml title="~/.continue/config.yaml" | |
| 89 | +name: Local Agent | |
| 90 | +version: 1.0.0 | |
| 91 | +schema: v1 | |
| 38 | 92 | models: |
| 39 | - - name: <MODEL_NAME> | |
| 40 | - provider: openai | |
| 41 | - model: <MODEL_ID> | |
| 42 | - apiKey: <TETRATE_API_KEY> | |
| 43 | - apiBase: https://api.router.tetrate.ai/v1 | |
| 93 | + - uses: tetrate/claude-sonnet-4 | |
| 94 | + with: | |
| 95 | + TETRATE_API_KEY: ${{ secrets.TETRATE_API_KEY }} | |
| 96 | +context: | |
| 97 | + - provider: code | |
| 98 | + - provider: docs | |
| 99 | + - provider: diff | |
| 100 | + - provider: terminal | |
| 101 | + - provider: problems | |
| 102 | + - provider: folder | |
| 103 | + - provider: codebase | |
| 44 | 104 | ``` |
| 45 | 105 | |
| 46 | -#### As a local model block | |
| 47 | - | |
| 48 | -Review the configuration reference for [model blocks](/reference#models) and using [local blocks](/reference#local-blocks). Ensure you look at the roles and capabilities section and review the [model capabilities guide](/customize/deep-dives/model-capabilities). | |
| 49 | - | |
| 50 | -```yaml title="model_name.yaml" | |
| 51 | - name: <MODEL_NAME> | |
| 52 | - models: | |
| 53 | - - name: <MODEL_NAME> | |
| 54 | - provider: openai | |
| 55 | - model: <MODEL_ID> | |
| 56 | - apiKey: ${{ inputs.TETRATE_API_KEY }} | |
| 57 | - apiBase: https://api.router.tetrate.ai/v1 | |
| 58 | - roles: | |
| 59 | - - chat | |
| 60 | - - edit | |
| 61 | - - apply | |
| 62 | - capabilities: | |
| 63 | - - tool_use | |
| 106 | +Or define the model directly: | |
| 107 | + | |
| 108 | +```yaml title="~/.continue/config.yaml" | |
| 109 | +name: Local Agent | |
| 110 | +version: 1.0.0 | |
| 111 | +schema: v1 | |
| 112 | +models: | |
| 113 | + - name: Claude Sonnet 4 | |
| 114 | + provider: tars | |
| 115 | + model: claude-4-sonnet-20250514 | |
| 116 | + apiKey: ${{ secrets.TETRATE_API_KEY }} | |
| 117 | + roles: | |
| 118 | + - chat | |
| 119 | + - edit | |
| 120 | + - apply | |
| 121 | + capabilities: | |
| 122 | + - tool_use | |
| 123 | +context: | |
| 124 | + - provider: code | |
| 125 | + - provider: docs | |
| 126 | + - provider: diff | |
| 127 | + - provider: terminal | |
| 128 | + - provider: problems | |
| 129 | + - provider: folder | |
| 130 | + - provider: codebase | |
| 131 | +``` | |
| 132 | +</Tab> | |
| 133 | +<Tab title="Continue Hub"> | |
| 134 | +**When to use**: Share configurations across teams or contribute to the community. | |
| 135 | + | |
| 136 | +**The Model Block:** | |
| 137 | + | |
| 138 | +```yaml title="tetrate/claude-sonnet-4" | |
| 139 | +name: Claude Sonnet 4 | |
| 140 | +version: 1.0.14 | |
| 141 | +schema: v1 | |
| 142 | +models: | |
| 143 | + - name: Claude Sonnet 4 - Tetrate | |
| 144 | + provider: tars | |
| 145 | + model: claude-4-sonnet-20250514 | |
| 146 | + apiKey: ${{ inputs.TETRATE_API_KEY }} | |
| 147 | + roles: | |
| 148 | + - chat | |
| 149 | + - edit | |
| 150 | + - apply | |
| 151 | + capabilities: | |
| 152 | + - tool_use | |
| 64 | 153 | ``` |
| 154 | +View the model block `tetrate/claude-sonnet-4` on the [Continue Hub](https://hub.continue.dev/tetrate/claude-sonnet-4). | |
| 65 | 155 | |
| 66 | -### On Model Block on Continue Hub | |
| 67 | -Learn how to use model blocks on Continue Hub [here](/hub/blocks/create-a-block). | |
| 68 | - | |
| 69 | -```yaml title="model_name.yaml" | |
| 70 | - name: <MODEL_NAME> | |
| 71 | - models: | |
| 72 | - - name: <MODEL_NAME> | |
| 73 | - provider: openai | |
| 74 | - model: <MODEL_ID> | |
| 75 | - apiKey: ${{ inputs.TETRATE_API_KEY }} | |
| 76 | - apiBase: https://api.router.tetrate.ai/v1 | |
| 77 | - roles: | |
| 78 | - - chat | |
| 79 | - - edit | |
| 80 | - - apply | |
| 81 | - capabilities: | |
| 82 | - - tool_use | |
| 156 | +**Reference it in your Agent configuration:** | |
| 157 | + | |
| 158 | +```yaml title="my-agent" | |
| 159 | +name: My Agent | |
| 160 | +version: 1.0.0 | |
| 161 | +schema: v1 | |
| 162 | +models: | |
| 163 | + - uses: tetrate/claude-sonnet-4 | |
| 164 | + with: | |
| 165 | + TETRATE_API_KEY: ${{ secrets.TETRATE_API_KEY }} | |
| 166 | +context: | |
| 167 | + - uses: continuedev/diff-context | |
| 168 | + - uses: continuedev/terminal-context | |
| 169 | + - uses: continuedev/file-context | |
| 170 | +``` | |
| 171 | +<Tip> | |
| 172 | +To customize, see the [model block creation guide](/hub/blocks/create-a-block). | |
| 173 | +</Tip> | |
| 174 | + | |
| 175 | +</Tab> | |
| 176 | + | |
| 177 | +<Tab title="Using Local Model Blocks"> | |
| 178 | +**When to use**: Reuse configurations across agents and keep them local or in GitHub (not on Continue Hub). | |
| 179 | + | |
| 180 | +**The Local Model Block:** | |
| 181 | +<Info> | |
| 182 | +Name the file `my-claude-4-model.yaml` so you can reference it in the Agent. | |
| 183 | +</Info> | |
| 184 | + | |
| 185 | +```yaml title="~/.continue/models/my-claude-4-model.yaml" | |
| 186 | +name: Claude Sonnet 4 | |
| 187 | +version: 1.0.1 | |
| 188 | +schema: v1 | |
| 189 | +models: | |
| 190 | + - name: Claude Sonnet 4 | |
| 191 | + provider: tars | |
| 192 | + model: claude-4-sonnet-20250514 | |
| 193 | + apiKey: ${{ inputs.TETRATE_API_KEY }} | |
| 194 | + roles: | |
| 195 | + - chat | |
| 196 | + - edit | |
| 197 | + - apply | |
| 198 | + capabilities: | |
| 199 | + - tool_use | |
| 200 | +``` | |
| 201 | +Reference it as `my-claude-4-model` in your Agent configuration: | |
| 202 | + | |
| 203 | +```yaml title="~/.continue/agents/simple-agent.yaml" | |
| 204 | +name: Simple Agent | |
| 205 | +version: 1.0.0 | |
| 206 | +schema: v1 | |
| 207 | +models: | |
| 208 | + - uses: my-claude-4-model | |
| 209 | + with: | |
| 210 | + TETRATE_API_KEY: ${{ secrets.TETRATE_API_KEY }} | |
| 211 | +context: | |
| 212 | + - uses: continuedev/diff-context | |
| 213 | + - uses: continuedev/terminal-context | |
| 214 | + - uses: continuedev/file-context | |
| 83 | 215 | ``` |
| 216 | + | |
| 217 | +<Tip> | |
| 218 | +Learn more about [model blocks](/reference#models) and [local blocks](/reference#local-blocks). | |
| 219 | +</Tip> | |
| 220 | + | |
| 221 | +</Tab> | |
| 222 | +</Tabs> | |
| 223 | + | |
| 224 | +--- | |
| 225 | + | |
| 226 | +## Troubleshooting Common Issues | |
| 227 | + | |
| 228 | +<CardGroup cols={2}> | |
| 229 | + <Card title="Invalid API key" icon="key" vertical> | |
| 230 | + Verify your API key is active and has no extra spaces. | |
| 231 | + </Card> | |
| 232 | + <Card title="Model not found" icon="ban" href="https://router.tetrate.ai/models" vertical> | |
| 233 | + Confirm the model ID matches the Tetrate catalog. | |
| 234 | + </Card> | |
| 235 | + <Card title="Slow responses" icon="code" vertical> | |
| 236 | + Check your network or try a less-loaded model. Contact Tetrate support if issues persist. | |
| 237 | + </Card> | |
| 238 | + <Card title="Configuration not loading" icon="file-lines" vertical> | |
| 239 | + Validate YAML syntax and review error messages in Continue. If using Hub, ensure the block is published. | |
| 240 | + </Card> | |
| 241 | +</CardGroup> | |
| 242 | + | |
| 243 | +--- | |
| 244 | + | |
| 245 | +## Join the Community | |
| 246 | +Connect with Tetrate and other builders for help and discussion. | |
| 247 | + | |
| 248 | +<CardGroup cols={1}> | |
| 249 | + <Card title="Join the Tetrate Community" icon="slack" href="https://join.slack.com/t/tetrate-agent-router/shared_invite/zt-399tv7hjm-6YMXztGywTOQrMIolvEBNg"> | |
| 250 | +Get answers, insights, and best practices for secure, scalable infrastructure | |
| 251 | + </Card> | |
| 252 | +</CardGroup> |
| @@ -360,10 +360,6 @@ | ||
| 360 | 360 | "source": "/hub/blocks", |
| 361 | 361 | "destination": "/hub/blocks/intro" |
| 362 | 362 | }, |
| 363 | - { | |
| 364 | - "source": "/hub/agents/intro", | |
| 365 | - "destination": "/hub/agents/intro" | |
| 366 | - }, | |
| 367 | 363 | { |
| 368 | 364 | "source": "/customize", |
| 369 | 365 | "destination": "/customization/overview" |
| @@ -403,6 +403,7 @@ | ||
| 403 | 403 | - `env`: An optional map of environment variables for the server process. |
| 404 | 404 | - `cwd`: An optional working directory to run the command in. Can be absolute or relative path. |
| 405 | 405 | - `connectionTimeout`: An optional connection timeout number to the server in milliseconds. |
| 406 | +- `requestOptions`: Optional request options for `sse` and `streamable-http` servers. Same format as [model requestOptions](#models). | |
| 406 | 407 | |
| 407 | 408 | **Example:** |
| 408 | 409 |
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | "license": "Apache-2.0", |
| 38 | 38 | "repository": { |
| 39 | 39 | "type": "git", |
| 40 | - "url": "https://github.com/continuedev/cli.git" | |
| 40 | + "url": "https://github.com/continuedev/continue.git" | |
| 41 | 41 | }, |
| 42 | 42 | "bugs": { |
| 43 | 43 | "url": "https://github.com/continuedev/continue/issues" |
| @@ -16,9 +16,11 @@ | ||
| 16 | 16 | import { ToolCall } from "../tools/index.js"; |
| 17 | 17 | import { |
| 18 | 18 | chatCompletionStreamWithBackoff, |
| 19 | + isContextLengthError, | |
| 19 | 20 | withExponentialBackoff, |
| 20 | 21 | } from "../util/exponentialBackoff.js"; |
| 21 | 22 | import { logger } from "../util/logger.js"; |
| 23 | +import { validateContextLength } from "../util/tokenizer.js"; | |
| 22 | 24 | |
| 23 | 25 | import { getAllTools, handleToolCalls } from "./handleToolCalls.js"; |
| 24 | 26 | import { handleAutoCompaction } from "./streamChatResponse.autoCompaction.js"; |
| @@ -148,6 +150,12 @@ | ||
| 148 | 150 | tools, |
| 149 | 151 | } = options; |
| 150 | 152 | |
| 153 | + // Validate context length before making the request | |
| 154 | + const validation = validateContextLength(chatHistory, model); | |
| 155 | + if (!validation.isValid) { | |
| 156 | + throw new Error(`Context length validation failed: ${validation.error}`); | |
| 157 | + } | |
| 158 | + | |
| 151 | 159 | // Get fresh system message and inject it |
| 152 | 160 | const systemMessage = await systemMessageService.getSystemMessage(); |
| 153 | 161 | const openaiChatHistory = convertFromUnifiedHistoryWithSystemMessage( |
| @@ -277,6 +285,13 @@ | ||
| 277 | 285 | shouldContinue: false, |
| 278 | 286 | }; |
| 279 | 287 | } |
| 288 | + | |
| 289 | + // Handle context length errors with helpful message | |
| 290 | + if (isContextLengthError(error)) { | |
| 291 | + logger.debug(`Context length exceeded: ${error}`); | |
| 292 | + throw new Error(`Context length exceeded: ${error}`); | |
| 293 | + } | |
| 294 | + | |
| 280 | 295 | throw error; |
| 281 | 296 | } |
| 282 | 297 |
| @@ -77,10 +77,40 @@ | ||
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | +/** | |
| 81 | + * Checks if the error indicates a context length issue (non-retryable) | |
| 82 | + */ | |
| 83 | +export function isContextLengthError(error: any): boolean { | |
| 84 | + const errorMessage = error.message?.toLowerCase() || ""; | |
| 85 | + const contextLengthPatterns = [ | |
| 86 | + // Anthropic Claude | |
| 87 | + "input length and max_tokens exceed context limit", | |
| 88 | + "decrease input length or max_tokens", | |
| 89 | + // OpenAI | |
| 90 | + "maximum context length", | |
| 91 | + "reduce the length of the messages", | |
| 92 | + // Mistral | |
| 93 | + "tokens in the prompt exceeds", | |
| 94 | + "use a shorter prompt", | |
| 95 | + // Generic patterns | |
| 96 | + "context_length_exceeded", | |
| 97 | + "invalid_request_error", | |
| 98 | + ]; | |
| 99 | + | |
| 100 | + return contextLengthPatterns.some((pattern) => | |
| 101 | + errorMessage.includes(pattern), | |
| 102 | + ); | |
| 103 | +} | |
| 104 | + | |
| 80 | 105 | /** |
| 81 | 106 | * Determines if an error is retryable based on the error type and status code |
| 82 | 107 | */ |
| 83 | 108 | function isRetryableError(error: any): boolean { |
| 109 | + // Context length errors are never retryable - they need user intervention | |
| 110 | + if (isContextLengthError(error)) { | |
| 111 | + return false; | |
| 112 | + } | |
| 113 | + | |
| 84 | 114 | // Network errors are retryable |
| 85 | 115 | if (isNetworkError(error)) { |
| 86 | 116 | return true; |
| @@ -0,0 +1,62 @@ | ||
| 1 | +import { ModelConfig } from "@continuedev/config-yaml"; | |
| 2 | +import { describe, expect, it } from "vitest"; | |
| 3 | + | |
| 4 | +import { validateContextLength } from "./tokenizer.js"; | |
| 5 | + | |
| 6 | +describe("validateContextLength", () => { | |
| 7 | + const createMockModel = ( | |
| 8 | + contextLength: number, | |
| 9 | + maxTokens?: number, | |
| 10 | + ): ModelConfig => ({ | |
| 11 | + name: "test-model", | |
| 12 | + model: "test", | |
| 13 | + provider: "openai", | |
| 14 | + defaultCompletionOptions: { | |
| 15 | + contextLength, | |
| 16 | + maxTokens, | |
| 17 | + }, | |
| 18 | + }); | |
| 19 | + | |
| 20 | + const createMockHistory = (messageCount: number, contentLength = 100) => { | |
| 21 | + return Array.from({ length: messageCount }, (_, i) => ({ | |
| 22 | + message: { | |
| 23 | + role: "user" as const, | |
| 24 | + content: "x".repeat(contentLength), // Roughly contentLength/4 tokens | |
| 25 | + }, | |
| 26 | + contextItems: [], | |
| 27 | + })); | |
| 28 | + }; | |
| 29 | + | |
| 30 | + it("should pass validation when within context limits", () => { | |
| 31 | + const model = createMockModel(1000, 200); | |
| 32 | + const chatHistory = createMockHistory(5, 40); // ~50 tokens total | |
| 33 | + | |
| 34 | + const result = validateContextLength(chatHistory, model); | |
| 35 | + | |
| 36 | + expect(result.isValid).toBe(true); | |
| 37 | + expect(result.error).toBeUndefined(); | |
| 38 | + }); | |
| 39 | + | |
| 40 | + it("should fail validation when input + maxTokens exceeds context limit", () => { | |
| 41 | + const model = createMockModel(1000, 800); | |
| 42 | + const chatHistory = createMockHistory(20, 100); // ~500+ tokens | |
| 43 | + | |
| 44 | + const result = validateContextLength(chatHistory, model); | |
| 45 | + | |
| 46 | + expect(result.isValid).toBe(false); | |
| 47 | + expect(result.error).toContain("Context length exceeded"); | |
| 48 | + expect(result.error).toContain("input"); | |
| 49 | + expect(result.error).toContain("max_tokens"); | |
| 50 | + expect(result.error).toContain("context_limit"); | |
| 51 | + }); | |
| 52 | + | |
| 53 | + it("should handle large models with appropriate scaling", () => { | |
| 54 | + const model = createMockModel(200_000, 64_000); // Claude-like model | |
| 55 | + const chatHistory = createMockHistory(100, 1000); // Large conversation | |
| 56 | + | |
| 57 | + const result = validateContextLength(chatHistory, model); | |
| 58 | + | |
| 59 | + expect(result.contextLimit).toBe(200_000); | |
| 60 | + expect(result.maxTokens).toBe(64_000); | |
| 61 | + }); | |
| 62 | +}); |
| @@ -78,14 +78,14 @@ | ||
| 78 | 78 | role: "user", |
| 79 | 79 | content: [ |
| 80 | 80 | { type: "text", text: "Hello" }, // 5 chars -> ~2 tokens |
| 81 | - { type: "imageUrl", imageUrl: { url: "test.jpg" } }, // +85 tokens | |
| 81 | + { type: "imageUrl", imageUrl: { url: "test.jpg" } }, // +1024 tokens | |
| 82 | 82 | ], |
| 83 | 83 | }, |
| 84 | 84 | contextItems: [], |
| 85 | 85 | }; |
| 86 | 86 | |
| 87 | 87 | const tokenCount = countChatHistoryItemTokens(historyItem); |
| 88 | - expect(tokenCount).toBe(89); // 2 + 85 + 2 role tokens | |
| 88 | + expect(tokenCount).toBe(1028); // 2 + 1024 + 2 role tokens | |
| 89 | 89 | }); |
| 90 | 90 | |
| 91 | 91 | it("should count tokens for tool calls", () => { |
| @@ -47,7 +47,7 @@ | ||
| 47 | 47 | // Images and other content types have their own token costs |
| 48 | 48 | // but we'll use a rough estimate for now |
| 49 | 49 | if (part.type === "imageUrl") { |
| 50 | - tokenCount += 85; // Rough estimate for image tokens | |
| 50 | + tokenCount += 1024; // Rough estimate for image tokens | |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
| @@ -192,3 +192,46 @@ | ||
| 192 | 192 | const limit = getModelContextLimit(model); |
| 193 | 193 | return `Approaching context limit (${(limit / 1000).toFixed(0)}K tokens). Auto-compacting chat history...`; |
| 194 | 194 | } |
| 195 | + | |
| 196 | +/** | |
| 197 | + * Validates that the input tokens + max_tokens don't exceed context limit | |
| 198 | + * @param chatHistory The chat history to validate | |
| 199 | + * @param model The model configuration | |
| 200 | + * @returns Validation result with error details if invalid | |
| 201 | + */ | |
| 202 | +export function validateContextLength( | |
| 203 | + chatHistory: ChatHistoryItem[], | |
| 204 | + model: ModelConfig, | |
| 205 | +): { | |
| 206 | + isValid: boolean; | |
| 207 | + error?: string; | |
| 208 | + inputTokens?: number; | |
| 209 | + contextLimit?: number; | |
| 210 | + maxTokens?: number; | |
| 211 | +} { | |
| 212 | + const inputTokens = countChatHistoryTokens(chatHistory); | |
| 213 | + const contextLimit = getModelContextLimit(model); | |
| 214 | + const maxTokens = model.defaultCompletionOptions?.maxTokens || 0; | |
| 215 | + | |
| 216 | + // If maxTokens is not set, use 35% default reservation for output | |
| 217 | + const reservedForOutput = | |
| 218 | + maxTokens > 0 ? maxTokens : Math.ceil(contextLimit * 0.35); | |
| 219 | + const totalRequired = inputTokens + reservedForOutput; | |
| 220 | + | |
| 221 | + if (totalRequired > contextLimit) { | |
| 222 | + return { | |
| 223 | + isValid: false, | |
| 224 | + error: `Context length exceeded: input (${inputTokens.toLocaleString()}) + max_tokens (${reservedForOutput.toLocaleString()}) = ${totalRequired.toLocaleString()} > context_limit (${contextLimit.toLocaleString()})`, | |
| 225 | + inputTokens, | |
| 226 | + contextLimit, | |
| 227 | + maxTokens: reservedForOutput, | |
| 228 | + }; | |
| 229 | + } | |
| 230 | + | |
| 231 | + return { | |
| 232 | + isValid: true, | |
| 233 | + inputTokens, | |
| 234 | + contextLimit, | |
| 235 | + maxTokens: reservedForOutput, | |
| 236 | + }; | |
| 237 | +} |
| @@ -45,6 +45,76 @@ | ||
| 45 | 45 | private val continuePluginService: ContinuePluginService, |
| 46 | 46 | |
| 47 | 47 | ) : IDE { |
| 48 | + | |
| 49 | + // Security-focused ignore patterns - should always be excluded for security reasons | |
| 50 | + private val DEFAULT_SECURITY_IGNORE_FILETYPES = listOf( | |
| 51 | + // Environment and configuration files with secrets | |
| 52 | + "*.env", "*.env.*", ".env*", "config.json", "config.yaml", "config.yml", | |
| 53 | + "settings.json", "appsettings.json", "appsettings.*.json", | |
| 54 | + | |
| 55 | + // Certificate and key files | |
| 56 | + "*.key", "*.pem", "*.p12", "*.pfx", "*.crt", "*.cer", "*.jks", | |
| 57 | + "*.keystore", "*.truststore", | |
| 58 | + | |
| 59 | + // Database files that may contain sensitive data | |
| 60 | + "*.db", "*.sqlite", "*.sqlite3", "*.mdb", "*.accdb", | |
| 61 | + | |
| 62 | + // Credential and secret files | |
| 63 | + "*.secret", "*.secrets", "credentials", "credentials.*", "auth.json", | |
| 64 | + "token", "token.*", "*.token", | |
| 65 | + | |
| 66 | + // Backup files that might contain sensitive data | |
| 67 | + "*.bak", "*.backup", "*.old", "*.orig", | |
| 68 | + | |
| 69 | + // Docker secrets | |
| 70 | + "docker-compose.override.yml", "docker-compose.override.yaml", | |
| 71 | + | |
| 72 | + // SSH and GPG | |
| 73 | + "id_rsa", "id_dsa", "id_ecdsa", "id_ed25519", "*.ppk", "*.gpg" | |
| 74 | + ) | |
| 75 | + | |
| 76 | + private val DEFAULT_SECURITY_IGNORE_DIRS = listOf( | |
| 77 | + // Environment and configuration directories | |
| 78 | + ".env/", "env/", | |
| 79 | + | |
| 80 | + // Cloud provider credential directories | |
| 81 | + ".aws/", ".gcp/", ".azure/", ".kube/", ".docker/", | |
| 82 | + | |
| 83 | + // Secret directories | |
| 84 | + "secrets/", ".secrets/", "private/", ".private/", "certs/", | |
| 85 | + "certificates/", "keys/", ".ssh/", ".gnupg/", ".gpg/", | |
| 86 | + | |
| 87 | + // Temporary directories that might contain sensitive data | |
| 88 | + "tmp/secrets/", "temp/secrets/", ".tmp/" | |
| 89 | + ) | |
| 90 | + | |
| 91 | + // Additional non-security patterns for general indexing exclusion | |
| 92 | + private val ADDITIONAL_SEARCH_IGNORE_FILETYPES = listOf( | |
| 93 | + "*.DS_Store", "*-lock.json", "*.lock", "*.log", "*.ttf", "*.png", | |
| 94 | + "*.jpg", "*.jpeg", "*.gif", "*.mp4", "*.svg", "*.ico", "*.pdf", | |
| 95 | + "*.zip", "*.gz", "*.tar", "*.dmg", "*.tgz", "*.rar", "*.7z", | |
| 96 | + "*.exe", "*.dll", "*.obj", "*.o", "*.o.d", "*.a", "*.lib", | |
| 97 | + "*.so", "*.dylib", "*.ncb", "*.sdf", "*.woff", "*.woff2", | |
| 98 | + "*.eot", "*.cur", "*.avi", "*.mpg", "*.mpeg", "*.mov", "*.mp3", | |
| 99 | + "*.mkv", "*.webm", "*.jar", "*.onnx", "*.parquet", "*.pqt", | |
| 100 | + "*.wav", "*.webp", "*.wasm", "*.plist", "*.profraw", "*.gcda", | |
| 101 | + "*.gcno", "go.sum", "*.gitignore", "*.gitkeep", "*.continueignore", | |
| 102 | + "*.csv", "*.uasset", "*.pdb", "*.bin", "*.pag", "*.swp", "*.jsonl" | |
| 103 | + ) | |
| 104 | + | |
| 105 | + private val ADDITIONAL_SEARCH_IGNORE_DIRS = listOf( | |
| 106 | + ".git/", ".svn/", "node_modules/", "dist/", "build/", "Build/", | |
| 107 | + "target/", "out/", "bin/", ".pytest_cache/", ".vscode-test/", | |
| 108 | + "__pycache__/", "site-packages/", ".gradle/", ".mvn/", ".cache/", | |
| 109 | + "gems/", "vendor/", ".venv/", "venv/", ".vscode/", ".idea/", ".vs/", | |
| 110 | + ".continue/" | |
| 111 | + ) | |
| 112 | + | |
| 113 | + // Combined patterns for use in ripgrep | |
| 114 | + private val DEFAULT_IGNORES = DEFAULT_SECURITY_IGNORE_FILETYPES + | |
| 115 | + DEFAULT_SECURITY_IGNORE_DIRS + | |
| 116 | + ADDITIONAL_SEARCH_IGNORE_FILETYPES + | |
| 117 | + ADDITIONAL_SEARCH_IGNORE_DIRS | |
| 48 | 118 | |
| 49 | 119 | private val gitService = GitService(project, continuePluginService) |
| 50 | 120 | private val fileUtils = FileUtils(project) |
| @@ -335,6 +405,9 @@ | ||
| 335 | 405 | val ideInfo = this.getIdeInfo() |
| 336 | 406 | if (ideInfo.remoteName == "local") { |
| 337 | 407 | try { |
| 408 | + // Create a single combined ignore pattern using glob brace expansion | |
| 409 | + val defaultIgnorePattern = DEFAULT_IGNORES.joinToString(",") { it } | |
| 410 | + | |
| 338 | 411 | var commandArgs = mutableListOf<String>( |
| 339 | 412 | ripgrep, |
| 340 | 413 | "--files", |
| @@ -343,7 +416,9 @@ | ||
| 343 | 416 | "--ignore-file", |
| 344 | 417 | ".continueignore", |
| 345 | 418 | "--ignore-file", |
| 346 | - ".gitignore" | |
| 419 | + ".gitignore", | |
| 420 | + "--glob", | |
| 421 | + "!{${defaultIgnorePattern}}" | |
| 347 | 422 | ) |
| 348 | 423 | if (maxResults != null) { |
| 349 | 424 | commandArgs.add("--max-count") |
| @@ -370,6 +445,9 @@ | ||
| 370 | 445 | val ideInfo = this.getIdeInfo() |
| 371 | 446 | if (ideInfo.remoteName == "local") { |
| 372 | 447 | try { |
| 448 | + // Create a single combined ignore pattern for ripgrep | |
| 449 | + val defaultIgnorePattern = DEFAULT_IGNORES.joinToString(",") { it } | |
| 450 | + | |
| 373 | 451 | val commandArgs = mutableListOf( |
| 374 | 452 | ripgrep, |
| 375 | 453 | "-i", |
| @@ -379,7 +457,9 @@ | ||
| 379 | 457 | ".gitignore", |
| 380 | 458 | "-C", |
| 381 | 459 | "2", |
| 382 | - "--heading" | |
| 460 | + "--heading", | |
| 461 | + "--glob", | |
| 462 | + "!{${defaultIgnorePattern}}" // Exclude all default ignores using brace expansion | |
| 383 | 463 | ) |
| 384 | 464 | |
| 385 | 465 | // Conditionally add maxResults flag |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | |
| 4 | 4 | import { Range } from "core"; |
| 5 | 5 | import { EXTENSION_NAME } from "core/control-plane/env"; |
| 6 | +import { DEFAULT_IGNORES, defaultIgnoresGlob } from "core/indexing/ignore"; | |
| 6 | 7 | import * as URI from "uri-js"; |
| 7 | 8 | import * as vscode from "vscode"; |
| 8 | 9 | |
| @@ -452,7 +453,9 @@ | ||
| 452 | 453 | resolve(output); |
| 453 | 454 | } else if (code === 1) { |
| 454 | 455 | // No matches |
| 455 | - resolve("No matches found"); | |
| 456 | + resolve( | |
| 457 | + "No matches found. Build, secrets, etc. dirs and files are not included.", | |
| 458 | + ); | |
| 456 | 459 | } else { |
| 457 | 460 | reject(new Error(`Process exited with code ${code}`)); |
| 458 | 461 | } |
| @@ -464,6 +467,8 @@ | ||
| 464 | 467 | pattern: string, |
| 465 | 468 | maxResults?: number, |
| 466 | 469 | ): Promise<string[]> { |
| 470 | + // Create a single combined ignore pattern for ripgrep (calculated once) | |
| 471 | + | |
| 467 | 472 | if (vscode.env.remoteName) { |
| 468 | 473 | // TODO better tests for this remote search implementation |
| 469 | 474 | // throw new Error("Ripgrep not supported, this workspace is remote"); |
| @@ -475,6 +480,11 @@ | ||
| 475 | 480 | ); |
| 476 | 481 | |
| 477 | 482 | const ignoreGlobs: Set<string> = new Set(); |
| 483 | + // Add default ignores from core | |
| 484 | + for (const pattern of DEFAULT_IGNORES) { | |
| 485 | + ignoreGlobs.add(pattern); | |
| 486 | + } | |
| 487 | + | |
| 478 | 488 | for (const file of ignoreFiles) { |
| 479 | 489 | const content = await this.ideUtils.readFile(file); |
| 480 | 490 | if (content === null) { |
| @@ -535,6 +545,7 @@ | ||
| 535 | 545 | return results.map((result) => vscode.workspace.asRelativePath(result)); |
| 536 | 546 | } else { |
| 537 | 547 | const results: string[] = []; |
| 548 | + // Create a single combined ignore pattern using glob brace expansion | |
| 538 | 549 | for (const dir of await this.getWorkspaceDirs()) { |
| 539 | 550 | const dirResults = await this.runRipgrepQuery(dir, [ |
| 540 | 551 | "--files", |
| @@ -544,6 +555,8 @@ | ||
| 544 | 555 | ".continueignore", |
| 545 | 556 | "--ignore-file", |
| 546 | 557 | ".gitignore", |
| 558 | + "--glob", | |
| 559 | + defaultIgnoresGlob, | |
| 547 | 560 | ...(maxResults ? ["--max-count", String(maxResults)] : []), |
| 548 | 561 | ]); |
| 549 | 562 | |
| @@ -566,6 +579,7 @@ | ||
| 566 | 579 | throw new Error("Ripgrep not supported, this workspace is remote"); |
| 567 | 580 | } |
| 568 | 581 | const results: string[] = []; |
| 582 | + | |
| 569 | 583 | for (const dir of await this.getWorkspaceDirs()) { |
| 570 | 584 | const dirResults = await this.runRipgrepQuery(dir, [ |
| 571 | 585 | "-i", // Case-insensitive search |
| @@ -576,6 +590,9 @@ | ||
| 576 | 590 | "-C", |
| 577 | 591 | "2", // Show 2 lines of context |
| 578 | 592 | "--heading", // Only show filepath once per result |
| 593 | + // Use a single glob with all default ignores | |
| 594 | + "--glob", | |
| 595 | + defaultIgnoresGlob, | |
| 579 | 596 | ...(maxResults ? ["-m", maxResults.toString()] : []), |
| 580 | 597 | "-e", |
| 581 | 598 | query, // Pattern to search for |
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | import { walkDirAsync } from "core/indexing/walkDir"; |
| 10 | 10 | import { isModelInstaller } from "core/llm"; |
| 11 | 11 | import { startLocalOllama } from "core/util/ollamaHelper"; |
| 12 | +import { startLocalLemonade } from "core/util/lemonadeHelper"; | |
| 12 | 13 | import { getConfigJsonPath, getConfigYamlPath } from "core/util/paths"; |
| 13 | 14 | import { Telemetry } from "core/util/posthog"; |
| 14 | 15 | import * as vscode from "vscode"; |
| @@ -620,6 +621,9 @@ | ||
| 620 | 621 | "continue.startLocalOllama": () => { |
| 621 | 622 | startLocalOllama(ide); |
| 622 | 623 | }, |
| 624 | + "continue.startLocalLemonade": () => { | |
| 625 | + startLocalLemonade(ide); | |
| 626 | + }, | |
| 623 | 627 | "continue.installModel": async ( |
| 624 | 628 | modelName: string, |
| 625 | 629 | llmProvider: ILLM | undefined, |
| @@ -76,6 +76,39 @@ | ||
| 76 | 76 | this.disposables.push(disposable); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | + /** ensures the current target file is open and focused before performing edits*/ | |
| 80 | + private async ensureCurrentFileIsFocused() { | |
| 81 | + const targetUri = this.editor.document.uri; | |
| 82 | + const active = vscode.window.activeTextEditor; | |
| 83 | + if ( | |
| 84 | + active && | |
| 85 | + URI.equal(active.document.uri.toString(), targetUri.toString()) | |
| 86 | + ) { | |
| 87 | + this.editor = active; | |
| 88 | + return; | |
| 89 | + } | |
| 90 | + | |
| 91 | + const visible = vscode.window.visibleTextEditors.find((foundEditor) => | |
| 92 | + URI.equal(foundEditor.document.uri.toString(), targetUri.toString()), | |
| 93 | + ); | |
| 94 | + if (visible) { | |
| 95 | + await vscode.window.showTextDocument(visible.document, { | |
| 96 | + preview: false, | |
| 97 | + preserveFocus: false, | |
| 98 | + viewColumn: visible.viewColumn, | |
| 99 | + }); | |
| 100 | + this.editor = vscode.window.activeTextEditor ?? visible; | |
| 101 | + return; | |
| 102 | + } | |
| 103 | + | |
| 104 | + const doc = await vscode.workspace.openTextDocument(targetUri); | |
| 105 | + const editor = await vscode.window.showTextDocument(doc, { | |
| 106 | + preview: false, | |
| 107 | + preserveFocus: false, | |
| 108 | + }); | |
| 109 | + this.editor = editor; | |
| 110 | + } | |
| 111 | + | |
| 79 | 112 | public get range(): vscode.Range { |
| 80 | 113 | const startLine = Math.min(this.startLine, this.endLine); |
| 81 | 114 | const endLine = Math.max(this.startLine, this.endLine); |
| @@ -296,6 +329,8 @@ | ||
| 296 | 329 | // Diff is messed up without this delay. |
| 297 | 330 | await new Promise((resolve) => setTimeout(resolve, 100)); |
| 298 | 331 | |
| 332 | + await this.ensureCurrentFileIsFocused(); | |
| 333 | + | |
| 299 | 334 | // First, we reset the original diff by rejecting all pending diff blocks |
| 300 | 335 | const blocks = this.editorToVerticalDiffCodeLens.get(this.fileUri) ?? []; |
| 301 | 336 | for (const block of blocks.reverse()) { |
| @@ -443,6 +478,7 @@ | ||
| 443 | 478 | } |
| 444 | 479 | |
| 445 | 480 | private async insertTextAboveLine(index: number, text: string) { |
| 481 | + await this.ensureCurrentFileIsFocused(); | |
| 446 | 482 | await this.editor.edit( |
| 447 | 483 | (editBuilder) => { |
| 448 | 484 | const lineCount = this.editor.document.lineCount; |
| @@ -471,6 +507,7 @@ | ||
| 471 | 507 | |
| 472 | 508 | private async deleteLinesAt(index: number, numLines = 1) { |
| 473 | 509 | const startLine = new vscode.Position(index, 0); |
| 510 | + await this.ensureCurrentFileIsFocused(); | |
| 474 | 511 | await this.editor.edit( |
| 475 | 512 | (editBuilder) => { |
| 476 | 513 | editBuilder.delete( |
| @@ -482,6 +519,7 @@ | ||
| 482 | 519 | } |
| 483 | 520 | |
| 484 | 521 | private async deleteRangeLines(ranges: vscode.Range[]) { |
| 522 | + await this.ensureCurrentFileIsFocused(); | |
| 485 | 523 | await this.editor.edit( |
| 486 | 524 | (editBuilder) => { |
| 487 | 525 | for (const range of ranges) { |
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | this.fileUriToHandler.get(fileUri)?.clear(false); |
| 52 | 52 | this.fileUriToHandler.delete(fileUri); |
| 53 | 53 | } |
| 54 | - const editor = vscode.window.activeTextEditor; // TODO might cause issues if user switches files | |
| 54 | + const editor = vscode.window.activeTextEditor; | |
| 55 | 55 | if (editor && URI.equal(editor.document.uri.toString(), fileUri)) { |
| 56 | 56 | const handler = new VerticalDiffHandler( |
| 57 | 57 | startLine, |
| @@ -3,13 +3,41 @@ | ||
| 3 | 3 | import * as vscode from "vscode"; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | - * @param error Handles common LLM errors. Currently only handles Ollama-related errors. | |
| 6 | + * @param error Handles common LLM errors. Currently handles Ollama and Lemonade-related errors. | |
| 7 | 7 | * @returns true if error is handled, false otherwise |
| 8 | 8 | */ |
| 9 | 9 | export async function handleLLMError(error: unknown): Promise<boolean> { |
| 10 | 10 | if (!error || !(error instanceof Error) || !error.message) { |
| 11 | 11 | return false; |
| 12 | 12 | } |
| 13 | + | |
| 14 | + // Handle Lemonade errors | |
| 15 | + if (error.message.toLowerCase().includes("lemonade")) { | |
| 16 | + let message: string = error.message; | |
| 17 | + let options: string[] | undefined; | |
| 18 | + | |
| 19 | + // For Windows, offer to start Lemonade if it's installed but not running | |
| 20 | + if ( | |
| 21 | + process.platform === "win32" && | |
| 22 | + message.includes("Lemonade server may not be running") | |
| 23 | + ) { | |
| 24 | + options = ["Start Lemonade", "Setup Instructions"]; | |
| 25 | + } else { | |
| 26 | + // For all other cases (Linux, not installed, etc.), direct to setup instructions | |
| 27 | + options = ["Setup Instructions"]; | |
| 28 | + } | |
| 29 | + | |
| 30 | + vscode.window.showErrorMessage(message, ...options).then((val) => { | |
| 31 | + if (val === "Setup Instructions") { | |
| 32 | + vscode.env.openExternal(vscode.Uri.parse("https://lemonade-server.ai")); | |
| 33 | + } else if (val === "Start Lemonade") { | |
| 34 | + vscode.commands.executeCommand("continue.startLocalLemonade"); | |
| 35 | + } | |
| 36 | + }); | |
| 37 | + return true; | |
| 38 | + } | |
| 39 | + | |
| 40 | + // Handle Ollama errors | |
| 13 | 41 | if (!error.message.toLowerCase().includes("ollama")) { |
| 14 | 42 | return false; |
| 15 | 43 | } |
| @@ -107,7 +107,7 @@ | ||
| 107 | 107 | |
| 108 | 108 | if (e.cause) { |
| 109 | 109 | if (e.cause.name === "ConnectTimeoutError") { |
| 110 | - message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in config.json by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://docs.continue.dev/reference/config`; | |
| 110 | + message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in your config by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://docs.continue.dev/reference/config`; | |
| 111 | 111 | } else if (e.cause.code === "ECONNREFUSED") { |
| 112 | 112 | message = `Connection was refused. This likely means that there is no server running at the specified URL. If you are running your own server you may need to set the "apiBase" parameter in config.json. For example, you can set up an OpenAI-compatible server like here: https://docs.continue.dev/reference/Model%20Providers/openai#openai-compatible-servers--apis`; |
| 113 | 113 | } else { |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
Binary content is not shown. View the file.
| @@ -1,4 +1,7 @@ | ||
| 1 | -import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + Cog6ToothIcon, | |
| 3 | + ExclamationTriangleIcon, | |
| 4 | +} from "@heroicons/react/24/outline"; | |
| 2 | 5 | import { ProfileDescription } from "core/config/ProfileLifecycleManager"; |
| 3 | 6 | import { useContext, useMemo } from "react"; |
| 4 | 7 | import { useNavigate } from "react-router-dom"; |
| @@ -48,7 +51,7 @@ | ||
| 48 | 51 | disabled={hasFatalErrors} |
| 49 | 52 | onClick={!hasFatalErrors ? handleOptionClick : undefined} |
| 50 | 53 | fontSizeModifier={-2} |
| 51 | - className={selected ? "bg-list-active text-list-active-foreground" : ""} | |
| 54 | + className={`group ${selected ? "bg-list-active text-list-active-foreground" : ""}`} | |
| 52 | 55 | > |
| 53 | 56 | <div className="flex w-full items-center justify-between gap-10 py-0.5"> |
| 54 | 57 | <div className="flex w-full items-center gap-3"> |
| @@ -62,6 +65,20 @@ | ||
| 62 | 65 | </span> |
| 63 | 66 | </div> |
| 64 | 67 | <div className="flex flex-row items-center gap-1.5"> |
| 68 | + <Button | |
| 69 | + variant="ghost" | |
| 70 | + size="sm" | |
| 71 | + className="text-description-muted hover:enabled:text-foreground my-0 h-4 w-4 p-0 opacity-0 transition-opacity group-hover:opacity-100" | |
| 72 | + onClick={(e) => { | |
| 73 | + e.stopPropagation(); | |
| 74 | + ideMessenger.post("config/openProfile", { | |
| 75 | + profileId: profile.id, | |
| 76 | + }); | |
| 77 | + onClick(); // Close the listbox | |
| 78 | + }} | |
| 79 | + > | |
| 80 | + <Cog6ToothIcon className="h-3.5 w-3.5" /> | |
| 81 | + </Button> | |
| 65 | 82 | {profile.errors && profile.errors?.length > 0 && ( |
| 66 | 83 | <ToolTip content="View errors"> |
| 67 | 84 | <Button |
| @@ -1,14 +1,16 @@ | ||
| 1 | -import { CheckIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { Cog6ToothIcon } from "@heroicons/react/24/outline"; | |
| 2 | 2 | import { |
| 3 | 3 | BuildingOfficeIcon, |
| 4 | 4 | UserCircleIcon, |
| 5 | 5 | UserIcon, |
| 6 | 6 | } from "@heroicons/react/24/solid"; |
| 7 | 7 | import { useContext } from "react"; |
| 8 | +import { useNavigate } from "react-router-dom"; | |
| 8 | 9 | import { IdeMessengerContext } from "../../context/IdeMessenger"; |
| 9 | 10 | import { useAppDispatch, useAppSelector } from "../../redux/hooks"; |
| 10 | 11 | import { setSelectedOrgId } from "../../redux/slices/profilesSlice"; |
| 11 | -import { ListboxOption } from "../ui"; | |
| 12 | +import { CONFIG_ROUTES } from "../../util/navigation"; | |
| 13 | +import { Button, ListboxOption } from "../ui"; | |
| 12 | 14 | |
| 13 | 15 | interface OrganizationOptionProps { |
| 14 | 16 | organization: { id: string; name: string; iconUrl?: string | null }; |
| @@ -45,6 +47,7 @@ | ||
| 45 | 47 | onClose, |
| 46 | 48 | }: OrganizationOptionProps) { |
| 47 | 49 | const dispatch = useAppDispatch(); |
| 50 | + const navigate = useNavigate(); | |
| 48 | 51 | const ideMessenger = useContext(IdeMessengerContext); |
| 49 | 52 | const selectedOrgId = useAppSelector( |
| 50 | 53 | (state) => state.profiles.selectedOrganizationId, |
| @@ -64,7 +67,7 @@ | ||
| 64 | 67 | value={organization.id} |
| 65 | 68 | onClick={handleOptionClick} |
| 66 | 69 | fontSizeModifier={-2} |
| 67 | - className={isSelected ? "bg-list-active text-list-active-foreground" : ""} | |
| 70 | + className={`group ${isSelected ? "bg-list-active text-list-active-foreground" : ""}`} | |
| 68 | 71 | > |
| 69 | 72 | <div className="flex w-full items-center justify-between gap-10 py-0.5"> |
| 70 | 73 | <div className="flex w-full items-center gap-3"> |
| @@ -78,7 +81,18 @@ | ||
| 78 | 81 | </span> |
| 79 | 82 | </div> |
| 80 | 83 | <div className="flex flex-row items-center gap-1.5"> |
| 81 | - {isSelected && <CheckIcon className="h-3.5 w-3.5 flex-shrink-0" />} | |
| 84 | + <Button | |
| 85 | + variant="ghost" | |
| 86 | + size="sm" | |
| 87 | + className="text-description-muted hover:enabled:text-foreground my-0 h-4 w-4 p-0 opacity-0 transition-opacity group-hover:opacity-100" | |
| 88 | + onClick={(e) => { | |
| 89 | + e.stopPropagation(); | |
| 90 | + navigate(CONFIG_ROUTES.ORGANIZATIONS); | |
| 91 | + onClose(); // Close the listbox | |
| 92 | + }} | |
| 93 | + > | |
| 94 | + <Cog6ToothIcon className="h-3.5 w-3.5" /> | |
| 95 | + </Button> | |
| 82 | 96 | </div> |
| 83 | 97 | </div> |
| 84 | 98 | </ListboxOption> |
| @@ -2,9 +2,7 @@ | ||
| 2 | 2 | ArrowPathIcon, |
| 3 | 3 | ArrowRightStartOnRectangleIcon, |
| 4 | 4 | Cog6ToothIcon, |
| 5 | - PencilIcon, | |
| 6 | 5 | PlusIcon, |
| 7 | - WrenchScrewdriverIcon, | |
| 8 | 6 | } from "@heroicons/react/24/outline"; |
| 9 | 7 | import { isOnPremSession } from "core/control-plane/AuthTypes"; |
| 10 | 8 | import { useContext, useEffect, useRef } from "react"; |
| @@ -155,7 +153,7 @@ | ||
| 155 | 153 | className="max-h-32 -translate-x-1.5 overflow-y-auto pb-0" |
| 156 | 154 | style={{ zIndex: 200 }} |
| 157 | 155 | > |
| 158 | - <div className="flex items-center justify-between p-2"> | |
| 156 | + <div className="flex items-center justify-between px-1.5 py-1"> | |
| 159 | 157 | <span className="text-description text-xs font-medium"> |
| 160 | 158 | Agents |
| 161 | 159 | </span> |
| @@ -193,7 +191,7 @@ | ||
| 193 | 191 | {shouldRenderOrgInfo && ( |
| 194 | 192 | <> |
| 195 | 193 | <Divider className="!mb-0.5 !mt-0" /> |
| 196 | - <div className="flex items-center justify-between p-2"> | |
| 194 | + <div className="flex items-center justify-between px-1.5 py-1"> | |
| 197 | 195 | <span className="text-description text-xs font-medium"> |
| 198 | 196 | Organizations |
| 199 | 197 | </span> |
| @@ -232,34 +230,6 @@ | ||
| 232 | 230 | {/* Settings Section */} |
| 233 | 231 | {variant !== "sidebar" && ( |
| 234 | 232 | <div> |
| 235 | - <Button | |
| 236 | - onClick={(e) => { | |
| 237 | - e.stopPropagation(); | |
| 238 | - onRulesConfig(); | |
| 239 | - }} | |
| 240 | - variant="ghost" | |
| 241 | - size="sm" | |
| 242 | - className="text-description hover:bg-input my-0 w-full justify-start py-1.5 pl-1 text-left" | |
| 243 | - > | |
| 244 | - <div className="flex w-full items-center"> | |
| 245 | - <PencilIcon className="ml-1.5 mr-2 h-3.5 w-3.5 flex-shrink-0" /> | |
| 246 | - <span className="text-2xs">Rules</span> | |
| 247 | - </div> | |
| 248 | - </Button> | |
| 249 | - <Button | |
| 250 | - onClick={(e) => { | |
| 251 | - e.stopPropagation(); | |
| 252 | - onToolsConfig(); | |
| 253 | - }} | |
| 254 | - variant="ghost" | |
| 255 | - size="sm" | |
| 256 | - className="text-description hover:bg-input my-0 w-full justify-start py-1.5 pl-1 text-left" | |
| 257 | - > | |
| 258 | - <div className="flex w-full items-center"> | |
| 259 | - <WrenchScrewdriverIcon className="ml-1.5 mr-2 h-3.5 w-3.5 flex-shrink-0" /> | |
| 260 | - <span className="text-2xs">Tools</span> | |
| 261 | - </div> | |
| 262 | - </Button> | |
| 263 | 233 | <Button |
| 264 | 234 | onClick={(e) => { |
| 265 | 235 | e.stopPropagation(); |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | |
| 7 | 7 | type SectionKey = Exclude< |
| 8 | 8 | keyof ConfigYaml, |
| 9 | - "name" | "version" | "schema" | "metadata" | "env" | |
| 9 | + "name" | "version" | "schema" | "metadata" | "env" | "requestOptions" | |
| 10 | 10 | >; |
| 11 | 11 | |
| 12 | 12 | interface EditBlockButtonProps<T extends SectionKey> { |
| @@ -1,24 +1,45 @@ | ||
| 1 | -import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + CubeIcon, | |
| 3 | + ExclamationTriangleIcon, | |
| 4 | + PencilIcon, | |
| 5 | + WrenchScrewdriverIcon, | |
| 6 | +} from "@heroicons/react/24/outline"; | |
| 2 | 7 | import { useContext, useEffect, useState } from "react"; |
| 3 | 8 | import { useNavigate } from "react-router-dom"; |
| 4 | 9 | import { IdeMessengerContext } from "../../../../context/IdeMessenger"; |
| 5 | -import { useAppSelector } from "../../../../redux/hooks"; | |
| 10 | +import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; | |
| 11 | +import { | |
| 12 | + selectPendingToolCalls, | |
| 13 | + selectToolCallsByStatus, | |
| 14 | +} from "../../../../redux/selectors/selectToolCalls"; | |
| 15 | +import { setSelectedProfile } from "../../../../redux/slices/profilesSlice"; | |
| 6 | 16 | import FreeTrialButton from "../../../FreeTrialButton"; |
| 7 | 17 | import { ToolTip } from "../../../gui/Tooltip"; |
| 18 | +import HoverItem from "../../InputToolbar/HoverItem"; | |
| 8 | 19 | |
| 9 | 20 | import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey"; |
| 10 | 21 | import type { FreeTrialStatus } from "core/control-plane/client"; |
| 22 | +import { useAuth } from "../../../../context/Auth"; | |
| 11 | 23 | import { getLocalStorage } from "../../../../util/localStorage"; |
| 12 | 24 | import { CONFIG_ROUTES } from "../../../../util/navigation"; |
| 13 | 25 | import { AssistantAndOrgListbox } from "../../../AssistantAndOrgListbox"; |
| 14 | 26 | |
| 15 | 27 | export function BlockSettingsTopToolbar() { |
| 16 | 28 | const navigate = useNavigate(); |
| 29 | + const dispatch = useAppDispatch(); | |
| 30 | + const { selectedProfile } = useAuth(); | |
| 17 | 31 | |
| 18 | 32 | const configError = useAppSelector((store) => store.config.configError); |
| 19 | 33 | const config = useAppSelector((state) => state.config.config); |
| 20 | 34 | const ideMessenger = useContext(IdeMessengerContext); |
| 21 | 35 | |
| 36 | + const pendingToolCalls = useAppSelector(selectPendingToolCalls); | |
| 37 | + const callingToolCalls = useAppSelector((state) => | |
| 38 | + selectToolCallsByStatus(state, "calling"), | |
| 39 | + ); | |
| 40 | + const hasActiveContent = | |
| 41 | + pendingToolCalls.length > 0 || callingToolCalls.length > 0; | |
| 42 | + | |
| 22 | 43 | const [freeTrialStatus, setFreeTrialStatus] = |
| 23 | 44 | useState<FreeTrialStatus | null>(null); |
| 24 | 45 | const hasExitedFreeTrial = getLocalStorage("hasExitedFreeTrial"); |
| @@ -53,9 +74,39 @@ | ||
| 53 | 74 | |
| 54 | 75 | const shouldShowError = configError && configError?.length > 0; |
| 55 | 76 | |
| 77 | + const handleRulesClick = () => { | |
| 78 | + if (selectedProfile) { | |
| 79 | + dispatch(setSelectedProfile(selectedProfile.id)); | |
| 80 | + ideMessenger.post("didChangeSelectedProfile", { | |
| 81 | + id: selectedProfile.id, | |
| 82 | + }); | |
| 83 | + } | |
| 84 | + navigate(CONFIG_ROUTES.RULES); | |
| 85 | + }; | |
| 86 | + | |
| 87 | + const handleToolsClick = () => { | |
| 88 | + if (selectedProfile) { | |
| 89 | + dispatch(setSelectedProfile(selectedProfile.id)); | |
| 90 | + ideMessenger.post("didChangeSelectedProfile", { | |
| 91 | + id: selectedProfile.id, | |
| 92 | + }); | |
| 93 | + } | |
| 94 | + navigate(CONFIG_ROUTES.TOOLS); | |
| 95 | + }; | |
| 96 | + | |
| 97 | + const handleModelsClick = () => { | |
| 98 | + if (selectedProfile) { | |
| 99 | + dispatch(setSelectedProfile(selectedProfile.id)); | |
| 100 | + ideMessenger.post("didChangeSelectedProfile", { | |
| 101 | + id: selectedProfile.id, | |
| 102 | + }); | |
| 103 | + } | |
| 104 | + navigate(CONFIG_ROUTES.MODELS); | |
| 105 | + }; | |
| 106 | + | |
| 56 | 107 | return ( |
| 57 | 108 | <div className="flex flex-1 items-center justify-between gap-1.5"> |
| 58 | - <div> | |
| 109 | + <div className="flex items-center gap-1"> | |
| 59 | 110 | {shouldShowError && ( |
| 60 | 111 | <ToolTip delayShow={700} content="View configuration errors"> |
| 61 | 112 | <div |
| @@ -78,7 +129,30 @@ | ||
| 78 | 129 | </div> |
| 79 | 130 | </ToolTip> |
| 80 | 131 | )} |
| 132 | + | |
| 133 | + {!hasActiveContent && ( | |
| 134 | + <div className="flex items-center gap-1.5"> | |
| 135 | + <ToolTip content="Configure rules"> | |
| 136 | + <HoverItem onClick={handleRulesClick} px={2}> | |
| 137 | + <PencilIcon className="text-description-muted h-3 w-3 hover:brightness-125" /> | |
| 138 | + </HoverItem> | |
| 139 | + </ToolTip> | |
| 140 | + | |
| 141 | + <ToolTip content="Configure tools"> | |
| 142 | + <HoverItem onClick={handleToolsClick} px={2}> | |
| 143 | + <WrenchScrewdriverIcon className="text-description-muted h-3 w-3 hover:brightness-125" /> | |
| 144 | + </HoverItem> | |
| 145 | + </ToolTip> | |
| 146 | + | |
| 147 | + <ToolTip content="Configure models"> | |
| 148 | + <HoverItem onClick={handleModelsClick} px={2}> | |
| 149 | + <CubeIcon className="text-description-muted h-3 w-3 hover:brightness-125" /> | |
| 150 | + </HoverItem> | |
| 151 | + </ToolTip> | |
| 152 | + </div> | |
| 153 | + )} | |
| 81 | 154 | </div> |
| 155 | + | |
| 82 | 156 | <ToolTip |
| 83 | 157 | place="top" |
| 84 | 158 | content={isUsingFreeTrial ? "View free trial usage" : "Select Agent"} |
| @@ -120,6 +120,23 @@ | ||
| 120 | 120 | } |
| 121 | 121 | }, [props.isMainInput, isStreaming, editor]); |
| 122 | 122 | |
| 123 | + // Recovery mechanism: ensure historical inputs regain editability when streaming ends | |
| 124 | + useEffect(() => { | |
| 125 | + if (!isStreaming && !props.isMainInput && editor) { | |
| 126 | + // Small delay to ensure editor state has settled after streaming transition | |
| 127 | + const timeoutId = setTimeout(() => { | |
| 128 | + if (editor && !editor.isDestroyed) { | |
| 129 | + // Force re-enable the editor | |
| 130 | + editor.setOptions({ editable: true }); | |
| 131 | + // Trigger view update to refresh editor state | |
| 132 | + editor.view.dispatch(editor.state.tr); | |
| 133 | + } | |
| 134 | + }, 100); | |
| 135 | + | |
| 136 | + return () => clearTimeout(timeoutId); | |
| 137 | + } | |
| 138 | + }, [isStreaming, props.isMainInput]); | |
| 139 | + | |
| 123 | 140 | const [showDragOverMsg, setShowDragOverMsg] = useState(false); |
| 124 | 141 | |
| 125 | 142 | const [activeKey, setActiveKey] = useState<string | null>(null); |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | import { |
| 2 | 2 | ArrowPathIcon, |
| 3 | - CheckIcon, | |
| 4 | 3 | ChevronDownIcon, |
| 5 | 4 | Cog6ToothIcon, |
| 6 | 5 | CubeIcon, |
| @@ -16,7 +15,9 @@ | ||
| 16 | 15 | import { updateSelectedModelByRole } from "../../redux/thunks/updateSelectedModelByRole"; |
| 17 | 16 | import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; |
| 18 | 17 | import { CONFIG_ROUTES } from "../../util/navigation"; |
| 18 | +import { ToolTip } from "../gui/Tooltip"; | |
| 19 | 19 | import { |
| 20 | + Button, | |
| 20 | 21 | Listbox, |
| 21 | 22 | ListboxButton, |
| 22 | 23 | ListboxOption, |
| @@ -57,6 +58,8 @@ | ||
| 57 | 58 | showMissingApiKeyMsg, |
| 58 | 59 | isSelected, |
| 59 | 60 | }: ModelOptionProps) { |
| 61 | + const navigate = useNavigate(); | |
| 62 | + | |
| 60 | 63 | function handleOptionClick(e: any) { |
| 61 | 64 | if (showMissingApiKeyMsg) { |
| 62 | 65 | e.preventDefault(); |
| @@ -64,12 +67,18 @@ | ||
| 64 | 67 | } |
| 65 | 68 | } |
| 66 | 69 | |
| 70 | + function handleConfigureClick(e: React.MouseEvent) { | |
| 71 | + e.stopPropagation(); | |
| 72 | + navigate(CONFIG_ROUTES.MODELS); | |
| 73 | + } | |
| 74 | + | |
| 67 | 75 | return ( |
| 68 | 76 | <ListboxOption |
| 69 | 77 | key={idx} |
| 70 | 78 | disabled={showMissingApiKeyMsg} |
| 71 | 79 | value={option.value} |
| 72 | 80 | onClick={handleOptionClick} |
| 81 | + className={`group ${isSelected ? "bg-list-active text-list-active-foreground" : ""}`} | |
| 73 | 82 | > |
| 74 | 83 | <div className="flex w-full items-center justify-between gap-5"> |
| 75 | 84 | <div className="flex items-center gap-2 py-0.5"> |
| @@ -88,9 +97,14 @@ | ||
| 88 | 97 | )} |
| 89 | 98 | </span> |
| 90 | 99 | </div> |
| 91 | - <CheckIcon | |
| 92 | - className={`h-3 w-3 flex-shrink-0 ${isSelected ? "" : "invisible"}`} | |
| 93 | - /> | |
| 100 | + <Button | |
| 101 | + variant="ghost" | |
| 102 | + size="sm" | |
| 103 | + className="text-description-muted hover:enabled:text-foreground my-0 h-4 w-4 p-0 opacity-0 transition-opacity group-hover:opacity-100" | |
| 104 | + onClick={handleConfigureClick} | |
| 105 | + > | |
| 106 | + <Cog6ToothIcon className="h-3.5 w-3.5" /> | |
| 107 | + </Button> | |
| 94 | 108 | </div> |
| 95 | 109 | </ListboxOption> |
| 96 | 110 | ); |
| @@ -245,8 +259,21 @@ | ||
| 245 | 259 | /> |
| 246 | 260 | </ListboxButton> |
| 247 | 261 | <ListboxOptions className="min-w-[160px]"> |
| 248 | - <div className="flex items-center justify-between gap-1 px-2 py-1"> | |
| 249 | - <span className="text-description font-semibold">Models</span> | |
| 262 | + <div className="flex items-center justify-between px-1.5 py-1"> | |
| 263 | + <span className="text-description text-xs font-medium">Models</span> | |
| 264 | + <div className="flex items-center gap-0.5"> | |
| 265 | + <Button | |
| 266 | + onClick={(e) => { | |
| 267 | + e.stopPropagation(); | |
| 268 | + onClickConfigureModels(e); | |
| 269 | + }} | |
| 270 | + variant="ghost" | |
| 271 | + size="sm" | |
| 272 | + className="my-0 h-5 w-5 p-0" | |
| 273 | + > | |
| 274 | + <Cog6ToothIcon className="text-description h-3.5 w-3.5" /> | |
| 275 | + </Button> | |
| 276 | + </div> | |
| 250 | 277 | </div> |
| 251 | 278 | |
| 252 | 279 | <div className="no-scrollbar max-h-[300px] overflow-y-auto"> |
| @@ -274,36 +301,26 @@ | ||
| 274 | 301 | |
| 275 | 302 | {!isConfigLoading && ( |
| 276 | 303 | <> |
| 277 | - <Divider className="!mb-0" /> | |
| 278 | - | |
| 279 | 304 | {selectedProfile?.profileType === "local" && ( |
| 280 | - <ListboxOption | |
| 281 | - key={options.length} | |
| 282 | - onClick={onClickAddModel} | |
| 283 | - value={"addModel" as any} | |
| 284 | - fontSizeModifier={-2} | |
| 285 | - className="px-2 py-2" | |
| 286 | - > | |
| 287 | - <span className="text-description text-2xs flex flex-row items-center"> | |
| 288 | - <PlusIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 289 | - Add Chat model | |
| 290 | - </span> | |
| 291 | - </ListboxOption> | |
| 305 | + <> | |
| 306 | + <Divider className="!mb-0" /> | |
| 307 | + <ListboxOption | |
| 308 | + key={options.length} | |
| 309 | + onClick={onClickAddModel} | |
| 310 | + value={"addModel" as any} | |
| 311 | + fontSizeModifier={-2} | |
| 312 | + className="px-2 py-2" | |
| 313 | + > | |
| 314 | + <span className="text-description text-2xs flex flex-row items-center"> | |
| 315 | + <PlusIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 316 | + Add Chat model | |
| 317 | + </span> | |
| 318 | + </ListboxOption> | |
| 319 | + </> | |
| 292 | 320 | )} |
| 293 | 321 | |
| 294 | - <ListboxOption | |
| 295 | - value="configure-models" | |
| 296 | - fontSizeModifier={-2} | |
| 297 | - className="px-2 py-2" | |
| 298 | - onClick={onClickConfigureModels} | |
| 299 | - > | |
| 300 | - <span className="text-description text-2xs flex flex-row items-center"> | |
| 301 | - <Cog6ToothIcon className="mr-1.5 h-3.5 w-3.5" /> | |
| 302 | - Configure models | |
| 303 | - </span> | |
| 304 | - </ListboxOption> | |
| 305 | 322 | <Divider className="!my-0" /> |
| 306 | - <div className="text-description flex items-center justify-between gap-1.5 px-2 py-2"> | |
| 323 | + <div className="text-description flex items-center justify-start p-2"> | |
| 307 | 324 | <span className="block" style={{ fontSize: tinyFont }}> |
| 308 | 325 | <code>{getMetaKeyLabel()}'</code> to toggle model |
| 309 | 326 | </span> |
| @@ -1,57 +0,0 @@ | ||
| 1 | -import styled from "styled-components"; | |
| 2 | -import { | |
| 3 | - defaultBorderRadius, | |
| 4 | - lightGray, | |
| 5 | - vscInputBackground, | |
| 6 | - vscListActiveBackground, | |
| 7 | - vscListActiveForeground, | |
| 8 | -} from ".."; | |
| 9 | - | |
| 10 | -const TopDiv = styled.div` | |
| 11 | - display: flex; | |
| 12 | - align-items: center; | |
| 13 | - text-align: center; | |
| 14 | - margin: auto; | |
| 15 | - width: fit-content; | |
| 16 | - cursor: pointer; | |
| 17 | - | |
| 18 | - border: 1px solid ${lightGray}; | |
| 19 | - | |
| 20 | - background-color: ${vscInputBackground}; | |
| 21 | - border-radius: ${defaultBorderRadius}; | |
| 22 | - | |
| 23 | - &:hover { | |
| 24 | - background-color: ${lightGray}55; | |
| 25 | - } | |
| 26 | -`; | |
| 27 | - | |
| 28 | -const SubDiv = styled.div<{ selected: boolean }>` | |
| 29 | - text-align: center; | |
| 30 | - padding: 8px 12px; | |
| 31 | - border-radius: ${defaultBorderRadius}; | |
| 32 | - | |
| 33 | - transition: all 0.2s ease-in-out; | |
| 34 | - | |
| 35 | - ${(props) => | |
| 36 | - props.selected && | |
| 37 | - ` | |
| 38 | - background-color: ${vscListActiveBackground}; | |
| 39 | - color: ${vscListActiveForeground}; | |
| 40 | - `} | |
| 41 | -`; | |
| 42 | - | |
| 43 | -function Toggle(props: { | |
| 44 | - optionOne: string; | |
| 45 | - optionTwo: string; | |
| 46 | - selected: boolean; | |
| 47 | - onClick: () => void; | |
| 48 | -}) { | |
| 49 | - return ( | |
| 50 | - <TopDiv onClick={props.onClick}> | |
| 51 | - <SubDiv selected={props.selected}>{props.optionOne}</SubDiv> | |
| 52 | - <SubDiv selected={!props.selected}>{props.optionTwo}</SubDiv> | |
| 53 | - </TopDiv> | |
| 54 | - ); | |
| 55 | -} | |
| 56 | - | |
| 57 | -export default Toggle; |
| @@ -566,6 +566,38 @@ | ||
| 566 | 566 | packages: [models.grokBeta], |
| 567 | 567 | apiKeyUrl: "https://console.x.ai/", |
| 568 | 568 | }, |
| 569 | + lemonade: { | |
| 570 | + title: "Lemonade", | |
| 571 | + provider: "lemonade", | |
| 572 | + description: | |
| 573 | + "High-performance local LLM inference with AMD hardware optimization", | |
| 574 | + longDescription: | |
| 575 | + "Lemonade provides optimized local LLM inference with support for AMD NPU, GPU, and CPU acceleration. Visit [lemonade-server.ai](https://lemonade-server.ai/) for installation and setup instructions. Once the Lemonade server is running, you can begin using Continue with your local models.", | |
| 576 | + icon: "lemonade.png", | |
| 577 | + tags: [ModelProviderTags.Local, ModelProviderTags.OpenSource], | |
| 578 | + params: { | |
| 579 | + apiBase: "http://localhost:8000/api/v1/", | |
| 580 | + }, | |
| 581 | + packages: [ | |
| 582 | + { | |
| 583 | + ...models.AUTODETECT, | |
| 584 | + params: { | |
| 585 | + ...models.AUTODETECT.params, | |
| 586 | + title: "Lemonade", | |
| 587 | + }, | |
| 588 | + }, | |
| 589 | + ...openSourceModels, | |
| 590 | + ], | |
| 591 | + collectInputFor: [ | |
| 592 | + ...completionParamsInputsConfigs, | |
| 593 | + { | |
| 594 | + ...apiBaseInput, | |
| 595 | + defaultValue: "http://localhost:8000/api/v1/", | |
| 596 | + required: true, | |
| 597 | + }, | |
| 598 | + ], | |
| 599 | + downloadUrl: "http://lemonade-server.ai", | |
| 600 | + }, | |
| 569 | 601 | lmstudio: { |
| 570 | 602 | title: "LM Studio", |
| 571 | 603 | provider: "lmstudio", |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { isOnPremSession } from "core/control-plane/AuthTypes"; |
| 2 | -import React, { useEffect, useState } from "react"; | |
| 2 | +import React, { useState } from "react"; | |
| 3 | 3 | import { useNavigate, useSearchParams } from "react-router-dom"; |
| 4 | 4 | import { AssistantAndOrgListbox } from "../../components/AssistantAndOrgListbox"; |
| 5 | 5 | import Alert from "../../components/gui/Alert"; |
| @@ -14,17 +14,11 @@ | ||
| 14 | 14 | useNavigationListener(); |
| 15 | 15 | const navigate = useNavigate(); |
| 16 | 16 | const [searchParams] = useSearchParams(); |
| 17 | - const [activeTab, setActiveTab] = useState("settings"); | |
| 17 | + const [activeTab, setActiveTab] = useState(() => { | |
| 18 | + return searchParams.get("tab") || "settings"; | |
| 19 | + }); | |
| 18 | 20 | const { session, organizations } = useAuth(); |
| 19 | 21 | |
| 20 | - // Set initial tab from URL parameter | |
| 21 | - useEffect(() => { | |
| 22 | - const tab = searchParams.get("tab"); | |
| 23 | - if (tab) { | |
| 24 | - setActiveTab(tab); | |
| 25 | - } | |
| 26 | - }, [searchParams]); | |
| 27 | - | |
| 28 | 22 | const allTabs = getAllTabs(); |
| 29 | 23 | const shouldRenderOrgInfo = |
| 30 | 24 | session && organizations.length > 1 && !isOnPremSession(session); |
| @@ -19,9 +19,16 @@ | ||
| 19 | 19 | useFontSize: () => 14, |
| 20 | 20 | })); |
| 21 | 21 | |
| 22 | -vi.mock("../../../util/clientTools/findAndReplaceUtils", () => ({ | |
| 23 | - performFindAndReplace: vi.fn(), | |
| 24 | -})); | |
| 22 | +vi.mock("../../../util/clientTools/findAndReplaceUtils", async () => { | |
| 23 | + const actual = await vi.importActual( | |
| 24 | + "../../../util/clientTools/findAndReplaceUtils", | |
| 25 | + ); | |
| 26 | + | |
| 27 | + return { | |
| 28 | + performFindAndReplace: vi.fn(), | |
| 29 | + trimEmptyLines: actual.trimEmptyLines, | |
| 30 | + }; | |
| 31 | +}); | |
| 25 | 32 | |
| 26 | 33 | vi.mock("./utils", () => ({ |
| 27 | 34 | getStatusIcon: vi.fn(() => <div data-testid="status-icon">✓</div>), |
| @@ -13,7 +13,10 @@ | ||
| 13 | 13 | selectApplyStateByToolCallId, |
| 14 | 14 | selectToolCallById, |
| 15 | 15 | } from "../../../redux/selectors/selectToolCalls"; |
| 16 | -import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils"; | |
| 16 | +import { | |
| 17 | + performFindAndReplace, | |
| 18 | + trimEmptyLines, | |
| 19 | +} from "../../../util/clientTools/findAndReplaceUtils"; | |
| 17 | 20 | import { cn } from "../../../util/cn"; |
| 18 | 21 | import { getStatusIcon } from "./utils"; |
| 19 | 22 | |
| @@ -313,14 +316,16 @@ | ||
| 313 | 316 | const showMiddleEllipses = |
| 314 | 317 | !isFirst && !isLast && lines.length > MAX_SAME_LINES * 2 + 1; |
| 315 | 318 | |
| 316 | - const startLines = showStartEllipsis | |
| 319 | + let startLines = showStartEllipsis | |
| 317 | 320 | ? lines.slice(-MAX_SAME_LINES) |
| 318 | 321 | : showMiddleEllipses || showEndEllipsis |
| 319 | 322 | ? lines.slice(0, MAX_SAME_LINES) |
| 320 | 323 | : lines; |
| 321 | - const endLines = showMiddleEllipses | |
| 324 | + startLines = trimEmptyLines({ lines: startLines, fromEnd: false }); | |
| 325 | + let endLines = showMiddleEllipses | |
| 322 | 326 | ? lines.slice(-MAX_SAME_LINES) |
| 323 | 327 | : []; |
| 328 | + endLines = trimEmptyLines({ lines: endLines, fromEnd: true }); | |
| 324 | 329 | |
| 325 | 330 | return ( |
| 326 | 331 | <div key={index}> |
| @@ -43,18 +43,6 @@ | ||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - function handleToggleClick() { | |
| 47 | - if (isToggleable) { | |
| 48 | - setOpen((prev) => !prev); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - | |
| 52 | - function handleIconClick() { | |
| 53 | - if (isSingleItem) { | |
| 54 | - openContextItem(shownContextItems[0], ideMessenger); | |
| 55 | - } | |
| 56 | - } | |
| 57 | - | |
| 58 | 46 | return ( |
| 59 | 47 | <div className="mt-1 flex flex-col px-4"> |
| 60 | 48 | <div className="flex min-w-0 flex-row items-center justify-between gap-2"> |
| @@ -69,7 +57,6 @@ | ||
| 69 | 57 | icon={Icon} |
| 70 | 58 | isToggleable={isToggleable} |
| 71 | 59 | open={shouldShowContent} |
| 72 | - onClick={isToggleable ? handleToggleClick : handleIconClick} | |
| 73 | 60 | isClickable={isSingleItem} |
| 74 | 61 | /> |
| 75 | 62 | <ToolCallStatusMessage tool={tool} toolCallState={toolCallState} /> |
| @@ -1,4 +1,7 @@ | ||
| 1 | -import { ArrowRightIcon } from "@heroicons/react/24/outline"; | |
| 1 | +import { | |
| 2 | + ArrowRightIcon, | |
| 3 | + MagnifyingGlassIcon, | |
| 4 | +} from "@heroicons/react/24/outline"; | |
| 2 | 5 | import { ToolCallState } from "core"; |
| 3 | 6 | import { BuiltInToolNames } from "core/tools/builtIn"; |
| 4 | 7 | import { useState } from "react"; |
| @@ -7,7 +10,7 @@ | ||
| 7 | 10 | import { GroupedToolCallHeader } from "./GroupedToolCallHeader"; |
| 8 | 11 | import { SimpleToolCallUI } from "./SimpleToolCallUI"; |
| 9 | 12 | import { ToolCallDisplay } from "./ToolCallDisplay"; |
| 10 | -import { getStatusIcon, toolCallIcons } from "./utils"; | |
| 13 | +import { getIconByName, getStatusIcon } from "./utils"; | |
| 11 | 14 | |
| 12 | 15 | interface ToolCallDivProps { |
| 13 | 16 | toolCallStates: ToolCallState[]; |
| @@ -37,7 +40,10 @@ | ||
| 37 | 40 | (tool) => toolCallState.toolCall.function?.name === tool.function.name, |
| 38 | 41 | ); |
| 39 | 42 | const functionName = toolCallState.toolCall.function?.name; |
| 40 | - const icon = functionName && toolCallIcons[functionName]; | |
| 43 | + const icon = | |
| 44 | + functionName && tool?.toolCallIcon | |
| 45 | + ? getIconByName(tool.toolCallIcon) | |
| 46 | + : undefined; | |
| 41 | 47 | |
| 42 | 48 | if (icon) { |
| 43 | 49 | return ( |
| @@ -1,25 +1,11 @@ | ||
| 1 | -import { | |
| 2 | - ArrowRightIcon, | |
| 3 | - CheckIcon, | |
| 4 | - CodeBracketIcon, | |
| 5 | - DocumentIcon, | |
| 6 | - DocumentTextIcon, | |
| 7 | - FolderIcon, | |
| 8 | - FolderOpenIcon, | |
| 9 | - GlobeAltIcon, | |
| 10 | - MagnifyingGlassIcon, | |
| 11 | - MapIcon, | |
| 12 | - PencilIcon, | |
| 13 | - XMarkIcon, | |
| 14 | -} from "@heroicons/react/24/outline"; | |
| 1 | +import * as Icons from "@heroicons/react/24/outline"; | |
| 15 | 2 | import { |
| 16 | 3 | ContextItem, |
| 17 | 4 | ContextItemWithId, |
| 18 | 5 | ToolCallState, |
| 19 | 6 | ToolStatus, |
| 20 | 7 | } from "core"; |
| 21 | -import { BuiltInToolNames } from "core/tools/builtIn"; | |
| 22 | -import { ComponentType } from "react"; | |
| 8 | +import { ComponentType, SVGProps } from "react"; | |
| 23 | 9 | import { vscButtonBackground } from "../../../components"; |
| 24 | 10 | import Spinner from "../../../components/gui/Spinner"; |
| 25 | 11 | |
| @@ -70,19 +56,16 @@ | ||
| 70 | 56 | return "Performing"; |
| 71 | 57 | } |
| 72 | 58 | |
| 73 | -export const toolCallIcons: Record<string, ComponentType> = { | |
| 74 | - [BuiltInToolNames.FileGlobSearch]: MagnifyingGlassIcon, | |
| 75 | - [BuiltInToolNames.GrepSearch]: MagnifyingGlassIcon, | |
| 76 | - [BuiltInToolNames.LSTool]: FolderIcon, | |
| 77 | - [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon, | |
| 78 | - [BuiltInToolNames.ReadFile]: DocumentIcon, | |
| 79 | - [BuiltInToolNames.FetchUrlContent]: GlobeAltIcon, | |
| 80 | - [BuiltInToolNames.SearchWeb]: GlobeAltIcon, | |
| 81 | - [BuiltInToolNames.ViewDiff]: CodeBracketIcon, | |
| 82 | - [BuiltInToolNames.ViewRepoMap]: MapIcon, | |
| 83 | - [BuiltInToolNames.ViewSubdirectory]: FolderOpenIcon, | |
| 84 | - [BuiltInToolNames.CreateRuleBlock]: PencilIcon, | |
| 85 | -}; | |
| 59 | +type IconName = keyof typeof Icons; | |
| 60 | + | |
| 61 | +type Icon = ComponentType<SVGProps<SVGSVGElement>> | undefined; | |
| 62 | + | |
| 63 | +export function getIconByName(name: string): Icon | null { | |
| 64 | + if (name in Icons) { | |
| 65 | + return Icons[name as IconName] as Icon; | |
| 66 | + } | |
| 67 | + return null; | |
| 68 | +} | |
| 86 | 69 | |
| 87 | 70 | export function getStatusIcon(state: ToolStatus) { |
| 88 | 71 | switch (state) { |
| @@ -90,12 +73,12 @@ | ||
| 90 | 73 | case "calling": |
| 91 | 74 | return <Spinner />; |
| 92 | 75 | case "generated": |
| 93 | - return <ArrowRightIcon color={vscButtonBackground} />; | |
| 76 | + return <Icons.ArrowRightIcon color={vscButtonBackground} />; | |
| 94 | 77 | case "done": |
| 95 | - return <CheckIcon className="text-success" />; | |
| 78 | + return <Icons.CheckIcon className="text-success" />; | |
| 96 | 79 | case "canceled": |
| 97 | 80 | case "errored": |
| 98 | - return <XMarkIcon className="text-error" />; | |
| 81 | + return <Icons.XMarkIcon className="text-error" />; | |
| 99 | 82 | } |
| 100 | 83 | } |
| 101 | 84 |
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | EMPTY_NON_FIRST_EDIT_MESSAGE, |
| 5 | 5 | FOUND_MULTIPLE_FIND_STRINGS_ERROR, |
| 6 | 6 | performFindAndReplace, |
| 7 | + trimEmptyLines, | |
| 7 | 8 | validateCreatingForMultiEdit, |
| 8 | 9 | validateSingleEdit, |
| 9 | 10 | } from "./findAndReplaceUtils"; |
| @@ -454,3 +455,23 @@ | ||
| 454 | 455 | }); |
| 455 | 456 | }); |
| 456 | 457 | }); |
| 458 | + | |
| 459 | +describe("trimEmptyLines", () => { | |
| 460 | + it("trims leading empty lines from start", () => { | |
| 461 | + const input = ["", "", "a", "", "b"]; | |
| 462 | + const result = trimEmptyLines({ lines: input, fromEnd: false }); | |
| 463 | + expect(result).toEqual(["a", "", "b"]); | |
| 464 | + }); | |
| 465 | + | |
| 466 | + it("trims trailing empty lines from end", () => { | |
| 467 | + const input = ["a", "", "b", "", ""]; | |
| 468 | + const result = trimEmptyLines({ lines: input, fromEnd: true }); | |
| 469 | + expect(result).toEqual(["a", "", "b"]); | |
| 470 | + }); | |
| 471 | + | |
| 472 | + it("returns empty array when all lines are empty", () => { | |
| 473 | + const input = ["", "", ""]; | |
| 474 | + const result = trimEmptyLines({ lines: input, fromEnd: false }); | |
| 475 | + expect(result).toEqual([]); | |
| 476 | + }); | |
| 477 | +}); |
| @@ -95,3 +95,22 @@ | ||
| 95 | 95 | |
| 96 | 96 | return isCreating; |
| 97 | 97 | } |
| 98 | + | |
| 99 | +export function trimEmptyLines({ | |
| 100 | + lines, | |
| 101 | + fromEnd, | |
| 102 | +}: { | |
| 103 | + lines: string[]; | |
| 104 | + fromEnd: boolean; | |
| 105 | +}): string[] { | |
| 106 | + lines = fromEnd ? lines.toReversed() : lines.slice(); | |
| 107 | + const newLines: string[] = []; | |
| 108 | + let shouldContinueRemoving = true; | |
| 109 | + for (let index = 0; index < lines.length; index++) { | |
| 110 | + const line = lines[index]; | |
| 111 | + if (shouldContinueRemoving && line.trim() === "") continue; | |
| 112 | + shouldContinueRemoving = false; | |
| 113 | + newLines.push(line); | |
| 114 | + } | |
| 115 | + return fromEnd ? newLines.reverse() : newLines; | |
| 116 | +} |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/config-yaml", |
| 3 | - "version": "1.14.0", | |
| 3 | + "version": "1.17.0", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
| @@ -193,6 +193,7 @@ | ||
| 193 | 193 | prompts, |
| 194 | 194 | mcpServers, |
| 195 | 195 | docs, |
| 196 | + requestOptions: configJson.requestOptions, | |
| 196 | 197 | }; |
| 197 | 198 | |
| 198 | 199 | return configYaml; |
| @@ -1,3 +1,5 @@ | ||
| 1 | +import os from "node:os"; | |
| 2 | + | |
| 1 | 3 | export interface PackageSlug { |
| 2 | 4 | ownerSlug: string; |
| 3 | 5 | packageSlug: string; |
| @@ -61,13 +63,18 @@ | ||
| 61 | 63 | fileUri: identifier.substring(7), |
| 62 | 64 | }; |
| 63 | 65 | } |
| 64 | - // Otherwise, it's a slug | |
| 65 | - else { | |
| 66 | + // support ~ by replacing with home directory | |
| 67 | + else if (identifier.startsWith("~")) { | |
| 66 | 68 | return { |
| 67 | - uriType: "slug", | |
| 68 | - fullSlug: decodeFullSlug(identifier), | |
| 69 | + uriType: "file", | |
| 70 | + fileUri: identifier.replace("~", os.homedir()), | |
| 69 | 71 | }; |
| 70 | 72 | } |
| 73 | + // Otherwise, it's a slug | |
| 74 | + return { | |
| 75 | + uriType: "slug", | |
| 76 | + fullSlug: decodeFullSlug(identifier), | |
| 77 | + }; | |
| 71 | 78 | } |
| 72 | 79 | |
| 73 | 80 | export enum VirtualTags { |
| @@ -0,0 +1,235 @@ | ||
| 1 | +import { describe, expect, it } from "@jest/globals"; | |
| 2 | +import type { RequestOptions } from "../schemas/models.js"; | |
| 3 | +import { mergeConfigYamlRequestOptions } from "./merge.js"; | |
| 4 | + | |
| 5 | +describe("mergeConfigYamlRequestOptions", () => { | |
| 6 | + it("should return undefined when both base and global are undefined", () => { | |
| 7 | + const result = mergeConfigYamlRequestOptions(undefined, undefined); | |
| 8 | + expect(result).toBeUndefined(); | |
| 9 | + }); | |
| 10 | + | |
| 11 | + it("should return global when base is undefined", () => { | |
| 12 | + const global: RequestOptions = { | |
| 13 | + timeout: 5000, | |
| 14 | + verifySsl: true, | |
| 15 | + headers: { Authorization: "Bearer token" }, | |
| 16 | + }; | |
| 17 | + const result = mergeConfigYamlRequestOptions(undefined, global); | |
| 18 | + expect(result).toEqual(global); | |
| 19 | + }); | |
| 20 | + | |
| 21 | + it("should return base when global is undefined", () => { | |
| 22 | + const base: RequestOptions = { | |
| 23 | + timeout: 3000, | |
| 24 | + verifySsl: false, | |
| 25 | + headers: { "X-Custom": "value" }, | |
| 26 | + }; | |
| 27 | + const result = mergeConfigYamlRequestOptions(base, undefined); | |
| 28 | + expect(result).toEqual(base); | |
| 29 | + }); | |
| 30 | + | |
| 31 | + it("should merge headers from both objects", () => { | |
| 32 | + const base: RequestOptions = { | |
| 33 | + headers: { "X-Base": "base-value", "X-Common": "base-common" }, | |
| 34 | + }; | |
| 35 | + const global: RequestOptions = { | |
| 36 | + headers: { "X-Global": "global-value", "X-Common": "global-common" }, | |
| 37 | + }; | |
| 38 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 39 | + expect(result?.headers).toEqual({ | |
| 40 | + "X-Global": "global-value", | |
| 41 | + "X-Common": "base-common", // base overrides global | |
| 42 | + "X-Base": "base-value", | |
| 43 | + }); | |
| 44 | + }); | |
| 45 | + | |
| 46 | + it("should override simple values with base values", () => { | |
| 47 | + const base: RequestOptions = { | |
| 48 | + timeout: 3000, | |
| 49 | + verifySsl: false, | |
| 50 | + proxy: "http://base-proxy.com", | |
| 51 | + }; | |
| 52 | + const global: RequestOptions = { | |
| 53 | + timeout: 5000, | |
| 54 | + verifySsl: true, | |
| 55 | + proxy: "http://global-proxy.com", | |
| 56 | + caBundlePath: "/path/to/ca", | |
| 57 | + }; | |
| 58 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 59 | + expect(result).toEqual({ | |
| 60 | + timeout: 3000, // base overrides | |
| 61 | + verifySsl: false, // base overrides | |
| 62 | + proxy: "http://base-proxy.com", // base overrides | |
| 63 | + caBundlePath: "/path/to/ca", // only in global | |
| 64 | + headers: undefined, | |
| 65 | + }); | |
| 66 | + }); | |
| 67 | + | |
| 68 | + it("should handle noProxy array properly (base overrides)", () => { | |
| 69 | + const base: RequestOptions = { | |
| 70 | + noProxy: ["localhost", "127.0.0.1"], | |
| 71 | + }; | |
| 72 | + const global: RequestOptions = { | |
| 73 | + noProxy: ["192.168.1.1", "example.com"], | |
| 74 | + }; | |
| 75 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 76 | + expect(result?.noProxy).toEqual(["localhost", "127.0.0.1"]); // base overrides completely | |
| 77 | + }); | |
| 78 | + | |
| 79 | + it("should handle extraBodyProperties (base overrides)", () => { | |
| 80 | + const base: RequestOptions = { | |
| 81 | + extraBodyProperties: { baseProp: "baseValue", common: "base" }, | |
| 82 | + }; | |
| 83 | + const global: RequestOptions = { | |
| 84 | + extraBodyProperties: { globalProp: "globalValue", common: "global" }, | |
| 85 | + }; | |
| 86 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 87 | + expect(result?.extraBodyProperties).toEqual({ | |
| 88 | + baseProp: "baseValue", | |
| 89 | + common: "base", | |
| 90 | + }); // base overrides completely | |
| 91 | + }); | |
| 92 | + | |
| 93 | + it("should handle clientCertificate (base overrides)", () => { | |
| 94 | + const base: RequestOptions = { | |
| 95 | + clientCertificate: { | |
| 96 | + cert: "base-cert", | |
| 97 | + key: "base-key", | |
| 98 | + passphrase: "base-pass", | |
| 99 | + }, | |
| 100 | + }; | |
| 101 | + const global: RequestOptions = { | |
| 102 | + clientCertificate: { | |
| 103 | + cert: "global-cert", | |
| 104 | + key: "global-key", | |
| 105 | + }, | |
| 106 | + }; | |
| 107 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 108 | + expect(result?.clientCertificate).toEqual({ | |
| 109 | + cert: "base-cert", | |
| 110 | + key: "base-key", | |
| 111 | + passphrase: "base-pass", | |
| 112 | + }); // base overrides completely | |
| 113 | + }); | |
| 114 | + | |
| 115 | + it("should return undefined headers when both have empty headers", () => { | |
| 116 | + const base: RequestOptions = { | |
| 117 | + headers: {}, | |
| 118 | + timeout: 1000, | |
| 119 | + }; | |
| 120 | + const global: RequestOptions = { | |
| 121 | + headers: {}, | |
| 122 | + verifySsl: true, | |
| 123 | + }; | |
| 124 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 125 | + expect(result?.headers).toBeUndefined(); | |
| 126 | + expect(result?.timeout).toBe(1000); | |
| 127 | + expect(result?.verifySsl).toBe(true); | |
| 128 | + }); | |
| 129 | + | |
| 130 | + it("should handle caBundlePath as string", () => { | |
| 131 | + const base: RequestOptions = { | |
| 132 | + caBundlePath: "/base/ca.pem", | |
| 133 | + }; | |
| 134 | + const global: RequestOptions = { | |
| 135 | + caBundlePath: "/global/ca.pem", | |
| 136 | + }; | |
| 137 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 138 | + expect(result?.caBundlePath).toBe("/base/ca.pem"); // base overrides | |
| 139 | + }); | |
| 140 | + | |
| 141 | + it("should handle caBundlePath as array", () => { | |
| 142 | + const base: RequestOptions = { | |
| 143 | + caBundlePath: ["/base/ca1.pem", "/base/ca2.pem"], | |
| 144 | + }; | |
| 145 | + const global: RequestOptions = { | |
| 146 | + caBundlePath: ["/global/ca.pem"], | |
| 147 | + }; | |
| 148 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 149 | + expect(result?.caBundlePath).toEqual(["/base/ca1.pem", "/base/ca2.pem"]); // base overrides | |
| 150 | + }); | |
| 151 | + | |
| 152 | + it("should preserve all fields from base when global has different fields", () => { | |
| 153 | + const base: RequestOptions = { | |
| 154 | + timeout: 3000, | |
| 155 | + headers: { "X-Base": "value" }, | |
| 156 | + noProxy: ["localhost"], | |
| 157 | + }; | |
| 158 | + const global: RequestOptions = { | |
| 159 | + verifySsl: true, | |
| 160 | + proxy: "http://proxy.com", | |
| 161 | + caBundlePath: "/ca.pem", | |
| 162 | + }; | |
| 163 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 164 | + expect(result).toEqual({ | |
| 165 | + timeout: 3000, | |
| 166 | + verifySsl: true, | |
| 167 | + proxy: "http://proxy.com", | |
| 168 | + caBundlePath: "/ca.pem", | |
| 169 | + headers: { "X-Base": "value" }, | |
| 170 | + noProxy: ["localhost"], | |
| 171 | + }); | |
| 172 | + }); | |
| 173 | + | |
| 174 | + it("should handle complex header merging scenario", () => { | |
| 175 | + const base: RequestOptions = { | |
| 176 | + headers: { | |
| 177 | + Authorization: "Bearer base-token", | |
| 178 | + "X-Custom-Header": "base-custom", | |
| 179 | + "Content-Type": "application/json", | |
| 180 | + }, | |
| 181 | + }; | |
| 182 | + const global: RequestOptions = { | |
| 183 | + headers: { | |
| 184 | + Authorization: "Bearer global-token", | |
| 185 | + "X-Global-Header": "global-value", | |
| 186 | + "Accept-Language": "en-US", | |
| 187 | + }, | |
| 188 | + }; | |
| 189 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 190 | + expect(result?.headers).toEqual({ | |
| 191 | + Authorization: "Bearer base-token", // base overrides | |
| 192 | + "X-Global-Header": "global-value", // from global | |
| 193 | + "Accept-Language": "en-US", // from global | |
| 194 | + "X-Custom-Header": "base-custom", // from base | |
| 195 | + "Content-Type": "application/json", // from base | |
| 196 | + }); | |
| 197 | + }); | |
| 198 | + | |
| 199 | + it("should handle all possible fields", () => { | |
| 200 | + const base: RequestOptions = { | |
| 201 | + timeout: 1000, | |
| 202 | + verifySsl: false, | |
| 203 | + caBundlePath: ["/base/ca.pem"], | |
| 204 | + proxy: "http://base-proxy.com", | |
| 205 | + headers: { "X-Base": "base" }, | |
| 206 | + extraBodyProperties: { baseProp: true }, | |
| 207 | + noProxy: ["base.local"], | |
| 208 | + clientCertificate: { cert: "base-cert", key: "base-key" }, | |
| 209 | + }; | |
| 210 | + const global: RequestOptions = { | |
| 211 | + timeout: 2000, | |
| 212 | + verifySsl: true, | |
| 213 | + caBundlePath: ["/global/ca.pem"], | |
| 214 | + proxy: "http://global-proxy.com", | |
| 215 | + headers: { "X-Global": "global" }, | |
| 216 | + extraBodyProperties: { globalProp: false }, | |
| 217 | + noProxy: ["global.local"], | |
| 218 | + clientCertificate: { cert: "global-cert", key: "global-key" }, | |
| 219 | + }; | |
| 220 | + const result = mergeConfigYamlRequestOptions(base, global); | |
| 221 | + expect(result).toEqual({ | |
| 222 | + timeout: 1000, // base overrides | |
| 223 | + verifySsl: false, // base overrides | |
| 224 | + caBundlePath: ["/base/ca.pem"], // base overrides | |
| 225 | + proxy: "http://base-proxy.com", // base overrides | |
| 226 | + headers: { | |
| 227 | + "X-Global": "global", | |
| 228 | + "X-Base": "base", | |
| 229 | + }, // merged | |
| 230 | + extraBodyProperties: { baseProp: true }, // base overrides | |
| 231 | + noProxy: ["base.local"], // base overrides | |
| 232 | + clientCertificate: { cert: "base-cert", key: "base-key" }, // base overrides | |
| 233 | + }); | |
| 234 | + }); | |
| 235 | +}); |
| @@ -1,3 +1,4 @@ | ||
| 1 | +import { RequestOptions } from "../browser.js"; | |
| 1 | 2 | import { AssistantUnrolled, ConfigYaml } from "../schemas/index.js"; |
| 2 | 3 | |
| 3 | 4 | export function mergePackages( |
| @@ -14,6 +15,10 @@ | ||
| 14 | 15 | prompts: [...(current.prompts ?? []), ...(incoming.prompts ?? [])], |
| 15 | 16 | docs: [...(current.docs ?? []), ...(incoming.docs ?? [])], |
| 16 | 17 | env: { ...current.env, ...incoming.env }, |
| 18 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 19 | + current.requestOptions, | |
| 20 | + incoming.requestOptions, | |
| 21 | + ), | |
| 17 | 22 | }; |
| 18 | 23 | } |
| 19 | 24 | |
| @@ -31,5 +36,35 @@ | ||
| 31 | 36 | mcpServers: [...(current.mcpServers ?? []), ...(incoming.mcpServers ?? [])], |
| 32 | 37 | prompts: [...(current.prompts ?? []), ...(incoming.prompts ?? [])], |
| 33 | 38 | env: { ...current.env, ...incoming.env }, |
| 39 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 40 | + current.requestOptions, | |
| 41 | + incoming.requestOptions, | |
| 42 | + ), | |
| 43 | + }; | |
| 44 | +} | |
| 45 | + | |
| 46 | +export function mergeConfigYamlRequestOptions( | |
| 47 | + base: RequestOptions | undefined, | |
| 48 | + global: RequestOptions | undefined, | |
| 49 | +): RequestOptions | undefined { | |
| 50 | + if (!base && !global) { | |
| 51 | + return undefined; | |
| 52 | + } | |
| 53 | + if (!base) { | |
| 54 | + return global; | |
| 55 | + } | |
| 56 | + if (!global) { | |
| 57 | + return base; | |
| 58 | + } | |
| 59 | + | |
| 60 | + const headers = { | |
| 61 | + ...global.headers, | |
| 62 | + ...base.headers, | |
| 63 | + }; | |
| 64 | + | |
| 65 | + return { | |
| 66 | + ...global, | |
| 67 | + ...base, // base overrides for simple values as well as noProxy and extraBodyProperties | |
| 68 | + headers: Object.keys(headers).length === 0 ? undefined : headers, // headers are the only thing that really merge | |
| 34 | 69 | }; |
| 35 | 70 | } |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import * as YAML from "yaml"; |
| 2 | 2 | import { ZodError } from "zod"; |
| 3 | +import { mergeConfigYamlRequestOptions, RequestOptions } from "../browser.js"; | |
| 3 | 4 | import { PlatformClient, Registry } from "../interfaces/index.js"; |
| 4 | 5 | import { encodeSecretLocation } from "../interfaces/SecretResult.js"; |
| 5 | 6 | import { |
| @@ -203,6 +204,7 @@ | ||
| 203 | 204 | injectBlocks?: PackageIdentifier[]; |
| 204 | 205 | allowlistedBlocks?: PackageSlug[]; |
| 205 | 206 | blocklistedBlocks?: PackageSlug[]; |
| 207 | + injectRequestOptions?: RequestOptions; | |
| 206 | 208 | } |
| 207 | 209 | |
| 208 | 210 | export interface DoNotRenderSecretsUnrollAssistantOptions |
| @@ -274,6 +276,7 @@ | ||
| 274 | 276 | options.injectBlocks, |
| 275 | 277 | options.allowlistedBlocks, |
| 276 | 278 | options.blocklistedBlocks, |
| 279 | + options.injectRequestOptions, | |
| 277 | 280 | ); |
| 278 | 281 | |
| 279 | 282 | // Back to a string so we can fill in template variables |
| @@ -302,14 +305,14 @@ | ||
| 302 | 305 | const renderedYaml = renderTemplateData(templatedYaml, { secrets }); |
| 303 | 306 | |
| 304 | 307 | // Parse again and replace models with proxy versions where secrets weren't rendered |
| 305 | - const finalConfig = useProxyForUnrenderedSecrets( | |
| 308 | + const renderedConfig = useProxyForUnrenderedSecrets( | |
| 306 | 309 | parseAssistantUnrolled(renderedYaml), |
| 307 | 310 | id, |
| 308 | 311 | options.orgScopeId, |
| 309 | 312 | options.onPremProxyUrl, |
| 310 | 313 | ); |
| 311 | 314 | |
| 312 | - return { config: finalConfig, errors, configLoadInterrupted }; | |
| 315 | + return { config: renderedConfig, errors, configLoadInterrupted }; | |
| 313 | 316 | } |
| 314 | 317 | |
| 315 | 318 | function isPackageAllowed( |
| @@ -350,6 +353,7 @@ | ||
| 350 | 353 | injectBlocks: PackageIdentifier[] | undefined, |
| 351 | 354 | allowlistedBlocks?: PackageSlug[], |
| 352 | 355 | blocklistedBlocks?: PackageSlug[], |
| 356 | + injectRequestOptions?: RequestOptions, | |
| 353 | 357 | ): Promise<ConfigResult<AssistantUnrolled>> { |
| 354 | 358 | const errors: ConfigValidationError[] = []; |
| 355 | 359 | |
| @@ -363,11 +367,27 @@ | ||
| 363 | 367 | const unrolledAssistant: AssistantUnrolled = { |
| 364 | 368 | name: assistant.name, |
| 365 | 369 | version: assistant.version, |
| 370 | + requestOptions: assistant.requestOptions, | |
| 366 | 371 | }; |
| 367 | 372 | |
| 373 | + if (injectRequestOptions) { | |
| 374 | + unrolledAssistant.requestOptions = mergeConfigYamlRequestOptions( | |
| 375 | + assistant.requestOptions, | |
| 376 | + injectRequestOptions, | |
| 377 | + ); | |
| 378 | + } else { | |
| 379 | + unrolledAssistant.requestOptions = assistant.requestOptions; | |
| 380 | + } | |
| 381 | + | |
| 368 | 382 | const sections: (keyof Omit< |
| 369 | 383 | ConfigYaml, |
| 370 | - "name" | "version" | "rules" | "schema" | "metadata" | "env" | |
| 384 | + | "name" | |
| 385 | + | "version" | |
| 386 | + | "rules" | |
| 387 | + | "schema" | |
| 388 | + | "metadata" | |
| 389 | + | "env" | |
| 390 | + | "requestOptions" | |
| 371 | 391 | >)[] = ["models", "context", "data", "mcpServers", "prompts", "docs"]; |
| 372 | 392 | |
| 373 | 393 | // Process all sections in parallel |
| @@ -36,6 +36,7 @@ | ||
| 36 | 36 | globs?: string | string[]; |
| 37 | 37 | regex?: string | string[]; |
| 38 | 38 | alwaysApply?: boolean; |
| 39 | + invokable?: boolean; | |
| 39 | 40 | } = {}, |
| 40 | 41 | ): string { |
| 41 | 42 | const frontmatter: RuleFrontmatter = {}; |
| @@ -54,6 +55,10 @@ | ||
| 54 | 55 | frontmatter.description = options.description.trim(); |
| 55 | 56 | } |
| 56 | 57 | |
| 58 | + if (options.invokable !== undefined) { | |
| 59 | + frontmatter.invokable = options.invokable; | |
| 60 | + } | |
| 61 | + | |
| 57 | 62 | if (options.alwaysApply !== undefined) { |
| 58 | 63 | frontmatter.alwaysApply = options.alwaysApply; |
| 59 | 64 | } |
| @@ -117,6 +117,7 @@ | ||
| 117 | 117 | schema: z.string().optional(), |
| 118 | 118 | metadata: z.record(z.string()).and(commonMetadataSchema.partial()).optional(), |
| 119 | 119 | env: envRecord.optional(), |
| 120 | + requestOptions: requestOptionsSchema.optional(), | |
| 120 | 121 | }); |
| 121 | 122 | |
| 122 | 123 | const modelsUsesSchema = z |
| @@ -262,6 +263,7 @@ | ||
| 262 | 263 | api_base: z.string().optional(), |
| 263 | 264 | api_key: z.string().optional(), |
| 264 | 265 | env: envRecord.optional(), |
| 266 | + requestOptions: requestOptionsSchema.optional(), | |
| 265 | 267 | }); |
| 266 | 268 | |
| 267 | 269 | export type Config = z.infer<typeof configSchema>; |
| @@ -20,10 +20,10 @@ | ||
| 20 | 20 | }, |
| 21 | 21 | "../config-yaml": { |
| 22 | 22 | "name": "@continuedev/config-yaml", |
| 23 | - "version": "1.0.96", | |
| 23 | + "version": "1.14.0", | |
| 24 | 24 | "license": "Apache-2.0", |
| 25 | 25 | "dependencies": { |
| 26 | - "@continuedev/config-types": "file:../config-types", | |
| 26 | + "@continuedev/config-types": "^1.0.14", | |
| 27 | 27 | "yaml": "^2.6.1", |
| 28 | 28 | "zod": "^3.24.2" |
| 29 | 29 | }, |
| @@ -4,5 +4,6 @@ | ||
| 4 | 4 | { |
| 5 | 5 | model: "starcoder2:3b", |
| 6 | 6 | displayName: "StarCoder 2 3B", |
| 7 | + contextLength: 8192, | |
| 7 | 8 | }, |
| 8 | 9 | ]; |
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/openai-adapters", |
| 3 | - "version": "1.14.0", | |
| 3 | + "version": "1.15.0", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
| @@ -140,9 +140,25 @@ | ||
| 140 | 140 | ], |
| 141 | 141 | }; |
| 142 | 142 | } else if (message.role === "assistant" && message.tool_calls) { |
| 143 | - return { | |
| 144 | - role: "assistant", | |
| 145 | - content: message.tool_calls.map((toolCall) => { | |
| 143 | + const parts: any[] = []; | |
| 144 | + if (message.content) { | |
| 145 | + if (typeof message.content === "string") { | |
| 146 | + parts.push({ | |
| 147 | + type: "text", | |
| 148 | + text: message.content, | |
| 149 | + }); | |
| 150 | + } else if (message.content.length > 0) { | |
| 151 | + parts.push( | |
| 152 | + message.content.map((c) => ({ | |
| 153 | + type: "text", | |
| 154 | + text: c.type === "text" ? c.text : c.refusal, | |
| 155 | + })), | |
| 156 | + ); | |
| 157 | + } | |
| 158 | + } | |
| 159 | + | |
| 160 | + parts.push( | |
| 161 | + ...message.tool_calls.map((toolCall) => { | |
| 146 | 162 | // Type guard for function tool calls |
| 147 | 163 | if (toolCall.type === "function" && "function" in toolCall) { |
| 148 | 164 | return { |
| @@ -158,6 +174,10 @@ | ||
| 158 | 174 | throw new Error(`Unsupported tool call type: ${toolCall.type}`); |
| 159 | 175 | } |
| 160 | 176 | }), |
| 177 | + ); | |
| 178 | + return { | |
| 179 | + role: "assistant", | |
| 180 | + content: parts, | |
| 161 | 181 | }; |
| 162 | 182 | } |
| 163 | 183 |