@cleocode/lafs-protocol 1.2.3 → 1.3.2
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 +58 -5
- package/dist/examples/discovery-server.js +4 -4
- 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 +92 -0
- package/dist/src/a2a/bindings/http.js +99 -0
- package/dist/src/a2a/bindings/index.d.ts +31 -0
- package/dist/src/a2a/bindings/index.js +54 -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 +121 -76
- package/dist/src/a2a/bridge.js +185 -89
- package/dist/src/a2a/extensions.d.ts +93 -0
- package/dist/src/a2a/extensions.js +147 -0
- package/dist/src/a2a/index.d.ts +27 -25
- package/dist/src/a2a/index.js +59 -25
- package/dist/src/a2a/task-lifecycle.d.ts +98 -0
- package/dist/src/a2a/task-lifecycle.js +263 -0
- package/dist/src/discovery.d.ts +203 -44
- package/dist/src/discovery.js +211 -165
- package/dist/src/health/index.js +10 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +10 -1
- package/dist/src/types.d.ts +2 -1
- package/lafs.md +1 -1
- package/package.json +14 -1
- package/schemas/v1/agent-card.schema.json +230 -0
package/dist/src/discovery.d.ts
CHANGED
|
@@ -1,10 +1,111 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LAFS Agent Discovery - Express/Fastify Middleware
|
|
3
|
-
* Serves
|
|
3
|
+
* Serves A2A-compliant Agent Card at /.well-known/agent-card.json
|
|
4
|
+
* Maintains backward compatibility with legacy /.well-known/lafs.json
|
|
5
|
+
*
|
|
6
|
+
* A2A v1.0+ Compliant Implementation
|
|
7
|
+
* Reference: specs/external/agent-discovery.md
|
|
4
8
|
*/
|
|
5
9
|
import type { RequestHandler } from "express";
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* A2A Agent Provider information
|
|
12
|
+
*/
|
|
13
|
+
export interface AgentProvider {
|
|
14
|
+
/** Organization URL */
|
|
15
|
+
url: string;
|
|
16
|
+
/** Organization name */
|
|
17
|
+
organization: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A2A Agent Capabilities
|
|
21
|
+
*/
|
|
22
|
+
export interface AgentCapabilities {
|
|
23
|
+
/** Supports streaming responses */
|
|
24
|
+
streaming?: boolean;
|
|
25
|
+
/** Supports push notifications */
|
|
26
|
+
pushNotifications?: boolean;
|
|
27
|
+
/** Supports extended agent card */
|
|
28
|
+
extendedAgentCard?: boolean;
|
|
29
|
+
/** Supported extensions */
|
|
30
|
+
extensions?: AgentExtension[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A2A Agent Extension declaration
|
|
34
|
+
*/
|
|
35
|
+
export interface AgentExtension {
|
|
36
|
+
/** Extension URI (unique identifier) */
|
|
37
|
+
uri: string;
|
|
38
|
+
/** Human-readable description */
|
|
39
|
+
description: string;
|
|
40
|
+
/** Whether the extension is required */
|
|
41
|
+
required: boolean;
|
|
42
|
+
/** Extension-specific parameters */
|
|
43
|
+
params?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A2A Agent Skill
|
|
47
|
+
*/
|
|
48
|
+
export interface AgentSkill {
|
|
49
|
+
/** Skill unique identifier */
|
|
50
|
+
id: string;
|
|
51
|
+
/** Human-readable name */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Detailed description */
|
|
54
|
+
description: string;
|
|
55
|
+
/** Keywords/tags for the skill */
|
|
56
|
+
tags: string[];
|
|
57
|
+
/** Example prompts */
|
|
58
|
+
examples?: string[];
|
|
59
|
+
/** Supported input modes (overrides agent defaults) */
|
|
60
|
+
inputModes?: string[];
|
|
61
|
+
/** Supported output modes (overrides agent defaults) */
|
|
62
|
+
outputModes?: string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Security scheme for authentication (OpenAPI 3.0 style)
|
|
66
|
+
*/
|
|
67
|
+
export interface SecurityScheme {
|
|
68
|
+
type: "http" | "apiKey" | "oauth2" | "openIdConnect";
|
|
69
|
+
description?: string;
|
|
70
|
+
scheme?: string;
|
|
71
|
+
bearerFormat?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A2A v1.0 Agent Card - Standard format for agent discovery
|
|
75
|
+
* Reference: specs/external/specification.md Section 5
|
|
76
|
+
*/
|
|
77
|
+
export interface AgentCard {
|
|
78
|
+
/** JSON Schema URL */
|
|
79
|
+
$schema?: string;
|
|
80
|
+
/** Human-readable agent name */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Detailed description of agent capabilities */
|
|
83
|
+
description: string;
|
|
84
|
+
/** Agent version (SemVer) */
|
|
85
|
+
version: string;
|
|
86
|
+
/** Base URL for A2A endpoints */
|
|
87
|
+
url: string;
|
|
88
|
+
/** Service provider information */
|
|
89
|
+
provider?: AgentProvider;
|
|
90
|
+
/** Agent capabilities */
|
|
91
|
+
capabilities: AgentCapabilities;
|
|
92
|
+
/** Supported input content types */
|
|
93
|
+
defaultInputModes: string[];
|
|
94
|
+
/** Supported output content types */
|
|
95
|
+
defaultOutputModes: string[];
|
|
96
|
+
/** Agent skills/capabilities */
|
|
97
|
+
skills: AgentSkill[];
|
|
98
|
+
/** Security authentication schemes */
|
|
99
|
+
securitySchemes?: Record<string, SecurityScheme>;
|
|
100
|
+
/** Required security schemes */
|
|
101
|
+
security?: Array<Record<string, string[]>>;
|
|
102
|
+
/** Documentation URL */
|
|
103
|
+
documentationUrl?: string;
|
|
104
|
+
/** Icon URL */
|
|
105
|
+
iconUrl?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated Use AgentSkill instead
|
|
8
109
|
*/
|
|
9
110
|
export interface Capability {
|
|
10
111
|
name: string;
|
|
@@ -14,7 +115,7 @@ export interface Capability {
|
|
|
14
115
|
optional?: boolean;
|
|
15
116
|
}
|
|
16
117
|
/**
|
|
17
|
-
*
|
|
118
|
+
* @deprecated Use AgentCard instead
|
|
18
119
|
*/
|
|
19
120
|
export interface ServiceConfig {
|
|
20
121
|
name: string;
|
|
@@ -22,7 +123,7 @@ export interface ServiceConfig {
|
|
|
22
123
|
description?: string;
|
|
23
124
|
}
|
|
24
125
|
/**
|
|
25
|
-
*
|
|
126
|
+
* @deprecated Will be removed in v2.0.0
|
|
26
127
|
*/
|
|
27
128
|
export interface EndpointConfig {
|
|
28
129
|
envelope: string;
|
|
@@ -30,7 +131,7 @@ export interface EndpointConfig {
|
|
|
30
131
|
discovery: string;
|
|
31
132
|
}
|
|
32
133
|
/**
|
|
33
|
-
*
|
|
134
|
+
* @deprecated Use AgentCard instead
|
|
34
135
|
*/
|
|
35
136
|
export interface DiscoveryDocument {
|
|
36
137
|
$schema: string;
|
|
@@ -40,82 +141,115 @@ export interface DiscoveryDocument {
|
|
|
40
141
|
endpoints: EndpointConfig;
|
|
41
142
|
}
|
|
42
143
|
/**
|
|
43
|
-
* Configuration for the discovery middleware
|
|
144
|
+
* Configuration for the discovery middleware (A2A v1.0 format)
|
|
44
145
|
*/
|
|
45
146
|
export interface DiscoveryConfig {
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
/** Endpoint URLs - can be relative paths or absolute URLs */
|
|
51
|
-
endpoints: {
|
|
52
|
-
/** URL for envelope submission endpoint */
|
|
53
|
-
envelope: string;
|
|
54
|
-
/** Optional URL for context ledger endpoint */
|
|
55
|
-
context?: string;
|
|
56
|
-
/** URL for this discovery document (usually auto-detected) */
|
|
57
|
-
discovery?: string;
|
|
58
|
-
};
|
|
147
|
+
/** Agent information (required for A2A v1.0; omit only with legacy 'service') */
|
|
148
|
+
agent?: Omit<AgentCard, '$schema'>;
|
|
149
|
+
/** Base URL for constructing absolute URLs */
|
|
150
|
+
baseUrl?: string;
|
|
59
151
|
/** Cache duration in seconds (default: 3600) */
|
|
60
152
|
cacheMaxAge?: number;
|
|
61
|
-
/** LAFS protocol version (default: "1.0.0") */
|
|
62
|
-
lafsVersion?: string;
|
|
63
153
|
/** Schema URL override */
|
|
64
154
|
schemaUrl?: string;
|
|
65
|
-
/**
|
|
66
|
-
baseUrl?: string;
|
|
67
|
-
/** Optional custom headers to include in response */
|
|
155
|
+
/** Optional custom headers */
|
|
68
156
|
headers?: Record<string, string>;
|
|
157
|
+
/**
|
|
158
|
+
* Automatically include LAFS as an A2A extension in Agent Card.
|
|
159
|
+
* Pass `true` for defaults, or an object to customize parameters.
|
|
160
|
+
*/
|
|
161
|
+
autoIncludeLafsExtension?: boolean | {
|
|
162
|
+
required?: boolean;
|
|
163
|
+
supportsContextLedger?: boolean;
|
|
164
|
+
supportsTokenBudgets?: boolean;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use 'agent' instead
|
|
168
|
+
*/
|
|
169
|
+
service?: ServiceConfig;
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use 'agent.skills' instead
|
|
172
|
+
*/
|
|
173
|
+
capabilities?: Capability[];
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated Use 'agent.url' and individual endpoints
|
|
176
|
+
*/
|
|
177
|
+
endpoints?: {
|
|
178
|
+
envelope: string;
|
|
179
|
+
context?: string;
|
|
180
|
+
discovery?: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use 'agent.version' instead
|
|
184
|
+
*/
|
|
185
|
+
lafsVersion?: string;
|
|
69
186
|
}
|
|
70
187
|
/**
|
|
71
188
|
* Discovery middleware options
|
|
72
189
|
*/
|
|
73
190
|
export interface DiscoveryMiddlewareOptions {
|
|
74
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Primary path to serve Agent Card (default: /.well-known/agent-card.json)
|
|
193
|
+
*/
|
|
75
194
|
path?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Legacy path for backward compatibility (default: /.well-known/lafs.json)
|
|
197
|
+
* @deprecated Will be removed in v2.0.0
|
|
198
|
+
*/
|
|
199
|
+
legacyPath?: string;
|
|
200
|
+
/** Enable legacy path support (default: true) */
|
|
201
|
+
enableLegacyPath?: boolean;
|
|
76
202
|
/** Enable HEAD requests (default: true) */
|
|
77
203
|
enableHead?: boolean;
|
|
78
204
|
/** Enable ETag caching (default: true) */
|
|
79
205
|
enableEtag?: boolean;
|
|
80
206
|
}
|
|
81
207
|
/**
|
|
82
|
-
* Create Express middleware for serving
|
|
208
|
+
* Create Express middleware for serving A2A Agent Card
|
|
209
|
+
*
|
|
210
|
+
* Serves A2A-compliant Agent Card at /.well-known/agent-card.json
|
|
211
|
+
* Maintains backward compatibility with legacy /.well-known/lafs.json
|
|
83
212
|
*
|
|
84
|
-
* @param config - Discovery configuration
|
|
213
|
+
* @param config - Discovery configuration (A2A v1.0 format)
|
|
85
214
|
* @param options - Middleware options
|
|
86
215
|
* @returns Express RequestHandler
|
|
87
216
|
*
|
|
88
217
|
* @example
|
|
89
218
|
* ```typescript
|
|
90
219
|
* import express from "express";
|
|
91
|
-
* import { discoveryMiddleware } from "
|
|
220
|
+
* import { discoveryMiddleware } from "@cleocode/lafs-protocol/discovery";
|
|
92
221
|
*
|
|
93
222
|
* const app = express();
|
|
94
223
|
*
|
|
95
224
|
* app.use(discoveryMiddleware({
|
|
96
|
-
*
|
|
97
|
-
* name: "my-lafs-
|
|
225
|
+
* agent: {
|
|
226
|
+
* name: "my-lafs-agent",
|
|
227
|
+
* description: "A LAFS-compliant agent with A2A support",
|
|
98
228
|
* version: "1.0.0",
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
229
|
+
* url: "https://api.example.com",
|
|
230
|
+
* capabilities: {
|
|
231
|
+
* streaming: true,
|
|
232
|
+
* pushNotifications: false,
|
|
233
|
+
* extensions: []
|
|
234
|
+
* },
|
|
235
|
+
* defaultInputModes: ["application/json", "text/plain"],
|
|
236
|
+
* defaultOutputModes: ["application/json"],
|
|
237
|
+
* skills: [
|
|
238
|
+
* {
|
|
239
|
+
* id: "envelope-processor",
|
|
240
|
+
* name: "Envelope Processor",
|
|
241
|
+
* description: "Process LAFS envelopes",
|
|
242
|
+
* tags: ["lafs", "envelope", "validation"],
|
|
243
|
+
* examples: ["Validate this envelope", "Process envelope data"]
|
|
244
|
+
* }
|
|
245
|
+
* ]
|
|
112
246
|
* }
|
|
113
247
|
* }));
|
|
114
248
|
* ```
|
|
115
249
|
*/
|
|
116
250
|
export declare function discoveryMiddleware(config: DiscoveryConfig, options?: DiscoveryMiddlewareOptions): RequestHandler;
|
|
117
251
|
/**
|
|
118
|
-
* Fastify plugin for
|
|
252
|
+
* Fastify plugin for A2A Agent Card discovery
|
|
119
253
|
*
|
|
120
254
|
* @param fastify - Fastify instance
|
|
121
255
|
* @param options - Plugin options
|
|
@@ -124,4 +258,29 @@ export declare function discoveryFastifyPlugin(fastify: unknown, options: {
|
|
|
124
258
|
config: DiscoveryConfig;
|
|
125
259
|
path?: string;
|
|
126
260
|
}): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* BREAKING CHANGES v1.2.3 → v2.0.0:
|
|
263
|
+
*
|
|
264
|
+
* 1. Discovery Endpoint Path
|
|
265
|
+
* - OLD: /.well-known/lafs.json
|
|
266
|
+
* - NEW: /.well-known/agent-card.json
|
|
267
|
+
* - MIGRATION: Update client code to use new path
|
|
268
|
+
* - BACKWARD COMPAT: Legacy path still works but logs deprecation warning
|
|
269
|
+
*
|
|
270
|
+
* 2. Discovery Document Format
|
|
271
|
+
* - OLD: DiscoveryDocument interface (lafs_version, service, capabilities, endpoints)
|
|
272
|
+
* - NEW: AgentCard interface (A2A v1.0 compliant)
|
|
273
|
+
* - MIGRATION: Update config from 'service' to 'agent' format
|
|
274
|
+
* - BACKWARD COMPAT: Legacy config format automatically converted with warning
|
|
275
|
+
*
|
|
276
|
+
* 3. Type Names
|
|
277
|
+
* - Capability → AgentSkill (renamed to align with A2A spec)
|
|
278
|
+
* - ServiceConfig → AgentCard (renamed)
|
|
279
|
+
* - All old types marked as @deprecated
|
|
280
|
+
*
|
|
281
|
+
* 4. Removed in v2.0.0
|
|
282
|
+
* - Legacy path support will be removed
|
|
283
|
+
* - Old type definitions will be removed
|
|
284
|
+
* - Automatic config migration will be removed
|
|
285
|
+
*/
|
|
127
286
|
export default discoveryMiddleware;
|