> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Handoffs & A2A

> JavaScript API reference for Handoffs & A2A.

## agentSwitch

```typescript theme={null}
function agentSwitch(to: string, opts: AgentSwitchOptions = {}): Record<string, any>
```

Build a handoff directive that transfers control to another agent (by id).
Return the result from a tool to switch the active agent mid-call; the target
must be pre-registered via `AgentOptions.agents`.

<ParamField path="to" type="string" required>
  Id of the agent to switch to.
</ParamField>

<ParamField path="opts" type="AgentSwitchOptions" />

<ResponseField name="returns" type="Record<string, any>" />

***

## AgentCard

Create an AgentCard, filling unset fields with empty defaults.

### Constructor

```typescript theme={null}
new AgentCard(opts: AgentCardOptions)
```

<ParamField path="agentId" type="string">
  Unique identifier for this agent. Default: `''`.
</ParamField>

<ParamField path="name" type="string">
  Human-readable agent name. Default: `''`.
</ParamField>

<ParamField path="description" type="string">
  Short description of what the agent does. Default: `''`.
</ParamField>

<ParamField path="capabilities" type="string[]">
  List of capability tags advertised by the agent. Default: `[]`.
</ParamField>

<ParamField path="metadata" type="Record<string, any>">
  Arbitrary metadata to attach to the card. Default: `{}`.
</ParamField>

***

## A2AMessage

Create an A2AMessage. `messageType` defaults to `'text'`.

### Constructor

```typescript theme={null}
new A2AMessage(opts: A2AMessageOptions)
```

<ParamField path="sourceAgentId" type="string">
  ID of the agent sending the message. Default: `''`.
</ParamField>

<ParamField path="targetAgentId" type="string">
  ID of the agent the message is addressed to. Default: `''`.
</ParamField>

<ParamField path="messageType" type="string">
  Message kind. Default: `'text'`.
</ParamField>

<ParamField path="payload" type="Record<string, any>">
  Message body. Default: `{}`.
</ParamField>
