multi-agent-protocol 0.0.6 → 0.1.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/docs/11-trajectory-protocol.md +292 -0
- package/package.json +1 -1
- package/schema/meta.json +49 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# MAP Trajectory Protocol
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Trajectory Protocol is an **optional extension** to MAP that adds agent work trajectory tracking. While MAP's core protocol tracks agent lifecycle and state, and Mail tracks conversations between agents, Trajectory tracks **what agents actually do** — checkpoints of work with extensible metadata.
|
|
6
|
+
|
|
7
|
+
### Design Rationale
|
|
8
|
+
|
|
9
|
+
Multi-agent systems need observability not just into agent state (active, idle, stopped) and communication (messages, conversations), but into the **substance of agent work**:
|
|
10
|
+
|
|
11
|
+
- **Progress visibility**: What was accomplished at each milestone?
|
|
12
|
+
- **Cost tracking**: How many resources did an agent consume?
|
|
13
|
+
- **Session continuity**: What happened in previous work sessions?
|
|
14
|
+
- **Auditability**: A structured log of agent activity over time
|
|
15
|
+
|
|
16
|
+
Trajectory addresses these needs without changing the core agent lifecycle model. It records checkpoints — snapshots of agent work at meaningful points (task completions, session boundaries, or any agent-defined milestone).
|
|
17
|
+
|
|
18
|
+
### Design Philosophy
|
|
19
|
+
|
|
20
|
+
Trajectory is intentionally **minimal and agent-agnostic**. The core checkpoint type carries only universal fields (id, agentId, timestamp, label, sessionId). All domain-specific data — token usage, file lists, AI summaries, VCS info, attribution — goes into a freeform `metadata` bag.
|
|
21
|
+
|
|
22
|
+
This means:
|
|
23
|
+
- A coding agent can store `filesTouched`, `branch`, `commitHash` in metadata
|
|
24
|
+
- An LLM agent can store `tokenUsage` with whatever fields its provider uses
|
|
25
|
+
- A research agent can store `sourcesConsulted`, `documentsGenerated`
|
|
26
|
+
- Any agent can attach whatever makes sense for its workflow
|
|
27
|
+
|
|
28
|
+
### Relationship to Mail
|
|
29
|
+
|
|
30
|
+
Mail and Trajectory are **complementary**:
|
|
31
|
+
|
|
32
|
+
| Aspect | Mail | Trajectory |
|
|
33
|
+
|--------|------|-----------|
|
|
34
|
+
| **Tracks** | Conversations between participants | Individual agent work output |
|
|
35
|
+
| **Unit** | Turn (a message in a conversation) | Checkpoint (a snapshot of work) |
|
|
36
|
+
| **Content** | Text, data, events, references | Named artifacts (freeform) |
|
|
37
|
+
| **Trigger** | Explicit or intercepted messages | Agent-reported at meaningful milestones |
|
|
38
|
+
| **Primary audience** | Other agents, coordinators | Dashboards, auditors, developers |
|
|
39
|
+
|
|
40
|
+
An agent working on a task might participate in Mail conversations (coordinating with other agents) while also reporting Trajectory checkpoints (recording what work was done).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Concepts
|
|
45
|
+
|
|
46
|
+
### Checkpoint
|
|
47
|
+
|
|
48
|
+
A **checkpoint** is the atomic unit of trajectory tracking. It records a snapshot of agent work at a meaningful point:
|
|
49
|
+
|
|
50
|
+
- **Identity**: Which agent created it (`agentId`)
|
|
51
|
+
- **Timing**: When it was created (`timestamp`)
|
|
52
|
+
- **Label**: Human-readable description of the milestone (`label`)
|
|
53
|
+
- **Session**: Which work session it belongs to (`sessionId`)
|
|
54
|
+
- **Metadata**: Extensible key-value bag for agent-specific data (`metadata`)
|
|
55
|
+
|
|
56
|
+
Checkpoints are reported by agents via `trajectory/checkpoint` and stored server-side for querying.
|
|
57
|
+
|
|
58
|
+
### Content
|
|
59
|
+
|
|
60
|
+
Each checkpoint may have associated **content artifacts** — named blobs of data such as session transcripts, logs, prompts, or any other agent-specific content. Artifacts are served on-demand via `trajectory/content` with support for streaming large payloads.
|
|
61
|
+
|
|
62
|
+
Artifact names are freeform strings. Well-known names include:
|
|
63
|
+
- `metadata` — Structured checkpoint metadata
|
|
64
|
+
- `transcript` — Session transcript (may be large)
|
|
65
|
+
- `prompts` — User prompts
|
|
66
|
+
- `context` — Session context
|
|
67
|
+
|
|
68
|
+
Agents may define their own artifact names as needed.
|
|
69
|
+
|
|
70
|
+
### Content Streaming
|
|
71
|
+
|
|
72
|
+
For large artifacts, the response to `trajectory/content` indicates streaming mode:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Client Server
|
|
76
|
+
| |
|
|
77
|
+
|--- trajectory/content -->| (request with id)
|
|
78
|
+
| |
|
|
79
|
+
|<-- response (streaming) -| (small artifacts inline, streamId, streamInfo)
|
|
80
|
+
| |
|
|
81
|
+
|<-- content.chunk [0] ----| (base64-encoded chunk)
|
|
82
|
+
|<-- content.chunk [1] ----|
|
|
83
|
+
|<-- content.chunk [N] ----| (final=true, checksum)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Small artifacts are returned inline in the response. One large artifact per request can be streamed via chunks.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Methods
|
|
91
|
+
|
|
92
|
+
### trajectory/checkpoint
|
|
93
|
+
|
|
94
|
+
**Report a trajectory checkpoint.** Called by agents when they reach a meaningful milestone.
|
|
95
|
+
|
|
96
|
+
- **Tier**: Extension
|
|
97
|
+
- **Callable by**: Agent
|
|
98
|
+
- **Capability**: `trajectory.canReport`
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// Request
|
|
102
|
+
{
|
|
103
|
+
method: "trajectory/checkpoint",
|
|
104
|
+
params: {
|
|
105
|
+
checkpoint: {
|
|
106
|
+
id: "a1b2c3d4e5f6",
|
|
107
|
+
agentId: "agent-1",
|
|
108
|
+
label: "Implement JWT authentication middleware",
|
|
109
|
+
sessionId: "sess-abc",
|
|
110
|
+
metadata: {
|
|
111
|
+
agent: "Claude Code",
|
|
112
|
+
branch: "feature/auth",
|
|
113
|
+
commitHash: "abc123def",
|
|
114
|
+
filesTouched: ["src/auth.ts", "src/middleware.ts"],
|
|
115
|
+
tokenUsage: {
|
|
116
|
+
inputTokens: 50000,
|
|
117
|
+
outputTokens: 12000
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Response
|
|
125
|
+
{
|
|
126
|
+
result: {
|
|
127
|
+
checkpoint: { /* stored checkpoint with server timestamp */ }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### trajectory/list
|
|
133
|
+
|
|
134
|
+
**List trajectory checkpoints** with optional filtering and pagination.
|
|
135
|
+
|
|
136
|
+
- **Tier**: Extension
|
|
137
|
+
- **Callable by**: Client, Agent
|
|
138
|
+
- **Capability**: `trajectory.canQuery`
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Request
|
|
142
|
+
{
|
|
143
|
+
method: "trajectory/list",
|
|
144
|
+
params: {
|
|
145
|
+
filter: {
|
|
146
|
+
agentId: "agent-1",
|
|
147
|
+
afterTimestamp: 1706120000000
|
|
148
|
+
},
|
|
149
|
+
limit: 20
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Response
|
|
154
|
+
{
|
|
155
|
+
result: {
|
|
156
|
+
checkpoints: [ /* ... */ ],
|
|
157
|
+
hasMore: true,
|
|
158
|
+
nextCursor: "ckpt-xyz"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### trajectory/get
|
|
164
|
+
|
|
165
|
+
**Get a specific checkpoint** by ID.
|
|
166
|
+
|
|
167
|
+
- **Tier**: Extension
|
|
168
|
+
- **Callable by**: Client, Agent
|
|
169
|
+
- **Capability**: `trajectory.canQuery`
|
|
170
|
+
|
|
171
|
+
### trajectory/content
|
|
172
|
+
|
|
173
|
+
**Request content artifacts** for a checkpoint. May return inline or initiate streaming.
|
|
174
|
+
|
|
175
|
+
- **Tier**: Extension
|
|
176
|
+
- **Callable by**: Client, Agent
|
|
177
|
+
- **Capability**: `trajectory.canRequestContent`
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// Request
|
|
181
|
+
{
|
|
182
|
+
method: "trajectory/content",
|
|
183
|
+
params: {
|
|
184
|
+
checkpointId: "a1b2c3d4e5f6",
|
|
185
|
+
include: ["metadata", "transcript"]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Response (inline — all artifacts fit in a single message)
|
|
190
|
+
{
|
|
191
|
+
result: {
|
|
192
|
+
content: {
|
|
193
|
+
streaming: false,
|
|
194
|
+
checkpointId: "a1b2c3d4e5f6",
|
|
195
|
+
artifacts: {
|
|
196
|
+
metadata: { /* structured metadata */ },
|
|
197
|
+
transcript: "{ ... }\n{ ... }\n"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Response (streaming — one large artifact will arrive as chunks)
|
|
204
|
+
{
|
|
205
|
+
result: {
|
|
206
|
+
content: {
|
|
207
|
+
streaming: true,
|
|
208
|
+
checkpointId: "a1b2c3d4e5f6",
|
|
209
|
+
streamId: "stream-123",
|
|
210
|
+
artifacts: {
|
|
211
|
+
metadata: { /* inline — small */ },
|
|
212
|
+
prompts: "..."
|
|
213
|
+
},
|
|
214
|
+
streamArtifact: "transcript",
|
|
215
|
+
streamInfo: {
|
|
216
|
+
totalBytes: 2048000,
|
|
217
|
+
totalChunks: 4,
|
|
218
|
+
encoding: "base64"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### trajectory/content.chunk (notification)
|
|
226
|
+
|
|
227
|
+
**Content chunk** sent after a streaming content response. Not a request — no response expected.
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
{
|
|
231
|
+
method: "trajectory/content.chunk",
|
|
232
|
+
params: {
|
|
233
|
+
streamId: "stream-123",
|
|
234
|
+
index: 0,
|
|
235
|
+
data: "eyJ0eXBlIjoi...", // base64-encoded chunk
|
|
236
|
+
final: false
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The final chunk includes `final: true` and a `checksum` (SHA-256 of the full content).
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Events
|
|
246
|
+
|
|
247
|
+
### trajectory.checkpoint
|
|
248
|
+
|
|
249
|
+
Emitted when an agent reports a checkpoint. Subscribe to track agent work in real-time.
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
{
|
|
253
|
+
type: "trajectory.checkpoint",
|
|
254
|
+
data: {
|
|
255
|
+
checkpoint: { /* TrajectoryCheckpoint */ }
|
|
256
|
+
},
|
|
257
|
+
source: { agentId: "agent-1" }
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### trajectory.content.available
|
|
262
|
+
|
|
263
|
+
Emitted when full content for a checkpoint becomes available (e.g., after caching from a remote agent).
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Capabilities
|
|
268
|
+
|
|
269
|
+
Add `trajectory` to `ParticipantCapabilities`:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
trajectory?: {
|
|
273
|
+
enabled?: boolean; // Server supports trajectory
|
|
274
|
+
canReport?: boolean; // Can report checkpoints
|
|
275
|
+
canQuery?: boolean; // Can list/get checkpoints
|
|
276
|
+
canRequestContent?: boolean; // Can request full content
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Advertised in `map/connect` response when the server supports trajectory tracking.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Error Codes
|
|
285
|
+
|
|
286
|
+
| Code | Name | Description |
|
|
287
|
+
|------|------|-------------|
|
|
288
|
+
| 13000 | TRAJECTORY_NOT_ENABLED | Server does not support trajectory extension |
|
|
289
|
+
| 13001 | TRAJECTORY_CHECKPOINT_NOT_FOUND | Checkpoint ID not found |
|
|
290
|
+
| 13002 | TRAJECTORY_CONTENT_UNAVAILABLE | Content provider not configured or content not available |
|
|
291
|
+
| 13003 | TRAJECTORY_STREAM_FAILED | Streaming content transfer failed |
|
|
292
|
+
| 13004 | TRAJECTORY_PERMISSION_DENIED | Insufficient permissions for trajectory operation |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multi-agent-protocol",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Multi-Agent Protocol (MAP) - A protocol for observing, coordinating, and routing messages within multi-agent AI systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./schema/schema.json",
|
package/schema/meta.json
CHANGED
|
@@ -435,6 +435,42 @@
|
|
|
435
435
|
"description": "Read file contents from an agent's workspace",
|
|
436
436
|
"requestType": "WorkspaceReadRequest",
|
|
437
437
|
"responseType": "WorkspaceReadResponse"
|
|
438
|
+
},
|
|
439
|
+
"trajectory/checkpoint": {
|
|
440
|
+
"tier": "extension",
|
|
441
|
+
"implementedBy": "system",
|
|
442
|
+
"callableBy": ["agent"],
|
|
443
|
+
"capabilities": ["trajectory.canReport"],
|
|
444
|
+
"description": "Report a trajectory checkpoint with metadata",
|
|
445
|
+
"requestType": "TrajectoryCheckpointRequest",
|
|
446
|
+
"responseType": "TrajectoryCheckpointResponse"
|
|
447
|
+
},
|
|
448
|
+
"trajectory/list": {
|
|
449
|
+
"tier": "extension",
|
|
450
|
+
"implementedBy": "system",
|
|
451
|
+
"callableBy": ["client", "agent"],
|
|
452
|
+
"capabilities": ["trajectory.canQuery"],
|
|
453
|
+
"description": "List trajectory checkpoints with filtering",
|
|
454
|
+
"requestType": "TrajectoryListRequest",
|
|
455
|
+
"responseType": "TrajectoryListResponse"
|
|
456
|
+
},
|
|
457
|
+
"trajectory/get": {
|
|
458
|
+
"tier": "extension",
|
|
459
|
+
"implementedBy": "system",
|
|
460
|
+
"callableBy": ["client", "agent"],
|
|
461
|
+
"capabilities": ["trajectory.canQuery"],
|
|
462
|
+
"description": "Get a specific trajectory checkpoint",
|
|
463
|
+
"requestType": "TrajectoryGetRequest",
|
|
464
|
+
"responseType": "TrajectoryGetResponse"
|
|
465
|
+
},
|
|
466
|
+
"trajectory/content": {
|
|
467
|
+
"tier": "extension",
|
|
468
|
+
"implementedBy": "system",
|
|
469
|
+
"callableBy": ["client", "agent"],
|
|
470
|
+
"capabilities": ["trajectory.canRequestContent"],
|
|
471
|
+
"description": "Request full checkpoint content (may stream large transcripts)",
|
|
472
|
+
"requestType": "TrajectoryContentRequest",
|
|
473
|
+
"responseType": "TrajectoryContentResponse"
|
|
438
474
|
}
|
|
439
475
|
},
|
|
440
476
|
"notifications": {
|
|
@@ -449,6 +485,12 @@
|
|
|
449
485
|
"direction": "system-to-participant",
|
|
450
486
|
"description": "Message delivery notification",
|
|
451
487
|
"paramsType": "MessageNotification"
|
|
488
|
+
},
|
|
489
|
+
"trajectory/content.chunk": {
|
|
490
|
+
"tier": "extension",
|
|
491
|
+
"direction": "system-to-participant",
|
|
492
|
+
"description": "Content chunk for streaming large trajectory transcripts",
|
|
493
|
+
"paramsType": "TrajectoryContentChunkNotification"
|
|
452
494
|
}
|
|
453
495
|
},
|
|
454
496
|
"errorCodes": {
|
|
@@ -516,6 +558,13 @@
|
|
|
516
558
|
"12001": "File not found",
|
|
517
559
|
"12002": "Permission denied",
|
|
518
560
|
"12003": "Invalid path"
|
|
561
|
+
},
|
|
562
|
+
"trajectory": {
|
|
563
|
+
"13000": "Trajectory not enabled",
|
|
564
|
+
"13001": "Checkpoint not found",
|
|
565
|
+
"13002": "Content unavailable",
|
|
566
|
+
"13003": "Stream failed",
|
|
567
|
+
"13004": "Permission denied"
|
|
519
568
|
}
|
|
520
569
|
},
|
|
521
570
|
"tiers": {
|