MCPcopy
hub / github.com/simstudioai/sim / resolveToolsLabel

Function resolveToolsLabel

apps/sim/lib/workflows/subblocks/display.ts:435–478  ·  view source on GitHub ↗
(
  subBlock: SubBlockConfig | undefined,
  rawValue: unknown,
  customTools: Array<{ id: string; title?: string; schema?: { function?: { name?: string } } }>
)

Source from the content-addressed store, hash-verified

433 * name, then the block registry.
434 */
435export function resolveToolsLabel(
436 subBlock: SubBlockConfig | undefined,
437 rawValue: unknown,
438 customTools: Array<{ id: string; title?: string; schema?: { function?: { name?: string } } }>
439): string | null {
440 if (subBlock?.type !== 'tool-input') return null
441 if (!Array.isArray(rawValue) || rawValue.length === 0) return null
442
443 const names = rawValue
444 .map((tool: unknown) => {
445 if (!tool || typeof tool !== 'object') return null
446 const t = tool as Record<string, unknown>
447
448 if (typeof t.title === 'string' && t.title) return t.title
449
450 if (t.type === 'custom-tool' && typeof t.customToolId === 'string') {
451 const customTool = customTools.find((candidate) => candidate.id === t.customToolId)
452 if (customTool?.title) return customTool.title
453 if (customTool?.schema?.function?.name) return customTool.schema.function.name
454 }
455
456 const schema = t.schema as { function?: { name?: string } } | undefined
457 if (schema?.function?.name) return schema.function.name
458
459 const fn = t.function as { name?: string } | undefined
460 if (fn?.name) return fn.name
461
462 if (
463 typeof t.type === 'string' &&
464 t.type !== 'custom-tool' &&
465 t.type !== 'mcp' &&
466 t.type !== 'workflow' &&
467 t.type !== 'workflow_input'
468 ) {
469 const blockConfig = getBlock(t.type)
470 if (blockConfig?.name) return blockConfig.name
471 }
472
473 return null
474 })
475 .filter((name): name is string => !!name)
476
477 return summarizeNames(names)
478}
479
480/**
481 * Resolves a skill-input value to a skill-name summary: the live skill name

Callers 3

display.test.tsFile · 0.90
block.tsxFile · 0.90
workflow-block.tsxFile · 0.90

Calls 2

getBlockFunction · 0.90
summarizeNamesFunction · 0.85

Tested by

no test coverage detected