MCPcopy
hub / github.com/FlowiseAI/Flowise / findParamValue

Function findParamValue

packages/server/src/utils/buildAgentflow.ts:497–527  ·  view source on GitHub ↗
(obj: any, paramName: string)

Source from the content-addressed store, hash-verified

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

Callers 1

getParamValuesFunction · 0.85

Calls 1

callMethod · 0.45

Tested by

no test coverage detected