2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { isString } from '../../../../base/common/types.js';
7
>
import { MessageAttachmentKind, type MessageAnnotationsAttachment, type MessageAttachment, type SimpleMessageAttachment, type TextRange } from '../state/protocol/state.js';
8
>
9
>
export const AgentFeedbackAttachmentDisplayKind = 'agentFeedback';
10
>
export const AgentFeedbackAttachmentMetadataKey = 'agentFeedback';
11
>
12
>
export interface IAgentFeedbackAttachmentMetadata {
13
>
readonly sessionResource: string;
14
>
readonly feedbackItems: readonly IAgentFeedbackAttachmentItemMetadata[];
15
>
}
16
>
17
>
export interface IAgentFeedbackAttachmentItemMetadata {
18
>
readonly id: string;
19
>
readonly text: string;
20
>
readonly resourceUri: string;
21
>
readonly range: TextRange;
22
>
readonly replies?: readonly string[];
23
>
}
24
>
25
>
export function isAgentFeedbackAttachment(attachment: MessageAttachment): attachment is SimpleMessageAttachment {
26
return attachment.type === MessageAttachmentKind.Simple && attachment.displayKind === AgentFeedbackAttachmentDisplayKind;
27
}
29
>
/**
30
>
* Agent feedback is sent to agent-host sessions as one
31
>
* {@link MessageAnnotationsAttachment} per submitted comment, each referencing
32
>
* the specific annotation(s) on the session's annotations channel. The agent
33
>
* reads the comment content via the `listComments` tool and should act on the
34
>
* referenced comments.
35
>
*/
36
>
export function isAgentFeedbackAnnotationsAttachment(attachment: MessageAttachment): attachment is MessageAnnotationsAttachment {
37
return attachment.type === MessageAttachmentKind.Annotations && attachment.displayKind === AgentFeedbackAttachmentDisplayKind;
38
}
40
>
/**
41
>
* Renders an agent-feedback annotations attachment into the textual hint shown
42
>
* to the agent. The hint references the attached comment ids and points the
43
>
* agent at the `listComments` tool to read their content.
44
>
*/
45
>
export function renderAgentFeedbackAnnotationsAttachment(attachment: MessageAnnotationsAttachment): string | undefined {
46
const ids = attachment.annotationIds?.filter(isString) ?? [];
47
if (ids.length === 0) {