@artinet/sdk 0.6.0-preview.2 → 0.6.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 +100 -59
- package/dist/browser/browser.d.ts +2 -7
- package/dist/browser/browser.js +2 -7
- package/dist/browser/config/observability.d.ts +1 -1
- package/dist/browser/create/message-builder.d.ts +1 -1
- package/dist/browser/create/message-builder.js +19 -7
- package/dist/browser/create/task-builder.js +1 -1
- package/dist/browser/messenger/index.d.ts +1 -0
- package/dist/browser/messenger/index.js +1 -0
- package/dist/browser/messenger/messenger.d.ts +119 -0
- package/dist/browser/messenger/messenger.js +245 -0
- package/dist/browser/types/a2a/a2a.d.ts +38 -20
- package/dist/browser/types/a2a/a2a.js +0 -1
- package/dist/browser/types/core/core.d.ts +4 -2
- package/dist/browser/types/index.d.ts +0 -1
- package/dist/browser/types/index.js +0 -1
- package/dist/browser/types/storage.d.ts +2 -14
- package/dist/browser/types/storage.js +0 -4
- package/dist/browser/utils/{common/constants.d.ts → constants.d.ts} +1 -1
- package/dist/{utils/common → browser/utils}/constants.js +1 -1
- package/dist/browser/utils/{common/errors.d.ts → errors.d.ts} +17 -36
- package/dist/browser/utils/errors.js +76 -0
- package/dist/browser/utils/index.d.ts +6 -0
- package/dist/browser/utils/index.js +6 -0
- package/dist/{utils/common → browser/utils}/parse.js +1 -1
- package/dist/{utils/common → browser/utils}/schema-validation.js +2 -2
- package/dist/config/index.d.ts +1 -1
- package/dist/config/observability.d.ts +1 -1
- package/dist/create/agent-builder.d.ts +1 -1
- package/dist/create/create.d.ts +19 -20
- package/dist/create/create.js +33 -101
- package/dist/create/message-builder.d.ts +1 -1
- package/dist/create/message-builder.js +19 -7
- package/dist/create/status-builder.d.ts +4 -0
- package/dist/create/task-builder.js +1 -1
- package/dist/extensions/otel.d.ts +3 -0
- package/dist/extensions/otel.js +3 -0
- package/dist/extensions/pino.d.ts +3 -0
- package/dist/extensions/pino.js +3 -0
- package/dist/extensions/winston.d.ts +3 -0
- package/dist/extensions/winston.js +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/messenger/index.d.ts +1 -0
- package/dist/messenger/index.js +1 -0
- package/dist/messenger/messenger.d.ts +119 -0
- package/dist/messenger/messenger.js +251 -0
- package/dist/server/adapters/a2a_request_handler.d.ts +889 -0
- package/dist/server/adapters/a2a_request_handler.js +241 -0
- package/dist/server/adapters/loadable.d.ts +7 -0
- package/dist/server/adapters/loadable.js +73 -0
- package/dist/server/adapters/notifications.d.ts +26 -0
- package/dist/server/adapters/notifications.js +77 -0
- package/dist/server/express/server.d.ts +24 -18
- package/dist/server/express/server.js +41 -62
- package/dist/server/express/utils.d.ts +14 -0
- package/dist/server/express/{errors.js → utils.js} +22 -0
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +4 -1
- package/dist/server/params.d.ts +115 -0
- package/dist/server/params.js +21 -0
- package/dist/services/a2a/factory/context.d.ts +2 -1
- package/dist/services/a2a/factory/context.js +4 -3
- package/dist/services/a2a/factory/handler.d.ts +1 -1
- package/dist/services/a2a/factory/handler.js +7 -6
- package/dist/services/a2a/factory/service.d.ts +1 -1
- package/dist/services/a2a/factory/service.js +2 -2
- package/dist/services/a2a/factory/state-machine.js +9 -6
- package/dist/services/a2a/handlers/cancel-task.d.ts +1 -1
- package/dist/services/a2a/handlers/get-task.d.ts +1 -1
- package/dist/services/a2a/handlers/resubscribe-task.d.ts +2 -2
- package/dist/services/a2a/handlers/send-message.d.ts +1 -1
- package/dist/services/a2a/handlers/stream-message.d.ts +2 -2
- package/dist/services/a2a/handlers/update.js +7 -9
- package/dist/services/a2a/index.d.ts +0 -1
- package/dist/services/a2a/index.js +0 -1
- package/dist/services/a2a/managers.js +2 -1
- package/dist/services/a2a/messenger.d.ts +1 -1
- package/dist/services/a2a/messenger.js +1 -1
- package/dist/services/a2a/service.d.ts +26 -21
- package/dist/services/a2a/service.js +161 -93
- package/dist/services/a2a/state-machine.d.ts +1 -1
- package/dist/services/a2a/state-machine.js +2 -1
- package/dist/services/a2a/streams.js +1 -1
- package/dist/services/core/manager.d.ts +5 -0
- package/dist/services/core/manager.js +6 -0
- package/dist/services/mcp/service.js +1 -1
- package/dist/{utils/storage → storage}/file.d.ts +4 -2
- package/dist/{utils/storage → storage}/file.js +5 -4
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/sqlite.d.ts +353 -0
- package/dist/storage/sqlite.js +85 -0
- package/dist/transport/trpc/a2a/factory/router.d.ts +16 -16
- package/dist/transport/trpc/a2a/routes/info.d.ts +2 -2
- package/dist/transport/trpc/a2a/routes/message/route.d.ts +3 -3
- package/dist/transport/trpc/a2a/routes/message/route.js +2 -1
- package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +4 -4
- package/dist/transport/trpc/a2a/routes/tasks/route.js +3 -2
- package/dist/types/a2a/a2a.d.ts +38 -20
- package/dist/types/a2a/a2a.js +0 -1
- package/dist/types/core/core.d.ts +4 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/storage.d.ts +2 -14
- package/dist/types/storage.js +0 -4
- package/dist/utils/{common/constants.d.ts → constants.d.ts} +1 -1
- package/dist/{browser/utils/common → utils}/constants.js +1 -1
- package/dist/utils/{common/errors.d.ts → errors.d.ts} +17 -36
- package/dist/utils/errors.js +80 -0
- package/dist/utils/index.d.ts +6 -11
- package/dist/utils/index.js +6 -11
- package/dist/utils/parse.d.ts +7 -0
- package/dist/utils/parse.js +14 -0
- package/dist/utils/schema-validation.d.ts +2 -0
- package/dist/utils/schema-validation.js +12 -0
- package/package.json +35 -22
- package/dist/browser/client/a2a-client.d.ts +0 -127
- package/dist/browser/client/a2a-client.js +0 -233
- package/dist/browser/client/index.d.ts +0 -1
- package/dist/browser/client/index.js +0 -1
- package/dist/browser/transport/rpc/parser.d.ts +0 -15
- package/dist/browser/transport/rpc/parser.js +0 -49
- package/dist/browser/transport/rpc/rpc-client.d.ts +0 -80
- package/dist/browser/transport/rpc/rpc-client.js +0 -189
- package/dist/browser/transport/streaming/event-stream.d.ts +0 -25
- package/dist/browser/transport/streaming/event-stream.js +0 -100
- package/dist/browser/types/client.d.ts +0 -133
- package/dist/browser/types/client.js +0 -5
- package/dist/browser/utils/common/errors.js +0 -95
- package/dist/client/a2a-client.d.ts +0 -127
- package/dist/client/a2a-client.js +0 -237
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +0 -1
- package/dist/server/express/errors.d.ts +0 -9
- package/dist/server/express/index.d.ts +0 -3
- package/dist/server/express/index.js +0 -3
- package/dist/server/express/middeware.d.ts +0 -7
- package/dist/server/express/middeware.js +0 -121
- package/dist/transport/index.d.ts +0 -3
- package/dist/transport/index.js +0 -4
- package/dist/transport/rpc/parser.d.ts +0 -15
- package/dist/transport/rpc/parser.js +0 -49
- package/dist/transport/rpc/rpc-client.d.ts +0 -80
- package/dist/transport/rpc/rpc-client.js +0 -189
- package/dist/transport/streaming/event-stream.d.ts +0 -25
- package/dist/transport/streaming/event-stream.js +0 -100
- package/dist/types/client.d.ts +0 -133
- package/dist/types/client.js +0 -5
- package/dist/utils/common/errors.js +0 -98
- /package/dist/{utils/common → browser/utils}/parse.d.ts +0 -0
- /package/dist/{utils/common → browser/utils}/schema-validation.d.ts +0 -0
- /package/dist/browser/utils/{common/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/browser/utils/{common/utils.js → utils.js} +0 -0
- /package/dist/utils/{common/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/utils/{common/utils.js → utils.js} +0 -0
- /package/dist/utils/{common/zAsyncIterable-v3.d.ts → zAsyncIterable-v3.d.ts} +0 -0
- /package/dist/utils/{common/zAsyncIterable-v3.js → zAsyncIterable-v3.js} +0 -0
- /package/dist/utils/{common/zAsyncIterable.d.ts → zAsyncIterable.d.ts} +0 -0
- /package/dist/utils/{common/zAsyncIterable.js → zAsyncIterable.js} +0 -0
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* HTTP JSON-RPC client utilities.
|
|
7
|
-
* Handles the common pattern of sending JSON-RPC requests and processing responses.
|
|
8
|
-
*/
|
|
9
|
-
import { v4 as uuidv4 } from "uuid";
|
|
10
|
-
import { SystemError, INTERNAL_ERROR, PARSE_ERROR, } from "../../utils/common/errors.js";
|
|
11
|
-
import { parseResponse } from "./parser.js";
|
|
12
|
-
import { logger } from "../../config/index.js";
|
|
13
|
-
/**
|
|
14
|
-
* Creates a JSON-RPC request body with the specified method and parameters.
|
|
15
|
-
*, ErrorCodeParseError
|
|
16
|
-
* @param method The JSON-RPC method name
|
|
17
|
-
* @param params The parameters for the method
|
|
18
|
-
* @param requestId Optional request ID (generates a UUID v4 if not provided)
|
|
19
|
-
* @returns A properly formatted JSON-RPC request object
|
|
20
|
-
*/
|
|
21
|
-
export function createJsonRpcRequest(method, params, requestId = uuidv4()) {
|
|
22
|
-
return {
|
|
23
|
-
jsonrpc: "2.0",
|
|
24
|
-
id: requestId,
|
|
25
|
-
method,
|
|
26
|
-
params,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Sends a JSON-RPC request to the specified endpoint.
|
|
31
|
-
*
|
|
32
|
-
* @param baseUrl The API endpoint URL
|
|
33
|
-
* @param method The JSON-RPC method name
|
|
34
|
-
* @param params The parameters for the method
|
|
35
|
-
* @param headers Custom headers to include in the request
|
|
36
|
-
* @param acceptHeader The desired Accept header ('application/json' or 'text/event-stream')
|
|
37
|
-
* @returns A Promise resolving to the fetch Response object
|
|
38
|
-
* @throws RpcError if there's a network error
|
|
39
|
-
*/
|
|
40
|
-
export async function sendJsonRpcRequest(baseUrl, method, params, headers = {}, acceptHeader = "application/json") {
|
|
41
|
-
const requestBody = createJsonRpcRequest(method, params);
|
|
42
|
-
try {
|
|
43
|
-
return await fetch(baseUrl, {
|
|
44
|
-
method: "POST",
|
|
45
|
-
headers: {
|
|
46
|
-
"Content-Type": "application/json",
|
|
47
|
-
"Access-Control-Allow-Origin": "*",
|
|
48
|
-
Accept: acceptHeader,
|
|
49
|
-
...headers,
|
|
50
|
-
},
|
|
51
|
-
priority: "high",
|
|
52
|
-
mode: "cors",
|
|
53
|
-
keepalive: true,
|
|
54
|
-
body: JSON.stringify(requestBody),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
catch (networkError) {
|
|
58
|
-
logger.error("SendJsonRpcRequest: Network error during RPC call:", networkError);
|
|
59
|
-
// Wrap network errors into a standard error format
|
|
60
|
-
throw INTERNAL_ERROR(networkError);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Sends a GET request to the specified endpoint.
|
|
65
|
-
* This is used for non-JSON-RPC calls like agent card retrieval.
|
|
66
|
-
*
|
|
67
|
-
* @param url The endpoint URL
|
|
68
|
-
* @param headers Custom headers to include in the request
|
|
69
|
-
* @returns A Promise resolving to the fetch Response object
|
|
70
|
-
* @throws RpcError if there's a network error
|
|
71
|
-
*/
|
|
72
|
-
export async function sendGetRequest(url, headers = {}) {
|
|
73
|
-
try {
|
|
74
|
-
return await fetch(url, {
|
|
75
|
-
method: "GET",
|
|
76
|
-
headers: {
|
|
77
|
-
Accept: "application/json",
|
|
78
|
-
...headers,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (networkError) {
|
|
83
|
-
logger.error("SendGetRequest: Network error during GET request:", networkError);
|
|
84
|
-
throw INTERNAL_ERROR(networkError);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Processes a standard JSON-RPC response (non-streaming).
|
|
89
|
-
* Parses the response, validates it, and returns the result payload.
|
|
90
|
-
*
|
|
91
|
-
* @param response The fetch Response object
|
|
92
|
-
* @param expectedMethod Optional method name for logging purposes
|
|
93
|
-
* @returns A promise resolving to the result payload
|
|
94
|
-
* @throws RpcError if there's an error in the response
|
|
95
|
-
*/
|
|
96
|
-
export async function handleJsonRpcResponse(response, expectedMethod) {
|
|
97
|
-
let responseBody = null;
|
|
98
|
-
try {
|
|
99
|
-
responseBody = await response.text();
|
|
100
|
-
if (!response.ok) {
|
|
101
|
-
try {
|
|
102
|
-
// Try to parse error as JSON-RPC
|
|
103
|
-
parseResponse(responseBody);
|
|
104
|
-
// If we get here, it means there was no error in the response
|
|
105
|
-
// But the HTTP status was not OK, so we throw a generic error
|
|
106
|
-
}
|
|
107
|
-
catch (parseError) {
|
|
108
|
-
logger.warn("handleJsonRpcResponse", "Error parsing JSON-RPC response:", parseError);
|
|
109
|
-
}
|
|
110
|
-
// Throw a generic HTTP error if we couldn't extract an RPC error
|
|
111
|
-
throw new Error(`HTTP error ${response.status}: ${response.statusText}${responseBody ? ` - ${responseBody}` : ""}`);
|
|
112
|
-
}
|
|
113
|
-
// Parse and validate the response
|
|
114
|
-
// If it has an error, parseResponse will throw
|
|
115
|
-
// If it doesn't have a result, parseResponse will also throw
|
|
116
|
-
const jsonResponse = parseResponse(responseBody);
|
|
117
|
-
// At this point, we know we have a valid result
|
|
118
|
-
// NonNullable is used in the return type to ensure TypeScript knows this
|
|
119
|
-
return jsonResponse.result;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
logger.error(`handleJsonRpcResponse: Error processing response [${expectedMethod}]:`, error);
|
|
123
|
-
// Re-throw RpcError instances directly, wrap others
|
|
124
|
-
if (error instanceof SystemError) {
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
throw INTERNAL_ERROR(error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Processes a JSON response from a regular GET request.
|
|
134
|
-
* Handles error checking and returns the parsed JSON.
|
|
135
|
-
*
|
|
136
|
-
* @param response The fetch Response object
|
|
137
|
-
* @param endpoint Optional endpoint description for logging purposes
|
|
138
|
-
* @returns A promise resolving to the parsed JSON
|
|
139
|
-
* @throws RpcError if there's a response error
|
|
140
|
-
*/
|
|
141
|
-
export async function handleJsonResponse(response, endpoint) {
|
|
142
|
-
let responseBody = null;
|
|
143
|
-
try {
|
|
144
|
-
responseBody = await response.text();
|
|
145
|
-
if (!response.ok) {
|
|
146
|
-
throw new Error(`HTTP error ${response.status}: ${response.statusText}${responseBody ? ` - ${responseBody}` : ""}`);
|
|
147
|
-
}
|
|
148
|
-
return JSON.parse(responseBody);
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
logger.error(`handleJsonResponse: Error processing response for ${endpoint || "unknown endpoint"}:`, error);
|
|
152
|
-
if (error instanceof SystemError) {
|
|
153
|
-
throw error;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
throw PARSE_ERROR(error);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Sends a JSON-RPC request and processes the response in a single operation.
|
|
162
|
-
* This combines sendJsonRpcRequest and handleJsonRpcResponse into one call.
|
|
163
|
-
*
|
|
164
|
-
* @param baseUrl The API endpoint URL
|
|
165
|
-
* @param method The JSON-RPC method name
|
|
166
|
-
* @param params The parameters for the method
|
|
167
|
-
* @param headers Custom headers to include in the request
|
|
168
|
-
* @param acceptHeader The desired Accept header ('application/json' or 'text/event-stream')
|
|
169
|
-
* @returns A Promise resolving to the result payload
|
|
170
|
-
* @throws RpcError if there's a network error or error in the response
|
|
171
|
-
*/
|
|
172
|
-
export async function executeJsonRpcRequest(baseUrl, method, params, headers = {}, acceptHeader = "application/json") {
|
|
173
|
-
const response = await sendJsonRpcRequest(baseUrl, method, params, headers, acceptHeader);
|
|
174
|
-
return handleJsonRpcResponse(response, method);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Sends a GET request and processes the JSON response.
|
|
178
|
-
* Helper for non-RPC REST endpoints.
|
|
179
|
-
*
|
|
180
|
-
* @param url The endpoint URL
|
|
181
|
-
* @param headers Custom headers to include in the request
|
|
182
|
-
* @param endpoint Optional endpoint description for logging
|
|
183
|
-
* @returns A Promise resolving to the parsed JSON
|
|
184
|
-
* @throws RpcError if there's a network error or error in the response
|
|
185
|
-
*/
|
|
186
|
-
export async function executeGetRequest(url, headers = {}, endpoint) {
|
|
187
|
-
const response = await sendGetRequest(url, headers);
|
|
188
|
-
return handleJsonResponse(response, endpoint);
|
|
189
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { A2A, MCP } from "../../types/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Creates an async generator for processing task events from an SSE stream
|
|
8
|
-
*
|
|
9
|
-
* @template T The type of task event to process (TaskStatusUpdateEvent or TaskArtifactUpdateEvent)
|
|
10
|
-
* @param response The fetch Response object containing the event stream
|
|
11
|
-
* @returns An async generator yielding the specified type of task events from StreamingResponse
|
|
12
|
-
*/
|
|
13
|
-
export declare function handleEventStream<StreamRes extends MCP.JSONRPCResultResponse>(response: Response): AsyncGenerator<NonNullable<StreamRes["result"]>>;
|
|
14
|
-
/**
|
|
15
|
-
* Executes a streaming JSON-RPC request and yields events as they arrive
|
|
16
|
-
*
|
|
17
|
-
* @template Req The type of request being made
|
|
18
|
-
* @template StreamRes The type of streaming response expected
|
|
19
|
-
* @param baseUrl The base URL for the API
|
|
20
|
-
* @param method The JSON-RPC method to call
|
|
21
|
-
* @param params The parameters for the method
|
|
22
|
-
* @param customHeaders Any custom headers to include in the request
|
|
23
|
-
* @returns An AsyncIterable yielding events from the stream
|
|
24
|
-
*/
|
|
25
|
-
export declare function executeStreamEvents<Req extends A2A.A2ARequest, StreamRes extends MCP.JSONRPCResultResponse>(baseUrl: URL, method: Req["method"], params: Req["params"], customHeaders: Record<string, string>): AsyncIterable<NonNullable<StreamRes["result"]>>;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Event stream utilities for handling Server-Sent Events (SSE).
|
|
7
|
-
*/
|
|
8
|
-
import { parseResponse } from "../rpc/parser.js";
|
|
9
|
-
import { createParser, } from "eventsource-parser";
|
|
10
|
-
import { sendJsonRpcRequest } from "../rpc/rpc-client.js";
|
|
11
|
-
import { logger } from "../../config/index.js";
|
|
12
|
-
/**
|
|
13
|
-
* Creates an async generator for processing task events from an SSE stream
|
|
14
|
-
*
|
|
15
|
-
* @template T The type of task event to process (TaskStatusUpdateEvent or TaskArtifactUpdateEvent)
|
|
16
|
-
* @param response The fetch Response object containing the event stream
|
|
17
|
-
* @returns An async generator yielding the specified type of task events from StreamingResponse
|
|
18
|
-
*/
|
|
19
|
-
export async function* handleEventStream(response) {
|
|
20
|
-
if (!response.ok || !response.body) {
|
|
21
|
-
let errorText = null;
|
|
22
|
-
try {
|
|
23
|
-
errorText = await response.text();
|
|
24
|
-
}
|
|
25
|
-
catch (_) { }
|
|
26
|
-
const err = new Error(`HTTP error [${response.status}:${response.statusText}] - ${errorText}`);
|
|
27
|
-
logger.error(`handleEventStream: HTTP error [${response.status}:${response.statusText}] - ${errorText}`, err);
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
// Use eventsource-parser to process the SSE stream
|
|
31
|
-
const reader = response.body.getReader();
|
|
32
|
-
const decoder = new TextDecoder();
|
|
33
|
-
const events = [];
|
|
34
|
-
const parser = createParser({
|
|
35
|
-
onEvent: (event) => {
|
|
36
|
-
if (event.data) {
|
|
37
|
-
if (event.event === "close") {
|
|
38
|
-
logger.debug("handleEventStream", "Stream closed");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const parsedData = parseResponse(event.data);
|
|
43
|
-
const eventResult = parsedData.result;
|
|
44
|
-
if (eventResult) {
|
|
45
|
-
events.push(eventResult);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
logger.warn("handleEventStream", "Failed to parse SSE data", parsedData);
|
|
49
|
-
}
|
|
50
|
-
// if (parsedData.final && parsedData.final === true) {
|
|
51
|
-
// logDebug("handleEventStream", "Stream completed");
|
|
52
|
-
// return;
|
|
53
|
-
// }
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
logger.warn("handleEventStream", "Failed to parse SSE data", e);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
onError: (error) => {
|
|
61
|
-
logger.error("handleEventStream: Error parsing SSE data", error);
|
|
62
|
-
},
|
|
63
|
-
onRetry: (retry) => {
|
|
64
|
-
logger.warn("handleEventStream", "Retrying SSE connection", retry);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
try {
|
|
68
|
-
while (true) {
|
|
69
|
-
const { done, value } = await reader.read();
|
|
70
|
-
if (done)
|
|
71
|
-
break;
|
|
72
|
-
const chunk = decoder.decode(value, { stream: true });
|
|
73
|
-
parser.feed(chunk);
|
|
74
|
-
while (events.length > 0) {
|
|
75
|
-
yield events.shift();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
reader.releaseLock();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Executes a streaming JSON-RPC request and yields events as they arrive
|
|
85
|
-
*
|
|
86
|
-
* @template Req The type of request being made
|
|
87
|
-
* @template StreamRes The type of streaming response expected
|
|
88
|
-
* @param baseUrl The base URL for the API
|
|
89
|
-
* @param method The JSON-RPC method to call
|
|
90
|
-
* @param params The parameters for the method
|
|
91
|
-
* @param customHeaders Any custom headers to include in the request
|
|
92
|
-
* @returns An AsyncIterable yielding events from the stream
|
|
93
|
-
*/
|
|
94
|
-
export async function* executeStreamEvents(baseUrl, method, params, customHeaders) {
|
|
95
|
-
logger.debug("executeStreamEvents", `Sending streaming request to: ${baseUrl.toString()}, method: ${method}`);
|
|
96
|
-
const responsePromise = sendJsonRpcRequest(baseUrl, method, params, customHeaders, "text/event-stream");
|
|
97
|
-
const response = await responsePromise;
|
|
98
|
-
logger.debug("executeStreamEvents", "Response", response);
|
|
99
|
-
yield* handleEventStream(response);
|
|
100
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { A2A } from "./a2a/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* @interface Client
|
|
8
|
-
* @description Defines the standard contract for an A2A (Agent-to-Agent) client implementation.
|
|
9
|
-
* This interface allows consumers to create custom client solutions while ensuring
|
|
10
|
-
* compatibility with the A2A protocol. It outlines the core functionalities
|
|
11
|
-
* required for interacting with an A2A agent server, including task management,
|
|
12
|
-
* capability discovery, and communication configuration.
|
|
13
|
-
*/
|
|
14
|
-
export interface Client {
|
|
15
|
-
/**
|
|
16
|
-
* @description Fetches the agent's metadata (AgentCard) from a well-known path or a fallback path.
|
|
17
|
-
* The AgentCard contains essential information about the agent, such as its capabilities and endpoints.
|
|
18
|
-
* @param {string} wellKnownPath The standard path (e.g., "/.well-known/a2a") to look for the AgentCard.
|
|
19
|
-
* @param {string} fallbackPath An alternative path to check if the well-known path fails.
|
|
20
|
-
* @returns {Promise<A2A.AgentCard>} A promise that resolves with the AgentCard object.
|
|
21
|
-
* @async
|
|
22
|
-
*/
|
|
23
|
-
agentCard(): Promise<A2A.AgentCard>;
|
|
24
|
-
/**
|
|
25
|
-
* @description Refreshes the cached AgentCard information by re-fetching it from the server.
|
|
26
|
-
* Useful when the agent's capabilities or configuration might have changed.
|
|
27
|
-
* @returns {Promise<A2A.AgentCard>} A promise that resolves with the updated AgentCard object.
|
|
28
|
-
* @async
|
|
29
|
-
*/
|
|
30
|
-
refreshAgentCard(): Promise<A2A.AgentCard>;
|
|
31
|
-
/**
|
|
32
|
-
* @description Sends a task request to the agent server.
|
|
33
|
-
* @param {A2A.MessageSendParams} params Parameters required to send the task, including the task definition and metadata.
|
|
34
|
-
* @returns {Promise<A2A.Task | null>} A promise that resolves with the initial Task object representing the submitted task, or null if the submission failed.
|
|
35
|
-
* @async
|
|
36
|
-
*/
|
|
37
|
-
sendMessage(params: A2A.MessageSendParams): Promise<A2A.Message | A2A.Task | null>;
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated Will be removed in v6.Use sendMessage instead.
|
|
40
|
-
* @description Sends a task request to the agent server.
|
|
41
|
-
* @param {MessageSendParams} params Parameters required to send the task, including the task definition and metadata.
|
|
42
|
-
* @returns {Promise<Task | null>} A promise that resolves with the initial Task object representing the submitted task, or null if the submission failed.
|
|
43
|
-
* @async
|
|
44
|
-
*/
|
|
45
|
-
sendTask(params: A2A.MessageSendParams): Promise<A2A.Message | A2A.Task | null>;
|
|
46
|
-
/**
|
|
47
|
-
* @description Sends a task request and subscribes to real-time updates (status changes, artifact updates) for that task.
|
|
48
|
-
* This uses a streaming connection if available.
|
|
49
|
-
* @param {MessageSendParams} params Parameters required to send the task.
|
|
50
|
-
* @returns {AsyncIterable<UpdateEvent>} An async iterable that yields task status and artifact updates.
|
|
51
|
-
* @async
|
|
52
|
-
*/
|
|
53
|
-
sendStreamingMessage(params: A2A.MessageSendParams): AsyncIterable<A2A.Update>;
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Will be removed in v6Use sendStreamingMessage instead.
|
|
56
|
-
* @description Sends a task request and subscribes to real-time updates (status changes, artifact updates) for that task.
|
|
57
|
-
* This uses a streaming connection if available.
|
|
58
|
-
* @param {MessageSendParams} params Parameters required to send the task.
|
|
59
|
-
* @returns {AsyncIterable<UpdateEvent>} An async iterable that yields task status and artifact updates.
|
|
60
|
-
* @async
|
|
61
|
-
*/
|
|
62
|
-
sendTaskSubscribe(params: A2A.MessageSendParams): AsyncIterable<A2A.Update>;
|
|
63
|
-
/**
|
|
64
|
-
* @description Retrieves the current state of a specific task by its ID.
|
|
65
|
-
* @param {A2A.TaskQueryParams} params Parameters containing the task ID to query.
|
|
66
|
-
* @returns {Promise<A2A.Task | null>} A promise that resolves with the Task object, or null if the task is not found.
|
|
67
|
-
* @async
|
|
68
|
-
*/
|
|
69
|
-
getTask(params: A2A.TaskQueryParams): Promise<A2A.Task | null>;
|
|
70
|
-
/**
|
|
71
|
-
* @description Sends a request to cancel an ongoing task.
|
|
72
|
-
* @param {A2A.TaskIdParams} params Parameters containing the ID of the task to cancel.
|
|
73
|
-
* @returns {Promise<A2A.Task | null>} A promise that resolves with the final state of the cancelled Task object, or null if cancellation failed or the task wasn't found.
|
|
74
|
-
* @async
|
|
75
|
-
*/
|
|
76
|
-
cancelTask(params: A2A.TaskIdParams): Promise<A2A.Task | null>;
|
|
77
|
-
/**
|
|
78
|
-
* @description Configures push notifications for a specific task. This allows the client
|
|
79
|
-
* to receive updates asynchronously via a specified webhook URL.
|
|
80
|
-
* Requires the agent to support the 'pushNotifications' capability.
|
|
81
|
-
* @param {A2A.TaskPushNotificationConfig} params The configuration details for the push notification, including the task ID and webhook URL.
|
|
82
|
-
* @returns {Promise<A2A.TaskPushNotificationConfig | null>} A promise that resolves with the applied configuration, or null if the configuration failed.
|
|
83
|
-
* @async
|
|
84
|
-
*/
|
|
85
|
-
setTaskPushNotification(params: A2A.TaskPushNotificationConfig): Promise<A2A.TaskPushNotificationConfig | null>;
|
|
86
|
-
/**
|
|
87
|
-
* @description Retrieves the current push notification configuration for a specific task.
|
|
88
|
-
* @param {A2A.TaskIdParams} params Parameters containing the task ID.
|
|
89
|
-
* @returns {Promise<A2A.TaskPushNotificationConfig | null>} A promise that resolves with the push notification configuration, or null if not configured or not found.
|
|
90
|
-
* @async
|
|
91
|
-
*/
|
|
92
|
-
getTaskPushNotification(params: A2A.TaskIdParams): Promise<A2A.TaskPushNotificationConfig | null>;
|
|
93
|
-
/**
|
|
94
|
-
* @description Resubscribes to updates for an existing task, potentially after a connection drop or client restart.
|
|
95
|
-
* This allows resuming the stream of status and artifact updates.
|
|
96
|
-
* @param {A2A.TaskQueryParams} params Parameters containing the task ID to resubscribe to.
|
|
97
|
-
* @returns {AsyncIterable<UpdateEvent>} An async iterable that yields task status and artifact updates.
|
|
98
|
-
* @async
|
|
99
|
-
*/
|
|
100
|
-
resubscribeTask(params: A2A.TaskQueryParams): AsyncIterable<A2A.Update>;
|
|
101
|
-
/**
|
|
102
|
-
* @description Checks if the agent server supports a specific capability.
|
|
103
|
-
* @param {"streaming" | "pushNotifications" | "stateTransitionHistory"} capability The capability to check for.
|
|
104
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the capability is supported, false otherwise.
|
|
105
|
-
* @async
|
|
106
|
-
*/
|
|
107
|
-
supports(capability: "streaming" | "pushNotifications" | "stateTransitionHistory"): Promise<boolean>;
|
|
108
|
-
/**
|
|
109
|
-
* @description Sets multiple HTTP headers to be included in all subsequent requests made by the client instance.
|
|
110
|
-
* Replaces any previously set headers.
|
|
111
|
-
* @param {Record<string, string>} headers An object containing header names and values.
|
|
112
|
-
* @returns {void}
|
|
113
|
-
*/
|
|
114
|
-
setHeaders(headers: Record<string, string>): void;
|
|
115
|
-
/**
|
|
116
|
-
* @description Adds or updates a single HTTP header for subsequent requests.
|
|
117
|
-
* @param {string} name The name of the header.
|
|
118
|
-
* @param {string} value The value of the header.
|
|
119
|
-
* @returns {void}
|
|
120
|
-
*/
|
|
121
|
-
addHeader(name: string, value: string): void;
|
|
122
|
-
/**
|
|
123
|
-
* @description Removes a specific HTTP header from subsequent requests.
|
|
124
|
-
* @param {string} name The name of the header to remove.
|
|
125
|
-
* @returns {void}
|
|
126
|
-
*/
|
|
127
|
-
removeHeader(name: string): void;
|
|
128
|
-
/**
|
|
129
|
-
* @description Clears all custom HTTP headers previously set on the client instance.
|
|
130
|
-
* @returns {void}
|
|
131
|
-
*/
|
|
132
|
-
clearHeaders(): void;
|
|
133
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { A2A } from "../../types/index.js";
|
|
6
|
-
import * as describe from "../../create/describe.js";
|
|
7
|
-
import { formatJson } from "./utils.js";
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
10
|
-
* @since 0.6.0
|
|
11
|
-
*/
|
|
12
|
-
export class SystemError extends Error {
|
|
13
|
-
constructor(message, code, data) {
|
|
14
|
-
super(message + " " + formatJson({ cause: data }));
|
|
15
|
-
// this.name = "RpcError";
|
|
16
|
-
this.message = message;
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.data = data;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
23
|
-
* @since 0.6.0
|
|
24
|
-
*/
|
|
25
|
-
export const PARSE_ERROR = (data) => new SystemError("Invalid JSON payload", A2A.ErrorCodeParseError, data);
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
28
|
-
* @since 0.6.0
|
|
29
|
-
*/
|
|
30
|
-
export const INVALID_REQUEST = (data) => new SystemError("Request payload validation error", A2A.ErrorCodeInvalidRequest, data);
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
33
|
-
* @since 0.6.0
|
|
34
|
-
*/
|
|
35
|
-
export const METHOD_NOT_FOUND = (data) => new SystemError("Method not found", A2A.ErrorCodeMethodNotFound, data);
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
38
|
-
* @since 0.6.0
|
|
39
|
-
*/
|
|
40
|
-
export const INVALID_PARAMS = (data) => new SystemError("Invalid parameters", A2A.ErrorCodeInvalidParams, data);
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
43
|
-
* @since 0.6.0
|
|
44
|
-
*/
|
|
45
|
-
export const INTERNAL_ERROR = (data) => new SystemError("Internal error", A2A.ErrorCodeInternalError, data);
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
48
|
-
* @since 0.6.0
|
|
49
|
-
*/
|
|
50
|
-
export const TASK_NOT_FOUND = (data) => new SystemError("Task not found", A2A.ErrorCodeTaskNotFound, data);
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
53
|
-
* @since 0.6.0
|
|
54
|
-
*/
|
|
55
|
-
export const TASK_NOT_CANCELABLE = (data) => new SystemError("Task cannot be canceled", A2A.ErrorCodeTaskNotCancelable, data);
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
58
|
-
* @since 0.6.0
|
|
59
|
-
*/
|
|
60
|
-
export const PUSH_NOTIFICATION_NOT_SUPPORTED = (data) => new SystemError("Push Notifications is not supported", A2A.ErrorCodePushNotificationNotSupported, data);
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
63
|
-
* @since 0.6.0
|
|
64
|
-
*/
|
|
65
|
-
export const AUTHENTICATED_EXTENDED_CARD_NOT_CONFIGURED = (data) => new SystemError("Authenticated Extended Card is not configured", A2A.ErrorCodeAuthenticatedExtendedCardNotConfigured, data);
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
68
|
-
* @since 0.6.0
|
|
69
|
-
*/
|
|
70
|
-
export const UNSUPPORTED_OPERATION = (data) => new SystemError("This operation is not supported", A2A.ErrorCodeUnsupportedOperation, data);
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
73
|
-
* @since 0.6.0
|
|
74
|
-
*/
|
|
75
|
-
export const CONTENT_TYPE_NOT_SUPPORTED = (data) => new SystemError("Content type not supported", A2A.ErrorCodeContentTypeNotSupported, data);
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated Use errors from the `@a2a-js/sdk` package instead
|
|
78
|
-
* @since 0.6.0
|
|
79
|
-
*/
|
|
80
|
-
export const INVALID_AGENT_RESPONSE = (data) => new SystemError("Invalid agent response", A2A.ErrorCodeInvalidAgentResponse, data);
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated Use {@link describe.update.failed} instead
|
|
83
|
-
* @since 0.6.0
|
|
84
|
-
*/
|
|
85
|
-
export const FAILED_UPDATE = (taskId, contextId, messageId = "failed-update", errMessage) => {
|
|
86
|
-
return describe.update.failed({
|
|
87
|
-
taskId,
|
|
88
|
-
contextId,
|
|
89
|
-
final: true,
|
|
90
|
-
message: describe.message({
|
|
91
|
-
messageId,
|
|
92
|
-
parts: [{ kind: "text", text: errMessage }],
|
|
93
|
-
}),
|
|
94
|
-
});
|
|
95
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { A2A } from "../types/index.js";
|
|
6
|
-
import type { Client } from "../types/client.js";
|
|
7
|
-
/**
|
|
8
|
-
* A2AClient is the main client class for interacting with Agent2Agent (A2A) protocol-compliant services.
|
|
9
|
-
* It provides methods for sending tasks, retrieving statuses, canceling operations, and handling streaming responses.
|
|
10
|
-
*/
|
|
11
|
-
export declare class A2AClient implements Client {
|
|
12
|
-
private baseUrl;
|
|
13
|
-
private cachedAgentCard;
|
|
14
|
-
private customHeaders;
|
|
15
|
-
private fallbackPath;
|
|
16
|
-
private agentUrl;
|
|
17
|
-
private mergePath;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new A2AClient instance.
|
|
20
|
-
* @param baseUrl The base URL for the A2A server.
|
|
21
|
-
* @param headers Optional custom headers to include in all requests.
|
|
22
|
-
* @param fallbackPath Optional fallback path to use if the agent card is not found at the base URL.
|
|
23
|
-
* @example
|
|
24
|
-
* const client = new A2AClient("http://localhost:4000/a2a");
|
|
25
|
-
* const card = await client.agentCard();
|
|
26
|
-
* console.log(card);
|
|
27
|
-
* @example
|
|
28
|
-
* const client = new A2AClient("http://localhost:4000/a2a", {}, "/agent-card");
|
|
29
|
-
* const card = await client.agentCard();
|
|
30
|
-
* console.log(card);
|
|
31
|
-
*/
|
|
32
|
-
constructor(baseUrl: URL | string, headers?: Record<string, string>, fallbackPath?: string, mergePath?: boolean);
|
|
33
|
-
/**
|
|
34
|
-
* Retrieves the AgentCard from the A2A server.
|
|
35
|
-
* Caches the result after the first successful fetch.
|
|
36
|
-
* @returns A promise resolving to the AgentCard.
|
|
37
|
-
*/
|
|
38
|
-
agentCard(): Promise<A2A.AgentCard>;
|
|
39
|
-
/**
|
|
40
|
-
* Retrieves the AgentCard from the A2A server.
|
|
41
|
-
* @returns A promise resolving to the AgentCard.
|
|
42
|
-
*/
|
|
43
|
-
getAgentCard(): Promise<A2A.AgentCard>;
|
|
44
|
-
/**
|
|
45
|
-
* Refreshes the cached AgentCard by fetching it again from the server.
|
|
46
|
-
* @returns A promise resolving to the updated AgentCard.
|
|
47
|
-
*/
|
|
48
|
-
refreshAgentCard(): Promise<A2A.AgentCard>;
|
|
49
|
-
sendMessage(params: A2A.MessageSendParams): Promise<A2A.Message | A2A.Task | null>;
|
|
50
|
-
sendMessage(params: string | A2A.MessageSendParams["message"]): Promise<A2A.Message | A2A.Task | null>;
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated Use sendMessage instead.
|
|
53
|
-
* Sends a task request to the agent (non-streaming).
|
|
54
|
-
* @param params The parameters for the message/send method.
|
|
55
|
-
* @returns A promise resolving to the Task object or null.
|
|
56
|
-
*/
|
|
57
|
-
sendTask(params: A2A.MessageSendParams): Promise<A2A.Message | A2A.Task | null>;
|
|
58
|
-
/**
|
|
59
|
-
* Sends a Message and returns a stream of status and artifact updates.
|
|
60
|
-
* @param params Task parameters for the request
|
|
61
|
-
* @returns An AsyncIterable that yields TaskStatusUpdateEvent/TaskArtifactUpdateEvent/Task/Message payloads.
|
|
62
|
-
*/
|
|
63
|
-
sendStreamingMessage(params: A2A.MessageSendParams | string): AsyncIterable<A2A.Update>;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Use sendStreamingMessage instead.
|
|
66
|
-
* Sends a task and returns a subscription to status and artifact updates.
|
|
67
|
-
* @param params Task parameters for the request
|
|
68
|
-
* @returns An AsyncIterable that yields TaskStatusUpdateEvent or TaskArtifactUpdateEvent payloads.
|
|
69
|
-
*/
|
|
70
|
-
sendTaskSubscribe(params: A2A.MessageSendParams): AsyncIterable<A2A.Update>;
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves the current state of a task.
|
|
73
|
-
* @param params The parameters for the tasks/get method.
|
|
74
|
-
* @returns A promise resolving to the Task object or null.
|
|
75
|
-
*/
|
|
76
|
-
getTask(params: A2A.TaskQueryParams): Promise<A2A.Task | null>;
|
|
77
|
-
/**
|
|
78
|
-
* Cancels a currently running task.
|
|
79
|
-
* @param params The parameters for the tasks/cancel method.
|
|
80
|
-
* @returns A promise resolving to the updated Task object (usually canceled state) or null.
|
|
81
|
-
*/
|
|
82
|
-
cancelTask(params: A2A.TaskIdParams): Promise<A2A.Task | null>;
|
|
83
|
-
/**
|
|
84
|
-
* Sets or updates the push notification config for a task.
|
|
85
|
-
* @param params The parameters for the tasks/pushNotificationConfig/set method (which is TaskPushNotificationConfig).
|
|
86
|
-
* @returns A promise resolving to the confirmed TaskPushNotificationConfig or null.
|
|
87
|
-
*/
|
|
88
|
-
setTaskPushNotification(params: A2A.TaskPushNotificationConfig): Promise<A2A.TaskPushNotificationConfig | null>;
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves the currently configured push notification config for a task.
|
|
91
|
-
* @param params The parameters for the tasks/pushNotificationConfig/get method.
|
|
92
|
-
* @returns A promise resolving to the TaskPushNotificationConfig or null.
|
|
93
|
-
*/
|
|
94
|
-
getTaskPushNotification(params: A2A.TaskIdParams): Promise<A2A.TaskPushNotificationConfig | null>;
|
|
95
|
-
/**
|
|
96
|
-
* Resubscribes to an existing task's update stream.
|
|
97
|
-
* @param params Parameters identifying the task to resubscribe to
|
|
98
|
-
* @returns An AsyncIterable that yields TaskStatusUpdateEvent or TaskArtifactUpdateEvent payloads.
|
|
99
|
-
*/
|
|
100
|
-
resubscribeTask(params: A2A.TaskQueryParams): AsyncIterable<A2A.Update>;
|
|
101
|
-
/**
|
|
102
|
-
* Checks if the server supports a specific capability based on the agent card.
|
|
103
|
-
* @param capability The capability to check (e.g., 'streaming', 'pushNotifications').
|
|
104
|
-
* @returns A promise resolving to true if the capability is supported.
|
|
105
|
-
*/
|
|
106
|
-
supports(capability: "streaming" | "pushNotifications" | "stateTransitionHistory"): Promise<boolean>;
|
|
107
|
-
/**
|
|
108
|
-
* Sets custom headers to be included in all requests.
|
|
109
|
-
* @param headers A record of header name/value pairs.
|
|
110
|
-
*/
|
|
111
|
-
setHeaders(headers: Record<string, string>): void;
|
|
112
|
-
/**
|
|
113
|
-
* Adds a single custom header to be included in all requests.
|
|
114
|
-
* @param name The header name.
|
|
115
|
-
* @param value The header value.
|
|
116
|
-
*/
|
|
117
|
-
addHeader(name: string, value: string): void;
|
|
118
|
-
/**
|
|
119
|
-
* Removes a custom header.
|
|
120
|
-
* @param name The header name to remove.
|
|
121
|
-
*/
|
|
122
|
-
removeHeader(name: string): void;
|
|
123
|
-
/**
|
|
124
|
-
* Clears all custom headers.
|
|
125
|
-
*/
|
|
126
|
-
clearHeaders(): void;
|
|
127
|
-
}
|