MCPcopy Index your code
hub / github.com/simstudioai/sim / extractBlockParams

Function extractBlockParams

apps/sim/serializer/index.ts:432–524  ·  view source on GitHub ↗
(block: BlockState)

Source from the content-addressed store, hash-verified

430 * params exactly the way execution (serializeBlock) does.
431 */
432export function extractBlockParams(block: BlockState): Record<string, any> {
433 if (block.type === 'loop' || block.type === 'parallel') {
434 return {}
435 }
436
437 const blockConfig = getBlock(block.type)
438 if (!blockConfig) {
439 throw new Error(`Invalid block type: ${block.type}`)
440 }
441
442 const params: Record<string, any> = {}
443 const legacyAdvancedMode = block.advancedMode ?? false
444 const canonicalModeOverrides = block.data?.canonicalModes
445 const isStarterBlock = block.type === 'starter'
446 const isAgentBlock = block.type === 'agent'
447 const isTriggerContext = block.triggerMode ?? false
448 const isTriggerCategory = blockConfig.category === 'triggers'
449 const canonicalIndex = buildCanonicalIndex(blockConfig.subBlocks)
450 const allValues = buildSubBlockValues(block.subBlocks)
451
452 Object.entries(block.subBlocks).forEach(([id, subBlock]) => {
453 const matchingConfigs = blockConfig.subBlocks.filter((config) => config.id === id)
454
455 const hasStarterInputFormatValues =
456 isStarterBlock &&
457 id === 'inputFormat' &&
458 Array.isArray(subBlock.value) &&
459 subBlock.value.length > 0
460
461 const isLegacyAgentField =
462 isAgentBlock && ['systemPrompt', 'userPrompt', 'memories'].includes(id)
463
464 const shouldInclude =
465 matchingConfigs.length === 0 ||
466 matchingConfigs.some((config) =>
467 shouldSerializeSubBlock(
468 config,
469 allValues,
470 legacyAdvancedMode,
471 isTriggerContext,
472 isTriggerCategory,
473 canonicalIndex,
474 canonicalModeOverrides
475 )
476 )
477
478 if (
479 (matchingConfigs.length > 0 && shouldInclude) ||
480 hasStarterInputFormatValues ||
481 isLegacyAgentField
482 ) {
483 params[id] = subBlock.value
484 }
485 })
486
487 blockConfig.subBlocks.forEach((subBlockConfig) => {
488 const id = subBlockConfig.id
489 if (

Callers 3

serializeBlockMethod · 0.85

Calls 6

getBlockFunction · 0.90
buildCanonicalIndexFunction · 0.90
buildSubBlockValuesFunction · 0.90
getCanonicalValuesFunction · 0.90
resolveCanonicalModeFunction · 0.90
shouldSerializeSubBlockFunction · 0.85

Tested by

no test coverage detected