@cleocode/lafs 2026.3.74 → 2026.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +97 -68
- package/dist/schemas/v1/agent-card.schema.json +230 -0
- package/dist/schemas/v1/conformance-profiles.json +0 -0
- package/dist/schemas/v1/context-ledger.schema.json +70 -0
- package/dist/schemas/v1/discovery.schema.json +132 -0
- package/dist/schemas/v1/envelope.schema.json +0 -0
- package/dist/schemas/v1/error-registry.json +0 -0
- package/dist/src/a2a/bindings/grpc.d.ts +118 -11
- package/dist/src/a2a/bindings/grpc.d.ts.map +1 -0
- package/dist/src/a2a/bindings/grpc.js +80 -8
- package/dist/src/a2a/bindings/grpc.js.map +1 -0
- package/dist/src/a2a/bindings/http.d.ts +131 -15
- package/dist/src/a2a/bindings/http.d.ts.map +1 -0
- package/dist/src/a2a/bindings/http.js +101 -14
- package/dist/src/a2a/bindings/http.js.map +1 -0
- package/dist/src/a2a/bindings/index.d.ts +83 -9
- package/dist/src/a2a/bindings/index.d.ts.map +1 -0
- package/dist/src/a2a/bindings/index.js +74 -6
- package/dist/src/a2a/bindings/index.js.map +1 -0
- package/dist/src/a2a/bindings/jsonrpc.d.ts +194 -9
- package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -0
- package/dist/src/a2a/bindings/jsonrpc.js +155 -10
- package/dist/src/a2a/bindings/jsonrpc.js.map +1 -0
- package/dist/src/a2a/bridge.d.ts +237 -44
- package/dist/src/a2a/bridge.d.ts.map +1 -0
- package/dist/src/a2a/bridge.js +187 -48
- package/dist/src/a2a/bridge.js.map +1 -0
- package/dist/src/a2a/extensions.d.ts +222 -12
- package/dist/src/a2a/extensions.d.ts.map +1 -0
- package/dist/src/a2a/extensions.js +178 -13
- package/dist/src/a2a/extensions.js.map +1 -0
- package/dist/src/a2a/index.d.ts +10 -7
- package/dist/src/a2a/index.d.ts.map +1 -0
- package/dist/src/a2a/index.js +24 -27
- package/dist/src/a2a/index.js.map +1 -0
- package/dist/src/a2a/streaming.d.ts +276 -3
- package/dist/src/a2a/streaming.d.ts.map +1 -0
- package/dist/src/a2a/streaming.js +255 -11
- package/dist/src/a2a/streaming.js.map +1 -0
- package/dist/src/a2a/task-lifecycle.d.ts +341 -20
- package/dist/src/a2a/task-lifecycle.d.ts.map +1 -0
- package/dist/src/a2a/task-lifecycle.js +327 -26
- package/dist/src/a2a/task-lifecycle.js.map +1 -0
- package/dist/src/budgetEnforcement.d.ts +93 -20
- package/dist/src/budgetEnforcement.d.ts.map +1 -0
- package/dist/src/budgetEnforcement.js +146 -31
- package/dist/src/budgetEnforcement.js.map +1 -0
- package/dist/src/circuit-breaker/index.d.ts +260 -10
- package/dist/src/circuit-breaker/index.d.ts.map +1 -0
- package/dist/src/circuit-breaker/index.js +226 -14
- package/dist/src/circuit-breaker/index.js.map +1 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +12 -11
- package/dist/src/cli.js.map +1 -0
- package/dist/src/compliance.d.ts +180 -3
- package/dist/src/compliance.d.ts.map +1 -0
- package/dist/src/compliance.js +114 -13
- package/dist/src/compliance.js.map +1 -0
- package/dist/src/conformance.d.ts +55 -2
- package/dist/src/conformance.d.ts.map +1 -0
- package/dist/src/conformance.js +124 -76
- package/dist/src/conformance.js.map +1 -0
- package/dist/src/conformanceProfiles.d.ts +68 -1
- package/dist/src/conformanceProfiles.d.ts.map +1 -0
- package/dist/src/conformanceProfiles.js +53 -1
- package/dist/src/conformanceProfiles.js.map +1 -0
- package/dist/src/deprecationRegistry.d.ts +82 -1
- package/dist/src/deprecationRegistry.d.ts.map +1 -0
- package/dist/src/deprecationRegistry.js +58 -7
- package/dist/src/deprecationRegistry.js.map +1 -0
- package/dist/src/discovery.d.ts +347 -65
- package/dist/src/discovery.d.ts.map +1 -0
- package/dist/src/discovery.js +130 -72
- package/dist/src/discovery.js.map +1 -0
- package/dist/src/envelope.d.ts +262 -9
- package/dist/src/envelope.d.ts.map +1 -0
- package/dist/src/envelope.js +179 -15
- package/dist/src/envelope.js.map +1 -0
- package/dist/src/errorRegistry.d.ts +163 -3
- package/dist/src/errorRegistry.d.ts.map +1 -0
- package/dist/src/errorRegistry.js +119 -3
- package/dist/src/errorRegistry.js.map +1 -0
- package/dist/src/fieldExtraction.d.ts +128 -27
- package/dist/src/fieldExtraction.d.ts.map +1 -0
- package/dist/src/fieldExtraction.js +100 -27
- package/dist/src/fieldExtraction.js.map +1 -0
- package/dist/src/flagResolver.d.ts +77 -10
- package/dist/src/flagResolver.d.ts.map +1 -0
- package/dist/src/flagResolver.js +22 -5
- package/dist/src/flagResolver.js.map +1 -0
- package/dist/src/flagSemantics.d.ts +80 -4
- package/dist/src/flagSemantics.d.ts.map +1 -0
- package/dist/src/flagSemantics.js +78 -11
- package/dist/src/flagSemantics.js.map +1 -0
- package/dist/src/health/index.d.ts +103 -9
- package/dist/src/health/index.d.ts.map +1 -0
- package/dist/src/health/index.js +75 -26
- package/dist/src/health/index.js.map +1 -0
- package/dist/src/index.d.ts +34 -23
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +40 -28
- package/dist/src/index.js.map +1 -0
- package/dist/src/mviProjection.d.ts +43 -6
- package/dist/src/mviProjection.d.ts.map +1 -0
- package/dist/src/mviProjection.js +32 -5
- package/dist/src/mviProjection.js.map +1 -0
- package/dist/src/native-loader.d.ts +49 -0
- package/dist/src/native-loader.d.ts.map +1 -0
- package/dist/src/native-loader.js +56 -0
- package/dist/src/native-loader.js.map +1 -0
- package/dist/src/problemDetails.d.ts +71 -4
- package/dist/src/problemDetails.d.ts.map +1 -0
- package/dist/src/problemDetails.js +27 -3
- package/dist/src/problemDetails.js.map +1 -0
- package/dist/src/shutdown/index.d.ts +103 -9
- package/dist/src/shutdown/index.d.ts.map +1 -0
- package/dist/src/shutdown/index.js +78 -12
- package/dist/src/shutdown/index.js.map +1 -0
- package/dist/src/tokenEstimator.d.ts +98 -11
- package/dist/src/tokenEstimator.d.ts.map +1 -0
- package/dist/src/tokenEstimator.js +91 -13
- package/dist/src/tokenEstimator.js.map +1 -0
- package/dist/src/types.d.ts +477 -11
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +76 -2
- package/dist/src/types.js.map +1 -0
- package/dist/src/validateEnvelope.d.ts +61 -2
- package/dist/src/validateEnvelope.d.ts.map +1 -0
- package/dist/src/validateEnvelope.js +81 -14
- package/dist/src/validateEnvelope.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/lafs.md +3 -4
- package/package.json +14 -12
- package/schemas/v1/agent-card.schema.json +0 -0
- package/schemas/v1/conformance-profiles.json +0 -0
- package/schemas/v1/context-ledger.schema.json +0 -0
- package/schemas/v1/discovery.schema.json +0 -0
- package/schemas/v1/envelope.schema.json +0 -0
- package/schemas/v1/error-registry.json +0 -0
- package/dist/src/mcpAdapter.d.ts +0 -28
- package/dist/src/mcpAdapter.js +0 -281
package/dist/src/a2a/bridge.js
CHANGED
|
@@ -4,41 +4,59 @@
|
|
|
4
4
|
* Full integration with official @a2a-js/sdk for Agent-to-Agent communication.
|
|
5
5
|
* Implements A2A Protocol v1.0+ specification.
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Provides the core bridge between LAFS envelopes and A2A protocol types.
|
|
9
|
+
* Includes a result wrapper ({@link LafsA2AResult}) for extracting typed data
|
|
10
|
+
* from A2A responses, artifact creation helpers for LAFS envelopes, text, and
|
|
11
|
+
* files, and extension introspection utilities.
|
|
12
|
+
*
|
|
7
13
|
* Reference: specs/external/specification.md
|
|
8
14
|
*/
|
|
9
|
-
|
|
10
|
-
// Imports - Use official A2A SDK types
|
|
11
|
-
// ============================================================================
|
|
12
|
-
import { AGENT_CARD_PATH, HTTP_EXTENSION_HEADER, } from '@a2a-js/sdk';
|
|
15
|
+
import { AGENT_CARD_PATH, HTTP_EXTENSION_HEADER } from '@a2a-js/sdk';
|
|
13
16
|
// ============================================================================
|
|
14
17
|
// Result Wrapper
|
|
15
18
|
// ============================================================================
|
|
16
19
|
/**
|
|
17
|
-
* Wrapper for A2A responses with LAFS envelope support
|
|
20
|
+
* Wrapper for A2A responses with LAFS envelope support.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Provides typed accessors for extracting tasks, messages, LAFS envelopes,
|
|
24
|
+
* token estimates, and state information from raw A2A `SendMessageResponse`
|
|
25
|
+
* objects. All methods are null-safe and return `null` when the expected
|
|
26
|
+
* data is not present.
|
|
18
27
|
*/
|
|
19
28
|
export class LafsA2AResult {
|
|
20
29
|
result;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Create a LafsA2AResult wrapper.
|
|
32
|
+
*
|
|
33
|
+
* @param result - Raw A2A SendMessageResponse to wrap
|
|
34
|
+
* @param _config - LAFS A2A configuration (reserved for future use)
|
|
35
|
+
* @param _requestId - Request ID for correlation (reserved for future use)
|
|
36
|
+
*/
|
|
37
|
+
constructor(result, _config, _requestId) {
|
|
24
38
|
this.result = result;
|
|
25
|
-
this.config = config;
|
|
26
|
-
this.requestId = requestId;
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
|
-
* Get the raw A2A response
|
|
41
|
+
* Get the raw A2A response.
|
|
42
|
+
*
|
|
43
|
+
* @returns The underlying SendMessageResponse object
|
|
30
44
|
*/
|
|
31
45
|
getA2AResult() {
|
|
32
46
|
return this.result;
|
|
33
47
|
}
|
|
34
48
|
/**
|
|
35
|
-
* Check if result is an error
|
|
49
|
+
* Check if the result is an error response.
|
|
50
|
+
*
|
|
51
|
+
* @returns True if the response contains a JSON-RPC error
|
|
36
52
|
*/
|
|
37
53
|
isError() {
|
|
38
54
|
return 'error' in this.result;
|
|
39
55
|
}
|
|
40
56
|
/**
|
|
41
|
-
* Get error details if result is an error
|
|
57
|
+
* Get error details if the result is an error.
|
|
58
|
+
*
|
|
59
|
+
* @returns The JSON-RPC error response, or null if the result is a success
|
|
42
60
|
*/
|
|
43
61
|
getError() {
|
|
44
62
|
if (this.isError()) {
|
|
@@ -47,7 +65,9 @@ export class LafsA2AResult {
|
|
|
47
65
|
return null;
|
|
48
66
|
}
|
|
49
67
|
/**
|
|
50
|
-
* Get success result
|
|
68
|
+
* Get the success result.
|
|
69
|
+
*
|
|
70
|
+
* @returns The success response, or null if the result is an error
|
|
51
71
|
*/
|
|
52
72
|
getSuccess() {
|
|
53
73
|
if (!this.isError()) {
|
|
@@ -56,7 +76,13 @@ export class LafsA2AResult {
|
|
|
56
76
|
return null;
|
|
57
77
|
}
|
|
58
78
|
/**
|
|
59
|
-
* Extract Task from response (if present)
|
|
79
|
+
* Extract a Task from the response (if present).
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* Checks the success result for an object with `id` and `status` properties,
|
|
83
|
+
* which identifies it as a Task rather than a Message.
|
|
84
|
+
*
|
|
85
|
+
* @returns The extracted Task, or null if not present or result is an error
|
|
60
86
|
*/
|
|
61
87
|
getTask() {
|
|
62
88
|
const success = this.getSuccess();
|
|
@@ -73,7 +99,13 @@ export class LafsA2AResult {
|
|
|
73
99
|
return null;
|
|
74
100
|
}
|
|
75
101
|
/**
|
|
76
|
-
* Extract Message from response (if present)
|
|
102
|
+
* Extract a Message from the response (if present).
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Checks the success result for an object with `messageId` but without
|
|
106
|
+
* `status`, which distinguishes it from a Task.
|
|
107
|
+
*
|
|
108
|
+
* @returns The extracted Message, or null if not present or result is an error
|
|
77
109
|
*/
|
|
78
110
|
getMessage() {
|
|
79
111
|
const success = this.getSuccess();
|
|
@@ -89,16 +121,22 @@ export class LafsA2AResult {
|
|
|
89
121
|
return null;
|
|
90
122
|
}
|
|
91
123
|
/**
|
|
92
|
-
* Check if response contains a LAFS envelope
|
|
124
|
+
* Check if the response contains a LAFS envelope.
|
|
125
|
+
*
|
|
126
|
+
* @returns True if a LAFS envelope was found in the task's artifacts
|
|
93
127
|
*/
|
|
94
128
|
hasLafsEnvelope() {
|
|
95
129
|
return this.getLafsEnvelope() !== null;
|
|
96
130
|
}
|
|
97
131
|
/**
|
|
98
|
-
* Extract LAFS envelope from A2A artifact
|
|
132
|
+
* Extract a LAFS envelope from A2A artifact.
|
|
99
133
|
*
|
|
134
|
+
* @remarks
|
|
100
135
|
* A2A agents can return LAFS envelopes in artifacts for structured data.
|
|
101
|
-
* This method
|
|
136
|
+
* This method scans all artifacts for a DataPart containing an object
|
|
137
|
+
* with `$schema`, `_meta`, and `success` fields (the LAFS envelope shape).
|
|
138
|
+
*
|
|
139
|
+
* @returns The first LAFS envelope found, or null if none present
|
|
102
140
|
*/
|
|
103
141
|
getLafsEnvelope() {
|
|
104
142
|
const task = this.getTask();
|
|
@@ -117,7 +155,14 @@ export class LafsA2AResult {
|
|
|
117
155
|
return null;
|
|
118
156
|
}
|
|
119
157
|
/**
|
|
120
|
-
* Get token estimate from LAFS envelope
|
|
158
|
+
* Get token estimate from LAFS envelope.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* Extracts the `_tokenEstimate` field from the LAFS envelope's `_meta`
|
|
162
|
+
* section, which contains estimated token usage, budget, and truncation
|
|
163
|
+
* information.
|
|
164
|
+
*
|
|
165
|
+
* @returns Token estimate object, or null if no envelope or no estimate present
|
|
121
166
|
*/
|
|
122
167
|
getTokenEstimate() {
|
|
123
168
|
const envelope = this.getLafsEnvelope();
|
|
@@ -128,53 +173,65 @@ export class LafsA2AResult {
|
|
|
128
173
|
return meta._tokenEstimate ?? null;
|
|
129
174
|
}
|
|
130
175
|
/**
|
|
131
|
-
* Get task status
|
|
176
|
+
* Get the task status.
|
|
177
|
+
*
|
|
178
|
+
* @returns The task's current status, or null if no task is present
|
|
132
179
|
*/
|
|
133
180
|
getTaskStatus() {
|
|
134
181
|
return this.getTask()?.status ?? null;
|
|
135
182
|
}
|
|
136
183
|
/**
|
|
137
|
-
* Get task state
|
|
184
|
+
* Get the task state.
|
|
185
|
+
*
|
|
186
|
+
* @returns The task's current state string, or null if no task is present
|
|
138
187
|
*/
|
|
139
188
|
getTaskState() {
|
|
140
189
|
return this.getTaskStatus()?.state ?? null;
|
|
141
190
|
}
|
|
142
191
|
/**
|
|
143
|
-
* Check if task is in a terminal state
|
|
192
|
+
* Check if the task is in a terminal state.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* Terminal states are `completed`, `failed`, `canceled`, and `rejected`.
|
|
196
|
+
*
|
|
197
|
+
* @returns True if the task is in a terminal state, false otherwise or if no task is present
|
|
144
198
|
*/
|
|
145
199
|
isTerminal() {
|
|
146
200
|
const state = this.getTaskState();
|
|
147
201
|
if (!state)
|
|
148
202
|
return false;
|
|
149
|
-
const terminalStates = [
|
|
150
|
-
'completed',
|
|
151
|
-
'failed',
|
|
152
|
-
'canceled',
|
|
153
|
-
'rejected'
|
|
154
|
-
];
|
|
203
|
+
const terminalStates = ['completed', 'failed', 'canceled', 'rejected'];
|
|
155
204
|
return terminalStates.includes(state);
|
|
156
205
|
}
|
|
157
206
|
/**
|
|
158
|
-
* Check if task requires input
|
|
207
|
+
* Check if the task requires user input.
|
|
208
|
+
*
|
|
209
|
+
* @returns True if the task state is `input-required`
|
|
159
210
|
*/
|
|
160
211
|
isInputRequired() {
|
|
161
212
|
return this.getTaskState() === 'input-required';
|
|
162
213
|
}
|
|
163
214
|
/**
|
|
164
|
-
* Check if task requires authentication
|
|
215
|
+
* Check if the task requires authentication.
|
|
216
|
+
*
|
|
217
|
+
* @returns True if the task state is `auth-required`
|
|
165
218
|
*/
|
|
166
219
|
isAuthRequired() {
|
|
167
220
|
return this.getTaskState() === 'auth-required';
|
|
168
221
|
}
|
|
169
222
|
/**
|
|
170
|
-
* Get all artifacts from task
|
|
223
|
+
* Get all artifacts from the task.
|
|
224
|
+
*
|
|
225
|
+
* @returns Array of task artifacts, or empty array if no task or no artifacts
|
|
171
226
|
*/
|
|
172
227
|
getArtifacts() {
|
|
173
228
|
return this.getTask()?.artifacts ?? [];
|
|
174
229
|
}
|
|
230
|
+
/** Type guard: checks whether a Part is a DataPart by inspecting its `kind` field. */
|
|
175
231
|
isDataPart(part) {
|
|
176
232
|
return part.kind === 'data';
|
|
177
233
|
}
|
|
234
|
+
/** Heuristic check: returns true if the data object looks like a LAFS envelope (has `$schema`, `_meta`, `success`). */
|
|
178
235
|
isLafsEnvelope(data) {
|
|
179
236
|
return (typeof data === 'object' &&
|
|
180
237
|
data !== null &&
|
|
@@ -187,7 +244,15 @@ export class LafsA2AResult {
|
|
|
187
244
|
// LAFS Artifact Creation Helpers
|
|
188
245
|
// ============================================================================
|
|
189
246
|
/**
|
|
190
|
-
* Create a LAFS envelope artifact for A2A
|
|
247
|
+
* Create a LAFS envelope artifact for A2A.
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* Wraps a LAFS envelope in an A2A Artifact with a DataPart. The artifact
|
|
251
|
+
* is tagged with LAFS version and content type metadata for identification
|
|
252
|
+
* by consumers.
|
|
253
|
+
*
|
|
254
|
+
* @param envelope - LAFS envelope to wrap as an artifact
|
|
255
|
+
* @returns A2A Artifact containing the envelope as a DataPart
|
|
191
256
|
*
|
|
192
257
|
* @example
|
|
193
258
|
* ```typescript
|
|
@@ -206,10 +271,12 @@ export function createLafsArtifact(envelope) {
|
|
|
206
271
|
artifactId: generateId(),
|
|
207
272
|
name: 'lafs_response',
|
|
208
273
|
description: 'LAFS-formatted response envelope',
|
|
209
|
-
parts: [
|
|
274
|
+
parts: [
|
|
275
|
+
{
|
|
210
276
|
kind: 'data',
|
|
211
277
|
data: envelope,
|
|
212
|
-
}
|
|
278
|
+
},
|
|
279
|
+
],
|
|
213
280
|
metadata: {
|
|
214
281
|
'x-lafs-version': '2.0.0',
|
|
215
282
|
'x-content-type': 'application/vnd.lafs.envelope+json',
|
|
@@ -217,7 +284,19 @@ export function createLafsArtifact(envelope) {
|
|
|
217
284
|
};
|
|
218
285
|
}
|
|
219
286
|
/**
|
|
220
|
-
* Create a text artifact
|
|
287
|
+
* Create a text artifact.
|
|
288
|
+
*
|
|
289
|
+
* @remarks
|
|
290
|
+
* Wraps a plain text string in an A2A Artifact with a TextPart.
|
|
291
|
+
*
|
|
292
|
+
* @param text - Text content for the artifact
|
|
293
|
+
* @param name - Display name for the artifact
|
|
294
|
+
* @returns A2A Artifact containing the text as a TextPart
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const artifact = createTextArtifact('Hello, world!', 'greeting');
|
|
299
|
+
* ```
|
|
221
300
|
*/
|
|
222
301
|
export function createTextArtifact(text, name = 'text_response') {
|
|
223
302
|
const part = {
|
|
@@ -231,7 +310,26 @@ export function createTextArtifact(text, name = 'text_response') {
|
|
|
231
310
|
};
|
|
232
311
|
}
|
|
233
312
|
/**
|
|
234
|
-
* Create a file artifact
|
|
313
|
+
* Create a file artifact.
|
|
314
|
+
*
|
|
315
|
+
* @remarks
|
|
316
|
+
* Wraps a file URI in an A2A Artifact with a FilePart. The media type
|
|
317
|
+
* and optional filename are included for proper content handling by
|
|
318
|
+
* consumers.
|
|
319
|
+
*
|
|
320
|
+
* @param fileUrl - URI pointing to the file resource
|
|
321
|
+
* @param mediaType - MIME type of the file (e.g., `application/pdf`)
|
|
322
|
+
* @param filename - Optional display filename for the artifact
|
|
323
|
+
* @returns A2A Artifact containing the file reference as a FilePart
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const artifact = createFileArtifact(
|
|
328
|
+
* 'https://example.com/report.pdf',
|
|
329
|
+
* 'application/pdf',
|
|
330
|
+
* 'report.pdf',
|
|
331
|
+
* );
|
|
332
|
+
* ```
|
|
235
333
|
*/
|
|
236
334
|
export function createFileArtifact(fileUrl, mediaType, filename) {
|
|
237
335
|
const part = {
|
|
@@ -250,9 +348,9 @@ export function createFileArtifact(fileUrl, mediaType, filename) {
|
|
|
250
348
|
};
|
|
251
349
|
}
|
|
252
350
|
function generateId() {
|
|
253
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
|
254
|
-
const r = Math.random() * 16 | 0;
|
|
255
|
-
const v = c === 'x' ? r : (r & 0x3 | 0x8
|
|
351
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
352
|
+
const r = (Math.random() * 16) | 0;
|
|
353
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
256
354
|
return v.toString(16);
|
|
257
355
|
});
|
|
258
356
|
}
|
|
@@ -260,27 +358,68 @@ function generateId() {
|
|
|
260
358
|
// Extension Helpers
|
|
261
359
|
// ============================================================================
|
|
262
360
|
/**
|
|
263
|
-
* Check if an extension is required
|
|
361
|
+
* Check if an extension is required in an Agent Card.
|
|
362
|
+
*
|
|
363
|
+
* @remarks
|
|
364
|
+
* Scans the agent card's declared extensions for one matching the given
|
|
365
|
+
* URI with `required: true`.
|
|
366
|
+
*
|
|
367
|
+
* @param agentCard - Agent Card to inspect
|
|
368
|
+
* @param extensionUri - URI of the extension to check
|
|
369
|
+
* @returns True if the extension is declared as required
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* if (isExtensionRequired(agentCard, LAFS_EXTENSION_URI)) {
|
|
374
|
+
* console.log('LAFS extension is mandatory for this agent');
|
|
375
|
+
* }
|
|
376
|
+
* ```
|
|
264
377
|
*/
|
|
265
378
|
export function isExtensionRequired(agentCard, extensionUri) {
|
|
266
|
-
return agentCard.capabilities?.extensions?.some(ext => ext.uri === extensionUri && ext.required) ??
|
|
379
|
+
return (agentCard.capabilities?.extensions?.some((ext) => ext.uri === extensionUri && ext.required) ??
|
|
380
|
+
false);
|
|
267
381
|
}
|
|
268
382
|
/**
|
|
269
|
-
* Get extension parameters
|
|
383
|
+
* Get extension parameters from an Agent Card.
|
|
384
|
+
*
|
|
385
|
+
* @remarks
|
|
386
|
+
* Finds the extension matching the given URI and returns its `params` object.
|
|
387
|
+
*
|
|
388
|
+
* @param agentCard - Agent Card to inspect
|
|
389
|
+
* @param extensionUri - URI of the extension to look up
|
|
390
|
+
* @returns The extension's params object, or undefined if not found
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* const params = getExtensionParams(agentCard, LAFS_EXTENSION_URI);
|
|
395
|
+
* if (params?.supportsTokenBudgets) {
|
|
396
|
+
* // Enable budget tracking
|
|
397
|
+
* }
|
|
398
|
+
* ```
|
|
270
399
|
*/
|
|
271
400
|
export function getExtensionParams(agentCard, extensionUri) {
|
|
272
|
-
return agentCard.capabilities?.extensions?.find(ext => ext.uri === extensionUri)?.params;
|
|
401
|
+
return agentCard.capabilities?.extensions?.find((ext) => ext.uri === extensionUri)?.params;
|
|
273
402
|
}
|
|
274
403
|
// ============================================================================
|
|
275
404
|
// Constants
|
|
276
405
|
// ============================================================================
|
|
277
406
|
/**
|
|
278
|
-
* A2A Agent Card well-known path
|
|
407
|
+
* A2A Agent Card well-known path.
|
|
408
|
+
*
|
|
409
|
+
* @remarks
|
|
410
|
+
* The standard path `/.well-known/agent-card.json` where A2A Agent Cards
|
|
411
|
+
* are published. Re-exported from the A2A SDK.
|
|
412
|
+
*
|
|
279
413
|
* Reference: specs/external/agent-discovery.md
|
|
280
414
|
*/
|
|
281
|
-
export { AGENT_CARD_PATH };
|
|
282
415
|
/**
|
|
283
|
-
* HTTP header for A2A Extensions
|
|
416
|
+
* HTTP header for A2A Extensions.
|
|
417
|
+
*
|
|
418
|
+
* @remarks
|
|
419
|
+
* Used to communicate extension activation between client and agent.
|
|
420
|
+
* Re-exported from the A2A SDK.
|
|
421
|
+
*
|
|
284
422
|
* Reference: specs/external/extensions.md
|
|
285
423
|
*/
|
|
286
|
-
export { HTTP_EXTENSION_HEADER };
|
|
424
|
+
export { AGENT_CARD_PATH, HTTP_EXTENSION_HEADER };
|
|
425
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../src/a2a/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAuBH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAqGrE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IASd;IARV;;;;;;OAMG;IACH,YACU,MAA2B,EACnC,OAAsB,EACtB,UAAkB;QAFV,WAAM,GAAN,MAAM,CAAqB;IAGlC,CAAC;IAEJ;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,MAA8B,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,MAAoC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE1B,wDAAwD;QACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzC,qCAAqC;YACrC,IAAI,IAAI,IAAI,MAAM,IAAI,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