diff --git a/apps/kilocode-docs/docs/basic-usage/adding-credits.md b/apps/kilocode-docs/docs/basic-usage/adding-credits.md index 2d4784e0eae..0bdab83d423 100644 --- a/apps/kilocode-docs/docs/basic-usage/adding-credits.md +++ b/apps/kilocode-docs/docs/basic-usage/adding-credits.md @@ -8,9 +8,9 @@ Once you've used any initial free Kilo Credits, you can easily add more: - Purchase additional credits as a one-time transaction. - Enable automatic top-up, which purchases additional credits when your balance is below $5. -These options are available to purchase from your [personal profile page](https://app.kilo.ai). +These options are available to purchase from your [personal profile page](https://app.kilo.ai). -You can also use subscriptions or credits you may have purchased directly with an AI provider by adding your keys on the [Bring your own Key (BYOK)](https://app.kilo.ai/byok) settings screen. If your provider is not yet supported, you can also [directly connect your provider](/getting-started/connecting-api-provider.md) in the extension and CLI. +You can also use subscriptions or credits you may have purchased directly with an AI provider by adding your keys on the [Bring your own Key (BYOK)](https://app.kilo.ai/byok) settings screen. If your provider is not yet supported, you can also [directly connect your provider](/getting-started/connecting-api-provider.md) in the extension and CLI. ## Transparent Pricing diff --git a/cli/package.json b/cli/package.json index 81658521249..4afcb3f8ca1 100644 --- a/cli/package.json +++ b/cli/package.json @@ -43,6 +43,7 @@ "@modelcontextprotocol/sdk": "^1.25.2", "@qdrant/js-client-rest": "^1.16.2", "@roo-code/cloud": "workspace:^", + "@kilocode/core-schemas": "workspace:^", "@roo-code/telemetry": "workspace:^", "@roo-code/types": "workspace:^", "@vscode/codicons": "^0.0.44", diff --git a/cli/src/auth/types.ts b/cli/src/auth/types.ts index 52888c15ce4..69aa9f88b61 100644 --- a/cli/src/auth/types.ts +++ b/cli/src/auth/types.ts @@ -1,5 +1,27 @@ +/** + * Authentication Types + * + * Re-exports types from @kilocode/core-schemas for runtime validation + * and backward compatibility with existing code. + */ + import type { ProviderConfig } from "../config/types.js" +// Re-export Kilocode schemas from core-schemas +export { kilocodeOrganizationSchema, kilocodeProfileDataSchema } from "@kilocode/core-schemas" + +// Re-export Kilocode types from core-schemas +export type { KilocodeOrganization, KilocodeProfileData } from "@kilocode/core-schemas" + +// Device auth (from @roo-code/types via core-schemas) +export { + DeviceAuthInitiateResponseSchema, + DeviceAuthPollResponseSchema, + type DeviceAuthInitiateResponse, + type DeviceAuthPollResponse, + type DeviceAuthState, +} from "@kilocode/core-schemas" + /** * Result of a successful authentication flow */ @@ -20,50 +42,15 @@ export interface AuthProvider { } /** - * Device authorization response from initiate endpoint - */ -export interface DeviceAuthInitiateResponse { - /** Verification code to display to user */ - code: string - /** URL for user to visit in browser */ - verificationUrl: string - /** Time in seconds until code expires */ - expiresIn: number -} - -/** - * Device authorization poll response - */ -export interface DeviceAuthPollResponse { - /** Current status of the authorization */ - status: "pending" | "approved" | "denied" | "expired" - /** API token (only present when approved) */ - token?: string - /** User ID (only present when approved) */ - userId?: string - /** User email (only present when approved) */ - userEmail?: string -} - -/** - * Organization data from Kilocode API - */ -export interface KilocodeOrganization { - id: string - name: string - role: string -} - -/** - * Profile data structure from Kilocode API + * Result of a poll operation */ -export interface KilocodeProfileData { - user?: { - name?: string - email?: string - image?: string - } - organizations?: KilocodeOrganization[] +export interface PollResult { + /** Whether polling should continue */ + continue: boolean + /** Optional data returned when polling completes */ + data?: unknown + /** Optional error if polling failed */ + error?: Error } /** @@ -79,15 +66,3 @@ export interface PollingOptions { /** Optional callback for progress updates */ onProgress?: (attempt: number, maxAttempts: number) => void } - -/** - * Result of a poll operation - */ -export interface PollResult { - /** Whether polling should continue */ - continue: boolean - /** Optional data returned when polling completes */ - data?: unknown - /** Optional error if polling failed */ - error?: Error -} diff --git a/cli/src/config/types.ts b/cli/src/config/types.ts index 93b9207acf4..849caa1f63d 100644 --- a/cli/src/config/types.ts +++ b/cli/src/config/types.ts @@ -1,501 +1,142 @@ -import type { ThemeId, Theme } from "../types/theme.js" - /** - * Auto approval configuration for read operations + * CLI Configuration Types + * + * Re-exports types from @kilocode/core-schemas for runtime validation + * and backward compatibility with existing code. */ -export interface AutoApprovalReadConfig { - enabled?: boolean - outside?: boolean -} -/** - * Auto approval configuration for write operations - */ -export interface AutoApprovalWriteConfig { - enabled?: boolean - outside?: boolean - protected?: boolean -} +import type { ProviderConfig as CoreProviderConfig, CLIConfig as CoreCLIConfig } from "@kilocode/core-schemas" -/** - * Auto approval configuration for browser operations - */ -export interface AutoApprovalBrowserConfig { - enabled?: boolean -} +// ProviderConfig with index signature for dynamic property access (backward compatibility) +export type ProviderConfig = CoreProviderConfig & { [key: string]: unknown } -/** - * Auto approval configuration for retry operations - */ -export interface AutoApprovalRetryConfig { - enabled?: boolean - delay?: number -} - -/** - * Auto approval configuration for MCP operations - */ -export interface AutoApprovalMcpConfig { - enabled?: boolean -} - -/** - * Auto approval configuration for mode switching - */ -export interface AutoApprovalModeConfig { - enabled?: boolean -} - -/** - * Auto approval configuration for subtasks - */ -export interface AutoApprovalSubtasksConfig { - enabled?: boolean -} - -/** - * Auto approval configuration for command execution - */ -export interface AutoApprovalExecuteConfig { - enabled?: boolean - allowed?: string[] - denied?: string[] -} - -/** - * Auto approval configuration for followup questions - */ -export interface AutoApprovalQuestionConfig { - enabled?: boolean - timeout?: number -} - -/** - * Auto approval configuration for todo list updates - */ -export interface AutoApprovalTodoConfig { - enabled?: boolean -} - -/** - * Complete auto approval configuration - */ -export interface AutoApprovalConfig { - enabled?: boolean - read?: AutoApprovalReadConfig - write?: AutoApprovalWriteConfig - browser?: AutoApprovalBrowserConfig - retry?: AutoApprovalRetryConfig - mcp?: AutoApprovalMcpConfig - mode?: AutoApprovalModeConfig - subtasks?: AutoApprovalSubtasksConfig - execute?: AutoApprovalExecuteConfig - question?: AutoApprovalQuestionConfig - todo?: AutoApprovalTodoConfig -} - -export interface CLIConfig { - version: "1.0.0" - mode: string - telemetry: boolean - provider: string +// CLIConfig with our enhanced ProviderConfig type +export interface CLIConfig extends Omit { providers: ProviderConfig[] - autoApproval?: AutoApprovalConfig - theme?: ThemeId - customThemes?: Record -} - -// Base provider config with common fields -interface BaseProviderConfig { - id: string - [key: string]: unknown // Allow additional fields for flexibility -} - -// Provider-specific configurations with discriminated unions -type KilocodeProviderConfig = BaseProviderConfig & { - provider: "kilocode" - kilocodeModel?: string - kilocodeToken?: string - kilocodeOrganizationId?: string - openRouterSpecificProvider?: string - openRouterProviderDataCollection?: "allow" | "deny" - openRouterProviderSort?: "price" | "throughput" | "latency" - openRouterZdr?: boolean - kilocodeTesterWarningsDisabledUntil?: number -} - -type AnthropicProviderConfig = BaseProviderConfig & { - provider: "anthropic" - apiModelId?: string - apiKey?: string - anthropicBaseUrl?: string - anthropicUseAuthToken?: boolean - anthropicBeta1MContext?: boolean -} - -type OpenAINativeProviderConfig = BaseProviderConfig & { - provider: "openai-native" - apiModelId?: string - openAiNativeApiKey?: string - openAiNativeBaseUrl?: string - openAiNativeServiceTier?: "auto" | "default" | "flex" | "priority" -} - -type OpenAIProviderConfig = BaseProviderConfig & { - provider: "openai" - openAiModelId?: string - openAiBaseUrl?: string - openAiApiKey?: string - openAiLegacyFormat?: boolean - openAiR1FormatEnabled?: boolean - openAiUseAzure?: boolean - azureApiVersion?: string - openAiStreamingEnabled?: boolean - openAiHeaders?: Record -} - -type OpenRouterProviderConfig = BaseProviderConfig & { - provider: "openrouter" - openRouterModelId?: string - openRouterApiKey?: string - openRouterBaseUrl?: string - openRouterSpecificProvider?: string - openRouterUseMiddleOutTransform?: boolean - openRouterProviderDataCollection?: "allow" | "deny" - openRouterProviderSort?: "price" | "throughput" | "latency" - openRouterZdr?: boolean -} - -type OllamaProviderConfig = BaseProviderConfig & { - provider: "ollama" - ollamaModelId?: string - ollamaBaseUrl?: string - ollamaApiKey?: string - ollamaNumCtx?: number -} - -type LMStudioProviderConfig = BaseProviderConfig & { - provider: "lmstudio" - lmStudioModelId?: string - lmStudioBaseUrl?: string - lmStudioDraftModelId?: string - lmStudioSpeculativeDecodingEnabled?: boolean -} - -type GlamaProviderConfig = BaseProviderConfig & { - provider: "glama" - glamaModelId?: string - glamaApiKey?: string -} - -type LiteLLMProviderConfig = BaseProviderConfig & { - provider: "litellm" - litellmModelId?: string - litellmBaseUrl?: string - litellmApiKey?: string - litellmUsePromptCache?: boolean -} - -type DeepInfraProviderConfig = BaseProviderConfig & { - provider: "deepinfra" - deepInfraModelId?: string - deepInfraBaseUrl?: string - deepInfraApiKey?: string -} - -type UnboundProviderConfig = BaseProviderConfig & { - provider: "unbound" - unboundModelId?: string - unboundApiKey?: string -} - -type RequestyProviderConfig = BaseProviderConfig & { - provider: "requesty" - requestyModelId?: string - requestyBaseUrl?: string - requestyApiKey?: string -} - -type VercelAiGatewayProviderConfig = BaseProviderConfig & { - provider: "vercel-ai-gateway" - vercelAiGatewayModelId?: string - vercelAiGatewayApiKey?: string -} - -type IOIntelligenceProviderConfig = BaseProviderConfig & { - provider: "io-intelligence" - ioIntelligenceModelId?: string - ioIntelligenceApiKey?: string -} - -type OVHCloudProviderConfig = BaseProviderConfig & { - provider: "ovhcloud" - ovhCloudAiEndpointsModelId?: string - ovhCloudAiEndpointsApiKey?: string - ovhCloudAiEndpointsBaseUrl?: string -} - -type InceptionProviderConfig = BaseProviderConfig & { - provider: "inception" - inceptionLabsModelId?: string - inceptionLabsBaseUrl?: string - inceptionLabsApiKey?: string -} - -type BedrockProviderConfig = BaseProviderConfig & { - provider: "bedrock" - apiModelId?: string - awsAccessKey?: string - awsSecretKey?: string - awsSessionToken?: string - awsRegion?: string - awsUseCrossRegionInference?: boolean - awsUsePromptCache?: boolean - awsProfile?: string - awsUseProfile?: boolean - awsApiKey?: string - awsUseApiKey?: boolean - awsCustomArn?: string - awsModelContextWindow?: number - awsBedrockEndpointEnabled?: boolean - awsBedrockEndpoint?: string - awsBedrock1MContext?: boolean -} - -type VertexProviderConfig = BaseProviderConfig & { - provider: "vertex" - apiModelId?: string - vertexKeyFile?: string - vertexJsonCredentials?: string - vertexProjectId?: string - vertexRegion?: string - enableUrlContext?: boolean - enableGrounding?: boolean -} - -type GeminiProviderConfig = BaseProviderConfig & { - provider: "gemini" - apiModelId?: string - geminiApiKey?: string - googleGeminiBaseUrl?: string - enableUrlContext?: boolean - enableGrounding?: boolean -} - -type GeminiCliProviderConfig = BaseProviderConfig & { - provider: "gemini-cli" - apiModelId?: string - geminiCliOAuthPath?: string - geminiCliProjectId?: string -} - -type MistralProviderConfig = BaseProviderConfig & { - provider: "mistral" - apiModelId?: string - mistralApiKey?: string - mistralCodestralUrl?: string -} - -type MoonshotProviderConfig = BaseProviderConfig & { - provider: "moonshot" - apiModelId?: string - moonshotBaseUrl?: string - moonshotApiKey?: string -} - -type MinimaxProviderConfig = BaseProviderConfig & { - provider: "minimax" - apiModelId?: string - minimaxBaseUrl?: string - minimaxApiKey?: string -} - -type DeepSeekProviderConfig = BaseProviderConfig & { - provider: "deepseek" - apiModelId?: string - deepSeekBaseUrl?: string - deepSeekApiKey?: string -} - -type DoubaoProviderConfig = BaseProviderConfig & { - provider: "doubao" - apiModelId?: string - doubaoBaseUrl?: string - doubaoApiKey?: string -} - -type QwenCodeProviderConfig = BaseProviderConfig & { - provider: "qwen-code" - apiModelId?: string - qwenCodeOauthPath?: string -} - -type XAIProviderConfig = BaseProviderConfig & { - provider: "xai" - apiModelId?: string - xaiApiKey?: string -} - -type GroqProviderConfig = BaseProviderConfig & { - provider: "groq" - apiModelId?: string - groqApiKey?: string } -type ChutesProviderConfig = BaseProviderConfig & { - provider: "chutes" - apiModelId?: string - chutesApiKey?: string -} - -type CerebrasProviderConfig = BaseProviderConfig & { - provider: "cerebras" - apiModelId?: string - cerebrasApiKey?: string -} - -type SambaNovaProviderConfig = BaseProviderConfig & { - provider: "sambanova" - apiModelId?: string - sambaNovaApiKey?: string -} - -type ZAIProviderConfig = BaseProviderConfig & { - provider: "zai" - apiModelId?: string - zaiApiKey?: string - zaiApiLine?: "international_coding" | "china_coding" -} - -type FireworksProviderConfig = BaseProviderConfig & { - provider: "fireworks" - apiModelId?: string - fireworksApiKey?: string -} - -type FeatherlessProviderConfig = BaseProviderConfig & { - provider: "featherless" - apiModelId?: string - featherlessApiKey?: string -} - -type RooProviderConfig = BaseProviderConfig & { - provider: "roo" - apiModelId?: string -} - -type ClaudeCodeProviderConfig = BaseProviderConfig & { - provider: "claude-code" - apiModelId?: string - claudeCodePath?: string - claudeCodeMaxOutputTokens?: number -} - -type VSCodeLMProviderConfig = BaseProviderConfig & { - provider: "vscode-lm" - vsCodeLmModelSelector?: { - vendor?: string - family?: string - version?: string - id?: string - } -} - -type HuggingFaceProviderConfig = BaseProviderConfig & { - provider: "huggingface" - huggingFaceModelId?: string - huggingFaceApiKey?: string - huggingFaceInferenceProvider?: string -} - -type SyntheticProviderConfig = BaseProviderConfig & { - provider: "synthetic" - apiModelId?: string - syntheticApiKey?: string -} - -type VirtualQuotaFallbackProviderConfig = BaseProviderConfig & { - provider: "virtual-quota-fallback" - profiles?: Array<{ - profileName?: string - profileId?: string - profileLimits?: { - tokensPerMinute?: number - tokensPerHour?: number - tokensPerDay?: number - requestsPerMinute?: number - requestsPerHour?: number - requestsPerDay?: number - } - }> -} - -type HumanRelayProviderConfig = BaseProviderConfig & { - provider: "human-relay" - // No model ID field -} - -type FakeAIProviderConfig = BaseProviderConfig & { - provider: "fake-ai" - fakeAi?: unknown -} - -// Discriminated union of all provider configs -export type ProviderConfig = - | KilocodeProviderConfig - | AnthropicProviderConfig - | OpenAINativeProviderConfig - | OpenAIProviderConfig - | OpenRouterProviderConfig - | OllamaProviderConfig - | LMStudioProviderConfig - | GlamaProviderConfig - | LiteLLMProviderConfig - | DeepInfraProviderConfig - | UnboundProviderConfig - | RequestyProviderConfig - | VercelAiGatewayProviderConfig - | IOIntelligenceProviderConfig - | OVHCloudProviderConfig - | InceptionProviderConfig - | BedrockProviderConfig - | VertexProviderConfig - | GeminiProviderConfig - | GeminiCliProviderConfig - | MistralProviderConfig - | MoonshotProviderConfig - | MinimaxProviderConfig - | DeepSeekProviderConfig - | DoubaoProviderConfig - | QwenCodeProviderConfig - | XAIProviderConfig - | GroqProviderConfig - | ChutesProviderConfig - | CerebrasProviderConfig - | SambaNovaProviderConfig - | ZAIProviderConfig - | FireworksProviderConfig - | FeatherlessProviderConfig - | RooProviderConfig - | ClaudeCodeProviderConfig - | VSCodeLMProviderConfig - | HuggingFaceProviderConfig - | SyntheticProviderConfig - | VirtualQuotaFallbackProviderConfig - | HumanRelayProviderConfig - | FakeAIProviderConfig - -// Type guards -export function isValidConfig(config: unknown): config is CLIConfig { - return ( - typeof config === "object" && - config !== null && - "version" in config && - "provider" in config && - "providers" in config - ) -} - -export function isProviderConfig(provider: unknown): provider is ProviderConfig { - return typeof provider === "object" && provider !== null && "id" in provider && "provider" in provider -} +// Re-export all config types from core-schemas +export { + // Provider schemas + providerConfigSchema, + kilocodeProviderSchema, + anthropicProviderSchema, + openAINativeProviderSchema, + openAIProviderSchema, + openRouterProviderSchema, + ollamaProviderSchema, + lmStudioProviderSchema, + glamaProviderSchema, + liteLLMProviderSchema, + deepInfraProviderSchema, + unboundProviderSchema, + requestyProviderSchema, + vercelAiGatewayProviderSchema, + ioIntelligenceProviderSchema, + ovhCloudProviderSchema, + inceptionProviderSchema, + bedrockProviderSchema, + vertexProviderSchema, + geminiProviderSchema, + geminiCliProviderSchema, + mistralProviderSchema, + moonshotProviderSchema, + minimaxProviderSchema, + deepSeekProviderSchema, + doubaoProviderSchema, + qwenCodeProviderSchema, + xaiProviderSchema, + groqProviderSchema, + chutesProviderSchema, + cerebrasProviderSchema, + sambaNovaProviderSchema, + zaiProviderSchema, + fireworksProviderSchema, + featherlessProviderSchema, + rooProviderSchema, + claudeCodeProviderSchema, + vsCodeLMProviderSchema, + huggingFaceProviderSchema, + syntheticProviderSchema, + virtualQuotaFallbackProviderSchema, + humanRelayProviderSchema, + fakeAIProviderSchema, + // Provider types (ProviderConfig and CLIConfig are defined locally with index signature) + type KilocodeProviderConfig, + type AnthropicProviderConfig, + type OpenAINativeProviderConfig, + type OpenAIProviderConfig, + type OpenRouterProviderConfig, + type OllamaProviderConfig, + type LMStudioProviderConfig, + type GlamaProviderConfig, + type LiteLLMProviderConfig, + type DeepInfraProviderConfig, + type UnboundProviderConfig, + type RequestyProviderConfig, + type VercelAiGatewayProviderConfig, + type IOIntelligenceProviderConfig, + type OVHCloudProviderConfig, + type InceptionProviderConfig, + type BedrockProviderConfig, + type VertexProviderConfig, + type GeminiProviderConfig, + type GeminiCliProviderConfig, + type MistralProviderConfig, + type MoonshotProviderConfig, + type MinimaxProviderConfig, + type DeepSeekProviderConfig, + type DoubaoProviderConfig, + type QwenCodeProviderConfig, + type XAIProviderConfig, + type GroqProviderConfig, + type ChutesProviderConfig, + type CerebrasProviderConfig, + type SambaNovaProviderConfig, + type ZAIProviderConfig, + type FireworksProviderConfig, + type FeatherlessProviderConfig, + type RooProviderConfig, + type ClaudeCodeProviderConfig, + type VSCodeLMProviderConfig, + type HuggingFaceProviderConfig, + type SyntheticProviderConfig, + type VirtualQuotaFallbackProviderConfig, + type HumanRelayProviderConfig, + type FakeAIProviderConfig, + // Type guard + isProviderConfig, + // Auto-approval schemas + autoApprovalConfigSchema, + autoApprovalReadSchema, + autoApprovalWriteSchema, + autoApprovalBrowserSchema, + autoApprovalRetrySchema, + autoApprovalMcpSchema, + autoApprovalModeSchema, + autoApprovalSubtasksSchema, + autoApprovalExecuteSchema, + autoApprovalQuestionSchema, + autoApprovalTodoSchema, + // Auto-approval types + type AutoApprovalConfig, + type AutoApprovalReadConfig, + type AutoApprovalWriteConfig, + type AutoApprovalBrowserConfig, + type AutoApprovalRetryConfig, + type AutoApprovalMcpConfig, + type AutoApprovalModeConfig, + type AutoApprovalSubtasksConfig, + type AutoApprovalExecuteConfig, + type AutoApprovalQuestionConfig, + type AutoApprovalTodoConfig, + // CLI config schema (CLIConfig type is defined locally) + cliConfigSchema, + isValidConfig, + // ValidationResult is defined in validation.ts, not re-exported here to avoid conflict + // History + historyEntrySchema, + historyDataSchema, + type HistoryEntry, + type HistoryData, +} from "@kilocode/core-schemas" diff --git a/cli/src/types/cli.ts b/cli/src/types/cli.ts index 016a6b6508c..bea7a0b1153 100644 --- a/cli/src/types/cli.ts +++ b/cli/src/types/cli.ts @@ -1,30 +1,20 @@ -import type { ModeConfig } from "./messages.js" +/** + * CLI Types + * + * Re-exports types from @kilocode/core-schemas for runtime validation + * and backward compatibility with existing code. + */ -export interface WelcomeMessageOptions { - // Clear viewport before showing the message - clearScreen?: boolean - // Display options - showInstructions?: boolean - // Content customization - instructions?: string[] // Custom instruction lines - // Parallel mode branch name - worktreeBranch?: string | undefined - // Workspace directory - workspace?: string | undefined -} +import type { ModeConfig } from "@roo-code/types" -export interface CliMessage { - id: string - type: "user" | "assistant" | "system" | "error" | "welcome" | "empty" | "requestCheckpointRestoreApproval" - content: string - ts: number - partial?: boolean | undefined - metadata?: { - welcomeOptions?: WelcomeMessageOptions | undefined - } - payload?: unknown -} +// Re-export schemas from core-schemas +export { welcomeMessageOptionsSchema, cliMessageSchema, cliOptionsSchema } from "@kilocode/core-schemas" + +// Re-export schema-inferred types for simpler cases +export type { WelcomeMessageOptions, CliMessage } from "@kilocode/core-schemas" +// CLIOptions interface with proper typing for ModeConfig +// (The schema uses z.unknown() but we want proper types at compile time) export interface CLIOptions { mode?: string workspace?: string diff --git a/cli/src/types/keyboard.ts b/cli/src/types/keyboard.ts index cb07ad37d91..001a567ccc0 100644 --- a/cli/src/types/keyboard.ts +++ b/cli/src/types/keyboard.ts @@ -1,49 +1,19 @@ /** - * Key event types and interfaces for the keyboard system + * Keyboard Types + * + * Re-exports types from @kilocode/core-schemas for runtime validation + * and backward compatibility with existing code. */ -/** - * Represents a parsed key event with all relevant information - */ -export interface Key { - /** Key name (e.g., 'a', 'return', 'escape', 'up', 'down') */ - name: string - /** Whether Ctrl modifier is pressed */ - ctrl: boolean - /** Whether Alt/Meta modifier is pressed */ - meta: boolean - /** Whether Shift modifier is pressed */ - shift: boolean - /** Whether this is a paste event containing multiple characters */ - paste: boolean - /** Raw key sequence as received from terminal */ - sequence: string - /** Whether this was parsed using Kitty keyboard protocol */ - kittyProtocol?: boolean -} - -/** - * Represents a key object from Node's readline keypress event - */ -export interface ReadlineKey { - name?: string - sequence: string - ctrl?: boolean - meta?: boolean - shift?: boolean -} - -/** - * Handler function type for key events - */ -export type KeypressHandler = (key: Key) => void - -/** - * Configuration for the KeyboardProvider - */ -export interface KeyboardProviderConfig { - /** Enable debug logging for keystrokes */ - debugKeystrokeLogging?: boolean - /** Custom escape code timeout (ms) */ - escapeCodeTimeout?: number -} +// Re-export all keyboard types from core-schemas +export { + // Schemas + keySchema, + readlineKeySchema, + keyboardProviderConfigSchema, + // Types + type Key, + type ReadlineKey, + type KeyboardProviderConfig, + type KeypressHandler, +} from "@kilocode/core-schemas" diff --git a/cli/src/types/messages.ts b/cli/src/types/messages.ts index 85d82b61225..e8a63f76e15 100644 --- a/cli/src/types/messages.ts +++ b/cli/src/types/messages.ts @@ -42,8 +42,24 @@ export type ExtensionChatMessage = ClineMessage export type { RouterName, ModelInfo, ModelRecord, RouterModels } // ============================================ -// CLI-SPECIFIC TYPES (Keep these) +// CLI-SPECIFIC TYPES from core-schemas // ============================================ +export { + // Extension message schemas + organizationAllowListSchema, + extensionMessageSchema, + extensionStateSchema, + // Extension message types (also exported for backward compat) + type OrganizationAllowList, + type Mode, +} from "@kilocode/core-schemas" + +// ============================================ +// CLI-SPECIFIC TYPES (Interface definitions for complex types +// that require imports from @roo-code/types) +// ============================================ + +// ExtensionMessage interface with proper typing export interface ExtensionMessage { type: string action?: string @@ -55,19 +71,7 @@ export interface ExtensionMessage { [key: string]: unknown } -// Organization Allow List for provider validation -export interface OrganizationAllowList { - allowAll: boolean - providers: Record< - string, - { - allowAll: boolean - models?: string[] - } - > -} - -// CLI-specific ExtensionState +// CLI-specific ExtensionState with proper typing export interface ExtensionState { version: string apiConfiguration: ProviderSettings @@ -85,10 +89,8 @@ export interface ExtensionState { telemetrySetting: string renderContext: "sidebar" | "editor" | "cli" cwd?: string - organizationAllowList?: OrganizationAllowList + organizationAllowList?: import("@kilocode/core-schemas").OrganizationAllowList routerModels?: RouterModels appendSystemPrompt?: string // Custom text to append to system prompt (CLI only) [key: string]: unknown } - -export type Mode = string diff --git a/cli/src/types/theme.ts b/cli/src/types/theme.ts index 6a40b847af0..f3ad6c0c08b 100644 --- a/cli/src/types/theme.ts +++ b/cli/src/types/theme.ts @@ -1,116 +1,18 @@ /** - * Theme type definitions for Kilo Code CLI + * Theme Types * - * Defines the structure for color themes used throughout the CLI interface. + * Re-exports types from @kilocode/core-schemas for runtime validation + * and backward compatibility with existing code. */ -/** - * Theme type for categorization - */ -export type ThemeType = "dark" | "light" | "custom" - -/** - * Core theme interface defining all color categories - */ -export interface Theme { - /** Theme identifier */ - id: string - /** Theme display name */ - name: string - /** Theme type for categorization */ - type: ThemeType - - /** Brand identity colors */ - brand: { - primary: string - secondary: string - } - - /** Semantic colors for common states */ - semantic: { - success: string - error: string - warning: string - info: string - neutral: string - } - - /** Interactive element colors */ - interactive: { - prompt: string - selection: string - hover: string - disabled: string - focus: string - } - - /** Message type colors */ - messages: { - user: string - assistant: string - system: string - error: string - } - - /** Action colors (unified approve/reject/cancel patterns) */ - actions: { - approve: string - reject: string - cancel: string - pending: string - } - - /** Code and diff display colors */ - code: { - addition: string - deletion: string - modification: string - context: string - lineNumber: string - } - - /** Markdown rendering colors */ - markdown: { - text: string - heading: string - strong: string - em: string - code: string - blockquote: string - link: string - list: string - } - - /** UI structure colors */ - ui: { - border: { - default: string - active: string - warning: string - error: string - } - text: { - primary: string - secondary: string - dimmed: string - highlight: string - } - background: { - default: string - elevated: string - } - } - - /** Status indicator colors */ - status: { - online: string - offline: string - busy: string - idle: string - } -} - -/** - * Theme identifier type - */ -export type ThemeId = "dark" | "light" | string +// Re-export all theme types from core-schemas +export { + // Schemas + themeTypeSchema, + themeSchema, + themeIdSchema, + // Types + type ThemeType, + type Theme, + type ThemeId, +} from "@kilocode/core-schemas" diff --git a/cli/src/ui/messages/extension/ExtensionMessageRow.tsx b/cli/src/ui/messages/extension/ExtensionMessageRow.tsx index 3e220cd191e..11bf7a64d8c 100644 --- a/cli/src/ui/messages/extension/ExtensionMessageRow.tsx +++ b/cli/src/ui/messages/extension/ExtensionMessageRow.tsx @@ -43,5 +43,9 @@ export const ExtensionMessageRow: React.FC = ({ messag ) } - return <>{content} + return ( + + <>{content} + + ) } diff --git a/packages/core-schemas/eslint.config.mjs b/packages/core-schemas/eslint.config.mjs new file mode 100644 index 00000000000..c603a68f12d --- /dev/null +++ b/packages/core-schemas/eslint.config.mjs @@ -0,0 +1,20 @@ +import { config } from "@roo-code/config-eslint/base" +import globals from "globals" + +/** @type {import("eslint").Linter.Config} */ +export default [ + ...config, + { + files: ["**/*.cjs"], + languageOptions: { + globals: { + ...globals.node, + ...globals.commonjs, + }, + sourceType: "commonjs", + }, + rules: { + "@typescript-eslint/no-require-imports": "off", + }, + }, +] diff --git a/packages/core-schemas/package.json b/packages/core-schemas/package.json new file mode 100644 index 00000000000..de30dfb8e45 --- /dev/null +++ b/packages/core-schemas/package.json @@ -0,0 +1,38 @@ +{ + "name": "@kilocode/core-schemas", + "version": "0.0.0", + "type": "module", + "main": "./dist/index.cjs", + "exports": { + ".": { + "types": "./src/index.ts", + "import": "./src/index.ts", + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, + "scripts": { + "lint": "eslint src --ext=ts --max-warnings=0", + "check-types": "tsc --noEmit", + "test": "vitest run", + "build": "tsup", + "clean": "rimraf dist .turbo" + }, + "dependencies": { + "zod": "^3.25.61" + }, + "peerDependencies": { + "@roo-code/types": "workspace:^" + }, + "devDependencies": { + "@roo-code/config-eslint": "workspace:^", + "@roo-code/config-typescript": "workspace:^", + "@roo-code/types": "workspace:^", + "@types/node": "20.x", + "globals": "^16.3.0", + "tsup": "^8.3.5", + "vitest": "^3.2.3" + } +} diff --git a/packages/core-schemas/src/agent-manager/index.ts b/packages/core-schemas/src/agent-manager/index.ts new file mode 100644 index 00000000000..2d6a0aee31a --- /dev/null +++ b/packages/core-schemas/src/agent-manager/index.ts @@ -0,0 +1,2 @@ +// Agent manager schemas and types +export * from "./types.js" diff --git a/packages/core-schemas/src/agent-manager/types.ts b/packages/core-schemas/src/agent-manager/types.ts new file mode 100644 index 00000000000..60fc385ab36 --- /dev/null +++ b/packages/core-schemas/src/agent-manager/types.ts @@ -0,0 +1,115 @@ +import { z } from "zod" + +/** + * Agent Manager Types + * + * These types are used by the agent-manager in the extension for managing + * CLI sessions and parallel mode worktrees. + */ + +/** + * Agent status schema + */ +export const agentStatusSchema = z.enum(["creating", "running", "done", "error", "stopped"]) + +/** + * Session source schema + */ +export const sessionSourceSchema = z.enum(["local", "remote"]) + +/** + * Parallel mode (worktree) information schema + */ +export const parallelModeInfoSchema = z.object({ + enabled: z.boolean(), + branch: z.string().optional(), // e.g., "add-authentication-1702734891234" + worktreePath: z.string().optional(), // e.g., ".kilocode/worktrees/add-auth..." + parentBranch: z.string().optional(), // e.g., "main" - the branch worktree was created from + completionMessage: z.string().optional(), // Merge instructions from CLI on completion +}) + +/** + * Agent session schema + */ +export const agentSessionSchema = z.object({ + sessionId: z.string(), + label: z.string(), + prompt: z.string(), + status: agentStatusSchema, + startTime: z.number(), + endTime: z.number().optional(), + exitCode: z.number().optional(), + error: z.string().optional(), + logs: z.array(z.string()), + pid: z.number().optional(), + source: sessionSourceSchema, + parallelMode: parallelModeInfoSchema.optional(), + gitUrl: z.string().optional(), +}) + +/** + * Pending session schema (waiting for CLI's session_created event) + */ +export const pendingSessionSchema = z.object({ + prompt: z.string(), + label: z.string(), + startTime: z.number(), + parallelMode: z.boolean().optional(), + gitUrl: z.string().optional(), +}) + +/** + * Agent manager state schema + */ +export const agentManagerStateSchema = z.object({ + sessions: z.array(agentSessionSchema), + selectedId: z.string().nullable(), +}) + +/** + * Messages from Webview to Extension + */ +export const agentManagerMessageSchema = z.discriminatedUnion("type", [ + z.object({ type: z.literal("agentManager.webviewReady") }), + z.object({ + type: z.literal("agentManager.startSession"), + prompt: z.string(), + parallelMode: z.boolean().optional(), + existingBranch: z.string().optional(), + }), + z.object({ type: z.literal("agentManager.stopSession"), sessionId: z.string() }), + z.object({ type: z.literal("agentManager.selectSession"), sessionId: z.string() }), + z.object({ type: z.literal("agentManager.refreshRemoteSessions") }), + z.object({ type: z.literal("agentManager.listBranches") }), +]) + +/** + * Remote session schema (simplified - full type comes from shared session client) + */ +export const remoteSessionSchema = z.object({ + id: z.string(), + name: z.string().optional(), + status: z.string().optional(), +}).passthrough() // Allow additional fields from the full RemoteSession type + +/** + * Messages from Extension to Webview + */ +export const agentManagerExtensionMessageSchema = z.discriminatedUnion("type", [ + z.object({ type: z.literal("agentManager.state"), state: agentManagerStateSchema }), + z.object({ type: z.literal("agentManager.sessionUpdated"), session: agentSessionSchema }), + z.object({ type: z.literal("agentManager.sessionRemoved"), sessionId: z.string() }), + z.object({ type: z.literal("agentManager.error"), error: z.string() }), + z.object({ type: z.literal("agentManager.remoteSessions"), sessions: z.array(remoteSessionSchema) }), + z.object({ type: z.literal("agentManager.branches"), branches: z.array(z.string()), currentBranch: z.string().optional() }), +]) + +// Inferred types +export type AgentStatus = z.infer +export type SessionSource = z.infer +export type ParallelModeInfo = z.infer +export type AgentSession = z.infer +export type PendingSession = z.infer +export type AgentManagerState = z.infer +export type AgentManagerMessage = z.infer +export type AgentManagerExtensionMessage = z.infer diff --git a/packages/core-schemas/src/auth/index.ts b/packages/core-schemas/src/auth/index.ts new file mode 100644 index 00000000000..5059773edd4 --- /dev/null +++ b/packages/core-schemas/src/auth/index.ts @@ -0,0 +1,6 @@ +// Re-export device auth types from @roo-code/types +export type { DeviceAuthInitiateResponse, DeviceAuthPollResponse, DeviceAuthState } from "@roo-code/types" +export { DeviceAuthInitiateResponseSchema, DeviceAuthPollResponseSchema } from "@roo-code/types" + +// Kilocode-specific auth types +export * from "./kilocode.js" diff --git a/packages/core-schemas/src/auth/kilocode.ts b/packages/core-schemas/src/auth/kilocode.ts new file mode 100644 index 00000000000..b53f6563c21 --- /dev/null +++ b/packages/core-schemas/src/auth/kilocode.ts @@ -0,0 +1,76 @@ +import { z } from "zod" +import type { ProviderConfig } from "../config/provider.js" + +/** + * Organization data from Kilocode API + */ +export const kilocodeOrganizationSchema = z.object({ + id: z.string(), + name: z.string(), + role: z.string(), +}) + +/** + * Profile data structure from Kilocode API + */ +export const kilocodeProfileDataSchema = z.object({ + user: z + .object({ + name: z.string().optional(), + email: z.string().optional(), + image: z.string().optional(), + }) + .optional(), + organizations: z.array(kilocodeOrganizationSchema).optional(), +}) + +/** + * Options for polling operations + */ +export const pollingOptionsSchema = z.object({ + /** Interval between polls in milliseconds */ + interval: z.number(), + /** Maximum number of attempts before timeout */ + maxAttempts: z.number(), + /** Function to execute on each poll */ + pollFn: z.function().args().returns(z.promise(z.unknown())), + /** Optional callback for progress updates */ + onProgress: z.function().args(z.number(), z.number()).returns(z.void()).optional(), +}) + +/** + * Result of a poll operation + */ +export const pollResultSchema = z.object({ + /** Whether polling should continue */ + continue: z.boolean(), + /** Optional data returned when polling completes */ + data: z.unknown().optional(), + /** Optional error if polling failed */ + error: z.instanceof(Error).optional(), +}) + +// Inferred types +export type KilocodeOrganization = z.infer +export type KilocodeProfileData = z.infer +export type PollingOptions = z.infer +export type PollResult = z.infer + +/** + * Result of a successful authentication flow + */ +export interface AuthResult { + providerConfig: ProviderConfig +} + +/** + * Base interface for all authentication providers + */ +export interface AuthProvider { + /** Display name shown to users */ + name: string + /** Unique identifier for the provider */ + value: string + /** Execute the authentication flow */ + authenticate(): Promise +} diff --git a/packages/core-schemas/src/config/auto-approval.ts b/packages/core-schemas/src/config/auto-approval.ts new file mode 100644 index 00000000000..657bb874744 --- /dev/null +++ b/packages/core-schemas/src/config/auto-approval.ts @@ -0,0 +1,108 @@ +import { z } from "zod" + +/** + * Auto approval configuration for read operations + */ +export const autoApprovalReadSchema = z.object({ + enabled: z.boolean().optional(), + outside: z.boolean().optional(), +}) + +/** + * Auto approval configuration for write operations + */ +export const autoApprovalWriteSchema = z.object({ + enabled: z.boolean().optional(), + outside: z.boolean().optional(), + protected: z.boolean().optional(), +}) + +/** + * Auto approval configuration for browser operations + */ +export const autoApprovalBrowserSchema = z.object({ + enabled: z.boolean().optional(), +}) + +/** + * Auto approval configuration for retry operations + */ +export const autoApprovalRetrySchema = z.object({ + enabled: z.boolean().optional(), + delay: z.number().optional(), +}) + +/** + * Auto approval configuration for MCP operations + */ +export const autoApprovalMcpSchema = z.object({ + enabled: z.boolean().optional(), +}) + +/** + * Auto approval configuration for mode switching + */ +export const autoApprovalModeSchema = z.object({ + enabled: z.boolean().optional(), +}) + +/** + * Auto approval configuration for subtasks + */ +export const autoApprovalSubtasksSchema = z.object({ + enabled: z.boolean().optional(), +}) + +/** + * Auto approval configuration for command execution + */ +export const autoApprovalExecuteSchema = z.object({ + enabled: z.boolean().optional(), + allowed: z.array(z.string()).optional(), + denied: z.array(z.string()).optional(), +}) + +/** + * Auto approval configuration for followup questions + */ +export const autoApprovalQuestionSchema = z.object({ + enabled: z.boolean().optional(), + timeout: z.number().optional(), +}) + +/** + * Auto approval configuration for todo list updates + */ +export const autoApprovalTodoSchema = z.object({ + enabled: z.boolean().optional(), +}) + +/** + * Complete auto approval configuration + */ +export const autoApprovalConfigSchema = z.object({ + enabled: z.boolean().optional(), + read: autoApprovalReadSchema.optional(), + write: autoApprovalWriteSchema.optional(), + browser: autoApprovalBrowserSchema.optional(), + retry: autoApprovalRetrySchema.optional(), + mcp: autoApprovalMcpSchema.optional(), + mode: autoApprovalModeSchema.optional(), + subtasks: autoApprovalSubtasksSchema.optional(), + execute: autoApprovalExecuteSchema.optional(), + question: autoApprovalQuestionSchema.optional(), + todo: autoApprovalTodoSchema.optional(), +}) + +// Inferred types +export type AutoApprovalReadConfig = z.infer +export type AutoApprovalWriteConfig = z.infer +export type AutoApprovalBrowserConfig = z.infer +export type AutoApprovalRetryConfig = z.infer +export type AutoApprovalMcpConfig = z.infer +export type AutoApprovalModeConfig = z.infer +export type AutoApprovalSubtasksConfig = z.infer +export type AutoApprovalExecuteConfig = z.infer +export type AutoApprovalQuestionConfig = z.infer +export type AutoApprovalTodoConfig = z.infer +export type AutoApprovalConfig = z.infer diff --git a/packages/core-schemas/src/config/cli-config.ts b/packages/core-schemas/src/config/cli-config.ts new file mode 100644 index 00000000000..a0bd38bfe83 --- /dev/null +++ b/packages/core-schemas/src/config/cli-config.ts @@ -0,0 +1,53 @@ +import { z } from "zod" +import { providerConfigSchema } from "./provider.js" +import { autoApprovalConfigSchema } from "./auto-approval.js" +import { themeSchema, themeIdSchema } from "../theme/theme.js" + +/** + * CLI configuration schema + */ +export const cliConfigSchema = z.object({ + version: z.literal("1.0.0"), + mode: z.string(), + telemetry: z.boolean(), + provider: z.string(), + providers: z.array(providerConfigSchema), + autoApproval: autoApprovalConfigSchema.optional(), + theme: themeIdSchema.optional(), + customThemes: z.record(themeSchema).optional(), +}) + +// Inferred type +export type CLIConfig = z.infer + +// Type guard +export function isValidConfig(config: unknown): config is CLIConfig { + return cliConfigSchema.safeParse(config).success +} + +/** + * Validation result structure + */ +export const validationResultSchema = z.object({ + valid: z.boolean(), + errors: z + .array( + z.object({ + path: z.array(z.union([z.string(), z.number()])), + message: z.string(), + }), + ) + .optional(), +}) + +export type ValidationResult = z.infer + +/** + * Config load result structure + */ +export const configLoadResultSchema = z.object({ + config: cliConfigSchema.optional(), + validation: validationResultSchema, +}) + +export type ConfigLoadResult = z.infer diff --git a/packages/core-schemas/src/config/history.ts b/packages/core-schemas/src/config/history.ts new file mode 100644 index 00000000000..428464629e7 --- /dev/null +++ b/packages/core-schemas/src/config/history.ts @@ -0,0 +1,22 @@ +import { z } from "zod" + +/** + * Single history entry + */ +export const historyEntrySchema = z.object({ + prompt: z.string(), + timestamp: z.number(), +}) + +/** + * History data structure + */ +export const historyDataSchema = z.object({ + version: z.string(), + maxSize: z.number(), + entries: z.array(historyEntrySchema), +}) + +// Inferred types +export type HistoryEntry = z.infer +export type HistoryData = z.infer diff --git a/packages/core-schemas/src/config/index.ts b/packages/core-schemas/src/config/index.ts new file mode 100644 index 00000000000..9187d07e31b --- /dev/null +++ b/packages/core-schemas/src/config/index.ts @@ -0,0 +1,11 @@ +// Provider configuration schemas and types +export * from "./provider.js" + +// Auto-approval configuration schemas and types +export * from "./auto-approval.js" + +// CLI configuration schemas and types +export * from "./cli-config.js" + +// History schemas and types +export * from "./history.js" diff --git a/packages/core-schemas/src/config/provider.ts b/packages/core-schemas/src/config/provider.ts new file mode 100644 index 00000000000..c5980c03978 --- /dev/null +++ b/packages/core-schemas/src/config/provider.ts @@ -0,0 +1,479 @@ +import { z } from "zod" + +// Base schema all providers extend +const baseProviderSchema = z.object({ + id: z.string(), +}) + +// Kilocode provider +export const kilocodeProviderSchema = baseProviderSchema.extend({ + provider: z.literal("kilocode"), + kilocodeModel: z.string().optional(), + kilocodeToken: z.string().optional(), + kilocodeOrganizationId: z.string().optional(), + openRouterSpecificProvider: z.string().optional(), + openRouterProviderDataCollection: z.enum(["allow", "deny"]).optional(), + openRouterProviderSort: z.enum(["price", "throughput", "latency"]).optional(), + openRouterZdr: z.boolean().optional(), + kilocodeTesterWarningsDisabledUntil: z.number().optional(), +}) + +// Anthropic provider +export const anthropicProviderSchema = baseProviderSchema.extend({ + provider: z.literal("anthropic"), + apiModelId: z.string().optional(), + apiKey: z.string().optional(), + anthropicBaseUrl: z.string().optional(), + anthropicUseAuthToken: z.boolean().optional(), + anthropicBeta1MContext: z.boolean().optional(), +}) + +// OpenAI Native provider +export const openAINativeProviderSchema = baseProviderSchema.extend({ + provider: z.literal("openai-native"), + apiModelId: z.string().optional(), + openAiNativeApiKey: z.string().optional(), + openAiNativeBaseUrl: z.string().optional(), + openAiNativeServiceTier: z.enum(["auto", "default", "flex", "priority"]).optional(), +}) + +// OpenAI provider +export const openAIProviderSchema = baseProviderSchema.extend({ + provider: z.literal("openai"), + openAiModelId: z.string().optional(), + openAiBaseUrl: z.string().optional(), + openAiApiKey: z.string().optional(), + openAiLegacyFormat: z.boolean().optional(), + openAiR1FormatEnabled: z.boolean().optional(), + openAiUseAzure: z.boolean().optional(), + azureApiVersion: z.string().optional(), + openAiStreamingEnabled: z.boolean().optional(), + openAiHeaders: z.record(z.string()).optional(), +}) + +// OpenRouter provider +export const openRouterProviderSchema = baseProviderSchema.extend({ + provider: z.literal("openrouter"), + openRouterModelId: z.string().optional(), + openRouterApiKey: z.string().optional(), + openRouterBaseUrl: z.string().optional(), + openRouterSpecificProvider: z.string().optional(), + openRouterUseMiddleOutTransform: z.boolean().optional(), + openRouterProviderDataCollection: z.enum(["allow", "deny"]).optional(), + openRouterProviderSort: z.enum(["price", "throughput", "latency"]).optional(), + openRouterZdr: z.boolean().optional(), +}) + +// Ollama provider +export const ollamaProviderSchema = baseProviderSchema.extend({ + provider: z.literal("ollama"), + ollamaModelId: z.string().optional(), + ollamaBaseUrl: z.string().optional(), + ollamaApiKey: z.string().optional(), + ollamaNumCtx: z.number().optional(), +}) + +// LM Studio provider +export const lmStudioProviderSchema = baseProviderSchema.extend({ + provider: z.literal("lmstudio"), + lmStudioModelId: z.string().optional(), + lmStudioBaseUrl: z.string().optional(), + lmStudioDraftModelId: z.string().optional(), + lmStudioSpeculativeDecodingEnabled: z.boolean().optional(), +}) + +// Glama provider +export const glamaProviderSchema = baseProviderSchema.extend({ + provider: z.literal("glama"), + glamaModelId: z.string().optional(), + glamaApiKey: z.string().optional(), +}) + +// LiteLLM provider +export const liteLLMProviderSchema = baseProviderSchema.extend({ + provider: z.literal("litellm"), + litellmModelId: z.string().optional(), + litellmBaseUrl: z.string().optional(), + litellmApiKey: z.string().optional(), + litellmUsePromptCache: z.boolean().optional(), +}) + +// DeepInfra provider +export const deepInfraProviderSchema = baseProviderSchema.extend({ + provider: z.literal("deepinfra"), + deepInfraModelId: z.string().optional(), + deepInfraBaseUrl: z.string().optional(), + deepInfraApiKey: z.string().optional(), +}) + +// Unbound provider +export const unboundProviderSchema = baseProviderSchema.extend({ + provider: z.literal("unbound"), + unboundModelId: z.string().optional(), + unboundApiKey: z.string().optional(), +}) + +// Requesty provider +export const requestyProviderSchema = baseProviderSchema.extend({ + provider: z.literal("requesty"), + requestyModelId: z.string().optional(), + requestyBaseUrl: z.string().optional(), + requestyApiKey: z.string().optional(), +}) + +// Vercel AI Gateway provider +export const vercelAiGatewayProviderSchema = baseProviderSchema.extend({ + provider: z.literal("vercel-ai-gateway"), + vercelAiGatewayModelId: z.string().optional(), + vercelAiGatewayApiKey: z.string().optional(), +}) + +// IO Intelligence provider +export const ioIntelligenceProviderSchema = baseProviderSchema.extend({ + provider: z.literal("io-intelligence"), + ioIntelligenceModelId: z.string().optional(), + ioIntelligenceApiKey: z.string().optional(), +}) + +// OVH Cloud provider +export const ovhCloudProviderSchema = baseProviderSchema.extend({ + provider: z.literal("ovhcloud"), + ovhCloudAiEndpointsModelId: z.string().optional(), + ovhCloudAiEndpointsApiKey: z.string().optional(), + ovhCloudAiEndpointsBaseUrl: z.string().optional(), +}) + +// Inception provider +export const inceptionProviderSchema = baseProviderSchema.extend({ + provider: z.literal("inception"), + inceptionLabsModelId: z.string().optional(), + inceptionLabsBaseUrl: z.string().optional(), + inceptionLabsApiKey: z.string().optional(), +}) + +// Bedrock provider (AWS) +export const bedrockProviderSchema = baseProviderSchema.extend({ + provider: z.literal("bedrock"), + apiModelId: z.string().optional(), + awsAccessKey: z.string().optional(), + awsSecretKey: z.string().optional(), + awsSessionToken: z.string().optional(), + awsRegion: z.string().optional(), + awsUseCrossRegionInference: z.boolean().optional(), + awsUsePromptCache: z.boolean().optional(), + awsProfile: z.string().optional(), + awsUseProfile: z.boolean().optional(), + awsApiKey: z.string().optional(), + awsUseApiKey: z.boolean().optional(), + awsCustomArn: z.string().optional(), + awsModelContextWindow: z.number().optional(), + awsBedrockEndpointEnabled: z.boolean().optional(), + awsBedrockEndpoint: z.string().optional(), + awsBedrock1MContext: z.boolean().optional(), +}) + +// Vertex provider +export const vertexProviderSchema = baseProviderSchema.extend({ + provider: z.literal("vertex"), + apiModelId: z.string().optional(), + vertexKeyFile: z.string().optional(), + vertexJsonCredentials: z.string().optional(), + vertexProjectId: z.string().optional(), + vertexRegion: z.string().optional(), + enableUrlContext: z.boolean().optional(), + enableGrounding: z.boolean().optional(), +}) + +// Gemini provider +export const geminiProviderSchema = baseProviderSchema.extend({ + provider: z.literal("gemini"), + apiModelId: z.string().optional(), + geminiApiKey: z.string().optional(), + googleGeminiBaseUrl: z.string().optional(), + enableUrlContext: z.boolean().optional(), + enableGrounding: z.boolean().optional(), +}) + +// Gemini CLI provider +export const geminiCliProviderSchema = baseProviderSchema.extend({ + provider: z.literal("gemini-cli"), + apiModelId: z.string().optional(), + geminiCliOAuthPath: z.string().optional(), + geminiCliProjectId: z.string().optional(), +}) + +// Mistral provider +export const mistralProviderSchema = baseProviderSchema.extend({ + provider: z.literal("mistral"), + apiModelId: z.string().optional(), + mistralApiKey: z.string().optional(), + mistralCodestralUrl: z.string().optional(), +}) + +// Moonshot provider +export const moonshotProviderSchema = baseProviderSchema.extend({ + provider: z.literal("moonshot"), + apiModelId: z.string().optional(), + moonshotBaseUrl: z.string().optional(), + moonshotApiKey: z.string().optional(), +}) + +// Minimax provider +export const minimaxProviderSchema = baseProviderSchema.extend({ + provider: z.literal("minimax"), + apiModelId: z.string().optional(), + minimaxBaseUrl: z.string().optional(), + minimaxApiKey: z.string().optional(), +}) + +// DeepSeek provider +export const deepSeekProviderSchema = baseProviderSchema.extend({ + provider: z.literal("deepseek"), + apiModelId: z.string().optional(), + deepSeekBaseUrl: z.string().optional(), + deepSeekApiKey: z.string().optional(), +}) + +// Doubao provider +export const doubaoProviderSchema = baseProviderSchema.extend({ + provider: z.literal("doubao"), + apiModelId: z.string().optional(), + doubaoBaseUrl: z.string().optional(), + doubaoApiKey: z.string().optional(), +}) + +// Qwen Code provider +export const qwenCodeProviderSchema = baseProviderSchema.extend({ + provider: z.literal("qwen-code"), + apiModelId: z.string().optional(), + qwenCodeOauthPath: z.string().optional(), +}) + +// XAI provider +export const xaiProviderSchema = baseProviderSchema.extend({ + provider: z.literal("xai"), + apiModelId: z.string().optional(), + xaiApiKey: z.string().optional(), +}) + +// Groq provider +export const groqProviderSchema = baseProviderSchema.extend({ + provider: z.literal("groq"), + apiModelId: z.string().optional(), + groqApiKey: z.string().optional(), +}) + +// Chutes provider +export const chutesProviderSchema = baseProviderSchema.extend({ + provider: z.literal("chutes"), + apiModelId: z.string().optional(), + chutesApiKey: z.string().optional(), +}) + +// Cerebras provider +export const cerebrasProviderSchema = baseProviderSchema.extend({ + provider: z.literal("cerebras"), + apiModelId: z.string().optional(), + cerebrasApiKey: z.string().optional(), +}) + +// SambaNova provider +export const sambaNovaProviderSchema = baseProviderSchema.extend({ + provider: z.literal("sambanova"), + apiModelId: z.string().optional(), + sambaNovaApiKey: z.string().optional(), +}) + +// ZAI provider +export const zaiProviderSchema = baseProviderSchema.extend({ + provider: z.literal("zai"), + apiModelId: z.string().optional(), + zaiApiKey: z.string().optional(), + zaiApiLine: z.enum(["international_coding", "china_coding"]).optional(), +}) + +// Fireworks provider +export const fireworksProviderSchema = baseProviderSchema.extend({ + provider: z.literal("fireworks"), + apiModelId: z.string().optional(), + fireworksApiKey: z.string().optional(), +}) + +// Featherless provider +export const featherlessProviderSchema = baseProviderSchema.extend({ + provider: z.literal("featherless"), + apiModelId: z.string().optional(), + featherlessApiKey: z.string().optional(), +}) + +// Roo provider +export const rooProviderSchema = baseProviderSchema.extend({ + provider: z.literal("roo"), + apiModelId: z.string().optional(), +}) + +// Claude Code provider +export const claudeCodeProviderSchema = baseProviderSchema.extend({ + provider: z.literal("claude-code"), + apiModelId: z.string().optional(), + claudeCodePath: z.string().optional(), + claudeCodeMaxOutputTokens: z.number().optional(), +}) + +// VSCode LM provider +export const vsCodeLMProviderSchema = baseProviderSchema.extend({ + provider: z.literal("vscode-lm"), + vsCodeLmModelSelector: z + .object({ + vendor: z.string().optional(), + family: z.string().optional(), + version: z.string().optional(), + id: z.string().optional(), + }) + .optional(), +}) + +// HuggingFace provider +export const huggingFaceProviderSchema = baseProviderSchema.extend({ + provider: z.literal("huggingface"), + huggingFaceModelId: z.string().optional(), + huggingFaceApiKey: z.string().optional(), + huggingFaceInferenceProvider: z.string().optional(), +}) + +// Synthetic provider +export const syntheticProviderSchema = baseProviderSchema.extend({ + provider: z.literal("synthetic"), + apiModelId: z.string().optional(), + syntheticApiKey: z.string().optional(), +}) + +// Virtual Quota Fallback provider +export const virtualQuotaFallbackProviderSchema = baseProviderSchema.extend({ + provider: z.literal("virtual-quota-fallback"), + profiles: z + .array( + z.object({ + profileName: z.string().optional(), + profileId: z.string().optional(), + profileLimits: z + .object({ + tokensPerMinute: z.number().optional(), + tokensPerHour: z.number().optional(), + tokensPerDay: z.number().optional(), + requestsPerMinute: z.number().optional(), + requestsPerHour: z.number().optional(), + requestsPerDay: z.number().optional(), + }) + .optional(), + }), + ) + .optional(), +}) + +// Human Relay provider +export const humanRelayProviderSchema = baseProviderSchema.extend({ + provider: z.literal("human-relay"), +}) + +// Fake AI provider (for testing) +export const fakeAIProviderSchema = baseProviderSchema.extend({ + provider: z.literal("fake-ai"), + fakeAi: z.unknown().optional(), +}) + +// Discriminated union of all provider configs +export const providerConfigSchema = z.discriminatedUnion("provider", [ + kilocodeProviderSchema, + anthropicProviderSchema, + openAINativeProviderSchema, + openAIProviderSchema, + openRouterProviderSchema, + ollamaProviderSchema, + lmStudioProviderSchema, + glamaProviderSchema, + liteLLMProviderSchema, + deepInfraProviderSchema, + unboundProviderSchema, + requestyProviderSchema, + vercelAiGatewayProviderSchema, + ioIntelligenceProviderSchema, + ovhCloudProviderSchema, + inceptionProviderSchema, + bedrockProviderSchema, + vertexProviderSchema, + geminiProviderSchema, + geminiCliProviderSchema, + mistralProviderSchema, + moonshotProviderSchema, + minimaxProviderSchema, + deepSeekProviderSchema, + doubaoProviderSchema, + qwenCodeProviderSchema, + xaiProviderSchema, + groqProviderSchema, + chutesProviderSchema, + cerebrasProviderSchema, + sambaNovaProviderSchema, + zaiProviderSchema, + fireworksProviderSchema, + featherlessProviderSchema, + rooProviderSchema, + claudeCodeProviderSchema, + vsCodeLMProviderSchema, + huggingFaceProviderSchema, + syntheticProviderSchema, + virtualQuotaFallbackProviderSchema, + humanRelayProviderSchema, + fakeAIProviderSchema, +]) + +// Inferred types +export type KilocodeProviderConfig = z.infer +export type AnthropicProviderConfig = z.infer +export type OpenAINativeProviderConfig = z.infer +export type OpenAIProviderConfig = z.infer +export type OpenRouterProviderConfig = z.infer +export type OllamaProviderConfig = z.infer +export type LMStudioProviderConfig = z.infer +export type GlamaProviderConfig = z.infer +export type LiteLLMProviderConfig = z.infer +export type DeepInfraProviderConfig = z.infer +export type UnboundProviderConfig = z.infer +export type RequestyProviderConfig = z.infer +export type VercelAiGatewayProviderConfig = z.infer +export type IOIntelligenceProviderConfig = z.infer +export type OVHCloudProviderConfig = z.infer +export type InceptionProviderConfig = z.infer +export type BedrockProviderConfig = z.infer +export type VertexProviderConfig = z.infer +export type GeminiProviderConfig = z.infer +export type GeminiCliProviderConfig = z.infer +export type MistralProviderConfig = z.infer +export type MoonshotProviderConfig = z.infer +export type MinimaxProviderConfig = z.infer +export type DeepSeekProviderConfig = z.infer +export type DoubaoProviderConfig = z.infer +export type QwenCodeProviderConfig = z.infer +export type XAIProviderConfig = z.infer +export type GroqProviderConfig = z.infer +export type ChutesProviderConfig = z.infer +export type CerebrasProviderConfig = z.infer +export type SambaNovaProviderConfig = z.infer +export type ZAIProviderConfig = z.infer +export type FireworksProviderConfig = z.infer +export type FeatherlessProviderConfig = z.infer +export type RooProviderConfig = z.infer +export type ClaudeCodeProviderConfig = z.infer +export type VSCodeLMProviderConfig = z.infer +export type HuggingFaceProviderConfig = z.infer +export type SyntheticProviderConfig = z.infer +export type VirtualQuotaFallbackProviderConfig = z.infer +export type HumanRelayProviderConfig = z.infer +export type FakeAIProviderConfig = z.infer +export type ProviderConfig = z.infer + +// Type guards +export function isProviderConfig(provider: unknown): provider is ProviderConfig { + return providerConfigSchema.safeParse(provider).success +} diff --git a/packages/core-schemas/src/index.ts b/packages/core-schemas/src/index.ts new file mode 100644 index 00000000000..cccb56c3885 --- /dev/null +++ b/packages/core-schemas/src/index.ts @@ -0,0 +1,27 @@ +/** + * @kilocode/core-schemas + * + * Zod schemas and inferred types for CLI configuration and runtime data. + * This package provides runtime validation and type inference for the CLI. + */ + +// Configuration schemas +export * from "./config/index.js" + +// Authentication schemas +export * from "./auth/index.js" + +// Message schemas +export * from "./messages/index.js" + +// MCP (Model Context Protocol) schemas +export * from "./mcp/index.js" + +// Keyboard input schemas +export * from "./keyboard/index.js" + +// Theme schemas +export * from "./theme/index.js" + +// Agent manager schemas +export * from "./agent-manager/index.js" diff --git a/packages/core-schemas/src/keyboard/index.ts b/packages/core-schemas/src/keyboard/index.ts new file mode 100644 index 00000000000..0e6e01c193b --- /dev/null +++ b/packages/core-schemas/src/keyboard/index.ts @@ -0,0 +1,2 @@ +// Keyboard input schemas and types +export * from "./key.js" diff --git a/packages/core-schemas/src/keyboard/key.ts b/packages/core-schemas/src/keyboard/key.ts new file mode 100644 index 00000000000..03b90824e4d --- /dev/null +++ b/packages/core-schemas/src/keyboard/key.ts @@ -0,0 +1,52 @@ +import { z } from "zod" + +/** + * Represents a parsed key event with all relevant information + */ +export const keySchema = z.object({ + /** Key name (e.g., 'a', 'return', 'escape', 'up', 'down') */ + name: z.string(), + /** Whether Ctrl modifier is pressed */ + ctrl: z.boolean(), + /** Whether Alt/Meta modifier is pressed */ + meta: z.boolean(), + /** Whether Shift modifier is pressed */ + shift: z.boolean(), + /** Whether this is a paste event containing multiple characters */ + paste: z.boolean(), + /** Raw key sequence as received from terminal */ + sequence: z.string(), + /** Whether this was parsed using Kitty keyboard protocol */ + kittyProtocol: z.boolean().optional(), +}) + +/** + * Represents a key object from Node's readline keypress event + */ +export const readlineKeySchema = z.object({ + name: z.string().optional(), + sequence: z.string(), + ctrl: z.boolean().optional(), + meta: z.boolean().optional(), + shift: z.boolean().optional(), +}) + +/** + * Configuration for the KeyboardProvider + */ +export const keyboardProviderConfigSchema = z.object({ + /** Enable debug logging for keystrokes */ + debugKeystrokeLogging: z.boolean().optional(), + /** Custom escape code timeout (ms) */ + escapeCodeTimeout: z.number().optional(), +}) + +// Inferred types +export type Key = z.infer +export type ReadlineKey = z.infer +export type KeyboardProviderConfig = z.infer + +/** + * Handler function type for key events + */ +export type KeypressHandler = (key: Key) => void diff --git a/packages/core-schemas/src/mcp/index.ts b/packages/core-schemas/src/mcp/index.ts new file mode 100644 index 00000000000..903c38ffc61 --- /dev/null +++ b/packages/core-schemas/src/mcp/index.ts @@ -0,0 +1,2 @@ +// MCP server schemas and types +export * from "./server.js" diff --git a/packages/core-schemas/src/mcp/server.ts b/packages/core-schemas/src/mcp/server.ts new file mode 100644 index 00000000000..4718dd83107 --- /dev/null +++ b/packages/core-schemas/src/mcp/server.ts @@ -0,0 +1,59 @@ +import { z } from "zod" + +/** + * MCP Tool schema + */ +export const mcpToolSchema = z.object({ + name: z.string(), + description: z.string().optional(), + inputSchema: z.record(z.unknown()).optional(), +}) + +/** + * MCP Resource schema + */ +export const mcpResourceSchema = z.object({ + uri: z.string(), + name: z.string(), + description: z.string().optional(), + mimeType: z.string().optional(), +}) + +/** + * MCP Server status schema + */ +export const mcpServerStatusSchema = z.enum(["connected", "connecting", "disconnected"]) + +/** + * MCP Server schema + */ +export const mcpServerSchema = z.object({ + name: z.string(), + config: z.record(z.unknown()), + status: mcpServerStatusSchema, + tools: z.array(mcpToolSchema).optional(), + resources: z.array(mcpResourceSchema).optional(), + resourceTemplates: z.array(z.unknown()).optional(), + errorHistory: z.array(z.string()).optional(), + timeout: z.number().optional(), + source: z.enum(["global", "project"]).optional(), +}) + +/** + * MCP server data for message rendering + */ +export const mcpServerDataSchema = z.object({ + type: z.string().optional(), + serverName: z.string().optional(), + toolName: z.string().optional(), + arguments: z.string().optional(), + uri: z.string().optional(), + response: z.string().optional(), +}) + +// Inferred types +export type McpTool = z.infer +export type McpResource = z.infer +export type McpServerStatus = z.infer +export type McpServer = z.infer +export type McpServerData = z.infer diff --git a/packages/core-schemas/src/messages/cli.ts b/packages/core-schemas/src/messages/cli.ts new file mode 100644 index 00000000000..d7d3f68c5c9 --- /dev/null +++ b/packages/core-schemas/src/messages/cli.ts @@ -0,0 +1,63 @@ +import { z } from "zod" + +/** + * Welcome message options schema + */ +export const welcomeMessageOptionsSchema = z.object({ + // Clear viewport before showing the message + clearScreen: z.boolean().optional(), + // Display options + showInstructions: z.boolean().optional(), + // Content customization + instructions: z.array(z.string()).optional(), + // Parallel mode branch name + worktreeBranch: z.string().optional(), + // Workspace directory + workspace: z.string().optional(), +}) + +/** + * CLI message schema + */ +export const cliMessageSchema = z.object({ + id: z.string(), + type: z.enum(["user", "assistant", "system", "error", "welcome", "empty", "requestCheckpointRestoreApproval"]), + content: z.string(), + ts: z.number(), + partial: z.boolean().optional(), + metadata: z + .object({ + welcomeOptions: welcomeMessageOptionsSchema.optional(), + }) + .optional(), + payload: z.unknown().optional(), +}) + +/** + * CLI options schema + */ +export const cliOptionsSchema = z.object({ + mode: z.string().optional(), + workspace: z.string().optional(), + ci: z.boolean().optional(), + yolo: z.boolean().optional(), + json: z.boolean().optional(), + jsonInteractive: z.boolean().optional(), + prompt: z.string().optional(), + timeout: z.number().optional(), + customModes: z.array(z.unknown()).optional(), // ModeConfig from @roo-code/types + parallel: z.boolean().optional(), + worktreeBranch: z.string().optional(), + continue: z.boolean().optional(), + provider: z.string().optional(), + model: z.string().optional(), + session: z.string().optional(), + fork: z.string().optional(), + noSplash: z.boolean().optional(), + appendSystemPrompt: z.string().optional(), +}) + +// Inferred types +export type WelcomeMessageOptions = z.infer +export type CliMessage = z.infer +export type CLIOptions = z.infer diff --git a/packages/core-schemas/src/messages/extension.ts b/packages/core-schemas/src/messages/extension.ts new file mode 100644 index 00000000000..5c996223d95 --- /dev/null +++ b/packages/core-schemas/src/messages/extension.ts @@ -0,0 +1,60 @@ +import { z } from "zod" + +/** + * Organization Allow List for provider validation + */ +export const organizationAllowListSchema = z.object({ + allowAll: z.boolean(), + providers: z.record( + z.object({ + allowAll: z.boolean(), + models: z.array(z.string()).optional(), + }), + ), +}) + +/** + * Extension message schema + */ +export const extensionMessageSchema = z.object({ + type: z.string(), + action: z.string().optional(), + text: z.string().optional(), + state: z.unknown().optional(), // ExtensionState + images: z.array(z.string()).optional(), + chatMessages: z.array(z.unknown()).optional(), // ExtensionChatMessage[] + values: z.record(z.unknown()).optional(), +}) + +/** + * CLI-specific ExtensionState schema + */ +export const extensionStateSchema = z.object({ + version: z.string(), + apiConfiguration: z.unknown(), // ProviderSettings + currentApiConfigName: z.string().optional(), + listApiConfigMeta: z.array(z.unknown()).optional(), // ProviderSettingsEntry[] + chatMessages: z.array(z.unknown()), // ExtensionChatMessage[] + clineMessages: z.array(z.unknown()).optional(), // Cline Legacy + currentTaskItem: z.unknown().optional(), // HistoryItem + currentTaskTodos: z.array(z.unknown()).optional(), // TodoItem[] + mode: z.string(), + customModes: z.array(z.unknown()), // ModeConfig[] + taskHistoryFullLength: z.number(), + taskHistoryVersion: z.number(), + mcpServers: z.array(z.unknown()).optional(), // McpServer[] + telemetrySetting: z.string(), + renderContext: z.enum(["sidebar", "editor", "cli"]), + cwd: z.string().optional(), + organizationAllowList: organizationAllowListSchema.optional(), + routerModels: z.unknown().optional(), // RouterModels + appendSystemPrompt: z.string().optional(), // Custom text to append to system prompt (CLI only) +}) + +// Inferred types +export type OrganizationAllowList = z.infer +export type ExtensionMessage = z.infer +export type ExtensionState = z.infer + +// Mode type alias +export type Mode = string diff --git a/packages/core-schemas/src/messages/index.ts b/packages/core-schemas/src/messages/index.ts new file mode 100644 index 00000000000..9376c9a2fa1 --- /dev/null +++ b/packages/core-schemas/src/messages/index.ts @@ -0,0 +1,5 @@ +// CLI-specific message types +export * from "./cli.js" + +// Extension message types +export * from "./extension.js" diff --git a/packages/core-schemas/src/theme/index.ts b/packages/core-schemas/src/theme/index.ts new file mode 100644 index 00000000000..b280cae4532 --- /dev/null +++ b/packages/core-schemas/src/theme/index.ts @@ -0,0 +1,2 @@ +// Theme schemas and types +export * from "./theme.js" diff --git a/packages/core-schemas/src/theme/theme.ts b/packages/core-schemas/src/theme/theme.ts new file mode 100644 index 00000000000..db478261e2a --- /dev/null +++ b/packages/core-schemas/src/theme/theme.ts @@ -0,0 +1,117 @@ +import { z } from "zod" + +/** + * Theme type for categorization + */ +export const themeTypeSchema = z.enum(["dark", "light", "custom"]) + +/** + * Core theme interface defining all color categories + */ +export const themeSchema = z.object({ + /** Theme identifier */ + id: z.string(), + /** Theme display name */ + name: z.string(), + /** Theme type for categorization */ + type: themeTypeSchema, + + /** Brand identity colors */ + brand: z.object({ + primary: z.string(), + secondary: z.string(), + }), + + /** Semantic colors for common states */ + semantic: z.object({ + success: z.string(), + error: z.string(), + warning: z.string(), + info: z.string(), + neutral: z.string(), + }), + + /** Interactive element colors */ + interactive: z.object({ + prompt: z.string(), + selection: z.string(), + hover: z.string(), + disabled: z.string(), + focus: z.string(), + }), + + /** Message type colors */ + messages: z.object({ + user: z.string(), + assistant: z.string(), + system: z.string(), + error: z.string(), + }), + + /** Action colors (unified approve/reject/cancel patterns) */ + actions: z.object({ + approve: z.string(), + reject: z.string(), + cancel: z.string(), + pending: z.string(), + }), + + /** Code and diff display colors */ + code: z.object({ + addition: z.string(), + deletion: z.string(), + modification: z.string(), + context: z.string(), + lineNumber: z.string(), + }), + + /** Markdown rendering colors */ + markdown: z.object({ + text: z.string(), + heading: z.string(), + strong: z.string(), + em: z.string(), + code: z.string(), + blockquote: z.string(), + link: z.string(), + list: z.string(), + }), + + /** UI structure colors */ + ui: z.object({ + border: z.object({ + default: z.string(), + active: z.string(), + warning: z.string(), + error: z.string(), + }), + text: z.object({ + primary: z.string(), + secondary: z.string(), + dimmed: z.string(), + highlight: z.string(), + }), + background: z.object({ + default: z.string(), + elevated: z.string(), + }), + }), + + /** Status indicator colors */ + status: z.object({ + online: z.string(), + offline: z.string(), + busy: z.string(), + idle: z.string(), + }), +}) + +/** + * Theme identifier type - can be a built-in theme or custom theme ID + */ +export const themeIdSchema = z.union([z.literal("dark"), z.literal("light"), z.string()]) + +// Inferred types +export type ThemeType = z.infer +export type Theme = z.infer +export type ThemeId = z.infer diff --git a/packages/core-schemas/tsconfig.json b/packages/core-schemas/tsconfig.json new file mode 100644 index 00000000000..9893fe2966c --- /dev/null +++ b/packages/core-schemas/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@roo-code/config-typescript/base.json", + "compilerOptions": { + "types": ["vitest/globals"], + "outDir": "dist" + }, + "include": ["src", "*.config.ts"], + "exclude": ["node_modules"] +} diff --git a/packages/core-schemas/tsup.config.ts b/packages/core-schemas/tsup.config.ts new file mode 100644 index 00000000000..38b458806ae --- /dev/null +++ b/packages/core-schemas/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from "tsup" + +export default defineConfig({ + entry: ["src/index.ts"], + format: ["cjs", "esm"], + dts: true, + splitting: false, + sourcemap: true, + clean: true, + outDir: "dist", +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b2aa3b008a..8d8a5599f89 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -607,6 +607,9 @@ importers: '@google/genai': specifier: ^1.35.0 version: 1.35.0(@modelcontextprotocol/sdk@1.25.2(hono@4.11.3)(zod@4.3.5)) + '@kilocode/core-schemas': + specifier: workspace:^ + version: link:../packages/core-schemas '@lmstudio/sdk': specifier: ^1.5.0 version: 1.5.0 @@ -1505,6 +1508,34 @@ importers: packages/config-typescript: {} + packages/core-schemas: + dependencies: + zod: + specifier: ^3.25.61 + version: 3.25.76 + devDependencies: + '@roo-code/config-eslint': + specifier: workspace:^ + version: link:../config-eslint + '@roo-code/config-typescript': + specifier: workspace:^ + version: link:../config-typescript + '@roo-code/types': + specifier: workspace:^ + version: link:../types + '@types/node': + specifier: 20.x + version: 20.19.27 + globals: + specifier: ^16.3.0 + version: 16.3.0 + tsup: + specifier: ^8.3.5 + version: 8.5.0(@swc/core@1.15.1(@swc/helpers@0.5.18))(jiti@2.4.2)(postcss@8.5.6)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.2) + vitest: + specifier: ^3.2.3 + version: 3.2.4(@types/debug@4.1.12)(@types/node@20.19.27)(@vitest/ui@3.2.4)(jiti@2.4.2)(jsdom@27.4.0)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + packages/evals: dependencies: '@roo-code/ipc': @@ -1670,6 +1701,9 @@ importers: '@google/genai': specifier: ^1.29.1 version: 1.29.1(@modelcontextprotocol/sdk@1.24.0(zod@3.25.61)) + '@kilocode/core-schemas': + specifier: workspace:^ + version: link:../packages/core-schemas '@lancedb/lancedb': specifier: ^0.21.2 version: 0.21.3(apache-arrow@18.1.0) @@ -25675,7 +25709,7 @@ snapshots: '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -25688,14 +25722,14 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.57 + '@types/node': 20.19.27 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.57)(ts-node@10.9.2(@swc/core@1.15.1(@swc/helpers@0.5.18))(@types/node@20.17.57)(typescript@5.8.3)) + jest-config: 29.7.0(@types/node@20.19.27)(ts-node@10.9.2(@swc/core@1.15.1(@swc/helpers@0.5.18))(@types/node@20.17.57)(typescript@5.8.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -25724,7 +25758,7 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.57 + '@types/node': 20.19.27 jest-mock: 29.7.0 '@jest/expect-utils@29.7.0': @@ -25742,7 +25776,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.17.57 + '@types/node': 20.19.27 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -25758,7 +25792,7 @@ snapshots: '@jest/pattern@30.0.1': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 jest-regex-util: 30.0.1 '@jest/reporters@29.7.0': @@ -25769,7 +25803,7 @@ snapshots: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 20.17.57 + '@types/node': 20.19.27 chalk: 4.1.2 collect-v8-coverage: 1.0.3 exit: 0.1.2 @@ -25843,7 +25877,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/yargs': 17.0.33 chalk: 4.1.2 @@ -25853,7 +25887,7 @@ snapshots: '@jest/schemas': 30.0.5 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/yargs': 17.0.33 chalk: 4.1.2 @@ -26104,8 +26138,8 @@ snapshots: '@lmstudio/lms-isomorphic': 0.4.5 chalk: 4.1.2 jsonschema: 1.5.0 - zod: 3.25.61 - zod-to-json-schema: 3.24.5(zod@3.25.61) + zod: 3.25.76 + zod-to-json-schema: 3.24.5(zod@3.25.76) transitivePeerDependencies: - bufferutil - utf-8-validate @@ -29486,17 +29520,17 @@ snapshots: '@types/body-parser@1.19.6': dependencies: '@types/connect': 3.4.38 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/bonjour@3.5.13': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/cacheable-request@6.0.3': dependencies: '@types/http-cache-semantics': 4.0.4 '@types/keyv': 3.1.4 - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/responselike': 1.0.3 '@types/cardinal@2.1.1': {} @@ -29519,11 +29553,11 @@ snapshots: '@types/connect-history-api-fallback@1.5.4': dependencies: '@types/express-serve-static-core': 4.19.7 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/connect@3.4.38': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/cookie@0.3.3': {} @@ -29680,7 +29714,7 @@ snapshots: '@types/express-serve-static-core@4.19.7': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/qs': 6.14.0 '@types/range-parser': 1.2.7 '@types/send': 1.2.1 @@ -29702,13 +29736,13 @@ snapshots: '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.17.57 + '@types/node': 20.19.27 optional: true '@types/glob@8.1.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.17.50 + '@types/node': 20.19.27 '@types/glob@9.0.0': dependencies: @@ -29716,7 +29750,7 @@ snapshots: '@types/graceful-fs@4.1.9': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/gtag.js@0.0.12': {} @@ -29749,7 +29783,7 @@ snapshots: '@types/http-proxy@1.17.17': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/istanbul-lib-coverage@2.0.6': {} @@ -29770,13 +29804,13 @@ snapshots: '@types/jsdom@20.0.1': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/tough-cookie': 4.0.5 parse5: 7.3.0 '@types/jsdom@21.1.7': dependencies: - '@types/node': 20.17.50 + '@types/node': 20.19.27 '@types/tough-cookie': 4.0.5 parse5: 7.3.0 @@ -29788,7 +29822,7 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/katex@0.16.7': {} @@ -29796,7 +29830,7 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/lodash.debounce@4.0.9': dependencies: @@ -29839,16 +29873,16 @@ snapshots: '@types/node-fetch@2.6.12': dependencies: - '@types/node': 20.17.50 + '@types/node': 20.19.27 form-data: 4.0.4 '@types/node-forge@1.3.14': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/node-ipc@9.2.3': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/node@12.20.55': {} @@ -29888,7 +29922,7 @@ snapshots: '@types/qrcode@1.5.6': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/qs@6.14.0': {} @@ -29926,13 +29960,13 @@ snapshots: '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/resolve@1.20.6': {} '@types/responselike@1.0.3': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/retry@0.12.2': {} @@ -29940,7 +29974,7 @@ snapshots: '@types/sax@1.2.7': dependencies: - '@types/node': 17.0.45 + '@types/node': 20.19.27 '@types/seedrandom@3.0.8': {} @@ -29951,11 +29985,11 @@ snapshots: '@types/send@0.17.6': dependencies: '@types/mime': 1.3.5 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/send@1.2.1': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/serve-index@1.9.4': dependencies: @@ -29964,7 +29998,7 @@ snapshots: '@types/serve-static@1.15.10': dependencies: '@types/http-errors': 2.0.5 - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/send': 0.17.6 '@types/shell-quote@1.7.5': {} @@ -29981,7 +30015,7 @@ snapshots: '@types/sockjs@0.3.36': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/stack-utils@2.0.3': {} @@ -29991,11 +30025,11 @@ snapshots: '@types/stream-chain@2.1.0': dependencies: - '@types/node': 20.17.50 + '@types/node': 20.19.27 '@types/stream-json@1.7.8': dependencies: - '@types/node': 20.17.50 + '@types/node': 20.19.27 '@types/stream-chain': 2.1.0 '@types/string-similarity@4.0.2': {} @@ -30032,7 +30066,7 @@ snapshots: '@types/vinyl@2.0.12': dependencies: '@types/expect': 1.20.4 - '@types/node': 20.17.57 + '@types/node': 20.19.27 '@types/vscode-notebook-renderer@1.72.4': {} @@ -30044,7 +30078,7 @@ snapshots: '@types/wait-on@5.3.4': dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 '@types/webpack@5.28.5(@swc/core@1.15.1(@swc/helpers@0.5.18))(esbuild@0.25.9)(webpack-cli@5.1.4)': dependencies: @@ -30067,7 +30101,7 @@ snapshots: '@types/ws@8.18.1': dependencies: - '@types/node': 20.17.50 + '@types/node': 20.19.27 '@types/yargs-parser@21.0.3': {} @@ -30362,6 +30396,14 @@ snapshots: optionalDependencies: vite: 6.3.6(@types/node@20.17.57)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + '@vitest/mocker@3.2.4(vite@6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2))': + dependencies: + '@vitest/spy': 3.2.4 + estree-walker: 3.0.3 + magic-string: 0.30.17 + optionalDependencies: + vite: 6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + '@vitest/mocker@3.2.4(vite@6.3.6(@types/node@25.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2))': dependencies: '@vitest/spy': 3.2.4 @@ -34223,7 +34265,7 @@ snapshots: eval@0.1.8: dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 require-like: 0.1.2 event-emitter@0.3.5: @@ -36713,7 +36755,7 @@ snapshots: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 chalk: 4.1.2 co: 4.6.0 dedent: 1.7.0 @@ -36802,6 +36844,37 @@ snapshots: - babel-plugin-macros - supports-color + jest-config@29.7.0(@types/node@20.19.27)(ts-node@10.9.2(@swc/core@1.15.1(@swc/helpers@0.5.18))(@types/node@20.17.57)(typescript@5.8.3)): + dependencies: + '@babel/core': 7.27.1 + '@jest/test-sequencer': 29.7.0 + '@jest/types': 29.6.3 + babel-jest: 29.7.0(@babel/core@7.27.1) + chalk: 4.1.2 + ci-info: 3.9.0 + deepmerge: 4.3.1 + glob: 13.0.0 + graceful-fs: 4.2.11 + jest-circus: 29.7.0 + jest-environment-node: 29.7.0 + jest-get-type: 29.6.3 + jest-regex-util: 29.6.3 + jest-resolve: 29.7.0 + jest-runner: 29.7.0 + jest-util: 29.7.0 + jest-validate: 29.7.0 + micromatch: 4.0.8 + parse-json: 5.2.0 + pretty-format: 29.7.0 + slash: 3.0.0 + strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 20.19.27 + ts-node: 10.9.2(@swc/core@1.15.1(@swc/helpers@0.5.18))(@types/node@20.17.57)(typescript@5.8.3) + transitivePeerDependencies: + - babel-plugin-macros + - supports-color + jest-config@29.7.0(@types/node@25.0.3): dependencies: '@babel/core': 7.27.1 @@ -36857,7 +36930,7 @@ snapshots: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 '@types/jsdom': 20.0.1 - '@types/node': 20.17.57 + '@types/node': 20.19.27 jest-mock: 29.7.0 jest-util: 29.7.0 jsdom: 20.0.3 @@ -36871,7 +36944,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -36881,7 +36954,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 25.0.3 + '@types/node': 20.19.27 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -36927,7 +37000,7 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.57 + '@types/node': 20.19.27 jest-util: 29.7.0 jest-playwright-preset@4.0.0(jest-circus@29.7.0)(jest-environment-node@29.7.0)(jest-runner@29.7.0)(jest@29.7.0(@types/node@25.0.3)): @@ -36996,7 +37069,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -37024,7 +37097,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 chalk: 4.1.2 cjs-module-lexer: 1.4.3 collect-v8-coverage: 1.0.3 @@ -37076,7 +37149,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.57 + '@types/node': 20.19.27 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -37106,7 +37179,7 @@ snapshots: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 25.0.3 + '@types/node': 20.19.27 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -37115,13 +37188,13 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.27 merge-stream: 2.0.0 supports-color: 8.1.1 jest-worker@29.7.0: dependencies: - '@types/node': 25.0.3 + '@types/node': 20.19.27 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -44430,6 +44503,27 @@ snapshots: - tsx - yaml + vite-node@3.2.4(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): + dependencies: + cac: 6.7.14 + debug: 4.4.1(supports-color@8.1.1) + es-module-lexer: 1.7.0 + pathe: 2.0.3 + vite: 6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + transitivePeerDependencies: + - '@types/node' + - jiti + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + vite-node@3.2.4(@types/node@25.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): dependencies: cac: 6.7.14 @@ -44519,6 +44613,23 @@ snapshots: tsx: 4.21.0 yaml: 2.8.2 + vite@6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): + dependencies: + esbuild: 0.25.9 + fdir: 6.4.6(picomatch@4.0.2) + picomatch: 4.0.2 + postcss: 8.5.4 + rollup: 4.40.2 + tinyglobby: 0.2.14 + optionalDependencies: + '@types/node': 20.19.27 + fsevents: 2.3.3 + jiti: 2.4.2 + lightningcss: 1.30.1 + terser: 5.44.1 + tsx: 4.21.0 + yaml: 2.8.2 + vite@6.3.6(@types/node@25.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): dependencies: esbuild: 0.25.9 @@ -44729,6 +44840,50 @@ snapshots: - tsx - yaml + vitest@3.2.4(@types/debug@4.1.12)(@types/node@20.19.27)(@vitest/ui@3.2.4)(jiti@2.4.2)(jsdom@27.4.0)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): + dependencies: + '@types/chai': 5.2.2 + '@vitest/expect': 3.2.4 + '@vitest/mocker': 3.2.4(vite@6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2)) + '@vitest/pretty-format': 3.2.4 + '@vitest/runner': 3.2.4 + '@vitest/snapshot': 3.2.4 + '@vitest/spy': 3.2.4 + '@vitest/utils': 3.2.4 + chai: 5.2.0 + debug: 4.4.1(supports-color@8.1.1) + expect-type: 1.2.1 + magic-string: 0.30.17 + pathe: 2.0.3 + picomatch: 4.0.2 + std-env: 3.9.0 + tinybench: 2.9.0 + tinyexec: 0.3.2 + tinyglobby: 0.2.14 + tinypool: 1.1.1 + tinyrainbow: 2.0.0 + vite: 6.3.6(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + vite-node: 3.2.4(@types/node@20.19.27)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/debug': 4.1.12 + '@types/node': 20.19.27 + '@vitest/ui': 3.2.4(vitest@3.2.4) + jsdom: 27.4.0 + transitivePeerDependencies: + - jiti + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - yaml + vitest@3.2.4(@types/debug@4.1.12)(@types/node@25.0.3)(@vitest/ui@3.2.4)(jiti@2.4.2)(jsdom@27.4.0)(lightningcss@1.30.1)(terser@5.44.1)(tsx@4.21.0)(yaml@2.8.2): dependencies: '@types/chai': 5.2.2 @@ -45508,6 +45663,10 @@ snapshots: dependencies: zod: 3.25.61 + zod-to-json-schema@3.24.5(zod@3.25.76): + dependencies: + zod: 3.25.76 + zod-to-json-schema@3.25.0(zod@3.25.61): dependencies: zod: 3.25.61 diff --git a/src/core/kilocode/agent-manager/types.ts b/src/core/kilocode/agent-manager/types.ts index 0dccd17d006..95a06358d91 100644 --- a/src/core/kilocode/agent-manager/types.ts +++ b/src/core/kilocode/agent-manager/types.ts @@ -1,76 +1,33 @@ -import type { Session as RemoteSession } from "../../../shared/kilocode/cli-sessions/core/SessionClient" - /** * Agent Manager Types + * + * Re-exports types from @kilocode/core-schemas for consistency + * and backward compatibility. */ -export type AgentStatus = "creating" | "running" | "done" | "error" | "stopped" -export type SessionSource = "local" | "remote" - -/** - * Parallel mode (worktree) information for a session - */ -export interface ParallelModeInfo { - enabled: boolean - branch?: string // e.g., "add-authentication-1702734891234" - worktreePath?: string // e.g., ".kilocode/worktrees/add-auth..." - parentBranch?: string // e.g., "main" - the branch worktree was created from - completionMessage?: string // Merge instructions from CLI on completion -} - -export interface AgentSession { - sessionId: string - label: string - prompt: string - status: AgentStatus - startTime: number - endTime?: number - exitCode?: number - error?: string - logs: string[] - pid?: number - source: SessionSource - parallelMode?: ParallelModeInfo - gitUrl?: string -} +import type { Session as RemoteSession } from "../../../shared/kilocode/cli-sessions/core/SessionClient" -/** - * Represents a session that is being created (waiting for CLI's session_created event) - */ -export interface PendingSession { - prompt: string - label: string - startTime: number - parallelMode?: boolean - gitUrl?: string -} +// Re-export all agent manager types from core-schemas +export { + // Schemas + agentStatusSchema, + sessionSourceSchema, + parallelModeInfoSchema, + agentSessionSchema, + pendingSessionSchema, + agentManagerStateSchema, + agentManagerMessageSchema, + agentManagerExtensionMessageSchema, + // Types + type AgentStatus, + type SessionSource, + type ParallelModeInfo, + type AgentSession, + type PendingSession, + type AgentManagerState, + type AgentManagerMessage, + type AgentManagerExtensionMessage, +} from "@kilocode/core-schemas" // Re-export remote session shape from shared session client for consistency export type { RemoteSession } - -export interface AgentManagerState { - sessions: AgentSession[] - selectedId: string | null -} - -/** - * Messages from Webview to Extension - */ -export type AgentManagerMessage = - | { type: "agentManager.webviewReady" } - | { type: "agentManager.startSession"; prompt: string; parallelMode?: boolean; existingBranch?: string } - | { type: "agentManager.stopSession"; sessionId: string } - | { type: "agentManager.selectSession"; sessionId: string } - | { type: "agentManager.refreshRemoteSessions" } - | { type: "agentManager.listBranches" } - -/** - * Messages from Extension to Webview - */ -export type AgentManagerExtensionMessage = - | { type: "agentManager.state"; state: AgentManagerState } - | { type: "agentManager.sessionUpdated"; session: AgentSession } - | { type: "agentManager.sessionRemoved"; sessionId: string } - | { type: "agentManager.error"; error: string } - | { type: "agentManager.remoteSessions"; sessions: RemoteSession[] } - | { type: "agentManager.branches"; branches: string[]; currentBranch?: string } diff --git a/src/package.json b/src/package.json index 417b9b8cf0c..003549fc217 100644 --- a/src/package.json +++ b/src/package.json @@ -675,6 +675,7 @@ "@modelcontextprotocol/sdk": "^1.24.0", "@qdrant/js-client-rest": "^1.14.0", "@roo-code/cloud": "workspace:^", + "@kilocode/core-schemas": "workspace:^", "@roo-code/ipc": "workspace:^", "@roo-code/telemetry": "workspace:^", "@roo-code/types": "workspace:^",