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

Method initializeStarterBlock

apps/sim/executor/execution/executor.ts:576–627  ·  view source on GitHub ↗
(
    context: ExecutionContext,
    state: ExecutionState,
    triggerBlockId?: string
  )

Source from the content-addressed store, hash-verified

574 }
575
576 private initializeStarterBlock(
577 context: ExecutionContext,
578 state: ExecutionState,
579 triggerBlockId?: string
580 ): void {
581 let startResolution: ReturnType<typeof resolveExecutorStartBlock> | null = null
582
583 if (triggerBlockId) {
584 const triggerBlock = this.workflow.blocks.find((b) => b.id === triggerBlockId)
585 if (!triggerBlock) {
586 this.execLogger.error('Specified trigger block not found in workflow', {
587 triggerBlockId,
588 })
589 throw new Error(`Trigger block not found: ${triggerBlockId}`)
590 }
591
592 startResolution = buildResolutionFromBlock(triggerBlock)
593
594 if (!startResolution) {
595 startResolution = {
596 blockId: triggerBlock.id,
597 block: triggerBlock,
598 path: StartBlockPath.SPLIT_MANUAL,
599 }
600 }
601 } else {
602 startResolution = resolveExecutorStartBlock(this.workflow.blocks, {
603 execution: 'manual',
604 isChildWorkflow: false,
605 })
606
607 if (!startResolution?.block) {
608 this.execLogger.warn('No start block found in workflow')
609 return
610 }
611 }
612
613 if (state.getBlockStates().has(startResolution.block.id)) {
614 return
615 }
616
617 const blockOutput = buildStartBlockOutput({
618 resolution: startResolution,
619 workflowInput: this.workflowInput,
620 })
621
622 state.setBlockState(startResolution.block.id, {
623 output: blockOutput,
624 executed: false,
625 executionTime: 0,
626 })
627 }
628}

Callers 1

Calls 7

buildResolutionFromBlockFunction · 0.90
buildStartBlockOutputFunction · 0.90
errorMethod · 0.80
getBlockStatesMethod · 0.80
warnMethod · 0.65
setBlockStateMethod · 0.65

Tested by

no test coverage detected