* 应用默认值
(
parameters: Record<string, any>,
schema: Record<string, ToolParameterSchema>
)
| 97 | * 应用默认值 |
| 98 | */ |
| 99 | public static applyDefaults( |
| 100 | parameters: Record<string, any>, |
| 101 | schema: Record<string, ToolParameterSchema> |
| 102 | ): Record<string, any> { |
| 103 | const result = { ...parameters }; |
| 104 | |
| 105 | for (const [key, paramSchema] of Object.entries(schema)) { |
| 106 | if (!(key in result) && paramSchema.default !== undefined) { |
| 107 | result[key] = paramSchema.default; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return result; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * 清理参数(移除未定义的参数) |