fix(types): support both 'name' and 'exportName' for backward compatibility
The TpmjsToolDefinitionSchema now accepts either 'name' (new) or 'exportName' (legacy) to ensure existing published packages continue to work. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5fc584fc66
commit
b7ea9bf4d6
1 changed files with 22 additions and 11 deletions
|
|
@ -90,17 +90,28 @@ export type TpmjsAiAgent = z.infer<typeof TpmjsAiAgentSchema>;
|
|||
* - returns: Tool return type - auto-extracted from tool
|
||||
* - aiAgent: AI agent guidance - auto-extracted from tool
|
||||
*/
|
||||
export const TpmjsToolDefinitionSchema = z.object({
|
||||
name: z.string().min(1, 'Tool name is required'),
|
||||
// Optional - auto-extracted from tool if not provided
|
||||
description: z.string().min(20, 'Description must be at least 20 characters').max(500).optional(),
|
||||
// @deprecated - now auto-extracted from tool's inputSchema
|
||||
parameters: z.array(TpmjsParameterSchema).optional(),
|
||||
// @deprecated - now auto-extracted from tool
|
||||
returns: TpmjsReturnsSchema.optional(),
|
||||
// @deprecated - now auto-extracted from tool
|
||||
aiAgent: TpmjsAiAgentSchema.optional(),
|
||||
});
|
||||
export const TpmjsToolDefinitionSchema = z
|
||||
.object({
|
||||
// New field name (preferred)
|
||||
name: z.string().min(1).optional(),
|
||||
// @deprecated - use 'name' instead. Kept for backward compatibility.
|
||||
exportName: z.string().min(1).optional(),
|
||||
// Optional - auto-extracted from tool if not provided
|
||||
description: z
|
||||
.string()
|
||||
.min(20, 'Description must be at least 20 characters')
|
||||
.max(500)
|
||||
.optional(),
|
||||
// @deprecated - now auto-extracted from tool's inputSchema
|
||||
parameters: z.array(TpmjsParameterSchema).optional(),
|
||||
// @deprecated - now auto-extracted from tool
|
||||
returns: TpmjsReturnsSchema.optional(),
|
||||
// @deprecated - now auto-extracted from tool
|
||||
aiAgent: TpmjsAiAgentSchema.optional(),
|
||||
})
|
||||
.refine((data) => data.name || data.exportName, {
|
||||
message: 'Either name or exportName is required',
|
||||
});
|
||||
|
||||
export type TpmjsToolDefinition = z.infer<typeof TpmjsToolDefinitionSchema>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue