feat: configure embedding servers and transcript agents

This commit is contained in:
yiling
2026-12-04 18:54:29 +08:00
parent 72a7f68c92
commit 553269012c
57 changed files with 1686 additions and 271 deletions
+15 -24
View File
@@ -1,5 +1,6 @@
import { zValidator } from '@hono/zod-validator'
import { agentService } from '@shumai/core/src/agent/agent'
import { getSystemAgentSetting } from '@shumai/core/src/agent/system-agents'
import { agentSessionService } from '@shumai/core/src/agent/session-service'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import {
@@ -68,13 +69,10 @@ const route = new Hono<{ Variables: { user: User } }>()
id: teamId,
})
const isEmbeddingManagedByEnv =
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
if (req.type === 'embedding' && isEmbeddingManagedByEnv) {
const managedSetting = getSystemAgentSetting(req.type)
if (managedSetting) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be created',
message: `${managedSetting.name} is managed by environment configuration and cannot be created`,
})
}
@@ -108,14 +106,13 @@ const route = new Hono<{ Variables: { user: User } }>()
id: agentId,
})
const isEmbeddingManagedByEnv =
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
const existingAgent = await agentService.getAgent({ agentId })
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
const managedSetting =
(existingAgent && getSystemAgentSetting(existingAgent.type)) ??
getSystemAgentSetting(req.type)
if (managedSetting) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be modified',
message: `${managedSetting.name} is managed by environment configuration and cannot be modified`,
})
}
@@ -150,14 +147,11 @@ const route = new Hono<{ Variables: { user: User } }>()
id: agentId,
})
const isEmbeddingManagedByEnv =
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
const existingAgent = await agentService.getAgent({ agentId })
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
const managedSetting = existingAgent && getSystemAgentSetting(existingAgent.type)
if (managedSetting) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be modified',
message: `${managedSetting.name} is managed by environment configuration and cannot be modified`,
})
}
@@ -186,14 +180,11 @@ const route = new Hono<{ Variables: { user: User } }>()
id: agentId,
})
const isEmbeddingManagedByEnv =
process.env.ENABLE_EMBEDDING_AGENT === 'true' ||
process.env.ENABLE_EMBEDDING_AGENT === 'false'
const existingAgent = await agentService.getAgent({ agentId })
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
const managedSetting = existingAgent && getSystemAgentSetting(existingAgent.type)
if (managedSetting) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be deleted',
message: `${managedSetting.name} is managed by environment configuration and cannot be deleted`,
})
}