dsh-a2a-server 0.1.0 → 0.2.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 +80 -40
- package/README.zh-CN.md +72 -37
- package/lib/config.d.ts +15 -7
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +6 -1
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +9 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +53 -20
- package/lib/index.js.map +1 -1
- package/lib/projection.d.ts +21 -19
- package/lib/projection.d.ts.map +1 -1
- package/lib/projection.js +15 -7
- 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 +10 -1
- package/lib/router.d.ts.map +1 -1
- package/lib/router.js +247 -107
- package/lib/router.js.map +1 -1
- package/lib/security.d.ts +33 -1
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +44 -2
- package/lib/security.js.map +1 -1
- package/lib/tasks.js +5 -5
- package/lib/tasks.js.map +1 -1
- package/lib/types.d.ts +3 -3
- package/lib/types.js +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/package.json +1 -1
- 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
package/lib/protocol/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The A2A wire protocol as a dependency-free library.
|
|
2
|
+
* The A2A v1.0 wire protocol as a dependency-free library.
|
|
3
3
|
*
|
|
4
4
|
* Nothing here touches Cordis, HTTP, or the harness: it is types, framing,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* inbound parsing, and document construction, so the spec's own JSON examples
|
|
6
|
+
* can be used as golden tests without booting anything.
|
|
7
7
|
*
|
|
8
8
|
* @module dsh-a2a/protocol
|
|
9
9
|
*/
|
|
10
10
|
export { A2AContextId, A2ATaskId } from "./brand.js";
|
|
11
|
-
export { TERMINAL_STATES, isTerminal, } from "./wire.js";
|
|
12
|
-
export { A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_INTERNAL, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, } from "./jsonrpc.js";
|
|
13
|
-
export {
|
|
14
|
-
export { buildAgentCard, FALLBACK_SKILL } from "./card.js";
|
|
11
|
+
export { A2A_PROTOCOL_VERSION, TASK_STATES, TERMINAL_STATES, isTerminal, streamArtifactUpdate, streamStatusUpdate, streamTask, } from "./wire.js";
|
|
12
|
+
export { A2A_ERROR_DOMAIN, A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_EXTENDED_CARD_NOT_CONFIGURED, ERR_EXTENSION_SUPPORT_REQUIRED, ERR_INTERNAL, ERR_INVALID_AGENT_RESPONSE, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, ERR_VERSION_NOT_SUPPORTED, errorDetails, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, unsupportedOperation, versionNotSupported, } from "./jsonrpc.js";
|
|
13
|
+
export { legacyMethodReplacement, parseListTasksParams, parsePart, parseSendMessageRequest, parseTenant, partsToText, resolveMethod, } from "./parse.js";
|
|
14
|
+
export { buildAgentCard, buildExtendedAgentCard, FALLBACK_SKILL } from "./card.js";
|
|
15
15
|
export { sseFrame } from "./sse.js";
|
|
16
|
-
/** ISO 8601 UTC with millisecond precision, the timestamp shape A2A
|
|
16
|
+
/** ISO 8601 UTC with millisecond precision, the timestamp shape A2A v1.0 requires. */
|
|
17
17
|
export function nowIso() {
|
|
18
18
|
return new Date().toISOString();
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EACL,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,WAAW,CAAA;AA6BlB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAC9B,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,sFAAsF;AACtF,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;AACjC,CAAC"}
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* a valid JSON-RPC error envelope, so a client that blindly parses the body
|
|
9
9
|
* and one that reads the status are both served.
|
|
10
10
|
*
|
|
11
|
+
* v1.0 additionally requires that A2A-specific failures carry a machine-
|
|
12
|
+
* readable reason in `error.data`, as a `google.rpc.ErrorInfo` object. That is
|
|
13
|
+
* what {@link A2ARpcError.reason} feeds.
|
|
14
|
+
*
|
|
11
15
|
* @module dsh-a2a/protocol/jsonrpc
|
|
12
16
|
*/
|
|
13
17
|
/** Standard JSON-RPC 2.0 codes. */
|
|
@@ -22,6 +26,12 @@ export declare const ERR_TASK_NOT_CANCELABLE = -32002;
|
|
|
22
26
|
export declare const ERR_PUSH_NOT_SUPPORTED = -32003;
|
|
23
27
|
export declare const ERR_UNSUPPORTED_OPERATION = -32004;
|
|
24
28
|
export declare const ERR_CONTENT_TYPE_NOT_SUPPORTED = -32005;
|
|
29
|
+
export declare const ERR_INVALID_AGENT_RESPONSE = -32006;
|
|
30
|
+
export declare const ERR_EXTENDED_CARD_NOT_CONFIGURED = -32007;
|
|
31
|
+
export declare const ERR_EXTENSION_SUPPORT_REQUIRED = -32008;
|
|
32
|
+
export declare const ERR_VERSION_NOT_SUPPORTED = -32009;
|
|
33
|
+
/** The domain every A2A `ErrorInfo` detail is scoped to. */
|
|
34
|
+
export declare const A2A_ERROR_DOMAIN = "a2a-protocol.org";
|
|
25
35
|
/** A JSON-RPC request as received from a peer. */
|
|
26
36
|
export interface JsonRpcRequest {
|
|
27
37
|
jsonrpc?: string;
|
|
@@ -59,21 +69,46 @@ export declare function jsonRpcResult(id: string | number | null, result: unknow
|
|
|
59
69
|
* @param id - the request id being answered, or null when unknown.
|
|
60
70
|
* @param code - the JSON-RPC or A2A error code.
|
|
61
71
|
* @param message - a human-readable explanation carrying no internal paths.
|
|
62
|
-
* @param data - optional structured detail.
|
|
72
|
+
* @param data - optional structured detail, already in the details-array shape.
|
|
63
73
|
* @returns the response envelope.
|
|
64
74
|
*/
|
|
65
75
|
export declare function jsonRpcError(id: string | number | null, code: number, message: string, data?: unknown): JsonRpcFailure;
|
|
66
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Build the `error.data` details array for an A2A-specific failure.
|
|
78
|
+
*
|
|
79
|
+
* v1.0 models error details on `google.rpc.Status`: an array of typed objects,
|
|
80
|
+
* each naming its type through `@type`. The reason is the UPPER_SNAKE_CASE form
|
|
81
|
+
* of the A2A error name, which is what lets a client branch on the failure
|
|
82
|
+
* without string-matching the human-readable message.
|
|
83
|
+
* @param reason - the A2A error reason, e.g. `TASK_NOT_FOUND`.
|
|
84
|
+
* @param metadata - additional string context, e.g. the offending id.
|
|
85
|
+
* @returns the details array.
|
|
86
|
+
*/
|
|
87
|
+
export declare function errorDetails(reason: string, metadata?: Record<string, string>): unknown[];
|
|
88
|
+
/** An error carrying the JSON-RPC code and A2A reason a handler wants reported. */
|
|
67
89
|
export declare class A2ARpcError extends Error {
|
|
68
90
|
readonly code: number;
|
|
69
|
-
readonly
|
|
91
|
+
readonly options: {
|
|
92
|
+
reason?: string;
|
|
93
|
+
metadata?: Record<string, string>;
|
|
94
|
+
httpStatus?: number;
|
|
95
|
+
};
|
|
70
96
|
/**
|
|
71
97
|
* @param code - the JSON-RPC or A2A error code.
|
|
72
98
|
* @param message - the human-readable explanation.
|
|
73
|
-
* @param
|
|
74
|
-
*
|
|
99
|
+
* @param options - the A2A reason and metadata for `error.data`, plus the
|
|
100
|
+
* HTTP status to answer with; the status defaults to 200 because an ordinary
|
|
101
|
+
* JSON-RPC error is a successful HTTP exchange.
|
|
75
102
|
*/
|
|
76
|
-
constructor(code: number, message: string,
|
|
103
|
+
constructor(code: number, message: string, options?: {
|
|
104
|
+
reason?: string;
|
|
105
|
+
metadata?: Record<string, string>;
|
|
106
|
+
httpStatus?: number;
|
|
107
|
+
});
|
|
108
|
+
/** The HTTP status this failure should be answered with. */
|
|
109
|
+
get httpStatus(): number;
|
|
110
|
+
/** The `error.data` details array, or undefined when no reason is carried. */
|
|
111
|
+
get data(): unknown[] | undefined;
|
|
77
112
|
}
|
|
78
113
|
/**
|
|
79
114
|
* Reject a malformed or unsupported parameter.
|
|
@@ -90,4 +125,17 @@ export declare function invalidParams(detail: string): A2ARpcError;
|
|
|
90
125
|
* @returns the error to throw.
|
|
91
126
|
*/
|
|
92
127
|
export declare function taskNotFound(taskId: string): A2ARpcError;
|
|
128
|
+
/**
|
|
129
|
+
* Report an A2A-Version this interface does not implement.
|
|
130
|
+
* @param requested - the version the peer asked for.
|
|
131
|
+
* @param supported - the version this interface serves.
|
|
132
|
+
* @returns the error to throw.
|
|
133
|
+
*/
|
|
134
|
+
export declare function versionNotSupported(requested: string, supported: string): A2ARpcError;
|
|
135
|
+
/**
|
|
136
|
+
* Report an operation this deployment does not perform.
|
|
137
|
+
* @param detail - what was refused, and why.
|
|
138
|
+
* @returns the error to throw.
|
|
139
|
+
*/
|
|
140
|
+
export declare function unsupportedOperation(detail: string): A2ARpcError;
|
|
93
141
|
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mCAAmC;AACnC,eAAO,MAAM,SAAS,SAAS,CAAA;AAC/B,eAAO,MAAM,mBAAmB,SAAS,CAAA;AACzC,eAAO,MAAM,oBAAoB,SAAS,CAAA;AAC1C,eAAO,MAAM,kBAAkB,SAAS,CAAA;AACxC,eAAO,MAAM,YAAY,SAAS,CAAA;AAElC,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,SAAS,CAAA;AACxC,eAAO,MAAM,uBAAuB,SAAS,CAAA;AAC7C,eAAO,MAAM,sBAAsB,SAAS,CAAA;AAC5C,eAAO,MAAM,yBAAyB,SAAS,CAAA;AAC/C,eAAO,MAAM,8BAA8B,SAAS,CAAA;AACpD,eAAO,MAAM,0BAA0B,SAAS,CAAA;AAChD,eAAO,MAAM,gCAAgC,SAAS,CAAA;AACtD,eAAO,MAAM,8BAA8B,SAAS,CAAA;AACpD,eAAO,MAAM,yBAAyB,SAAS,CAAA;AAE/C,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AAElD,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;I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AA;KACpB;IAdH;;;;;;OAMG;gBAEQ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,OAAO,GAAE;QAChB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,UAAU,CAAC,EAAE,MAAM,CAAA;KACf;IAMR,4DAA4D;IAC5D,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,8EAA8E;IAC9E,IAAI,IAAI,IAAI,OAAO,EAAE,GAAG,SAAS,CAGhC;CACF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAKxD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAMrF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAIhE"}
|
package/lib/protocol/jsonrpc.js
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* a valid JSON-RPC error envelope, so a client that blindly parses the body
|
|
9
9
|
* and one that reads the status are both served.
|
|
10
10
|
*
|
|
11
|
+
* v1.0 additionally requires that A2A-specific failures carry a machine-
|
|
12
|
+
* readable reason in `error.data`, as a `google.rpc.ErrorInfo` object. That is
|
|
13
|
+
* what {@link A2ARpcError.reason} feeds.
|
|
14
|
+
*
|
|
11
15
|
* @module dsh-a2a/protocol/jsonrpc
|
|
12
16
|
*/
|
|
13
17
|
/** Standard JSON-RPC 2.0 codes. */
|
|
@@ -22,6 +26,12 @@ export const ERR_TASK_NOT_CANCELABLE = -32002;
|
|
|
22
26
|
export const ERR_PUSH_NOT_SUPPORTED = -32003;
|
|
23
27
|
export const ERR_UNSUPPORTED_OPERATION = -32004;
|
|
24
28
|
export const ERR_CONTENT_TYPE_NOT_SUPPORTED = -32005;
|
|
29
|
+
export const ERR_INVALID_AGENT_RESPONSE = -32006;
|
|
30
|
+
export const ERR_EXTENDED_CARD_NOT_CONFIGURED = -32007;
|
|
31
|
+
export const ERR_EXTENSION_SUPPORT_REQUIRED = -32008;
|
|
32
|
+
export const ERR_VERSION_NOT_SUPPORTED = -32009;
|
|
33
|
+
/** The domain every A2A `ErrorInfo` detail is scoped to. */
|
|
34
|
+
export const A2A_ERROR_DOMAIN = 'a2a-protocol.org';
|
|
25
35
|
/**
|
|
26
36
|
* Build a success envelope.
|
|
27
37
|
* @param id - the request id being answered.
|
|
@@ -36,28 +46,58 @@ export function jsonRpcResult(id, result) {
|
|
|
36
46
|
* @param id - the request id being answered, or null when unknown.
|
|
37
47
|
* @param code - the JSON-RPC or A2A error code.
|
|
38
48
|
* @param message - a human-readable explanation carrying no internal paths.
|
|
39
|
-
* @param data - optional structured detail.
|
|
49
|
+
* @param data - optional structured detail, already in the details-array shape.
|
|
40
50
|
* @returns the response envelope.
|
|
41
51
|
*/
|
|
42
52
|
export function jsonRpcError(id, code, message, data) {
|
|
43
53
|
return { jsonrpc: '2.0', id, error: { code, message, ...data === undefined ? {} : { data } } };
|
|
44
54
|
}
|
|
45
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Build the `error.data` details array for an A2A-specific failure.
|
|
57
|
+
*
|
|
58
|
+
* v1.0 models error details on `google.rpc.Status`: an array of typed objects,
|
|
59
|
+
* each naming its type through `@type`. The reason is the UPPER_SNAKE_CASE form
|
|
60
|
+
* of the A2A error name, which is what lets a client branch on the failure
|
|
61
|
+
* without string-matching the human-readable message.
|
|
62
|
+
* @param reason - the A2A error reason, e.g. `TASK_NOT_FOUND`.
|
|
63
|
+
* @param metadata - additional string context, e.g. the offending id.
|
|
64
|
+
* @returns the details array.
|
|
65
|
+
*/
|
|
66
|
+
export function errorDetails(reason, metadata) {
|
|
67
|
+
return [{
|
|
68
|
+
'@type': 'type.googleapis.com/google.rpc.ErrorInfo',
|
|
69
|
+
reason,
|
|
70
|
+
domain: A2A_ERROR_DOMAIN,
|
|
71
|
+
...metadata === undefined ? {} : { metadata },
|
|
72
|
+
}];
|
|
73
|
+
}
|
|
74
|
+
/** An error carrying the JSON-RPC code and A2A reason a handler wants reported. */
|
|
46
75
|
export class A2ARpcError extends Error {
|
|
47
76
|
code;
|
|
48
|
-
|
|
77
|
+
options;
|
|
49
78
|
/**
|
|
50
79
|
* @param code - the JSON-RPC or A2A error code.
|
|
51
80
|
* @param message - the human-readable explanation.
|
|
52
|
-
* @param
|
|
53
|
-
*
|
|
81
|
+
* @param options - the A2A reason and metadata for `error.data`, plus the
|
|
82
|
+
* HTTP status to answer with; the status defaults to 200 because an ordinary
|
|
83
|
+
* JSON-RPC error is a successful HTTP exchange.
|
|
54
84
|
*/
|
|
55
|
-
constructor(code, message,
|
|
85
|
+
constructor(code, message, options = {}) {
|
|
56
86
|
super(message);
|
|
57
87
|
this.code = code;
|
|
58
|
-
this.
|
|
88
|
+
this.options = options;
|
|
59
89
|
this.name = 'A2ARpcError';
|
|
60
90
|
}
|
|
91
|
+
/** The HTTP status this failure should be answered with. */
|
|
92
|
+
get httpStatus() {
|
|
93
|
+
return this.options.httpStatus ?? 200;
|
|
94
|
+
}
|
|
95
|
+
/** The `error.data` details array, or undefined when no reason is carried. */
|
|
96
|
+
get data() {
|
|
97
|
+
if (this.options.reason === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
return errorDetails(this.options.reason, this.options.metadata);
|
|
100
|
+
}
|
|
61
101
|
}
|
|
62
102
|
/**
|
|
63
103
|
* Reject a malformed or unsupported parameter.
|
|
@@ -76,6 +116,28 @@ export function invalidParams(detail) {
|
|
|
76
116
|
* @returns the error to throw.
|
|
77
117
|
*/
|
|
78
118
|
export function taskNotFound(taskId) {
|
|
79
|
-
return new A2ARpcError(ERR_TASK_NOT_FOUND, `task not found: ${taskId}
|
|
119
|
+
return new A2ARpcError(ERR_TASK_NOT_FOUND, `task not found: ${taskId}`, {
|
|
120
|
+
reason: 'TASK_NOT_FOUND',
|
|
121
|
+
metadata: { taskId },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Report an A2A-Version this interface does not implement.
|
|
126
|
+
* @param requested - the version the peer asked for.
|
|
127
|
+
* @param supported - the version this interface serves.
|
|
128
|
+
* @returns the error to throw.
|
|
129
|
+
*/
|
|
130
|
+
export function versionNotSupported(requested, supported) {
|
|
131
|
+
return new A2ARpcError(ERR_VERSION_NOT_SUPPORTED, `unsupported A2A-Version: ${requested}; this interface serves ${supported}`, { reason: 'VERSION_NOT_SUPPORTED', metadata: { requested, supported } });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Report an operation this deployment does not perform.
|
|
135
|
+
* @param detail - what was refused, and why.
|
|
136
|
+
* @returns the error to throw.
|
|
137
|
+
*/
|
|
138
|
+
export function unsupportedOperation(detail) {
|
|
139
|
+
return new A2ARpcError(ERR_UNSUPPORTED_OPERATION, detail, {
|
|
140
|
+
reason: 'UNSUPPORTED_OPERATION',
|
|
141
|
+
});
|
|
80
142
|
}
|
|
81
143
|
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,CAAA;AAC/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAA;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK,CAAA;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG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ACzB,4BAA4B,SAAS,2BAA2B,SAAS,EAAE,EAC3E,EAAE,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CACxE,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,IAAI,WAAW,CAAC,yBAAyB,EAAE,MAAM,EAAE;QACxD,MAAM,EAAE,uBAAuB;KAChC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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 type { A2AListTasksParams, A2APart, A2ASendMessageRequest } from './wire.ts';
|
|
17
|
+
/** The internal operation a peer's method name resolves to. */
|
|
18
|
+
export type A2AOperation = 'send' | 'stream' | 'get' | 'list' | 'cancel' | 'subscribe' | 'push_create' | 'push_get' | 'push_list' | 'push_delete' | 'extended_card';
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a method name to its operation.
|
|
21
|
+
* @param method - the raw `method` string from the request.
|
|
22
|
+
* @returns the operation, or undefined for an unknown method.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveMethod(method: string): A2AOperation | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The v1.0 name that replaced a retired v0.3 method.
|
|
27
|
+
* @param method - the raw `method` string from the request.
|
|
28
|
+
* @returns the replacement name, or undefined when the method was never ours.
|
|
29
|
+
*/
|
|
30
|
+
export declare function legacyMethodReplacement(method: string): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Read one `Part`.
|
|
33
|
+
*
|
|
34
|
+
* v1.0 discriminates on which content member is present, so the probes below
|
|
35
|
+
* must each be specific enough not to claim another variant's shape. An
|
|
36
|
+
* unrecognizable part yields undefined rather than throwing: one odd part must
|
|
37
|
+
* not fail a request whose other parts are usable.
|
|
38
|
+
* @param raw - one element of a `parts` array.
|
|
39
|
+
* @returns the normalized part, or undefined when no content member is present.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parsePart(raw: unknown): A2APart | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Render every part as text the model can read.
|
|
44
|
+
*
|
|
45
|
+
* File and data parts become bracketed references rather than being dropped, so
|
|
46
|
+
* the agent knows something was attached and can ask about it. This is the same
|
|
47
|
+
* flattening `dsh-acp` applies to baseline resource links.
|
|
48
|
+
* @param parts - normalized parts, in order.
|
|
49
|
+
* @returns the joined text, empty when nothing rendered.
|
|
50
|
+
*/
|
|
51
|
+
export declare function partsToText(parts: readonly A2APart[]): string;
|
|
52
|
+
/**
|
|
53
|
+
* Parse the `SendMessage` / `SendStreamingMessage` request object.
|
|
54
|
+
* @param raw - the request's `params` value.
|
|
55
|
+
* @returns the normalized request, or undefined when the shape is unusable.
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseSendMessageRequest(raw: unknown): A2ASendMessageRequest | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Parse `ListTasks` parameters.
|
|
60
|
+
*
|
|
61
|
+
* Every filter is optional; an absent `params` lists everything the caller may
|
|
62
|
+
* see. `pageSize` is clamped to the spec's 1..100 window rather than rejected,
|
|
63
|
+
* because a client asking for 500 wants "as many as you'll give me".
|
|
64
|
+
* @param raw - the request's `params` value.
|
|
65
|
+
* @returns the normalized filters.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseListTasksParams(raw: unknown): A2AListTasksParams;
|
|
68
|
+
/**
|
|
69
|
+
* Read the `tenant` routing member.
|
|
70
|
+
*
|
|
71
|
+
* This card declares no tenant on its interface, so the spec's rule ("clients
|
|
72
|
+
* MUST include this value ... omit the field if tenant is not set") makes any
|
|
73
|
+
* non-empty tenant a misrouted request. Reporting it beats silently serving a
|
|
74
|
+
* peer that believes it reached a different agent.
|
|
75
|
+
* @param raw - the request's `params` value.
|
|
76
|
+
* @returns the tenant a peer asked for, or undefined when correctly omitted.
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseTenant(raw: unknown): string | undefined;
|
|
79
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/protocol/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAElB,OAAO,EAEP,qBAAqB,EAEtB,MAAM,WAAW,CAAA;AAElB,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,KAAK,GACL,MAAM,GACN,QAAQ,GACR,WAAW,GACX,aAAa,GACb,UAAU,GACV,WAAW,GACX,aAAa,GACb,eAAe,CAAA;AA4CnB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAmB3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAc7D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,GAAG,SAAS,CAqCvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CA4BrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D"}
|
|
@@ -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,EAAE,QAAQ,CAAC;IAClC,CAAC,SAAS,EAAE,KAAK,CAAC;IAClB,CAAC,WAAW,EAAE,MAAM,CAAC;IACrB,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,iBAAiB,EAAE,WAAW,CAAC;IAChC,CAAC,kCAAkC,EAAE,aAAa,CAAC;IACnD,CAAC,+BAA+B,EAAE,UAAU,CAAC;IAC7C,CAAC,iCAAiC,EAAE,WAAW,CAAC;IAChD,CAAC,kCAAkC,EAAE,aAAa,CAAC;IACnD,CAAC,sBAAsB,EAAE,eAAe,CAAC;CAC1C,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,cAAc,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,cAAc,EAAE,aAAa,CAAC;IAC/B,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;IAC1C,CAAC,WAAW,EAAE,SAAS,CAAC;IACxB,CAAC,cAAc,EAAE,YAAY,CAAC;IAC9B,CAAC,mBAAmB,EAAE,iBAAiB,C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;KACP,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAG,MAAiB;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAA;IACjE,CAAC;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
|