Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/common/chatDiskSessionResources.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
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 { createServiceIdentifier } from '../../../util/common/services';
7
import { URI } from '../../../util/vs/base/common/uri';
8
9
/**
10
* A recursive file tree structure where keys are filenames/directory names
11
* and values are either file contents (string) or nested FileTree objects.
12
*/
13
export interface FileTree {
14
[name: string]: string | FileTree | undefined;
15
}
16
17
/**
18
* Service for managing disk-based session resources for chat.
19
* Used to persist large tool results to disk to avoid filling up the context window.
20
*/
21
export interface IChatDiskSessionResources {
22
readonly _serviceBrand: undefined;
23
24
/**
25
* Ensures that files exist on disk in an idempotent manner.
26
* If files already exist with matching content, this is a no-op.
27
*
28
* @param sessionId The session ID for namespacing
29
* @param subdir A subdirectory path (will be sanitized)
30
* @param files Either a single file content string or a FileTree structure
31
* @returns The URI of the created directory containing the files
32
*/
33
ensure(sessionId: string, subdir: string, files: string | FileTree): Promise<URI>;
34
35
/**
36
* Checks if a URI is within the disk session resources storage.
37
* Used to allow reading these files without confirmation.
38
*/
39
isSessionResourceUri(uri: URI): boolean;
40
}
41
42
export const IChatDiskSessionResources = createServiceIdentifier<IChatDiskSessionResources>('IChatDiskSessionResources');
43
44