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

Method createBlockLog

apps/sim/executor/execution/block-executor.ts:458–514  ·  view source on GitHub ↗
(
    ctx: ExecutionContext,
    blockId: string,
    block: SerializedBlock,
    node: DAGNode,
    startedAt: string
  )

Source from the content-addressed store, hash-verified

456 }
457
458 private createBlockLog(
459 ctx: ExecutionContext,
460 blockId: string,
461 block: SerializedBlock,
462 node: DAGNode,
463 startedAt: string
464 ): BlockLog {
465 let blockName = block.metadata?.name ?? blockId
466 let loopId: string | undefined
467 let parallelId: string | undefined
468 let iterationIndex: number | undefined
469
470 if (node?.metadata) {
471 if (
472 node.metadata.branchIndex !== undefined &&
473 node.metadata.subflowType === 'parallel' &&
474 node.metadata.subflowId
475 ) {
476 blockName = `${blockName} (iteration ${node.metadata.branchIndex})`
477 iterationIndex = node.metadata.branchIndex
478 parallelId = node.metadata.subflowId
479 } else if (
480 node.metadata.isLoopNode &&
481 node.metadata.subflowType === 'loop' &&
482 node.metadata.subflowId
483 ) {
484 loopId = node.metadata.subflowId
485 const loopScope = ctx.loopExecutions?.get(loopId)
486 if (loopScope && loopScope.iteration !== undefined) {
487 blockName = `${blockName} (iteration ${loopScope.iteration})`
488 iterationIndex = loopScope.iteration
489 } else {
490 this.execLogger.warn('Loop scope not found for block', { blockId, loopId })
491 }
492 }
493 }
494
495 const containerId = parallelId ?? loopId
496 const parentIterations = containerId
497 ? buildUnifiedParentIterations(ctx, containerId)
498 : undefined
499
500 return {
501 blockId,
502 blockName,
503 blockType: block.metadata?.id ?? DEFAULTS.BLOCK_TYPE,
504 startedAt,
505 executionOrder: getNextExecutionOrder(ctx),
506 endedAt: '',
507 durationMs: 0,
508 success: false,
509 loopId,
510 parallelId,
511 iterationIndex,
512 ...(parentIterations?.length && { parentIterations }),
513 }
514 }
515

Callers 1

executeMethod · 0.95

Calls 4

getNextExecutionOrderFunction · 0.90
getMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected