MCPcopy Index your code
hub / github.com/coder/mux / createRun

Method createRun

src/node/services/workflows/WorkflowRunStore.ts:104–135  ·  view source on GitHub ↗
(input: CreateWorkflowRunInput)

Source from the content-addressed store, hash-verified

102 }
103
104 async createRun(input: CreateWorkflowRunInput): Promise<WorkflowRunRecord> {
105 assert(input.id.length > 0, "WorkflowRunStore.createRun: id is required");
106 assert(input.workspaceId.length > 0, "WorkflowRunStore.createRun: workspaceId is required");
107 assert(input.source.length > 0, "WorkflowRunStore.createRun: source is required");
108
109 const runDir = this.runDir(input.id);
110 await fs.mkdir(runDir, { recursive: true });
111 await fs.writeFile(path.join(runDir, WORKFLOW_SOURCE_FILENAME), input.source, "utf-8");
112 await fs.writeFile(path.join(runDir, "events.jsonl"), "", { flag: "a" });
113 await fs.writeFile(path.join(runDir, "steps.jsonl"), "", { flag: "a" });
114
115 const run = WorkflowRunRecordSchema.parse({
116 id: input.id,
117 workspaceId: input.workspaceId,
118 workflow: input.workflow,
119 source: input.source,
120 sourceHash: hashSource(input.source),
121 args: input.args,
122 agentOutputSchemaRequired: input.agentOutputSchemaRequired ?? true,
123 agentTypeAliasAllowed: input.agentTypeAliasAllowed ?? false,
124 ...(input.parentWorkflow != null ? { parentWorkflow: input.parentWorkflow } : {}),
125 ...(input.attentionPolicy != null ? { attentionPolicy: input.attentionPolicy } : {}),
126 status: "pending",
127 createdAt: input.now,
128 updatedAt: input.now,
129 events: [],
130 steps: [],
131 });
132
133 await this.writeRunFile(input.id, run);
134 return run;
135 }
136
137 async createRunIfAbsent(input: CreateWorkflowRunInput): Promise<WorkflowRunRecord> {
138 assert(input.id.length > 0, "WorkflowRunStore.createRunIfAbsent: id is required");

Callers 3

writeWorkflowRunFunction · 0.95
createStoreFunction · 0.95
createRunStoreFunction · 0.95

Calls 6

runDirMethod · 0.95
writeRunFileMethod · 0.95
hashSourceFunction · 0.70
writeFileMethod · 0.65
assertFunction · 0.50
parseMethod · 0.45

Tested by 3

writeWorkflowRunFunction · 0.76
createStoreFunction · 0.76
createRunStoreFunction · 0.76