Skip to main content

Class: RunManager

Defined in: packages/orchestration/src/run/run-manager.ts:18

Manages the lifecycle of agent execution runs. This is the critical integration point where agent.process() is called and streaming events are captured to Supabase for live UI.

Constructors

Constructor

new RunManager(runStore, ticketStore, registry, events, costs): RunManager

Defined in: packages/orchestration/src/run/run-manager.ts:21

Parameters

runStore

RunStore

ticketStore

TicketStore

registry

AgentRegistry

events

EventBus<OrchestrationEventMap>

costs

CostTracker

Returns

RunManager

Methods

cancel()

cancel(runId): Promise<void>

Defined in: packages/orchestration/src/run/run-manager.ts:277

Cancel a running run

Parameters

runId

string

Returns

Promise<void>


getActive()

getActive(): Map<string, ActiveRun>

Defined in: packages/orchestration/src/run/run-manager.ts:284

Get all active runs

Returns

Map<string, ActiveRun>


getActiveCount()

getActiveCount(): number

Defined in: packages/orchestration/src/run/run-manager.ts:289

Get active run count

Returns

number


resumeRun()

resumeRun(runId, answer): Promise<Run>

Defined in: packages/orchestration/src/run/run-manager.ts:305

Resume a paused run with an answer to the agent's question.

Creates a new run for the same ticket, restoring the agent's conversation history from the paused run's serialized state. The answer is passed as the new input, and the agent sees its full previous conversation context.

Parameters

runId

string

The paused run's ID

answer

string

The answer to the agent's question

Returns

Promise<Run>

The new run (completed or paused again)


spawn()

spawn(ticket, agentName): Promise<Run>

Defined in: packages/orchestration/src/run/run-manager.ts:40

Spawn a run: create run record, call agent.process(), stream events to store.

This is the critical path for live streaming:

  1. Creates a Run record in Supabase
  2. Updates ticket status to in_progress
  3. Calls agent.process() with onToken callback that persists every event
  4. Each event is emitted on EventBus for server-side listeners
  5. Uses AbortController signal for pause/cancel
  6. On completion, updates run and ticket status

Parameters

ticket

Ticket

agentName

string

Returns

Promise<Run>