Path: blob/main/extensions/copilot/src/extension/prompts/common/chatDiskSessionResources.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { createServiceIdentifier } from '../../../util/common/services';6import { URI } from '../../../util/vs/base/common/uri';78/**9* A recursive file tree structure where keys are filenames/directory names10* and values are either file contents (string) or nested FileTree objects.11*/12export interface FileTree {13[name: string]: string | FileTree | undefined;14}1516/**17* Service for managing disk-based session resources for chat.18* Used to persist large tool results to disk to avoid filling up the context window.19*/20export interface IChatDiskSessionResources {21readonly _serviceBrand: undefined;2223/**24* Ensures that files exist on disk in an idempotent manner.25* If files already exist with matching content, this is a no-op.26*27* @param sessionId The session ID for namespacing28* @param subdir A subdirectory path (will be sanitized)29* @param files Either a single file content string or a FileTree structure30* @returns The URI of the created directory containing the files31*/32ensure(sessionId: string, subdir: string, files: string | FileTree): Promise<URI>;3334/**35* Checks if a URI is within the disk session resources storage.36* Used to allow reading these files without confirmation.37*/38isSessionResourceUri(uri: URI): boolean;39}4041export const IChatDiskSessionResources = createServiceIdentifier<IChatDiskSessionResources>('IChatDiskSessionResources');424344