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

Class ExecutionContextBuilder

packages/testing/src/builders/execution.builder.ts:20–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 * ```
19 */
20export class ExecutionContextBuilder {
21 private workflowId = 'test-workflow'
22 private executionId = `exec-${generateRandomString(8)}`
23 private blockStates = new Map<string, any>()
24 private executedBlocks = new Set<string>()
25 private blockLogs: any[] = []
26 private metadata: { duration: number; startTime?: string; endTime?: string } = { duration: 0 }
27 private environmentVariables: Record<string, string> = {}
28 private workflowVariables: Record<string, any> = {}
29 private routerDecisions = new Map<string, any>()
30 private conditionDecisions = new Map<string, any>()
31 private loopExecutions = new Map<string, any>()
32 private completedLoops = new Set<string>()
33 private activeExecutionPath = new Set<string>()
34 private abortSignal?: AbortSignal
35
36 /**
37 * Sets the workflow ID.
38 */
39 forWorkflow(workflowId: string): this {
40 this.workflowId = workflowId
41 return this
42 }
43
44 /**
45 * Sets a custom execution ID.
46 */
47 withExecutionId(executionId: string): this {
48 this.executionId = executionId
49 return this
50 }
51
52 /**
53 * Adds a block state.
54 */
55 withBlockState(blockId: string, state: any): this {
56 this.blockStates.set(blockId, state)
57 return this
58 }
59
60 /**
61 * Adds multiple block states at once.
62 */
63 withBlockStates(states: Record<string, any>): this {
64 Object.entries(states).forEach(([id, state]) => {
65 this.blockStates.set(id, state)
66 })
67 return this
68 }
69
70 /**
71 * Marks a block as executed.
72 */
73 markExecuted(blockId: string): this {
74 this.executedBlocks.add(blockId)
75 return this
76 }
77

Callers

nothing calls this directly

Calls 1

generateRandomStringFunction · 0.90

Tested by

no test coverage detected