feat(server): context awareness for copilot (#9611)

fix PD-2167
fix PD-2169
fix PD-2190
This commit is contained in:
darkskygit
2025-03-13 11:44:55 +00:00
parent 05f3069efd
commit d8373f66e7
51 changed files with 2101 additions and 294 deletions
@@ -250,7 +250,7 @@ declare global {
addContextDoc: (options: {
contextId: string;
docId: string;
}) => Promise<Array<{ id: string }>>;
}) => Promise<{ id: string; createdAt: number }>;
removeContextDoc: (options: {
contextId: string;
docId: string;
@@ -268,7 +268,11 @@ declare global {
sessionId: string,
contextId: string
) => Promise<
{ docs: CopilotContextDoc[]; files: CopilotContextFile[] } | undefined
| {
docs: Array<CopilotContextDoc>;
files: Array<CopilotContextFile>;
}
| undefined
>;
}
@@ -18,6 +18,7 @@ import {
type GraphQLQuery,
listContextDocsAndFilesQuery,
listContextQuery,
matchContextQuery,
type QueryOptions,
type QueryResponse,
removeContextDocMutation,
@@ -284,6 +285,18 @@ export class CopilotClient {
return res.currentUser?.copilot?.contexts?.[0];
}
async matchContext(contextId: string, content: string, limit?: number) {
const res = await this.gql({
query: matchContextQuery,
variables: {
contextId,
content,
limit,
},
});
return res.currentUser?.copilot?.contexts?.[0]?.matchContext;
}
async chatText({
sessionId,
messageId,