@cleocode/lafs 1.8.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/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/schemas/v1/conformance-profiles.json +39 -0
- package/dist/schemas/v1/envelope.schema.json +306 -0
- package/dist/schemas/v1/error-registry.json +162 -0
- package/dist/src/a2a/bindings/grpc.d.ts +67 -0
- package/dist/src/a2a/bindings/grpc.js +148 -0
- package/dist/src/a2a/bindings/http.d.ts +102 -0
- package/dist/src/a2a/bindings/http.js +120 -0
- package/dist/src/a2a/bindings/index.d.ts +35 -0
- package/dist/src/a2a/bindings/index.js +79 -0
- package/dist/src/a2a/bindings/jsonrpc.d.ts +77 -0
- package/dist/src/a2a/bindings/jsonrpc.js +114 -0
- package/dist/src/a2a/bridge.d.ts +175 -0
- package/dist/src/a2a/bridge.js +286 -0
- package/dist/src/a2a/extensions.d.ts +121 -0
- package/dist/src/a2a/extensions.js +205 -0
- package/dist/src/a2a/index.d.ts +40 -0
- package/dist/src/a2a/index.js +76 -0
- package/dist/src/a2a/streaming.d.ts +74 -0
- package/dist/src/a2a/streaming.js +265 -0
- package/dist/src/a2a/task-lifecycle.d.ts +109 -0
- package/dist/src/a2a/task-lifecycle.js +313 -0
- package/dist/src/budgetEnforcement.d.ts +84 -0
- package/dist/src/budgetEnforcement.js +328 -0
- package/dist/src/circuit-breaker/index.d.ts +121 -0
- package/dist/src/circuit-breaker/index.js +249 -0
- package/dist/src/cli.d.ts +16 -0
- package/dist/src/cli.js +63 -0
- package/dist/src/compliance.d.ts +31 -0
- package/dist/src/compliance.js +89 -0
- package/dist/src/conformance.d.ts +7 -0
- package/dist/src/conformance.js +248 -0
- package/dist/src/conformanceProfiles.d.ts +11 -0
- package/dist/src/conformanceProfiles.js +34 -0
- package/dist/src/deprecationRegistry.d.ts +13 -0
- package/dist/src/deprecationRegistry.js +39 -0
- package/dist/src/discovery.d.ts +286 -0
- package/dist/src/discovery.js +350 -0
- package/dist/src/envelope.d.ts +60 -0
- package/dist/src/envelope.js +136 -0
- package/dist/src/errorRegistry.d.ts +28 -0
- package/dist/src/errorRegistry.js +36 -0
- package/dist/src/fieldExtraction.d.ts +67 -0
- package/dist/src/fieldExtraction.js +133 -0
- package/dist/src/flagResolver.d.ts +46 -0
- package/dist/src/flagResolver.js +47 -0
- package/dist/src/flagSemantics.d.ts +16 -0
- package/dist/src/flagSemantics.js +45 -0
- package/dist/src/health/index.d.ts +105 -0
- package/dist/src/health/index.js +220 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.js +34 -0
- package/dist/src/mcpAdapter.d.ts +28 -0
- package/dist/src/mcpAdapter.js +281 -0
- package/dist/src/mviProjection.d.ts +19 -0
- package/dist/src/mviProjection.js +116 -0
- package/dist/src/problemDetails.d.ts +34 -0
- package/dist/src/problemDetails.js +45 -0
- package/dist/src/shutdown/index.d.ts +69 -0
- package/dist/src/shutdown/index.js +160 -0
- package/dist/src/tokenEstimator.d.ts +87 -0
- package/dist/src/tokenEstimator.js +238 -0
- package/dist/src/types.d.ts +135 -0
- package/dist/src/types.js +12 -0
- package/dist/src/validateEnvelope.d.ts +15 -0
- package/dist/src/validateEnvelope.js +31 -0
- package/lafs.md +819 -0
- package/package.json +88 -0
- package/schemas/v1/agent-card.schema.json +230 -0
- package/schemas/v1/conformance-profiles.json +39 -0
- package/schemas/v1/context-ledger.schema.json +70 -0
- package/schemas/v1/discovery.schema.json +132 -0
- package/schemas/v1/envelope.schema.json +306 -0
- package/schemas/v1/error-registry.json +162 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Protocol Bindings - Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all binding modules and provides cross-binding
|
|
5
|
+
* error code mapping for consistent error handling across transports.
|
|
6
|
+
*/
|
|
7
|
+
export * from './jsonrpc.js';
|
|
8
|
+
export * from './http.js';
|
|
9
|
+
export * from './grpc.js';
|
|
10
|
+
import { JSONRPC_A2A_ERROR_CODES } from './jsonrpc.js';
|
|
11
|
+
import { A2A_HTTP_STATUS_CODES, A2A_ERROR_TYPE_URIS } from './http.js';
|
|
12
|
+
import { A2A_GRPC_STATUS_CODES, GRPC_STATUS_CODE } from './grpc.js';
|
|
13
|
+
/** All 9 A2A error types */
|
|
14
|
+
const ERROR_TYPES = [
|
|
15
|
+
'TaskNotFound',
|
|
16
|
+
'TaskNotCancelable',
|
|
17
|
+
'PushNotificationNotSupported',
|
|
18
|
+
'UnsupportedOperation',
|
|
19
|
+
'ContentTypeNotSupported',
|
|
20
|
+
'InvalidAgentResponse',
|
|
21
|
+
'AuthenticatedExtendedCardNotConfigured',
|
|
22
|
+
'ExtensionSupportRequired',
|
|
23
|
+
'VersionNotSupported',
|
|
24
|
+
];
|
|
25
|
+
function buildMappings() {
|
|
26
|
+
const map = new Map();
|
|
27
|
+
for (const errorType of ERROR_TYPES) {
|
|
28
|
+
const grpcStatusName = A2A_GRPC_STATUS_CODES[errorType];
|
|
29
|
+
map.set(errorType, {
|
|
30
|
+
jsonRpcCode: JSONRPC_A2A_ERROR_CODES[errorType],
|
|
31
|
+
httpStatus: A2A_HTTP_STATUS_CODES[errorType],
|
|
32
|
+
httpTypeUri: A2A_ERROR_TYPE_URIS[errorType],
|
|
33
|
+
grpcStatus: grpcStatusName,
|
|
34
|
+
grpcCode: GRPC_STATUS_CODE[grpcStatusName],
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return map;
|
|
38
|
+
}
|
|
39
|
+
/** Precomputed cross-binding error mapping for all 9 A2A error types */
|
|
40
|
+
export const A2A_ERROR_MAPPINGS = buildMappings();
|
|
41
|
+
/**
|
|
42
|
+
* Get the complete error code mapping for a given A2A error type.
|
|
43
|
+
* Returns consistent values across JSON-RPC, HTTP, and gRPC.
|
|
44
|
+
*/
|
|
45
|
+
export function getErrorCodeMapping(errorType) {
|
|
46
|
+
const mapping = A2A_ERROR_MAPPINGS.get(errorType);
|
|
47
|
+
if (!mapping) {
|
|
48
|
+
throw new Error(`Unknown A2A error type: ${errorType}`);
|
|
49
|
+
}
|
|
50
|
+
return mapping;
|
|
51
|
+
}
|
|
52
|
+
// Also export A2A_GRPC_ERROR_REASONS for convenience (re-exported from grpc.ts via *)
|
|
53
|
+
// but explicitly reference it here so the cross-binding module is self-documenting
|
|
54
|
+
export { A2A_GRPC_ERROR_REASONS } from './grpc.js';
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Version Negotiation
|
|
57
|
+
// ============================================================================
|
|
58
|
+
export const SUPPORTED_A2A_VERSIONS = ['1.0'];
|
|
59
|
+
export const DEFAULT_A2A_VERSION = '1.0';
|
|
60
|
+
export function parseA2AVersionHeader(headerValue) {
|
|
61
|
+
if (!headerValue)
|
|
62
|
+
return [];
|
|
63
|
+
return headerValue
|
|
64
|
+
.split(',')
|
|
65
|
+
.map((v) => v.trim())
|
|
66
|
+
.filter(Boolean);
|
|
67
|
+
}
|
|
68
|
+
export function negotiateA2AVersion(requestedVersions) {
|
|
69
|
+
if (requestedVersions.length === 0) {
|
|
70
|
+
return DEFAULT_A2A_VERSION;
|
|
71
|
+
}
|
|
72
|
+
const supported = new Set(SUPPORTED_A2A_VERSIONS);
|
|
73
|
+
for (const version of requestedVersions) {
|
|
74
|
+
if (supported.has(version)) {
|
|
75
|
+
return version;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A JSON-RPC Protocol Binding
|
|
3
|
+
*
|
|
4
|
+
* Method constants, error codes, and request/response builders
|
|
5
|
+
* for JSON-RPC 2.0 transport per A2A spec Section 5.3-5.4.
|
|
6
|
+
*/
|
|
7
|
+
/** All JSON-RPC method names defined by the A2A protocol */
|
|
8
|
+
export declare const JSONRPC_METHODS: {
|
|
9
|
+
readonly SendMessage: "message/send";
|
|
10
|
+
readonly SendStreamingMessage: "message/stream";
|
|
11
|
+
readonly GetTask: "tasks/get";
|
|
12
|
+
readonly ListTasks: "tasks/list";
|
|
13
|
+
readonly CancelTask: "tasks/cancel";
|
|
14
|
+
readonly SubscribeToTask: "tasks/resubscribe";
|
|
15
|
+
readonly SetTaskPushNotificationConfig: "tasks/pushNotificationConfig/set";
|
|
16
|
+
readonly GetTaskPushNotificationConfig: "tasks/pushNotificationConfig/get";
|
|
17
|
+
readonly ListTaskPushNotificationConfig: "tasks/pushNotificationConfig/list";
|
|
18
|
+
readonly DeleteTaskPushNotificationConfig: "tasks/pushNotificationConfig/delete";
|
|
19
|
+
readonly GetExtendedAgentCard: "agent/getAuthenticatedExtendedCard";
|
|
20
|
+
};
|
|
21
|
+
export type JsonRpcMethod = (typeof JSONRPC_METHODS)[keyof typeof JSONRPC_METHODS];
|
|
22
|
+
/** Standard JSON-RPC 2.0 error codes */
|
|
23
|
+
export declare const JSONRPC_STANDARD_ERROR_CODES: {
|
|
24
|
+
readonly ParseError: -32700;
|
|
25
|
+
readonly InvalidRequest: -32600;
|
|
26
|
+
readonly MethodNotFound: -32601;
|
|
27
|
+
readonly InvalidParams: -32602;
|
|
28
|
+
readonly InternalError: -32603;
|
|
29
|
+
};
|
|
30
|
+
/** A2A-specific error codes (-32001 through -32009) */
|
|
31
|
+
export declare const JSONRPC_A2A_ERROR_CODES: {
|
|
32
|
+
readonly TaskNotFound: -32001;
|
|
33
|
+
readonly TaskNotCancelable: -32002;
|
|
34
|
+
readonly PushNotificationNotSupported: -32003;
|
|
35
|
+
readonly UnsupportedOperation: -32004;
|
|
36
|
+
readonly ContentTypeNotSupported: -32005;
|
|
37
|
+
readonly InvalidAgentResponse: -32006;
|
|
38
|
+
readonly AuthenticatedExtendedCardNotConfigured: -32007;
|
|
39
|
+
readonly ExtensionSupportRequired: -32008;
|
|
40
|
+
readonly VersionNotSupported: -32009;
|
|
41
|
+
};
|
|
42
|
+
export type A2AErrorType = keyof typeof JSONRPC_A2A_ERROR_CODES;
|
|
43
|
+
export interface JsonRpcRequest {
|
|
44
|
+
jsonrpc: '2.0';
|
|
45
|
+
id: string | number;
|
|
46
|
+
method: string;
|
|
47
|
+
params?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface JsonRpcResponse {
|
|
50
|
+
jsonrpc: '2.0';
|
|
51
|
+
id: string | number | null;
|
|
52
|
+
result: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface JsonRpcErrorResponse {
|
|
55
|
+
jsonrpc: '2.0';
|
|
56
|
+
id: string | number | null;
|
|
57
|
+
error: {
|
|
58
|
+
code: number;
|
|
59
|
+
message: string;
|
|
60
|
+
data?: Record<string, unknown>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Create a JSON-RPC 2.0 request object */
|
|
64
|
+
export declare function createJsonRpcRequest(id: string | number, method: string, params?: Record<string, unknown>): JsonRpcRequest;
|
|
65
|
+
/** Create a JSON-RPC 2.0 success response */
|
|
66
|
+
export declare function createJsonRpcResponse(id: string | number | null, result: unknown): JsonRpcResponse;
|
|
67
|
+
/** Create a JSON-RPC 2.0 error response */
|
|
68
|
+
export declare function createJsonRpcErrorResponse(id: string | number | null, code: number, message: string, data?: Record<string, unknown>): JsonRpcErrorResponse;
|
|
69
|
+
/** Create an A2A-specific JSON-RPC error response by error type name */
|
|
70
|
+
export declare function createA2AErrorResponse(id: string | number | null, errorType: A2AErrorType, message: string, data?: Record<string, unknown>): JsonRpcErrorResponse;
|
|
71
|
+
/** Validate the structure of a JSON-RPC request */
|
|
72
|
+
export declare function validateJsonRpcRequest(input: unknown): {
|
|
73
|
+
valid: boolean;
|
|
74
|
+
errors: string[];
|
|
75
|
+
};
|
|
76
|
+
/** Check if a numeric error code is an A2A-specific error */
|
|
77
|
+
export declare function isA2AError(code: number): boolean;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A JSON-RPC Protocol Binding
|
|
3
|
+
*
|
|
4
|
+
* Method constants, error codes, and request/response builders
|
|
5
|
+
* for JSON-RPC 2.0 transport per A2A spec Section 5.3-5.4.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Method Constants (spec Section 5.3)
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/** All JSON-RPC method names defined by the A2A protocol */
|
|
11
|
+
export const JSONRPC_METHODS = {
|
|
12
|
+
SendMessage: 'message/send',
|
|
13
|
+
SendStreamingMessage: 'message/stream',
|
|
14
|
+
GetTask: 'tasks/get',
|
|
15
|
+
ListTasks: 'tasks/list',
|
|
16
|
+
CancelTask: 'tasks/cancel',
|
|
17
|
+
SubscribeToTask: 'tasks/resubscribe',
|
|
18
|
+
SetTaskPushNotificationConfig: 'tasks/pushNotificationConfig/set',
|
|
19
|
+
GetTaskPushNotificationConfig: 'tasks/pushNotificationConfig/get',
|
|
20
|
+
ListTaskPushNotificationConfig: 'tasks/pushNotificationConfig/list',
|
|
21
|
+
DeleteTaskPushNotificationConfig: 'tasks/pushNotificationConfig/delete',
|
|
22
|
+
GetExtendedAgentCard: 'agent/getAuthenticatedExtendedCard',
|
|
23
|
+
};
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Error Code Constants (spec Section 5.4)
|
|
26
|
+
// ============================================================================
|
|
27
|
+
/** Standard JSON-RPC 2.0 error codes */
|
|
28
|
+
export const JSONRPC_STANDARD_ERROR_CODES = {
|
|
29
|
+
ParseError: -32700,
|
|
30
|
+
InvalidRequest: -32600,
|
|
31
|
+
MethodNotFound: -32601,
|
|
32
|
+
InvalidParams: -32602,
|
|
33
|
+
InternalError: -32603,
|
|
34
|
+
};
|
|
35
|
+
/** A2A-specific error codes (-32001 through -32009) */
|
|
36
|
+
export const JSONRPC_A2A_ERROR_CODES = {
|
|
37
|
+
TaskNotFound: -32001,
|
|
38
|
+
TaskNotCancelable: -32002,
|
|
39
|
+
PushNotificationNotSupported: -32003,
|
|
40
|
+
UnsupportedOperation: -32004,
|
|
41
|
+
ContentTypeNotSupported: -32005,
|
|
42
|
+
InvalidAgentResponse: -32006,
|
|
43
|
+
AuthenticatedExtendedCardNotConfigured: -32007,
|
|
44
|
+
ExtensionSupportRequired: -32008,
|
|
45
|
+
VersionNotSupported: -32009,
|
|
46
|
+
};
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Builders
|
|
49
|
+
// ============================================================================
|
|
50
|
+
/** Create a JSON-RPC 2.0 request object */
|
|
51
|
+
export function createJsonRpcRequest(id, method, params) {
|
|
52
|
+
return {
|
|
53
|
+
jsonrpc: '2.0',
|
|
54
|
+
id,
|
|
55
|
+
method,
|
|
56
|
+
...(params !== undefined && { params }),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Create a JSON-RPC 2.0 success response */
|
|
60
|
+
export function createJsonRpcResponse(id, result) {
|
|
61
|
+
return {
|
|
62
|
+
jsonrpc: '2.0',
|
|
63
|
+
id,
|
|
64
|
+
result,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Create a JSON-RPC 2.0 error response */
|
|
68
|
+
export function createJsonRpcErrorResponse(id, code, message, data) {
|
|
69
|
+
return {
|
|
70
|
+
jsonrpc: '2.0',
|
|
71
|
+
id,
|
|
72
|
+
error: {
|
|
73
|
+
code,
|
|
74
|
+
message,
|
|
75
|
+
...(data !== undefined && { data }),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Create an A2A-specific JSON-RPC error response by error type name */
|
|
80
|
+
export function createA2AErrorResponse(id, errorType, message, data) {
|
|
81
|
+
return createJsonRpcErrorResponse(id, JSONRPC_A2A_ERROR_CODES[errorType], message, data);
|
|
82
|
+
}
|
|
83
|
+
// ============================================================================
|
|
84
|
+
// Validation
|
|
85
|
+
// ============================================================================
|
|
86
|
+
const knownMethods = new Set(Object.values(JSONRPC_METHODS));
|
|
87
|
+
/** Validate the structure of a JSON-RPC request */
|
|
88
|
+
export function validateJsonRpcRequest(input) {
|
|
89
|
+
const errors = [];
|
|
90
|
+
if (typeof input !== 'object' || input === null) {
|
|
91
|
+
return { valid: false, errors: ['Input must be an object'] };
|
|
92
|
+
}
|
|
93
|
+
const obj = input;
|
|
94
|
+
if (obj['jsonrpc'] !== '2.0') {
|
|
95
|
+
errors.push('jsonrpc must be "2.0"');
|
|
96
|
+
}
|
|
97
|
+
if (obj['id'] === undefined || (typeof obj['id'] !== 'string' && typeof obj['id'] !== 'number')) {
|
|
98
|
+
errors.push('id must be a string or number');
|
|
99
|
+
}
|
|
100
|
+
if (typeof obj['method'] !== 'string') {
|
|
101
|
+
errors.push('method must be a string');
|
|
102
|
+
}
|
|
103
|
+
else if (!knownMethods.has(obj['method'])) {
|
|
104
|
+
errors.push(`Unknown method: ${obj['method']}`);
|
|
105
|
+
}
|
|
106
|
+
if (obj['params'] !== undefined && (typeof obj['params'] !== 'object' || obj['params'] === null)) {
|
|
107
|
+
errors.push('params must be an object when provided');
|
|
108
|
+
}
|
|
109
|
+
return { valid: errors.length === 0, errors };
|
|
110
|
+
}
|
|
111
|
+
/** Check if a numeric error code is an A2A-specific error */
|
|
112
|
+
export function isA2AError(code) {
|
|
113
|
+
return code >= -32009 && code <= -32001;
|
|
114
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAFS A2A Bridge v2.0
|
|
3
|
+
*
|
|
4
|
+
* Full integration with official @a2a-js/sdk for Agent-to-Agent communication.
|
|
5
|
+
* Implements A2A Protocol v1.0+ specification.
|
|
6
|
+
*
|
|
7
|
+
* Reference: specs/external/specification.md
|
|
8
|
+
*/
|
|
9
|
+
import { AGENT_CARD_PATH, HTTP_EXTENSION_HEADER } from '@a2a-js/sdk';
|
|
10
|
+
import type { Task, TaskState, TaskStatus, Artifact, Part, Message, AgentCard, MessageSendConfiguration, SendMessageResponse, SendMessageSuccessResponse, JSONRPCErrorResponse } from '@a2a-js/sdk';
|
|
11
|
+
import type { LAFSEnvelope } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for LAFS A2A integration
|
|
14
|
+
*/
|
|
15
|
+
export interface LafsA2AConfig {
|
|
16
|
+
/** Default token budget for all operations */
|
|
17
|
+
defaultBudget?: {
|
|
18
|
+
maxTokens?: number;
|
|
19
|
+
maxItems?: number;
|
|
20
|
+
maxBytes?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Whether to automatically wrap responses in LAFS envelopes */
|
|
23
|
+
envelopeResponses?: boolean;
|
|
24
|
+
/** A2A protocol version to use (default: "1.0") */
|
|
25
|
+
protocolVersion?: string;
|
|
26
|
+
/** Extension URIs to activate for all requests */
|
|
27
|
+
defaultExtensions?: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Request parameters for sending messages
|
|
31
|
+
*/
|
|
32
|
+
export interface LafsSendMessageParams {
|
|
33
|
+
/** Message content */
|
|
34
|
+
message: {
|
|
35
|
+
role: 'user' | 'agent';
|
|
36
|
+
parts: Part[];
|
|
37
|
+
/** Optional message metadata */
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
/** A2A configuration for this request */
|
|
41
|
+
configuration?: MessageSendConfiguration;
|
|
42
|
+
/** Token budget override */
|
|
43
|
+
budget?: {
|
|
44
|
+
maxTokens?: number;
|
|
45
|
+
maxItems?: number;
|
|
46
|
+
maxBytes?: number;
|
|
47
|
+
};
|
|
48
|
+
/** Extensions to activate for this request */
|
|
49
|
+
extensions?: string[];
|
|
50
|
+
/** Context ID for multi-turn conversations */
|
|
51
|
+
contextId?: string;
|
|
52
|
+
/** Task ID for continuing existing task */
|
|
53
|
+
taskId?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wrapper for A2A responses with LAFS envelope support
|
|
57
|
+
*/
|
|
58
|
+
export declare class LafsA2AResult {
|
|
59
|
+
private result;
|
|
60
|
+
private config;
|
|
61
|
+
private requestId;
|
|
62
|
+
constructor(result: SendMessageResponse, config: LafsA2AConfig, requestId: string);
|
|
63
|
+
/**
|
|
64
|
+
* Get the raw A2A response
|
|
65
|
+
*/
|
|
66
|
+
getA2AResult(): SendMessageResponse;
|
|
67
|
+
/**
|
|
68
|
+
* Check if result is an error
|
|
69
|
+
*/
|
|
70
|
+
isError(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get error details if result is an error
|
|
73
|
+
*/
|
|
74
|
+
getError(): JSONRPCErrorResponse | null;
|
|
75
|
+
/**
|
|
76
|
+
* Get success result
|
|
77
|
+
*/
|
|
78
|
+
getSuccess(): SendMessageSuccessResponse | null;
|
|
79
|
+
/**
|
|
80
|
+
* Extract Task from response (if present)
|
|
81
|
+
*/
|
|
82
|
+
getTask(): Task | null;
|
|
83
|
+
/**
|
|
84
|
+
* Extract Message from response (if present)
|
|
85
|
+
*/
|
|
86
|
+
getMessage(): Message | null;
|
|
87
|
+
/**
|
|
88
|
+
* Check if response contains a LAFS envelope
|
|
89
|
+
*/
|
|
90
|
+
hasLafsEnvelope(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Extract LAFS envelope from A2A artifact
|
|
93
|
+
*
|
|
94
|
+
* A2A agents can return LAFS envelopes in artifacts for structured data.
|
|
95
|
+
* This method extracts the envelope from the first artifact containing one.
|
|
96
|
+
*/
|
|
97
|
+
getLafsEnvelope(): LAFSEnvelope | null;
|
|
98
|
+
/**
|
|
99
|
+
* Get token estimate from LAFS envelope
|
|
100
|
+
*/
|
|
101
|
+
getTokenEstimate(): {
|
|
102
|
+
estimated: number;
|
|
103
|
+
budget?: number;
|
|
104
|
+
truncated?: boolean;
|
|
105
|
+
} | null;
|
|
106
|
+
/**
|
|
107
|
+
* Get task status
|
|
108
|
+
*/
|
|
109
|
+
getTaskStatus(): TaskStatus | null;
|
|
110
|
+
/**
|
|
111
|
+
* Get task state
|
|
112
|
+
*/
|
|
113
|
+
getTaskState(): TaskState | null;
|
|
114
|
+
/**
|
|
115
|
+
* Check if task is in a terminal state
|
|
116
|
+
*/
|
|
117
|
+
isTerminal(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Check if task requires input
|
|
120
|
+
*/
|
|
121
|
+
isInputRequired(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Check if task requires authentication
|
|
124
|
+
*/
|
|
125
|
+
isAuthRequired(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Get all artifacts from task
|
|
128
|
+
*/
|
|
129
|
+
getArtifacts(): Artifact[];
|
|
130
|
+
private isDataPart;
|
|
131
|
+
private isLafsEnvelope;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a LAFS envelope artifact for A2A
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const envelope = createEnvelope({
|
|
139
|
+
* success: true,
|
|
140
|
+
* result: { data: '...' },
|
|
141
|
+
* meta: { operation: 'analysis.run' }
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* const artifact = createLafsArtifact(envelope);
|
|
145
|
+
* task.artifacts.push(artifact);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function createLafsArtifact(envelope: LAFSEnvelope): Artifact;
|
|
149
|
+
/**
|
|
150
|
+
* Create a text artifact
|
|
151
|
+
*/
|
|
152
|
+
export declare function createTextArtifact(text: string, name?: string): Artifact;
|
|
153
|
+
/**
|
|
154
|
+
* Create a file artifact
|
|
155
|
+
*/
|
|
156
|
+
export declare function createFileArtifact(fileUrl: string, mediaType: string, filename?: string): Artifact;
|
|
157
|
+
/**
|
|
158
|
+
* Check if an extension is required
|
|
159
|
+
*/
|
|
160
|
+
export declare function isExtensionRequired(agentCard: AgentCard, extensionUri: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Get extension parameters
|
|
163
|
+
*/
|
|
164
|
+
export declare function getExtensionParams(agentCard: AgentCard, extensionUri: string): Record<string, unknown> | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* A2A Agent Card well-known path
|
|
167
|
+
* Reference: specs/external/agent-discovery.md
|
|
168
|
+
*/
|
|
169
|
+
export { AGENT_CARD_PATH };
|
|
170
|
+
/**
|
|
171
|
+
* HTTP header for A2A Extensions
|
|
172
|
+
* Reference: specs/external/extensions.md
|
|
173
|
+
*/
|
|
174
|
+
export { HTTP_EXTENSION_HEADER };
|
|
175
|
+
export type { Task, TaskState, TaskStatus, Artifact, Part, Message, AgentCard, AgentSkill, AgentCapabilities, AgentExtension, PushNotificationConfig, MessageSendConfiguration, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, SendMessageResponse, SendMessageSuccessResponse, JSONRPCErrorResponse, TextPart, DataPart, FilePart, } from '@a2a-js/sdk';
|