1
>
/*---------------------------------------------------------------------------------------------
chatAttachmentContext.ts
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 { MessageAttachmentKind, ResponsePartKind, type MessageChatAttachment, type SimpleMessageAttachment, type Turn } from './protocol/state.js';
7
>
8
>
/**
9
>
* Model-facing preamble that frames the resolved transcript for the SDK. It is
10
>
* intentionally hard-coded English (like Claude's `<system-reminder>` text):
11
>
* this string is consumed by the model, not shown in the UI, so it must not be
12
>
* localized.
13
>
*/
14
>
const CHAT_TRANSCRIPT_PREAMBLE =
15
>
'The user referenced another chat in the same session. ' +
16
>
'The transcript below is that chat up to the selected turn, provided as background context. ' +
17
>
'Treat it as reference material that may or may not be relevant to the new question.';
18
>
19
>
/**
20
>
* Returns the referenced chat's turns bounded through {@link endTurn}, inclusive.
21
>
* Throws when {@link endTurn} is not a retained completed turn.
22
>
*/
23
>
export function boundChatTranscriptTurns(turns: readonly Turn[], endTurn: string): readonly Turn[] {
24
const index = turns.findIndex(t => t.id === endTurn);
25
if (index < 0) {