move api folder to core (#5539)
* move api folder to core * fix incorrect import path mock in test setup * fix import in zai.ts * fix additional import errors
This commit is contained in:
1 parent
f676f2be78
commit
803574e7f3
86 files changed
+248
-222
No files matched your search
@@ -20,7 +20,6 @@ const aliasResolverPlugin = {
|
||||
setup(build) {
|
||||
const aliases = {
|
||||
"@": path.resolve(__dirname, "src"),
|
||||
"@api": path.resolve(__dirname, "src/api"),
|
||||
"@core": path.resolve(__dirname, "src/core"),
|
||||
"@integrations": path.resolve(__dirname, "src/integrations"),
|
||||
"@services": path.resolve(__dirname, "src/services"),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
import * as grpc from "@grpc/grpc-js"
|
||||
import * as protoLoader from "@grpc/proto-loader"
|
||||
import * as fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
|
||||
const DESCRIPTOR_SET = path.resolve("dist-standalone/proto/descriptor_set.pb")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
import * as grpc from "@grpc/grpc-js"
|
||||
import * as health from "grpc-health-check"
|
||||
import { ReflectionService } from "@grpc/reflection"
|
||||
import * as health from "grpc-health-check"
|
||||
import * as os from "os"
|
||||
import { host } from "src/generated/grpc-js/index"
|
||||
import { getPackageDefinition } from "./proto-utils.mjs"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ApiConfiguration, ModelInfo, QwenApiRegions } from "@shared/api"
|
||||
import { Mode } from "@shared/storage/types"
|
||||
import { ApiConfiguration, ModelInfo, QwenApiRegions } from "../shared/api"
|
||||
import { AnthropicHandler } from "./providers/anthropic"
|
||||
import { AskSageHandler } from "./providers/asksage"
|
||||
import { BasetenHandler } from "./providers/baseten"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { BasetenModelId, ModelInfo, basetenDefaultModelId, basetenModels } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
import { bedrockDefaultModelId, BedrockModelId, bedrockModels, CLAUDE_SONNET_4_1M_SUFFIX, ModelInfo } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { fromNodeProviderChain } from "@aws-sdk/credential-providers"
|
||||
import {
|
||||
@@ -3,7 +3,7 @@ import Cerebras from "@cerebras/cerebras_cloud_sdk"
|
||||
import { withRetry } from "../retry"
|
||||
import { ModelInfo, CerebrasModelId, cerebrasDefaultModelId, cerebrasModels } from "@shared/api"
|
||||
import { ApiHandler } from "../index"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
interface CerebrasHandlerOptions {
|
||||
cerebrasApiKey?: string
|
||||
File renamed without changes.
@@ -9,7 +9,7 @@ import { OpenRouterErrorResponse } from "./types"
|
||||
import { withRetry } from "../retry"
|
||||
import { AuthService } from "@/services/auth/AuthService"
|
||||
import OpenAI from "openai"
|
||||
import { version as extensionVersion } from "../../../package.json"
|
||||
import { version as extensionVersion } from "../../../../package.json"
|
||||
import { shouldSkipReasoningForModel } from "@utils/model-utils"
|
||||
import { CLINE_ACCOUNT_AUTH_ERROR_MESSAGE } from "@/shared/ClineAccount"
|
||||
import { clineEnvConfig } from "@/config"
|
||||
@@ -3,7 +3,7 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { ApiHandlerOptions, DeepSeekModelId, ModelInfo, deepSeekDefaultModelId, deepSeekModels } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
File renamed without changes.
@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from ".."
|
||||
import { ModelInfo, openAiModelInfoSaneDefaults } from "../../shared/api"
|
||||
import { ModelInfo, openAiModelInfoSaneDefaults } from "@shared/api"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { GroqModelId, ModelInfo, groqDefaultModelId, groqModels } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { ApiHandlerOptions, HuggingFaceModelId, ModelInfo, huggingFaceDefaultModelId, huggingFaceModels } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@ import { ApiHandler } from "../index"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
import { nebiusDefaultModelId, nebiusModels, type ModelInfo, type NebiusModelId } from "../../shared/api"
|
||||
import { nebiusDefaultModelId, nebiusModels, type ModelInfo, type NebiusModelId } from "@shared/api"
|
||||
|
||||
interface NebiusHandlerOptions {
|
||||
nebiusApiKey?: string
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { type ModelInfo, openAiModelInfoSaneDefaults } from "@shared/api"
|
||||
import { type Config, type Message, Ollama } from "ollama"
|
||||
import { ApiHandlerOptions, type ModelInfo, openAiModelInfoSaneDefaults } from "../../shared/api"
|
||||
import type { ApiHandler } from "../"
|
||||
import { withRetry } from "../retry"
|
||||
import { convertToOllamaMessages } from "../transform/ollama-format"
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ModelInfo, OpenAiNativeModelId, openAiNativeDefaultModelId, openAiNativeModels } from "@shared/api"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { ApiHandlerOptions, ModelInfo, openAiNativeDefaultModelId, OpenAiNativeModelId, openAiNativeModels } from "@shared/api"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { calculateApiCostOpenAI } from "../../utils/cost"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import type { ChatCompletionReasoningEffort } from "openai/resources/chat/completions"
|
||||
import { ApiHandler } from "../"
|
||||
import { withRetry } from "../retry"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
interface OpenAiNativeHandlerOptions {
|
||||
openAiNativeApiKey?: string
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,11 +1,11 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import OpenAI from "openai"
|
||||
import { ApiHandlerOptions, ModelInfo, requestyDefaultModelId, requestyDefaultModelInfo } from "@shared/api"
|
||||
import { ModelInfo, requestyDefaultModelId, requestyDefaultModelInfo } from "@shared/api"
|
||||
import { ApiHandler } from "../index"
|
||||
import { withRetry } from "../retry"
|
||||
import { convertToOpenAiMessages } from "@api/transform/openai-format"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { calculateApiCostOpenAI } from "@utils/cost"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
||||
interface RequestyHandlerOptions {
|
||||
requestyBaseUrl?: string
|
||||
@@ -3,9 +3,9 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ModelInfo, SambanovaModelId, sambanovaDefaultModelId, sambanovaModels } from "@shared/api"
|
||||
import { ApiHandler } from "../index"
|
||||
import { convertToOpenAiMessages } from "@/api/transform/openai-format"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { convertToR1Format } from "@api/transform/r1-format"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
|
||||
interface SambanovaHandlerOptions {
|
||||
sambanovaApiKey?: string
|
||||
@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import axios from "axios"
|
||||
import OpenAI from "openai"
|
||||
import { ApiHandler } from "../"
|
||||
import { ModelInfo, sapAiCoreDefaultModelId, SapAiCoreModelId, sapAiCoreModels } from "../../shared/api"
|
||||
import { ModelInfo, sapAiCoreDefaultModelId, SapAiCoreModelId, sapAiCoreModels } from "@shared/api"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import {
|
||||
@@ -3,9 +3,9 @@ import OpenAI from "openai"
|
||||
import { withRetry } from "../retry"
|
||||
import { ModelInfo, openAiModelInfoSaneDefaults } from "@shared/api"
|
||||
import { ApiHandler } from "../index"
|
||||
import { convertToOpenAiMessages } from "@api/transform/openai-format"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { convertToR1Format } from "@api/transform/r1-format"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
|
||||
interface TogetherHandlerOptions {
|
||||
togetherApiKey?: string
|
||||
File renamed without changes.
@@ -2,8 +2,8 @@ import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk"
|
||||
import { withRetry } from "../retry"
|
||||
import { ApiHandler } from "../"
|
||||
import { ApiHandlerOptions, ModelInfo, vertexDefaultModelId, VertexModelId, vertexModels } from "@shared/api"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { ModelInfo, vertexDefaultModelId, VertexModelId, vertexModels } from "@shared/api"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { GeminiHandler } from "./gemini"
|
||||
|
||||
interface VertexHandlerOptions {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { convertToVsCodeLmMessages } from "@api/transform/vscode-lm-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { convertToVsCodeLmMessages } from "../transform/vscode-lm-format"
|
||||
import { ModelInfo, openAiModelInfoSaneDefaults } from "@shared/api"
|
||||
import { SELECTOR_SEPARATOR, stringifyVsCodeLmModelSelector } from "@shared/vsCodeSelectorUtils"
|
||||
import { calculateApiCostAnthropic } from "@utils/cost"
|
||||
@@ -2,8 +2,8 @@ import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import OpenAI from "openai"
|
||||
import { ApiHandler } from "../"
|
||||
import { XAIModelId, ModelInfo, xaiDefaultModelId, xaiModels } from "@shared/api"
|
||||
import { convertToOpenAiMessages } from "@api/transform/openai-format"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { ApiStream } from "../transform/stream"
|
||||
import { ChatCompletionReasoningEffort } from "openai/resources/chat/completions"
|
||||
import { withRetry } from "../retry"
|
||||
import { shouldSkipReasoningForModel } from "@utils/model-utils"
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
mainlandZAiModels,
|
||||
} from "@shared/api"
|
||||
import OpenAI from "openai"
|
||||
import { version as extensionVersion } from "../../../package.json"
|
||||
import { version as extensionVersion } from "../../../../package.json"
|
||||
import { ApiHandler } from ".."
|
||||
import { withRetry } from "../retry"
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { CLAUDE_SONNET_4_1M_SUFFIX, ModelInfo, openRouterClaudeSonnet41mModelId } from "@shared/api"
|
||||
import { convertToOpenAiMessages } from "@api/transform/openai-format"
|
||||
import { convertToR1Format } from "@api/transform/r1-format"
|
||||
import { convertToOpenAiMessages } from "./openai-format"
|
||||
import { convertToR1Format } from "./r1-format"
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import OpenAI from "openai"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ClineApiReqInfo, ClineMessage } from "@shared/ExtensionMessage"
|
||||
import { ApiHandler } from "@api/index"
|
||||
import { ApiHandler } from "@core/api"
|
||||
import { getContextWindowInfo } from "./context-window-utils"
|
||||
|
||||
class ContextManager {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { getContextWindowInfo } from "./context-window-utils"
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ApiHandler } from "@core/api"
|
||||
import { formatResponse } from "@core/prompts/responses"
|
||||
import { GlobalFileNames } from "@core/storage/disk"
|
||||
import { fileExistsAtPath } from "@utils/fs"
|
||||
import * as path from "path"
|
||||
import fs from "fs/promises"
|
||||
import cloneDeep from "clone-deep"
|
||||
import { ClineApiReqInfo, ClineMessage } from "@shared/ExtensionMessage"
|
||||
import { ApiHandler } from "@api/index"
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { fileExistsAtPath } from "@utils/fs"
|
||||
import cloneDeep from "clone-deep"
|
||||
import fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
import { getContextWindowInfo } from "./context-window-utils"
|
||||
|
||||
enum EditType {
|
||||
UNDEFINED = 0,
|
||||
@@ -180,7 +180,7 @@ export class ContextManager {
|
||||
previousApiReqIndex: number,
|
||||
taskDirectory: string,
|
||||
) {
|
||||
let updatedConversationHistoryDeletedRange = false
|
||||
const updatedConversationHistoryDeletedRange = false
|
||||
|
||||
const truncatedConversationHistory = this.getAndAlterTruncatedMessages(
|
||||
apiConversationHistory,
|
||||
@@ -566,7 +566,7 @@ export class ContextManager {
|
||||
fileReadIndices: Map<string, [number, number, string, string][]>,
|
||||
thisExistingFileReads: string[],
|
||||
): [boolean, string[]] {
|
||||
const pattern = new RegExp(`<file_content path="([^"]*)">([\\s\\S]*?)</file_content>`, "g")
|
||||
const pattern = /<file_content path="([^"]*)">([\s\S]*?)<\/file_content>/g
|
||||
|
||||
let foundMatch = false
|
||||
const filePaths: string[] = []
|
||||
@@ -631,7 +631,7 @@ export class ContextManager {
|
||||
secondBlockText: string,
|
||||
fileReadIndices: Map<string, [number, number, string, string][]>,
|
||||
) {
|
||||
const pattern = new RegExp(`(<final_file_content path="[^"]*">)[\\s\\S]*?(</final_file_content>)`)
|
||||
const pattern = /(<final_file_content path="[^"]*">)[\s\S]*?(<\/final_file_content>)/
|
||||
|
||||
// check if this exists in the text, it won't exist if the user rejects the file change for example
|
||||
if (pattern.test(secondBlockText)) {
|
||||
@@ -715,7 +715,7 @@ export class ContextManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let innerTuple = this.contextHistoryUpdates.get(messageIndex)
|
||||
const innerTuple = this.contextHistoryUpdates.get(messageIndex)
|
||||
let innerMap: Map<number, ContextUpdate[]>
|
||||
|
||||
if (!innerTuple) {
|
||||
@@ -742,7 +742,7 @@ export class ContextManager {
|
||||
// apply file mention updates to contextHistoryUpdates
|
||||
// in fileMentionUpdates, filePathsUpdated includes all the file paths which are updated in the latest version of this altered text
|
||||
for (const [messageIndex, [updatedText, filePathsUpdated]] of fileMentionUpdates.entries()) {
|
||||
let innerTuple = this.contextHistoryUpdates.get(messageIndex)
|
||||
const innerTuple = this.contextHistoryUpdates.get(messageIndex)
|
||||
let innerMap: Map<number, ContextUpdate[]>
|
||||
|
||||
if (!innerTuple) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiHandler } from "@api/index"
|
||||
import { OpenAiHandler } from "@api/providers/openai"
|
||||
import { ApiHandler } from "@core/api"
|
||||
import { OpenAiHandler } from "@core/api/providers/openai"
|
||||
|
||||
/**
|
||||
* Gets context window information for the given API handler
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { getLatestAnnouncementId } from "@/utils/announcements"
|
||||
import { getCwd, getDesktopDir } from "@/utils/path"
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { buildApiHandler } from "@api/index"
|
||||
import { buildApiHandler } from "@core/api"
|
||||
import { cleanupLegacyCheckpoints } from "@integrations/checkpoints/CheckpointMigration"
|
||||
import { downloadTask } from "@integrations/misc/export-markdown"
|
||||
import { ClineAccountService } from "@services/account/ClineAccountService"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Controller } from "../index"
|
||||
import { Empty } from "@shared/proto/cline/common"
|
||||
import { UpdateApiConfigurationRequest } from "@shared/proto/cline/models"
|
||||
import { buildApiHandler } from "@api/index"
|
||||
import { buildApiHandler } from "@core/api"
|
||||
import { convertProtoToApiConfiguration } from "@shared/proto-conversions/models/api-configuration-conversion"
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,10 +6,10 @@ import {
|
||||
OpenaiReasoningEffort as ProtoOpenaiReasoningEffort,
|
||||
McpDisplayMode as ProtoMcpDisplayMode,
|
||||
} from "@shared/proto/cline/state"
|
||||
import { buildApiHandler } from "../../../api"
|
||||
import { convertProtoApiConfigurationToApiConfiguration } from "../../../shared/proto-conversions/state/settings-conversion"
|
||||
import { TelemetrySetting } from "@/shared/TelemetrySetting"
|
||||
import { OpenaiReasoningEffort } from "@/shared/storage/types"
|
||||
import { buildApiHandler } from "@core/api"
|
||||
import { convertProtoApiConfigurationToApiConfiguration } from "@shared/proto-conversions/state/settings-conversion"
|
||||
import { TelemetrySetting } from "@shared/TelemetrySetting"
|
||||
import { OpenaiReasoningEffort } from "@shared/storage/types"
|
||||
import { McpDisplayMode } from "@/shared/McpDisplayMode"
|
||||
import { telemetryService } from "../../../services/posthog/PostHogClientProvider"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import * as diff from "diff"
|
||||
import * as path from "path"
|
||||
import { ClineIgnoreController, LOCK_TEXT_SYMBOL } from "../ignore/ClineIgnoreController"
|
||||
import { Mode } from "@/shared/storage/types"
|
||||
import { ClineIgnoreController, LOCK_TEXT_SYMBOL } from "../ignore/ClineIgnoreController"
|
||||
|
||||
export const formatResponse = {
|
||||
duplicateFileReadNotice: () =>
|
||||
@@ -52,7 +52,7 @@ Otherwise, if you have not completed the task and do not need additional informa
|
||||
images?: string[],
|
||||
fileString?: string,
|
||||
): string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam> => {
|
||||
let toolResultOutput = []
|
||||
const toolResultOutput = []
|
||||
|
||||
if (!(images && images.length > 0) && !fileString) {
|
||||
return text
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ApiHandlerModel } from "@core/api"
|
||||
import { McpHub } from "@services/mcp/McpHub"
|
||||
import { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import { ApiHandlerModel } from "@/api"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { SYSTEM_PROMPT_GENERIC } from "./generic-system-prompt"
|
||||
import { SYSTEM_PROMPT_NEXT_GEN } from "./families/next-gen-models/next-gen-system-prompt"
|
||||
import { SYSTEM_PROMPT_GENERIC } from "./generic-system-prompt"
|
||||
import { isNextGenModelFamily } from "./utils"
|
||||
|
||||
export const buildSystemPrompt = async (
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { getShell } from "@utils/shell"
|
||||
import os from "os"
|
||||
import osName from "os-name"
|
||||
import { McpHub } from "@services/mcp/McpHub"
|
||||
import { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { getShell } from "@utils/shell"
|
||||
import os from "os"
|
||||
import osName from "os-name"
|
||||
|
||||
export const SYSTEM_PROMPT_NEXT_GEN = async (
|
||||
cwd: string,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { getShell } from "@utils/shell"
|
||||
import os from "os"
|
||||
import osName from "os-name"
|
||||
import { McpHub } from "@services/mcp/McpHub"
|
||||
import { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { getShell } from "@utils/shell"
|
||||
import os from "os"
|
||||
import osName from "os-name"
|
||||
|
||||
export const SYSTEM_PROMPT_GENERIC = async (
|
||||
cwd: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiHandlerModel } from "@/api"
|
||||
import { ApiHandlerModel } from "@core/api"
|
||||
|
||||
export function isClaude4ModelFamily(apiHandlerModel: ApiHandlerModel): boolean {
|
||||
const modelId = apiHandlerModel.id.toLowerCase()
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
import { showSystemNotification } from "@/integrations/notifications"
|
||||
import { listFiles } from "@/services/glob/list-files"
|
||||
import { telemetryService } from "@/services/posthog/PostHogClientProvider"
|
||||
import { regexSearchFiles } from "@/services/ripgrep"
|
||||
import { parseSourceCodeForDefinitionsTopLevel } from "@/services/tree-sitter"
|
||||
import { findLast, findLastIndex, parsePartialArrayString } from "@/shared/array"
|
||||
import { createAndOpenGitHubIssue } from "@/utils/github-url-utils"
|
||||
import { getReadablePath, isLocatedInWorkspace } from "@/utils/path"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import Anthropic from "@anthropic-ai/sdk"
|
||||
import { ApiHandler } from "@api/index"
|
||||
import { ApiHandler } from "@core/api"
|
||||
import { FileContextTracker } from "@core/context/context-tracking/FileContextTracker"
|
||||
import { ClineIgnoreController } from "@core/ignore/ClineIgnoreController"
|
||||
import { DiffViewProvider } from "@integrations/editor/DiffViewProvider"
|
||||
import { extractFileContent } from "@integrations/misc/extract-file-content"
|
||||
import { processFilesIntoText } from "@integrations/misc/extract-text"
|
||||
import { BrowserSession } from "@services/browser/BrowserSession"
|
||||
import { UrlContentFetcher } from "@services/browser/UrlContentFetcher"
|
||||
import { McpHub } from "@services/mcp/McpHub"
|
||||
import { AutoApprovalSettings } from "@shared/AutoApprovalSettings"
|
||||
import { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { COMMAND_REQ_APP_STRING } from "@shared/combineCommandSequences"
|
||||
import {
|
||||
BrowserAction,
|
||||
BrowserActionResult,
|
||||
@@ -31,32 +25,38 @@ import {
|
||||
ClineSayTool,
|
||||
COMPLETION_RESULT_CHANGES_FLAG,
|
||||
} from "@shared/ExtensionMessage"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { Mode } from "@shared/storage/types"
|
||||
import { ClineAskResponse } from "@shared/WebviewMessage"
|
||||
import { extractFileContent } from "@integrations/misc/extract-file-content"
|
||||
import { COMMAND_REQ_APP_STRING } from "@shared/combineCommandSequences"
|
||||
import { fileExistsAtPath } from "@utils/fs"
|
||||
import { modelDoesntSupportWebp } from "@utils/model-utils"
|
||||
import { fixModelHtmlEscaping, removeInvalidChars } from "@utils/string"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import os from "os"
|
||||
import * as path from "path"
|
||||
import { serializeError } from "serialize-error"
|
||||
import * as vscode from "vscode"
|
||||
import { ToolResponse } from "."
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { showSystemNotification } from "@/integrations/notifications"
|
||||
import { listFiles } from "@/services/glob/list-files"
|
||||
import { telemetryService } from "@/services/posthog/PostHogClientProvider"
|
||||
import { regexSearchFiles } from "@/services/ripgrep"
|
||||
import { parseSourceCodeForDefinitionsTopLevel } from "@/services/tree-sitter"
|
||||
import { findLast, findLastIndex, parsePartialArrayString } from "@/shared/array"
|
||||
import { createAndOpenGitHubIssue } from "@/utils/github-url-utils"
|
||||
import { getReadablePath, isLocatedInWorkspace } from "@/utils/path"
|
||||
import { ToolParamName, ToolUse, ToolUseName } from "../assistant-message"
|
||||
import { constructNewFileContent } from "../assistant-message/diff"
|
||||
import { ContextManager } from "../context/context-management/ContextManager"
|
||||
import { continuationPrompt } from "../prompts/contextManagement"
|
||||
import { loadMcpDocumentation } from "../prompts/loadMcpDocumentation"
|
||||
import { formatResponse } from "../prompts/responses"
|
||||
import { ensureTaskDirectoryExists } from "../storage/disk"
|
||||
import { CacheService } from "../storage/CacheService"
|
||||
import { TaskState } from "./TaskState"
|
||||
import { ensureTaskDirectoryExists } from "../storage/disk"
|
||||
import { ToolResponse } from "."
|
||||
import { MessageStateHandler } from "./message-state"
|
||||
import { TaskState } from "./TaskState"
|
||||
import { AutoApprove } from "./tools/autoApprove"
|
||||
import { showNotificationForApprovalIfAutoApprovalEnabled } from "./utils"
|
||||
import { Mode } from "@shared/storage/types"
|
||||
import { continuationPrompt } from "../prompts/contextManagement"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
|
||||
export class ToolExecutor {
|
||||
private autoApprover: AutoApprove
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { isFocusChainItem } from "@shared/focus-chain-utils"
|
||||
import * as fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
import * as vscode from "vscode"
|
||||
import { ensureTaskDirectoryExists } from "../../storage/disk"
|
||||
import { isFocusChainItem } from "@shared/focus-chain-utils"
|
||||
|
||||
/**
|
||||
* Generate the standard file path for a task's focusChain markdown file
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isFocusChainItem, isCompletedFocusChainItem } from "@shared/focus-chain-utils"
|
||||
import { isCompletedFocusChainItem, isFocusChainItem } from "@shared/focus-chain-utils"
|
||||
|
||||
export interface TodoListCounts {
|
||||
totalItems: number
|
||||
|
||||
+14
-14
@@ -1,13 +1,11 @@
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { errorService } from "@/services/posthog/PostHogClientProvider"
|
||||
import { ShowMessageType } from "@/shared/proto/index.host"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { ApiHandler, buildApiHandler } from "@api/index"
|
||||
import { ApiStream } from "@api/transform/stream"
|
||||
import { ApiHandler, buildApiHandler } from "@core/api"
|
||||
import { ApiStream } from "@core/api/transform/stream"
|
||||
import { parseAssistantMessageV2, ToolUseName } from "@core/assistant-message"
|
||||
import { ContextManager } from "@core/context/context-management/ContextManager"
|
||||
import { checkContextWindowExceededError } from "@core/context/context-management/context-error-handling"
|
||||
import { getContextWindowInfo } from "@core/context/context-management/context-window-utils"
|
||||
import { ContextManager } from "@core/context/context-management/ContextManager"
|
||||
import { FileContextTracker } from "@core/context/context-tracking/FileContextTracker"
|
||||
import { ModelContextTracker } from "@core/context/context-tracking/ModelContextTracker"
|
||||
import {
|
||||
@@ -24,15 +22,15 @@ import { sendPartialMessageEvent } from "@core/controller/ui/subscribeToPartialM
|
||||
import { sendRelinquishControlEvent } from "@core/controller/ui/subscribeToRelinquishControl"
|
||||
import { ClineIgnoreController } from "@core/ignore/ClineIgnoreController"
|
||||
import { parseMentions } from "@core/mentions"
|
||||
import { summarizeTask } from "@core/prompts/contextManagement"
|
||||
import { formatResponse } from "@core/prompts/responses"
|
||||
import { buildSystemPrompt } from "@/core/prompts/system-prompt/build-system-prompt"
|
||||
import { parseSlashCommands } from "@core/slash-commands"
|
||||
import {
|
||||
ensureRulesDirectoryExists,
|
||||
ensureTaskDirectoryExists,
|
||||
GlobalFileNames,
|
||||
getSavedApiConversationHistory,
|
||||
getSavedClineMessages,
|
||||
GlobalFileNames,
|
||||
} from "@core/storage/disk"
|
||||
import CheckpointTracker from "@integrations/checkpoints/CheckpointTracker"
|
||||
import { DiffViewProvider } from "@integrations/editor/DiffViewProvider"
|
||||
@@ -46,14 +44,14 @@ import { listFiles } from "@services/glob/list-files"
|
||||
import { Logger } from "@services/logging/Logger"
|
||||
import { McpHub } from "@services/mcp/McpHub"
|
||||
import { telemetryService } from "@services/posthog/PostHogClientProvider"
|
||||
import { AutoApprovalSettings } from "@shared/AutoApprovalSettings"
|
||||
import { ApiConfiguration } from "@shared/api"
|
||||
import { findLast, findLastIndex } from "@shared/array"
|
||||
import { AutoApprovalSettings } from "@shared/AutoApprovalSettings"
|
||||
import { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { combineApiRequests } from "@shared/combineApiRequests"
|
||||
import { combineCommandSequences } from "@shared/combineCommandSequences"
|
||||
import { ClineApiReqCancelReason, ClineApiReqInfo, ClineAsk, ClineMessage, ClineSay } from "@shared/ExtensionMessage"
|
||||
import { FocusChainSettings } from "@shared/FocusChainSettings"
|
||||
import { getApiMetrics } from "@shared/getApiMetrics"
|
||||
import { HistoryItem } from "@shared/HistoryItem"
|
||||
import { DEFAULT_LANGUAGE_SETTINGS, getLanguageKey, LanguageDisplay } from "@shared/Languages"
|
||||
@@ -64,25 +62,27 @@ import { getGitRemoteUrls, getLatestGitCommitHash } from "@utils/git"
|
||||
import { arePathsEqual, getDesktopDir } from "@utils/path"
|
||||
import cloneDeep from "clone-deep"
|
||||
import { execa } from "execa"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import pTimeout from "p-timeout"
|
||||
import pWaitFor from "p-wait-for"
|
||||
import * as path from "path"
|
||||
import { ulid } from "ulid"
|
||||
import * as vscode from "vscode"
|
||||
import { buildSystemPrompt } from "@/core/prompts/system-prompt/build-system-prompt"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { errorService } from "@/services/posthog/PostHogClientProvider"
|
||||
import { ShowMessageType } from "@/shared/proto/index.host"
|
||||
import { isInTestMode } from "../../services/test/TestMode"
|
||||
import { ensureLocalClineDirExists } from "../context/instructions/user-instructions/rule-helpers"
|
||||
import { refreshWorkflowToggles } from "../context/instructions/user-instructions/workflows"
|
||||
import { Controller } from "../controller"
|
||||
import { addUserInstructions } from "../prompts/system-prompt/user-instructions/addUserInstructions"
|
||||
import { CacheService } from "../storage/CacheService"
|
||||
import { FocusChainManager } from "./focus-chain"
|
||||
import { MessageStateHandler } from "./message-state"
|
||||
import { showChangedFilesDiff } from "./multifile-diff"
|
||||
import { TaskState } from "./TaskState"
|
||||
import { ToolExecutor } from "./ToolExecutor"
|
||||
import { updateApiReqMsg } from "./utils"
|
||||
import { FocusChainManager } from "./focus-chain"
|
||||
import { summarizeTask } from "@core/prompts/contextManagement"
|
||||
import { addUserInstructions } from "../prompts/system-prompt/user-instructions/addUserInstructions"
|
||||
|
||||
export type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>
|
||||
type UserContent = Array<Anthropic.ContentBlockParam>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { showSystemNotification } from "@/integrations/notifications"
|
||||
import { ClineApiReqCancelReason, ClineApiReqInfo } from "@/shared/ExtensionMessage"
|
||||
import { MessageStateHandler } from "./message-state"
|
||||
import { calculateApiCostAnthropic } from "@/utils/cost"
|
||||
import { ApiHandler } from "@/api"
|
||||
import { ApiHandler } from "@core/api"
|
||||
|
||||
export const showNotificationForApprovalIfAutoApprovalEnabled = (
|
||||
message: string,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { GetHostVersionResponse } from "@/shared/proto/index.host"
|
||||
import { EmptyRequest, String } from "@shared/proto/cline/common"
|
||||
import * as vscode from "vscode"
|
||||
import { GetHostVersionResponse } from "@/shared/proto/index.host"
|
||||
|
||||
export async function getHostVersion(_: EmptyRequest): Promise<GetHostVersionResponse> {
|
||||
return { platform: "VSCode", version: vscode.version }
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import * as path from "path"
|
||||
import * as fs from "fs/promises"
|
||||
import { formatResponse } from "@core/prompts/responses"
|
||||
import { createDirectoriesForFile } from "@utils/fs"
|
||||
import { getCwd } from "@utils/path"
|
||||
import { formatResponse } from "@core/prompts/responses"
|
||||
import * as diff from "diff"
|
||||
import { detectEncoding } from "../misc/extract-text"
|
||||
import * as fs from "fs/promises"
|
||||
import * as iconv from "iconv-lite"
|
||||
import * as path from "path"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { DiagnosticSeverity, FileDiagnostics } from "@/shared/proto/index.cline"
|
||||
import { diagnosticsToProblemsString, getNewDiagnostics } from "@/integrations/diagnostics"
|
||||
import { DiagnosticSeverity, FileDiagnostics } from "@/shared/proto/index.cline"
|
||||
import { detectEncoding } from "../misc/extract-text"
|
||||
import { openFile } from "../misc/open-file"
|
||||
|
||||
export abstract class DiffViewProvider {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { buildApiHandler } from "@core/api"
|
||||
import * as vscode from "vscode"
|
||||
import { readStateFromDisk } from "@/core/storage/utils/state-helpers"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { buildApiHandler } from "@/api"
|
||||
import { readStateFromDisk } from "@/core/storage/utils/state-helpers"
|
||||
import { getWorkingState } from "@/utils/git"
|
||||
import { getCwd } from "@/utils/path"
|
||||
|
||||
@@ -14,7 +14,7 @@ export const GitCommitGenerator = {
|
||||
abort,
|
||||
}
|
||||
|
||||
let commitGenerationAbortController: AbortController | undefined = undefined
|
||||
let commitGenerationAbortController: AbortController | undefined
|
||||
|
||||
async function generate(context: vscode.ExtensionContext, scm?: vscode.SourceControl) {
|
||||
const cwd = await getCwd()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import { writeFile } from "@utils/fs"
|
||||
import os from "os"
|
||||
import * as path from "path"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { writeFile } from "@utils/fs"
|
||||
import { openFile } from "./open-file"
|
||||
|
||||
export async function downloadTask(dateTs: number, conversationHistory: Anthropic.MessageParam[]) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as path from "path"
|
||||
import * as os from "os"
|
||||
import * as vscode from "vscode"
|
||||
import { writeFile } from "@utils/fs"
|
||||
import { arePathsEqual } from "@utils/path"
|
||||
import * as os from "os"
|
||||
import * as path from "path"
|
||||
import * as vscode from "vscode"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageRequest, ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { writeFile } from "@utils/fs"
|
||||
|
||||
export async function openImage(dataUri: string) {
|
||||
const matches = dataUri.match(/^data:image\/([a-zA-Z]+);base64,(.+)$/)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
import sizeOf from "image-size"
|
||||
import * as path from "path"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { featureFlagsService, telemetryService } from "@services/posthog/PostHogClientProvider"
|
||||
import { AuthState, UserInfo } from "@shared/proto/cline/account"
|
||||
import { type EmptyRequest, String } from "@shared/proto/cline/common"
|
||||
import { clineEnvConfig } from "@/config"
|
||||
import { Controller } from "@/core/controller"
|
||||
import { getRequestRegistry, type StreamingResponseHandler } from "@/core/controller/grpc-handler"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { FEATURE_FLAGS } from "@/shared/services/feature-flags/feature-flags"
|
||||
import { openExternal } from "@/utils/env"
|
||||
import { featureFlagsService, telemetryService } from "@services/posthog/PostHogClientProvider"
|
||||
import { AuthState, UserInfo } from "@shared/proto/cline/account"
|
||||
import { type EmptyRequest, String } from "@shared/proto/cline/common"
|
||||
import { FirebaseAuthProvider } from "./providers/FirebaseAuthProvider"
|
||||
|
||||
const DefaultClineAccountURI = `${clineEnvConfig.appBaseUrl}/auth`
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { String } from "@shared/proto/cline/common"
|
||||
import { clineEnvConfig } from "@/config"
|
||||
import { Controller } from "@/core/controller"
|
||||
import { WebviewProvider } from "@/core/webview"
|
||||
import type { UserResponse } from "@/shared/ClineAccount"
|
||||
import { String } from "@shared/proto/cline/common"
|
||||
import { AuthService } from "./AuthService"
|
||||
|
||||
export class AuthServiceMock extends AuthService {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import { sendMcpServersUpdate } from "@core/controller/mcp/subscribeToMcpServers"
|
||||
import { GlobalFileNames } from "@core/storage/disk"
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
|
||||
@@ -29,11 +28,12 @@ import { secondsToMs } from "@utils/time"
|
||||
import chokidar, { FSWatcher } from "chokidar"
|
||||
import deepEqual from "fast-deep-equal"
|
||||
import * as fs from "fs/promises"
|
||||
import { setTimeout as setTimeoutPromise } from "node:timers/promises"
|
||||
import * as path from "path"
|
||||
import ReconnectingEventSource from "reconnecting-eventsource"
|
||||
import * as vscode from "vscode"
|
||||
import { z } from "zod"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { DEFAULT_REQUEST_TIMEOUT_MS } from "./constants"
|
||||
import { BaseConfigSchema, McpSettingsSchema, ServerConfigSchema } from "./schemas"
|
||||
import { McpConnection, McpServerConfig, Transport } from "./types"
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import * as vscode from "vscode"
|
||||
import { version as extensionVersion } from "../../../../package.json"
|
||||
import { HostProvider } from "@hosts/host-provider"
|
||||
import { ShowMessageType } from "@shared/proto/host/window"
|
||||
|
||||
import type { TaskFeedbackType } from "@shared/WebviewMessage"
|
||||
import type { BrowserSettings } from "@shared/BrowserSettings"
|
||||
import type { PostHogClientProvider } from "../PostHogClientProvider"
|
||||
import { Mode } from "@/shared/storage/types"
|
||||
import { ShowMessageType } from "@shared/proto/host/window"
|
||||
import type { TaskFeedbackType } from "@shared/WebviewMessage"
|
||||
import * as vscode from "vscode"
|
||||
import { ClineAccountUserInfo } from "@/services/auth/AuthService"
|
||||
import { Mode } from "@/shared/storage/types"
|
||||
import { version as extensionVersion } from "../../../../package.json"
|
||||
import type { PostHogClientProvider } from "../PostHogClientProvider"
|
||||
|
||||
/**
|
||||
* TelemetryService handles telemetry event tracking for the Cline extension
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { LanguageModelChatSelector } from "../api/providers/types"
|
||||
import type { LanguageModelChatSelector } from "../core/api/providers/types"
|
||||
|
||||
export type ApiProvider =
|
||||
| "anthropic"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiHandlerModel } from "@api/index"
|
||||
import { ApiHandlerModel } from "@core/api"
|
||||
|
||||
export function modelDoesntSupportWebp(apiHandlerModel: ApiHandlerModel): boolean {
|
||||
const modelId = apiHandlerModel.id.toLowerCase()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ Module.prototype.require = function (id) {
|
||||
// Intercept requires for @google/genai
|
||||
if (id === "@google/genai") {
|
||||
// Return the mock instead
|
||||
const mockPath = path.join(baseUrl, "out/src/api/providers/gemini-mock.test.js")
|
||||
const mockPath = path.join(baseUrl, "out/src/core/api/providers/gemini-mock.test.js")
|
||||
return originalRequire.call(this, mockPath)
|
||||
}
|
||||
return originalRequire.call(this, id)
|
||||
|
||||
+40
-13
@@ -4,7 +4,10 @@
|
||||
"experimentalDecorators": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
"lib": ["es2022", "DOM"],
|
||||
"lib": [
|
||||
"es2022",
|
||||
"DOM"
|
||||
],
|
||||
"module": "esnext",
|
||||
"moduleResolution": "Bundler",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
@@ -21,18 +24,42 @@
|
||||
"useUnknownInCatchVariables": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"@api/*": ["src/api/*"],
|
||||
"@core/*": ["src/core/*"],
|
||||
"@generated/*": ["src/generated/*"],
|
||||
"@hosts/*": ["src/hosts/*"],
|
||||
"@integrations/*": ["src/integrations/*"],
|
||||
"@packages/*": ["src/packages/*"],
|
||||
"@services/*": ["src/services/*"],
|
||||
"@shared/*": ["src/shared/*"],
|
||||
"@utils/*": ["src/utils/*"]
|
||||
"@/*": [
|
||||
"src/*"
|
||||
],
|
||||
"@core/*": [
|
||||
"src/core/*"
|
||||
],
|
||||
"@generated/*": [
|
||||
"src/generated/*"
|
||||
],
|
||||
"@hosts/*": [
|
||||
"src/hosts/*"
|
||||
],
|
||||
"@integrations/*": [
|
||||
"src/integrations/*"
|
||||
],
|
||||
"@packages/*": [
|
||||
"src/packages/*"
|
||||
],
|
||||
"@services/*": [
|
||||
"src/services/*"
|
||||
],
|
||||
"@shared/*": [
|
||||
"src/shared/*"
|
||||
],
|
||||
"@utils/*": [
|
||||
"src/utils/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", ".vscode-test", "webview-ui", "src/test/e2e/**/*"]
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test",
|
||||
"webview-ui",
|
||||
"src/test/e2e/**/*"
|
||||
]
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
import HeroTooltip from "@/components/common/HeroTooltip"
|
||||
import Thumbnails from "@/components/common/Thumbnails"
|
||||
import { normalizeApiConfiguration, getModeSpecificFields } from "@/components/settings/utils/providerUtils"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { FileServiceClient, TaskServiceClient, UiServiceClient } from "@/services/grpc-client"
|
||||
import { formatLargeNumber, formatSize } from "@/utils/format"
|
||||
import { validateSlashCommand } from "@/utils/slash-commands"
|
||||
import { mentionRegexGlobal } from "@shared/context-mentions"
|
||||
import { isFocusChainItem, isCompletedFocusChainItem, FOCUS_CHAIN_ITEM_REGEX } from "@shared/focus-chain-utils"
|
||||
import { ClineMessage } from "@shared/ExtensionMessage"
|
||||
import { FOCUS_CHAIN_ITEM_REGEX, isCompletedFocusChainItem, isFocusChainItem } from "@shared/focus-chain-utils"
|
||||
import { StringArrayRequest, StringRequest } from "@shared/proto/cline/common"
|
||||
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
|
||||
import React, { memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { useWindowSize } from "react-use"
|
||||
import TaskTimeline from "./TaskTimeline"
|
||||
import DeleteTaskButton from "./buttons/DeleteTaskButton"
|
||||
import CopyTaskButton from "./buttons/CopyTaskButton"
|
||||
import OpenDiskTaskHistoryButton from "./buttons/OpenDiskTaskHistoryButton"
|
||||
import ChecklistRenderer from "@/components/common/ChecklistRenderer"
|
||||
import HeroTooltip from "@/components/common/HeroTooltip"
|
||||
import Thumbnails from "@/components/common/Thumbnails"
|
||||
import { getModeSpecificFields, normalizeApiConfiguration } from "@/components/settings/utils/providerUtils"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { FileServiceClient, TaskServiceClient, UiServiceClient } from "@/services/grpc-client"
|
||||
import { formatLargeNumber, formatSize } from "@/utils/format"
|
||||
import { validateSlashCommand } from "@/utils/slash-commands"
|
||||
import CopyTaskButton from "./buttons/CopyTaskButton"
|
||||
import DeleteTaskButton from "./buttons/DeleteTaskButton"
|
||||
import OpenDiskTaskHistoryButton from "./buttons/OpenDiskTaskHistoryButton"
|
||||
import TaskTimeline from "./TaskTimeline"
|
||||
|
||||
const IS_DEV = process.env.IS_DEV
|
||||
|
||||
@@ -216,14 +216,14 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
}}>
|
||||
<HeroTooltip content="Context window usage">
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
style={{
|
||||
flex: 1,
|
||||
height: "4px",
|
||||
backgroundColor: "color-mix(in srgb, var(--vscode-badge-foreground) 20%, transparent)",
|
||||
borderRadius: "2px",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
className="cursor-pointer">
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
width: `${((lastApiReqTotalTokens || 0) / contextWindow) * 100}%`,
|
||||
@@ -265,6 +265,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
alignItems: "center",
|
||||
}}>
|
||||
<div
|
||||
onClick={() => setIsTaskExpanded(!isTaskExpanded)}
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
@@ -276,8 +277,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
msUserSelect: "none",
|
||||
flexGrow: 1,
|
||||
minWidth: 0, // This allows the div to shrink below its content size
|
||||
}}
|
||||
onClick={() => setIsTaskExpanded(!isTaskExpanded)}>
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
@@ -324,9 +324,9 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
)}
|
||||
<VSCodeButton
|
||||
appearance="icon"
|
||||
aria-label="Close task"
|
||||
onClick={onClose}
|
||||
style={{ marginLeft: 6, flexShrink: 0 }}
|
||||
aria-label="Close task">
|
||||
style={{ marginLeft: 6, flexShrink: 0 }}>
|
||||
<span className="codicon codicon-close"></span>
|
||||
</VSCodeButton>
|
||||
</div>
|
||||
@@ -372,14 +372,14 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
onClick={() => setIsTextExpanded(!isTextExpanded)}
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
color: "var(--vscode-textLink-foreground)",
|
||||
paddingRight: 0,
|
||||
paddingLeft: 3,
|
||||
backgroundColor: "var(--vscode-badge-background)",
|
||||
}}
|
||||
onClick={() => setIsTextExpanded(!isTextExpanded)}>
|
||||
}}>
|
||||
See more
|
||||
</div>
|
||||
</div>
|
||||
@@ -387,19 +387,19 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
</div>
|
||||
{isTextExpanded && showSeeMore && (
|
||||
<div
|
||||
onClick={() => setIsTextExpanded(!isTextExpanded)}
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
color: "var(--vscode-textLink-foreground)",
|
||||
marginLeft: "auto",
|
||||
textAlign: "right",
|
||||
paddingRight: 2,
|
||||
}}
|
||||
onClick={() => setIsTextExpanded(!isTextExpanded)}>
|
||||
}}>
|
||||
See less
|
||||
</div>
|
||||
)}
|
||||
{((task.images && task.images.length > 0) || (task.files && task.files.length > 0)) && (
|
||||
<Thumbnails images={task.images ?? []} files={task.files ?? []} />
|
||||
<Thumbnails files={task.files ?? []} images={task.images ?? []} />
|
||||
)}
|
||||
|
||||
<div
|
||||
@@ -457,8 +457,8 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
{IS_DEV === '"true"' && <OpenDiskTaskHistoryButton taskId={currentTaskItem?.id} />}
|
||||
<CopyTaskButton taskText={task.text} />
|
||||
<DeleteTaskButton
|
||||
taskSize={formatSize(currentTaskItem?.size)}
|
||||
taskId={currentTaskItem?.id}
|
||||
taskSize={formatSize(currentTaskItem?.size)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -516,8 +516,8 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
{IS_DEV === '"true"' && <OpenDiskTaskHistoryButton taskId={currentTaskItem?.id} />}
|
||||
<CopyTaskButton taskText={task.text} />
|
||||
<DeleteTaskButton
|
||||
taskSize={formatSize(currentTaskItem?.size)}
|
||||
taskId={currentTaskItem?.id}
|
||||
taskSize={formatSize(currentTaskItem?.size)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -537,6 +537,14 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
return (
|
||||
<div
|
||||
onClick={() => setIsTodoExpanded(!isTodoExpanded)}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor =
|
||||
"color-mix(in srgb, var(--vscode-charts-green) 25%, transparent)"
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor =
|
||||
"color-mix(in srgb, var(--vscode-charts-green) 15%, transparent)"
|
||||
}}
|
||||
style={{
|
||||
marginTop: "6px",
|
||||
padding: "8px 12px",
|
||||
@@ -547,14 +555,6 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
cursor: "pointer",
|
||||
transition: "background-color 0.2s ease",
|
||||
border: "1px solid color-mix(in srgb, var(--vscode-charts-green) 30%, transparent)",
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.backgroundColor =
|
||||
"color-mix(in srgb, var(--vscode-charts-green) 25%, transparent)"
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.backgroundColor =
|
||||
"color-mix(in srgb, var(--vscode-charts-green) 15%, transparent)"
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
@@ -759,6 +759,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
{checkpointTrackerErrorMessage.endsWith("disabling checkpoints.") && (
|
||||
<>
|
||||
<button
|
||||
className="underline cursor-pointer bg-transparent border-0 p-0 text-inherit font-inherit"
|
||||
onClick={() => {
|
||||
// First open the settings panel using direct navigation
|
||||
navigateToSettings()
|
||||
@@ -773,8 +774,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
console.error("Error scrolling to checkpoint settings:", error)
|
||||
}
|
||||
}, 300)
|
||||
}}
|
||||
className="underline cursor-pointer bg-transparent border-0 p-0 text-inherit font-inherit">
|
||||
}}>
|
||||
disabling checkpoints.
|
||||
</button>
|
||||
</>
|
||||
@@ -825,7 +825,7 @@ const highlightSlashCommands = (text: string, withShadow = true) => {
|
||||
|
||||
return [
|
||||
beforeCommand,
|
||||
<span key="slashCommand" className={withShadow ? "mention-context-highlight-with-shadow" : "mention-context-highlight"}>
|
||||
<span className={withShadow ? "mention-context-highlight-with-shadow" : "mention-context-highlight"} key="slashCommand">
|
||||
/{commandName}
|
||||
</span>,
|
||||
afterCommand,
|
||||
@@ -846,10 +846,10 @@ export const highlightMentions = (text: string, withShadow = true) => {
|
||||
// This is a mention
|
||||
return (
|
||||
<span
|
||||
key={index}
|
||||
className={withShadow ? "mention-context-highlight-with-shadow" : "mention-context-highlight"}
|
||||
style={{ cursor: "pointer" }}
|
||||
onClick={() => FileServiceClient.openMention(StringRequest.create({ value: part }))}>
|
||||
key={index}
|
||||
onClick={() => FileServiceClient.openMention(StringRequest.create({ value: part }))}
|
||||
style={{ cursor: "pointer" }}>
|
||||
@{part}
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React, { useMemo, useState, useRef, useEffect, useCallback } from "react"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
import { ClineMessage } from "@shared/ExtensionMessage"
|
||||
import { combineApiRequests } from "@shared/combineApiRequests"
|
||||
import { combineCommandSequences } from "@shared/combineCommandSequences"
|
||||
import { ClineMessage } from "@shared/ExtensionMessage"
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
import { COLOR_BEIGE, COLOR_BLUE, COLOR_DARK_GRAY, COLOR_GRAY, COLOR_GREEN, COLOR_PURPLE, COLOR_WHITE } from "../colors"
|
||||
import TaskTimelineTooltip from "./TaskTimelineTooltip"
|
||||
import { getColor } from "./util"
|
||||
import { COLOR_WHITE, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_BEIGE, COLOR_BLUE, COLOR_PURPLE, COLOR_GREEN } from "../colors"
|
||||
|
||||
// Timeline dimensions and spacing
|
||||
const TIMELINE_HEIGHT = "13px"
|
||||
@@ -186,18 +186,18 @@ const TaskTimeline: React.FC<TaskTimelineProps> = ({ messages, onBlockClick }) =
|
||||
</style>
|
||||
|
||||
<Virtuoso
|
||||
ref={virtuosoRef}
|
||||
className="timeline-virtuoso"
|
||||
fixedItemHeight={itemWidth}
|
||||
horizontalDirection={true}
|
||||
increaseViewportBy={12}
|
||||
itemContent={TimelineBlock}
|
||||
ref={virtuosoRef}
|
||||
style={{
|
||||
height: TIMELINE_HEIGHT,
|
||||
width: "100%",
|
||||
//overflowY: "hidden",
|
||||
}}
|
||||
totalCount={Math.max(1, taskTimelinePropsMessages.length)}
|
||||
itemContent={TimelineBlock}
|
||||
horizontalDirection={true}
|
||||
increaseViewportBy={12}
|
||||
fixedItemHeight={itemWidth}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useState, useCallback } from "react"
|
||||
import { parseFocusChainItem } from "@shared/focus-chain-utils"
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react"
|
||||
|
||||
interface ChecklistRendererProps {
|
||||
text: string
|
||||
@@ -90,8 +90,8 @@ const ChecklistRenderer: React.FC<ChecklistRendererProps> = ({ text }) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
onScroll={handleScroll}
|
||||
ref={containerRef}
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
|
||||
import { useState, useCallback, useEffect } from "react"
|
||||
import { useInterval } from "react-use"
|
||||
import { DebouncedTextField } from "../common/DebouncedTextField"
|
||||
import { ApiKeyField } from "../common/ApiKeyField"
|
||||
import { ModelsServiceClient } from "@/services/grpc-client"
|
||||
import { StringRequest } from "@shared/proto/cline/common"
|
||||
import OllamaModelPicker from "../OllamaModelPicker"
|
||||
import { BaseUrlField } from "../common/BaseUrlField"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers"
|
||||
import { getModeSpecificFields } from "../utils/providerUtils"
|
||||
import { Mode } from "@shared/storage/types"
|
||||
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { useInterval } from "react-use"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { ModelsServiceClient } from "@/services/grpc-client"
|
||||
import { ApiKeyField } from "../common/ApiKeyField"
|
||||
import { BaseUrlField } from "../common/BaseUrlField"
|
||||
import { DebouncedTextField } from "../common/DebouncedTextField"
|
||||
import OllamaModelPicker from "../OllamaModelPicker"
|
||||
import { getModeSpecificFields } from "../utils/providerUtils"
|
||||
import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers"
|
||||
|
||||
/**
|
||||
* Props for the OllamaProvider component
|
||||
*/
|
||||
@@ -58,18 +59,18 @@ export const OllamaProvider = ({ showModelOptions, isPopup, currentMode }: Ollam
|
||||
<div>
|
||||
<BaseUrlField
|
||||
initialValue={apiConfiguration?.ollamaBaseUrl}
|
||||
label="Use custom base URL"
|
||||
onChange={(value) => handleFieldChange("ollamaBaseUrl", value)}
|
||||
placeholder="Default: http://localhost:11434"
|
||||
label="Use custom base URL"
|
||||
/>
|
||||
|
||||
{apiConfiguration?.ollamaBaseUrl && (
|
||||
<ApiKeyField
|
||||
helpText="Optional API key for authenticated Ollama instances or cloud services. Leave empty for local installations."
|
||||
initialValue={apiConfiguration?.ollamaApiKey || ""}
|
||||
onChange={(value) => handleFieldChange("ollamaApiKey", value)}
|
||||
providerName="Ollama"
|
||||
placeholder="Enter API Key (optional)..."
|
||||
helpText="Optional API key for authenticated Ollama instances or cloud services. Leave empty for local installations."
|
||||
providerName="Ollama"
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -79,11 +80,11 @@ export const OllamaProvider = ({ showModelOptions, isPopup, currentMode }: Ollam
|
||||
</label>
|
||||
<OllamaModelPicker
|
||||
ollamaModels={ollamaModels}
|
||||
selectedModelId={ollamaModelId || ""}
|
||||
onModelChange={(modelId) => {
|
||||
handleModeFieldChange({ plan: "planModeOllamaModelId", act: "actModeOllamaModelId" }, modelId, currentMode)
|
||||
}}
|
||||
placeholder={ollamaModels.length > 0 ? "Search and select a model..." : "e.g. llama3.1"}
|
||||
selectedModelId={ollamaModelId || ""}
|
||||
/>
|
||||
|
||||
{/* Show status message based on model availability */}
|
||||
@@ -103,8 +104,8 @@ export const OllamaProvider = ({ showModelOptions, isPopup, currentMode }: Ollam
|
||||
<DebouncedTextField
|
||||
initialValue={apiConfiguration?.ollamaApiOptionsCtxNum || "32768"}
|
||||
onChange={(v) => handleFieldChange("ollamaApiOptionsCtxNum", v || undefined)}
|
||||
style={{ width: "100%" }}
|
||||
placeholder={"e.g. 32768"}>
|
||||
placeholder={"e.g. 32768"}
|
||||
style={{ width: "100%" }}>
|
||||
<span style={{ fontWeight: 500 }}>Model Context Window</span>
|
||||
</DebouncedTextField>
|
||||
|
||||
@@ -119,8 +120,8 @@ export const OllamaProvider = ({ showModelOptions, isPopup, currentMode }: Ollam
|
||||
handleFieldChange("requestTimeoutMs", numValue)
|
||||
}
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
placeholder="Default: 30000 (30 seconds)">
|
||||
placeholder="Default: 30000 (30 seconds)"
|
||||
style={{ width: "100%" }}>
|
||||
<span style={{ fontWeight: 500 }}>Request Timeout (ms)</span>
|
||||
</DebouncedTextField>
|
||||
<p style={{ fontSize: "12px", marginTop: 3, color: "var(--vscode-descriptionForeground)" }}>
|
||||
|
||||
Reference in new issue
Block a user