# A2A

Show A2A v1 messages, task status, and artifacts together.

## Load a task or message

[Install Ghost UI and its view dependencies](/libraries/ai#installation), then add the A2A v1 SDK.

```bash
npm install @a2a-js/sdk@1.3.0
```

Create an authenticated Client with ClientFactory and your server’s agent card. Your app handles discovery, trust, and credentials.

```tsx
import type { Client } from "@a2a-js/sdk/client";
import type { Task } from "@a2a-js/sdk";
import { normalizeA2aTask } from "@collectivecreation/ghost-ui/chat-normalizers";
import { Message, MessageBody } from "@collectivecreation/ghost-ui/components/message";
import { MessageParts } from "@collectivecreation/ghost-ui/components/message-parts";
export async function loadTask(client: Client, tenant: string, id: string) {
  return client.getTask({ tenant, id, historyLength: 100 });
}
export function A2aTask({ task }: { task: Task }) {
  const messages = normalizeA2aTask(task);
  return <>{messages.map(message => <Message key={message.id} actor={message.actor}><MessageBody>
    <MessageParts parts={message.parts} />
  </MessageBody></Message>)}</>;
}

```

```tsx
import { Message } from "@a2a-js/sdk";
import type { Client } from "@a2a-js/sdk/client";
export function sendA2a(client: Client, tenant: string, text: string, contextId?: string) {
  return client.sendMessage({ tenant, configuration: undefined, metadata: undefined,
    message: Message.fromJSON({ messageId: crypto.randomUUID(), role: "ROLE_USER", contextId, parts: [{ text }] }),
  });
}
export function cancelA2a(client: Client, tenant: string, taskId: string) {
  return client.cancelTask({ tenant, id: taskId, metadata: undefined });
}

```

Use normalizeA2aMessages for messages and normalizeA2aTask for tasks. For live updates, use sendMessageStream or a task subscription. Apply status and artifact events to your task store before passing the new snapshot to the view.

## A transcript is only one view of a task

normalizeA2aTask keeps task ID, context ID, status and artifacts in a2a-task data. input_required and auth_required need application flows; neither means a pending boolean tool approval. Artifacts can contain structured data or files independently of a message. Validate and render them with MessageParts.renderers.data, or show an application artifact panel beside the transcript.

The normalizer accepts protobuf v1 oneof parts/enums and their JSON representation. Native message IDs and ordered history survive projection. A2A v0.3 uses the SDK's separate compatibility entry; do not treat those shapes as v1.

## Troubleshooting

A visible data notice can be an unrendered task/artifact, not a lost answer. Retain task IDs for cancellation/resubscription and context IDs for follow-up messages. Task cancellation is a request to the remote agent, not a guaranteed local status transition. See [A2A specification](https://a2a-protocol.org/latest/specification/) and the [SDK](https://github.com/a2aproject/a2a-js) for streaming, discovery and authentication.
