@@ -39,7 +39,7 @@ import { DEFAULT_EDITOR_ASSOCIATION, SaveReason } from 'vs/workbench/common/edit
39
39
import { IViewBadge } from 'vs/workbench/common/views' ;
40
40
import { ChatAgentLocation , IChatAgentRequest , IChatAgentResult } from 'vs/workbench/contrib/chat/common/chatAgents' ;
41
41
import { IChatRequestVariableEntry } from 'vs/workbench/contrib/chat/common/chatModel' ;
42
- import { IChatCommandButton , IChatContentInlineReference , IChatContentReference , IChatFollowup , IChatMarkdownContent , IChatProgressMessage , IChatTextEdit , IChatTreeData , IChatUserActionEvent } from 'vs/workbench/contrib/chat/common/chatService' ;
42
+ import { IChatAgentDetection , IChatAgentMarkdownContentWithVulnerability , IChatCommandButton , IChatContentInlineReference , IChatContentReference , IChatFollowup , IChatMarkdownContent , IChatProgressMessage , IChatTextEdit , IChatTreeData , IChatUserActionEvent } from 'vs/workbench/contrib/chat/common/chatService' ;
43
43
import { IChatRequestVariableValue } from 'vs/workbench/contrib/chat/common/chatVariables' ;
44
44
import * as chatProvider from 'vs/workbench/contrib/chat/common/languageModels' ;
45
45
import { DebugTreeItemCollapsibleState , IDebugVisualizationTreeItem } from 'vs/workbench/contrib/debug/common/debug' ;
@@ -51,7 +51,6 @@ import { TestId } from 'vs/workbench/contrib/testing/common/testId';
51
51
import { CoverageDetails , DetailType , ICoverageCount , IFileCoverage , ISerializedTestResults , ITestErrorMessage , ITestItem , ITestTag , TestMessageType , TestResultItem , denamespaceTestTag , namespaceTestTag } from 'vs/workbench/contrib/testing/common/testTypes' ;
52
52
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn' ;
53
53
import { ACTIVE_GROUP , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
54
- import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions' ;
55
54
import { Dto } from 'vs/workbench/services/extensions/common/proxyIdentifier' ;
56
55
import type * as vscode from 'vscode' ;
57
56
import * as types from './extHostTypes' ;
@@ -2361,6 +2360,32 @@ export namespace ChatResponseMarkdownPart {
2361
2360
}
2362
2361
}
2363
2362
2363
+ export namespace ChatResponseMarkdownWithVulnerabilitiesPart {
2364
+ export function from ( part : vscode . ChatResponseMarkdownWithVulnerabilitiesPart ) : Dto < IChatAgentMarkdownContentWithVulnerability > {
2365
+ return {
2366
+ kind : 'markdownVuln' ,
2367
+ content : MarkdownString . from ( part . value ) ,
2368
+ vulnerabilities : part . vulnerabilities ,
2369
+ } ;
2370
+ }
2371
+ export function to ( part : Dto < IChatAgentMarkdownContentWithVulnerability > ) : vscode . ChatResponseMarkdownWithVulnerabilitiesPart {
2372
+ return new types . ChatResponseMarkdownWithVulnerabilitiesPart ( MarkdownString . to ( part . content ) , part . vulnerabilities ) ;
2373
+ }
2374
+ }
2375
+
2376
+ export namespace ChatResponseDetectedParticipantPart {
2377
+ export function from ( part : vscode . ChatResponseDetectedParticipantPart ) : Dto < IChatAgentDetection > {
2378
+ return {
2379
+ kind : 'agentDetection' ,
2380
+ agentId : part . participant ,
2381
+ command : part . command ,
2382
+ } ;
2383
+ }
2384
+ export function to ( part : Dto < IChatAgentDetection > ) : vscode . ChatResponseDetectedParticipantPart {
2385
+ return new types . ChatResponseDetectedParticipantPart ( part . agentId , part . command ) ;
2386
+ }
2387
+ }
2388
+
2364
2389
export namespace ChatResponseFilesPart {
2365
2390
export function from ( part : vscode . ChatResponseFileTreePart ) : IChatTreeData {
2366
2391
const { value, baseUri } = part ;
@@ -2499,7 +2524,7 @@ export namespace ChatResponseReferencePart {
2499
2524
2500
2525
export namespace ChatResponsePart {
2501
2526
2502
- export function from ( part : vscode . ChatResponsePart | vscode . ChatResponseTextEditPart , commandsConverter : CommandsConverter , commandDisposables : DisposableStore ) : extHostProtocol . IChatProgressDto {
2527
+ export function from ( part : vscode . ChatResponsePart | vscode . ChatResponseTextEditPart | vscode . ChatResponseMarkdownWithVulnerabilitiesPart | vscode . ChatResponseDetectedParticipantPart , commandsConverter : CommandsConverter , commandDisposables : DisposableStore ) : extHostProtocol . IChatProgressDto {
2503
2528
if ( part instanceof types . ChatResponseMarkdownPart ) {
2504
2529
return ChatResponseMarkdownPart . from ( part ) ;
2505
2530
} else if ( part instanceof types . ChatResponseAnchorPart ) {
@@ -2514,12 +2539,16 @@ export namespace ChatResponsePart {
2514
2539
return ChatResponseCommandButtonPart . from ( part , commandsConverter , commandDisposables ) ;
2515
2540
} else if ( part instanceof types . ChatResponseTextEditPart ) {
2516
2541
return ChatResponseTextEditPart . from ( part ) ;
2542
+ } else if ( part instanceof types . ChatResponseMarkdownWithVulnerabilitiesPart ) {
2543
+ return ChatResponseMarkdownWithVulnerabilitiesPart . from ( part ) ;
2544
+ } else if ( part instanceof types . ChatResponseDetectedParticipantPart ) {
2545
+ return ChatResponseDetectedParticipantPart . from ( part ) ;
2517
2546
}
2547
+
2518
2548
return {
2519
- kind : 'content ' ,
2520
- content : ''
2549
+ kind : 'markdownContent ' ,
2550
+ content : MarkdownString . from ( '' )
2521
2551
} ;
2522
-
2523
2552
}
2524
2553
2525
2554
export function to ( part : extHostProtocol . IChatProgressDto , commandsConverter : CommandsConverter ) : vscode . ChatResponsePart | undefined {
@@ -2548,86 +2577,6 @@ export namespace ChatResponsePart {
2548
2577
}
2549
2578
}
2550
2579
2551
- export namespace ChatResponseProgress {
2552
- export function from ( extension : IExtensionDescription , progress : vscode . ChatExtendedProgress ) : extHostProtocol . IChatProgressDto | undefined {
2553
- if ( 'markdownContent' in progress ) {
2554
- checkProposedApiEnabled ( extension , 'chatParticipantAdditions' ) ;
2555
- return { content : MarkdownString . from ( progress . markdownContent ) , kind : 'markdownContent' } ;
2556
- } else if ( 'content' in progress ) {
2557
- if ( 'vulnerabilities' in progress && progress . vulnerabilities ) {
2558
- checkProposedApiEnabled ( extension , 'chatParticipantAdditions' ) ;
2559
- return { content : progress . content , vulnerabilities : progress . vulnerabilities , kind : 'vulnerability' } ;
2560
- }
2561
-
2562
- if ( typeof progress . content === 'string' ) {
2563
- return { content : progress . content , kind : 'content' } ;
2564
- }
2565
-
2566
- checkProposedApiEnabled ( extension , 'chatParticipantAdditions' ) ;
2567
- return { content : MarkdownString . from ( progress . content ) , kind : 'markdownContent' } ;
2568
- } else if ( 'documents' in progress ) {
2569
- return {
2570
- documents : progress . documents . map ( d => ( {
2571
- uri : d . uri ,
2572
- version : d . version ,
2573
- ranges : d . ranges . map ( r => Range . from ( r ) )
2574
- } ) ) ,
2575
- kind : 'usedContext'
2576
- } ;
2577
- } else if ( 'reference' in progress ) {
2578
- return {
2579
- reference : 'uri' in progress . reference ?
2580
- {
2581
- uri : progress . reference . uri ,
2582
- range : Range . from ( progress . reference . range )
2583
- } : progress . reference ,
2584
- kind : 'reference'
2585
- } ;
2586
- } else if ( 'inlineReference' in progress ) {
2587
- return {
2588
- inlineReference : 'uri' in progress . inlineReference ?
2589
- {
2590
- uri : progress . inlineReference . uri ,
2591
- range : Range . from ( progress . inlineReference . range )
2592
- } : progress . inlineReference ,
2593
- name : progress . title ,
2594
- kind : 'inlineReference'
2595
- } ;
2596
- } else if ( 'participant' in progress ) {
2597
- checkProposedApiEnabled ( extension , 'chatParticipantAdditions' ) ;
2598
- return { agentId : progress . participant , command : progress . command , kind : 'agentDetection' } ;
2599
- } else if ( 'message' in progress ) {
2600
- return { content : MarkdownString . from ( progress . message ) , kind : 'progressMessage' } ;
2601
- } else {
2602
- return undefined ;
2603
- }
2604
- }
2605
-
2606
- export function toProgressContent ( progress : extHostProtocol . IChatContentProgressDto , commandsConverter : Command . ICommandsConverter ) : vscode . ChatContentProgress | undefined {
2607
- switch ( progress . kind ) {
2608
- case 'markdownContent' :
2609
- // For simplicity, don't sent back the 'extended' types, so downgrade markdown to just some text
2610
- return { content : progress . content . value } ;
2611
- case 'inlineReference' :
2612
- return {
2613
- inlineReference :
2614
- isUriComponents ( progress . inlineReference ) ?
2615
- URI . revive ( progress . inlineReference ) :
2616
- Location . to ( progress . inlineReference ) ,
2617
- title : progress . name
2618
- } ;
2619
- case 'command' :
2620
- // If the command isn't in the converter, then this session may have been restored, and the command args don't exist anymore
2621
- return {
2622
- command : commandsConverter . fromInternal ( progress . command ) ?? { command : progress . command . id , title : progress . command . title } ,
2623
- } ;
2624
- default :
2625
- // Unknown type, eg something in history that was removed? Ignore
2626
- return undefined ;
2627
- }
2628
- }
2629
- }
2630
-
2631
2580
export namespace ChatAgentRequest {
2632
2581
export function to ( request : IChatAgentRequest ) : vscode . ChatRequest {
2633
2582
return {
@@ -2692,7 +2641,11 @@ export namespace ChatAgentUserActionEvent {
2692
2641
2693
2642
const ehResult = ChatAgentResult . to ( result ) ;
2694
2643
if ( event . action . kind === 'command' ) {
2695
- const commandAction : vscode . ChatCommandAction = { kind : 'command' , commandButton : ChatResponseProgress . toProgressContent ( event . action . commandButton , commandsConverter ) as vscode . ChatCommandButton } ;
2644
+ const command = event . action . commandButton . command ;
2645
+ const commandButton = {
2646
+ command : commandsConverter . fromInternal ( command ) ?? { command : command . id , title : command . title } ,
2647
+ } ;
2648
+ const commandAction : vscode . ChatCommandAction = { kind : 'command' , commandButton } ;
2696
2649
return { action : commandAction , result : ehResult } ;
2697
2650
} else if ( event . action . kind === 'followUp' ) {
2698
2651
const followupAction : vscode . ChatFollowupAction = { kind : 'followUp' , followup : ChatFollowup . to ( event . action . followup ) } ;
0 commit comments