refactor(agent): centralize sandbox allowedDomains default in prisma schema

This commit is contained in:
yiling
2026-05-20 14:07:34 +08:00
parent fb30e63b47
commit 712b9d4185
4 changed files with 7 additions and 11 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "sandboxes" ALTER COLUMN "allowedDomains" SET DEFAULT ARRAY['npmjs.org', '*.npmjs.org', 'registry.npmjs.org', 'registry.yarnpkg.com', 'pypi.org', '*.pypi.org', 'github.com', '*.github.com', 'api.github.com', 'raw.githubusercontent.com']::TEXT[];
+1 -1
View File
@@ -226,7 +226,7 @@ model Team {
model Sandbox {
id String @id @default(ulid())
allowedDomains String[] @default(["github.com", "api.github.com", "raw.githubusercontent.com"])
allowedDomains String[] @default(["npmjs.org", "*.npmjs.org", "registry.npmjs.org", "registry.yarnpkg.com", "pypi.org", "*.pypi.org", "github.com", "*.github.com", "api.github.com", "raw.githubusercontent.com"])
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
+1 -5
View File
@@ -172,11 +172,7 @@ export class AgentExecutor {
})
const sandbox = await this.getSandbox(teamId)
const allowedDomains = sandbox?.allowedDomains || [
'github.com',
'api.github.com',
'raw.githubusercontent.com',
]
const allowedDomains = sandbox?.allowedDomains || []
const piDir = path.join(process.cwd(), '.pi')
if (!fs.existsSync(piDir)) fs.mkdirSync(piDir, { recursive: true })
+3 -5
View File
@@ -26,6 +26,7 @@ export class TeamService {
enablePublicSignup: true,
transcode: { videoStrategy: 'disable', imageStrategy: 'disable' },
},
sandbox: { create: {} },
},
})
await providerService.initBuiltinProviders(team.id)
@@ -42,6 +43,7 @@ export class TeamService {
name: req.name,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
settings: {} as any,
sandbox: { create: {} },
},
})
@@ -208,11 +210,7 @@ export class TeamService {
where: { teamId },
})
return {
allowedDomains: sandbox?.allowedDomains || [
'github.com',
'api.github.com',
'raw.githubusercontent.com',
],
allowedDomains: sandbox?.allowedDomains || [],
}
}