MCPcopy
hub / github.com/coder/mux / createWorkflowService

Function createWorkflowService

src/cli/workflow.ts:349–395  ·  view source on GitHub ↗
(input: {
  ctx: WorkflowContext;
  opts: WorkflowCLIOptions;
  model: string;
  thinkingLevel: ParsedThinkingInput;
})

Source from the content-addressed store, hash-verified

347}
348
349function createWorkflowService(input: {
350 ctx: WorkflowContext;
351 opts: WorkflowCLIOptions;
352 model: string;
353 thinkingLevel: ParsedThinkingInput;
354}): WorkflowService {
355 const experiments = buildExperimentsObject(input.opts.experiment);
356 const runtime = createRuntime(input.ctx.runtimeConfig, {
357 projectPath: input.ctx.projectDir,
358 workspaceName: input.ctx.workspaceId,
359 workspacePath: input.ctx.workspacePath,
360 });
361 const workspaceSessionDir = input.ctx.config.getSessionDir(input.ctx.workspaceId);
362
363 return new WorkflowService({
364 runStore: new WorkflowRunStore({ sessionDir: workspaceSessionDir }),
365 runtimeFactory: new QuickJSRuntimeFactory(),
366 taskAdapterFactory: (runId) =>
367 new WorkflowTaskServiceAdapter({
368 taskService: input.ctx.services.taskService,
369 parentWorkspaceId: input.ctx.workspaceId,
370 workflowRunId: runId,
371 defaultAgentId: DEFAULT_WORKFLOW_AGENT_ID,
372 experiments,
373 modelString: input.model,
374 thinkingLevel: input.thinkingLevel,
375 getProjectTrusted: () => input.ctx.projectTrusted,
376 patchToolConfig: {
377 workspaceId: input.ctx.workspaceId,
378 cwd: input.ctx.workspacePath,
379 runtime,
380 runtimeTempDir: runtime.normalizePath(".mux/tmp", input.ctx.workspacePath),
381 workspaceSessionDir,
382 trusted: input.ctx.projectTrusted,
383 },
384 }),
385 resolveWorkflowScript: (scriptPath) =>
386 resolveWorkflowScript({
387 scriptPath,
388 runtime,
389 workspacePath: input.ctx.workspacePath,
390 projectTrusted: input.ctx.projectTrusted,
391 }),
392 getCurrentProjectTrusted: () => input.ctx.projectTrusted,
393 runnerId: input.ctx.workspaceId,
394 });
395}
396
397async function runWorkflow(scriptPath: string, options: WorkflowCLIOptions): Promise<number> {
398 const projectDir = await resolveProjectDir({

Callers 1

runWorkflowFunction · 0.85

Calls 5

createRuntimeFunction · 0.90
resolveWorkflowScriptFunction · 0.90
buildExperimentsObjectFunction · 0.70
getSessionDirMethod · 0.65
normalizePathMethod · 0.65

Tested by

no test coverage detected