MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / stopActiveOpenADERuntime

Function stopActiveOpenADERuntime

projects/openade-module/src/node.ts:231–262  ·  view source on GitHub ↗
({
    server,
    writer,
    agentExecutor,
    activeTaskExecutions,
    runtime,
}: {
    server: RuntimeServer
    writer: ReturnType<typeof createOpenADEYjsWriter>
    agentExecutor: RuntimeNodeAgentExecutor
    activeTaskExecutions: Map<string, ActiveTaskExecution>
    runtime: RuntimeRecord
})

Source from the content-addressed store, hash-verified

229}
230
231async 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
264export function createRuntimeNodeOpenADEAdapters(options: RuntimeNodeOpenADEOptions = {}): OpenADEModuleAdapters {
265 const storage = createOpenADENodeYjsStorage(options.dataDir ?? defaultDataDir())

Callers 1

Calls 7

notifyWorkingTasksFunction · 0.85
notifyTaskChangedFunction · 0.85
entriesMethod · 0.80
allMethod · 0.80
interruptMethod · 0.80
stoppedActionEventMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected