feat(embedding): add compose tiers, docs, and regenerate-embeddings CLI (#480)

* feat(embedding): update compose tiers, docs, and add regenerate-embeddings CLI

- Add Lite, Embedding, and Full Docker Compose configurations (and Aliyun mirrors)
- Set CONCURRENCY_AGENT to 1 for compose files containing embedding-server
- Update README and README_CN with compose options, recommended RAM, and semantic search links
- Add LiteRT-LM Embedding Server setup guide in docs/using-shumai/embedding-server.mdx
- Add shumai regenerate-embeddings CLI command and EmbeddingService to regenerate embeddings across teams
- Add comprehensive test coverage for EmbeddingService

* fix(docker): remove basic auth for turntable-renderer in full compose

* fix(agent): lock and disable embedding agent when ENABLE_EMBEDDING_AGENT is false

Ensure that when ENABLE_EMBEDDING_AGENT is set to 'false', existing embedding agents are automatically disabled on startup, marked as read-only, and blocked from manual API modifications or creations. Additionally guard background task creation and semantic search when the environment variable disables embedding agents.

* test(upload): remove flaky status assertion on workflow tasks
This commit is contained in:
Yiling-J
2026-10-16 21:20:25 +08:00
committed by GitHub
parent 0f318b4050
commit 7c297895e5
28 changed files with 1373 additions and 453 deletions
+81
View File
@@ -526,5 +526,86 @@ describe('Agent API', () => {
expect(res.status).toBe(403)
expect(agentService.updateAgentPermission).not.toHaveBeenCalled()
})
it('rejects POST /teams/:teamId/agents with 403 for embedding agent', async () => {
const res = await app.request('/teams/team1/agents', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Manual Embedding',
type: 'embedding',
}),
})
expect(res.status).toBe(403)
expect(agentService.createAgent).not.toHaveBeenCalled()
})
})
describe('read-only embedding agent when ENABLE_EMBEDDING_AGENT is false', () => {
beforeEach(() => {
process.env.ENABLE_EMBEDDING_AGENT = 'false'
vi.mocked(agentService.getAgent).mockResolvedValue({
id: 'emb1',
teamId: 'team1',
type: 'embedding',
} as unknown as Awaited<ReturnType<typeof agentService.getAgent>>)
})
afterEach(() => {
delete process.env.ENABLE_EMBEDDING_AGENT
})
it('rejects PUT /agents/:agentId with 403', async () => {
const res = await app.request('/agents/emb1', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Updated Embedding',
type: 'embedding',
enabled: false,
}),
})
expect(res.status).toBe(403)
expect(agentService.updateAgent).not.toHaveBeenCalled()
})
it('rejects DELETE /agents/:agentId with 403', async () => {
const res = await app.request('/agents/emb1', {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
})
expect(res.status).toBe(403)
expect(agentService.deleteAgent).not.toHaveBeenCalled()
})
it('rejects PATCH /agents/:agentId/permission with 403', async () => {
const res = await app.request('/agents/emb1/permission', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
permission: 'owner',
}),
})
expect(res.status).toBe(403)
expect(agentService.updateAgentPermission).not.toHaveBeenCalled()
})
it('rejects POST /teams/:teamId/agents with 403 for embedding agent', async () => {
const res = await app.request('/teams/team1/agents', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Manual Embedding',
type: 'embedding',
}),
})
expect(res.status).toBe(403)
expect(agentService.createAgent).not.toHaveBeenCalled()
})
})
})
+25 -3
View File
@@ -63,6 +63,16 @@ 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) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be created',
})
}
const agent = await agentService.createAgent({
teamId,
...req,
@@ -93,8 +103,12 @@ 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' && process.env.ENABLE_EMBEDDING_AGENT === 'true') {
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be modified',
})
@@ -131,8 +145,12 @@ 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' && process.env.ENABLE_EMBEDDING_AGENT === 'true') {
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be modified',
})
@@ -163,8 +181,12 @@ 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' && process.env.ENABLE_EMBEDDING_AGENT === 'true') {
if (existingAgent?.type === 'embedding' && isEmbeddingManagedByEnv) {
throw new HTTPException(403, {
message: 'Embedding agent is managed by environment configuration and cannot be deleted',
})