mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 13:19:48 +00:00
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.
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
/** Compact asset representation returned by asset Operations. */
|
|
export const assetSummarySchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
/** `file`, `folder`, `version_stack`, or `symlink`. */
|
|
type: z.string(),
|
|
/** Size in bytes. */
|
|
size: z.number(),
|
|
projectId: z.string().nullable(),
|
|
})
|
|
export type AssetSummary = z.infer<typeof assetSummarySchema>
|
|
|
|
/** Cursor pagination metadata. Pass `endCursor` as `after` to fetch the next page. */
|
|
export const pageInfoSchema = z.object({
|
|
hasNextPage: z.boolean(),
|
|
endCursor: z.string().nullable(),
|
|
})
|
|
export type PageInfo = z.infer<typeof pageInfoSchema>
|
|
|
|
export const projectSummarySchema = z.object({
|
|
id: z.string(),
|
|
name: z.string(),
|
|
teamId: z.string(),
|
|
/** The project's root folder; use it as the parent for asset Operations. */
|
|
rootFolderId: z.string().nullable(),
|
|
})
|
|
export type ProjectSummary = z.infer<typeof projectSummarySchema>
|
|
|
|
/** Page size bounds shared by list Operations (matches `paginateQuery`). */
|
|
export const DEFAULT_PAGE_SIZE = 20
|
|
export const MAX_PAGE_SIZE = 200
|