| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- import { z } from "zod"
- import {
- type RooCodeSettings,
- type ProviderSettings,
- type PromptComponent,
- type ModeConfig,
- type InstallMarketplaceItemOptions,
- type MarketplaceItem,
- type ShareVisibility,
- type QueuedMessage,
- marketplaceItemSchema,
- // kilocode_change start
- CommitRange,
- HistoryItem,
- GlobalState,
- // kilocode_change end
- } from "@roo-code/types"
- import { Mode } from "./modes"
- import { MicrophoneDevice } from "./sttContract" // kilocode_change: Microphone device type for STT
- export type ClineAskResponse =
- | "yesButtonClicked"
- | "noButtonClicked"
- | "messageResponse"
- | "objectResponse"
- | "retry_clicked" // kilocode_change: Added retry_clicked for payment required dialog
- export type PromptMode = Mode | "enhance"
- export type AudioType = "notification" | "celebration" | "progress_loop"
- export interface UpdateTodoListPayload {
- todos: any[]
- }
- export type EditQueuedMessagePayload = Pick<QueuedMessage, "id" | "text" | "images">
- // kilocode_change start: Type-safe global state update message
- export type GlobalStateValue<K extends keyof GlobalState> = GlobalState[K]
- export type UpdateGlobalStateMessage<K extends keyof GlobalState = keyof GlobalState> = {
- type: "updateGlobalState"
- stateKey: K
- stateValue: GlobalStateValue<K>
- }
- // kilocode_change end: Type-safe global state update message
- export interface WebviewMessage {
- type:
- | "updateTodoList"
- | "deleteMultipleTasksWithIds"
- | "currentApiConfigName"
- | "saveApiConfiguration"
- | "upsertApiConfiguration"
- | "deleteApiConfiguration"
- | "loadApiConfiguration"
- | "loadApiConfigurationById"
- | "getProfileConfigurationForEditing" // kilocode_change: Request to get profile config without activating
- | "renameApiConfiguration"
- | "getListApiConfiguration"
- | "customInstructions"
- | "webviewDidLaunch"
- | "newTask"
- | "askResponse"
- | "terminalOperation"
- | "clearTask"
- | "didShowAnnouncement"
- | "selectImages"
- | "exportCurrentTask"
- | "shareCurrentTask"
- | "showTaskWithId"
- | "deleteTaskWithId"
- | "exportTaskWithId"
- | "importSettings"
- | "toggleToolAutoApprove"
- | "openExtensionSettings"
- | "openInBrowser"
- | "fetchOpenGraphData"
- | "checkIsImageUrl"
- | "exportSettings"
- | "resetState"
- | "flushRouterModels"
- | "requestRouterModels"
- | "requestOpenAiModels"
- | "requestOllamaModels"
- | "requestLmStudioModels"
- | "requestRooModels"
- | "requestRooCreditBalance"
- | "requestVsCodeLmModels"
- | "requestHuggingFaceModels"
- | "requestSapAiCoreModels" // kilocode_change
- | "requestSapAiCoreDeployments" // kilocode_change
- | "openImage"
- | "saveImage"
- | "openFile"
- | "openMention"
- | "cancelTask"
- | "cancelAutoApproval"
- | "updateVSCodeSetting"
- | "getVSCodeSetting"
- | "vsCodeSetting"
- | "updateCondensingPrompt"
- | "yoloGatekeeperApiConfigId" // kilocode_change: AI gatekeeper for YOLO mode
- | "playSound"
- | "playTts"
- | "stopTts"
- | "ttsEnabled"
- | "ttsSpeed"
- | "openKeyboardShortcuts"
- | "openMcpSettings"
- | "openProjectMcpSettings"
- | "restartMcpServer"
- | "mcpServerOAuthSignIn" // kilocode_change: MCP OAuth sign-in
- | "refreshAllMcpServers"
- | "toggleToolAlwaysAllow"
- | "toggleToolEnabledForPrompt"
- | "toggleMcpServer"
- | "updateMcpTimeout"
- | "fuzzyMatchThreshold" // kilocode_change
- | "morphApiKey" // kilocode_change: Morph fast apply - global setting
- | "fastApplyModel" // kilocode_change: Fast Apply model selection
- | "fastApplyApiProvider" // kilocode_change: Fast Apply model api base url
- | "writeDelayMs" // kilocode_change
- | "diagnosticsEnabled" // kilocode_change
- | "enhancePrompt"
- | "enhancedPrompt"
- | "draggedImages"
- | "deleteMessage"
- | "deleteMessageConfirm"
- | "submitEditedMessage"
- | "editMessageConfirm"
- | "enableMcpServerCreation"
- | "remoteControlEnabled"
- | "taskSyncEnabled"
- | "searchCommits"
- | "setApiConfigPassword"
- | "mode"
- | "updatePrompt"
- | "getSystemPrompt"
- | "copySystemPrompt"
- | "systemPrompt"
- | "enhancementApiConfigId"
- | "commitMessageApiConfigId" // kilocode_change
- | "terminalCommandApiConfigId" // kilocode_change
- | "ghostServiceSettings" // kilocode_change
- | "stt:start" // kilocode_change: Start STT recording
- | "stt:stop" // kilocode_change: Stop STT recording
- | "stt:cancel" // kilocode_change: Cancel STT recording
- | "stt:checkAvailability" // kilocode_change: Check STT availability on demand
- | "stt:listDevices" // kilocode_change: List microphone devices
- | "stt:selectDevice" // kilocode_change: Select microphone device
- | "includeTaskHistoryInEnhance" // kilocode_change
- | "snoozeAutocomplete" // kilocode_change
- | "autoApprovalEnabled"
- | "yoloMode" // kilocode_change
- | "updateCustomMode"
- | "deleteCustomMode"
- | "setopenAiCustomModelInfo"
- | "openCustomModesSettings"
- | "checkpointDiff"
- | "checkpointRestore"
- | "requestCheckpointRestoreApproval"
- | "seeNewChanges" // kilocode_change
- | "deleteMcpServer"
- | "insertTextToChatArea" // kilocode_change
- | "humanRelayResponse"
- | "humanRelayCancel"
- | "codebaseIndexEnabled"
- | "telemetrySetting"
- | "testBrowserConnection"
- | "browserConnectionResult"
- | "allowVeryLargeReads" // kilocode_change
- | "showFeedbackOptions" // kilocode_change
- | "fetchMcpMarketplace" // kilocode_change
- | "silentlyRefreshMcpMarketplace" // kilocode_change
- | "fetchLatestMcpServersFromHub" // kilocode_change
- | "downloadMcp" // kilocode_change
- | "showSystemNotification" // kilocode_change
- | "showAutoApproveMenu" // kilocode_change
- | "reportBug" // kilocode_change
- | "profileButtonClicked" // kilocode_change
- | "fetchProfileDataRequest" // kilocode_change
- | "profileDataResponse" // kilocode_change
- | "fetchBalanceDataRequest" // kilocode_change
- | "shopBuyCredits" // kilocode_change
- | "balanceDataResponse" // kilocode_change
- | "updateProfileData" // kilocode_change
- | "condense" // kilocode_change
- | "toggleWorkflow" // kilocode_change
- | "refreshRules" // kilocode_change
- | "refreshSkills" // kilocode_change
- | "toggleRule" // kilocode_change
- | "createRuleFile" // kilocode_change
- | "deleteRuleFile" // kilocode_change
- | "searchFiles"
- | "toggleApiConfigPin"
- | "hasOpenedModeSelector"
- | "clearCloudAuthSkipModel"
- | "cloudButtonClicked"
- | "rooCloudSignIn"
- | "cloudLandingPageSignIn"
- | "rooCloudSignOut"
- | "rooCloudManualUrl"
- | "claudeCodeSignIn"
- | "claudeCodeSignOut"
- | "openAiCodexSignIn"
- | "openAiCodexSignOut"
- | "switchOrganization"
- | "condenseTaskContextRequest"
- | "requestIndexingStatus"
- | "startIndexing"
- | "cancelIndexing" // kilocode_change
- | "clearIndexData"
- | "indexingStatusUpdate"
- | "indexCleared"
- | "focusPanelRequest"
- | "clearUsageData" // kilocode_change
- | "getUsageData" // kilocode_change
- | "usageDataResponse" // kilocode_change
- | "showTaskTimeline" // kilocode_change
- | "sendMessageOnEnter" // kilocode_change
- | "showTimestamps" // kilocode_change
- | "showDiffStats" // kilocode_change
- | "hideCostBelowThreshold" // kilocode_change
- | "toggleTaskFavorite" // kilocode_change
- | "fixMermaidSyntax" // kilocode_change
- | "mermaidFixResponse" // kilocode_change
- | "openGlobalKeybindings" // kilocode_change
- | "getKeybindings" // kilocode_change
- | "setReasoningBlockCollapsed"
- | "setHistoryPreviewCollapsed" // kilocode_change
- | "openExternal"
- | "filterMarketplaceItems"
- | "marketplaceButtonClicked"
- | "installMarketplaceItem"
- | "installMarketplaceItemWithParameters"
- | "cancelMarketplaceInstall"
- | "removeInstalledMarketplaceItem"
- | "marketplaceInstallResult"
- | "fetchMarketplaceData"
- | "switchTab"
- | "profileThresholds" // kilocode_change
- | "editMessage" // kilocode_change
- | "systemNotificationsEnabled" // kilocode_change
- | "dismissNotificationId" // kilocode_change
- | "tasksByIdRequest" // kilocode_change
- | "taskHistoryRequest" // kilocode_change
- | "updateGlobalState" // kilocode_change
- | "autoPurgeEnabled" // kilocode_change
- | "autoPurgeDefaultRetentionDays" // kilocode_change
- | "autoPurgeFavoritedTaskRetentionDays" // kilocode_change
- | "autoPurgeCompletedTaskRetentionDays" // kilocode_change
- | "autoPurgeIncompleteTaskRetentionDays" // kilocode_change
- | "manualPurge" // kilocode_change
- | "shareTaskSuccess" // kilocode_change
- | "exportMode"
- | "exportModeResult"
- | "importMode"
- | "importModeResult"
- | "checkRulesDirectory"
- | "checkRulesDirectoryResult"
- | "saveCodeIndexSettingsAtomic"
- | "requestCodeIndexSecretStatus"
- | "fetchKilocodeNotifications"
- | "requestCommands"
- | "openCommandFile"
- | "deleteCommand"
- | "createCommand"
- | "insertTextIntoTextarea"
- | "showMdmAuthRequiredNotification"
- | "imageGenerationSettings"
- | "kiloCodeImageApiKey" // kilocode_change
- | "queueMessage"
- | "removeQueuedMessage"
- | "editQueuedMessage"
- | "dismissUpsell"
- | "getDismissedUpsells"
- | "updateSettings"
- | "requestManagedIndexerState" // kilocode_change
- | "allowedCommands"
- | "deniedCommands"
- | "killBrowserSession"
- | "openBrowserSessionPanel"
- | "showBrowserSessionPanelAtStep"
- | "refreshBrowserSessionPanel"
- | "browserPanelDidLaunch"
- | "addTaskToHistory" // kilocode_change
- | "sessionShare" // kilocode_change
- | "shareTaskSession" // kilocode_change
- | "sessionFork" // kilocode_change
- | "sessionShow" // kilocode_change
- | "sessionSelect" // kilocode_change
- | "singleCompletion" // kilocode_change
- | "openDebugApiHistory"
- | "openDebugUiHistory"
- | "startDeviceAuth" // kilocode_change: Start device auth flow
- | "cancelDeviceAuth" // kilocode_change: Cancel device auth flow
- | "deviceAuthCompleteWithProfile" // kilocode_change: Device auth complete with specific profile
- | "requestChatCompletion" // kilocode_change: Request FIM completion for chat text area
- | "chatCompletionAccepted" // kilocode_change: User accepted a chat completion suggestion
- | "downloadErrorDiagnostics"
- | "requestClaudeCodeRateLimits"
- | "refreshCustomTools"
- text?: string
- suggestionLength?: number // kilocode_change: Length of accepted suggestion for telemetry
- completionRequestId?: string // kilocode_change
- shareId?: string // kilocode_change - for sessionFork
- sessionId?: string // kilocode_change - for sessionSelect
- editedMessageContent?: string
- tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "cloud" | "auth" | "skills" // kilocode_change
- disabled?: boolean
- context?: string
- dataUri?: string
- askResponse?: ClineAskResponse
- apiConfiguration?: ProviderSettings
- images?: string[]
- bool?: boolean
- value?: number
- stepIndex?: number
- isLaunchAction?: boolean
- forceShow?: boolean
- commands?: string[]
- audioType?: AudioType
- // kilocode_change begin
- notificationOptions?: {
- title?: string
- subtitle?: string
- message: string
- }
- mcpId?: string
- toolNames?: string[]
- autoApprove?: boolean
- workflowPath?: string // kilocode_change
- enabled?: boolean // kilocode_change
- rulePath?: string // kilocode_change
- isGlobal?: boolean // kilocode_change
- filename?: string // kilocode_change
- ruleType?: string // kilocode_change
- notificationId?: string // kilocode_change
- commandIds?: string[] // kilocode_change: For getKeybindings
- // kilocode_change end
- serverName?: string
- toolName?: string
- alwaysAllow?: boolean
- isEnabled?: boolean
- mode?: Mode
- promptMode?: PromptMode
- customPrompt?: PromptComponent
- dataUrls?: string[]
- values?: Record<string, any>
- query?: string
- setting?: string
- slug?: string
- language?: string // User's language for speech transcription (STT)
- device?: MicrophoneDevice | null // kilocode_change: Microphone device for stt:selectDevice
- modeConfig?: ModeConfig
- timeout?: number
- payload?: WebViewMessagePayload
- source?: "global" | "project"
- requestId?: string
- ids?: string[]
- hasSystemPromptOverride?: boolean
- terminalOperation?: "continue" | "abort"
- messageTs?: number
- restoreCheckpoint?: boolean
- historyPreviewCollapsed?: boolean
- filters?: { type?: string; search?: string; tags?: string[] }
- settings?: any
- url?: string // For openExternal
- mpItem?: MarketplaceItem
- mpInstallOptions?: InstallMarketplaceItemOptions
- config?: Record<string, any> // Add config to the payload
- visibility?: ShareVisibility // For share visibility
- hasContent?: boolean // For checkRulesDirectoryResult
- checkOnly?: boolean // For deleteCustomMode check
- upsellId?: string // For dismissUpsell
- list?: string[] // For dismissedUpsells response
- organizationId?: string | null // For organization switching
- useProviderSignup?: boolean // For rooCloudSignIn to use provider signup flow
- historyItem?: HistoryItem // kilocode_change For addTaskToHistory
- codeIndexSettings?: {
- // Global state settings
- codebaseIndexEnabled: boolean
- codebaseIndexQdrantUrl: string
- codebaseIndexEmbedderProvider:
- | "openai"
- | "ollama"
- | "openai-compatible"
- | "gemini"
- | "mistral"
- | "vercel-ai-gateway"
- | "bedrock"
- | "openrouter"
- codebaseIndexVectorStoreProvider?: "lancedb" | "qdrant" // kilocode_change
- codebaseIndexLancedbVectorStoreDirectory?: string // kilocode_change
- codebaseIndexEmbedderBaseUrl?: string
- codebaseIndexEmbedderModelId: string
- codebaseIndexEmbedderModelDimension?: number // Generic dimension for all providers
- codebaseIndexOpenAiCompatibleBaseUrl?: string
- codebaseIndexBedrockRegion?: string
- codebaseIndexBedrockProfile?: string
- codebaseIndexSearchMaxResults?: number
- codebaseIndexSearchMinScore?: number
- // kilocode_change start
- codebaseIndexEmbeddingBatchSize?: number
- codebaseIndexScannerMaxBatchRetries?: number
- // kilocode_change end
- codebaseIndexOpenRouterSpecificProvider?: string // OpenRouter provider routing
- // Secret settings
- codeIndexOpenAiKey?: string
- codeIndexQdrantApiKey?: string
- codebaseIndexOpenAiCompatibleApiKey?: string
- codebaseIndexGeminiApiKey?: string
- codebaseIndexMistralApiKey?: string
- codebaseIndexVercelAiGatewayApiKey?: string
- codebaseIndexOpenRouterApiKey?: string
- }
- updatedSettings?: RooCodeSettings
- }
- // kilocode_change: Create discriminated union for type-safe messages
- export type MaybeTypedWebviewMessage = WebviewMessage | UpdateGlobalStateMessage
- // kilocode_change begin
- export type OrganizationRole = "owner" | "admin" | "member"
- export type UserOrganizationWithApiKey = {
- id: string
- name: string
- balance: number
- role: OrganizationRole
- apiKey: string
- }
- export type ProfileData = {
- kilocodeToken: string
- user: {
- id: string
- name: string
- email: string
- image: string
- }
- organizations?: UserOrganizationWithApiKey[]
- }
- export interface ProfileDataResponsePayload {
- success: boolean
- data?: ProfileData
- error?: string
- }
- export interface BalanceDataResponsePayload {
- // New: Payload for balance data
- success: boolean
- data?: any // Replace 'any' with a more specific type if known for balance
- error?: string
- }
- export interface SeeNewChangesPayload {
- commitRange: CommitRange
- }
- export interface TasksByIdRequestPayload {
- requestId: string
- taskIds: string[]
- }
- export interface TaskHistoryRequestPayload {
- requestId: string
- workspace: "current" | "all"
- sort: "newest" | "oldest" | "mostExpensive" | "mostTokens" | "mostRelevant"
- favoritesOnly: boolean
- pageIndex: number
- search?: string
- }
- export interface TasksByIdResponsePayload {
- requestId: string
- tasks: HistoryItem[]
- }
- export interface TaskHistoryResponsePayload {
- requestId: string
- historyItems: HistoryItem[]
- pageIndex: number
- pageCount: number
- }
- // kilocode_change end
- export const checkoutDiffPayloadSchema = z.object({
- ts: z.number().optional(),
- previousCommitHash: z.string().optional(),
- commitHash: z.string(),
- mode: z.enum(["full", "checkpoint", "from-init", "to-current"]),
- })
- export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
- export const checkoutRestorePayloadSchema = z.object({
- ts: z.number(),
- commitHash: z.string(),
- mode: z.enum(["preview", "restore"]),
- })
- export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
- export const requestCheckpointRestoreApprovalPayloadSchema = z.object({
- commitHash: z.string(),
- checkpointTs: z.number(),
- messagesToRemove: z.number(),
- confirmationText: z.string(),
- })
- export type RequestCheckpointRestoreApprovalPayload = z.infer<typeof requestCheckpointRestoreApprovalPayloadSchema>
- export interface IndexingStatusPayload {
- state: "Standby" | "Indexing" | "Indexed" | "Error"
- message: string
- }
- export interface IndexClearedPayload {
- success: boolean
- error?: string
- }
- export const installMarketplaceItemWithParametersPayloadSchema = z.object({
- item: marketplaceItemSchema,
- parameters: z.record(z.string(), z.any()),
- })
- export type InstallMarketplaceItemWithParametersPayload = z.infer<
- typeof installMarketplaceItemWithParametersPayloadSchema
- >
- export type WebViewMessagePayload =
- // kilocode_change start
- | ProfileDataResponsePayload
- | BalanceDataResponsePayload
- | SeeNewChangesPayload
- | TasksByIdRequestPayload
- | TaskHistoryRequestPayload
- | RequestCheckpointRestoreApprovalPayload
- // kilocode_change end
- | CheckpointDiffPayload
- | CheckpointRestorePayload
- | IndexingStatusPayload
- | IndexClearedPayload
- | InstallMarketplaceItemWithParametersPayload
- | UpdateTodoListPayload
- | EditQueuedMessagePayload
|