From 8830b01db31b1761267bbcec37ca77af79614b17 Mon Sep 17 00:00:00 2001 From: nalbion Date: Tue, 12 Mar 2024 19:31:17 +1100 Subject: [PATCH] updated ProgressData as per VS Code chat participants --- package.json | 2 +- src/agents/AgentContext.ts | 73 +++++++++++++++----------------------- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 301997a..8442bdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "agent-adapters", - "version": "1.0.3", + "version": "1.0.4", "description": "Configurable AI Agents", "license": "MPL-2.0", "main": "dist/index.js", diff --git a/src/agents/AgentContext.ts b/src/agents/AgentContext.ts index 1e5fd91..1da1d2f 100644 --- a/src/agents/AgentContext.ts +++ b/src/agents/AgentContext.ts @@ -29,61 +29,46 @@ export type ProgressData = | { /** A piece of the chat response's content. * Will be merged with other progress pieces as needed, and rendered as markdown. */ - type: 'content'; - /** The content as a string of markdown source */ - content: string; // || MarkdownString; + type: 'markdown'; + content: string; + // || MarkdownString {value: string, isTruested?: boolean | {enabledCommands: string[]}, supportThemeIcons?: boolean, supportHtml?: boolean, baseUri?: Uri}; } | { - /** - * Represents a piece of the chat response's content that is resolved asynchronously. - * It is rendered immediately with a placeholder, which is replaced once the full content is available. - * @deprecated // Apparently this one type is going away - * https://github.com/microsoft/vscode/blob/96bc006c927c18fe87e15a824c0f2a4349104013/src/vs/workbench/api/common/extHostChatAgents2.ts#L135 - */ - type: 'task'; - /** The markdown string to be rendered immediately. */ - placeholder: string; - /** A Thenable resolving to the real content. - * The placeholder will be replaced with this content once it's available. - * eg: - * resolvedContent: Promise.resolve({ content: response.content }) - * resolvedContent: Promise.resolve({ treeData: { label: "", uri: vscode.Uri.file(""), children: []} }) */ - resolvedContent: Promise; // ChatAgentContent | ChatAgentFileTree>; + type: 'progress'; + content: string; } | { - /** Represents a tree, such as a file and directory structure, rendered in the chat response - * eg: {treeData: { label: "", uri: vscode.Uri.file(""), children: []}} */ - type: 'fileTree'; - /** The markdown string to be rendered immediately. */ - treeData: unknown; // ChatAgentFileTreeData; - } - | { - /** Document references that should be used by the MappedEditsProvider */ - type: 'usedContext'; - /** Document references that should be used by the MappedEditsProvider */ - documents: unknown[]; // ChatAgentDocumentContext[]; + /** An anchor is an inline reference to some type of resource */ + type: 'anchor'; + uri: string; + title?: string; + range?: { start: { line: number; character: number }; end: { line: number; character: number } }; } | { - /** Indicates a piece of content that was used by the chat agent while processing the request. - * Will be displayed to the user. */ - type: 'contentReference'; - /** The resource that was referenced. */ - reference: unknown; // Uri | Location; + type: 'button'; + command: { title: string; command: string; tooltip?: string; arguments?: any[] }; } | { - /** A reference to a piece of content that will be rendered inline with the markdown content. */ - type: 'inlineContentReference'; - /** The resource that was referenced. */ - inlineReference: unknown; // Uri | Location; - /** An alternate title for the resource. */ - title: string; + /** Represents a tree, such as a file and directory structure, rendered in the chat response */ + type: 'fileTree'; + /** {name: string, children?: [{name, children}, ...]} */ + treeData: TreeData; } | { - // Requires chatAgents2Additions in package.json - type: 'agentDetection'; - agentName: string; - command: string; + /** Indicates a piece of content that was used by the chat agent while processing the request. + * NOT rendered inline with response */ + type: 'reference'; + uri: string; + range?: { start: { line: number; character: number }; end: { line: number; character: number } }; }; +// | { +// // Requires chatAgents2Additions in package.json +// type: 'agentDetection'; +// agentName: string; +// command: string; +// ; + +export type TreeData = { name: string; children?: TreeData[] }; export type RoutingContextValue = string | string[] | { [key: string]: RoutingContextValue }; export type RoutingContext = Record;