feat(operations): add shared Operation layer for agent capabilities (#494)

Introduce @shumai/operations (pure definitions: Zod schemas, metadata,
CLI hints) and @shumai/core/src/operations (implementOperation and the
runOperation pipeline: validate, authorize, prepare, execute, validate
output, audit).

Migrate list_assets, create_folder, rename_asset, move_assets and
delete_asset to Operations, and add list_projects. The agent now builds
these tools from the registry, and the folder create/rename, file
rename and reparent routes call the same Operations.

Audit logs gain a nullable via column recording the surface. A lint
rule keeps the Prisma client out of Operation implementations.
This commit is contained in:
Yiling-J
2026-10-27 08:09:09 +08:00
committed by GitHub
parent 47ee794ae4
commit 76057ccd21
65 changed files with 2372 additions and 1149 deletions
@@ -0,0 +1,19 @@
import { listProjects, MAX_PAGE_SIZE } from '@shumai/operations'
import { projectService } from '@shumai/core/src/project/project'
import { implementOperation } from '../implement'
export const listProjectsOp = implementOperation(listProjects, {
// Only the caller's own projects are listed, scoped by team/project membership in the service.
authz: () => [],
execute: async (input, ctx) => {
const projects = await projectService.getUserProjects(ctx.userId, input.first ?? MAX_PAGE_SIZE)
return {
data: projects.map((p) => ({
id: p.id,
name: p.name,
teamId: p.teamId,
rootFolderId: p.rootFolder ?? null,
})),
}
},
})