feat(server): refactor copilot (#14892)

#### PR Dependency Tree


* **PR #14892** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
DarkSky
2026-05-04 00:36:47 +08:00
committed by GitHub
parent fa8f1a096c
commit d64f368623
239 changed files with 35859 additions and 16777 deletions
@@ -48,13 +48,14 @@ export class CopilotStorage {
userId: string,
workspaceId: string,
key: string,
blob: BlobInputType
blob: BlobInputType,
mimeType = 'image/png'
) {
const name = `${userId}/${workspaceId}/${key}`;
await this.provider.put(name, blob);
if (!env.prod) {
// return image base64url for dev environment
return `data:image/png;base64,${blob.toString('base64')}`;
return `data:${mimeType};base64,${blob.toString('base64')}`;
}
return this.url.link(`/api/copilot/blob/${name}`);
}
@@ -92,8 +93,12 @@ export class CopilotStorage {
@CallMetric('ai', 'blob_proxy_remote_url')
async handleRemoteLink(userId: string, workspaceId: string, link: string) {
const { buffer } = await fetchBuffer(link, REMOTE_BLOB_MAX_BYTES, 'image/');
const { buffer, type } = await fetchBuffer(
link,
REMOTE_BLOB_MAX_BYTES,
'image/'
);
const filename = createHash('sha256').update(buffer).digest('base64url');
return this.put(userId, workspaceId, filename, buffer);
return this.put(userId, workspaceId, filename, buffer, type);
}
}