SwarmApi
Class: SwarmApi
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:43
Manages swarm coordination for multi-agent workflows.
Swarms organize agents into teams with roles, enabling complex collaborative tasks. This API handles swarm lifecycle, agent management, role assignment, and vacancy coordination.
Constructors
Constructor
new SwarmApi(http: HttpClient): SwarmApi;
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:44
Parameters
| Parameter | Type |
|---|---|
http | HttpClient |
Returns
SwarmApi
Methods
addAgent()
addAgent(swarmId: string, data: AgentRegistration): Promise<SwarmAgentInfo>;
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:179
Add an agent to a swarm.
Registers a new agent with the swarm, making it available for assignment to teams and roles. Agents are the worker entities that perform tasks within the swarm context.
Parameters
| Parameter | Type | Description |
|---|---|---|
swarmId | string | The unique identifier of the swarm |
data | AgentRegistration | The agent registration information |
Returns
Promise<SwarmAgentInfo>
A promise that resolves to the registered SwarmAgentInfo object
Example
const agent = await client.swarm.addAgent('swarm-123', {
agentId: 'agent-456',
name: 'Research Agent',
capabilities: ['analysis', 'writing']
});
applyToVacancy()
applyToVacancy(
swarmId: string,
vacancyId: string,
data?: ApplyToVacancyRequest): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:786
Apply to a vacancy in a swarm.
Submits an application from an agent for a specific vacancy. The agent will be considered for the position and may be selected based on qualifications and availability.
Parameters
| Parameter | Type | Description |
|---|---|---|
swarmId | string | The unique identifier of the swarm |
vacancyId | string | The unique identifier of the vacancy |
data? | ApplyToVacancyRequest | Optional application information |
Returns
Promise<void>
A promise that resolves when the application is submitted
Example
await client.swarm.applyToVacancy('swarm-123', 'vacancy-456', {
agentId: 'agent-789',
message: 'Experienced analyst ready to help'
});
approveSpawnRequest()
approveSpawnRequest(
swarmId: string,
requestId: string,
data?: SpawnRequestActionBody): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:1117
Approve a spawn request.
Approves a pending spawn request, authorizing the creation of new agent instances. The agents will be spawned according to the request specifications.
Parameters
| Parameter | Type | Description |
|---|---|---|
swarmId | string | The unique identifier of the swarm |
requestId | string | The unique identifier of the spawn request |
data? | SpawnRequestActionBody | Optional approval information |
Returns
Promise<void>
A promise that resolves when the request is approved
Example
await client.swarm.approveSpawnRequest('swarm-123', 'request-456', {
approver: 'admin',
comment: 'Approved for capacity increase'
});
approveTerminationRequest()
approveTerminationRequest(
swarmId: string,
requestId: string,
data?: TerminationRequestActionBody): Promise<void>;
Defined in: CodeBolt/packages/clientsdk/src/api/swarm.api.ts:1265
Approve a termination request.
Approves a pending termination request, authorizing the removal of specified agent instances. The agents will be terminated gracefully.