@cogitator-ai/a2a 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +139 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # @cogitator-ai/a2a
2
+
3
+ Native implementation of [Google's A2A Protocol v0.3](https://a2a-protocol.org) for Cogitator. Expose agents as A2A services or connect to any A2A-compatible agent across frameworks.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @cogitator-ai/a2a
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **A2AServer** - Expose any Cogitator agent as an A2A-compliant service
14
+ - **A2AClient** - Connect to remote A2A agents with discovery and streaming
15
+ - **asTool() Bridge** - Wrap remote A2A agents as local Cogitator tools
16
+ - **Agent Card** - Auto-generate A2A Agent Cards from agent metadata
17
+ - **Task Management** - Full task lifecycle (working, completed, failed, canceled)
18
+ - **SSE Streaming** - Real-time streaming on both server and client
19
+ - **Framework Adapters** - Express, Hono, Fastify, Koa, Next.js
20
+ - **Zero Dependencies** - Own implementation from spec, no external A2A deps
21
+
22
+ ---
23
+
24
+ ## Quick Start
25
+
26
+ ### Expose an Agent via A2A
27
+
28
+ ```typescript
29
+ import { Cogitator, Agent } from '@cogitator-ai/core';
30
+ import { A2AServer } from '@cogitator-ai/a2a';
31
+ import { a2aExpress } from '@cogitator-ai/a2a/express';
32
+ import express from 'express';
33
+
34
+ const cogitator = new Cogitator();
35
+ const agent = new Agent({
36
+ name: 'researcher',
37
+ description: 'Research agent',
38
+ model: 'openai/gpt-4o',
39
+ instructions: 'You are a research assistant.',
40
+ });
41
+
42
+ const a2aServer = new A2AServer({
43
+ agents: { researcher: agent },
44
+ cogitator,
45
+ cardUrl: 'https://my-server.com',
46
+ });
47
+
48
+ const app = express();
49
+ app.use(a2aExpress(a2aServer));
50
+ app.listen(3000);
51
+ // Agent Card: GET /.well-known/agent.json
52
+ // JSON-RPC: POST /a2a
53
+ ```
54
+
55
+ ### Connect to a Remote A2A Agent
56
+
57
+ ```typescript
58
+ import { A2AClient } from '@cogitator-ai/a2a';
59
+
60
+ const client = new A2AClient('https://remote-agent.example.com');
61
+
62
+ // Discover
63
+ const card = await client.agentCard();
64
+ console.log(card.name, card.skills);
65
+
66
+ // Send message
67
+ const task = await client.sendMessage({
68
+ role: 'user',
69
+ parts: [{ type: 'text', text: 'Research quantum computing' }],
70
+ });
71
+
72
+ // Stream
73
+ for await (const event of client.sendMessageStream({
74
+ role: 'user',
75
+ parts: [{ type: 'text', text: 'Analyze market trends' }],
76
+ })) {
77
+ console.log(event.type, event);
78
+ }
79
+ ```
80
+
81
+ ### Use Remote Agent as a Tool
82
+
83
+ ```typescript
84
+ const client = new A2AClient('https://research-agent.example.com');
85
+ const card = await client.agentCard();
86
+ const remoteTool = client.asToolFromCard(card);
87
+
88
+ const orchestrator = new Agent({
89
+ name: 'orchestrator',
90
+ model: 'openai/gpt-4o',
91
+ instructions: 'Use the researcher for information gathering.',
92
+ tools: [remoteTool],
93
+ });
94
+
95
+ const result = await cogitator.run(orchestrator, {
96
+ input: 'Write a report on AI trends',
97
+ });
98
+ ```
99
+
100
+ ## Framework Adapters
101
+
102
+ ```typescript
103
+ // Express
104
+ import { a2aExpress } from '@cogitator-ai/a2a/express';
105
+ app.use(a2aExpress(server));
106
+
107
+ // Hono
108
+ import { a2aHono } from '@cogitator-ai/a2a/hono';
109
+ app.route('/a2a', a2aHono(server));
110
+
111
+ // Fastify
112
+ import { a2aFastify } from '@cogitator-ai/a2a/fastify';
113
+ fastify.register(a2aFastify(server));
114
+
115
+ // Koa
116
+ import { a2aKoa } from '@cogitator-ai/a2a/koa';
117
+ app.use(a2aKoa(server));
118
+
119
+ // Next.js
120
+ import { a2aNext } from '@cogitator-ai/a2a/next';
121
+ export const { GET, POST } = a2aNext(server);
122
+ ```
123
+
124
+ ## A2A Protocol
125
+
126
+ | Method | Description |
127
+ | ---------------- | ---------------------------------- |
128
+ | `message/send` | Send a message, get completed task |
129
+ | `message/stream` | Send with SSE streaming |
130
+ | `tasks/get` | Retrieve task by ID |
131
+ | `tasks/cancel` | Cancel a running task |
132
+
133
+ ## Part of Cogitator
134
+
135
+ This package is part of the [Cogitator](https://github.com/cogitator-ai/Cogitator-AI) ecosystem — a self-hosted, production-grade AI agent runtime for TypeScript.
136
+
137
+ ## License
138
+
139
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogitator-ai/a2a",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A2A (Agent-to-Agent) Protocol v0.3 implementation for Cogitator",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,8 @@
32
32
  }
33
33
  },
34
34
  "files": [
35
- "dist"
35
+ "dist",
36
+ "README.md"
36
37
  ],
37
38
  "scripts": {
38
39
  "build": "tsc",