@runtypelabs/a2a-aisdk-example 0.2.3 → 0.3.0

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @runtypelabs/a2a-agent-example
1
+ # @runtypelabs/a2a-aisdk-example
2
2
 
3
3
  Reference A2A agent implementation with **deterministic time tools** and LLM-powered chat.
4
4
 
@@ -19,12 +19,12 @@ This agent includes deterministic time skills that compute answers from the syst
19
19
 
20
20
  ```bash
21
21
  # Using CLI
22
- npx a2a-agent-example serve --echo
22
+ npx @runtypelabs/a2a-aisdk-example serve --echo
23
23
  ```
24
24
 
25
25
  This starts a server at:
26
26
 
27
- - Agent Card: `http://localhost:9999/.well-known/agent.json`
27
+ - Agent Card: `http://localhost:9999/.well-known/agent-card.json`
28
28
  - A2A Endpoint: `http://localhost:9999/a2a`
29
29
 
30
30
  ### Test a time skill
@@ -35,42 +35,64 @@ curl -X POST http://localhost:9999/a2a \
35
35
  -d '{
36
36
  "jsonrpc": "2.0",
37
37
  "id": "1",
38
- "method": "tasks/send",
38
+ "method": "message/send",
39
39
  "params": {
40
- "skill": "time/day_of_week",
41
40
  "message": {
42
41
  "role": "user",
43
- "parts": [{"type": "data", "data": {"date": "2025-02-04"}}]
44
- }
42
+ "parts": [{"data": {"date": "2025-02-04"}}]
43
+ },
44
+ "metadata": { "skill": "time/day_of_week" }
45
45
  }
46
46
  }'
47
- # Returns: { "result": { "day": "Tuesday", ... }, "computed": { "method": "deterministic" } }
47
+ ```
48
+
49
+ Returns:
50
+ ```bash
51
+ { "result": { "day": "Tuesday", ... }, "computed": { "method": "deterministic" } }
48
52
  ```
49
53
 
50
54
  ### Run with LLM
51
55
 
52
56
  ```bash
53
57
  # OpenAI
54
- OPENAI_API_KEY=sk-xxx npx a2a-agent-example serve
58
+ OPENAI_API_KEY=sk-xxx npx @runtypelabs/a2a-aisdk-example serve
55
59
 
56
60
  # Anthropic
57
- ANTHROPIC_API_KEY=sk-xxx npx a2a-agent-example serve --provider anthropic --model claude-3-haiku-20240307
61
+ ANTHROPIC_API_KEY=sk-xxx npx @runtypelabs/a2a-aisdk-example serve --provider anthropic --model claude-3-haiku-20240307
58
62
  ```
59
63
 
60
64
  ### Test an A2A Endpoint
61
65
 
66
+ The server must be running first. Use two terminals:
67
+
68
+ **Terminal 1** — start the server:
69
+
70
+ ```bash
71
+ # Echo mode (no API key needed)
72
+ npx @runtypelabs/a2a-aisdk-example serve --echo
73
+ ```
74
+
62
75
  ```bash
63
- # Test local server
64
- npx a2a-agent-example test http://localhost:9999
76
+ # Or with LLM (requires OPENAI_API_KEY or ANTHROPIC_API_KEY)
77
+ OPENAI_API_KEY=sk-xxx npx @runtypelabs/a2a-aisdk-example serve
78
+ ```
65
79
 
66
- # Test with streaming
67
- npx a2a-agent-example test http://localhost:9999 --stream --skill chat --message "What is AI?"
80
+ **Terminal 2** run the test:
81
+
82
+ ```bash
83
+ # Test echo (works with echo mode)
84
+ npx @runtypelabs/a2a-aisdk-example test http://localhost:9999
85
+
86
+ # Test with streaming (chat requires LLM mode + API key)
87
+ npx @runtypelabs/a2a-aisdk-example test http://localhost:9999 --stream --skill chat --message "What is AI?"
68
88
  ```
69
89
 
90
+ > Run `npx @runtypelabs/a2a-aisdk-example --help` to see all commands and options.
91
+
70
92
  ### Test Runtype A2A Surface
71
93
 
72
94
  ```bash
73
- npx a2a-agent-example test-runtype \
95
+ npx @runtypelabs/a2a-aisdk-example test-runtype \
74
96
  --product-id prod_xxx \
75
97
  --surface-id surf_xxx \
76
98
  --api-key a2a_xxx \
@@ -108,7 +130,7 @@ Time tools return structured responses with a `computed.method: "deterministic"`
108
130
  Example prompt that triggers tool use from `chat`:
109
131
 
110
132
  ```bash
111
- npx a2a-agent-example test http://localhost:9999 \
133
+ npx @runtypelabs/a2a-aisdk-example test http://localhost:9999 \
112
134
  --skill chat \
113
135
  --message "What day of the week is 2026-02-09 in UTC?"
114
136
  ```
@@ -120,14 +142,14 @@ npx a2a-agent-example test http://localhost:9999 \
120
142
  1. Start the A2A server:
121
143
 
122
144
  ```bash
123
- npx a2a-agent-example serve --echo --port 9999
145
+ npx @runtypelabs/a2a-aisdk-example serve --echo --port 9999
124
146
  ```
125
147
 
126
148
  2. In Runtype Dashboard:
127
149
  - Go to your Product
128
150
  - Click "Add Capability" > "Connect External"
129
151
  - Enter:
130
- - Agent Card URL: `http://localhost:9999/.well-known/agent.json`
152
+ - Agent Card URL: `http://localhost:9999/.well-known/agent-card.json`
131
153
  - A2A Endpoint URL: `http://localhost:9999/a2a`
132
154
  - Click "Connect & Add"
133
155
 
@@ -138,7 +160,7 @@ npx a2a-agent-example test http://localhost:9999 \
138
160
  3. Generate an API key for the surface
139
161
  4. Test with the CLI:
140
162
  ```bash
141
- npx a2a-agent-example test-runtype \
163
+ npx @runtypelabs/a2a-aisdk-example test-runtype \
142
164
  --product-id prod_xxx \
143
165
  --surface-id surf_xxx \
144
166
  --api-key a2a_xxx \
@@ -150,7 +172,7 @@ npx a2a-agent-example test http://localhost:9999 \
150
172
  ### Create a Server
151
173
 
152
174
  ```typescript
153
- import { createA2AServer } from '@runtypelabs/a2a-agent-example'
175
+ import { createA2AServer } from '@runtypelabs/a2a-aisdk-example'
154
176
 
155
177
  const server = createA2AServer({
156
178
  config: {
@@ -176,7 +198,7 @@ process.on('SIGINT', async () => {
176
198
  ### Create a Client
177
199
 
178
200
  ```typescript
179
- import { A2AClient } from '@runtypelabs/a2a-agent-example'
201
+ import { A2AClient } from '@runtypelabs/a2a-aisdk-example'
180
202
 
181
203
  const client = new A2AClient({
182
204
  baseUrl: 'http://localhost:9999',
@@ -204,7 +226,7 @@ console.log('Response:', task.artifacts?.[0]?.parts?.[0]?.text)
204
226
  ### Test Runtype Surface
205
227
 
206
228
  ```typescript
207
- import { createRuntypeA2AClient } from '@runtypelabs/a2a-agent-example'
229
+ import { createRuntypeA2AClient } from '@runtypelabs/a2a-aisdk-example'
208
230
 
209
231
  const client = createRuntypeA2AClient({
210
232
  productId: 'prod_xxx',
@@ -231,10 +253,12 @@ await client.sendTaskStreaming(
231
253
 
232
254
  ## CLI Reference
233
255
 
256
+ Run `npx @runtypelabs/a2a-aisdk-example --help` for all commands and options.
257
+
234
258
  ### `serve` - Start A2A Server
235
259
 
236
260
  ```
237
- Usage: a2a-agent-example serve [options]
261
+ Usage: a2a-aisdk-example serve [options]
238
262
 
239
263
  Options:
240
264
  -p, --port <port> Port to listen on (default: "9999")
@@ -249,7 +273,7 @@ Options:
249
273
  ### `test` - Test A2A Endpoint
250
274
 
251
275
  ```
252
- Usage: a2a-agent-example test [options] <url>
276
+ Usage: a2a-aisdk-example test [options] <url>
253
277
 
254
278
  Arguments:
255
279
  url Base URL of the A2A endpoint
@@ -264,7 +288,7 @@ Options:
264
288
  ### `test-runtype` - Test Runtype A2A Surface
265
289
 
266
290
  ```
267
- Usage: a2a-agent-example test-runtype [options]
291
+ Usage: a2a-aisdk-example test-runtype [options]
268
292
 
269
293
  Options:
270
294
  --product-id <id> Runtype product ID (required)
@@ -278,20 +302,22 @@ Options:
278
302
 
279
303
  ## A2A Protocol
280
304
 
281
- This package implements [A2A Protocol v0.3](https://a2aproject.github.io/A2A/specification/).
305
+ This package implements [A2A Protocol v0.3](https://a2a-protocol.org/v0.3.0/specification/).
282
306
 
283
307
  ### Endpoints
284
308
 
285
- - `GET /.well-known/agent.json` - Agent Card discovery
309
+ - `GET /.well-known/agent-card.json` - Agent Card discovery (also serves `/.well-known/agent.json` for backward compat)
286
310
  - `POST /a2a` - JSON-RPC endpoint
287
311
 
288
312
  ### Supported Methods
289
313
 
290
- - `tasks/send` - Create and execute a task (synchronous)
291
- - `tasks/sendSubscribe` - Create and execute a task with SSE streaming
292
- - `tasks/get` - Get task status
293
- - `tasks/cancel` - Cancel a running task
294
- - `ping` - Health check
314
+ | Spec Method (preferred) | Legacy Alias | Description |
315
+ | --- | --- | --- |
316
+ | `message/send` | `tasks/send`, `SendMessage` | Send a message (synchronous) |
317
+ | `message/stream` | `tasks/sendSubscribe`, `SendStreamingMessage` | Send a message with SSE streaming |
318
+ | `GetTask` | `tasks/get` | Get task status |
319
+ | `CancelTask` | `tasks/cancel` | Cancel a running task |
320
+ | `ping` | | Health check |
295
321
 
296
322
  ## Vercel Deployment
297
323
 
@@ -312,15 +338,15 @@ Install the package and use the Vercel handlers:
312
338
 
313
339
  ```typescript
314
340
  // app/api/a2a/route.ts
315
- import { createA2AHandler } from '@runtypelabs/a2a-agent-example/vercel'
341
+ import { createA2AHandler } from '@runtypelabs/a2a-aisdk-example/vercel'
316
342
 
317
343
  export const POST = createA2AHandler({
318
344
  name: 'My Agent',
319
345
  llmConfig: { provider: 'openai', model: 'gpt-4o-mini' },
320
346
  })
321
347
 
322
- // app/.well-known/agent.json/route.ts
323
- import { createAgentCardHandler } from '@runtypelabs/a2a-agent-example/vercel'
348
+ // app/.well-known/agent-card.json/route.ts
349
+ import { createAgentCardHandler } from '@runtypelabs/a2a-aisdk-example/vercel'
324
350
 
325
351
  export const GET = createAgentCardHandler({
326
352
  name: 'My Agent',
@@ -332,9 +358,9 @@ export const GET = createAgentCardHandler({
332
358
 
333
359
  Since Vercel functions are stateless:
334
360
 
335
- - `tasks/get` returns "not available" (no task storage)
336
- - `tasks/cancel` returns "not available" (can't cancel in-flight tasks)
337
- - Use `tasks/sendSubscribe` for streaming responses
361
+ - `GetTask` returns "not available" (no task storage)
362
+ - `CancelTask` returns "not available" (can't cancel in-flight tasks)
363
+ - Use `message/stream` for streaming responses
338
364
 
339
365
  ## Development
340
366