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

Method createExecutionContext

apps/sim/executor/execution/executor.ts:387–540  ·  view source on GitHub ↗
(
    workflowId: string,
    triggerBlockId?: string,
    overrides?: {
      snapshotState?: SerializableExecutionState
      runFromBlockContext?: RunFromBlockContext
    }
  )

Source from the content-addressed store, hash-verified

385 }
386
387 private createExecutionContext(
388 workflowId: string,
389 triggerBlockId?: string,
390 overrides?: {
391 snapshotState?: SerializableExecutionState
392 runFromBlockContext?: RunFromBlockContext
393 }
394 ): { context: ExecutionContext; state: ExecutionState } {
395 const snapshotState = overrides?.snapshotState ?? this.contextExtensions.snapshotState
396 const blockStates = snapshotState?.blockStates
397 ? new Map(Object.entries(snapshotState.blockStates))
398 : new Map<string, BlockState>()
399 let executedBlocks = snapshotState?.executedBlocks
400 ? new Set(snapshotState.executedBlocks)
401 : new Set<string>()
402
403 if (overrides?.runFromBlockContext) {
404 const { dirtySet } = overrides.runFromBlockContext
405 executedBlocks = new Set([...executedBlocks].filter((id) => !dirtySet.has(id)))
406 this.execLogger.info('Cleared executed status for dirty blocks', {
407 dirtySetSize: dirtySet.size,
408 remainingExecutedBlocks: executedBlocks.size,
409 })
410 }
411
412 const state = new ExecutionState(blockStates, executedBlocks)
413
414 const context: ExecutionContext = {
415 workflowId,
416 workspaceId: this.contextExtensions.workspaceId,
417 executionId: this.contextExtensions.executionId,
418 largeValueExecutionIds: this.contextExtensions.largeValueExecutionIds,
419 largeValueKeys: this.contextExtensions.largeValueKeys,
420 fileKeys: this.contextExtensions.fileKeys,
421 allowLargeValueWorkflowScope: this.contextExtensions.allowLargeValueWorkflowScope,
422 userId: this.contextExtensions.userId,
423 isDeployedContext: this.contextExtensions.isDeployedContext,
424 enforceCredentialAccess: this.contextExtensions.enforceCredentialAccess,
425 piiBlockOutputRedaction: this.contextExtensions.piiBlockOutputRedaction,
426 blockStates: state.getBlockStates(),
427 blockLogs: overrides?.runFromBlockContext ? [] : (snapshotState?.blockLogs ?? []),
428 metadata: {
429 ...this.contextExtensions.metadata,
430 startTime: new Date().toISOString(),
431 duration: 0,
432 useDraftState:
433 this.contextExtensions.metadata?.useDraftState ??
434 this.contextExtensions.isDeployedContext !== true,
435 },
436 environmentVariables: this.environmentVariables,
437 workflowVariables: this.workflowVariables,
438 decisions: {
439 router: snapshotState?.decisions?.router
440 ? new Map(Object.entries(snapshotState.decisions.router))
441 : new Map(),
442 condition: snapshotState?.decisions?.condition
443 ? new Map(Object.entries(snapshotState.decisions.condition))
444 : new Map(),

Callers 3

executeMethod · 0.95
executeFromBlockMethod · 0.95

Calls 5

getBlockStatesMethod · 0.95
getExecutedBlocksMethod · 0.95
normalizeStringArrayFunction · 0.90
infoMethod · 0.80

Tested by 1