@cleocode/lafs 2026.4.0 → 2026.4.3
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 +97 -68
- package/dist/src/a2a/bindings/grpc.d.ts +117 -11
- package/dist/src/a2a/bindings/grpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/grpc.js +79 -8
- package/dist/src/a2a/bindings/grpc.js.map +1 -1
- package/dist/src/a2a/bindings/http.d.ts +129 -14
- package/dist/src/a2a/bindings/http.d.ts.map +1 -1
- package/dist/src/a2a/bindings/http.js +93 -12
- package/dist/src/a2a/bindings/http.js.map +1 -1
- package/dist/src/a2a/bindings/index.d.ts +80 -7
- package/dist/src/a2a/bindings/index.d.ts.map +1 -1
- package/dist/src/a2a/bindings/index.js +69 -2
- package/dist/src/a2a/bindings/index.js.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.d.ts +193 -9
- package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.js +152 -9
- package/dist/src/a2a/bindings/jsonrpc.js.map +1 -1
- package/dist/src/a2a/bridge.d.ts +232 -37
- package/dist/src/a2a/bridge.d.ts.map +1 -1
- package/dist/src/a2a/bridge.js +172 -24
- package/dist/src/a2a/bridge.js.map +1 -1
- package/dist/src/a2a/extensions.d.ts +221 -12
- package/dist/src/a2a/extensions.d.ts.map +1 -1
- package/dist/src/a2a/extensions.js +175 -11
- package/dist/src/a2a/extensions.js.map +1 -1
- package/dist/src/a2a/index.d.ts +2 -0
- package/dist/src/a2a/index.d.ts.map +1 -1
- package/dist/src/a2a/index.js +2 -0
- package/dist/src/a2a/index.js.map +1 -1
- package/dist/src/a2a/streaming.d.ts +274 -2
- package/dist/src/a2a/streaming.d.ts.map +1 -1
- package/dist/src/a2a/streaming.js +245 -2
- package/dist/src/a2a/streaming.js.map +1 -1
- package/dist/src/a2a/task-lifecycle.d.ts +339 -19
- package/dist/src/a2a/task-lifecycle.d.ts.map +1 -1
- package/dist/src/a2a/task-lifecycle.js +302 -19
- package/dist/src/a2a/task-lifecycle.js.map +1 -1
- package/dist/src/budgetEnforcement.d.ts +88 -14
- package/dist/src/budgetEnforcement.d.ts.map +1 -1
- package/dist/src/budgetEnforcement.js +132 -19
- package/dist/src/budgetEnforcement.js.map +1 -1
- package/dist/src/circuit-breaker/index.d.ts +254 -9
- package/dist/src/circuit-breaker/index.d.ts.map +1 -1
- package/dist/src/circuit-breaker/index.js +218 -9
- package/dist/src/circuit-breaker/index.js.map +1 -1
- package/dist/src/compliance.d.ts +176 -0
- package/dist/src/compliance.d.ts.map +1 -1
- package/dist/src/compliance.js +100 -0
- package/dist/src/compliance.js.map +1 -1
- package/dist/src/conformance.d.ts +52 -0
- package/dist/src/conformance.d.ts.map +1 -1
- package/dist/src/conformance.js +41 -0
- package/dist/src/conformance.js.map +1 -1
- package/dist/src/conformanceProfiles.d.ts +66 -0
- package/dist/src/conformanceProfiles.d.ts.map +1 -1
- package/dist/src/conformanceProfiles.js +51 -0
- package/dist/src/conformanceProfiles.js.map +1 -1
- package/dist/src/deprecationRegistry.d.ts +80 -0
- package/dist/src/deprecationRegistry.d.ts.map +1 -1
- package/dist/src/deprecationRegistry.js +50 -0
- package/dist/src/deprecationRegistry.js.map +1 -1
- package/dist/src/discovery.d.ts +344 -63
- package/dist/src/discovery.d.ts.map +1 -1
- package/dist/src/discovery.js +67 -13
- package/dist/src/discovery.js.map +1 -1
- package/dist/src/envelope.d.ts +252 -0
- package/dist/src/envelope.d.ts.map +1 -1
- package/dist/src/envelope.js +165 -0
- package/dist/src/envelope.js.map +1 -1
- package/dist/src/errorRegistry.d.ts +159 -0
- package/dist/src/errorRegistry.d.ts.map +1 -1
- package/dist/src/errorRegistry.js +115 -0
- package/dist/src/errorRegistry.js.map +1 -1
- package/dist/src/fieldExtraction.d.ts +125 -25
- package/dist/src/fieldExtraction.d.ts.map +1 -1
- package/dist/src/fieldExtraction.js +85 -16
- package/dist/src/fieldExtraction.js.map +1 -1
- package/dist/src/flagResolver.d.ts +75 -9
- package/dist/src/flagResolver.d.ts.map +1 -1
- package/dist/src/flagResolver.js +20 -4
- package/dist/src/flagResolver.js.map +1 -1
- package/dist/src/flagSemantics.d.ts +76 -1
- package/dist/src/flagSemantics.d.ts.map +1 -1
- package/dist/src/flagSemantics.js +66 -0
- package/dist/src/flagSemantics.js.map +1 -1
- package/dist/src/health/index.d.ts +87 -6
- package/dist/src/health/index.d.ts.map +1 -1
- package/dist/src/health/index.js +54 -6
- package/dist/src/health/index.js.map +1 -1
- package/dist/src/index.d.ts +12 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mviProjection.d.ts +42 -6
- package/dist/src/mviProjection.d.ts.map +1 -1
- package/dist/src/mviProjection.js +31 -5
- package/dist/src/mviProjection.js.map +1 -1
- package/dist/src/native-loader.d.ts +49 -0
- package/dist/src/native-loader.d.ts.map +1 -0
- package/dist/src/native-loader.js +56 -0
- package/dist/src/native-loader.js.map +1 -0
- package/dist/src/problemDetails.d.ts +70 -4
- package/dist/src/problemDetails.d.ts.map +1 -1
- package/dist/src/problemDetails.js +21 -3
- package/dist/src/problemDetails.js.map +1 -1
- package/dist/src/shutdown/index.d.ts +96 -7
- package/dist/src/shutdown/index.d.ts.map +1 -1
- package/dist/src/shutdown/index.js +72 -7
- package/dist/src/shutdown/index.js.map +1 -1
- package/dist/src/tokenEstimator.d.ts +97 -11
- package/dist/src/tokenEstimator.d.ts.map +1 -1
- package/dist/src/tokenEstimator.js +90 -11
- package/dist/src/tokenEstimator.js.map +1 -1
- package/dist/src/types.d.ts +467 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +64 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/validateEnvelope.d.ts +59 -1
- package/dist/src/validateEnvelope.d.ts.map +1 -1
- package/dist/src/validateEnvelope.js +75 -9
- package/dist/src/validateEnvelope.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/lafs.md +3 -4
- package/package.json +6 -3
- package/dist/src/mcpAdapter.d.ts +0 -29
- package/dist/src/mcpAdapter.d.ts.map +0 -1
- package/dist/src/mcpAdapter.js +0 -286
- package/dist/src/mcpAdapter.js.map +0 -1
- package/schemas/v1/conformance-profiles.d.ts +0 -15
- package/schemas/v1/envelope.schema.d.ts +0 -14
- package/schemas/v1/error-registry.d.ts +0 -24
|
@@ -6,98 +6,213 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { LAFSError } from '../../types.js';
|
|
8
8
|
import type { A2AErrorType } from './jsonrpc.js';
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* HTTP+JSON endpoint definitions for each A2A operation.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Each entry specifies the HTTP method and path template per A2A spec Section 11.3.
|
|
14
|
+
* Path parameters are prefixed with `:` (e.g. `:id`).
|
|
15
|
+
*/
|
|
10
16
|
export declare const HTTP_ENDPOINTS: {
|
|
17
|
+
/** Send a single message to an agent */
|
|
11
18
|
readonly SendMessage: {
|
|
12
19
|
readonly method: "POST";
|
|
13
20
|
readonly path: "/message:send";
|
|
14
21
|
};
|
|
22
|
+
/** Send a streaming message to an agent */
|
|
15
23
|
readonly SendStreamingMessage: {
|
|
16
24
|
readonly method: "POST";
|
|
17
25
|
readonly path: "/message:stream";
|
|
18
26
|
};
|
|
27
|
+
/** Retrieve a task by identifier */
|
|
19
28
|
readonly GetTask: {
|
|
20
29
|
readonly method: "GET";
|
|
21
30
|
readonly path: "/tasks/:id";
|
|
22
31
|
};
|
|
32
|
+
/** List tasks matching query criteria */
|
|
23
33
|
readonly ListTasks: {
|
|
24
34
|
readonly method: "GET";
|
|
25
35
|
readonly path: "/tasks";
|
|
26
36
|
};
|
|
37
|
+
/** Cancel a running task */
|
|
27
38
|
readonly CancelTask: {
|
|
28
39
|
readonly method: "POST";
|
|
29
40
|
readonly path: "/tasks/:id:cancel";
|
|
30
41
|
};
|
|
42
|
+
/** Subscribe to task events via SSE */
|
|
31
43
|
readonly SubscribeToTask: {
|
|
32
44
|
readonly method: "GET";
|
|
33
45
|
readonly path: "/tasks/:id:subscribe";
|
|
34
46
|
};
|
|
47
|
+
/** Set push notification configuration for a task */
|
|
35
48
|
readonly SetTaskPushNotificationConfig: {
|
|
36
49
|
readonly method: "POST";
|
|
37
50
|
readonly path: "/tasks/:id/pushNotificationConfig";
|
|
38
51
|
};
|
|
52
|
+
/** Get push notification configuration for a task */
|
|
39
53
|
readonly GetTaskPushNotificationConfig: {
|
|
40
54
|
readonly method: "GET";
|
|
41
55
|
readonly path: "/tasks/:id/pushNotificationConfig";
|
|
42
56
|
};
|
|
57
|
+
/** List push notification configurations for a task */
|
|
43
58
|
readonly ListTaskPushNotificationConfig: {
|
|
44
59
|
readonly method: "GET";
|
|
45
60
|
readonly path: "/tasks/:id/pushNotificationConfig:list";
|
|
46
61
|
};
|
|
62
|
+
/** Delete push notification configuration for a task */
|
|
47
63
|
readonly DeleteTaskPushNotificationConfig: {
|
|
48
64
|
readonly method: "DELETE";
|
|
49
65
|
readonly path: "/tasks/:id/pushNotificationConfig/:configId";
|
|
50
66
|
};
|
|
67
|
+
/** Retrieve the authenticated extended agent card */
|
|
51
68
|
readonly GetExtendedAgentCard: {
|
|
52
69
|
readonly method: "GET";
|
|
53
70
|
readonly path: "/agent/authenticatedExtendedCard";
|
|
54
71
|
};
|
|
55
72
|
};
|
|
73
|
+
/** Union of all HTTP endpoint descriptor objects from {@link HTTP_ENDPOINTS} */
|
|
56
74
|
export type HttpEndpoint = (typeof HTTP_ENDPOINTS)[keyof typeof HTTP_ENDPOINTS];
|
|
57
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Maps A2A error types to HTTP status codes.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Used by the HTTP binding to determine the appropriate response status
|
|
80
|
+
* code for each A2A error type per spec Section 5.4.
|
|
81
|
+
*/
|
|
58
82
|
export declare const A2A_HTTP_STATUS_CODES: Record<A2AErrorType, number>;
|
|
59
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* RFC 9457 Problem Details type URIs for A2A errors.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* Each URI uniquely identifies an A2A error type and is used as the
|
|
88
|
+
* `type` field in RFC 9457 Problem Details responses.
|
|
89
|
+
*/
|
|
60
90
|
export declare const A2A_ERROR_TYPE_URIS: Record<A2AErrorType, string>;
|
|
61
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* RFC 9457 Problem Details object.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* Represents a machine-readable error response per RFC 9457. The index
|
|
96
|
+
* signature allows arbitrary extension members alongside the required fields.
|
|
97
|
+
*/
|
|
62
98
|
export interface ProblemDetails {
|
|
99
|
+
/** URI reference identifying the problem type */
|
|
63
100
|
type: string;
|
|
101
|
+
/** Short human-readable summary of the problem */
|
|
64
102
|
title: string;
|
|
103
|
+
/** HTTP status code for this occurrence */
|
|
65
104
|
status: number;
|
|
105
|
+
/** Human-readable explanation specific to this occurrence */
|
|
66
106
|
detail: string;
|
|
107
|
+
/** Extension members (arbitrary key-value pairs) */
|
|
67
108
|
[key: string]: unknown;
|
|
68
109
|
}
|
|
69
110
|
/**
|
|
70
111
|
* Create an RFC 9457 Problem Details object for an A2A error.
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
73
|
-
*
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Resolves the `type` URI, `title`, and `status` automatically from
|
|
115
|
+
* the A2A error type. The title is derived by converting the PascalCase
|
|
116
|
+
* error type name to title case.
|
|
117
|
+
*
|
|
118
|
+
* @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
|
|
119
|
+
* @param detail - Human-readable explanation specific to this occurrence
|
|
120
|
+
* @param extensions - Optional additional members to include in the response
|
|
121
|
+
* @returns A fully formed {@link ProblemDetails} object
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const problem = createProblemDetails('TaskNotFound', 'No task with id xyz');
|
|
126
|
+
* // { type: 'https://a2a-protocol.org/errors/task-not-found', title: 'Task Not Found', status: 404, detail: '...' }
|
|
127
|
+
* ```
|
|
74
128
|
*/
|
|
75
129
|
export declare function createProblemDetails(errorType: A2AErrorType, detail: string, extensions?: Record<string, unknown>): ProblemDetails;
|
|
76
130
|
/**
|
|
77
131
|
* Create an RFC 9457 Problem Details object bridging A2A error types with LAFS error data.
|
|
78
|
-
* Includes LAFS agent-actionable extension fields from the LAFSError.
|
|
79
132
|
*
|
|
80
|
-
* @
|
|
133
|
+
* @remarks
|
|
134
|
+
* Extends the base Problem Details with LAFS agent-actionable fields such as
|
|
135
|
+
* `retryable`, `agentAction`, `retryAfterMs`, `escalationRequired`,
|
|
136
|
+
* `suggestedAction`, and `docUrl` extracted from the provided LAFSError.
|
|
137
|
+
*
|
|
138
|
+
* @param errorType - The A2A error type name (e.g. `"InvalidAgentResponse"`)
|
|
81
139
|
* @param lafsError - The LAFS error object to extract extension fields from
|
|
82
|
-
* @param requestId - Optional request identifier
|
|
140
|
+
* @param requestId - Optional request identifier used as the `instance` field
|
|
141
|
+
* @returns A {@link ProblemDetails} object with LAFS extension fields
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const problem = createLafsProblemDetails('InvalidAgentResponse', {
|
|
146
|
+
* code: 'E_AGENT_RESPONSE',
|
|
147
|
+
* message: 'Upstream agent returned invalid JSON',
|
|
148
|
+
* retryable: true,
|
|
149
|
+
* retryAfterMs: 5000,
|
|
150
|
+
* }, 'req-123');
|
|
151
|
+
* ```
|
|
83
152
|
*/
|
|
84
153
|
export declare function createLafsProblemDetails(errorType: A2AErrorType, lafsError: LAFSError, requestId?: string): ProblemDetails;
|
|
85
154
|
/**
|
|
86
155
|
* Build a URL by substituting path parameters.
|
|
87
|
-
*
|
|
88
|
-
* @
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* Replaces `:param` placeholders in the endpoint path template with
|
|
159
|
+
* URI-encoded values from the `params` object.
|
|
160
|
+
*
|
|
161
|
+
* @param endpoint - HTTP endpoint definition from {@link HTTP_ENDPOINTS}
|
|
162
|
+
* @param params - Path parameter values keyed by name (without leading colon)
|
|
163
|
+
* @returns The resolved URL path string with parameters substituted
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const url = buildUrl(HTTP_ENDPOINTS.GetTask, { id: 'task-42' });
|
|
168
|
+
* // '/tasks/task-42'
|
|
169
|
+
* ```
|
|
89
170
|
*/
|
|
90
171
|
export declare function buildUrl(endpoint: HttpEndpoint, params?: Record<string, string>): string;
|
|
91
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Parsed query parameters for the ListTasks endpoint.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* Represents the camelCase query parameters defined in A2A spec Section 11.5.
|
|
177
|
+
* All fields are optional for flexible filtering.
|
|
178
|
+
*/
|
|
92
179
|
export interface ListTasksQueryParams {
|
|
180
|
+
/**
|
|
181
|
+
* Filter tasks by context identifier.
|
|
182
|
+
* @defaultValue undefined
|
|
183
|
+
*/
|
|
93
184
|
contextId?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Filter tasks by state (e.g. `"submitted"`, `"working"`).
|
|
187
|
+
* @defaultValue undefined
|
|
188
|
+
*/
|
|
94
189
|
state?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Maximum number of tasks to return.
|
|
192
|
+
* @defaultValue undefined
|
|
193
|
+
*/
|
|
95
194
|
limit?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Pagination token from a previous response.
|
|
197
|
+
* @defaultValue undefined
|
|
198
|
+
*/
|
|
96
199
|
pageToken?: string;
|
|
97
200
|
}
|
|
98
201
|
/**
|
|
99
202
|
* Parse camelCase query parameters for the ListTasks endpoint.
|
|
100
|
-
*
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
* Handles type coercion for numeric fields (e.g. `limit` is parsed from
|
|
206
|
+
* string to integer). Undefined values are preserved as-is.
|
|
207
|
+
*
|
|
208
|
+
* @param query - Raw query parameter map from the HTTP request
|
|
209
|
+
* @returns A typed {@link ListTasksQueryParams} object with coerced values
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const params = parseListTasksQuery({ contextId: 'ctx-1', limit: '10' });
|
|
214
|
+
* // { contextId: 'ctx-1', limit: 10 }
|
|
215
|
+
* ```
|
|
101
216
|
*/
|
|
102
217
|
export declare function parseListTasksQuery(query: Record<string, string | undefined>): ListTasksQueryParams;
|
|
103
218
|
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/a2a/bindings/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/a2a/bindings/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB,wCAAwC;;;;;IAExC,2CAA2C;;;;;IAE3C,oCAAoC;;;;;IAEpC,yCAAyC;;;;;IAEzC,4BAA4B;;;;;IAE5B,uCAAuC;;;;;IAEvC,qDAAqD;;;;;IAErD,qDAAqD;;;;;IAErD,uDAAuD;;;;;IAEvD,wDAAwD;;;;;IAKxD,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CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACxC,oBAAoB,CAOtB"}
|
|
@@ -7,27 +7,50 @@
|
|
|
7
7
|
// ============================================================================
|
|
8
8
|
// Endpoint Constants (spec Section 11.3)
|
|
9
9
|
// ============================================================================
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* HTTP+JSON endpoint definitions for each A2A operation.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Each entry specifies the HTTP method and path template per A2A spec Section 11.3.
|
|
15
|
+
* Path parameters are prefixed with `:` (e.g. `:id`).
|
|
16
|
+
*/
|
|
11
17
|
export const HTTP_ENDPOINTS = {
|
|
18
|
+
/** Send a single message to an agent */
|
|
12
19
|
SendMessage: { method: 'POST', path: '/message:send' },
|
|
20
|
+
/** Send a streaming message to an agent */
|
|
13
21
|
SendStreamingMessage: { method: 'POST', path: '/message:stream' },
|
|
22
|
+
/** Retrieve a task by identifier */
|
|
14
23
|
GetTask: { method: 'GET', path: '/tasks/:id' },
|
|
24
|
+
/** List tasks matching query criteria */
|
|
15
25
|
ListTasks: { method: 'GET', path: '/tasks' },
|
|
26
|
+
/** Cancel a running task */
|
|
16
27
|
CancelTask: { method: 'POST', path: '/tasks/:id:cancel' },
|
|
28
|
+
/** Subscribe to task events via SSE */
|
|
17
29
|
SubscribeToTask: { method: 'GET', path: '/tasks/:id:subscribe' },
|
|
30
|
+
/** Set push notification configuration for a task */
|
|
18
31
|
SetTaskPushNotificationConfig: { method: 'POST', path: '/tasks/:id/pushNotificationConfig' },
|
|
32
|
+
/** Get push notification configuration for a task */
|
|
19
33
|
GetTaskPushNotificationConfig: { method: 'GET', path: '/tasks/:id/pushNotificationConfig' },
|
|
34
|
+
/** List push notification configurations for a task */
|
|
20
35
|
ListTaskPushNotificationConfig: { method: 'GET', path: '/tasks/:id/pushNotificationConfig:list' },
|
|
36
|
+
/** Delete push notification configuration for a task */
|
|
21
37
|
DeleteTaskPushNotificationConfig: {
|
|
22
38
|
method: 'DELETE',
|
|
23
39
|
path: '/tasks/:id/pushNotificationConfig/:configId',
|
|
24
40
|
},
|
|
41
|
+
/** Retrieve the authenticated extended agent card */
|
|
25
42
|
GetExtendedAgentCard: { method: 'GET', path: '/agent/authenticatedExtendedCard' },
|
|
26
43
|
};
|
|
27
44
|
// ============================================================================
|
|
28
45
|
// HTTP Status Codes (spec Section 5.4)
|
|
29
46
|
// ============================================================================
|
|
30
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Maps A2A error types to HTTP status codes.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Used by the HTTP binding to determine the appropriate response status
|
|
52
|
+
* code for each A2A error type per spec Section 5.4.
|
|
53
|
+
*/
|
|
31
54
|
export const A2A_HTTP_STATUS_CODES = {
|
|
32
55
|
TaskNotFound: 404,
|
|
33
56
|
TaskNotCancelable: 409,
|
|
@@ -42,7 +65,13 @@ export const A2A_HTTP_STATUS_CODES = {
|
|
|
42
65
|
// ============================================================================
|
|
43
66
|
// Error Type URIs (spec Section 5.4)
|
|
44
67
|
// ============================================================================
|
|
45
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* RFC 9457 Problem Details type URIs for A2A errors.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Each URI uniquely identifies an A2A error type and is used as the
|
|
73
|
+
* `type` field in RFC 9457 Problem Details responses.
|
|
74
|
+
*/
|
|
46
75
|
export const A2A_ERROR_TYPE_URIS = {
|
|
47
76
|
TaskNotFound: 'https://a2a-protocol.org/errors/task-not-found',
|
|
48
77
|
TaskNotCancelable: 'https://a2a-protocol.org/errors/task-not-cancelable',
|
|
@@ -56,9 +85,22 @@ export const A2A_ERROR_TYPE_URIS = {
|
|
|
56
85
|
};
|
|
57
86
|
/**
|
|
58
87
|
* Create an RFC 9457 Problem Details object for an A2A error.
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
*
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* Resolves the `type` URI, `title`, and `status` automatically from
|
|
91
|
+
* the A2A error type. The title is derived by converting the PascalCase
|
|
92
|
+
* error type name to title case.
|
|
93
|
+
*
|
|
94
|
+
* @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
|
|
95
|
+
* @param detail - Human-readable explanation specific to this occurrence
|
|
96
|
+
* @param extensions - Optional additional members to include in the response
|
|
97
|
+
* @returns A fully formed {@link ProblemDetails} object
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const problem = createProblemDetails('TaskNotFound', 'No task with id xyz');
|
|
102
|
+
* // { type: 'https://a2a-protocol.org/errors/task-not-found', title: 'Task Not Found', status: 404, detail: '...' }
|
|
103
|
+
* ```
|
|
62
104
|
*/
|
|
63
105
|
export function createProblemDetails(errorType, detail, extensions) {
|
|
64
106
|
// Convert PascalCase to Title Case: "TaskNotFound" -> "Task Not Found"
|
|
@@ -73,11 +115,26 @@ export function createProblemDetails(errorType, detail, extensions) {
|
|
|
73
115
|
}
|
|
74
116
|
/**
|
|
75
117
|
* Create an RFC 9457 Problem Details object bridging A2A error types with LAFS error data.
|
|
76
|
-
* Includes LAFS agent-actionable extension fields from the LAFSError.
|
|
77
118
|
*
|
|
78
|
-
* @
|
|
119
|
+
* @remarks
|
|
120
|
+
* Extends the base Problem Details with LAFS agent-actionable fields such as
|
|
121
|
+
* `retryable`, `agentAction`, `retryAfterMs`, `escalationRequired`,
|
|
122
|
+
* `suggestedAction`, and `docUrl` extracted from the provided LAFSError.
|
|
123
|
+
*
|
|
124
|
+
* @param errorType - The A2A error type name (e.g. `"InvalidAgentResponse"`)
|
|
79
125
|
* @param lafsError - The LAFS error object to extract extension fields from
|
|
80
|
-
* @param requestId - Optional request identifier
|
|
126
|
+
* @param requestId - Optional request identifier used as the `instance` field
|
|
127
|
+
* @returns A {@link ProblemDetails} object with LAFS extension fields
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const problem = createLafsProblemDetails('InvalidAgentResponse', {
|
|
132
|
+
* code: 'E_AGENT_RESPONSE',
|
|
133
|
+
* message: 'Upstream agent returned invalid JSON',
|
|
134
|
+
* retryable: true,
|
|
135
|
+
* retryAfterMs: 5000,
|
|
136
|
+
* }, 'req-123');
|
|
137
|
+
* ```
|
|
81
138
|
*/
|
|
82
139
|
export function createLafsProblemDetails(errorType, lafsError, requestId) {
|
|
83
140
|
const base = createProblemDetails(errorType, lafsError.message);
|
|
@@ -99,8 +156,20 @@ export function createLafsProblemDetails(errorType, lafsError, requestId) {
|
|
|
99
156
|
// ============================================================================
|
|
100
157
|
/**
|
|
101
158
|
* Build a URL by substituting path parameters.
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* Replaces `:param` placeholders in the endpoint path template with
|
|
162
|
+
* URI-encoded values from the `params` object.
|
|
163
|
+
*
|
|
164
|
+
* @param endpoint - HTTP endpoint definition from {@link HTTP_ENDPOINTS}
|
|
165
|
+
* @param params - Path parameter values keyed by name (without leading colon)
|
|
166
|
+
* @returns The resolved URL path string with parameters substituted
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const url = buildUrl(HTTP_ENDPOINTS.GetTask, { id: 'task-42' });
|
|
171
|
+
* // '/tasks/task-42'
|
|
172
|
+
* ```
|
|
104
173
|
*/
|
|
105
174
|
export function buildUrl(endpoint, params) {
|
|
106
175
|
let path = endpoint.path;
|
|
@@ -113,7 +182,19 @@ export function buildUrl(endpoint, params) {
|
|
|
113
182
|
}
|
|
114
183
|
/**
|
|
115
184
|
* Parse camelCase query parameters for the ListTasks endpoint.
|
|
116
|
-
*
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* Handles type coercion for numeric fields (e.g. `limit` is parsed from
|
|
188
|
+
* string to integer). Undefined values are preserved as-is.
|
|
189
|
+
*
|
|
190
|
+
* @param query - Raw query parameter map from the HTTP request
|
|
191
|
+
* @returns A typed {@link ListTasksQueryParams} object with coerced values
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const params = parseListTasksQuery({ contextId: 'ctx-1', limit: '10' });
|
|
196
|
+
* // { contextId: 'ctx-1', limit: 10 }
|
|
197
|
+
* ```
|
|
117
198
|
*/
|
|
118
199
|
export function parseListTasksQuery(query) {
|
|
119
200
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/a2a/bindings/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/a2a/bindings/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,wCAAwC;IACxC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;IACtD,2CAA2C;IAC3C,oBAAoB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACjE,oCAAoC;IACpC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE;IAC9C,yCAAyC;IACzC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5C,4BAA4B;IAC5B,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eAAe,EAAE,CAAC;QACxF,GAAG,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAsB,EAAE,MAA+B;IAC9E,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAc,CAAC;IACnC,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAoCD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAyC;IAEzC,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;QAC7B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QAChE,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -3,34 +3,107 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Re-exports all binding modules and provides cross-binding
|
|
5
5
|
* error code mapping for consistent error handling across transports.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
6
8
|
*/
|
|
7
9
|
export * from './grpc.js';
|
|
8
10
|
export * from './http.js';
|
|
9
11
|
export * from './jsonrpc.js';
|
|
10
12
|
import { type A2AErrorType } from './jsonrpc.js';
|
|
11
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Complete error code mapping across all three transports.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Provides a unified view of how a single A2A error type maps to
|
|
18
|
+
* JSON-RPC, HTTP, and gRPC error representations.
|
|
19
|
+
*/
|
|
12
20
|
export interface ErrorCodeMapping {
|
|
13
|
-
/** JSON-RPC numeric error code */
|
|
21
|
+
/** JSON-RPC numeric error code (e.g. `-32001`) */
|
|
14
22
|
jsonRpcCode: number;
|
|
15
|
-
/** HTTP response status code */
|
|
23
|
+
/** HTTP response status code (e.g. `404`) */
|
|
16
24
|
httpStatus: number;
|
|
17
25
|
/** RFC 9457 Problem Details type URI */
|
|
18
26
|
httpTypeUri: string;
|
|
19
|
-
/** gRPC status name (e.g. NOT_FOUND) */
|
|
27
|
+
/** gRPC status name (e.g. `"NOT_FOUND"`) */
|
|
20
28
|
grpcStatus: string;
|
|
21
|
-
/** gRPC numeric status code */
|
|
29
|
+
/** gRPC numeric status code (e.g. `5`) */
|
|
22
30
|
grpcCode: number;
|
|
23
31
|
}
|
|
24
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Precomputed cross-binding error mapping for all 9 A2A error types.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Built once at module load and immutable thereafter. Each entry maps an
|
|
37
|
+
* A2A error type to its JSON-RPC, HTTP, and gRPC representations.
|
|
38
|
+
*/
|
|
25
39
|
export declare const A2A_ERROR_MAPPINGS: ReadonlyMap<A2AErrorType, ErrorCodeMapping>;
|
|
26
40
|
/**
|
|
27
41
|
* Get the complete error code mapping for a given A2A error type.
|
|
28
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Looks up the precomputed mapping from {@link A2A_ERROR_MAPPINGS}. Throws
|
|
45
|
+
* if the error type is not one of the 9 known A2A error types.
|
|
46
|
+
*
|
|
47
|
+
* @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
|
|
48
|
+
* @returns The {@link ErrorCodeMapping} with JSON-RPC, HTTP, and gRPC codes
|
|
49
|
+
* @throws Error if the error type is not a known A2A error type
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const mapping = getErrorCodeMapping('TaskNotFound');
|
|
54
|
+
* // { jsonRpcCode: -32001, httpStatus: 404, httpTypeUri: '...', grpcStatus: 'NOT_FOUND', grpcCode: 5 }
|
|
55
|
+
* ```
|
|
29
56
|
*/
|
|
30
57
|
export declare function getErrorCodeMapping(errorType: A2AErrorType): ErrorCodeMapping;
|
|
31
58
|
export { A2A_GRPC_ERROR_REASONS } from './grpc.js';
|
|
59
|
+
/**
|
|
60
|
+
* Supported A2A protocol versions.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Tuple of version strings that this implementation can handle.
|
|
64
|
+
*/
|
|
32
65
|
export declare const SUPPORTED_A2A_VERSIONS: readonly ["1.0"];
|
|
66
|
+
/**
|
|
67
|
+
* Default A2A protocol version used when none is requested.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Applied when the client does not provide an `a2a-version` header.
|
|
71
|
+
*/
|
|
33
72
|
export declare const DEFAULT_A2A_VERSION: "1.0";
|
|
73
|
+
/**
|
|
74
|
+
* Parse the `a2a-version` header into an array of version strings.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* Splits the comma-separated header value, trims whitespace, and filters
|
|
78
|
+
* empty segments. Returns an empty array when the header is absent.
|
|
79
|
+
*
|
|
80
|
+
* @param headerValue - The raw `a2a-version` header value, or `undefined` if absent
|
|
81
|
+
* @returns An array of version strings extracted from the header
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* parseA2AVersionHeader('1.0, 2.0'); // ['1.0', '2.0']
|
|
86
|
+
* parseA2AVersionHeader(undefined); // []
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
34
89
|
export declare function parseA2AVersionHeader(headerValue: string | undefined): string[];
|
|
90
|
+
/**
|
|
91
|
+
* Negotiate an A2A protocol version from the client's requested versions.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Returns the first requested version that is also in {@link SUPPORTED_A2A_VERSIONS}.
|
|
95
|
+
* Falls back to {@link DEFAULT_A2A_VERSION} when the request list is empty.
|
|
96
|
+
* Returns `null` if no requested version is supported.
|
|
97
|
+
*
|
|
98
|
+
* @param requestedVersions - Array of version strings requested by the client
|
|
99
|
+
* @returns The negotiated version string, or `null` if no common version exists
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* negotiateA2AVersion(['1.0', '2.0']); // '1.0'
|
|
104
|
+
* negotiateA2AVersion([]); // '1.0' (default)
|
|
105
|
+
* negotiateA2AVersion(['3.0']); // null
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
35
108
|
export declare function negotiateA2AVersion(requestedVersions: string[]): string | null;
|
|
36
109
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/a2a/bindings/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/a2a/bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAI7B,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,cAAc,CAAC;AAM1E;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgCD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,YAAY,EAAE,gBAAgB,CAAmB,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,GAAG,gBAAgB,CAM7E;AAID,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAMnD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kBAAmB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAG,KAAc,CAAC;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAM/E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAY9E"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Re-exports all binding modules and provides cross-binding
|
|
5
5
|
* error code mapping for consistent error handling across transports.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
6
8
|
*/
|
|
7
9
|
export * from './grpc.js';
|
|
8
10
|
export * from './http.js';
|
|
@@ -36,11 +38,30 @@ function buildMappings() {
|
|
|
36
38
|
}
|
|
37
39
|
return map;
|
|
38
40
|
}
|
|
39
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Precomputed cross-binding error mapping for all 9 A2A error types.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Built once at module load and immutable thereafter. Each entry maps an
|
|
46
|
+
* A2A error type to its JSON-RPC, HTTP, and gRPC representations.
|
|
47
|
+
*/
|
|
40
48
|
export const A2A_ERROR_MAPPINGS = buildMappings();
|
|
41
49
|
/**
|
|
42
50
|
* Get the complete error code mapping for a given A2A error type.
|
|
43
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Looks up the precomputed mapping from {@link A2A_ERROR_MAPPINGS}. Throws
|
|
54
|
+
* if the error type is not one of the 9 known A2A error types.
|
|
55
|
+
*
|
|
56
|
+
* @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
|
|
57
|
+
* @returns The {@link ErrorCodeMapping} with JSON-RPC, HTTP, and gRPC codes
|
|
58
|
+
* @throws Error if the error type is not a known A2A error type
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const mapping = getErrorCodeMapping('TaskNotFound');
|
|
63
|
+
* // { jsonRpcCode: -32001, httpStatus: 404, httpTypeUri: '...', grpcStatus: 'NOT_FOUND', grpcCode: 5 }
|
|
64
|
+
* ```
|
|
44
65
|
*/
|
|
45
66
|
export function getErrorCodeMapping(errorType) {
|
|
46
67
|
const mapping = A2A_ERROR_MAPPINGS.get(errorType);
|
|
@@ -55,8 +76,36 @@ export { A2A_GRPC_ERROR_REASONS } from './grpc.js';
|
|
|
55
76
|
// ============================================================================
|
|
56
77
|
// Version Negotiation
|
|
57
78
|
// ============================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Supported A2A protocol versions.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Tuple of version strings that this implementation can handle.
|
|
84
|
+
*/
|
|
58
85
|
export const SUPPORTED_A2A_VERSIONS = ['1.0'];
|
|
86
|
+
/**
|
|
87
|
+
* Default A2A protocol version used when none is requested.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* Applied when the client does not provide an `a2a-version` header.
|
|
91
|
+
*/
|
|
59
92
|
export const DEFAULT_A2A_VERSION = '1.0';
|
|
93
|
+
/**
|
|
94
|
+
* Parse the `a2a-version` header into an array of version strings.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Splits the comma-separated header value, trims whitespace, and filters
|
|
98
|
+
* empty segments. Returns an empty array when the header is absent.
|
|
99
|
+
*
|
|
100
|
+
* @param headerValue - The raw `a2a-version` header value, or `undefined` if absent
|
|
101
|
+
* @returns An array of version strings extracted from the header
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* parseA2AVersionHeader('1.0, 2.0'); // ['1.0', '2.0']
|
|
106
|
+
* parseA2AVersionHeader(undefined); // []
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
60
109
|
export function parseA2AVersionHeader(headerValue) {
|
|
61
110
|
if (!headerValue)
|
|
62
111
|
return [];
|
|
@@ -65,6 +114,24 @@ export function parseA2AVersionHeader(headerValue) {
|
|
|
65
114
|
.map((v) => v.trim())
|
|
66
115
|
.filter(Boolean);
|
|
67
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Negotiate an A2A protocol version from the client's requested versions.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Returns the first requested version that is also in {@link SUPPORTED_A2A_VERSIONS}.
|
|
122
|
+
* Falls back to {@link DEFAULT_A2A_VERSION} when the request list is empty.
|
|
123
|
+
* Returns `null` if no requested version is supported.
|
|
124
|
+
*
|
|
125
|
+
* @param requestedVersions - Array of version strings requested by the client
|
|
126
|
+
* @returns The negotiated version string, or `null` if no common version exists
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* negotiateA2AVersion(['1.0', '2.0']); // '1.0'
|
|
131
|
+
* negotiateA2AVersion([]); // '1.0' (default)
|
|
132
|
+
* negotiateA2AVersion(['3.0']); // null
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
68
135
|
export function negotiateA2AVersion(requestedVersions) {
|
|
69
136
|
if (requestedVersions.length === 0) {
|
|
70
137
|
return DEFAULT_A2A_VERSION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/a2a/bindings/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/a2a/bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAqB,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA0B1E,4BAA4B;AAC5B,MAAM,WAAW,GAAmB;IAClC,cAAc;IACd,mBAAmB;IACnB,8BAA8B;IAC9B,sBAAsB;IACtB,yBAAyB;IACzB,sBAAsB;IACtB,wCAAwC;IACxC,0BAA0B;IAC1B,qBAAqB;CACtB,CAAC;AAEF,SAAS,aAAa;IACpB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkC,CAAC;IAEtD,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACpC,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;QACxD,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE;YACjB,WAAW,EAAE,uBAAuB,CAAC,SAAS,CAAC;YAC/C,UAAU,EAAE,qBAAqB,CAAC,SAAS,CAAC;YAC5C,WAAW,EAAE,mBAAmB,CAAC,SAAS,CAAC;YAC3C,UAAU,EAAE,cAAc;YAC1B,QAAQ,EAAE,gBAAgB,CAAC,cAAc,CAAC;SAC3C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgD,aAAa,EAAE,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAu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