@@ -20,11 +20,17 @@ import { ApiConfiguration, ApiProvider, ModelInfo } from "../../shared/api"
2020import { findLast } from "../../shared/array"
2121import { ApiConfigMeta , ExtensionMessage } from "../../shared/ExtensionMessage"
2222import { HistoryItem } from "../../shared/HistoryItem"
23- import { checkoutDiffPayloadSchema , checkoutRestorePayloadSchema , WebviewMessage } from "../../shared/WebviewMessage"
23+ import {
24+ checkoutDiffPayloadSchema ,
25+ checkoutRestorePayloadSchema ,
26+ researchAppendPayloadSchema ,
27+ WebviewMessage ,
28+ } from "../../shared/WebviewMessage"
2429import { Mode , CustomModePrompts , PromptComponent , defaultModeSlug } from "../../shared/modes"
2530import { SYSTEM_PROMPT } from "../prompts/system"
2631import { fileExistsAtPath } from "../../utils/fs"
2732import { Cline } from "../Cline"
33+ import { DeepResearchService } from "../../services/deep-research/DeepResearchService"
2834import { openMention } from "../mentions"
2935import { getNonce } from "./getNonce"
3036import { getUri } from "./getUri"
@@ -40,11 +46,10 @@ import { CustomSupportPrompts, supportPrompt } from "../../shared/support-prompt
4046import { ACTION_NAMES } from "../CodeActionProvider"
4147import { McpServerManager } from "../../services/mcp/McpServerManager"
4248
43- /*
44- https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
45-
46- https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
47- */
49+ /**
50+ * https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
51+ * https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
52+ */
4853
4954type SecretKey =
5055 | "apiKey"
@@ -60,6 +65,7 @@ type SecretKey =
6065 | "mistralApiKey"
6166 | "unboundApiKey"
6267 | "requestyApiKey"
68+
6369type GlobalStateKey =
6470 | "apiProvider"
6571 | "apiModelId"
@@ -146,6 +152,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
146152 private view ?: vscode . WebviewView | vscode . WebviewPanel
147153 private isViewLaunched = false
148154 private cline ?: Cline
155+ private deepResearchService ?: DeepResearchService
149156 private workspaceTracker ?: WorkspaceTracker
150157 protected mcpHub ?: McpHub // Change from private to protected
151158 private latestAnnouncementId = "jan-21-2025-custom-modes" // update to some unique identifier when we add a new announcement
@@ -158,6 +165,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
158165 ) {
159166 this . outputChannel . appendLine ( "ClineProvider instantiated" )
160167 ClineProvider . activeInstances . add ( this )
168+
161169 this . workspaceTracker = new WorkspaceTracker ( this )
162170 this . configManager = new ConfigManager ( this . context )
163171 this . customModesManager = new CustomModesManager ( this . context , async ( ) => {
@@ -1515,10 +1523,43 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15151523 }
15161524
15171525 await this . customModesManager . deleteCustomMode ( message . slug )
1518- // Switch back to default mode after deletion
1526+ // Switch back to default mode after deletion.
15191527 await this . updateGlobalState ( "mode" , defaultModeSlug )
15201528 await this . postStateToWebview ( )
15211529 }
1530+ break
1531+
1532+ case "research.start" : {
1533+ const result = researchAppendPayloadSchema . safeParse ( message . payload )
1534+ console . log ( "[ClineProvider] research.start" , result )
1535+
1536+ if ( result . success ) {
1537+ if ( this . deepResearchService ) {
1538+ await this . deepResearchService . abort ( )
1539+ }
1540+
1541+ this . deepResearchService = new DeepResearchService ( this , "o3-mini" , 4 , 2 , 2 )
1542+ this . deepResearchService . start ( result . data . message . content )
1543+ }
1544+
1545+ break
1546+ }
1547+ case "research.append" : {
1548+ const result = researchAppendPayloadSchema . safeParse ( message . payload )
1549+ console . log ( "[ClineProvider] research.append" , result )
1550+
1551+ if ( result . success && this . deepResearchService ) {
1552+ this . deepResearchService . append ( result . data . message . content )
1553+ }
1554+
1555+ break
1556+ }
1557+ case "research.reload" :
1558+ console . log ( "[ClineProvider] research.reload" , message )
1559+ break
1560+ case "research.stop" :
1561+ console . log ( "[ClineProvider] research.stop" , message )
1562+ break
15221563 }
15231564 } ,
15241565 null ,
0 commit comments