mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 04:14:30 +00:00
feat(agent): integrate sandboxed bash tool and sandbox settings
This commit is contained in:
@@ -45,9 +45,12 @@ describe('SkillService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mocking s3Service return value
|
||||
const getObjectSpy = vi.spyOn(s3Service, 'getObject').mockResolvedValue({ buffer: zipBuffer, contentType: 'application/zip' } as any)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- mocking s3Service return value
|
||||
const getObjectSpy = vi.spyOn(s3Service, 'getObject').mockResolvedValue({
|
||||
buffer: zipBuffer,
|
||||
contentType: 'application/zip',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const putObjectSpy = vi.spyOn(s3Service, 'putObject').mockResolvedValue(undefined as any)
|
||||
|
||||
const skill = await skillService.upsertSkill(team.id, {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
TeamInfo,
|
||||
GetMeResponse,
|
||||
UserInfo,
|
||||
SandboxSettings,
|
||||
} from '@/dtos/team'
|
||||
|
||||
export class TeamService {
|
||||
@@ -202,6 +203,35 @@ export class TeamService {
|
||||
return updated.settings || {}
|
||||
}
|
||||
|
||||
async getSandboxSettings(teamId: string): Promise<SandboxSettings> {
|
||||
const sandbox = await prisma.sandbox.findUnique({
|
||||
where: { teamId },
|
||||
})
|
||||
return {
|
||||
allowedDomains: sandbox?.allowedDomains || [
|
||||
'github.com',
|
||||
'api.github.com',
|
||||
'raw.githubusercontent.com',
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
async updateSandboxSettings(teamId: string, settings: SandboxSettings): Promise<SandboxSettings> {
|
||||
const sandbox = await prisma.sandbox.upsert({
|
||||
where: { teamId },
|
||||
create: {
|
||||
teamId,
|
||||
allowedDomains: settings.allowedDomains,
|
||||
},
|
||||
update: {
|
||||
allowedDomains: settings.allowedDomains,
|
||||
},
|
||||
})
|
||||
return {
|
||||
allowedDomains: sandbox.allowedDomains,
|
||||
}
|
||||
}
|
||||
|
||||
async getSignupInfo() {
|
||||
const count = await prisma.user.count()
|
||||
const defaultTeam = await this.ensureDefaultTeam()
|
||||
|
||||
Reference in New Issue
Block a user