@a2anet/a2a-utils 0.5.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 +350 -318
- package/dist/client/a2a-tools.d.ts +249 -147
- package/dist/client/a2a-tools.d.ts.map +1 -1
- package/dist/client/a2a-tools.js +292 -283
- package/dist/client/a2a-tools.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -58,9 +58,11 @@ Create an `A2ASession`, then `A2ATools` to get LLM-friendly tools that can be us
|
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
60
|
import { A2ATools, A2ASession, A2AAgents, JSONTaskStore, LocalFileStore } from "@a2anet/a2a-utils";
|
|
61
|
+
import { createAgent, tool } from "langchain";
|
|
62
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
61
63
|
|
|
62
64
|
const agents = new A2AAgents({
|
|
63
|
-
|
|
65
|
+
weather: { url: "https://weather.example.com/.well-known/agent-card.json" },
|
|
64
66
|
"research-bot": {
|
|
65
67
|
url: "https://research.example.com/.well-known/agent-card.json",
|
|
66
68
|
custom_headers: { "X-API-Key": "key_123" },
|
|
@@ -74,14 +76,20 @@ const a2aSession = new A2ASession(agents, {
|
|
|
74
76
|
|
|
75
77
|
const a2aTools = new A2ATools(a2aSession);
|
|
76
78
|
|
|
77
|
-
|
|
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 });
|
|
78
86
|
```
|
|
79
87
|
|
|
80
88
|
## 📖 API Reference
|
|
81
89
|
|
|
82
90
|
### A2ATools
|
|
83
91
|
|
|
84
|
-
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.
|
|
85
93
|
|
|
86
94
|
```typescript
|
|
87
95
|
import { A2ATools, A2ASession, A2AAgents } from "@a2anet/a2a-utils";
|
|
@@ -89,10 +97,10 @@ import { A2ATools, A2ASession, A2AAgents } from "@a2anet/a2a-utils";
|
|
|
89
97
|
const tools = new A2ATools(session);
|
|
90
98
|
```
|
|
91
99
|
|
|
92
|
-
| Parameter
|
|
93
|
-
|
|
94
|
-
| `session`
|
|
95
|
-
| `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()`) |
|
|
96
104
|
|
|
97
105
|
`artifactSettings` determines how Artifacts are minimized and viewed:
|
|
98
106
|
|
|
@@ -107,78 +115,81 @@ const settings = new ArtifactSettings({
|
|
|
107
115
|
const tools = new A2ATools(session, { artifactSettings: settings });
|
|
108
116
|
```
|
|
109
117
|
|
|
110
|
-
| Field
|
|
111
|
-
|
|
112
|
-
| `sendMessageCharacterLimit`
|
|
113
|
-
| `minimizedObjectStringLength` | `number` | `5,000`
|
|
114
|
-
| `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` |
|
|
115
123
|
|
|
116
|
-
#### `
|
|
124
|
+
#### `getAgents`
|
|
117
125
|
|
|
118
126
|
List all available agents with their names and descriptions.
|
|
119
127
|
|
|
120
128
|
```typescript
|
|
121
|
-
const result = await tools.getAgents();
|
|
129
|
+
const result = await tools.getAgents.execute({});
|
|
122
130
|
```
|
|
123
131
|
|
|
124
132
|
Example result:
|
|
125
133
|
|
|
126
134
|
```json
|
|
127
135
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
+
}
|
|
136
144
|
}
|
|
137
145
|
```
|
|
138
146
|
|
|
139
|
-
#### `
|
|
147
|
+
#### `getAgent`
|
|
140
148
|
|
|
141
149
|
Get detailed information about a specific agent, including its skills.
|
|
142
150
|
|
|
143
151
|
```typescript
|
|
144
|
-
const result = await tools.getAgent("research-bot");
|
|
152
|
+
const result = await tools.getAgent.execute({ agentId: "research-bot" });
|
|
145
153
|
```
|
|
146
154
|
|
|
147
155
|
Example result:
|
|
148
156
|
|
|
149
157
|
```json
|
|
150
158
|
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
]
|
|
163
171
|
}
|
|
164
172
|
```
|
|
165
173
|
|
|
166
|
-
#### `
|
|
174
|
+
#### `sendMessage`
|
|
167
175
|
|
|
168
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.
|
|
169
177
|
|
|
170
|
-
| Parameter
|
|
171
|
-
|
|
172
|
-
| `agentId`
|
|
173
|
-
| `message`
|
|
174
|
-
| `contextId` | `string
|
|
175
|
-
| `taskId`
|
|
176
|
-
| `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) |
|
|
177
187
|
|
|
178
188
|
```typescript
|
|
179
|
-
const result = await tools.sendMessage(
|
|
180
|
-
"research-bot",
|
|
181
|
-
|
|
189
|
+
const result = await tools.sendMessage.execute({
|
|
190
|
+
agentId: "research-bot",
|
|
191
|
+
message: "Find recent papers on quantum computing",
|
|
192
|
+
});
|
|
182
193
|
```
|
|
183
194
|
|
|
184
195
|
Example result:
|
|
@@ -202,19 +213,19 @@ Example result:
|
|
|
202
213
|
"kind": "data",
|
|
203
214
|
"data": [
|
|
204
215
|
{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
"title": "Quantum Error Correction Advances",
|
|
217
|
+
"year": 2025,
|
|
218
|
+
"authors": "Chen et al."
|
|
208
219
|
},
|
|
209
220
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
"title": "Topological Quantum Computing Survey",
|
|
222
|
+
"year": 2024,
|
|
223
|
+
"authors": "Nakamura et al."
|
|
213
224
|
},
|
|
214
225
|
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
226
|
+
"title": "Fault-Tolerant Logical Qubits",
|
|
227
|
+
"year": 2024,
|
|
228
|
+
"authors": "Wang et al."
|
|
218
229
|
}
|
|
219
230
|
]
|
|
220
231
|
}
|
|
@@ -238,46 +249,53 @@ Example result:
|
|
|
238
249
|
Continue the conversation using `contextId`:
|
|
239
250
|
|
|
240
251
|
```typescript
|
|
241
|
-
const result2 = await tools.sendMessage(
|
|
242
|
-
"research-bot",
|
|
243
|
-
"Summarize the most recent result",
|
|
244
|
-
"ctx-456",
|
|
245
|
-
);
|
|
252
|
+
const result2 = await tools.sendMessage.execute({
|
|
253
|
+
agentId: "research-bot",
|
|
254
|
+
message: "Summarize the most recent result",
|
|
255
|
+
contextId: "ctx-456",
|
|
256
|
+
});
|
|
246
257
|
```
|
|
247
258
|
|
|
248
|
-
#### `
|
|
259
|
+
#### `getTask`
|
|
249
260
|
|
|
250
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"`).
|
|
251
262
|
|
|
252
|
-
| Parameter
|
|
253
|
-
|
|
254
|
-
| `agentId`
|
|
255
|
-
| `taskId`
|
|
256
|
-
| `timeout`
|
|
257
|
-
| `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 |
|
|
258
269
|
|
|
259
270
|
```typescript
|
|
260
|
-
const result = await tools.getTask(
|
|
271
|
+
const result = await tools.getTask.execute({
|
|
272
|
+
agentId: "research-bot",
|
|
273
|
+
taskId: "task-123",
|
|
274
|
+
});
|
|
261
275
|
```
|
|
262
276
|
|
|
263
|
-
#### `
|
|
277
|
+
#### `viewTextArtifact`
|
|
264
278
|
|
|
265
279
|
View text content from an artifact, optionally selecting a range. Use this for artifacts containing text (documents, logs, code, etc.).
|
|
266
280
|
|
|
267
|
-
| Parameter
|
|
268
|
-
|
|
269
|
-
| `agentId`
|
|
270
|
-
| `taskId`
|
|
271
|
-
| `artifactId`
|
|
272
|
-
| `lineStart`
|
|
273
|
-
| `lineEnd`
|
|
274
|
-
| `characterStart` | `number
|
|
275
|
-
| `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) |
|
|
276
290
|
|
|
277
291
|
```typescript
|
|
278
|
-
const result = await tools.viewTextArtifact(
|
|
279
|
-
"research-bot",
|
|
280
|
-
|
|
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
|
+
});
|
|
281
299
|
```
|
|
282
300
|
|
|
283
301
|
Example result:
|
|
@@ -296,24 +314,27 @@ Example result:
|
|
|
296
314
|
}
|
|
297
315
|
```
|
|
298
316
|
|
|
299
|
-
#### `
|
|
317
|
+
#### `viewDataArtifact`
|
|
300
318
|
|
|
301
319
|
View structured data from an artifact with optional filtering. Use this for artifacts containing JSON data (objects, arrays, tables).
|
|
302
320
|
|
|
303
|
-
| Parameter
|
|
304
|
-
|
|
305
|
-
| `agentId`
|
|
306
|
-
| `taskId`
|
|
307
|
-
| `artifactId` | `string` | Yes
|
|
308
|
-
| `jsonPath`
|
|
309
|
-
| `rows`
|
|
310
|
-
| `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"` |
|
|
311
329
|
|
|
312
330
|
```typescript
|
|
313
|
-
const result = await tools.viewDataArtifact(
|
|
314
|
-
"research-bot",
|
|
315
|
-
|
|
316
|
-
|
|
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
|
+
});
|
|
317
338
|
```
|
|
318
339
|
|
|
319
340
|
Example result:
|
|
@@ -327,8 +348,8 @@ Example result:
|
|
|
327
348
|
{
|
|
328
349
|
"kind": "data",
|
|
329
350
|
"data": [
|
|
330
|
-
{"title": "Quantum Error Correction Advances", "year": 2025},
|
|
331
|
-
{"title": "Topological Quantum Computing Survey", "year": 2024}
|
|
351
|
+
{ "title": "Quantum Error Correction Advances", "year": 2025 },
|
|
352
|
+
{ "title": "Topological Quantum Computing Survey", "year": 2024 }
|
|
332
353
|
]
|
|
333
354
|
}
|
|
334
355
|
]
|
|
@@ -353,43 +374,42 @@ const session = new A2ASession(
|
|
|
353
374
|
);
|
|
354
375
|
```
|
|
355
376
|
|
|
356
|
-
| Parameter
|
|
357
|
-
|
|
358
|
-
| `agents`
|
|
359
|
-
| `taskStore`
|
|
360
|
-
| `fileStore`
|
|
361
|
-
| `sendMessageTimeout`
|
|
362
|
-
| `getTaskTimeout`
|
|
363
|
-
| `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`) |
|
|
364
385
|
|
|
365
386
|
#### `async sendMessage(agentId: string, message: string, opts?): Promise<Task | Message>`
|
|
366
387
|
|
|
367
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.
|
|
368
389
|
|
|
369
|
-
| Parameter
|
|
370
|
-
|
|
371
|
-
| `agentId`
|
|
372
|
-
| `message`
|
|
373
|
-
| `opts.contextId` | `string \| null` | No
|
|
374
|
-
| `opts.taskId`
|
|
375
|
-
| `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`) |
|
|
376
397
|
|
|
377
398
|
```typescript
|
|
378
399
|
import type { Task, Message } from "@a2a-js/sdk";
|
|
379
400
|
|
|
380
401
|
const response = await session.sendMessage(
|
|
381
|
-
"research-bot",
|
|
402
|
+
"research-bot",
|
|
403
|
+
"Find recent papers on quantum computing",
|
|
382
404
|
);
|
|
383
405
|
```
|
|
384
406
|
|
|
385
407
|
Continue the conversation using `contextId`:
|
|
386
408
|
|
|
387
409
|
```typescript
|
|
388
|
-
const response2 = await session.sendMessage(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{ contextId: response.contextId },
|
|
392
|
-
);
|
|
410
|
+
const response2 = await session.sendMessage("research-bot", "Summarize the most recent result", {
|
|
411
|
+
contextId: response.contextId,
|
|
412
|
+
});
|
|
393
413
|
```
|
|
394
414
|
|
|
395
415
|
**Returns:** `Task | Message` (from `@a2a-js/sdk`)
|
|
@@ -400,12 +420,12 @@ Get the current state of a task. Monitors until a terminal state (`completed`, `
|
|
|
400
420
|
|
|
401
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).
|
|
402
422
|
|
|
403
|
-
| Parameter
|
|
404
|
-
|
|
405
|
-
| `agentId`
|
|
406
|
-
| `taskId`
|
|
407
|
-
| `opts.timeout`
|
|
408
|
-
| `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`) |
|
|
409
429
|
|
|
410
430
|
```typescript
|
|
411
431
|
const task = await session.getTask("research-bot", "task-123");
|
|
@@ -424,7 +444,7 @@ import { A2AAgents } from "@a2anet/a2a-utils";
|
|
|
424
444
|
const manager = new A2AAgents({
|
|
425
445
|
"language-translator": {
|
|
426
446
|
url: "https://example.com/language-translator/agent-card.json",
|
|
427
|
-
custom_headers: {
|
|
447
|
+
custom_headers: { Authorization: "Bearer tok_123" },
|
|
428
448
|
},
|
|
429
449
|
});
|
|
430
450
|
|
|
@@ -450,9 +470,9 @@ const agents = await manager.getAgents();
|
|
|
450
470
|
|
|
451
471
|
Generate summary of all agents, sorted by agent_id.
|
|
452
472
|
|
|
453
|
-
| Parameter | Type
|
|
454
|
-
|
|
455
|
-
| `detail`
|
|
473
|
+
| Parameter | Type | Required | Description |
|
|
474
|
+
| --------- | -------- | -------- | -------------------------------------------------------------------- |
|
|
475
|
+
| `detail` | `string` | No | Detail level: `"name"`, `"basic"` (default), `"skills"`, or `"full"` |
|
|
456
476
|
|
|
457
477
|
**Returns:** `Record<string, Record<string, unknown>>`
|
|
458
478
|
|
|
@@ -464,8 +484,8 @@ const summaries = await manager.getAgentsForLlm("name");
|
|
|
464
484
|
|
|
465
485
|
```json
|
|
466
486
|
{
|
|
467
|
-
|
|
468
|
-
|
|
487
|
+
"code-reviewer": { "name": "Code Reviewer" },
|
|
488
|
+
"language-translator": { "name": "Universal Translator" }
|
|
469
489
|
}
|
|
470
490
|
```
|
|
471
491
|
|
|
@@ -477,14 +497,14 @@ const summaries = await manager.getAgentsForLlm();
|
|
|
477
497
|
|
|
478
498
|
```json
|
|
479
499
|
{
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
+
}
|
|
488
508
|
}
|
|
489
509
|
```
|
|
490
510
|
|
|
@@ -496,16 +516,16 @@ const summaries = await manager.getAgentsForLlm("skills");
|
|
|
496
516
|
|
|
497
517
|
```json
|
|
498
518
|
{
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
+
}
|
|
509
529
|
}
|
|
510
530
|
```
|
|
511
531
|
|
|
@@ -517,30 +537,30 @@ const summaries = await manager.getAgentsForLlm("full");
|
|
|
517
537
|
|
|
518
538
|
```json
|
|
519
539
|
{
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
+
}
|
|
544
564
|
}
|
|
545
565
|
```
|
|
546
566
|
|
|
@@ -549,9 +569,9 @@ const summaries = await manager.getAgentsForLlm("full");
|
|
|
549
569
|
Retrieve agent by ID.
|
|
550
570
|
Note: this should NOT be added to the LLM's context, use `getAgentForLlm` instead.
|
|
551
571
|
|
|
552
|
-
| Parameter | Type
|
|
553
|
-
|
|
554
|
-
| `agentId` | `string` | Yes
|
|
572
|
+
| Parameter | Type | Required | Description |
|
|
573
|
+
| --------- | -------- | -------- | ----------------------------- |
|
|
574
|
+
| `agentId` | `string` | Yes | User-defined agent identifier |
|
|
555
575
|
|
|
556
576
|
**Returns:** [`AgentURLAndCustomHeaders`](#agenturlandcustomheaders) | `null`
|
|
557
577
|
|
|
@@ -565,10 +585,10 @@ Returns `null` if the agent ID is not registered.
|
|
|
565
585
|
|
|
566
586
|
Generate summary for a single agent.
|
|
567
587
|
|
|
568
|
-
| Parameter | Type
|
|
569
|
-
|
|
570
|
-
| `agentId` | `string` | Yes
|
|
571
|
-
| `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"` |
|
|
572
592
|
|
|
573
593
|
**Returns:** `Record<string, unknown> | null` — summary object or `null` if not found.
|
|
574
594
|
|
|
@@ -578,8 +598,8 @@ const summary = await manager.getAgentForLlm("language-translator");
|
|
|
578
598
|
|
|
579
599
|
```json
|
|
580
600
|
{
|
|
581
|
-
|
|
582
|
-
|
|
601
|
+
"name": "Universal Translator",
|
|
602
|
+
"description": "Translate text and audio between 50+ languages"
|
|
583
603
|
}
|
|
584
604
|
```
|
|
585
605
|
|
|
@@ -587,20 +607,18 @@ const summary = await manager.getAgentForLlm("language-translator");
|
|
|
587
607
|
|
|
588
608
|
Register a new agent at runtime.
|
|
589
609
|
|
|
590
|
-
| Parameter
|
|
591
|
-
|
|
592
|
-
| `agentId`
|
|
593
|
-
| `url`
|
|
594
|
-
| `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 |
|
|
595
615
|
|
|
596
616
|
**Throws:** `Error` if `agentId` is already registered.
|
|
597
617
|
|
|
598
618
|
```typescript
|
|
599
|
-
await manager.addAgent(
|
|
600
|
-
"
|
|
601
|
-
|
|
602
|
-
{ "X-API-Key": "key_123" },
|
|
603
|
-
);
|
|
619
|
+
await manager.addAgent("code-reviewer", "https://review.example.com/.well-known/agent-card.json", {
|
|
620
|
+
"X-API-Key": "key_123",
|
|
621
|
+
});
|
|
604
622
|
```
|
|
605
623
|
|
|
606
624
|
### 💾 JSONTaskStore
|
|
@@ -664,7 +682,7 @@ const savedPaths = await fileStore.save("task-123", artifact);
|
|
|
664
682
|
Example result:
|
|
665
683
|
|
|
666
684
|
```typescript
|
|
667
|
-
["./storage/files/task-123/art-789/quarterly_report.pdf"]
|
|
685
|
+
["./storage/files/task-123/art-789/quarterly_report.pdf"];
|
|
668
686
|
```
|
|
669
687
|
|
|
670
688
|
##### `async get(taskId: string, artifactId: string): Promise<string[]>`
|
|
@@ -678,7 +696,7 @@ const paths = await fileStore.get("task-123", "art-789");
|
|
|
678
696
|
Example result:
|
|
679
697
|
|
|
680
698
|
```typescript
|
|
681
|
-
["./storage/files/task-123/art-789/quarterly_report.pdf"]
|
|
699
|
+
["./storage/files/task-123/art-789/quarterly_report.pdf"];
|
|
682
700
|
```
|
|
683
701
|
|
|
684
702
|
Returns an empty array if no files are found.
|
|
@@ -701,14 +719,14 @@ await fileStore.delete("task-123", "art-789");
|
|
|
701
719
|
|
|
702
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`.
|
|
703
721
|
|
|
704
|
-
| Parameter
|
|
705
|
-
|
|
706
|
-
| `text`
|
|
707
|
-
| `opts.lineStart`
|
|
708
|
-
| `opts.lineEnd`
|
|
709
|
-
| `opts.characterStart` | `number \| null` | No
|
|
710
|
-
| `opts.characterEnd`
|
|
711
|
-
| `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`) |
|
|
712
730
|
|
|
713
731
|
**Returns:** `string`
|
|
714
732
|
|
|
@@ -743,11 +761,11 @@ Example result:
|
|
|
743
761
|
|
|
744
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.
|
|
745
763
|
|
|
746
|
-
| Parameter
|
|
747
|
-
|
|
748
|
-
| `text`
|
|
749
|
-
| `opts.characterLimit` | `number`
|
|
750
|
-
| `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) |
|
|
751
769
|
|
|
752
770
|
**Returns:** `Record<string, unknown>`
|
|
753
771
|
|
|
@@ -760,7 +778,7 @@ TextArtifacts.minimize("Hello, world!");
|
|
|
760
778
|
```
|
|
761
779
|
|
|
762
780
|
```json
|
|
763
|
-
{"text": "Hello, world!"}
|
|
781
|
+
{ "text": "Hello, world!" }
|
|
764
782
|
```
|
|
765
783
|
|
|
766
784
|
Long text (over limit):
|
|
@@ -787,13 +805,13 @@ TextArtifacts.minimize("x".repeat(60_000));
|
|
|
787
805
|
|
|
788
806
|
View structured data with optional filtering. Navigate with `jsonPath`, then filter with `rows`/`columns`.
|
|
789
807
|
|
|
790
|
-
| Parameter
|
|
791
|
-
|
|
792
|
-
| `data`
|
|
793
|
-
| `opts.jsonPath`
|
|
794
|
-
| `opts.rows`
|
|
795
|
-
| `opts.columns`
|
|
796
|
-
| `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`) |
|
|
797
815
|
|
|
798
816
|
**Returns:** `unknown` (filtered data)
|
|
799
817
|
|
|
@@ -815,8 +833,8 @@ Example result:
|
|
|
815
833
|
|
|
816
834
|
```json
|
|
817
835
|
[
|
|
818
|
-
{"name": "Alice", "department": "Engineering"},
|
|
819
|
-
{"name": "Bob", "department": "Design"}
|
|
836
|
+
{ "name": "Alice", "department": "Engineering" },
|
|
837
|
+
{ "name": "Bob", "department": "Design" }
|
|
820
838
|
]
|
|
821
839
|
```
|
|
822
840
|
|
|
@@ -824,12 +842,12 @@ Example result:
|
|
|
824
842
|
|
|
825
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`.
|
|
826
844
|
|
|
827
|
-
| Parameter
|
|
828
|
-
|
|
829
|
-
| `data`
|
|
830
|
-
| `opts.characterLimit`
|
|
831
|
-
| `opts.minimizedObjectStringLength` | `number`
|
|
832
|
-
| `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) |
|
|
833
851
|
|
|
834
852
|
**Returns:** `Record<string, unknown>`
|
|
835
853
|
|
|
@@ -868,46 +886,52 @@ DataArtifacts.minimize(data, { characterLimit: 100, minimizedObjectStringLength:
|
|
|
868
886
|
{
|
|
869
887
|
"count": 100,
|
|
870
888
|
"unique_count": 100,
|
|
871
|
-
"types": [
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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
|
+
],
|
|
881
901
|
"name": "name"
|
|
882
902
|
},
|
|
883
903
|
{
|
|
884
904
|
"count": 100,
|
|
885
905
|
"unique_count": 4,
|
|
886
|
-
"types": [
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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
|
+
],
|
|
896
918
|
"name": "department"
|
|
897
919
|
},
|
|
898
920
|
{
|
|
899
921
|
"count": 100,
|
|
900
922
|
"unique_count": 100,
|
|
901
|
-
"types": [
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
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
|
+
],
|
|
911
935
|
"name": "salary"
|
|
912
936
|
}
|
|
913
937
|
],
|
|
@@ -922,9 +946,9 @@ DataArtifacts.minimize(data, { characterLimit: 100, minimizedObjectStringLength:
|
|
|
922
946
|
|
|
923
947
|
Generate a summary of tabular data (array of objects). Returns one summary object per column with count, unique count, and per-type statistics.
|
|
924
948
|
|
|
925
|
-
| Parameter | Type
|
|
926
|
-
|
|
927
|
-
| `data`
|
|
949
|
+
| Parameter | Type | Required | Description |
|
|
950
|
+
| --------- | --------------------------- | -------- | ----------- |
|
|
951
|
+
| `data` | `Record<string, unknown>[]` | Yes | Table rows |
|
|
928
952
|
|
|
929
953
|
**Returns:** `Record<string, unknown>[]`
|
|
930
954
|
|
|
@@ -1000,9 +1024,9 @@ DataArtifacts.summarizeTable(data);
|
|
|
1000
1024
|
|
|
1001
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).
|
|
1002
1026
|
|
|
1003
|
-
| Parameter | Type
|
|
1004
|
-
|
|
1005
|
-
| `values`
|
|
1027
|
+
| Parameter | Type | Required | Description |
|
|
1028
|
+
| --------- | ----------- | -------- | ------------------- |
|
|
1029
|
+
| `values` | `unknown[]` | Yes | Values to summarize |
|
|
1006
1030
|
|
|
1007
1031
|
**Returns:** `Record<string, unknown> | unknown[]`
|
|
1008
1032
|
|
|
@@ -1010,9 +1034,17 @@ Generate statistics for a list of values (like a single column). Includes count,
|
|
|
1010
1034
|
import { DataArtifacts } from "@a2anet/a2a-utils";
|
|
1011
1035
|
|
|
1012
1036
|
const salaries = [
|
|
1013
|
-
95000,
|
|
1037
|
+
95000,
|
|
1038
|
+
72000,
|
|
1039
|
+
105000,
|
|
1040
|
+
68000,
|
|
1041
|
+
88000,
|
|
1014
1042
|
// ... ~100 salary values total, with some nulls
|
|
1015
|
-
null,
|
|
1043
|
+
null,
|
|
1044
|
+
115000,
|
|
1045
|
+
92000,
|
|
1046
|
+
null,
|
|
1047
|
+
78000,
|
|
1016
1048
|
];
|
|
1017
1049
|
|
|
1018
1050
|
DataArtifacts.summarizeValues(salaries);
|
|
@@ -1047,14 +1079,14 @@ DataArtifacts.summarizeValues(salaries);
|
|
|
1047
1079
|
|
|
1048
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.
|
|
1049
1081
|
|
|
1050
|
-
| Parameter
|
|
1051
|
-
|
|
1052
|
-
| `artifacts`
|
|
1053
|
-
| `opts.characterLimit`
|
|
1054
|
-
| `opts.minimizedObjectStringLength` | `number`
|
|
1055
|
-
| `opts.savedFilePaths`
|
|
1056
|
-
| `opts.textTip`
|
|
1057
|
-
| `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`) |
|
|
1058
1090
|
|
|
1059
1091
|
**Returns:** [`ArtifactForLLM`](#artifactforllm)`[]`
|
|
1060
1092
|
|
|
@@ -1073,14 +1105,16 @@ const artifacts: Artifact[] = [
|
|
|
1073
1105
|
artifactId: "art-456",
|
|
1074
1106
|
description: "Company employee directory with names, departments, and salaries.",
|
|
1075
1107
|
name: "Employee Directory",
|
|
1076
|
-
parts: [
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
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
|
+
],
|
|
1084
1118
|
},
|
|
1085
1119
|
{
|
|
1086
1120
|
artifactId: "art-789",
|
|
@@ -1195,14 +1229,14 @@ const agent: AgentURLAndCustomHeaders = {
|
|
|
1195
1229
|
};
|
|
1196
1230
|
```
|
|
1197
1231
|
|
|
1198
|
-
| Field
|
|
1199
|
-
|
|
1200
|
-
| `agentCard`
|
|
1232
|
+
| Field | Type |
|
|
1233
|
+
| --------------- | ------------------------ |
|
|
1234
|
+
| `agentCard` | `AgentCard` |
|
|
1201
1235
|
| `customHeaders` | `Record<string, string>` |
|
|
1202
1236
|
|
|
1203
1237
|
#### `TaskForLLM`
|
|
1204
1238
|
|
|
1205
|
-
Returned by `A2ATools.sendMessage()` for task responses.
|
|
1239
|
+
Returned by `A2ATools.sendMessage.execute()` for task responses.
|
|
1206
1240
|
|
|
1207
1241
|
```typescript
|
|
1208
1242
|
const task: TaskForLLM = {
|
|
@@ -1265,17 +1299,17 @@ const task: TaskForLLM = {
|
|
|
1265
1299
|
};
|
|
1266
1300
|
```
|
|
1267
1301
|
|
|
1268
|
-
| Field
|
|
1269
|
-
|
|
1270
|
-
| `id`
|
|
1271
|
-
| `contextId` | `string`
|
|
1272
|
-
| `kind`
|
|
1273
|
-
| `status`
|
|
1302
|
+
| Field | Type |
|
|
1303
|
+
| ----------- | --------------------------------------- |
|
|
1304
|
+
| `id` | `string` |
|
|
1305
|
+
| `contextId` | `string` |
|
|
1306
|
+
| `kind` | `string` (`"task"`) |
|
|
1307
|
+
| `status` | [`TaskStatusForLLM`](#taskstatusforllm) |
|
|
1274
1308
|
| `artifacts` | [`ArtifactForLLM`](#artifactforllm)`[]` |
|
|
1275
1309
|
|
|
1276
1310
|
#### `MessageForLLM`
|
|
1277
1311
|
|
|
1278
|
-
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`.
|
|
1279
1313
|
|
|
1280
1314
|
```typescript
|
|
1281
1315
|
const message: MessageForLLM = {
|
|
@@ -1290,11 +1324,11 @@ const message: MessageForLLM = {
|
|
|
1290
1324
|
};
|
|
1291
1325
|
```
|
|
1292
1326
|
|
|
1293
|
-
| Field
|
|
1294
|
-
|
|
1295
|
-
| `contextId` | `string \| null`
|
|
1296
|
-
| `kind`
|
|
1297
|
-
| `parts`
|
|
1327
|
+
| Field | Type |
|
|
1328
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
1329
|
+
| `contextId` | `string \| null` |
|
|
1330
|
+
| `kind` | `string` (`"message"`) |
|
|
1331
|
+
| `parts` | ([`TextPartForLLM`](#textpartforllm) \| [`DataPartForLLM`](#datapartforllm) \| [`FilePartForLLM`](#filepartforllm))[] |
|
|
1298
1332
|
|
|
1299
1333
|
#### `TaskStatusForLLM`
|
|
1300
1334
|
|
|
@@ -1314,14 +1348,14 @@ const taskStatus: TaskStatusForLLM = {
|
|
|
1314
1348
|
};
|
|
1315
1349
|
```
|
|
1316
1350
|
|
|
1317
|
-
| Field
|
|
1318
|
-
|
|
1319
|
-
| `state`
|
|
1351
|
+
| Field | Type |
|
|
1352
|
+
| --------- | ------------------------------------------- |
|
|
1353
|
+
| `state` | `TaskState` |
|
|
1320
1354
|
| `message` | [`MessageForLLM`](#messageforllm) `\| null` |
|
|
1321
1355
|
|
|
1322
1356
|
#### `ArtifactForLLM`
|
|
1323
1357
|
|
|
1324
|
-
Returned by `viewTextArtifact()`, `viewDataArtifact()`, and `minimizeArtifacts()`. Used in `TaskForLLM.artifacts`.
|
|
1358
|
+
Returned by `viewTextArtifact.execute()`, `viewDataArtifact.execute()`, and `minimizeArtifacts()`. Used in `TaskForLLM.artifacts`.
|
|
1325
1359
|
|
|
1326
1360
|
```typescript
|
|
1327
1361
|
const artifact: ArtifactForLLM = {
|
|
@@ -1337,12 +1371,12 @@ const artifact: ArtifactForLLM = {
|
|
|
1337
1371
|
};
|
|
1338
1372
|
```
|
|
1339
1373
|
|
|
1340
|
-
| Field
|
|
1341
|
-
|
|
1342
|
-
| `artifactId`
|
|
1343
|
-
| `description` | `string \| null`
|
|
1344
|
-
| `name`
|
|
1345
|
-
| `parts`
|
|
1374
|
+
| Field | Type |
|
|
1375
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
1376
|
+
| `artifactId` | `string` |
|
|
1377
|
+
| `description` | `string \| null` |
|
|
1378
|
+
| `name` | `string \| null` |
|
|
1379
|
+
| `parts` | ([`TextPartForLLM`](#textpartforllm) \| [`DataPartForLLM`](#datapartforllm) \| [`FilePartForLLM`](#filepartforllm))[] |
|
|
1346
1380
|
|
|
1347
1381
|
#### `TextPartForLLM`
|
|
1348
1382
|
|
|
@@ -1353,10 +1387,10 @@ const textPart: TextPartForLLM = {
|
|
|
1353
1387
|
};
|
|
1354
1388
|
```
|
|
1355
1389
|
|
|
1356
|
-
| Field
|
|
1357
|
-
|
|
1390
|
+
| Field | Type |
|
|
1391
|
+
| ------ | ------------------- |
|
|
1358
1392
|
| `kind` | `string` (`"text"`) |
|
|
1359
|
-
| `text` | `string`
|
|
1393
|
+
| `text` | `string` |
|
|
1360
1394
|
|
|
1361
1395
|
#### `DataPartForLLM`
|
|
1362
1396
|
|
|
@@ -1383,10 +1417,10 @@ const dataPart: DataPartForLLM = {
|
|
|
1383
1417
|
};
|
|
1384
1418
|
```
|
|
1385
1419
|
|
|
1386
|
-
| Field
|
|
1387
|
-
|
|
1420
|
+
| Field | Type |
|
|
1421
|
+
| ------ | ------------------- |
|
|
1388
1422
|
| `kind` | `string` (`"data"`) |
|
|
1389
|
-
| `data` | `unknown`
|
|
1423
|
+
| `data` | `unknown` |
|
|
1390
1424
|
|
|
1391
1425
|
#### `FilePartForLLM`
|
|
1392
1426
|
|
|
@@ -1399,20 +1433,18 @@ const filePart: FilePartForLLM = {
|
|
|
1399
1433
|
mimeType: "application/pdf",
|
|
1400
1434
|
uri: null,
|
|
1401
1435
|
bytes: {
|
|
1402
|
-
_saved_to: [
|
|
1403
|
-
"./storage/files/task-123/art-789/q4-report.pdf",
|
|
1404
|
-
],
|
|
1436
|
+
_saved_to: ["./storage/files/task-123/art-789/q4-report.pdf"],
|
|
1405
1437
|
},
|
|
1406
1438
|
};
|
|
1407
1439
|
```
|
|
1408
1440
|
|
|
1409
|
-
| Field
|
|
1410
|
-
|
|
1411
|
-
| `kind`
|
|
1412
|
-
| `name`
|
|
1413
|
-
| `mimeType` | `string \| null`
|
|
1414
|
-
| `uri`
|
|
1415
|
-
| `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) |
|
|
1416
1448
|
|
|
1417
1449
|
## 📄 License
|
|
1418
1450
|
|