({
server,
writer,
agentExecutor,
repoId,
taskId,
eventId,
runtimeId,
executionId,
harnessId,
cwd,
prompt,
appendSystemPrompt,
readOnly,
modelId,
thinking,
fastMode,
activeTaskExecutions,
onCompleted,
}: {
server?: RuntimeServer
writer: ReturnType<typeof createOpenADEYjsWriter>
agentExecutor: RuntimeNodeAgentExecutor
repoId: string
taskId: string
eventId: string
runtimeId: string
executionId: string
harnessId: "claude-code" | "codex"
cwd: string
prompt: string
appendSystemPrompt?: string
readOnly: boolean
modelId?: string
thinking?: OpenADETurnStartRequest["thinking"]
fastMode?: boolean
activeTaskExecutions: Map<string, ActiveTaskExecution>
onCompleted?: (result: { events: Array<Record<string, unknown>>; sessionId?: string }) => Promise<void> | void
})
| 1106 | } |
| 1107 | |
| 1108 | async function runHeadlessTurn({ |
| 1109 | server, |
| 1110 | writer, |
| 1111 | agentExecutor, |
| 1112 | repoId, |
| 1113 | taskId, |
| 1114 | eventId, |
| 1115 | runtimeId, |
| 1116 | executionId, |
| 1117 | harnessId, |
| 1118 | cwd, |
| 1119 | prompt, |
| 1120 | appendSystemPrompt, |
| 1121 | readOnly, |
| 1122 | modelId, |
| 1123 | thinking, |
| 1124 | fastMode, |
| 1125 | activeTaskExecutions, |
| 1126 | onCompleted, |
| 1127 | }: { |
| 1128 | server?: RuntimeServer |
| 1129 | writer: ReturnType<typeof createOpenADEYjsWriter> |
| 1130 | agentExecutor: RuntimeNodeAgentExecutor |
| 1131 | repoId: string |
| 1132 | taskId: string |
| 1133 | eventId: string |
| 1134 | runtimeId: string |
| 1135 | executionId: string |
| 1136 | harnessId: "claude-code" | "codex" |
| 1137 | cwd: string |
| 1138 | prompt: string |
| 1139 | appendSystemPrompt?: string |
| 1140 | readOnly: boolean |
| 1141 | modelId?: string |
| 1142 | thinking?: OpenADETurnStartRequest["thinking"] |
| 1143 | fastMode?: boolean |
| 1144 | activeTaskExecutions: Map<string, ActiveTaskExecution> |
| 1145 | onCompleted?: (result: { events: Array<Record<string, unknown>>; sessionId?: string }) => Promise<void> | void |
| 1146 | }): Promise<void> { |
| 1147 | const pendingWrites: Array<Promise<unknown>> = [] |
| 1148 | const observedEvents: Array<Record<string, unknown>> = [] |
| 1149 | let savedSessionId: string | undefined |
| 1150 | let finalized = false |
| 1151 | |
| 1152 | const enqueue = (write: Promise<unknown>) => { |
| 1153 | pendingWrites.push(write.catch((error) => console.warn("[RuntimeNodeOpenADE] Failed to persist stream event:", error))) |
| 1154 | } |
| 1155 | const finalize = async (status: "completed" | "failed" | "stopped", error?: string) => { |
| 1156 | if (finalized) return |
| 1157 | finalized = true |
| 1158 | await Promise.all(pendingWrites) |
| 1159 | |
| 1160 | if (status === "completed") { |
| 1161 | await writer.completeActionEvent({ taskId, eventId, success: true }) |
| 1162 | const runtime = server?.supervisor.update(runtimeId, { status: "completed" }) |
| 1163 | server?.notify("runtime/completed", runtime) |
| 1164 | } else if (status === "stopped") { |
| 1165 | await writer.stoppedActionEvent({ taskId, eventId }) |
no test coverage detected