@@ -41,7 +41,7 @@ import { IViewBadge } from '../../common/views.js';
41
41
import { IChatAgentRequest , IChatAgentResult } from '../../contrib/chat/common/chatAgents.js' ;
42
42
import { IChatRequestDraft } from '../../contrib/chat/common/chatEditingService.js' ;
43
43
import { IChatRequestVariableEntry , isImageVariableEntry } from '../../contrib/chat/common/chatVariableEntries.js' ;
44
- import { IChatAgentMarkdownContentWithVulnerability , IChatCodeCitation , IChatCommandButton , IChatConfirmation , IChatContentInlineReference , IChatContentReference , IChatExtensionsContent , IChatFollowup , IChatMarkdownContent , IChatMoveMessage , IChatPrepareToolInvocationPart , IChatProgressMessage , IChatResponseCodeblockUriPart , IChatTaskDto , IChatTaskResult , IChatTextEdit , IChatTreeData , IChatUserActionEvent , IChatWarningMessage } from '../../contrib/chat/common/chatService.js' ;
44
+ import { IChatAgentMarkdownContentWithVulnerability , IChatCodeCitation , IChatCommandButton , IChatConfirmation , IChatContentInlineReference , IChatContentReference , IChatExtensionsContent , IChatFollowup , IChatMarkdownContent , IChatMoveMessage , IChatPrepareToolInvocationPart , IChatProgressMessage , IChatPullRequestContent , IChatResponseCodeblockUriPart , IChatTaskDto , IChatTaskResult , IChatTextEdit , IChatTreeData , IChatUserActionEvent , IChatWarningMessage } from '../../contrib/chat/common/chatService.js' ;
45
45
import { IToolResult , IToolResultInputOutputDetails , IToolResultOutputDetails , ToolDataSource } from '../../contrib/chat/common/languageModelToolsService.js' ;
46
46
import * as chatProvider from '../../contrib/chat/common/languageModels.js' ;
47
47
import { IChatMessageDataPart , IChatResponseDataPart , IChatResponsePromptTsxPart , IChatResponseTextPart } from '../../contrib/chat/common/languageModels.js' ;
@@ -2316,11 +2316,11 @@ export namespace LanguageModelChatMessage {
2316
2316
export function to ( message : chatProvider . IChatMessage ) : vscode . LanguageModelChatMessage {
2317
2317
const content = message . content . map ( c => {
2318
2318
if ( c . type === 'text' ) {
2319
- return new LanguageModelTextPart ( c . value ) ;
2319
+ return new LanguageModelTextPart ( c . value , c . audience ) ;
2320
2320
} else if ( c . type === 'tool_result' ) {
2321
2321
const content : ( LanguageModelTextPart | LanguageModelPromptTsxPart ) [ ] = c . value . map ( part => {
2322
2322
if ( part . type === 'text' ) {
2323
- return new types . LanguageModelTextPart ( part . value ) ;
2323
+ return new types . LanguageModelTextPart ( part . value , part . audience ) ;
2324
2324
} else {
2325
2325
return new types . LanguageModelPromptTsxPart ( part . value ) ;
2326
2326
}
@@ -2360,7 +2360,8 @@ export namespace LanguageModelChatMessage {
2360
2360
if ( part instanceof types . LanguageModelTextPart ) {
2361
2361
return {
2362
2362
type : 'text' ,
2363
- value : part . value
2363
+ value : part . value ,
2364
+ audience : part . audience ,
2364
2365
} satisfies IChatResponseTextPart ;
2365
2366
} else if ( part instanceof types . LanguageModelPromptTsxPart ) {
2366
2367
return {
@@ -2411,11 +2412,11 @@ export namespace LanguageModelChatMessage2 {
2411
2412
export function to ( message : chatProvider . IChatMessage ) : vscode . LanguageModelChatMessage2 {
2412
2413
const content = message . content . map ( c => {
2413
2414
if ( c . type === 'text' ) {
2414
- return new LanguageModelTextPart ( c . value ) ;
2415
+ return new LanguageModelTextPart ( c . value , c . audience ) ;
2415
2416
} else if ( c . type === 'tool_result' ) {
2416
2417
const content : ( LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart ) [ ] = c . value . map ( part => {
2417
2418
if ( part . type === 'text' ) {
2418
- return new types . LanguageModelTextPart ( part . value ) ;
2419
+ return new types . LanguageModelTextPart ( part . value , part . audience ) ;
2419
2420
} else if ( part . type === 'data' ) {
2420
2421
return new types . LanguageModelDataPart ( part . value . data . buffer , part . value . mimeType ) ;
2421
2422
} else {
@@ -2455,7 +2456,8 @@ export namespace LanguageModelChatMessage2 {
2455
2456
if ( part instanceof types . LanguageModelTextPart ) {
2456
2457
return {
2457
2458
type : 'text' ,
2458
- value : part . value
2459
+ value : part . value ,
2460
+ audience : part . audience ,
2459
2461
} satisfies IChatResponseTextPart ;
2460
2462
} else if ( part instanceof types . LanguageModelPromptTsxPart ) {
2461
2463
return {
@@ -2468,7 +2470,8 @@ export namespace LanguageModelChatMessage2 {
2468
2470
value : {
2469
2471
mimeType : part . mimeType as chatProvider . ChatImageMimeType ,
2470
2472
data : VSBuffer . wrap ( part . data )
2471
- }
2473
+ } ,
2474
+ audience : part . audience
2472
2475
} satisfies IChatResponseDataPart ;
2473
2476
} else {
2474
2477
// Strip unknown parts
@@ -2493,6 +2496,7 @@ export namespace LanguageModelChatMessage2 {
2493
2496
type : 'data' ,
2494
2497
mimeType : c . mimeType ,
2495
2498
data : VSBuffer . wrap ( c . data ) ,
2499
+ audience : c . audience
2496
2500
} satisfies IChatMessageDataPart ;
2497
2501
}
2498
2502
} else if ( c instanceof types . LanguageModelToolCallPart ) {
@@ -2692,6 +2696,19 @@ export namespace ChatResponseExtensionsPart {
2692
2696
}
2693
2697
}
2694
2698
2699
+ export namespace ChatResponsePullRequestPart {
2700
+ export function from ( part : vscode . ChatResponsePullRequestPart ) : Dto < IChatPullRequestContent > {
2701
+ return {
2702
+ kind : 'pullRequest' ,
2703
+ author : part . author ,
2704
+ title : part . title ,
2705
+ description : part . description ,
2706
+ uri : part . uri ,
2707
+ linkTag : part . linkTag
2708
+ } ;
2709
+ }
2710
+ }
2711
+
2695
2712
export namespace ChatResponseMovePart {
2696
2713
export function from ( part : vscode . ChatResponseMovePart ) : Dto < IChatMoveMessage > {
2697
2714
return {
@@ -2982,6 +2999,8 @@ export namespace ChatResponsePart {
2982
2999
return ChatResponseExtensionsPart . from ( part ) ;
2983
3000
} else if ( part instanceof types . ChatPrepareToolInvocationPart ) {
2984
3001
return ChatPrepareToolInvocationPart . from ( part ) ;
3002
+ } else if ( part instanceof types . ChatResponsePullRequestPart ) {
3003
+ return ChatResponsePullRequestPart . from ( part ) ;
2985
3004
} else if ( part instanceof types . ChatToolInvocationPart ) {
2986
3005
return ChatToolInvocationPart . from ( part ) ;
2987
3006
}
@@ -3215,7 +3234,7 @@ export namespace ChatAgentResult {
3215
3234
if ( value . $mid === MarshalledId . LanguageModelToolResult ) {
3216
3235
return new types . LanguageModelToolResult ( cloneAndChange ( value . content , reviveMetadata ) ) ;
3217
3236
} else if ( value . $mid === MarshalledId . LanguageModelTextPart ) {
3218
- return new types . LanguageModelTextPart ( value . value ) ;
3237
+ return new types . LanguageModelTextPart ( value . value , value . audience ) ;
3219
3238
} else if ( value . $mid === MarshalledId . LanguageModelPromptTsxPart ) {
3220
3239
return new types . LanguageModelPromptTsxPart ( value . value ) ;
3221
3240
}
@@ -3399,7 +3418,7 @@ export namespace LanguageModelToolResult {
3399
3418
export function to ( result : IToolResult ) : vscode . LanguageModelToolResult {
3400
3419
return new types . LanguageModelToolResult ( result . content . map ( item => {
3401
3420
if ( item . kind === 'text' ) {
3402
- return new types . LanguageModelTextPart ( item . value ) ;
3421
+ return new types . LanguageModelTextPart ( item . value , item . audience ) ;
3403
3422
} else {
3404
3423
return new types . LanguageModelPromptTsxPart ( item . value ) ;
3405
3424
}
@@ -3411,12 +3430,20 @@ export namespace LanguageModelToolResult {
3411
3430
checkProposedApiEnabled ( extension , 'chatParticipantPrivate' ) ;
3412
3431
}
3413
3432
3433
+ const checkAudienceApi = ( item : LanguageModelTextPart ) => {
3434
+ if ( item . audience ) {
3435
+ checkProposedApiEnabled ( extension , 'languageModelToolResultAudience' ) ;
3436
+ }
3437
+ } ;
3438
+
3414
3439
return {
3415
3440
content : result . content . map ( item => {
3416
3441
if ( item instanceof types . LanguageModelTextPart ) {
3442
+ checkAudienceApi ( item ) ;
3417
3443
return {
3418
3444
kind : 'text' ,
3419
- value : item . value
3445
+ value : item . value ,
3446
+ audience : item . audience
3420
3447
} ;
3421
3448
} else if ( item instanceof types . LanguageModelPromptTsxPart ) {
3422
3449
return {
@@ -3437,13 +3464,9 @@ export namespace LanguageModelToolResult2 {
3437
3464
export function to ( result : IToolResult ) : vscode . LanguageModelToolResult2 {
3438
3465
return new types . LanguageModelToolResult2 ( result . content . map ( item => {
3439
3466
if ( item . kind === 'text' ) {
3440
- return new types . LanguageModelTextPart ( item . value ) ;
3467
+ return new types . LanguageModelTextPart ( item . value , item . audience ) ;
3441
3468
} else if ( item . kind === 'data' ) {
3442
- const mimeType = Object . values ( types . ChatImageMimeType ) . includes ( item . value . mimeType as types . ChatImageMimeType ) ? item . value . mimeType as types . ChatImageMimeType : undefined ;
3443
- if ( ! mimeType ) {
3444
- throw new Error ( 'Invalid MIME type' ) ;
3445
- }
3446
- return new types . LanguageModelDataPart ( item . value . data . buffer , mimeType ) ;
3469
+ return new types . LanguageModelDataPart ( item . value . data . buffer , item . value . mimeType , item . audience ) ;
3447
3470
} else {
3448
3471
return new types . LanguageModelPromptTsxPart ( item . value ) ;
3449
3472
}
@@ -3455,6 +3478,12 @@ export namespace LanguageModelToolResult2 {
3455
3478
checkProposedApiEnabled ( extension , 'chatParticipantPrivate' ) ;
3456
3479
}
3457
3480
3481
+ const checkAudienceApi = ( item : LanguageModelTextPart | LanguageModelDataPart ) => {
3482
+ if ( item . audience ) {
3483
+ checkProposedApiEnabled ( extension , 'languageModelToolResultAudience' ) ;
3484
+ }
3485
+ } ;
3486
+
3458
3487
let hasBuffers = false ;
3459
3488
let detailsDto : Dto < Array < URI | types . Location > | IToolResultInputOutputDetails | IToolResultOutputDetails | undefined > = undefined ;
3460
3489
if ( Array . isArray ( result . toolResultDetails ) ) {
@@ -3477,23 +3506,27 @@ export namespace LanguageModelToolResult2 {
3477
3506
const dto : Dto < IToolResult > = {
3478
3507
content : result . content . map ( item => {
3479
3508
if ( item instanceof types . LanguageModelTextPart ) {
3509
+ checkAudienceApi ( item ) ;
3480
3510
return {
3481
3511
kind : 'text' ,
3482
- value : item . value
3512
+ value : item . value ,
3513
+ audience : item . audience
3483
3514
} ;
3484
3515
} else if ( item instanceof types . LanguageModelPromptTsxPart ) {
3485
3516
return {
3486
3517
kind : 'promptTsx' ,
3487
3518
value : item . value ,
3488
3519
} ;
3489
3520
} else if ( item instanceof types . LanguageModelDataPart ) {
3521
+ checkAudienceApi ( item ) ;
3490
3522
hasBuffers = true ;
3491
3523
return {
3492
3524
kind : 'data' ,
3493
3525
value : {
3494
3526
mimeType : item . mimeType ,
3495
3527
data : VSBuffer . wrap ( item . data )
3496
- }
3528
+ } ,
3529
+ audience : item . audience
3497
3530
} ;
3498
3531
} else {
3499
3532
throw new Error ( 'Unknown LanguageModelToolResult part type' ) ;
0 commit comments