dsh-a2a-server 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/CHANGELOG.zh-CN.md +28 -0
- package/README.md +151 -54
- package/README.zh-CN.md +113 -53
- package/cordis.patch.yml +10 -6
- package/lib/briefing.d.ts +39 -0
- package/lib/briefing.d.ts.map +1 -0
- package/lib/briefing.js +108 -0
- package/lib/briefing.js.map +1 -0
- package/lib/config.d.ts +69 -22
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +76 -6
- package/lib/config.js.map +1 -1
- package/lib/contexts.d.ts +9 -4
- package/lib/contexts.d.ts.map +1 -1
- package/lib/contexts.js +7 -13
- package/lib/contexts.js.map +1 -1
- package/lib/index.d.ts +1 -26
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +420 -408
- package/lib/index.js.map +1 -1
- package/lib/management.d.ts +5 -0
- package/lib/management.d.ts.map +1 -0
- package/lib/management.js +74 -0
- package/lib/management.js.map +1 -0
- package/lib/projection.d.ts +67 -22
- package/lib/projection.d.ts.map +1 -1
- package/lib/projection.js +30 -11
- package/lib/projection.js.map +1 -1
- package/lib/protocol/card.d.ts +25 -7
- package/lib/protocol/card.d.ts.map +1 -1
- package/lib/protocol/card.js +35 -14
- package/lib/protocol/card.js.map +1 -1
- package/lib/protocol/index.d.ts +10 -10
- package/lib/protocol/index.d.ts.map +1 -1
- package/lib/protocol/index.js +8 -8
- package/lib/protocol/index.js.map +1 -1
- package/lib/protocol/jsonrpc.d.ts +54 -6
- package/lib/protocol/jsonrpc.d.ts.map +1 -1
- package/lib/protocol/jsonrpc.js +70 -8
- package/lib/protocol/jsonrpc.js.map +1 -1
- package/lib/protocol/parse.d.ts +79 -0
- package/lib/protocol/parse.d.ts.map +1 -0
- package/lib/protocol/parse.js +249 -0
- package/lib/protocol/parse.js.map +1 -0
- package/lib/protocol/sse.d.ts +6 -3
- package/lib/protocol/sse.d.ts.map +1 -1
- package/lib/protocol/sse.js +4 -2
- package/lib/protocol/sse.js.map +1 -1
- package/lib/protocol/wire.d.ts +165 -54
- package/lib/protocol/wire.d.ts.map +1 -1
- package/lib/protocol/wire.js +54 -9
- package/lib/protocol/wire.js.map +1 -1
- package/lib/router.d.ts +55 -1
- package/lib/router.d.ts.map +1 -1
- package/lib/router.js +419 -137
- package/lib/router.js.map +1 -1
- package/lib/security.d.ts +37 -3
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +48 -4
- package/lib/security.js.map +1 -1
- package/lib/state.d.ts +37 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +146 -0
- package/lib/state.js.map +1 -0
- package/lib/tasks.d.ts +4 -0
- package/lib/tasks.d.ts.map +1 -1
- package/lib/tasks.js +23 -5
- package/lib/tasks.js.map +1 -1
- package/lib/types.d.ts +12 -3
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/version.d.ts +20 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +20 -0
- package/lib/version.js.map +1 -0
- package/lib/workspace-read.d.ts +9 -0
- package/lib/workspace-read.d.ts.map +1 -0
- package/lib/workspace-read.js +152 -0
- package/lib/workspace-read.js.map +1 -0
- package/package.json +39 -30
- package/lib/protocol/normalize.d.ts +0 -72
- package/lib/protocol/normalize.d.ts.map +0 -1
- package/lib/protocol/normalize.js +0 -278
- package/lib/protocol/normalize.js.map +0 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbound parsing: peer JSON to the internal v1.0 shape.
|
|
3
|
+
*
|
|
4
|
+
* There is no outbound counterpart. v0.3 needed one because two spellings had
|
|
5
|
+
* to be reconciled; this server speaks v1.0 only, so what {@link ./wire.ts}
|
|
6
|
+
* describes is what gets serialized, and the only work left is validating what
|
|
7
|
+
* arrives.
|
|
8
|
+
*
|
|
9
|
+
* Parsing is permissive about what it IGNORES (unknown members are skipped, as
|
|
10
|
+
* the spec's forward-compatibility rule requires) and strict about what it
|
|
11
|
+
* ACCEPTS: a v0.3 spelling is not quietly translated, because a peer that
|
|
12
|
+
* believes it is talking v0.3 to a v1.0-only agent needs to be told.
|
|
13
|
+
*
|
|
14
|
+
* @module dsh-a2a/protocol/parse
|
|
15
|
+
*/
|
|
16
|
+
import { A2AContextId, A2ATaskId } from "./brand.js";
|
|
17
|
+
import { TASK_STATES } from "./wire.js";
|
|
18
|
+
/**
|
|
19
|
+
* Every method this server answers, in the v1.0 PascalCase spelling.
|
|
20
|
+
*
|
|
21
|
+
* The names match the gRPC service methods exactly, which is the point of the
|
|
22
|
+
* v1.0 renaming: one operation has one name across all three bindings.
|
|
23
|
+
*/
|
|
24
|
+
const METHODS = new Map([
|
|
25
|
+
['SendMessage', 'send'],
|
|
26
|
+
['SendStreamingMessage', 'stream'],
|
|
27
|
+
['GetTask', 'get'],
|
|
28
|
+
['ListTasks', 'list'],
|
|
29
|
+
['CancelTask', 'cancel'],
|
|
30
|
+
['SubscribeToTask', 'subscribe'],
|
|
31
|
+
['CreateTaskPushNotificationConfig', 'push_create'],
|
|
32
|
+
['GetTaskPushNotificationConfig', 'push_get'],
|
|
33
|
+
['ListTaskPushNotificationConfigs', 'push_list'],
|
|
34
|
+
['DeleteTaskPushNotificationConfig', 'push_delete'],
|
|
35
|
+
['GetExtendedAgentCard', 'extended_card'],
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* The v0.3 names, kept only to explain their absence.
|
|
39
|
+
*
|
|
40
|
+
* A peer that sends `message/send` gets a method-not-found naming its v1.0
|
|
41
|
+
* replacement. Answering the call would be worse: the reply would be v1.0
|
|
42
|
+
* JSON that a v0.3 client cannot read, and the failure would surface much
|
|
43
|
+
* further from its cause.
|
|
44
|
+
*/
|
|
45
|
+
const LEGACY_METHODS = new Map([
|
|
46
|
+
['message/send', 'SendMessage'],
|
|
47
|
+
['message/stream', 'SendStreamingMessage'],
|
|
48
|
+
['tasks/get', 'GetTask'],
|
|
49
|
+
['tasks/cancel', 'CancelTask'],
|
|
50
|
+
['tasks/resubscribe', 'SubscribeToTask'],
|
|
51
|
+
['tasks/pushNotificationConfig/set', 'CreateTaskPushNotificationConfig'],
|
|
52
|
+
['tasks/pushNotificationConfig/get', 'GetTaskPushNotificationConfig'],
|
|
53
|
+
['tasks/pushNotificationConfig/list', 'ListTaskPushNotificationConfigs'],
|
|
54
|
+
['tasks/pushNotificationConfig/delete', 'DeleteTaskPushNotificationConfig'],
|
|
55
|
+
['tasks/pushNotification/set', 'CreateTaskPushNotificationConfig'],
|
|
56
|
+
['agent/getAuthenticatedExtendedCard', 'GetExtendedAgentCard'],
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a method name to its operation.
|
|
60
|
+
* @param method - the raw `method` string from the request.
|
|
61
|
+
* @returns the operation, or undefined for an unknown method.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveMethod(method) {
|
|
64
|
+
return METHODS.get(method);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The v1.0 name that replaced a retired v0.3 method.
|
|
68
|
+
* @param method - the raw `method` string from the request.
|
|
69
|
+
* @returns the replacement name, or undefined when the method was never ours.
|
|
70
|
+
*/
|
|
71
|
+
export function legacyMethodReplacement(method) {
|
|
72
|
+
return LEGACY_METHODS.get(method);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read one `Part`.
|
|
76
|
+
*
|
|
77
|
+
* v1.0 discriminates on which content member is present, so the probes below
|
|
78
|
+
* must each be specific enough not to claim another variant's shape. An
|
|
79
|
+
* unrecognizable part yields undefined rather than throwing: one odd part must
|
|
80
|
+
* not fail a request whose other parts are usable.
|
|
81
|
+
* @param raw - one element of a `parts` array.
|
|
82
|
+
* @returns the normalized part, or undefined when no content member is present.
|
|
83
|
+
*/
|
|
84
|
+
export function parsePart(raw) {
|
|
85
|
+
if (raw === null || typeof raw !== 'object')
|
|
86
|
+
return undefined;
|
|
87
|
+
const part = raw;
|
|
88
|
+
const common = {
|
|
89
|
+
...typeof part['mediaType'] === 'string' ? { mediaType: part['mediaType'] } : {},
|
|
90
|
+
...isObject(part['metadata']) ? { metadata: part['metadata'] } : {},
|
|
91
|
+
};
|
|
92
|
+
if (typeof part['text'] === 'string')
|
|
93
|
+
return { text: part['text'], ...common };
|
|
94
|
+
if (typeof part['url'] === 'string' || typeof part['raw'] === 'string') {
|
|
95
|
+
return {
|
|
96
|
+
...typeof part['url'] === 'string' ? { url: part['url'] } : {},
|
|
97
|
+
...typeof part['raw'] === 'string' ? { raw: part['raw'] } : {},
|
|
98
|
+
...typeof part['filename'] === 'string' ? { filename: part['filename'] } : {},
|
|
99
|
+
...common,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if ('data' in part)
|
|
103
|
+
return { data: part['data'], ...common };
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Render every part as text the model can read.
|
|
108
|
+
*
|
|
109
|
+
* File and data parts become bracketed references rather than being dropped, so
|
|
110
|
+
* the agent knows something was attached and can ask about it. This is the same
|
|
111
|
+
* flattening `dsh-acp` applies to baseline resource links.
|
|
112
|
+
* @param parts - normalized parts, in order.
|
|
113
|
+
* @returns the joined text, empty when nothing rendered.
|
|
114
|
+
*/
|
|
115
|
+
export function partsToText(parts) {
|
|
116
|
+
const chunks = [];
|
|
117
|
+
for (const part of parts) {
|
|
118
|
+
if ('text' in part) {
|
|
119
|
+
if (part.text.length > 0)
|
|
120
|
+
chunks.push(part.text);
|
|
121
|
+
}
|
|
122
|
+
else if ('data' in part) {
|
|
123
|
+
chunks.push(`[data ${JSON.stringify(part.data)}]`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const name = part.filename ?? part.url ?? 'unnamed';
|
|
127
|
+
const type = part.mediaType === undefined ? '' : ` mediaType=${part.mediaType}`;
|
|
128
|
+
chunks.push(`[file name=${name}${type}]`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return chunks.join('\n');
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Parse the `SendMessage` / `SendStreamingMessage` request object.
|
|
135
|
+
* @param raw - the request's `params` value.
|
|
136
|
+
* @returns the normalized request, or undefined when the shape is unusable.
|
|
137
|
+
*/
|
|
138
|
+
export function parseSendMessageRequest(raw) {
|
|
139
|
+
if (!isObject(raw))
|
|
140
|
+
return undefined;
|
|
141
|
+
const params = raw;
|
|
142
|
+
const rawMessage = params['message'];
|
|
143
|
+
if (!isObject(rawMessage))
|
|
144
|
+
return undefined;
|
|
145
|
+
const message = rawMessage;
|
|
146
|
+
const parts = [];
|
|
147
|
+
if (Array.isArray(message['parts'])) {
|
|
148
|
+
for (const item of message['parts']) {
|
|
149
|
+
const part = parsePart(item);
|
|
150
|
+
if (part !== undefined)
|
|
151
|
+
parts.push(part);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const contextId = firstString(message['contextId']);
|
|
155
|
+
const taskId = firstString(message['taskId']);
|
|
156
|
+
const normalized = {
|
|
157
|
+
messageId: firstString(message['messageId']) ?? '',
|
|
158
|
+
// v1.0 spells roles ROLE_USER / ROLE_AGENT. Anything else is a peer that
|
|
159
|
+
// has not migrated; treating it as a user message keeps the request usable
|
|
160
|
+
// and the agent still sees a peer-authored turn.
|
|
161
|
+
role: message['role'] === 'ROLE_AGENT' ? 'ROLE_AGENT' : 'ROLE_USER',
|
|
162
|
+
parts,
|
|
163
|
+
...contextId === undefined ? {} : { contextId: A2AContextId(contextId) },
|
|
164
|
+
...taskId === undefined ? {} : { taskId: A2ATaskId(taskId) },
|
|
165
|
+
};
|
|
166
|
+
const configuration = params['configuration'];
|
|
167
|
+
return {
|
|
168
|
+
message: normalized,
|
|
169
|
+
...isObject(configuration)
|
|
170
|
+
? { configuration: configuration }
|
|
171
|
+
: {},
|
|
172
|
+
...isObject(params['metadata']) ? { metadata: params['metadata'] } : {},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Parse `ListTasks` parameters.
|
|
177
|
+
*
|
|
178
|
+
* Every filter is optional; an absent `params` lists everything the caller may
|
|
179
|
+
* see. `pageSize` is clamped to the spec's 1..100 window rather than rejected,
|
|
180
|
+
* because a client asking for 500 wants "as many as you'll give me".
|
|
181
|
+
* @param raw - the request's `params` value.
|
|
182
|
+
* @returns the normalized filters.
|
|
183
|
+
*/
|
|
184
|
+
export function parseListTasksParams(raw) {
|
|
185
|
+
if (!isObject(raw))
|
|
186
|
+
return {};
|
|
187
|
+
const params = raw;
|
|
188
|
+
const status = typeof params['status'] === 'string' ? params['status'] : undefined;
|
|
189
|
+
const pageSize = typeof params['pageSize'] === 'number' && Number.isFinite(params['pageSize'])
|
|
190
|
+
? Math.min(100, Math.max(1, Math.floor(params['pageSize'])))
|
|
191
|
+
: undefined;
|
|
192
|
+
return {
|
|
193
|
+
...firstString(params['contextId']) === undefined
|
|
194
|
+
? {}
|
|
195
|
+
: { contextId: firstString(params['contextId']) },
|
|
196
|
+
...status !== undefined && TASK_STATES.includes(status)
|
|
197
|
+
? { status: status }
|
|
198
|
+
: {},
|
|
199
|
+
...pageSize === undefined ? {} : { pageSize },
|
|
200
|
+
...firstString(params['pageToken']) === undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { pageToken: firstString(params['pageToken']) },
|
|
203
|
+
...typeof params['historyLength'] === 'number'
|
|
204
|
+
? { historyLength: params['historyLength'] }
|
|
205
|
+
: {},
|
|
206
|
+
...firstString(params['statusTimestampAfter']) === undefined
|
|
207
|
+
? {}
|
|
208
|
+
: { statusTimestampAfter: firstString(params['statusTimestampAfter']) },
|
|
209
|
+
...typeof params['includeArtifacts'] === 'boolean'
|
|
210
|
+
? { includeArtifacts: params['includeArtifacts'] }
|
|
211
|
+
: {},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Read the `tenant` routing member.
|
|
216
|
+
*
|
|
217
|
+
* This card declares no tenant on its interface, so the spec's rule ("clients
|
|
218
|
+
* MUST include this value ... omit the field if tenant is not set") makes any
|
|
219
|
+
* non-empty tenant a misrouted request. Reporting it beats silently serving a
|
|
220
|
+
* peer that believes it reached a different agent.
|
|
221
|
+
* @param raw - the request's `params` value.
|
|
222
|
+
* @returns the tenant a peer asked for, or undefined when correctly omitted.
|
|
223
|
+
*/
|
|
224
|
+
export function parseTenant(raw) {
|
|
225
|
+
if (!isObject(raw))
|
|
226
|
+
return undefined;
|
|
227
|
+
return firstString(raw['tenant']);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Whether a value is a plain object usable as a JSON map.
|
|
231
|
+
* @param value - the candidate.
|
|
232
|
+
* @returns true for non-null, non-array objects.
|
|
233
|
+
*/
|
|
234
|
+
function isObject(value) {
|
|
235
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Return the first defined non-empty string among the candidates.
|
|
239
|
+
* @param values - candidate values in precedence order.
|
|
240
|
+
* @returns the winning string, or undefined.
|
|
241
|
+
*/
|
|
242
|
+
function firstString(...values) {
|
|
243
|
+
for (const value of values) {
|
|
244
|
+
if (typeof value === 'string' && value.length > 0)
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/protocol/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAwBvC;;;;;GAKG;AACH,MAAM,OAAO,GAAsC,IAAI,GAAG,CAAuB;IAC/E,CAAC,aAAa,EAAE,MAAM,CAAC;IACvB,CAAC,sBAAsB,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;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/lib/protocol/sse.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Server-Sent Events framing for `
|
|
2
|
+
* Server-Sent Events framing for `SendStreamingMessage` and `SubscribeToTask`.
|
|
3
3
|
*
|
|
4
4
|
* A2A streams JSON-RPC responses, not bare events: each frame carries the same
|
|
5
5
|
* envelope the unary methods return, correlated by the original request id.
|
|
6
|
+
* The payload is always a `StreamResponse` — v1.0 identifies an event by the
|
|
7
|
+
* member it is wrapped in, so a bare event on the wire is unreadable.
|
|
6
8
|
*
|
|
7
9
|
* @module dsh-a2a/protocol/sse
|
|
8
10
|
*/
|
|
11
|
+
import type { A2AStreamResponse } from './wire.ts';
|
|
9
12
|
/**
|
|
10
13
|
* Encode one payload as an SSE `data:` frame.
|
|
11
14
|
*
|
|
@@ -13,8 +16,8 @@
|
|
|
13
16
|
* serialized compactly (JSON.stringify emits no raw newlines) and terminated
|
|
14
17
|
* with the blank line SSE requires.
|
|
15
18
|
* @param id - the JSON-RPC id of the request this stream answers.
|
|
16
|
-
* @param payload - the
|
|
19
|
+
* @param payload - the StreamResponse to carry.
|
|
17
20
|
* @returns the wire text of one frame.
|
|
18
21
|
*/
|
|
19
|
-
export declare function sseFrame(id: string | number | null, payload:
|
|
22
|
+
export declare function sseFrame(id: string | number | null, payload: A2AStreamResponse): string;
|
|
20
23
|
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/protocol/sse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/protocol/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAEvF"}
|
package/lib/protocol/sse.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Server-Sent Events framing for `
|
|
2
|
+
* Server-Sent Events framing for `SendStreamingMessage` and `SubscribeToTask`.
|
|
3
3
|
*
|
|
4
4
|
* A2A streams JSON-RPC responses, not bare events: each frame carries the same
|
|
5
5
|
* envelope the unary methods return, correlated by the original request id.
|
|
6
|
+
* The payload is always a `StreamResponse` — v1.0 identifies an event by the
|
|
7
|
+
* member it is wrapped in, so a bare event on the wire is unreadable.
|
|
6
8
|
*
|
|
7
9
|
* @module dsh-a2a/protocol/sse
|
|
8
10
|
*/
|
|
@@ -14,7 +16,7 @@ import { jsonRpcResult } from "./jsonrpc.js";
|
|
|
14
16
|
* serialized compactly (JSON.stringify emits no raw newlines) and terminated
|
|
15
17
|
* with the blank line SSE requires.
|
|
16
18
|
* @param id - the JSON-RPC id of the request this stream answers.
|
|
17
|
-
* @param payload - the
|
|
19
|
+
* @param payload - the StreamResponse to carry.
|
|
18
20
|
* @returns the wire text of one frame.
|
|
19
21
|
*/
|
|
20
22
|
export function sseFrame(id, payload) {
|
package/lib/protocol/sse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/protocol/sse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/protocol/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,EAA0B,EAAE,OAA0B;IAC7E,OAAO,SAAS,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAA;AAClE,CAAC"}
|
package/lib/protocol/wire.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A2A wire vocabulary
|
|
2
|
+
* The A2A v1.0 wire vocabulary.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* There is exactly ONE shape in this server. v1.0 removed the `kind`
|
|
5
|
+
* discriminator, renamed every enum to its ProtoJSON spelling, and flattened
|
|
6
|
+
* `Part` into a single unified message — so the JSON these types describe is
|
|
7
|
+
* the JSON that goes on the wire, with no translation layer between them.
|
|
8
|
+
* That is the whole reason the v0.3 dialect machinery is gone: it existed only
|
|
9
|
+
* to bridge two spellings, and this server now speaks one.
|
|
8
10
|
*
|
|
9
11
|
* @module dsh-a2a/protocol/wire
|
|
10
12
|
*/
|
|
11
13
|
import type { A2AContextId, A2ATaskId } from './brand.ts';
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The single A2A protocol version this server implements.
|
|
16
|
+
*
|
|
17
|
+
* Major.Minor only: the spec states patch numbers do not affect compatibility
|
|
18
|
+
* and SHOULD NOT appear in requests, responses, or Agent Cards.
|
|
19
|
+
*/
|
|
20
|
+
export declare const A2A_PROTOCOL_VERSION = "1.0";
|
|
21
|
+
/** Task lifecycle state, in the ProtoJSON enum spelling v1.0 requires. */
|
|
22
|
+
export type A2ATaskState = 'TASK_STATE_UNSPECIFIED' | 'TASK_STATE_SUBMITTED' | 'TASK_STATE_WORKING' | 'TASK_STATE_INPUT_REQUIRED' | 'TASK_STATE_AUTH_REQUIRED' | 'TASK_STATE_COMPLETED' | 'TASK_STATE_CANCELED' | 'TASK_STATE_FAILED' | 'TASK_STATE_REJECTED';
|
|
23
|
+
/** Every state a peer may name, e.g. as the `ListTasks` status filter. */
|
|
24
|
+
export declare const TASK_STATES: readonly A2ATaskState[];
|
|
14
25
|
/** States after which a task accepts no further transition. */
|
|
15
26
|
export declare const TERMINAL_STATES: ReadonlySet<A2ATaskState>;
|
|
16
27
|
/**
|
|
@@ -19,41 +30,46 @@ export declare const TERMINAL_STATES: ReadonlySet<A2ATaskState>;
|
|
|
19
30
|
* @returns true when no further transition is accepted.
|
|
20
31
|
*/
|
|
21
32
|
export declare function isTerminal(state: A2ATaskState): boolean;
|
|
22
|
-
/** Message author, in the
|
|
23
|
-
export type A2ARole = '
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
/** Message author, in the ProtoJSON enum spelling. */
|
|
34
|
+
export type A2ARole = 'ROLE_USER' | 'ROLE_AGENT';
|
|
35
|
+
/**
|
|
36
|
+
* A text segment of a message or artifact.
|
|
37
|
+
*
|
|
38
|
+
* v1.0 unified the three part types into one message whose content member IS
|
|
39
|
+
* the discriminator, so these three interfaces narrow on member presence
|
|
40
|
+
* (`'text' in part`) rather than on a `kind` tag that no longer exists.
|
|
41
|
+
*/
|
|
27
42
|
export interface A2ATextPart {
|
|
28
|
-
kind: 'text';
|
|
29
43
|
text: string;
|
|
44
|
+
mediaType?: string;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
30
46
|
}
|
|
31
|
-
/** A file reference or inline payload. */
|
|
47
|
+
/** A file reference (`url`) or inline base64 payload (`raw`). */
|
|
32
48
|
export interface A2AFilePart {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
bytes?: string;
|
|
39
|
-
};
|
|
49
|
+
url?: string;
|
|
50
|
+
raw?: string;
|
|
51
|
+
filename?: string;
|
|
52
|
+
mediaType?: string;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
40
54
|
}
|
|
41
55
|
/** Structured JSON carried beside the text. */
|
|
42
56
|
export interface A2ADataPart {
|
|
43
|
-
kind: 'data';
|
|
44
57
|
data: unknown;
|
|
58
|
+
mediaType?: string;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
45
60
|
}
|
|
46
|
-
/** Any message or artifact segment. */
|
|
61
|
+
/** Any message or artifact segment. Exactly one content member is set. */
|
|
47
62
|
export type A2APart = A2ATextPart | A2AFilePart | A2ADataPart;
|
|
48
63
|
/** One message in a task's history. */
|
|
49
64
|
export interface A2AMessage {
|
|
50
|
-
kind: 'message';
|
|
51
65
|
messageId: string;
|
|
52
66
|
role: A2ARole;
|
|
53
67
|
parts: A2APart[];
|
|
54
68
|
taskId?: A2ATaskId;
|
|
55
69
|
contextId?: A2AContextId;
|
|
56
70
|
metadata?: Record<string, unknown>;
|
|
71
|
+
extensions?: string[];
|
|
72
|
+
referenceTaskIds?: string[];
|
|
57
73
|
}
|
|
58
74
|
/** A named output the agent produced for a task. */
|
|
59
75
|
export interface A2AArtifact {
|
|
@@ -62,6 +78,7 @@ export interface A2AArtifact {
|
|
|
62
78
|
description?: string;
|
|
63
79
|
parts: A2APart[];
|
|
64
80
|
metadata?: Record<string, unknown>;
|
|
81
|
+
extensions?: string[];
|
|
65
82
|
}
|
|
66
83
|
/** Current state plus the message that explains it. */
|
|
67
84
|
export interface A2ATaskStatus {
|
|
@@ -71,7 +88,6 @@ export interface A2ATaskStatus {
|
|
|
71
88
|
}
|
|
72
89
|
/** The unit of work a peer submits and polls. */
|
|
73
90
|
export interface A2ATask {
|
|
74
|
-
kind: 'task';
|
|
75
91
|
id: A2ATaskId;
|
|
76
92
|
contextId: A2AContextId;
|
|
77
93
|
status: A2ATaskStatus;
|
|
@@ -79,27 +95,69 @@ export interface A2ATask {
|
|
|
79
95
|
artifacts?: A2AArtifact[];
|
|
80
96
|
metadata?: Record<string, unknown>;
|
|
81
97
|
}
|
|
82
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* A streamed state transition.
|
|
100
|
+
*
|
|
101
|
+
* v1.0 removed the `final` flag: the stream's own closure is what tells a peer
|
|
102
|
+
* the task reached a terminal state, so a server that keeps a stream open after
|
|
103
|
+
* a terminal status is the bug, not a missing boolean.
|
|
104
|
+
*/
|
|
83
105
|
export interface A2ATaskStatusUpdateEvent {
|
|
84
|
-
kind: 'status-update';
|
|
85
106
|
taskId: A2ATaskId;
|
|
86
107
|
contextId: A2AContextId;
|
|
87
108
|
status: A2ATaskStatus;
|
|
88
|
-
final: boolean;
|
|
89
109
|
metadata?: Record<string, unknown>;
|
|
90
110
|
}
|
|
91
111
|
/** A streamed artifact, optionally appended to an earlier chunk. */
|
|
92
112
|
export interface A2ATaskArtifactUpdateEvent {
|
|
93
|
-
kind: 'artifact-update';
|
|
94
113
|
taskId: A2ATaskId;
|
|
95
114
|
contextId: A2AContextId;
|
|
96
115
|
artifact: A2AArtifact;
|
|
116
|
+
/** Position of this artifact in the task's `artifacts` array. */
|
|
117
|
+
index?: number;
|
|
97
118
|
append?: boolean;
|
|
98
119
|
lastChunk?: boolean;
|
|
99
120
|
metadata?: Record<string, unknown>;
|
|
100
121
|
}
|
|
101
|
-
/**
|
|
102
|
-
|
|
122
|
+
/**
|
|
123
|
+
* One frame of a stream, wrapped so the member name identifies the event type.
|
|
124
|
+
*
|
|
125
|
+
* Exactly one member is set. This replaces v0.3's `kind` tag, and it is why
|
|
126
|
+
* the router never writes a bare event onto a stream.
|
|
127
|
+
*/
|
|
128
|
+
export type A2AStreamResponse = {
|
|
129
|
+
task: A2ATask;
|
|
130
|
+
} | {
|
|
131
|
+
message: A2AMessage;
|
|
132
|
+
} | {
|
|
133
|
+
statusUpdate: A2ATaskStatusUpdateEvent;
|
|
134
|
+
} | {
|
|
135
|
+
artifactUpdate: A2ATaskArtifactUpdateEvent;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Wrap a task as the opening frame of a stream.
|
|
139
|
+
* @param task - the task the stream follows.
|
|
140
|
+
* @returns the StreamResponse to serialize.
|
|
141
|
+
*/
|
|
142
|
+
export declare function streamTask(task: A2ATask): A2AStreamResponse;
|
|
143
|
+
/**
|
|
144
|
+
* Wrap a status transition as a stream frame.
|
|
145
|
+
* @param event - the transition.
|
|
146
|
+
* @returns the StreamResponse to serialize.
|
|
147
|
+
*/
|
|
148
|
+
export declare function streamStatusUpdate(event: A2ATaskStatusUpdateEvent): A2AStreamResponse;
|
|
149
|
+
/**
|
|
150
|
+
* Wrap an artifact as a stream frame.
|
|
151
|
+
* @param event - the artifact event.
|
|
152
|
+
* @returns the StreamResponse to serialize.
|
|
153
|
+
*/
|
|
154
|
+
export declare function streamArtifactUpdate(event: A2ATaskArtifactUpdateEvent): A2AStreamResponse;
|
|
155
|
+
/** The result of `SendMessage`: a task to track, or a direct reply. */
|
|
156
|
+
export type A2ASendMessageResponse = {
|
|
157
|
+
task: A2ATask;
|
|
158
|
+
} | {
|
|
159
|
+
message: A2AMessage;
|
|
160
|
+
};
|
|
103
161
|
/** Webhook registration a peer supplies for terminal-state callbacks. */
|
|
104
162
|
export interface A2APushNotificationConfig {
|
|
105
163
|
id?: string;
|
|
@@ -110,19 +168,49 @@ export interface A2APushNotificationConfig {
|
|
|
110
168
|
credentials?: string;
|
|
111
169
|
};
|
|
112
170
|
}
|
|
113
|
-
/**
|
|
114
|
-
export interface
|
|
171
|
+
/** A push configuration bound to a task. Flattened in v1.0. */
|
|
172
|
+
export interface A2ATaskPushNotificationConfig {
|
|
173
|
+
taskId?: string;
|
|
174
|
+
id?: string;
|
|
175
|
+
pushNotificationConfig?: A2APushNotificationConfig;
|
|
176
|
+
}
|
|
177
|
+
/** Per-request knobs carried beside the message on `SendMessage`. */
|
|
178
|
+
export interface A2ASendMessageConfiguration {
|
|
115
179
|
acceptedOutputModes?: string[];
|
|
116
180
|
historyLength?: number;
|
|
117
|
-
|
|
118
|
-
|
|
181
|
+
taskPushNotificationConfig?: A2ATaskPushNotificationConfig;
|
|
182
|
+
/**
|
|
183
|
+
* Whether to answer before the task settles.
|
|
184
|
+
*
|
|
185
|
+
* v1.0 inverted v0.3's `blocking`: operations are BLOCKING by default, and a
|
|
186
|
+
* client opts out. Unset therefore means "wait", not "return now".
|
|
187
|
+
*/
|
|
188
|
+
returnImmediately?: boolean;
|
|
119
189
|
}
|
|
120
|
-
/** Parameters of `
|
|
121
|
-
export interface
|
|
190
|
+
/** Parameters of `SendMessage` and `SendStreamingMessage`. */
|
|
191
|
+
export interface A2ASendMessageRequest {
|
|
122
192
|
message: A2AMessage;
|
|
123
|
-
configuration?:
|
|
193
|
+
configuration?: A2ASendMessageConfiguration;
|
|
124
194
|
metadata?: Record<string, unknown>;
|
|
125
195
|
}
|
|
196
|
+
/** Parameters of `ListTasks`. */
|
|
197
|
+
export interface A2AListTasksParams {
|
|
198
|
+
contextId?: string;
|
|
199
|
+
status?: A2ATaskState;
|
|
200
|
+
pageSize?: number;
|
|
201
|
+
pageToken?: string;
|
|
202
|
+
historyLength?: number;
|
|
203
|
+
statusTimestampAfter?: string;
|
|
204
|
+
includeArtifacts?: boolean;
|
|
205
|
+
}
|
|
206
|
+
/** The result of `ListTasks`. Cursor-paginated, newest first. */
|
|
207
|
+
export interface A2AListTasksResult {
|
|
208
|
+
tasks: A2ATask[];
|
|
209
|
+
/** Empty string, never absent, when this is the last page. */
|
|
210
|
+
nextPageToken: string;
|
|
211
|
+
pageSize: number;
|
|
212
|
+
totalSize: number;
|
|
213
|
+
}
|
|
126
214
|
/** One capability this agent advertises on its card. */
|
|
127
215
|
export interface A2AAgentSkill {
|
|
128
216
|
id: string;
|
|
@@ -133,32 +221,55 @@ export interface A2AAgentSkill {
|
|
|
133
221
|
inputModes?: string[];
|
|
134
222
|
outputModes?: string[];
|
|
135
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* One transport this agent answers on.
|
|
226
|
+
*
|
|
227
|
+
* v1.0 folded `url`, `preferredTransport`, `additionalInterfaces`, and the
|
|
228
|
+
* card-level `protocolVersion` into this one repeated field: a version is a
|
|
229
|
+
* property of an interface, not of an agent.
|
|
230
|
+
*/
|
|
231
|
+
export interface A2AAgentInterface {
|
|
232
|
+
url: string;
|
|
233
|
+
protocolBinding: string;
|
|
234
|
+
protocolVersion: string;
|
|
235
|
+
tenant?: string;
|
|
236
|
+
}
|
|
237
|
+
/** Which schemes a caller must satisfy, and with which scopes. */
|
|
238
|
+
export interface A2ASecurityRequirement {
|
|
239
|
+
schemes: Record<string, {
|
|
240
|
+
list: string[];
|
|
241
|
+
}>;
|
|
242
|
+
}
|
|
243
|
+
/** Optional features a peer may rely on. */
|
|
244
|
+
export interface A2AAgentCapabilities {
|
|
245
|
+
streaming?: boolean;
|
|
246
|
+
pushNotifications?: boolean;
|
|
247
|
+
extensions?: {
|
|
248
|
+
uri: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
required?: boolean;
|
|
251
|
+
}[];
|
|
252
|
+
/** v1.0 home of what v0.3 spelled `supportsAuthenticatedExtendedCard`. */
|
|
253
|
+
extendedAgentCard?: boolean;
|
|
254
|
+
}
|
|
136
255
|
/** The public description a peer fetches before talking to us. */
|
|
137
256
|
export interface A2AAgentCard {
|
|
138
|
-
protocolVersion: string;
|
|
139
257
|
name: string;
|
|
140
258
|
description: string;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
preferredTransport: string;
|
|
144
|
-
supportedInterfaces?: {
|
|
145
|
-
url: string;
|
|
146
|
-
protocolBinding: string;
|
|
147
|
-
protocolVersion: string;
|
|
148
|
-
}[];
|
|
259
|
+
/** Ordered; the first entry is the preferred interface. Required in v1.0. */
|
|
260
|
+
supportedInterfaces: A2AAgentInterface[];
|
|
149
261
|
provider?: {
|
|
150
262
|
organization: string;
|
|
151
263
|
url: string;
|
|
152
264
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
265
|
+
version: string;
|
|
266
|
+
documentationUrl?: string;
|
|
267
|
+
capabilities: A2AAgentCapabilities;
|
|
268
|
+
securitySchemes?: Record<string, unknown>;
|
|
269
|
+
securityRequirements?: A2ASecurityRequirement[];
|
|
158
270
|
defaultInputModes: string[];
|
|
159
271
|
defaultOutputModes: string[];
|
|
160
272
|
skills: A2AAgentSkill[];
|
|
161
|
-
|
|
162
|
-
security?: Record<string, string[]>[];
|
|
273
|
+
iconUrl?: string;
|
|
163
274
|
}
|
|
164
275
|
//# sourceMappingURL=wire.d.ts.map
|