feat(asset): decouple logical assets from physical storage with StorageKey and implement O(1) copy

This commit is contained in:
yiling
2026-05-25 00:52:45 +08:00
parent c5fba746be
commit 5dc3bdb38e
33 changed files with 2203 additions and 273 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ describe('readSkillTool', () => {
data: {
id: 'asset1',
name: 'skill.zip',
key: 'skills/skill.zip',
storageKey: { create: { key: 'skills/skill.zip' } },
type: 'file',
status: 'uploaded',
},
+3 -2
View File
@@ -65,15 +65,16 @@ export const createReadSkillTool = (
const asset = await prisma.asset.findUnique({
where: { id: skill.assetId },
include: { storageKey: true },
})
if (!asset || !asset.key) {
if (!asset || !asset.storageKey?.key) {
throw new Error('Skill asset not found or has no key')
}
const { buffer: zipBuffer } = await s3Service.getObject(
process.env.S3_BUCKET || 'shumai',
asset.key,
asset.storageKey.key,
)
const zip = new AdmZip(zipBuffer)