@a2anet/a2a-utils 0.4.0 → 0.6.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 +363 -318
- package/dist/client/a2a-session.d.ts +32 -5
- package/dist/client/a2a-session.d.ts.map +1 -1
- package/dist/client/a2a-session.js +134 -14
- package/dist/client/a2a-session.js.map +1 -1
- package/dist/client/a2a-tools.d.ts +250 -130
- package/dist/client/a2a-tools.d.ts.map +1 -1
- package/dist/client/a2a-tools.js +351 -280
- package/dist/client/a2a-tools.js.map +1 -1
- package/dist/files/file-store.d.ts +19 -4
- package/dist/files/file-store.d.ts.map +1 -1
- package/dist/files/local-file-store.d.ts +32 -6
- package/dist/files/local-file-store.d.ts.map +1 -1
- package/dist/files/local-file-store.js +65 -23
- package/dist/files/local-file-store.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -25,6 +25,19 @@ Tool outputs are also optimised for LLMs.
|
|
|
25
25
|
For example, `getAgents` returns a list of agent names and descriptions, whereas `getAgent` also returns an agent's skill names and descriptions.
|
|
26
26
|
`sendMessage` and `getTask` return LLM-friendly types that are subsets of A2A types (e.g. `TaskForLLM`, `MessageForLLM`, and `ArtifactForLLM`) and automatically minimise large Artifacts, which can be viewed with `viewTextArtifact` and `viewDataArtifact`.
|
|
27
27
|
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
- **6 LLM-friendly tools** — `getAgents`, `getAgent`, `sendMessage`, `getTask`, `viewTextArtifact`, and `viewDataArtifact`, designed with clear docstrings, JSON-serialisable outputs, and actionable error messages
|
|
31
|
+
- **Simple message sending** — send messages with just an agent ID and message string; Agent Card fetching, headers, and non-blocking streaming are handled automatically
|
|
32
|
+
- **Multi-turn conversations** — continue conversations across multiple messages using `contextId`
|
|
33
|
+
- **Long-running task support** — if `sendMessage` times out, use `getTask` to resume streaming until the task reaches a terminal state
|
|
34
|
+
- **Automatic artifact minimization** — large text and data artifacts are automatically minimized for LLM context windows, with `viewTextArtifact` and `viewDataArtifact` for detailed navigation
|
|
35
|
+
- **Task persistence** — save and load tasks as JSON files with `JSONTaskStore`
|
|
36
|
+
- **File artifact storage** — save file artifacts to the local filesystem with `LocalFileStore`, or implement `FileStore` for custom backends (S3, GCS, etc.)
|
|
37
|
+
- **Agent Card management** — `A2AAgents` stores agent IDs, URLs, and custom headers, with multiple detail levels for LLM summaries (`name`, `basic`, `skills`, `full`)
|
|
38
|
+
- **Runtime agent registration** — add new agents at runtime with `addAgent`
|
|
39
|
+
- **Configurable timeouts and polling** — customisable timeouts for sending messages, monitoring tasks, and polling intervals
|
|
40
|
+
|
|
28
41
|
## 📦 Installation
|
|
29
42
|
|
|
30
43
|
To install with npm:
|
|
@@ -45,9 +58,11 @@ Create an `A2ASession`, then `A2ATools` to get LLM-friendly tools that can be us
|
|
|
45
58
|
|
|
46
59
|
```typescript
|
|
47
60
|
import { A2ATools, A2ASession, A2AAgents, JSONTaskStore, LocalFileStore } from "@a2anet/a2a-utils";
|
|
61
|
+
import { createAgent, tool } from "langchain";
|
|
62
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
48
63
|
|
|
49
64
|
const agents = new A2AAgents({
|
|
50
|
-
|
|
65
|
+
weather: { url: "https://weather.example.com/.well-known/agent-card.json" },
|
|
51
66
|
"research-bot": {
|
|
52
67
|
url: "https://research.example.com/.well-known/agent-card.json",
|
|
53
68
|
custom_headers: { "X-API-Key": "key_123" },
|
|
@@ -61,14 +76,20 @@ const a2aSession = new A2ASession(agents, {
|
|
|
61
76
|
|
|
62
77
|
const a2aTools = new A2ATools(a2aSession);
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
const langchainTools = a2aTools.toolDefinitions.map((def) =>
|
|
80
|
+
tool(def.execute, { name: def.name, description: def.description, schema: def.schema }),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const model = new ChatOpenAI({ model: "gpt-5.1", reasoning: { effort: "medium" } });
|
|
84
|
+
|
|
85
|
+
const agent = createAgent({ model, tools: langchainTools });
|
|
65
86
|
```
|
|
66
87
|
|
|
67
88
|
## 📖 API Reference
|
|
68
89
|
|
|
69
90
|
### A2ATools
|
|
70
91
|
|
|
71
|
-
Ready-made tools for agents to communicate with A2A servers.
|
|
92
|
+
Ready-made tools for agents to communicate with A2A servers. Each tool is an instance property with `name`, `description`, `schema` (Zod), and `execute`. Use the `toolDefinitions` getter for the full array.
|
|
72
93
|
|
|
73
94
|
```typescript
|
|
74
95
|
import { A2ATools, A2ASession, A2AAgents } from "@a2anet/a2a-utils";
|
|
@@ -76,10 +97,10 @@ import { A2ATools, A2ASession, A2AAgents } from "@a2anet/a2a-utils";
|
|
|
76
97
|
const tools = new A2ATools(session);
|
|
77
98
|
```
|
|
78
99
|
|
|
79
|
-
| Parameter
|
|
80
|
-
|
|
81
|
-
| `session`
|
|
82
|
-
| `artifactSettings` | `ArtifactSettings \| null` | No
|
|
100
|
+
| Parameter | Type | Required | Description |
|
|
101
|
+
| ------------------ | -------------------------- | -------- | -------------------------------------------------------------- |
|
|
102
|
+
| `session` | `A2ASession` | Yes | The session instance for sending messages and managing agents |
|
|
103
|
+
| `artifactSettings` | `ArtifactSettings \| null` | No | Minimization/view settings (default: `new ArtifactSettings()`) |
|
|
83
104
|
|
|
84
105
|
`artifactSettings` determines how Artifacts are minimized and viewed:
|
|
85
106
|
|
|
@@ -94,78 +115,81 @@ const settings = new ArtifactSettings({
|
|
|
94
115
|
const tools = new A2ATools(session, { artifactSettings: settings });
|
|
95
116
|
```
|
|
96
117
|
|
|
97
|
-
| Field
|
|
98
|
-
|
|
99
|
-
| `sendMessageCharacterLimit`
|
|
100
|
-
| `minimizedObjectStringLength` | `number` | `5,000`
|
|
101
|
-
| `viewArtifactCharacterLimit`
|
|
118
|
+
| Field | Type | Default | Description |
|
|
119
|
+
| ----------------------------- | -------- | -------- | ----------------------------------------------------------------------- |
|
|
120
|
+
| `sendMessageCharacterLimit` | `number` | `50,000` | Character limit above which artifacts are minimized in `sendMessage` |
|
|
121
|
+
| `minimizedObjectStringLength` | `number` | `5,000` | Max length for individual string values within minimized data objects |
|
|
122
|
+
| `viewArtifactCharacterLimit` | `number` | `50,000` | Character limit for output from `viewTextArtifact` / `viewDataArtifact` |
|
|
102
123
|
|
|
103
|
-
#### `
|
|
124
|
+
#### `getAgents`
|
|
104
125
|
|
|
105
126
|
List all available agents with their names and descriptions.
|
|
106
127
|
|
|
107
128
|
```typescript
|
|
108
|
-
const result = await tools.getAgents();
|
|
129
|
+
const result = await tools.getAgents.execute({});
|
|
109
130
|
```
|
|
110
131
|
|
|
111
132
|
Example result:
|
|
112
133
|
|
|
113
134
|
```json
|
|
114
135
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
"research-bot": {
|
|
137
|
+
"name": "Research Bot",
|
|
138
|
+
"description": "Find and summarize research papers"
|
|
139
|
+
},
|
|
140
|
+
"weather": {
|
|
141
|
+
"name": "Weather Agent",
|
|
142
|
+
"description": "Get weather forecasts for any location"
|
|
143
|
+
}
|
|
123
144
|
}
|
|
124
145
|
```
|
|
125
146
|
|
|
126
|
-
#### `
|
|
147
|
+
#### `getAgent`
|
|
127
148
|
|
|
128
149
|
Get detailed information about a specific agent, including its skills.
|
|
129
150
|
|
|
130
151
|
```typescript
|
|
131
|
-
const result = await tools.getAgent("research-bot");
|
|
152
|
+
const result = await tools.getAgent.execute({ agentId: "research-bot" });
|
|
132
153
|
```
|
|
133
154
|
|
|
134
155
|
Example result:
|
|
135
156
|
|
|
136
157
|
```json
|
|
137
158
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
"name": "Research Bot",
|
|
160
|
+
"description": "Find and summarize research papers",
|
|
161
|
+
"skills": [
|
|
162
|
+
{
|
|
163
|
+
"name": "Search Papers",
|
|
164
|
+
"description": "Search for papers by topic, author, or keyword"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "Summarize Paper",
|
|
168
|
+
"description": "Generate a summary of a specific paper"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
150
171
|
}
|
|
151
172
|
```
|
|
152
173
|
|
|
153
|
-
#### `
|
|
174
|
+
#### `sendMessage`
|
|
154
175
|
|
|
155
176
|
Send a message to an agent and receive a structured response. The response includes the agent's reply and any generated Artifacts. Artifacts are automatically minimized to fit the context window.
|
|
156
177
|
|
|
157
|
-
| Parameter
|
|
158
|
-
|
|
159
|
-
| `agentId`
|
|
160
|
-
| `message`
|
|
161
|
-
| `contextId` | `string
|
|
162
|
-
| `taskId`
|
|
163
|
-
| `timeout`
|
|
178
|
+
| Parameter | Type | Required | Description |
|
|
179
|
+
| ----------- | ----------- | -------- | ------------------------------------------------------------- |
|
|
180
|
+
| `agentId` | `string` | Yes | ID of the agent to message (from get_agents) |
|
|
181
|
+
| `message` | `string` | Yes | The message content to send |
|
|
182
|
+
| `contextId` | `string` | No | Continue an existing conversation by providing its context ID |
|
|
183
|
+
| `taskId` | `string` | No | Attach to an existing task (for input_required flows) |
|
|
184
|
+
| `timeout` | `number` | No | Override the default timeout in seconds |
|
|
185
|
+
| `data` | `unknown[]` | No | Structured data to include with the message |
|
|
186
|
+
| `files` | `string[]` | No | Files to include (local paths or URLs) |
|
|
164
187
|
|
|
165
188
|
```typescript
|
|
166
|
-
const result = await tools.sendMessage(
|
|
167
|
-
"research-bot",
|
|
168
|
-
|
|
189
|
+
const result = await tools.sendMessage.execute({
|
|
190
|
+
agentId: "research-bot",
|
|
191
|
+
message: "Find recent papers on quantum computing",
|
|
192
|
+
});
|
|
169
193
|
```
|
|
170
194
|
|
|
171
195
|
Example result:
|
|
@@ -189,19 +213,19 @@ Example result:
|
|
|
189
213
|
"kind": "data",
|
|
190
214
|
"data": [
|
|
191
215
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
"title": "Quantum Error Correction Advances",
|
|
217
|
+
"year": 2025,
|
|
218
|
+
"authors": "Chen et al."
|
|
195
219
|
},
|
|
196
220
|
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
221
|
+
"title": "Topological Quantum Computing Survey",
|
|
222
|
+
"year": 2024,
|
|
223
|
+
"authors": "Nakamura et al."
|
|
200
224
|
},
|
|
201
225
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
226
|
+
"title": "Fault-Tolerant Logical Qubits",
|
|
227
|
+
"year": 2024,
|
|
228
|
+
"authors": "Wang et al."
|
|
205
229
|
}
|
|
206
230
|
]
|
|
207
231
|
}
|
|
@@ -225,46 +249,53 @@ Example result:
|
|
|
225
249
|
Continue the conversation using `contextId`:
|
|
226
250
|
|
|
227
251
|
```typescript
|
|
228
|
-
const result2 = await tools.sendMessage(
|
|
229
|
-
"research-bot",
|
|
230
|
-
"Summarize the most recent result",
|
|
231
|
-
"ctx-456",
|
|
232
|
-
);
|
|
252
|
+
const result2 = await tools.sendMessage.execute({
|
|
253
|
+
agentId: "research-bot",
|
|
254
|
+
message: "Summarize the most recent result",
|
|
255
|
+
contextId: "ctx-456",
|
|
256
|
+
});
|
|
233
257
|
```
|
|
234
258
|
|
|
235
|
-
#### `
|
|
259
|
+
#### `getTask`
|
|
236
260
|
|
|
237
261
|
Check the progress of a task that is still in progress. Use this after `sendMessage` returns a task in a non-terminal state (e.g. `"working"`).
|
|
238
262
|
|
|
239
|
-
| Parameter
|
|
240
|
-
|
|
241
|
-
| `agentId`
|
|
242
|
-
| `taskId`
|
|
243
|
-
| `timeout`
|
|
244
|
-
| `pollInterval` | `number
|
|
263
|
+
| Parameter | Type | Required | Description |
|
|
264
|
+
| -------------- | -------- | -------- | ------------------------------------------------------ |
|
|
265
|
+
| `agentId` | `string` | Yes | ID of the agent that owns the task |
|
|
266
|
+
| `taskId` | `string` | Yes | Task ID from a previous send_message response |
|
|
267
|
+
| `timeout` | `number` | No | Override the monitoring timeout in seconds |
|
|
268
|
+
| `pollInterval` | `number` | No | Override the interval between status checks in seconds |
|
|
245
269
|
|
|
246
270
|
```typescript
|
|
247
|
-
const result = await tools.getTask(
|
|
271
|
+
const result = await tools.getTask.execute({
|
|
272
|
+
agentId: "research-bot",
|
|
273
|
+
taskId: "task-123",
|
|
274
|
+
});
|
|
248
275
|
```
|
|
249
276
|
|
|
250
|
-
#### `
|
|
277
|
+
#### `viewTextArtifact`
|
|
251
278
|
|
|
252
279
|
View text content from an artifact, optionally selecting a range. Use this for artifacts containing text (documents, logs, code, etc.).
|
|
253
280
|
|
|
254
|
-
| Parameter
|
|
255
|
-
|
|
256
|
-
| `agentId`
|
|
257
|
-
| `taskId`
|
|
258
|
-
| `artifactId`
|
|
259
|
-
| `lineStart`
|
|
260
|
-
| `lineEnd`
|
|
261
|
-
| `characterStart` | `number
|
|
262
|
-
| `characterEnd`
|
|
281
|
+
| Parameter | Type | Required | Description |
|
|
282
|
+
| ---------------- | -------- | -------- | --------------------------------------------- |
|
|
283
|
+
| `agentId` | `string` | Yes | ID of the agent that produced the artifact |
|
|
284
|
+
| `taskId` | `string` | Yes | Task ID containing the artifact |
|
|
285
|
+
| `artifactId` | `string` | Yes | The artifact's unique identifier |
|
|
286
|
+
| `lineStart` | `number` | No | Starting line number (1-based, inclusive) |
|
|
287
|
+
| `lineEnd` | `number` | No | Ending line number (1-based, inclusive) |
|
|
288
|
+
| `characterStart` | `number` | No | Starting character index (0-based, inclusive) |
|
|
289
|
+
| `characterEnd` | `number` | No | Ending character index (0-based, exclusive) |
|
|
263
290
|
|
|
264
291
|
```typescript
|
|
265
|
-
const result = await tools.viewTextArtifact(
|
|
266
|
-
"research-bot",
|
|
267
|
-
|
|
292
|
+
const result = await tools.viewTextArtifact.execute({
|
|
293
|
+
agentId: "research-bot",
|
|
294
|
+
taskId: "task-123",
|
|
295
|
+
artifactId: "art-790",
|
|
296
|
+
lineStart: 1,
|
|
297
|
+
lineEnd: 3,
|
|
298
|
+
});
|
|
268
299
|
```
|
|
269
300
|
|
|
270
301
|
Example result:
|
|
@@ -283,24 +314,27 @@ Example result:
|
|
|
283
314
|
}
|
|
284
315
|
```
|
|
285
316
|
|
|
286
|
-
#### `
|
|
317
|
+
#### `viewDataArtifact`
|
|
287
318
|
|
|
288
319
|
View structured data from an artifact with optional filtering. Use this for artifacts containing JSON data (objects, arrays, tables).
|
|
289
320
|
|
|
290
|
-
| Parameter
|
|
291
|
-
|
|
292
|
-
| `agentId`
|
|
293
|
-
| `taskId`
|
|
294
|
-
| `artifactId` | `string` | Yes
|
|
295
|
-
| `jsonPath`
|
|
296
|
-
| `rows`
|
|
297
|
-
| `columns`
|
|
321
|
+
| Parameter | Type | Required | Description |
|
|
322
|
+
| ------------ | -------- | -------- | --------------------------------------------------------------------- |
|
|
323
|
+
| `agentId` | `string` | Yes | ID of the agent that produced the artifact |
|
|
324
|
+
| `taskId` | `string` | Yes | Task ID containing the artifact |
|
|
325
|
+
| `artifactId` | `string` | Yes | The artifact's unique identifier |
|
|
326
|
+
| `jsonPath` | `string` | No | Dot-separated path to navigate into the data (e.g. `"results.items"`) |
|
|
327
|
+
| `rows` | `string` | No | Row selection: `"0"`, `"0-10"`, `"0,2,5"`, `"all"` |
|
|
328
|
+
| `columns` | `string` | No | Column selection: `"name"`, `"name,age"`, `"all"` |
|
|
298
329
|
|
|
299
330
|
```typescript
|
|
300
|
-
const result = await tools.viewDataArtifact(
|
|
301
|
-
"research-bot",
|
|
302
|
-
|
|
303
|
-
|
|
331
|
+
const result = await tools.viewDataArtifact.execute({
|
|
332
|
+
agentId: "research-bot",
|
|
333
|
+
taskId: "task-123",
|
|
334
|
+
artifactId: "art-789",
|
|
335
|
+
rows: "0-1",
|
|
336
|
+
columns: "title,year",
|
|
337
|
+
});
|
|
304
338
|
```
|
|
305
339
|
|
|
306
340
|
Example result:
|
|
@@ -314,8 +348,8 @@ Example result:
|
|
|
314
348
|
{
|
|
315
349
|
"kind": "data",
|
|
316
350
|
"data": [
|
|
317
|
-
{"title": "Quantum Error Correction Advances", "year": 2025},
|
|
318
|
-
{"title": "Topological Quantum Computing Survey", "year": 2024}
|
|
351
|
+
{ "title": "Quantum Error Correction Advances", "year": 2025 },
|
|
352
|
+
{ "title": "Topological Quantum Computing Survey", "year": 2024 }
|
|
319
353
|
]
|
|
320
354
|
}
|
|
321
355
|
]
|
|
@@ -340,43 +374,42 @@ const session = new A2ASession(
|
|
|
340
374
|
);
|
|
341
375
|
```
|
|
342
376
|
|
|
343
|
-
| Parameter
|
|
344
|
-
|
|
345
|
-
| `agents`
|
|
346
|
-
| `taskStore`
|
|
347
|
-
| `fileStore`
|
|
348
|
-
| `sendMessageTimeout`
|
|
349
|
-
| `getTaskTimeout`
|
|
350
|
-
| `getTaskPollInterval` | `number`
|
|
377
|
+
| Parameter | Type | Required | Description |
|
|
378
|
+
| --------------------- | ------------------------ | -------- | ------------------------------------------------------------------- |
|
|
379
|
+
| `agents` | `A2AAgents` | Yes | The agent manager instance |
|
|
380
|
+
| `taskStore` | `TaskStore \| undefined` | No | Task store for persistence (default: `InMemoryTaskStore`) |
|
|
381
|
+
| `fileStore` | `FileStore \| null` | No | File store for saving file artifacts (default: `null`) |
|
|
382
|
+
| `sendMessageTimeout` | `number` | No | HTTP timeout in seconds for `sendMessage` (default: `60.0`) |
|
|
383
|
+
| `getTaskTimeout` | `number` | No | Total monitoring timeout in seconds for `getTask` (default: `60.0`) |
|
|
384
|
+
| `getTaskPollInterval` | `number` | No | Interval in seconds between `getTask` polls (default: `5.0`) |
|
|
351
385
|
|
|
352
386
|
#### `async sendMessage(agentId: string, message: string, opts?): Promise<Task | Message>`
|
|
353
387
|
|
|
354
388
|
Send a message to an A2A agent. The returned task is automatically saved to the task store. File artifacts are saved via the file store.
|
|
355
389
|
|
|
356
|
-
| Parameter
|
|
357
|
-
|
|
358
|
-
| `agentId`
|
|
359
|
-
| `message`
|
|
360
|
-
| `opts.contextId` | `string \| null` | No
|
|
361
|
-
| `opts.taskId`
|
|
362
|
-
| `opts.timeout`
|
|
390
|
+
| Parameter | Type | Required | Description |
|
|
391
|
+
| ---------------- | ---------------- | -------- | ---------------------------------------------------------------- |
|
|
392
|
+
| `agentId` | `string` | Yes | Registered agent identifier |
|
|
393
|
+
| `message` | `string` | Yes | The message content to send |
|
|
394
|
+
| `opts.contextId` | `string \| null` | No | Context ID to continue a conversation (auto-generated when null) |
|
|
395
|
+
| `opts.taskId` | `string \| null` | No | Task ID to attach to the message |
|
|
396
|
+
| `opts.timeout` | `number \| null` | No | Override HTTP timeout in seconds (default: `sendMessageTimeout`) |
|
|
363
397
|
|
|
364
398
|
```typescript
|
|
365
399
|
import type { Task, Message } from "@a2a-js/sdk";
|
|
366
400
|
|
|
367
401
|
const response = await session.sendMessage(
|
|
368
|
-
"research-bot",
|
|
402
|
+
"research-bot",
|
|
403
|
+
"Find recent papers on quantum computing",
|
|
369
404
|
);
|
|
370
405
|
```
|
|
371
406
|
|
|
372
407
|
Continue the conversation using `contextId`:
|
|
373
408
|
|
|
374
409
|
```typescript
|
|
375
|
-
const response2 = await session.sendMessage(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
{ contextId: response.contextId },
|
|
379
|
-
);
|
|
410
|
+
const response2 = await session.sendMessage("research-bot", "Summarize the most recent result", {
|
|
411
|
+
contextId: response.contextId,
|
|
412
|
+
});
|
|
380
413
|
```
|
|
381
414
|
|
|
382
415
|
**Returns:** `Task | Message` (from `@a2a-js/sdk`)
|
|
@@ -387,12 +420,12 @@ Get the current state of a task. Monitors until a terminal state (`completed`, `
|
|
|
387
420
|
|
|
388
421
|
On monitoring timeout, returns the current task state (which may still be non-terminal, e.g. `working`). The only errors from `getTask` are failed HTTP requests (agent down, network error).
|
|
389
422
|
|
|
390
|
-
| Parameter
|
|
391
|
-
|
|
392
|
-
| `agentId`
|
|
393
|
-
| `taskId`
|
|
394
|
-
| `opts.timeout`
|
|
395
|
-
| `opts.pollInterval` | `number \| null` | No
|
|
423
|
+
| Parameter | Type | Required | Description |
|
|
424
|
+
| ------------------- | ---------------- | -------- | --------------------------------------------------------------------------- |
|
|
425
|
+
| `agentId` | `string` | Yes | Registered agent identifier |
|
|
426
|
+
| `taskId` | `string` | Yes | Task ID from a previous `sendMessage` call |
|
|
427
|
+
| `opts.timeout` | `number \| null` | No | Override monitoring timeout in seconds (default: `getTaskTimeout`) |
|
|
428
|
+
| `opts.pollInterval` | `number \| null` | No | Override interval between polls in seconds (default: `getTaskPollInterval`) |
|
|
396
429
|
|
|
397
430
|
```typescript
|
|
398
431
|
const task = await session.getTask("research-bot", "task-123");
|
|
@@ -411,7 +444,7 @@ import { A2AAgents } from "@a2anet/a2a-utils";
|
|
|
411
444
|
const manager = new A2AAgents({
|
|
412
445
|
"language-translator": {
|
|
413
446
|
url: "https://example.com/language-translator/agent-card.json",
|
|
414
|
-
custom_headers: {
|
|
447
|
+
custom_headers: { Authorization: "Bearer tok_123" },
|
|
415
448
|
},
|
|
416
449
|
});
|
|
417
450
|
|
|
@@ -437,9 +470,9 @@ const agents = await manager.getAgents();
|
|
|
437
470
|
|
|
438
471
|
Generate summary of all agents, sorted by agent_id.
|
|
439
472
|
|
|
440
|
-
| Parameter | Type
|
|
441
|
-
|
|
442
|
-
| `detail`
|
|
473
|
+
| Parameter | Type | Required | Description |
|
|
474
|
+
| --------- | -------- | -------- | -------------------------------------------------------------------- |
|
|
475
|
+
| `detail` | `string` | No | Detail level: `"name"`, `"basic"` (default), `"skills"`, or `"full"` |
|
|
443
476
|
|
|
444
477
|
**Returns:** `Record<string, Record<string, unknown>>`
|
|
445
478
|
|
|
@@ -451,8 +484,8 @@ const summaries = await manager.getAgentsForLlm("name");
|
|
|
451
484
|
|
|
452
485
|
```json
|
|
453
486
|
{
|
|
454
|
-
|
|
455
|
-
|
|
487
|
+
"code-reviewer": { "name": "Code Reviewer" },
|
|
488
|
+
"language-translator": { "name": "Universal Translator" }
|
|
456
489
|
}
|
|
457
490
|
```
|
|
458
491
|
|
|
@@ -464,14 +497,14 @@ const summaries = await manager.getAgentsForLlm();
|
|
|
464
497
|
|
|
465
498
|
```json
|
|
466
499
|
{
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
500
|
+
"code-reviewer": {
|
|
501
|
+
"name": "Code Reviewer",
|
|
502
|
+
"description": "Review code for best practices"
|
|
503
|
+
},
|
|
504
|
+
"language-translator": {
|
|
505
|
+
"name": "Universal Translator",
|
|
506
|
+
"description": "Translate text and audio between 50+ languages"
|
|
507
|
+
}
|
|
475
508
|
}
|
|
476
509
|
```
|
|
477
510
|
|
|
@@ -483,16 +516,16 @@ const summaries = await manager.getAgentsForLlm("skills");
|
|
|
483
516
|
|
|
484
517
|
```json
|
|
485
518
|
{
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
519
|
+
"code-reviewer": {
|
|
520
|
+
"name": "Code Reviewer",
|
|
521
|
+
"description": "Review code for best practices",
|
|
522
|
+
"skills": ["Review Code"]
|
|
523
|
+
},
|
|
524
|
+
"language-translator": {
|
|
525
|
+
"name": "Universal Translator",
|
|
526
|
+
"description": "Translate text between 50+ languages",
|
|
527
|
+
"skills": ["Translate Text", "Translate Audio"]
|
|
528
|
+
}
|
|
496
529
|
}
|
|
497
530
|
```
|
|
498
531
|
|
|
@@ -504,30 +537,30 @@ const summaries = await manager.getAgentsForLlm("full");
|
|
|
504
537
|
|
|
505
538
|
```json
|
|
506
539
|
{
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
540
|
+
"code-reviewer": {
|
|
541
|
+
"name": "Code Reviewer",
|
|
542
|
+
"description": "Review code for best practices",
|
|
543
|
+
"skills": [
|
|
544
|
+
{
|
|
545
|
+
"name": "Review Code",
|
|
546
|
+
"description": "Review code for best practices, identify bugs, and suggest improvements"
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
"language-translator": {
|
|
551
|
+
"name": "Universal Translator",
|
|
552
|
+
"description": "Translate text between 50+ languages",
|
|
553
|
+
"skills": [
|
|
554
|
+
{
|
|
555
|
+
"name": "Translate Text",
|
|
556
|
+
"description": "Translate text between any supported language pair"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"name": "Translate Audio",
|
|
560
|
+
"description": "Translate audio between any supported language pair"
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}
|
|
531
564
|
}
|
|
532
565
|
```
|
|
533
566
|
|
|
@@ -536,9 +569,9 @@ const summaries = await manager.getAgentsForLlm("full");
|
|
|
536
569
|
Retrieve agent by ID.
|
|
537
570
|
Note: this should NOT be added to the LLM's context, use `getAgentForLlm` instead.
|
|
538
571
|
|
|
539
|
-
| Parameter | Type
|
|
540
|
-
|
|
541
|
-
| `agentId` | `string` | Yes
|
|
572
|
+
| Parameter | Type | Required | Description |
|
|
573
|
+
| --------- | -------- | -------- | ----------------------------- |
|
|
574
|
+
| `agentId` | `string` | Yes | User-defined agent identifier |
|
|
542
575
|
|
|
543
576
|
**Returns:** [`AgentURLAndCustomHeaders`](#agenturlandcustomheaders) | `null`
|
|
544
577
|
|
|
@@ -552,10 +585,10 @@ Returns `null` if the agent ID is not registered.
|
|
|
552
585
|
|
|
553
586
|
Generate summary for a single agent.
|
|
554
587
|
|
|
555
|
-
| Parameter | Type
|
|
556
|
-
|
|
557
|
-
| `agentId` | `string` | Yes
|
|
558
|
-
| `detail`
|
|
588
|
+
| Parameter | Type | Required | Description |
|
|
589
|
+
| --------- | -------- | -------- | -------------------------------------------------------------------- |
|
|
590
|
+
| `agentId` | `string` | Yes | User-defined agent identifier |
|
|
591
|
+
| `detail` | `string` | No | Detail level: `"name"`, `"basic"` (default), `"skills"`, or `"full"` |
|
|
559
592
|
|
|
560
593
|
**Returns:** `Record<string, unknown> | null` — summary object or `null` if not found.
|
|
561
594
|
|
|
@@ -565,8 +598,8 @@ const summary = await manager.getAgentForLlm("language-translator");
|
|
|
565
598
|
|
|
566
599
|
```json
|
|
567
600
|
{
|
|
568
|
-
|
|
569
|
-
|
|
601
|
+
"name": "Universal Translator",
|
|
602
|
+
"description": "Translate text and audio between 50+ languages"
|
|
570
603
|
}
|
|
571
604
|
```
|
|
572
605
|
|
|
@@ -574,20 +607,18 @@ const summary = await manager.getAgentForLlm("language-translator");
|
|
|
574
607
|
|
|
575
608
|
Register a new agent at runtime.
|
|
576
609
|
|
|
577
|
-
| Parameter
|
|
578
|
-
|
|
579
|
-
| `agentId`
|
|
580
|
-
| `url`
|
|
581
|
-
| `customHeaders` | `Record<string, string>` | No
|
|
610
|
+
| Parameter | Type | Required | Description |
|
|
611
|
+
| --------------- | ------------------------ | -------- | ----------------------------- |
|
|
612
|
+
| `agentId` | `string` | Yes | User-defined agent identifier |
|
|
613
|
+
| `url` | `string` | Yes | Agent card URL |
|
|
614
|
+
| `customHeaders` | `Record<string, string>` | No | Custom HTTP headers |
|
|
582
615
|
|
|
583
616
|
**Throws:** `Error` if `agentId` is already registered.
|
|
584
617
|
|
|
585
618
|
```typescript
|
|
586
|
-
await manager.addAgent(
|
|
587
|
-
"
|
|
588
|
-
|
|
589
|
-
{ "X-API-Key": "key_123" },
|
|
590
|
-
);
|
|
619
|
+
await manager.addAgent("code-reviewer", "https://review.example.com/.well-known/agent-card.json", {
|
|
620
|
+
"X-API-Key": "key_123",
|
|
621
|
+
});
|
|
591
622
|
```
|
|
592
623
|
|
|
593
624
|
### 💾 JSONTaskStore
|
|
@@ -651,7 +682,7 @@ const savedPaths = await fileStore.save("task-123", artifact);
|
|
|
651
682
|
Example result:
|
|
652
683
|
|
|
653
684
|
```typescript
|
|
654
|
-
["./storage/files/task-123/art-789/quarterly_report.pdf"]
|
|
685
|
+
["./storage/files/task-123/art-789/quarterly_report.pdf"];
|
|
655
686
|
```
|
|
656
687
|
|
|
657
688
|
##### `async get(taskId: string, artifactId: string): Promise<string[]>`
|
|
@@ -665,7 +696,7 @@ const paths = await fileStore.get("task-123", "art-789");
|
|
|
665
696
|
Example result:
|
|
666
697
|
|
|
667
698
|
```typescript
|
|
668
|
-
["./storage/files/task-123/art-789/quarterly_report.pdf"]
|
|
699
|
+
["./storage/files/task-123/art-789/quarterly_report.pdf"];
|
|
669
700
|
```
|
|
670
701
|
|
|
671
702
|
Returns an empty array if no files are found.
|
|
@@ -688,14 +719,14 @@ await fileStore.delete("task-123", "art-789");
|
|
|
688
719
|
|
|
689
720
|
View text content with optional line or character range selection. Supports line selection (1-based, inclusive) or character selection (0-based, slice semantics). These are mutually exclusive — providing both throws an `Error`.
|
|
690
721
|
|
|
691
|
-
| Parameter
|
|
692
|
-
|
|
693
|
-
| `text`
|
|
694
|
-
| `opts.lineStart`
|
|
695
|
-
| `opts.lineEnd`
|
|
696
|
-
| `opts.characterStart` | `number \| null` | No
|
|
697
|
-
| `opts.characterEnd`
|
|
698
|
-
| `opts.characterLimit` | `number`
|
|
722
|
+
| Parameter | Type | Required | Description |
|
|
723
|
+
| --------------------- | ---------------- | -------- | --------------------------------------------- |
|
|
724
|
+
| `text` | `string` | Yes | The text to view |
|
|
725
|
+
| `opts.lineStart` | `number \| null` | No | Starting line number (1-based, inclusive) |
|
|
726
|
+
| `opts.lineEnd` | `number \| null` | No | Ending line number (1-based, inclusive) |
|
|
727
|
+
| `opts.characterStart` | `number \| null` | No | Starting character index (0-based, inclusive) |
|
|
728
|
+
| `opts.characterEnd` | `number \| null` | No | Ending character index (0-based, exclusive) |
|
|
729
|
+
| `opts.characterLimit` | `number` | No | Maximum output size (default: `50,000`) |
|
|
699
730
|
|
|
700
731
|
**Returns:** `string`
|
|
701
732
|
|
|
@@ -730,11 +761,11 @@ Example result:
|
|
|
730
761
|
|
|
731
762
|
Minimize text content for display. If text is within the character limit, returns it unchanged. If over the limit, shows first and last halves with metadata.
|
|
732
763
|
|
|
733
|
-
| Parameter
|
|
734
|
-
|
|
735
|
-
| `text`
|
|
736
|
-
| `opts.characterLimit` | `number`
|
|
737
|
-
| `opts.tip`
|
|
764
|
+
| Parameter | Type | Required | Description |
|
|
765
|
+
| --------------------- | ---------------- | -------- | ---------------------------------------------------------- |
|
|
766
|
+
| `text` | `string` | Yes | The text content to minimize |
|
|
767
|
+
| `opts.characterLimit` | `number` | No | Character limit (default: `50,000`) |
|
|
768
|
+
| `opts.tip` | `string \| null` | No | Tip string (default: `null`; pass a string to include one) |
|
|
738
769
|
|
|
739
770
|
**Returns:** `Record<string, unknown>`
|
|
740
771
|
|
|
@@ -747,7 +778,7 @@ TextArtifacts.minimize("Hello, world!");
|
|
|
747
778
|
```
|
|
748
779
|
|
|
749
780
|
```json
|
|
750
|
-
{"text": "Hello, world!"}
|
|
781
|
+
{ "text": "Hello, world!" }
|
|
751
782
|
```
|
|
752
783
|
|
|
753
784
|
Long text (over limit):
|
|
@@ -774,13 +805,13 @@ TextArtifacts.minimize("x".repeat(60_000));
|
|
|
774
805
|
|
|
775
806
|
View structured data with optional filtering. Navigate with `jsonPath`, then filter with `rows`/`columns`.
|
|
776
807
|
|
|
777
|
-
| Parameter
|
|
778
|
-
|
|
779
|
-
| `data`
|
|
780
|
-
| `opts.jsonPath`
|
|
781
|
-
| `opts.rows`
|
|
782
|
-
| `opts.columns`
|
|
783
|
-
| `opts.characterLimit` | `number`
|
|
808
|
+
| Parameter | Type | Required | Description |
|
|
809
|
+
| --------------------- | -------------------------------------- | -------- | --------------------------------------------- |
|
|
810
|
+
| `data` | `unknown` | Yes | The data to view |
|
|
811
|
+
| `opts.jsonPath` | `string \| null` | No | Dot-separated path to extract specific fields |
|
|
812
|
+
| `opts.rows` | `number \| number[] \| string \| null` | No | Row selection |
|
|
813
|
+
| `opts.columns` | `string \| string[] \| null` | No | Column selection |
|
|
814
|
+
| `opts.characterLimit` | `number` | No | Maximum output size (default: `50,000`) |
|
|
784
815
|
|
|
785
816
|
**Returns:** `unknown` (filtered data)
|
|
786
817
|
|
|
@@ -802,8 +833,8 @@ Example result:
|
|
|
802
833
|
|
|
803
834
|
```json
|
|
804
835
|
[
|
|
805
|
-
{"name": "Alice", "department": "Engineering"},
|
|
806
|
-
{"name": "Bob", "department": "Design"}
|
|
836
|
+
{ "name": "Alice", "department": "Engineering" },
|
|
837
|
+
{ "name": "Bob", "department": "Design" }
|
|
807
838
|
]
|
|
808
839
|
```
|
|
809
840
|
|
|
@@ -811,12 +842,12 @@ Example result:
|
|
|
811
842
|
|
|
812
843
|
Minimize data content for display based on type. Automatically selects the best strategy: list-of-objects gets a table summary, dicts get string truncation, strings delegate to `TextArtifacts.minimize`.
|
|
813
844
|
|
|
814
|
-
| Parameter
|
|
815
|
-
|
|
816
|
-
| `data`
|
|
817
|
-
| `opts.characterLimit`
|
|
818
|
-
| `opts.minimizedObjectStringLength` | `number`
|
|
819
|
-
| `opts.tip`
|
|
845
|
+
| Parameter | Type | Required | Description |
|
|
846
|
+
| ---------------------------------- | ---------------- | -------- | ---------------------------------------------------------- |
|
|
847
|
+
| `data` | `unknown` | Yes | The data to minimize |
|
|
848
|
+
| `opts.characterLimit` | `number` | No | Character limit (default: `50,000`) |
|
|
849
|
+
| `opts.minimizedObjectStringLength` | `number` | No | Max string length in objects (default: `5,000`) |
|
|
850
|
+
| `opts.tip` | `string \| null` | No | Tip string (default: `null`; pass a string to include one) |
|
|
820
851
|
|
|
821
852
|
**Returns:** `Record<string, unknown>`
|
|
822
853
|
|
|
@@ -855,46 +886,52 @@ DataArtifacts.minimize(data, { characterLimit: 100, minimizedObjectStringLength:
|
|
|
855
886
|
{
|
|
856
887
|
"count": 100,
|
|
857
888
|
"unique_count": 100,
|
|
858
|
-
"types": [
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
889
|
+
"types": [
|
|
890
|
+
{
|
|
891
|
+
"name": "string",
|
|
892
|
+
"count": 100,
|
|
893
|
+
"percentage": 100.0,
|
|
894
|
+
"sample_value": "Employee 42",
|
|
895
|
+
"length_minimum": 10,
|
|
896
|
+
"length_maximum": 11,
|
|
897
|
+
"length_average": 10.9,
|
|
898
|
+
"length_stdev": 0.3
|
|
899
|
+
}
|
|
900
|
+
],
|
|
868
901
|
"name": "name"
|
|
869
902
|
},
|
|
870
903
|
{
|
|
871
904
|
"count": 100,
|
|
872
905
|
"unique_count": 4,
|
|
873
|
-
"types": [
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
906
|
+
"types": [
|
|
907
|
+
{
|
|
908
|
+
"name": "string",
|
|
909
|
+
"count": 100,
|
|
910
|
+
"percentage": 100.0,
|
|
911
|
+
"sample_value": "Engineering",
|
|
912
|
+
"length_minimum": 5,
|
|
913
|
+
"length_maximum": 11,
|
|
914
|
+
"length_average": 7.75,
|
|
915
|
+
"length_stdev": 2.4
|
|
916
|
+
}
|
|
917
|
+
],
|
|
883
918
|
"name": "department"
|
|
884
919
|
},
|
|
885
920
|
{
|
|
886
921
|
"count": 100,
|
|
887
922
|
"unique_count": 100,
|
|
888
|
-
"types": [
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
923
|
+
"types": [
|
|
924
|
+
{
|
|
925
|
+
"name": "int",
|
|
926
|
+
"count": 100,
|
|
927
|
+
"percentage": 100.0,
|
|
928
|
+
"sample_value": 75000,
|
|
929
|
+
"minimum": 60000,
|
|
930
|
+
"maximum": 109500,
|
|
931
|
+
"average": 84750,
|
|
932
|
+
"stdev": 14505.75
|
|
933
|
+
}
|
|
934
|
+
],
|
|
898
935
|
"name": "salary"
|
|
899
936
|
}
|
|
900
937
|
],
|
|
@@ -909,9 +946,9 @@ DataArtifacts.minimize(data, { characterLimit: 100, minimizedObjectStringLength:
|
|
|
909
946
|
|
|
910
947
|
Generate a summary of tabular data (array of objects). Returns one summary object per column with count, unique count, and per-type statistics.
|
|
911
948
|
|
|
912
|
-
| Parameter | Type
|
|
913
|
-
|
|
914
|
-
| `data`
|
|
949
|
+
| Parameter | Type | Required | Description |
|
|
950
|
+
| --------- | --------------------------- | -------- | ----------- |
|
|
951
|
+
| `data` | `Record<string, unknown>[]` | Yes | Table rows |
|
|
915
952
|
|
|
916
953
|
**Returns:** `Record<string, unknown>[]`
|
|
917
954
|
|
|
@@ -987,9 +1024,9 @@ DataArtifacts.summarizeTable(data);
|
|
|
987
1024
|
|
|
988
1025
|
Generate statistics for a list of values (like a single column). Includes count, unique count, and per-type statistics (min/max/avg/stdev for numbers, length stats for strings, etc.). If the summary would be larger than the original values, the original list is returned instead (inflation guard).
|
|
989
1026
|
|
|
990
|
-
| Parameter | Type
|
|
991
|
-
|
|
992
|
-
| `values`
|
|
1027
|
+
| Parameter | Type | Required | Description |
|
|
1028
|
+
| --------- | ----------- | -------- | ------------------- |
|
|
1029
|
+
| `values` | `unknown[]` | Yes | Values to summarize |
|
|
993
1030
|
|
|
994
1031
|
**Returns:** `Record<string, unknown> | unknown[]`
|
|
995
1032
|
|
|
@@ -997,9 +1034,17 @@ Generate statistics for a list of values (like a single column). Includes count,
|
|
|
997
1034
|
import { DataArtifacts } from "@a2anet/a2a-utils";
|
|
998
1035
|
|
|
999
1036
|
const salaries = [
|
|
1000
|
-
95000,
|
|
1037
|
+
95000,
|
|
1038
|
+
72000,
|
|
1039
|
+
105000,
|
|
1040
|
+
68000,
|
|
1041
|
+
88000,
|
|
1001
1042
|
// ... ~100 salary values total, with some nulls
|
|
1002
|
-
null,
|
|
1043
|
+
null,
|
|
1044
|
+
115000,
|
|
1045
|
+
92000,
|
|
1046
|
+
null,
|
|
1047
|
+
78000,
|
|
1003
1048
|
];
|
|
1004
1049
|
|
|
1005
1050
|
DataArtifacts.summarizeValues(salaries);
|
|
@@ -1034,14 +1079,14 @@ DataArtifacts.summarizeValues(salaries);
|
|
|
1034
1079
|
|
|
1035
1080
|
Minimize a list of artifacts for LLM display. Called automatically by `A2ATools.sendMessage`. Combines all TextParts within each artifact into a single [`TextPartForLLM`](#textpartforllm). Handles `FilePart`s by including file metadata and saved paths.
|
|
1036
1081
|
|
|
1037
|
-
| Parameter
|
|
1038
|
-
|
|
1039
|
-
| `artifacts`
|
|
1040
|
-
| `opts.characterLimit`
|
|
1041
|
-
| `opts.minimizedObjectStringLength` | `number`
|
|
1042
|
-
| `opts.savedFilePaths`
|
|
1043
|
-
| `opts.textTip`
|
|
1044
|
-
| `opts.dataTip`
|
|
1082
|
+
| Parameter | Type | Required | Description |
|
|
1083
|
+
| ---------------------------------- | ---------------------------------- | -------- | --------------------------------------------------------- |
|
|
1084
|
+
| `artifacts` | `Artifact[]` | Yes | List of artifacts to minimize |
|
|
1085
|
+
| `opts.characterLimit` | `number` | No | Character limit (default: `50,000`) |
|
|
1086
|
+
| `opts.minimizedObjectStringLength` | `number` | No | Max string length in objects (default: `5,000`) |
|
|
1087
|
+
| `opts.savedFilePaths` | `Record<string, string[]> \| null` | No | Mapping of artifactId to saved file paths |
|
|
1088
|
+
| `opts.textTip` | `string \| null` | No | Tip string for minimized text artifacts (default: `null`) |
|
|
1089
|
+
| `opts.dataTip` | `string \| null` | No | Tip string for minimized data artifacts (default: `null`) |
|
|
1045
1090
|
|
|
1046
1091
|
**Returns:** [`ArtifactForLLM`](#artifactforllm)`[]`
|
|
1047
1092
|
|
|
@@ -1060,14 +1105,16 @@ const artifacts: Artifact[] = [
|
|
|
1060
1105
|
artifactId: "art-456",
|
|
1061
1106
|
description: "Company employee directory with names, departments, and salaries.",
|
|
1062
1107
|
name: "Employee Directory",
|
|
1063
|
-
parts: [
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1108
|
+
parts: [
|
|
1109
|
+
{
|
|
1110
|
+
kind: "data",
|
|
1111
|
+
data: Array.from({ length: 100 }, (_, i) => ({
|
|
1112
|
+
name: `Employee ${i}`,
|
|
1113
|
+
department: ["Eng", "Marketing", "Design", "Sales"][i % 4],
|
|
1114
|
+
salary: 60_000 + i * 500,
|
|
1115
|
+
})),
|
|
1116
|
+
},
|
|
1117
|
+
],
|
|
1071
1118
|
},
|
|
1072
1119
|
{
|
|
1073
1120
|
artifactId: "art-789",
|
|
@@ -1182,14 +1229,14 @@ const agent: AgentURLAndCustomHeaders = {
|
|
|
1182
1229
|
};
|
|
1183
1230
|
```
|
|
1184
1231
|
|
|
1185
|
-
| Field
|
|
1186
|
-
|
|
1187
|
-
| `agentCard`
|
|
1232
|
+
| Field | Type |
|
|
1233
|
+
| --------------- | ------------------------ |
|
|
1234
|
+
| `agentCard` | `AgentCard` |
|
|
1188
1235
|
| `customHeaders` | `Record<string, string>` |
|
|
1189
1236
|
|
|
1190
1237
|
#### `TaskForLLM`
|
|
1191
1238
|
|
|
1192
|
-
Returned by `A2ATools.sendMessage()` for task responses.
|
|
1239
|
+
Returned by `A2ATools.sendMessage.execute()` for task responses.
|
|
1193
1240
|
|
|
1194
1241
|
```typescript
|
|
1195
1242
|
const task: TaskForLLM = {
|
|
@@ -1252,17 +1299,17 @@ const task: TaskForLLM = {
|
|
|
1252
1299
|
};
|
|
1253
1300
|
```
|
|
1254
1301
|
|
|
1255
|
-
| Field
|
|
1256
|
-
|
|
1257
|
-
| `id`
|
|
1258
|
-
| `contextId` | `string`
|
|
1259
|
-
| `kind`
|
|
1260
|
-
| `status`
|
|
1302
|
+
| Field | Type |
|
|
1303
|
+
| ----------- | --------------------------------------- |
|
|
1304
|
+
| `id` | `string` |
|
|
1305
|
+
| `contextId` | `string` |
|
|
1306
|
+
| `kind` | `string` (`"task"`) |
|
|
1307
|
+
| `status` | [`TaskStatusForLLM`](#taskstatusforllm) |
|
|
1261
1308
|
| `artifacts` | [`ArtifactForLLM`](#artifactforllm)`[]` |
|
|
1262
1309
|
|
|
1263
1310
|
#### `MessageForLLM`
|
|
1264
1311
|
|
|
1265
|
-
Returned by `A2ATools.sendMessage()` for message-only responses, or as `TaskStatusForLLM.message`.
|
|
1312
|
+
Returned by `A2ATools.sendMessage.execute()` for message-only responses, or as `TaskStatusForLLM.message`.
|
|
1266
1313
|
|
|
1267
1314
|
```typescript
|
|
1268
1315
|
const message: MessageForLLM = {
|
|
@@ -1277,11 +1324,11 @@ const message: MessageForLLM = {
|
|
|
1277
1324
|
};
|
|
1278
1325
|
```
|
|
1279
1326
|
|
|
1280
|
-
| Field
|
|
1281
|
-
|
|
1282
|
-
| `contextId` | `string \| null`
|
|
1283
|
-
| `kind`
|
|
1284
|
-
| `parts`
|
|
1327
|
+
| Field | Type |
|
|
1328
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
1329
|
+
| `contextId` | `string \| null` |
|
|
1330
|
+
| `kind` | `string` (`"message"`) |
|
|
1331
|
+
| `parts` | ([`TextPartForLLM`](#textpartforllm) \| [`DataPartForLLM`](#datapartforllm) \| [`FilePartForLLM`](#filepartforllm))[] |
|
|
1285
1332
|
|
|
1286
1333
|
#### `TaskStatusForLLM`
|
|
1287
1334
|
|
|
@@ -1301,14 +1348,14 @@ const taskStatus: TaskStatusForLLM = {
|
|
|
1301
1348
|
};
|
|
1302
1349
|
```
|
|
1303
1350
|
|
|
1304
|
-
| Field
|
|
1305
|
-
|
|
1306
|
-
| `state`
|
|
1351
|
+
| Field | Type |
|
|
1352
|
+
| --------- | ------------------------------------------- |
|
|
1353
|
+
| `state` | `TaskState` |
|
|
1307
1354
|
| `message` | [`MessageForLLM`](#messageforllm) `\| null` |
|
|
1308
1355
|
|
|
1309
1356
|
#### `ArtifactForLLM`
|
|
1310
1357
|
|
|
1311
|
-
Returned by `viewTextArtifact()`, `viewDataArtifact()`, and `minimizeArtifacts()`. Used in `TaskForLLM.artifacts`.
|
|
1358
|
+
Returned by `viewTextArtifact.execute()`, `viewDataArtifact.execute()`, and `minimizeArtifacts()`. Used in `TaskForLLM.artifacts`.
|
|
1312
1359
|
|
|
1313
1360
|
```typescript
|
|
1314
1361
|
const artifact: ArtifactForLLM = {
|
|
@@ -1324,12 +1371,12 @@ const artifact: ArtifactForLLM = {
|
|
|
1324
1371
|
};
|
|
1325
1372
|
```
|
|
1326
1373
|
|
|
1327
|
-
| Field
|
|
1328
|
-
|
|
1329
|
-
| `artifactId`
|
|
1330
|
-
| `description` | `string \| null`
|
|
1331
|
-
| `name`
|
|
1332
|
-
| `parts`
|
|
1374
|
+
| Field | Type |
|
|
1375
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
1376
|
+
| `artifactId` | `string` |
|
|
1377
|
+
| `description` | `string \| null` |
|
|
1378
|
+
| `name` | `string \| null` |
|
|
1379
|
+
| `parts` | ([`TextPartForLLM`](#textpartforllm) \| [`DataPartForLLM`](#datapartforllm) \| [`FilePartForLLM`](#filepartforllm))[] |
|
|
1333
1380
|
|
|
1334
1381
|
#### `TextPartForLLM`
|
|
1335
1382
|
|
|
@@ -1340,10 +1387,10 @@ const textPart: TextPartForLLM = {
|
|
|
1340
1387
|
};
|
|
1341
1388
|
```
|
|
1342
1389
|
|
|
1343
|
-
| Field
|
|
1344
|
-
|
|
1390
|
+
| Field | Type |
|
|
1391
|
+
| ------ | ------------------- |
|
|
1345
1392
|
| `kind` | `string` (`"text"`) |
|
|
1346
|
-
| `text` | `string`
|
|
1393
|
+
| `text` | `string` |
|
|
1347
1394
|
|
|
1348
1395
|
#### `DataPartForLLM`
|
|
1349
1396
|
|
|
@@ -1370,10 +1417,10 @@ const dataPart: DataPartForLLM = {
|
|
|
1370
1417
|
};
|
|
1371
1418
|
```
|
|
1372
1419
|
|
|
1373
|
-
| Field
|
|
1374
|
-
|
|
1420
|
+
| Field | Type |
|
|
1421
|
+
| ------ | ------------------- |
|
|
1375
1422
|
| `kind` | `string` (`"data"`) |
|
|
1376
|
-
| `data` | `unknown`
|
|
1423
|
+
| `data` | `unknown` |
|
|
1377
1424
|
|
|
1378
1425
|
#### `FilePartForLLM`
|
|
1379
1426
|
|
|
@@ -1386,20 +1433,18 @@ const filePart: FilePartForLLM = {
|
|
|
1386
1433
|
mimeType: "application/pdf",
|
|
1387
1434
|
uri: null,
|
|
1388
1435
|
bytes: {
|
|
1389
|
-
_saved_to: [
|
|
1390
|
-
"./storage/files/task-123/art-789/q4-report.pdf",
|
|
1391
|
-
],
|
|
1436
|
+
_saved_to: ["./storage/files/task-123/art-789/q4-report.pdf"],
|
|
1392
1437
|
},
|
|
1393
1438
|
};
|
|
1394
1439
|
```
|
|
1395
1440
|
|
|
1396
|
-
| Field
|
|
1397
|
-
|
|
1398
|
-
| `kind`
|
|
1399
|
-
| `name`
|
|
1400
|
-
| `mimeType` | `string \| null`
|
|
1401
|
-
| `uri`
|
|
1402
|
-
| `bytes`
|
|
1441
|
+
| Field | Type | Description |
|
|
1442
|
+
| ---------- | ------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
1443
|
+
| `kind` | `string` (`"file"`) | Always `"file"` |
|
|
1444
|
+
| `name` | `string \| null` | Filename from the original FilePart |
|
|
1445
|
+
| `mimeType` | `string \| null` | MIME type from the original FilePart |
|
|
1446
|
+
| `uri` | `string \| Record<string, unknown> \| null` | Raw URI (no FileStore) or `{"_saved_to": [...]}` (FileStore saved it) |
|
|
1447
|
+
| `bytes` | `Record<string, unknown> \| null` | `{"_saved_to": [...]}` (FileStore saved it) or `{"_error": "..."}` (no FileStore) |
|
|
1403
1448
|
|
|
1404
1449
|
## 📄 License
|
|
1405
1450
|
|