* Creates a tool schema for LLM with user-provided parameters excluded
(
toolId: string,
paramId: string,
param: ToolParamDefinition,
options: UserToolSchemaOptions = {}
)
| 425 | * Creates a tool schema for LLM with user-provided parameters excluded |
| 426 | */ |
| 427 | function buildParameterSchema( |
| 428 | toolId: string, |
| 429 | paramId: string, |
| 430 | param: ToolParamDefinition, |
| 431 | options: UserToolSchemaOptions = {} |
| 432 | ): SchemaProperty { |
| 433 | const surface = options.surface ?? 'default' |
| 434 | |
| 435 | if (surface === 'copilot' && (param.type === 'file' || param.type === 'file[]')) { |
| 436 | return buildCopilotFileParameterSchema(param) |
| 437 | } |
| 438 | |
| 439 | let schemaType = param.type |
| 440 | if (schemaType === 'json' || schemaType === 'any') { |
| 441 | schemaType = 'object' |
| 442 | } |
| 443 | |
| 444 | const propertySchema: SchemaProperty = { |
| 445 | type: schemaType, |
| 446 | description: param.description || '', |
| 447 | } |
| 448 | |
| 449 | if (param.type === 'array' && param.items) { |
| 450 | propertySchema.items = { |
| 451 | ...param.items, |
| 452 | ...(param.items.properties && { |
| 453 | properties: { ...param.items.properties }, |
| 454 | }), |
| 455 | } |
| 456 | } else if (param.items) { |
| 457 | logger.warn(`items property ignored for non-array param "${paramId}" in tool "${toolId}"`) |
| 458 | } |
| 459 | |
| 460 | return propertySchema |
| 461 | } |
| 462 | |
| 463 | function buildCopilotFileParameterSchema(param: ToolParamDefinition): SchemaProperty { |
| 464 | const baseDescription = |
no test coverage detected