Skip to content

Commit 3872678

Browse files
authored
Refactor of copilotRemoteAgent (#7520)
1 parent eace45c commit 3872678

9 files changed

Lines changed: 702 additions & 469 deletions

File tree

src/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import { ITelemetry } from './common/telemetry';
1818
import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri';
1919
import { formatError } from './common/utils';
2020
import { EXTENSION_ID } from './constants';
21+
import { ICopilotRemoteAgentCommandArgs } from './github/common';
2122
import { ChatSessionWithPR } from './github/copilotApi';
22-
import { CopilotRemoteAgentManager, ICopilotRemoteAgentCommandArgs } from './github/copilotRemoteAgent';
23+
import { CopilotRemoteAgentManager } from './github/copilotRemoteAgent';
2324
import { FolderRepositoryManager } from './github/folderRepositoryManager';
2425
import { GitHubRepository } from './github/githubRepository';
2526
import { Issue } from './github/interface';

src/github/common.ts

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55
import * as OctokitRest from '@octokit/rest';
66
import { Endpoints } from '@octokit/types';
7+
import type { Uri } from 'vscode';
8+
import { Repository } from '../api/api';
9+
import { GitHubRemote } from '../common/remote';
10+
import { SessionInfo, SessionSetupStep } from './copilotApi';
11+
import { FolderRepositoryManager } from './folderRepositoryManager';
12+
import { GitHubRepository } from './githubRepository';
713

814
export namespace OctokitCommon {
915
export type IssuesAssignParams = OctokitRest.RestEndpointMethodTypes['issues']['addAssignees']['parameters'];
@@ -88,4 +94,71 @@ export function mergeQuerySchemaWithShared(sharedSchema: Schema, schema: Schema)
8894
...sharedSchema,
8995
definitions: mergedDefinitions
9096
};
91-
}
97+
}
98+
99+
type RemoteAgentSuccessResult = { link: string; state: 'success'; number: number; webviewUri: Uri; llmDetails: string };
100+
type RemoteAgentErrorResult = { error: string; state: 'error' };
101+
export type RemoteAgentResult = RemoteAgentSuccessResult | RemoteAgentErrorResult;
102+
103+
export interface IAPISessionLogs {
104+
readonly info: SessionInfo;
105+
readonly logs: string;
106+
readonly setupSteps: SessionSetupStep[] | undefined;
107+
}
108+
109+
export interface ICopilotRemoteAgentCommandArgs {
110+
userPrompt: string;
111+
summary?: string;
112+
source?: string;
113+
followup?: string;
114+
_version?: number; // TODO(jospicer): Remove once stabilized/engine version enforced
115+
}
116+
117+
export interface ICopilotRemoteAgentCommandResponse {
118+
uri: string;
119+
title: string;
120+
description: string;
121+
author: string;
122+
linkTag: string;
123+
}
124+
125+
export interface AssistantDelta {
126+
content?: string | undefined;
127+
role: string;
128+
tool_calls?: {
129+
function: {
130+
arguments: string;
131+
name: string;
132+
};
133+
id: string;
134+
type: string;
135+
index: number;
136+
}[] | undefined;
137+
}
138+
139+
export interface Choice {
140+
finish_reason: string;
141+
delta: {
142+
content?: string | undefined;
143+
role: string;
144+
tool_calls?: {
145+
function: {
146+
arguments: string;
147+
name: string;
148+
};
149+
id: string;
150+
type: string;
151+
index: number;
152+
}[] | undefined;
153+
};
154+
}
155+
156+
export interface RepoInfo {
157+
owner: string;
158+
repo: string;
159+
baseRef: string;
160+
remote: GitHubRemote;
161+
repository: Repository;
162+
ghRepository: GitHubRepository;
163+
fm: FolderRepositoryManager;
164+
}

0 commit comments

Comments
 (0)