fix(core): sanitize registered tool names (#34512)
This commit is contained in:
parent
ecfa918760
commit
f928b5be07
4 changed files with 9 additions and 11 deletions
|
|
@ -136,6 +136,9 @@ export const validateName = (name: string) =>
|
|||
? Effect.void
|
||||
: Effect.fail(new RegistrationError({ name, message: `Invalid tool name: ${name}` }))
|
||||
|
||||
export const registrationEntries = (tools: Readonly<Record<string, AnyTool>>) =>
|
||||
Object.entries(tools).map(([name, tool]) => [name.replace(/[^a-zA-Z0-9_-]/g, "_"), tool] as const)
|
||||
|
||||
export const withPermission = <Input extends SchemaType<any>, Output extends SchemaType<any>>(
|
||||
tool: Definition<Input, Output>,
|
||||
permission: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue