(
ownerWorkspaceId: string,
runId: string
)
| 4462 | } |
| 4463 | |
| 4464 | private async buildWorkflowTerminalPrompt( |
| 4465 | ownerWorkspaceId: string, |
| 4466 | runId: string |
| 4467 | ): Promise<string | null> { |
| 4468 | assert(ownerWorkspaceId.length > 0, "buildWorkflowTerminalPrompt requires ownerWorkspaceId"); |
| 4469 | assert(runId.length > 0, "buildWorkflowTerminalPrompt requires runId"); |
| 4470 | const runStore = new WorkflowRunStore({ |
| 4471 | sessionDir: this.config.getSessionDir(ownerWorkspaceId), |
| 4472 | }); |
| 4473 | let run: Awaited<ReturnType<WorkflowRunStore["getRun"]>>; |
| 4474 | try { |
| 4475 | run = await runStore.getRun(runId); |
| 4476 | } catch (error: unknown) { |
| 4477 | log.warn("Failed to load terminal workflow run for wake-up", { |
| 4478 | ownerWorkspaceId, |
| 4479 | runId, |
| 4480 | error: getErrorMessage(error), |
| 4481 | }); |
| 4482 | return null; |
| 4483 | } |
| 4484 | if ( |
| 4485 | run.workspaceId !== ownerWorkspaceId || |
| 4486 | run.parentWorkflow != null || |
| 4487 | !isTerminalWorkflowRunStatus(run.status) || |
| 4488 | !(await this.workspaceService.isWorkflowInvocationCurrent(ownerWorkspaceId, run.id)) |
| 4489 | ) { |
| 4490 | return null; |
| 4491 | } |
| 4492 | const scriptPath = run.workflow.sourcePath ?? run.workflow.name; |
| 4493 | return buildWorkflowResultContextMessage({ |
| 4494 | rawCommand: `workflow_run ${scriptPath}`, |
| 4495 | name: scriptPath, |
| 4496 | runId: run.id, |
| 4497 | status: run.status, |
| 4498 | result: null, |
| 4499 | run, |
| 4500 | }); |
| 4501 | } |
| 4502 | |
| 4503 | /** |
| 4504 | * Drain pending terminal notifications for one owner workspace: defer (leave pending) when the |
no test coverage detected