@@ -20,11 +20,18 @@ 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+ researchTaskPayloadSchema ,
27+ researchInputPayloadSchema ,
28+ WebviewMessage ,
29+ } from "../../shared/WebviewMessage"
2430import { Mode , CustomModePrompts , PromptComponent , defaultModeSlug } from "../../shared/modes"
2531import { SYSTEM_PROMPT } from "../prompts/system"
2632import { fileExistsAtPath } from "../../utils/fs"
2733import { Cline } from "../Cline"
34+ import { DeepResearchService } from "../../services/deep-research/DeepResearchService"
2835import { openMention } from "../mentions"
2936import { getNonce } from "./getNonce"
3037import { getUri } from "./getUri"
@@ -40,11 +47,10 @@ import { CustomSupportPrompts, supportPrompt } from "../../shared/support-prompt
4047import { ACTION_NAMES } from "../CodeActionProvider"
4148import { McpServerManager } from "../../services/mcp/McpServerManager"
4249
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- */
50+ /**
51+ * https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
52+ * https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
53+ */
4854
4955type SecretKey =
5056 | "apiKey"
@@ -60,6 +66,8 @@ type SecretKey =
6066 | "mistralApiKey"
6167 | "unboundApiKey"
6268 | "requestyApiKey"
69+ | "firecrawlApiKey"
70+
6371type GlobalStateKey =
6472 | "apiProvider"
6573 | "apiModelId"
@@ -148,6 +156,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
148156 private view ?: vscode . WebviewView | vscode . WebviewPanel
149157 private isViewLaunched = false
150158 private cline ?: Cline
159+ private deepResearchService ?: DeepResearchService
151160 private workspaceTracker ?: WorkspaceTracker
152161 protected mcpHub ?: McpHub // Change from private to protected
153162 private latestAnnouncementId = "jan-21-2025-custom-modes" // update to some unique identifier when we add a new announcement
@@ -160,6 +169,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
160169 ) {
161170 this . outputChannel . appendLine ( "ClineProvider instantiated" )
162171 ClineProvider . activeInstances . add ( this )
172+
163173 this . workspaceTracker = new WorkspaceTracker ( this )
164174 this . configManager = new ConfigManager ( this . context )
165175 this . customModesManager = new CustomModesManager ( this . context , async ( ) => {
@@ -1495,10 +1505,59 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14951505 }
14961506
14971507 await this . customModesManager . deleteCustomMode ( message . slug )
1498- // Switch back to default mode after deletion
1508+ // Switch back to default mode after deletion.
14991509 await this . updateGlobalState ( "mode" , defaultModeSlug )
15001510 await this . postStateToWebview ( )
15011511 }
1512+ break
1513+ case "research.task" : {
1514+ const result = researchTaskPayloadSchema . safeParse ( message . payload )
1515+
1516+ if ( ! result . success ) {
1517+ console . warn (
1518+ `[ClineProvider#research.task] Invalid payload: ${ JSON . stringify ( message . payload ) } ` ,
1519+ )
1520+ break
1521+ }
1522+
1523+ if ( result . success && ! this . deepResearchService ) {
1524+ const { session } = result . data
1525+ this . deepResearchService = new DeepResearchService ( session , this )
1526+ this . deepResearchService . input ( session . query )
1527+ }
1528+
1529+ break
1530+ }
1531+ case "research.input" : {
1532+ const result = researchInputPayloadSchema . safeParse ( message . payload )
1533+
1534+ if ( ! result . success ) {
1535+ console . warn (
1536+ `[ClineProvider#research.input] Invalid payload: ${ JSON . stringify ( message . payload ) } ` ,
1537+ )
1538+ break
1539+ }
1540+
1541+ if ( result . success && this . deepResearchService ) {
1542+ const { content } = result . data . message
1543+ this . deepResearchService . input ( content )
1544+ }
1545+
1546+ break
1547+ }
1548+ case "research.viewReport" :
1549+ this . deepResearchService ?. viewReport ( )
1550+ break
1551+ case "research.createTask" :
1552+ this . deepResearchService ?. createTask ( )
1553+ break
1554+ case "research.abort" :
1555+ this . deepResearchService ?. abort ( )
1556+ break
1557+ case "research.reset" :
1558+ this . deepResearchService ?. abort ( )
1559+ this . deepResearchService = undefined
1560+ break
15021561 }
15031562 } ,
15041563 null ,
@@ -1646,6 +1705,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16461705 requestyModelId,
16471706 requestyModelInfo,
16481707 modelTemperature,
1708+ firecrawlApiKey,
16491709 } = apiConfiguration
16501710 await this . updateGlobalState ( "apiProvider" , apiProvider )
16511711 await this . updateGlobalState ( "apiModelId" , apiModelId )
@@ -1692,6 +1752,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16921752 await this . updateGlobalState ( "requestyModelId" , requestyModelId )
16931753 await this . updateGlobalState ( "requestyModelInfo" , requestyModelInfo )
16941754 await this . updateGlobalState ( "modelTemperature" , modelTemperature )
1755+ await this . storeSecret ( "firecrawlApiKey" , firecrawlApiKey )
16951756 if ( this . cline ) {
16961757 this . cline . api = buildApiHandler ( apiConfiguration )
16971758 }
@@ -2575,6 +2636,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25752636 requestyModelInfo ,
25762637 modelTemperature ,
25772638 maxOpenTabsContext ,
2639+ firecrawlApiKey ,
25782640 ] = await Promise . all ( [
25792641 this . getGlobalState ( "apiProvider" ) as Promise < ApiProvider | undefined > ,
25802642 this . getGlobalState ( "apiModelId" ) as Promise < string | undefined > ,
@@ -2657,6 +2719,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
26572719 this . getGlobalState ( "requestyModelInfo" ) as Promise < ModelInfo | undefined > ,
26582720 this . getGlobalState ( "modelTemperature" ) as Promise < number | undefined > ,
26592721 this . getGlobalState ( "maxOpenTabsContext" ) as Promise < number | undefined > ,
2722+ this . getSecret ( "firecrawlApiKey" ) as Promise < string | undefined > ,
26602723 ] )
26612724
26622725 let apiProvider : ApiProvider
@@ -2720,6 +2783,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
27202783 requestyModelId,
27212784 requestyModelInfo,
27222785 modelTemperature,
2786+ firecrawlApiKey,
27232787 } ,
27242788 lastShownAnnouncementId,
27252789 customInstructions,
@@ -2875,6 +2939,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
28752939 "mistralApiKey" ,
28762940 "unboundApiKey" ,
28772941 "requestyApiKey" ,
2942+ "firecrawlApiKey" ,
28782943 ]
28792944 for ( const key of secretKeys ) {
28802945 await this . storeSecret ( key , undefined )
0 commit comments