(id: string, userId: string, runSource: 'api' | 'sdk' | 'mcp' | 'cli', requestedFormats?: OutputFormats[], promptInstructions?: string)
| 550 | }); |
| 551 | |
| 552 | async function createWorkflowAndStoreMetadata(id: string, userId: string, runSource: 'api' | 'sdk' | 'mcp' | 'cli', requestedFormats?: OutputFormats[], promptInstructions?: string) { |
| 553 | try { |
| 554 | const recording = await Robot.findOne({ |
| 555 | where: { |
| 556 | 'recording_meta.id': id, |
| 557 | userId: userId, |
| 558 | }, |
| 559 | raw: true |
| 560 | }); |
| 561 | |
| 562 | if (!recording || !recording.recording_meta || !recording.recording_meta.id) { |
| 563 | return { |
| 564 | success: false, |
| 565 | error: 'Recording not found' |
| 566 | }; |
| 567 | } |
| 568 | |
| 569 | const robotType = (recording.recording_meta as any).type || (recording.recording_meta as any).robotType; |
| 570 | const isDocRobot = robotType === 'doc-extract' || robotType === 'doc-parse'; |
| 571 | |
| 572 | const proxyConfig = await getDecryptedProxyConfig(userId); |
| 573 | let proxyOptions: any = {}; |
| 574 | |
| 575 | if (proxyConfig.proxy_url) { |
| 576 | proxyOptions = { |
| 577 | server: proxyConfig.proxy_url, |
| 578 | ...(proxyConfig.proxy_username && proxyConfig.proxy_password && { |
| 579 | username: proxyConfig.proxy_username, |
| 580 | password: proxyConfig.proxy_password, |
| 581 | }), |
| 582 | }; |
| 583 | } |
| 584 | |
| 585 | const browserId = isDocRobot ? uuid() : createRemoteBrowserForRun(userId); |
| 586 | |
| 587 | const runId = uuid(); |
| 588 | |
| 589 | const run = await Run.create({ |
| 590 | status: 'running', |
| 591 | name: recording.recording_meta.name, |
| 592 | robotId: recording.id, |
| 593 | robotMetaId: recording.recording_meta.id, |
| 594 | startedAt: new Date().toLocaleString(), |
| 595 | finishedAt: '', |
| 596 | browserId, |
| 597 | interpreterSettings: { maxConcurrency: 1, maxRepeats: 1, debug: true, formats: requestedFormats, promptInstructions, ...(isDocRobot && { robotType }) }, |
| 598 | log: '', |
| 599 | runId, |
| 600 | runByUserId: userId, |
| 601 | runByAPI: runSource === 'api', |
| 602 | runBySDK: runSource === 'sdk', |
| 603 | runByMCP: runSource === 'mcp', |
| 604 | runByCLI: runSource === 'cli', |
| 605 | serializableOutput: {}, |
| 606 | binaryOutput: {}, |
| 607 | retryCount: 0 |
| 608 | }); |
| 609 |
no test coverage detected