mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +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.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { z } from 'zod'
|
|
import { defineOperation } from '../define'
|
|
|
|
export const moveAssets = defineOperation({
|
|
name: 'move_assets',
|
|
title: 'Move Assets',
|
|
description:
|
|
'Move one or more assets (files or folders) to a specified parent folder. Note: All assets ' +
|
|
'to be moved must belong to the same current parent folder.',
|
|
input: z.object({
|
|
assetIds: z
|
|
.array(z.string().min(1))
|
|
.min(1)
|
|
.describe(
|
|
'The IDs of the assets to move. All assets must belong to the same parent folder. At least one asset ID is required.',
|
|
),
|
|
newParentId: z
|
|
.string()
|
|
.min(1)
|
|
.describe('The destination parent folder ID to move the assets into.'),
|
|
}),
|
|
output: z.object({
|
|
movedAssetIds: z.array(z.string()),
|
|
newParentId: z.string(),
|
|
}),
|
|
surfaces: ['agent', 'mcp', 'cli'],
|
|
annotations: { readOnly: false, destructive: false, idempotent: true },
|
|
cli: {
|
|
command: ['move'],
|
|
aliases: ['mv'],
|
|
positional: ['assetIds'],
|
|
flags: { newParentId: ['-p', '--parent'] },
|
|
format: (output) =>
|
|
`Moved ${output.movedAssetIds.length} asset(s) to parent ${output.newParentId}`,
|
|
},
|
|
})
|