({
server,
writer,
agentExecutor,
activeTaskExecutions,
runtime,
}: {
server: RuntimeServer
writer: ReturnType<typeof createOpenADEYjsWriter>
agentExecutor: RuntimeNodeAgentExecutor
activeTaskExecutions: Map<string, ActiveTaskExecution>
runtime: RuntimeRecord
})
| 229 | } |
| 230 | |
| 231 | async function stopActiveOpenADERuntime({ |
| 232 | server, |
| 233 | writer, |
| 234 | agentExecutor, |
| 235 | activeTaskExecutions, |
| 236 | runtime, |
| 237 | }: { |
| 238 | server: RuntimeServer |
| 239 | writer: ReturnType<typeof createOpenADEYjsWriter> |
| 240 | agentExecutor: RuntimeNodeAgentExecutor |
| 241 | activeTaskExecutions: Map<string, ActiveTaskExecution> |
| 242 | runtime: RuntimeRecord |
| 243 | }): Promise<boolean> { |
| 244 | if (runtime.scope.ownerType !== "openade-task" && runtime.scope.ownerType !== "openade-turn" && runtime.scope.ownerType !== "openade-review") return false |
| 245 | const activeEntry = [...activeTaskExecutions.entries()].find(([, active]) => active.runtimeId === runtime.runtimeId) |
| 246 | if (!activeEntry) return false |
| 247 | |
| 248 | const [taskId, active] = activeEntry |
| 249 | active.stopping = true |
| 250 | const executionIds = active.childExecutionIds && active.childExecutionIds.size > 0 ? Array.from(active.childExecutionIds) : [active.executionId] |
| 251 | const results = await Promise.all(executionIds.map((executionId) => agentExecutor.interrupt(executionId))) |
| 252 | const failed = results.find((result) => !result.ok) |
| 253 | if (failed) { |
| 254 | throw new RuntimeHandlerError("stop_failed", failed.error ?? "Failed to stop OpenADE runtime", { runtimeId: runtime.runtimeId }) |
| 255 | } |
| 256 | |
| 257 | await writer.stoppedActionEvent({ taskId, eventId: active.eventId }) |
| 258 | activeTaskExecutions.delete(taskId) |
| 259 | notifyWorkingTasks(server) |
| 260 | notifyTaskChanged(server, active.repoId, taskId) |
| 261 | return true |
| 262 | } |
| 263 | |
| 264 | export function createRuntimeNodeOpenADEAdapters(options: RuntimeNodeOpenADEOptions = {}): OpenADEModuleAdapters { |
| 265 | const storage = createOpenADENodeYjsStorage(options.dataDir ?? defaultDataDir()) |
no test coverage detected