| 495 | // Example: Searches for "agentSelectedTool" value in complex nested inputs structure |
| 496 | // Returns "requestsGet" when found in agentTools[0].agentSelectedTool |
| 497 | const findParamValue = (obj: any, paramName: string): any => { |
| 498 | if (typeof obj !== 'object' || obj === null) { |
| 499 | return undefined |
| 500 | } |
| 501 | |
| 502 | // Handle arrays (e.g., agentTools array) |
| 503 | if (Array.isArray(obj)) { |
| 504 | for (const item of obj) { |
| 505 | const result = findParamValue(item, paramName) |
| 506 | if (result !== undefined) { |
| 507 | return result |
| 508 | } |
| 509 | } |
| 510 | return undefined |
| 511 | } |
| 512 | |
| 513 | // Direct property match |
| 514 | if (Object.prototype.hasOwnProperty.call(obj, paramName)) { |
| 515 | return obj[paramName] |
| 516 | } |
| 517 | |
| 518 | // Recursively search nested objects |
| 519 | for (const value of Object.values(obj)) { |
| 520 | const result = findParamValue(value, paramName) |
| 521 | if (result !== undefined) { |
| 522 | return result |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | return undefined |
| 527 | } |
| 528 | |
| 529 | // Helper function to process config parameters with acceptVariable |
| 530 | // Example: Processes agentSelectedToolConfig object, resolving variables in requestsGetHeaders |