@a2a-js/sdk 0.3.10 → 0.3.12
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/dist/{a2a_request_handler-BuP9LgXH.d.ts → a2a_request_handler-BiphzMH4.d.cts} +2 -2
- package/dist/{a2a_request_handler-B3LxMq3P.d.cts → a2a_request_handler-C9bZITjN.d.ts} +2 -2
- package/dist/{chunk-U3QAVT4H.js → chunk-2TNRJNPO.js} +694 -694
- package/dist/client/index.cjs +1327 -1288
- package/dist/client/index.d.cts +7 -3
- package/dist/client/index.d.ts +7 -3
- package/dist/client/index.js +79 -40
- package/dist/client/transports/grpc/index.d.cts +2 -2
- package/dist/client/transports/grpc/index.d.ts +2 -2
- package/dist/client/transports/grpc/index.js +1 -1
- package/dist/{core-BAzQJfA2.d.ts → core-BHroNzI0.d.cts} +2 -2
- package/dist/{core-Ci-lR0jz.d.cts → core-NwQicv77.d.ts} +2 -2
- package/dist/{extensions-DvruCIzw.d.cts → extensions-APfrw8gz.d.cts} +1 -1
- package/dist/{extensions-DvruCIzw.d.ts → extensions-APfrw8gz.d.ts} +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/server/express/index.cjs +24 -113
- package/dist/server/express/index.d.cts +2 -2
- package/dist/server/express/index.d.ts +2 -2
- package/dist/server/express/index.js +25 -114
- package/dist/server/grpc/index.d.cts +2 -2
- package/dist/server/grpc/index.d.ts +2 -2
- package/dist/server/grpc/index.js +1 -1
- package/dist/server/index.cjs +0 -1
- package/dist/server/index.d.cts +3 -4
- package/dist/server/index.d.ts +3 -4
- package/dist/server/index.js +0 -1
- package/package.json +5 -3
package/dist/client/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TransportFactory, C as ClientConfig, a as TransportProtocolName, b as Client, c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData } from '../core-
|
|
2
|
-
export { d as A2AClient, e as A2AClientOptions,
|
|
3
|
-
import {
|
|
1
|
+
import { T as TransportFactory, C as ClientConfig, a as TransportProtocolName, b as Client, c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData } from '../core-BHroNzI0.cjs';
|
|
2
|
+
export { d as A2AClient, e as A2AClientOptions, f as AfterArgs, B as BeforeArgs, g as CallInterceptor, h as ClientCallContext, i as ClientCallContextKey, j as ClientCallInput, k as ClientCallResult, l as ContextUpdate, m as ServiceParameters, n as ServiceParametersUpdate, w as withA2AExtensions } from '../core-BHroNzI0.cjs';
|
|
3
|
+
import { i as AgentCard, aj as MessageSendParams, aU as TaskPushNotificationConfig, U as GetTaskPushNotificationConfigParams, aa as ListTaskPushNotificationConfigParams, E as DeleteTaskPushNotificationConfigParams, aY as TaskQueryParams, aL as Task, aP as TaskIdParams, a8 as JSONRPCResponse } from '../extensions-APfrw8gz.cjs';
|
|
4
4
|
|
|
5
5
|
interface HttpHeaders {
|
|
6
6
|
[key: string]: string;
|
|
@@ -80,6 +80,10 @@ declare class DefaultAgentCardResolver implements AgentCardResolver {
|
|
|
80
80
|
*/
|
|
81
81
|
resolve(baseUrl: string, path?: string): Promise<AgentCard>;
|
|
82
82
|
private fetchImpl;
|
|
83
|
+
private normalizeAgentCard;
|
|
84
|
+
private isProtoAgentCard;
|
|
85
|
+
private hasProtoSecurity;
|
|
86
|
+
private hasProtoSecuritySchemes;
|
|
83
87
|
}
|
|
84
88
|
interface AgentCardResolver {
|
|
85
89
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TransportFactory, C as ClientConfig, a as TransportProtocolName, b as Client, c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData } from '../core-
|
|
2
|
-
export { d as A2AClient, e as A2AClientOptions,
|
|
3
|
-
import {
|
|
1
|
+
import { T as TransportFactory, C as ClientConfig, a as TransportProtocolName, b as Client, c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData } from '../core-NwQicv77.js';
|
|
2
|
+
export { d as A2AClient, e as A2AClientOptions, f as AfterArgs, B as BeforeArgs, g as CallInterceptor, h as ClientCallContext, i as ClientCallContextKey, j as ClientCallInput, k as ClientCallResult, l as ContextUpdate, m as ServiceParameters, n as ServiceParametersUpdate, w as withA2AExtensions } from '../core-NwQicv77.js';
|
|
3
|
+
import { i as AgentCard, aj as MessageSendParams, aU as TaskPushNotificationConfig, U as GetTaskPushNotificationConfigParams, aa as ListTaskPushNotificationConfigParams, E as DeleteTaskPushNotificationConfigParams, aY as TaskQueryParams, aL as Task, aP as TaskIdParams, a8 as JSONRPCResponse } from '../extensions-APfrw8gz.js';
|
|
4
4
|
|
|
5
5
|
interface HttpHeaders {
|
|
6
6
|
[key: string]: string;
|
|
@@ -80,6 +80,10 @@ declare class DefaultAgentCardResolver implements AgentCardResolver {
|
|
|
80
80
|
*/
|
|
81
81
|
resolve(baseUrl: string, path?: string): Promise<AgentCard>;
|
|
82
82
|
private fetchImpl;
|
|
83
|
+
private normalizeAgentCard;
|
|
84
|
+
private isProtoAgentCard;
|
|
85
|
+
private hasProtoSecurity;
|
|
86
|
+
private hasProtoSecuritySchemes;
|
|
83
87
|
}
|
|
84
88
|
interface AgentCardResolver {
|
|
85
89
|
/**
|
package/dist/client/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
Task,
|
|
29
29
|
TaskPushNotificationConfig,
|
|
30
30
|
ToProto
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-2TNRJNPO.js";
|
|
32
32
|
import "../chunk-UHZEIZLS.js";
|
|
33
33
|
|
|
34
34
|
// src/client/transports/json_rpc_transport.ts
|
|
@@ -142,8 +142,8 @@ var JsonRpcTransport = class _JsonRpcTransport {
|
|
|
142
142
|
}
|
|
143
143
|
const rpcResponse = await httpResponse.json();
|
|
144
144
|
if (rpcResponse.id !== requestId) {
|
|
145
|
-
|
|
146
|
-
`
|
|
145
|
+
throw new Error(
|
|
146
|
+
`JSON-RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}.`
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
if ("error" in rpcResponse) {
|
|
@@ -207,38 +207,31 @@ var JsonRpcTransport = class _JsonRpcTransport {
|
|
|
207
207
|
if (!jsonData.trim()) {
|
|
208
208
|
throw new Error("Attempted to process empty SSE event data.");
|
|
209
209
|
}
|
|
210
|
+
let a2aStreamResponse;
|
|
210
211
|
try {
|
|
211
|
-
|
|
212
|
-
const a2aStreamResponse = sseJsonRpcResponse;
|
|
213
|
-
if (a2aStreamResponse.id !== originalRequestId) {
|
|
214
|
-
console.warn(
|
|
215
|
-
`SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
if ("error" in a2aStreamResponse) {
|
|
219
|
-
const err = a2aStreamResponse.error;
|
|
220
|
-
throw new Error(
|
|
221
|
-
`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data || {})}`,
|
|
222
|
-
{ cause: _JsonRpcTransport.mapToError(a2aStreamResponse) }
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
if (!("result" in a2aStreamResponse) || typeof a2aStreamResponse.result === "undefined") {
|
|
226
|
-
throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);
|
|
227
|
-
}
|
|
228
|
-
return a2aStreamResponse.result;
|
|
212
|
+
a2aStreamResponse = JSON.parse(jsonData);
|
|
229
213
|
} catch (e) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
console.error(
|
|
234
|
-
"Failed to parse SSE event data string or unexpected JSON-RPC structure:",
|
|
235
|
-
jsonData,
|
|
236
|
-
e
|
|
214
|
+
throw new Error(
|
|
215
|
+
`Failed to parse SSE event data: "${jsonData.substring(0, 100)}...". Original error: ${e instanceof Error && e.message || "Unknown error"}`,
|
|
216
|
+
{ cause: e }
|
|
237
217
|
);
|
|
218
|
+
}
|
|
219
|
+
if (a2aStreamResponse.id !== originalRequestId) {
|
|
238
220
|
throw new Error(
|
|
239
|
-
`
|
|
221
|
+
`JSON-RPC response ID mismatch in SSE event. Expected ${originalRequestId}, got ${a2aStreamResponse.id}.`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
if ("error" in a2aStreamResponse) {
|
|
225
|
+
const err = a2aStreamResponse.error;
|
|
226
|
+
throw new Error(
|
|
227
|
+
`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data || {})}`,
|
|
228
|
+
{ cause: _JsonRpcTransport.mapToError(a2aStreamResponse) }
|
|
240
229
|
);
|
|
241
230
|
}
|
|
231
|
+
if (!("result" in a2aStreamResponse) || typeof a2aStreamResponse.result === "undefined") {
|
|
232
|
+
throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);
|
|
233
|
+
}
|
|
234
|
+
return a2aStreamResponse.result;
|
|
242
235
|
}
|
|
243
236
|
static mapToError(response) {
|
|
244
237
|
switch (response.error.code) {
|
|
@@ -729,7 +722,8 @@ var DefaultAgentCardResolver = class {
|
|
|
729
722
|
if (!response.ok) {
|
|
730
723
|
throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status}`);
|
|
731
724
|
}
|
|
732
|
-
|
|
725
|
+
const rawCard = await response.json();
|
|
726
|
+
return this.normalizeAgentCard(rawCard);
|
|
733
727
|
}
|
|
734
728
|
fetchImpl(...args) {
|
|
735
729
|
if (this.options?.fetchImpl) {
|
|
@@ -737,6 +731,54 @@ var DefaultAgentCardResolver = class {
|
|
|
737
731
|
}
|
|
738
732
|
return fetch(...args);
|
|
739
733
|
}
|
|
734
|
+
/*
|
|
735
|
+
* In the v0.3.0 specification, there was a structural drift between the JSON Schema data model
|
|
736
|
+
* and the Protobuf-based data model for AgentCards.
|
|
737
|
+
* The JSON Schema format uses a `"type"` discriminator (e.g., `{"type": "openIdConnect"}`),
|
|
738
|
+
* while the Protobuf JSON representation uses the `oneof` field name as the discriminator
|
|
739
|
+
* (e.g., `{"openIdConnectSecurityScheme": {...}}`).
|
|
740
|
+
*
|
|
741
|
+
* The A2A SDK internal logic expects the JSON Schema-based format. This fallback detection
|
|
742
|
+
* allows us to parse cards served by endpoints returning the Protobuf JSON structure by
|
|
743
|
+
* identifying the lack of the "type" field in security schemes or the presence of the
|
|
744
|
+
* "schemes" wrapper in security entries, and normalizing it before use.
|
|
745
|
+
*/
|
|
746
|
+
normalizeAgentCard(card) {
|
|
747
|
+
if (this.isProtoAgentCard(card)) {
|
|
748
|
+
const parsedProto = AgentCard.fromJSON(card);
|
|
749
|
+
return FromProto.agentCard(parsedProto);
|
|
750
|
+
}
|
|
751
|
+
return card;
|
|
752
|
+
}
|
|
753
|
+
isProtoAgentCard(card) {
|
|
754
|
+
if (!card || typeof card !== "object") return false;
|
|
755
|
+
const c = card;
|
|
756
|
+
if (this.hasProtoSecurity(c.security)) return true;
|
|
757
|
+
if (this.hasProtoSecuritySchemes(c.securitySchemes)) return true;
|
|
758
|
+
if (Array.isArray(c.skills)) {
|
|
759
|
+
return c.skills.some(
|
|
760
|
+
(skill) => skill && typeof skill === "object" && this.hasProtoSecurity(skill.security)
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
hasProtoSecurity(securityArray) {
|
|
766
|
+
if (Array.isArray(securityArray) && securityArray.length > 0) {
|
|
767
|
+
const first = securityArray[0];
|
|
768
|
+
return first && typeof first === "object" && "schemes" in first;
|
|
769
|
+
}
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
hasProtoSecuritySchemes(securitySchemes) {
|
|
773
|
+
if (securitySchemes && typeof securitySchemes === "object") {
|
|
774
|
+
const schemes = Object.values(securitySchemes);
|
|
775
|
+
if (schemes.length > 0) {
|
|
776
|
+
const first = schemes[0];
|
|
777
|
+
return first && typeof first === "object" && !("type" in first);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
740
782
|
};
|
|
741
783
|
var AgentCardResolver = {
|
|
742
784
|
default: new DefaultAgentCardResolver()
|
|
@@ -1349,18 +1391,15 @@ var ClientFactory = class {
|
|
|
1349
1391
|
...additionalInterfaces.map((i) => i.transport)
|
|
1350
1392
|
];
|
|
1351
1393
|
for (const transport of transportsByPreference) {
|
|
1352
|
-
|
|
1353
|
-
continue;
|
|
1354
|
-
}
|
|
1394
|
+
const url = urlsPerAgentTransports.get(transport);
|
|
1355
1395
|
const factory = this.transportsByName.get(transport);
|
|
1356
|
-
if (
|
|
1357
|
-
|
|
1396
|
+
if (factory && url) {
|
|
1397
|
+
return new Client(
|
|
1398
|
+
await factory.create(url, agentCard),
|
|
1399
|
+
agentCard,
|
|
1400
|
+
this.options.clientConfig
|
|
1401
|
+
);
|
|
1358
1402
|
}
|
|
1359
|
-
return new Client(
|
|
1360
|
-
await factory.create(urlsPerAgentTransports.get(transport), agentCard),
|
|
1361
|
-
agentCard,
|
|
1362
|
-
this.options.clientConfig
|
|
1363
|
-
);
|
|
1364
1403
|
}
|
|
1365
1404
|
throw new Error(
|
|
1366
1405
|
"No compatible transport found, available transports: " + [...this.transportsByName.keys()].join()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData, T as TransportFactory, a as TransportProtocolName } from '../../../core-
|
|
3
|
-
import {
|
|
2
|
+
import { c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData, T as TransportFactory, a as TransportProtocolName } from '../../../core-BHroNzI0.cjs';
|
|
3
|
+
import { i as AgentCard, aj as MessageSendParams, aU as TaskPushNotificationConfig, U as GetTaskPushNotificationConfigParams, aa as ListTaskPushNotificationConfigParams, E as DeleteTaskPushNotificationConfigParams, aY as TaskQueryParams, aL as Task, aP as TaskIdParams } from '../../../extensions-APfrw8gz.cjs';
|
|
4
4
|
|
|
5
5
|
interface GrpcTransportOptions {
|
|
6
6
|
endpoint: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData, T as TransportFactory, a as TransportProtocolName } from '../../../core-
|
|
3
|
-
import {
|
|
2
|
+
import { c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData, T as TransportFactory, a as TransportProtocolName } from '../../../core-NwQicv77.js';
|
|
3
|
+
import { i as AgentCard, aj as MessageSendParams, aU as TaskPushNotificationConfig, U as GetTaskPushNotificationConfigParams, aa as ListTaskPushNotificationConfigParams, E as DeleteTaskPushNotificationConfigParams, aY as TaskQueryParams, aL as Task, aP as TaskIdParams } from '../../../extensions-APfrw8gz.js';
|
|
4
4
|
|
|
5
5
|
interface GrpcTransportOptions {
|
|
6
6
|
endpoint: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as AgentCard, aj as MessageSendParams, S as SendMessageResponse, ae as Message, aL as Task, b3 as TaskStatusUpdateEvent, aO as TaskArtifactUpdateEvent, aU as TaskPushNotificationConfig, b as SetTaskPushNotificationConfigResponse, aP as TaskIdParams, c as GetTaskPushNotificationConfigResponse, aa as ListTaskPushNotificationConfigParams, ad as ListTaskPushNotificationConfigResponse, E as DeleteTaskPushNotificationConfigParams, I as DeleteTaskPushNotificationConfigResponse, aY as TaskQueryParams, G as GetTaskResponse, C as CancelTaskResponse, a8 as JSONRPCResponse, M as Extensions, U as GetTaskPushNotificationConfigParams, az as PushNotificationConfig } from './extensions-APfrw8gz.cjs';
|
|
2
2
|
|
|
3
3
|
type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
4
4
|
type SendMessageResult = Message | Task;
|
|
@@ -413,4 +413,4 @@ declare class Client {
|
|
|
413
413
|
|
|
414
414
|
type TransportProtocolName = 'JSONRPC' | 'HTTP+JSON' | 'GRPC' | (string & {});
|
|
415
415
|
|
|
416
|
-
export { type A2AStreamEventData as A, type BeforeArgs as B, type ClientConfig as C, type RequestOptions as R, type SendMessageResult as S, type TransportFactory as T, type TransportProtocolName as a, Client as b, type Transport as c, A2AClient as d, type A2AClientOptions as e, type
|
|
416
|
+
export { type A2AStreamEventData as A, type BeforeArgs as B, type ClientConfig as C, type RequestOptions as R, type SendMessageResult as S, type TransportFactory as T, type TransportProtocolName as a, Client as b, type Transport as c, A2AClient as d, type A2AClientOptions as e, type AfterArgs as f, type CallInterceptor as g, ClientCallContext as h, ClientCallContextKey as i, type ClientCallInput as j, type ClientCallResult as k, type ContextUpdate as l, ServiceParameters as m, type ServiceParametersUpdate as n, withA2AExtensions as w };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as AgentCard, aj as MessageSendParams, S as SendMessageResponse, ae as Message, aL as Task, b3 as TaskStatusUpdateEvent, aO as TaskArtifactUpdateEvent, aU as TaskPushNotificationConfig, b as SetTaskPushNotificationConfigResponse, aP as TaskIdParams, c as GetTaskPushNotificationConfigResponse, aa as ListTaskPushNotificationConfigParams, ad as ListTaskPushNotificationConfigResponse, E as DeleteTaskPushNotificationConfigParams, I as DeleteTaskPushNotificationConfigResponse, aY as TaskQueryParams, G as GetTaskResponse, C as CancelTaskResponse, a8 as JSONRPCResponse, M as Extensions, U as GetTaskPushNotificationConfigParams, az as PushNotificationConfig } from './extensions-APfrw8gz.js';
|
|
2
2
|
|
|
3
3
|
type A2AStreamEventData = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
4
4
|
type SendMessageResult = Message | Task;
|
|
@@ -413,4 +413,4 @@ declare class Client {
|
|
|
413
413
|
|
|
414
414
|
type TransportProtocolName = 'JSONRPC' | 'HTTP+JSON' | 'GRPC' | (string & {});
|
|
415
415
|
|
|
416
|
-
export { type A2AStreamEventData as A, type BeforeArgs as B, type ClientConfig as C, type RequestOptions as R, type SendMessageResult as S, type TransportFactory as T, type TransportProtocolName as a, Client as b, type Transport as c, A2AClient as d, type A2AClientOptions as e, type
|
|
416
|
+
export { type A2AStreamEventData as A, type BeforeArgs as B, type ClientConfig as C, type RequestOptions as R, type SendMessageResult as S, type TransportFactory as T, type TransportProtocolName as a, Client as b, type Transport as c, A2AClient as d, type A2AClientOptions as e, type AfterArgs as f, type CallInterceptor as g, ClientCallContext as h, ClientCallContextKey as i, type ClientCallInput as j, type ClientCallResult as k, type ContextUpdate as l, ServiceParameters as m, type ServiceParametersUpdate as n, withA2AExtensions as w };
|
|
@@ -2586,4 +2586,4 @@ declare const Extensions: {
|
|
|
2586
2586
|
toServiceParameter: (value: Extensions) => string;
|
|
2587
2587
|
};
|
|
2588
2588
|
|
|
2589
|
-
export { type
|
|
2589
|
+
export { type ImplicitOAuthFlow1 as $, type A2AError as A, type DataPart as B, type CancelTaskResponse as C, type DeleteTaskPushNotificationConfigSuccessResponse as D, type DeleteTaskPushNotificationConfigParams as E, type DeleteTaskPushNotificationConfigParams1 as F, type GetTaskResponse as G, type DeleteTaskPushNotificationConfigRequest as H, type DeleteTaskPushNotificationConfigResponse as I, type JSONRPCErrorResponse as J, type ExtensionURI as K, type ListTaskPushNotificationConfigSuccessResponse as L, Extensions as M, type FileBase as N, type FilePart as O, type FileWithBytes as P, type FileWithUri as Q, type GetAuthenticatedExtendedCardRequest as R, type SendMessageResponse as S, type GetAuthenticatedExtendedCardResponse as T, type GetTaskPushNotificationConfigParams as U, type GetTaskPushNotificationConfigRequest as V, type GetTaskPushNotificationConfigSuccessResponse as W, type GetTaskRequest as X, type GetTaskSuccessResponse as Y, type HTTPAuthSecurityScheme as Z, type ImplicitOAuthFlow as _, type SendStreamingMessageResponse as a, type TaskState as a$, type InternalError as a0, type InvalidAgentResponseError as a1, type InvalidParamsError as a2, type InvalidRequestError as a3, type JSONParseError as a4, type JSONRPCError as a5, type JSONRPCMessage as a6, type JSONRPCRequest as a7, type JSONRPCResponse as a8, type JSONRPCSuccessResponse as a9, type PushNotificationConfig1 as aA, type PushNotificationConfig2 as aB, type PushNotificationNotSupportedError as aC, type SecurityScheme as aD, type SecuritySchemeBase as aE, type SendMessageRequest as aF, type SendMessageSuccessResponse as aG, type SendStreamingMessageRequest as aH, type SendStreamingMessageSuccessResponse as aI, type SetTaskPushNotificationConfigRequest as aJ, type SetTaskPushNotificationConfigSuccessResponse as aK, type Task as aL, type Task1 as aM, type Task2 as aN, type TaskArtifactUpdateEvent as aO, type TaskIdParams as aP, type TaskIdParams1 as aQ, type TaskIdParams2 as aR, type TaskNotCancelableError as aS, type TaskNotFoundError as aT, type TaskPushNotificationConfig as aU, type TaskPushNotificationConfig1 as aV, type TaskPushNotificationConfig2 as aW, type TaskPushNotificationConfig3 as aX, type TaskQueryParams as aY, type TaskQueryParams1 as aZ, type TaskResubscriptionRequest as a_, type ListTaskPushNotificationConfigParams as aa, type ListTaskPushNotificationConfigParams1 as ab, type ListTaskPushNotificationConfigRequest as ac, type ListTaskPushNotificationConfigResponse as ad, type Message as ae, type Message1 as af, type Message2 as ag, type MessageSendConfiguration as ah, type MessageSendConfiguration1 as ai, type MessageSendParams as aj, type MessageSendParams1 as ak, type MessageSendParams2 as al, type MethodNotFoundError as am, type MutualTLSSecurityScheme as an, type MySchema as ao, type OAuth2SecurityScheme as ap, type OAuthFlows as aq, type OAuthFlows1 as ar, type OpenIdConnectSecurityScheme as as, type Part as at, type PartBase as au, type PasswordOAuthFlow as av, type PasswordOAuthFlow1 as aw, type PushNotificationAuthenticationInfo as ax, type PushNotificationAuthenticationInfo1 as ay, type PushNotificationConfig as az, type SetTaskPushNotificationConfigResponse as b, type TaskStatus as b0, type TaskStatus1 as b1, type TaskStatus2 as b2, type TaskStatusUpdateEvent as b3, type TextPart as b4, type TransportProtocol as b5, type UnsupportedOperationError as b6, type GetTaskPushNotificationConfigResponse as c, type GetAuthenticatedExtendedCardSuccessResponse as d, type A2ARequest as e, type APIKeySecurityScheme as f, type AgentCapabilities as g, type AgentCapabilities1 as h, type AgentCard as i, type AgentCard1 as j, type AgentCardSignature as k, type AgentExtension as l, type AgentInterface as m, type AgentProvider as n, type AgentProvider1 as o, type AgentSkill as p, type Artifact as q, type Artifact1 as r, type AuthenticatedExtendedCardNotConfiguredError as s, type AuthorizationCodeOAuthFlow as t, type AuthorizationCodeOAuthFlow1 as u, type CancelTaskRequest as v, type CancelTaskSuccessResponse as w, type ClientCredentialsOAuthFlow as x, type ClientCredentialsOAuthFlow1 as y, type ContentTypeNotSupportedError as z };
|
|
@@ -2586,4 +2586,4 @@ declare const Extensions: {
|
|
|
2586
2586
|
toServiceParameter: (value: Extensions) => string;
|
|
2587
2587
|
};
|
|
2588
2588
|
|
|
2589
|
-
export { type
|
|
2589
|
+
export { type ImplicitOAuthFlow1 as $, type A2AError as A, type DataPart as B, type CancelTaskResponse as C, type DeleteTaskPushNotificationConfigSuccessResponse as D, type DeleteTaskPushNotificationConfigParams as E, type DeleteTaskPushNotificationConfigParams1 as F, type GetTaskResponse as G, type DeleteTaskPushNotificationConfigRequest as H, type DeleteTaskPushNotificationConfigResponse as I, type JSONRPCErrorResponse as J, type ExtensionURI as K, type ListTaskPushNotificationConfigSuccessResponse as L, Extensions as M, type FileBase as N, type FilePart as O, type FileWithBytes as P, type FileWithUri as Q, type GetAuthenticatedExtendedCardRequest as R, type SendMessageResponse as S, type GetAuthenticatedExtendedCardResponse as T, type GetTaskPushNotificationConfigParams as U, type GetTaskPushNotificationConfigRequest as V, type GetTaskPushNotificationConfigSuccessResponse as W, type GetTaskRequest as X, type GetTaskSuccessResponse as Y, type HTTPAuthSecurityScheme as Z, type ImplicitOAuthFlow as _, type SendStreamingMessageResponse as a, type TaskState as a$, type InternalError as a0, type InvalidAgentResponseError as a1, type InvalidParamsError as a2, type InvalidRequestError as a3, type JSONParseError as a4, type JSONRPCError as a5, type JSONRPCMessage as a6, type JSONRPCRequest as a7, type JSONRPCResponse as a8, type JSONRPCSuccessResponse as a9, type PushNotificationConfig1 as aA, type PushNotificationConfig2 as aB, type PushNotificationNotSupportedError as aC, type SecurityScheme as aD, type SecuritySchemeBase as aE, type SendMessageRequest as aF, type SendMessageSuccessResponse as aG, type SendStreamingMessageRequest as aH, type SendStreamingMessageSuccessResponse as aI, type SetTaskPushNotificationConfigRequest as aJ, type SetTaskPushNotificationConfigSuccessResponse as aK, type Task as aL, type Task1 as aM, type Task2 as aN, type TaskArtifactUpdateEvent as aO, type TaskIdParams as aP, type TaskIdParams1 as aQ, type TaskIdParams2 as aR, type TaskNotCancelableError as aS, type TaskNotFoundError as aT, type TaskPushNotificationConfig as aU, type TaskPushNotificationConfig1 as aV, type TaskPushNotificationConfig2 as aW, type TaskPushNotificationConfig3 as aX, type TaskQueryParams as aY, type TaskQueryParams1 as aZ, type TaskResubscriptionRequest as a_, type ListTaskPushNotificationConfigParams as aa, type ListTaskPushNotificationConfigParams1 as ab, type ListTaskPushNotificationConfigRequest as ac, type ListTaskPushNotificationConfigResponse as ad, type Message as ae, type Message1 as af, type Message2 as ag, type MessageSendConfiguration as ah, type MessageSendConfiguration1 as ai, type MessageSendParams as aj, type MessageSendParams1 as ak, type MessageSendParams2 as al, type MethodNotFoundError as am, type MutualTLSSecurityScheme as an, type MySchema as ao, type OAuth2SecurityScheme as ap, type OAuthFlows as aq, type OAuthFlows1 as ar, type OpenIdConnectSecurityScheme as as, type Part as at, type PartBase as au, type PasswordOAuthFlow as av, type PasswordOAuthFlow1 as aw, type PushNotificationAuthenticationInfo as ax, type PushNotificationAuthenticationInfo1 as ay, type PushNotificationConfig as az, type SetTaskPushNotificationConfigResponse as b, type TaskStatus as b0, type TaskStatus1 as b1, type TaskStatus2 as b2, type TaskStatusUpdateEvent as b3, type TextPart as b4, type TransportProtocol as b5, type UnsupportedOperationError as b6, type GetTaskPushNotificationConfigResponse as c, type GetAuthenticatedExtendedCardSuccessResponse as d, type A2ARequest as e, type APIKeySecurityScheme as f, type AgentCapabilities as g, type AgentCapabilities1 as h, type AgentCard as i, type AgentCard1 as j, type AgentCardSignature as k, type AgentExtension as l, type AgentInterface as m, type AgentProvider as n, type AgentProvider1 as o, type AgentSkill as p, type Artifact as q, type Artifact1 as r, type AuthenticatedExtendedCardNotConfiguredError as s, type AuthorizationCodeOAuthFlow as t, type AuthorizationCodeOAuthFlow1 as u, type CancelTaskRequest as v, type CancelTaskSuccessResponse as w, type ClientCredentialsOAuthFlow as x, type ClientCredentialsOAuthFlow1 as y, type ContentTypeNotSupportedError as z };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './extensions-
|
|
2
|
-
export { A as A2AError,
|
|
1
|
+
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './extensions-APfrw8gz.cjs';
|
|
2
|
+
export { A as A2AError, e as A2ARequest, f as APIKeySecurityScheme, g as AgentCapabilities, h as AgentCapabilities1, i as AgentCard, j as AgentCard1, k as AgentCardSignature, l as AgentExtension, m as AgentInterface, n as AgentProvider, o as AgentProvider1, p as AgentSkill, q as Artifact, r as Artifact1, s as AuthenticatedExtendedCardNotConfiguredError, t as AuthorizationCodeOAuthFlow, u as AuthorizationCodeOAuthFlow1, v as CancelTaskRequest, w as CancelTaskSuccessResponse, x as ClientCredentialsOAuthFlow, y as ClientCredentialsOAuthFlow1, z as ContentTypeNotSupportedError, B as DataPart, E as DeleteTaskPushNotificationConfigParams, F as DeleteTaskPushNotificationConfigParams1, H as DeleteTaskPushNotificationConfigRequest, I as DeleteTaskPushNotificationConfigResponse, K as ExtensionURI, M as Extensions, N as FileBase, O as FilePart, P as FileWithBytes, Q as FileWithUri, R as GetAuthenticatedExtendedCardRequest, T as GetAuthenticatedExtendedCardResponse, U as GetTaskPushNotificationConfigParams, V as GetTaskPushNotificationConfigRequest, W as GetTaskPushNotificationConfigSuccessResponse, X as GetTaskRequest, Y as GetTaskSuccessResponse, Z as HTTPAuthSecurityScheme, _ as ImplicitOAuthFlow, $ as ImplicitOAuthFlow1, a0 as InternalError, a1 as InvalidAgentResponseError, a2 as InvalidParamsError, a3 as InvalidRequestError, a4 as JSONParseError, a5 as JSONRPCError, a6 as JSONRPCMessage, a7 as JSONRPCRequest, a8 as JSONRPCResponse, a9 as JSONRPCSuccessResponse, aa as ListTaskPushNotificationConfigParams, ab as ListTaskPushNotificationConfigParams1, ac as ListTaskPushNotificationConfigRequest, ad as ListTaskPushNotificationConfigResponse, ae as Message, af as Message1, ag as Message2, ah as MessageSendConfiguration, ai as MessageSendConfiguration1, aj as MessageSendParams, ak as MessageSendParams1, al as MessageSendParams2, am as MethodNotFoundError, an as MutualTLSSecurityScheme, ao as MySchema, ap as OAuth2SecurityScheme, aq as OAuthFlows, ar as OAuthFlows1, as as OpenIdConnectSecurityScheme, at as Part, au as PartBase, av as PasswordOAuthFlow, aw as PasswordOAuthFlow1, ax as PushNotificationAuthenticationInfo, ay as PushNotificationAuthenticationInfo1, az as PushNotificationConfig, aA as PushNotificationConfig1, aB as PushNotificationConfig2, aC as PushNotificationNotSupportedError, aD as SecurityScheme, aE as SecuritySchemeBase, aF as SendMessageRequest, aG as SendMessageSuccessResponse, aH as SendStreamingMessageRequest, aI as SendStreamingMessageSuccessResponse, aJ as SetTaskPushNotificationConfigRequest, aK as SetTaskPushNotificationConfigSuccessResponse, aL as Task, aM as Task1, aN as Task2, aO as TaskArtifactUpdateEvent, aP as TaskIdParams, aQ as TaskIdParams1, aR as TaskIdParams2, aS as TaskNotCancelableError, aT as TaskNotFoundError, aU as TaskPushNotificationConfig, aV as TaskPushNotificationConfig1, aW as TaskPushNotificationConfig2, aX as TaskPushNotificationConfig3, aY as TaskQueryParams, aZ as TaskQueryParams1, a_ as TaskResubscriptionRequest, a$ as TaskState, b0 as TaskStatus, b1 as TaskStatus1, b2 as TaskStatus2, b3 as TaskStatusUpdateEvent, b4 as TextPart, b5 as TransportProtocol, b6 as UnsupportedOperationError } from './extensions-APfrw8gz.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents any valid JSON-RPC response defined in the A2A protocol.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './extensions-
|
|
2
|
-
export { A as A2AError,
|
|
1
|
+
import { S as SendMessageResponse, a as SendStreamingMessageResponse, G as GetTaskResponse, C as CancelTaskResponse, b as SetTaskPushNotificationConfigResponse, c as GetTaskPushNotificationConfigResponse, L as ListTaskPushNotificationConfigSuccessResponse, D as DeleteTaskPushNotificationConfigSuccessResponse, d as GetAuthenticatedExtendedCardSuccessResponse, J as JSONRPCErrorResponse } from './extensions-APfrw8gz.js';
|
|
2
|
+
export { A as A2AError, e as A2ARequest, f as APIKeySecurityScheme, g as AgentCapabilities, h as AgentCapabilities1, i as AgentCard, j as AgentCard1, k as AgentCardSignature, l as AgentExtension, m as AgentInterface, n as AgentProvider, o as AgentProvider1, p as AgentSkill, q as Artifact, r as Artifact1, s as AuthenticatedExtendedCardNotConfiguredError, t as AuthorizationCodeOAuthFlow, u as AuthorizationCodeOAuthFlow1, v as CancelTaskRequest, w as CancelTaskSuccessResponse, x as ClientCredentialsOAuthFlow, y as ClientCredentialsOAuthFlow1, z as ContentTypeNotSupportedError, B as DataPart, E as DeleteTaskPushNotificationConfigParams, F as DeleteTaskPushNotificationConfigParams1, H as DeleteTaskPushNotificationConfigRequest, I as DeleteTaskPushNotificationConfigResponse, K as ExtensionURI, M as Extensions, N as FileBase, O as FilePart, P as FileWithBytes, Q as FileWithUri, R as GetAuthenticatedExtendedCardRequest, T as GetAuthenticatedExtendedCardResponse, U as GetTaskPushNotificationConfigParams, V as GetTaskPushNotificationConfigRequest, W as GetTaskPushNotificationConfigSuccessResponse, X as GetTaskRequest, Y as GetTaskSuccessResponse, Z as HTTPAuthSecurityScheme, _ as ImplicitOAuthFlow, $ as ImplicitOAuthFlow1, a0 as InternalError, a1 as InvalidAgentResponseError, a2 as InvalidParamsError, a3 as InvalidRequestError, a4 as JSONParseError, a5 as JSONRPCError, a6 as JSONRPCMessage, a7 as JSONRPCRequest, a8 as JSONRPCResponse, a9 as JSONRPCSuccessResponse, aa as ListTaskPushNotificationConfigParams, ab as ListTaskPushNotificationConfigParams1, ac as ListTaskPushNotificationConfigRequest, ad as ListTaskPushNotificationConfigResponse, ae as Message, af as Message1, ag as Message2, ah as MessageSendConfiguration, ai as MessageSendConfiguration1, aj as MessageSendParams, ak as MessageSendParams1, al as MessageSendParams2, am as MethodNotFoundError, an as MutualTLSSecurityScheme, ao as MySchema, ap as OAuth2SecurityScheme, aq as OAuthFlows, ar as OAuthFlows1, as as OpenIdConnectSecurityScheme, at as Part, au as PartBase, av as PasswordOAuthFlow, aw as PasswordOAuthFlow1, ax as PushNotificationAuthenticationInfo, ay as PushNotificationAuthenticationInfo1, az as PushNotificationConfig, aA as PushNotificationConfig1, aB as PushNotificationConfig2, aC as PushNotificationNotSupportedError, aD as SecurityScheme, aE as SecuritySchemeBase, aF as SendMessageRequest, aG as SendMessageSuccessResponse, aH as SendStreamingMessageRequest, aI as SendStreamingMessageSuccessResponse, aJ as SetTaskPushNotificationConfigRequest, aK as SetTaskPushNotificationConfigSuccessResponse, aL as Task, aM as Task1, aN as Task2, aO as TaskArtifactUpdateEvent, aP as TaskIdParams, aQ as TaskIdParams1, aR as TaskIdParams2, aS as TaskNotCancelableError, aT as TaskNotFoundError, aU as TaskPushNotificationConfig, aV as TaskPushNotificationConfig1, aW as TaskPushNotificationConfig2, aX as TaskPushNotificationConfig3, aY as TaskQueryParams, aZ as TaskQueryParams1, a_ as TaskResubscriptionRequest, a$ as TaskState, b0 as TaskStatus, b1 as TaskStatus1, b2 as TaskStatus2, b3 as TaskStatusUpdateEvent, b4 as TextPart, b5 as TransportProtocol, b6 as UnsupportedOperationError } from './extensions-APfrw8gz.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents any valid JSON-RPC response defined in the A2A protocol.
|
|
@@ -575,23 +575,32 @@ var RestTransportHandler = class _RestTransportHandler {
|
|
|
575
575
|
async getAuthenticatedExtendedAgentCard(context) {
|
|
576
576
|
return this.requestHandler.getAuthenticatedExtendedAgentCard(context);
|
|
577
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Validate MessageSendParams.
|
|
580
|
+
*/
|
|
581
|
+
validateMessageSendParams(params) {
|
|
582
|
+
if (!params.message) {
|
|
583
|
+
throw A2AError.invalidParams("message is required");
|
|
584
|
+
}
|
|
585
|
+
if (!params.message.messageId) {
|
|
586
|
+
throw A2AError.invalidParams("message.messageId is required");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
578
589
|
/**
|
|
579
590
|
* Sends a message to the agent.
|
|
580
|
-
* Accepts both snake_case and camelCase input, returns camelCase.
|
|
581
591
|
*/
|
|
582
592
|
async sendMessage(params, context) {
|
|
583
|
-
|
|
584
|
-
return this.requestHandler.sendMessage(
|
|
593
|
+
this.validateMessageSendParams(params);
|
|
594
|
+
return this.requestHandler.sendMessage(params, context);
|
|
585
595
|
}
|
|
586
596
|
/**
|
|
587
597
|
* Sends a message with streaming response.
|
|
588
|
-
* Accepts both snake_case and camelCase input, returns camelCase stream.
|
|
589
598
|
* @throws {A2AError} UnsupportedOperation if streaming not supported
|
|
590
599
|
*/
|
|
591
600
|
async sendMessageStream(params, context) {
|
|
592
601
|
await this.requireCapability("streaming");
|
|
593
|
-
|
|
594
|
-
return this.requestHandler.sendMessageStream(
|
|
602
|
+
this.validateMessageSendParams(params);
|
|
603
|
+
return this.requestHandler.sendMessageStream(params, context);
|
|
595
604
|
}
|
|
596
605
|
/**
|
|
597
606
|
* Gets a task by ID.
|
|
@@ -623,13 +632,17 @@ var RestTransportHandler = class _RestTransportHandler {
|
|
|
623
632
|
}
|
|
624
633
|
/**
|
|
625
634
|
* Sets a push notification configuration.
|
|
626
|
-
* Accepts both snake_case and camelCase input, returns camelCase.
|
|
627
635
|
* @throws {A2AError} PushNotificationNotSupported if push notifications not supported
|
|
628
636
|
*/
|
|
629
637
|
async setTaskPushNotificationConfig(config, context) {
|
|
630
638
|
await this.requireCapability("pushNotifications");
|
|
631
|
-
|
|
632
|
-
|
|
639
|
+
if (!config.taskId) {
|
|
640
|
+
throw A2AError.invalidParams("taskId is required");
|
|
641
|
+
}
|
|
642
|
+
if (!config.pushNotificationConfig) {
|
|
643
|
+
throw A2AError.invalidParams("pushNotificationConfig is required");
|
|
644
|
+
}
|
|
645
|
+
return this.requestHandler.setTaskPushNotificationConfig(config, context);
|
|
633
646
|
}
|
|
634
647
|
/**
|
|
635
648
|
* Lists all push notification configurations for a task.
|
|
@@ -655,28 +668,6 @@ var RestTransportHandler = class _RestTransportHandler {
|
|
|
655
668
|
context
|
|
656
669
|
);
|
|
657
670
|
}
|
|
658
|
-
// ==========================================================================
|
|
659
|
-
// Private Transformation Methods
|
|
660
|
-
// ==========================================================================
|
|
661
|
-
// All type conversion between REST (snake_case) and internal (camelCase) formats
|
|
662
|
-
/**
|
|
663
|
-
* Validates and normalizes message parameters.
|
|
664
|
-
* Accepts both snake_case and camelCase input.
|
|
665
|
-
* @throws {A2AError} InvalidParams if message is missing or conversion fails
|
|
666
|
-
*/
|
|
667
|
-
normalizeMessageParams(input) {
|
|
668
|
-
if (!input.message) {
|
|
669
|
-
throw A2AError.invalidParams("message is required");
|
|
670
|
-
}
|
|
671
|
-
try {
|
|
672
|
-
return this.normalizeMessageSendParams(input);
|
|
673
|
-
} catch (error) {
|
|
674
|
-
if (error instanceof A2AError) throw error;
|
|
675
|
-
throw A2AError.invalidParams(
|
|
676
|
-
error instanceof Error ? error.message : "Invalid message parameters"
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
671
|
/**
|
|
681
672
|
* Static map of capability to error for missing capabilities.
|
|
682
673
|
*/
|
|
@@ -710,86 +701,6 @@ var RestTransportHandler = class _RestTransportHandler {
|
|
|
710
701
|
}
|
|
711
702
|
return parsed;
|
|
712
703
|
}
|
|
713
|
-
/**
|
|
714
|
-
* Normalizes Part input - accepts both snake_case and camelCase for file mimeType.
|
|
715
|
-
*/
|
|
716
|
-
normalizePart(part) {
|
|
717
|
-
if (part.kind === "text") return { kind: "text", text: part.text };
|
|
718
|
-
if (part.kind === "file") {
|
|
719
|
-
const file = this.normalizeFile(part.file);
|
|
720
|
-
return { kind: "file", file, metadata: part.metadata };
|
|
721
|
-
}
|
|
722
|
-
return { kind: "data", data: part.data, metadata: part.metadata };
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Normalizes File input - accepts both snake_case (mime_type) and camelCase (mimeType).
|
|
726
|
-
*/
|
|
727
|
-
normalizeFile(f) {
|
|
728
|
-
const file = f;
|
|
729
|
-
const mimeType = file.mimeType ?? file.mime_type;
|
|
730
|
-
if ("bytes" in file) {
|
|
731
|
-
return { bytes: file.bytes, mimeType, name: file.name };
|
|
732
|
-
}
|
|
733
|
-
return { uri: file.uri, mimeType, name: file.name };
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Normalizes Message input - accepts both snake_case and camelCase.
|
|
737
|
-
*/
|
|
738
|
-
normalizeMessage(input) {
|
|
739
|
-
const m = input;
|
|
740
|
-
const messageId = m.messageId ?? m.message_id;
|
|
741
|
-
if (!messageId) {
|
|
742
|
-
throw A2AError.invalidParams("message.messageId is required");
|
|
743
|
-
}
|
|
744
|
-
if (!m.parts || !Array.isArray(m.parts)) {
|
|
745
|
-
throw A2AError.invalidParams("message.parts must be an array");
|
|
746
|
-
}
|
|
747
|
-
return {
|
|
748
|
-
contextId: m.contextId ?? m.context_id,
|
|
749
|
-
extensions: m.extensions,
|
|
750
|
-
kind: "message",
|
|
751
|
-
messageId,
|
|
752
|
-
metadata: m.metadata,
|
|
753
|
-
parts: m.parts.map((p) => this.normalizePart(p)),
|
|
754
|
-
referenceTaskIds: m.referenceTaskIds ?? m.reference_task_ids,
|
|
755
|
-
role: m.role,
|
|
756
|
-
taskId: m.taskId ?? m.task_id
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Normalizes MessageSendParams - accepts both snake_case and camelCase.
|
|
761
|
-
*/
|
|
762
|
-
normalizeMessageSendParams(input) {
|
|
763
|
-
const p = input;
|
|
764
|
-
const config = p.configuration;
|
|
765
|
-
return {
|
|
766
|
-
configuration: config ? {
|
|
767
|
-
acceptedOutputModes: config.acceptedOutputModes ?? config.accepted_output_modes,
|
|
768
|
-
blocking: config.blocking,
|
|
769
|
-
historyLength: config.historyLength ?? config.history_length
|
|
770
|
-
} : void 0,
|
|
771
|
-
message: this.normalizeMessage(p.message),
|
|
772
|
-
metadata: p.metadata
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Normalizes TaskPushNotificationConfig - accepts both snake_case and camelCase.
|
|
777
|
-
*/
|
|
778
|
-
normalizeTaskPushNotificationConfig(input) {
|
|
779
|
-
const c = input;
|
|
780
|
-
const taskId = c.taskId ?? c.task_id;
|
|
781
|
-
if (!taskId) {
|
|
782
|
-
throw A2AError.invalidParams("taskId is required");
|
|
783
|
-
}
|
|
784
|
-
const pnConfig = c.pushNotificationConfig ?? c.push_notification_config;
|
|
785
|
-
if (!pnConfig) {
|
|
786
|
-
throw A2AError.invalidParams("pushNotificationConfig is required");
|
|
787
|
-
}
|
|
788
|
-
return {
|
|
789
|
-
pushNotificationConfig: pnConfig,
|
|
790
|
-
taskId
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
704
|
};
|
|
794
705
|
|
|
795
706
|
// src/types/pb/a2a_types.ts
|
|
@@ -2793,8 +2704,8 @@ function restHandler(options) {
|
|
|
2793
2704
|
if (statusCode === HTTP_STATUS.NO_CONTENT) {
|
|
2794
2705
|
res.end();
|
|
2795
2706
|
} else {
|
|
2796
|
-
if (!responseType) {
|
|
2797
|
-
throw new Error("Bug: toJson serializer must be provided for non-204 responses.");
|
|
2707
|
+
if (!responseType || body === void 0) {
|
|
2708
|
+
throw new Error("Bug: toJson serializer and body must be provided for non-204 responses.");
|
|
2798
2709
|
}
|
|
2799
2710
|
res.json(responseType.toJSON(body));
|
|
2800
2711
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Express, RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as User, U as UnauthenticatedUser, A as A2ARequestHandler } from '../../a2a_request_handler-BiphzMH4.cjs';
|
|
3
|
+
import { i as AgentCard } from '../../extensions-APfrw8gz.cjs';
|
|
4
4
|
|
|
5
5
|
type UserBuilder = (req: Request) => Promise<User>;
|
|
6
6
|
declare const UserBuilder: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Express, RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as User, U as UnauthenticatedUser, A as A2ARequestHandler } from '../../a2a_request_handler-C9bZITjN.js';
|
|
3
|
+
import { i as AgentCard } from '../../extensions-APfrw8gz.js';
|
|
4
4
|
|
|
5
5
|
type UserBuilder = (req: Request) => Promise<User>;
|
|
6
6
|
declare const UserBuilder: {
|