mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 06:24:30 +00:00
feat(asset-read): expose read_asset on MCP and the CLI
Enable the mcp and cli surfaces for read_asset and get_asset_render. - MCP: add per-Operation tool extensions. The read presenter attaches up to 8 images (2 MB each) inline, lists image links, supports inlineImages: false, and tells the model to call get_asset_render when a render is pending. Storage keys are stripped from the result. - CLI: generated commands can flatten object inputs into prefixed flags (cli.flatten) and omit fields (cli.omit); add per-command extensions. New `read` and `render` commands print image links, download them with --out, and support --no-wait with a printed `render <taskId>` hint. - Round frame timestamps in labels to 3 decimals.
This commit is contained in:
@@ -37,6 +37,14 @@ export interface CliSpec<TInput, TOutput> {
|
||||
positional?: readonly (keyof TInput & string)[]
|
||||
/** Flag spellings for input fields, e.g. `{ parent: ['-p', '--parent'] }`. */
|
||||
flags?: { readonly [K in keyof TInput & string]?: readonly string[] }
|
||||
/**
|
||||
* Object input fields exposed as one flag per sub-field, keyed by flag prefix: with
|
||||
* `{ videoConfig: 'video' }`, `videoConfig.start` becomes `--video-start`. An empty prefix
|
||||
* uses the sub-field name alone (`--degree`). Object fields must be flattened or omitted.
|
||||
*/
|
||||
flatten?: { readonly [K in keyof TInput & string]?: string }
|
||||
/** Input fields the CLI does not expose. They must be optional. */
|
||||
omit?: readonly (keyof TInput & string)[]
|
||||
/** Input values the CLI uses when the user does not pass them (e.g. a larger page size). */
|
||||
defaults?: { readonly [K in keyof TInput & string]?: TInput[K] }
|
||||
/** Human-friendly rendering of the output; the CLI falls back to a generic renderer. */
|
||||
@@ -101,12 +109,19 @@ export function defineOperation<
|
||||
...(def.cli.positional ?? []),
|
||||
...Object.keys(def.cli.flags ?? {}),
|
||||
...Object.keys(def.cli.defaults ?? {}),
|
||||
...Object.keys(def.cli.flatten ?? {}),
|
||||
...(def.cli.omit ?? []),
|
||||
]
|
||||
for (const field of referenced) {
|
||||
if (!fields.has(field)) {
|
||||
throw new Error(`Operation "${def.name}" cli spec references unknown input "${field}"`)
|
||||
}
|
||||
}
|
||||
for (const field of def.cli.omit ?? []) {
|
||||
if (!(def.input.shape[field] as z.ZodType).safeParse(undefined).success) {
|
||||
throw new Error(`Operation "${def.name}" cli spec omits required input "${field}"`)
|
||||
}
|
||||
}
|
||||
}
|
||||
return Object.freeze(def)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user