feat(server): integrate blob to context (#13491)

This commit is contained in:
DarkSky
2025-08-15 17:35:45 +08:00
committed by GitHub
parent 795bfb2f95
commit e2156ea135
5 changed files with 85 additions and 12 deletions
@@ -55,7 +55,7 @@ export class ContextSession implements AsyncDisposable {
return this.config.docs.map(d => ({ ...d }));
}
get files() {
get files(): Required<ContextFile>[] {
return this.config.files.map(f => this.fulfillFile(f));
}
@@ -135,6 +135,36 @@ export class ContextSession implements AsyncDisposable {
return record;
}
async getBlobMetadata() {
const blobIds = this.blobs.map(b => b.id);
const blobs = await this.models.blob.list(this.config.workspaceId, {
where: { key: { in: blobIds } },
select: { key: true, mime: true },
});
const blobChunkSizes = await this.models.copilotWorkspace.getBlobChunkSizes(
this.config.workspaceId,
blobIds
);
return blobs
.filter(b => !!blobChunkSizes.get(b.key))
.map(b => ({
id: b.key,
mimeType: b.mime,
chunkSize: blobChunkSizes.get(b.key),
}));
}
async getBlobContent(
blobId: string,
chunk?: number
): Promise<string | undefined> {
return this.models.copilotWorkspace.getBlobContent(
this.config.workspaceId,
blobId,
chunk
);
}
async removeBlobRecord(blobId: string): Promise<boolean> {
const index = this.config.blobs.findIndex(b => b.id === blobId);
if (index >= 0) {