(
toolConfig: ToolConfig,
options: UserToolSchemaOptions = {}
)
| 501 | } |
| 502 | |
| 503 | export function createUserToolSchema( |
| 504 | toolConfig: ToolConfig, |
| 505 | options: UserToolSchemaOptions = {} |
| 506 | ): ToolSchema { |
| 507 | const surface = options.surface ?? 'default' |
| 508 | const schema: ToolSchema = { |
| 509 | type: 'object', |
| 510 | properties: {}, |
| 511 | required: [], |
| 512 | } |
| 513 | |
| 514 | for (const [paramId, param] of Object.entries(toolConfig.params)) { |
| 515 | if (!param) continue |
| 516 | const visibility = param.visibility ?? 'user-or-llm' |
| 517 | if (visibility === 'hidden') { |
| 518 | continue |
| 519 | } |
| 520 | |
| 521 | const propertySchema = buildParameterSchema(toolConfig.id, paramId, param, options) |
| 522 | schema.properties[paramId] = propertySchema |
| 523 | |
| 524 | if (param.required) { |
| 525 | schema.required.push(paramId) |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | if (toolConfig.oauth?.required && surface === 'copilot') { |
| 530 | schema.properties.credentialId = { |
| 531 | type: 'string', |
| 532 | description: |
| 533 | 'Credential ID to use for this OAuth tool call. Required for Copilot/Superagent execution. Get valid IDs from environment/credentials.json.', |
| 534 | } |
| 535 | schema.required.push('credentialId') |
| 536 | } |
| 537 | |
| 538 | return schema |
| 539 | } |
| 540 | |
| 541 | export async function createLLMToolSchema( |
| 542 | toolConfig: ToolConfig, |
no test coverage detected