Class: Crew
Defined in: packages/orchestration/src/crew/crew.ts:50
Constructors
Constructor
new Crew(
config):Crew
Defined in: packages/orchestration/src/crew/crew.ts:75
Parameters
config
Returns
Crew
Methods
addAgent()
addAgent(
agent):RegisteredAgent
Defined in: packages/orchestration/src/crew/crew.ts:213
Register an additional agent after construction
Parameters
agent
Returns
dispose()
dispose():
Promise<void>
Defined in: packages/orchestration/src/crew/crew.ts:272
Tear down the crew permanently: cancel active runs, stop the orchestrator, stop the sessions this crew started, then release the host resources of everything the crew owns.
That last step is why this is async. An agent is any Processable, and
one may hold something that outlives the process; template.toCrew()
builds its agents inside the renderer — the caller holds the crew and
never the bots, so this is the only reachable place to release them.
It only closes what the crew owns: agents marked
CrewAgentConfig.owned (which template.toCrew() sets on the bots it
built) and the coordinators start() built. An agent you constructed and
passed in is yours — a crew has no refcount and cancels only its own runs,
so closing a bot another crew or a Team is mid-call against would pull
its resources out from under it. Close those yourself with closeAll().
Stopping a session is a different lifetime, in both directions.
CrewSession.stop() ends one conversation, asks the coordinator for a
closing summary, and leaves the agents intact — the same crew can
start() another session against them. dispose() is the reverse: it
ends the crew without a model call, so a session it stops produces no
summary and no crew.done. For a clean finish to a live session, call
await session.stop() first and then await crew.dispose().
Closing is restartable per the Processable.close() contract, so an agent
the caller also uses elsewhere rebuilds what it needs on its next
process() rather than breaking. Runs are cancelled first regardless, so
nothing is left executing against something about to go away.
Permanent and idempotent: a second call is a no-op, and start() throws
afterwards rather than rebuilding a crew nothing is tracking.
Including after a failure. A rejected dispose() is not retryable —
the crew is already marked disposed and has dropped its references, so a
second call returns immediately without reattempting, and an owned agent
the caller never held is unreachable from then on. That is the honest
shape rather than a gap: close() is idempotent and clears its handles
before awaiting, so a retry would find nothing left to do anyway. Read
CloseFailedError.errors (or its cause) to see what leaked.
Returns
Promise<void>
getGroupId()
getGroupId():
string
Defined in: packages/orchestration/src/crew/crew.ts:115
DeclaredGroup — how the dev panel lists this crew.
getMemberKeys reads this.roster, which is the live array, so an agent
added by addAgent() after construction shows up on the next list rather
than at the next restart. Same rule the family side follows: the registry
asks, it is never told once and left to go stale.
Returns
string
getGroupKind()
getGroupKind():
string
Defined in: packages/orchestration/src/crew/crew.ts:119
Returns
string
getMemberKeys()
getMemberKeys():
string[]
Defined in: packages/orchestration/src/crew/crew.ts:123
Returns
string[]
getOrchestrator()
getOrchestrator():
Orchestrator
Defined in: packages/orchestration/src/crew/crew.ts:227
Get the underlying orchestrator (for advanced usage)
Returns
start()
start(
goal):Promise<CrewSession>
Defined in: packages/orchestration/src/crew/crew.ts:167
Start a crew session with a goal. Returns a CrewSession for ongoing conversation while workers execute.
Throws once the crew has been disposed. dispose() is permanent, and a
silent restart here is worse than an error: it re-arms the scheduler and a
second proactive timer, and pushes a coordinator onto a list nothing will
drain — the exact leak dispose() exists to close. Build a new crew.
async with nothing to await, deliberately. The initial goal is sent
without blocking — that is the whole point of returning a session — so
there is no await to have. What the keyword buys is that the disposal
guard above arrives as a rejection rather than a synchronous throw, which
is what every caller (and Crew.dispose()'s own contract) expects of a
method typed Promise<CrewSession>.
Parameters
goal
string
Returns
Promise<CrewSession>