@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.
Files changed (143) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +97 -68
  3. package/dist/schemas/v1/agent-card.schema.json +230 -0
  4. package/dist/schemas/v1/conformance-profiles.json +0 -0
  5. package/dist/schemas/v1/context-ledger.schema.json +70 -0
  6. package/dist/schemas/v1/discovery.schema.json +132 -0
  7. package/dist/schemas/v1/envelope.schema.json +0 -0
  8. package/dist/schemas/v1/error-registry.json +0 -0
  9. package/dist/src/a2a/bindings/grpc.d.ts +118 -11
  10. package/dist/src/a2a/bindings/grpc.d.ts.map +1 -0
  11. package/dist/src/a2a/bindings/grpc.js +80 -8
  12. package/dist/src/a2a/bindings/grpc.js.map +1 -0
  13. package/dist/src/a2a/bindings/http.d.ts +131 -15
  14. package/dist/src/a2a/bindings/http.d.ts.map +1 -0
  15. package/dist/src/a2a/bindings/http.js +101 -14
  16. package/dist/src/a2a/bindings/http.js.map +1 -0
  17. package/dist/src/a2a/bindings/index.d.ts +83 -9
  18. package/dist/src/a2a/bindings/index.d.ts.map +1 -0
  19. package/dist/src/a2a/bindings/index.js +74 -6
  20. package/dist/src/a2a/bindings/index.js.map +1 -0
  21. package/dist/src/a2a/bindings/jsonrpc.d.ts +194 -9
  22. package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -0
  23. package/dist/src/a2a/bindings/jsonrpc.js +155 -10
  24. package/dist/src/a2a/bindings/jsonrpc.js.map +1 -0
  25. package/dist/src/a2a/bridge.d.ts +237 -44
  26. package/dist/src/a2a/bridge.d.ts.map +1 -0
  27. package/dist/src/a2a/bridge.js +187 -48
  28. package/dist/src/a2a/bridge.js.map +1 -0
  29. package/dist/src/a2a/extensions.d.ts +222 -12
  30. package/dist/src/a2a/extensions.d.ts.map +1 -0
  31. package/dist/src/a2a/extensions.js +178 -13
  32. package/dist/src/a2a/extensions.js.map +1 -0
  33. package/dist/src/a2a/index.d.ts +10 -7
  34. package/dist/src/a2a/index.d.ts.map +1 -0
  35. package/dist/src/a2a/index.js +24 -27
  36. package/dist/src/a2a/index.js.map +1 -0
  37. package/dist/src/a2a/streaming.d.ts +276 -3
  38. package/dist/src/a2a/streaming.d.ts.map +1 -0
  39. package/dist/src/a2a/streaming.js +255 -11
  40. package/dist/src/a2a/streaming.js.map +1 -0
  41. package/dist/src/a2a/task-lifecycle.d.ts +341 -20
  42. package/dist/src/a2a/task-lifecycle.d.ts.map +1 -0
  43. package/dist/src/a2a/task-lifecycle.js +327 -26
  44. package/dist/src/a2a/task-lifecycle.js.map +1 -0
  45. package/dist/src/budgetEnforcement.d.ts +93 -20
  46. package/dist/src/budgetEnforcement.d.ts.map +1 -0
  47. package/dist/src/budgetEnforcement.js +146 -31
  48. package/dist/src/budgetEnforcement.js.map +1 -0
  49. package/dist/src/circuit-breaker/index.d.ts +260 -10
  50. package/dist/src/circuit-breaker/index.d.ts.map +1 -0
  51. package/dist/src/circuit-breaker/index.js +226 -14
  52. package/dist/src/circuit-breaker/index.js.map +1 -0
  53. package/dist/src/cli.d.ts +1 -0
  54. package/dist/src/cli.d.ts.map +1 -0
  55. package/dist/src/cli.js +12 -11
  56. package/dist/src/cli.js.map +1 -0
  57. package/dist/src/compliance.d.ts +180 -3
  58. package/dist/src/compliance.d.ts.map +1 -0
  59. package/dist/src/compliance.js +114 -13
  60. package/dist/src/compliance.js.map +1 -0
  61. package/dist/src/conformance.d.ts +55 -2
  62. package/dist/src/conformance.d.ts.map +1 -0
  63. package/dist/src/conformance.js +124 -76
  64. package/dist/src/conformance.js.map +1 -0
  65. package/dist/src/conformanceProfiles.d.ts +68 -1
  66. package/dist/src/conformanceProfiles.d.ts.map +1 -0
  67. package/dist/src/conformanceProfiles.js +53 -1
  68. package/dist/src/conformanceProfiles.js.map +1 -0
  69. package/dist/src/deprecationRegistry.d.ts +82 -1
  70. package/dist/src/deprecationRegistry.d.ts.map +1 -0
  71. package/dist/src/deprecationRegistry.js +58 -7
  72. package/dist/src/deprecationRegistry.js.map +1 -0
  73. package/dist/src/discovery.d.ts +347 -65
  74. package/dist/src/discovery.d.ts.map +1 -0
  75. package/dist/src/discovery.js +130 -72
  76. package/dist/src/discovery.js.map +1 -0
  77. package/dist/src/envelope.d.ts +262 -9
  78. package/dist/src/envelope.d.ts.map +1 -0
  79. package/dist/src/envelope.js +179 -15
  80. package/dist/src/envelope.js.map +1 -0
  81. package/dist/src/errorRegistry.d.ts +163 -3
  82. package/dist/src/errorRegistry.d.ts.map +1 -0
  83. package/dist/src/errorRegistry.js +119 -3
  84. package/dist/src/errorRegistry.js.map +1 -0
  85. package/dist/src/fieldExtraction.d.ts +128 -27
  86. package/dist/src/fieldExtraction.d.ts.map +1 -0
  87. package/dist/src/fieldExtraction.js +100 -27
  88. package/dist/src/fieldExtraction.js.map +1 -0
  89. package/dist/src/flagResolver.d.ts +77 -10
  90. package/dist/src/flagResolver.d.ts.map +1 -0
  91. package/dist/src/flagResolver.js +22 -5
  92. package/dist/src/flagResolver.js.map +1 -0
  93. package/dist/src/flagSemantics.d.ts +80 -4
  94. package/dist/src/flagSemantics.d.ts.map +1 -0
  95. package/dist/src/flagSemantics.js +78 -11
  96. package/dist/src/flagSemantics.js.map +1 -0
  97. package/dist/src/health/index.d.ts +103 -9
  98. package/dist/src/health/index.d.ts.map +1 -0
  99. package/dist/src/health/index.js +75 -26
  100. package/dist/src/health/index.js.map +1 -0
  101. package/dist/src/index.d.ts +34 -23
  102. package/dist/src/index.d.ts.map +1 -0
  103. package/dist/src/index.js +40 -28
  104. package/dist/src/index.js.map +1 -0
  105. package/dist/src/mviProjection.d.ts +43 -6
  106. package/dist/src/mviProjection.d.ts.map +1 -0
  107. package/dist/src/mviProjection.js +32 -5
  108. package/dist/src/mviProjection.js.map +1 -0
  109. package/dist/src/native-loader.d.ts +49 -0
  110. package/dist/src/native-loader.d.ts.map +1 -0
  111. package/dist/src/native-loader.js +56 -0
  112. package/dist/src/native-loader.js.map +1 -0
  113. package/dist/src/problemDetails.d.ts +71 -4
  114. package/dist/src/problemDetails.d.ts.map +1 -0
  115. package/dist/src/problemDetails.js +27 -3
  116. package/dist/src/problemDetails.js.map +1 -0
  117. package/dist/src/shutdown/index.d.ts +103 -9
  118. package/dist/src/shutdown/index.d.ts.map +1 -0
  119. package/dist/src/shutdown/index.js +78 -12
  120. package/dist/src/shutdown/index.js.map +1 -0
  121. package/dist/src/tokenEstimator.d.ts +98 -11
  122. package/dist/src/tokenEstimator.d.ts.map +1 -0
  123. package/dist/src/tokenEstimator.js +91 -13
  124. package/dist/src/tokenEstimator.js.map +1 -0
  125. package/dist/src/types.d.ts +477 -11
  126. package/dist/src/types.d.ts.map +1 -0
  127. package/dist/src/types.js +76 -2
  128. package/dist/src/types.js.map +1 -0
  129. package/dist/src/validateEnvelope.d.ts +61 -2
  130. package/dist/src/validateEnvelope.d.ts.map +1 -0
  131. package/dist/src/validateEnvelope.js +81 -14
  132. package/dist/src/validateEnvelope.js.map +1 -0
  133. package/dist/tsconfig.build.tsbuildinfo +1 -0
  134. package/lafs.md +3 -4
  135. package/package.json +14 -12
  136. package/schemas/v1/agent-card.schema.json +0 -0
  137. package/schemas/v1/conformance-profiles.json +0 -0
  138. package/schemas/v1/context-ledger.schema.json +0 -0
  139. package/schemas/v1/discovery.schema.json +0 -0
  140. package/schemas/v1/envelope.schema.json +0 -0
  141. package/schemas/v1/error-registry.json +0 -0
  142. package/dist/src/mcpAdapter.d.ts +0 -28
  143. package/dist/src/mcpAdapter.js +0 -281
@@ -4,99 +4,215 @@
4
4
  * HTTP endpoint definitions, status codes, error type URIs,
5
5
  * and RFC 9457 Problem Details support per A2A spec Section 11.3-11.5.
6
6
  */
7
- import type { A2AErrorType } from './jsonrpc.js';
8
7
  import type { LAFSError } from '../../types.js';
9
- /** HTTP+JSON endpoint definitions for each A2A operation */
8
+ import type { A2AErrorType } from './jsonrpc.js';
9
+ /**
10
+ * HTTP+JSON endpoint definitions for each A2A operation.
11
+ *
12
+ * @remarks
13
+ * Each entry specifies the HTTP method and path template per A2A spec Section 11.3.
14
+ * Path parameters are prefixed with `:` (e.g. `:id`).
15
+ */
10
16
  export declare const HTTP_ENDPOINTS: {
17
+ /** Send a single message to an agent */
11
18
  readonly SendMessage: {
12
19
  readonly method: "POST";
13
20
  readonly path: "/message:send";
14
21
  };
22
+ /** Send a streaming message to an agent */
15
23
  readonly SendStreamingMessage: {
16
24
  readonly method: "POST";
17
25
  readonly path: "/message:stream";
18
26
  };
27
+ /** Retrieve a task by identifier */
19
28
  readonly GetTask: {
20
29
  readonly method: "GET";
21
30
  readonly path: "/tasks/:id";
22
31
  };
32
+ /** List tasks matching query criteria */
23
33
  readonly ListTasks: {
24
34
  readonly method: "GET";
25
35
  readonly path: "/tasks";
26
36
  };
37
+ /** Cancel a running task */
27
38
  readonly CancelTask: {
28
39
  readonly method: "POST";
29
40
  readonly path: "/tasks/:id:cancel";
30
41
  };
42
+ /** Subscribe to task events via SSE */
31
43
  readonly SubscribeToTask: {
32
44
  readonly method: "GET";
33
45
  readonly path: "/tasks/:id:subscribe";
34
46
  };
47
+ /** Set push notification configuration for a task */
35
48
  readonly SetTaskPushNotificationConfig: {
36
49
  readonly method: "POST";
37
50
  readonly path: "/tasks/:id/pushNotificationConfig";
38
51
  };
52
+ /** Get push notification configuration for a task */
39
53
  readonly GetTaskPushNotificationConfig: {
40
54
  readonly method: "GET";
41
55
  readonly path: "/tasks/:id/pushNotificationConfig";
42
56
  };
57
+ /** List push notification configurations for a task */
43
58
  readonly ListTaskPushNotificationConfig: {
44
59
  readonly method: "GET";
45
60
  readonly path: "/tasks/:id/pushNotificationConfig:list";
46
61
  };
62
+ /** Delete push notification configuration for a task */
47
63
  readonly DeleteTaskPushNotificationConfig: {
48
64
  readonly method: "DELETE";
49
65
  readonly path: "/tasks/:id/pushNotificationConfig/:configId";
50
66
  };
67
+ /** Retrieve the authenticated extended agent card */
51
68
  readonly GetExtendedAgentCard: {
52
69
  readonly method: "GET";
53
70
  readonly path: "/agent/authenticatedExtendedCard";
54
71
  };
55
72
  };
73
+ /** Union of all HTTP endpoint descriptor objects from {@link HTTP_ENDPOINTS} */
56
74
  export type HttpEndpoint = (typeof HTTP_ENDPOINTS)[keyof typeof HTTP_ENDPOINTS];
57
- /** Maps A2A error types to HTTP status codes */
75
+ /**
76
+ * Maps A2A error types to HTTP status codes.
77
+ *
78
+ * @remarks
79
+ * Used by the HTTP binding to determine the appropriate response status
80
+ * code for each A2A error type per spec Section 5.4.
81
+ */
58
82
  export declare const A2A_HTTP_STATUS_CODES: Record<A2AErrorType, number>;
59
- /** RFC 9457 Problem Details type URIs for A2A errors */
83
+ /**
84
+ * RFC 9457 Problem Details type URIs for A2A errors.
85
+ *
86
+ * @remarks
87
+ * Each URI uniquely identifies an A2A error type and is used as the
88
+ * `type` field in RFC 9457 Problem Details responses.
89
+ */
60
90
  export declare const A2A_ERROR_TYPE_URIS: Record<A2AErrorType, string>;
61
- /** RFC 9457 Problem Details object */
91
+ /**
92
+ * RFC 9457 Problem Details object.
93
+ *
94
+ * @remarks
95
+ * Represents a machine-readable error response per RFC 9457. The index
96
+ * signature allows arbitrary extension members alongside the required fields.
97
+ */
62
98
  export interface ProblemDetails {
99
+ /** URI reference identifying the problem type */
63
100
  type: string;
101
+ /** Short human-readable summary of the problem */
64
102
  title: string;
103
+ /** HTTP status code for this occurrence */
65
104
  status: number;
105
+ /** Human-readable explanation specific to this occurrence */
66
106
  detail: string;
107
+ /** Extension members (arbitrary key-value pairs) */
67
108
  [key: string]: unknown;
68
109
  }
69
110
  /**
70
111
  * Create an RFC 9457 Problem Details object for an A2A error.
71
- * @param errorType - The A2A error type name
72
- * @param detail - Human-readable explanation of the error
73
- * @param extensions - Additional members to include in the response
112
+ *
113
+ * @remarks
114
+ * Resolves the `type` URI, `title`, and `status` automatically from
115
+ * the A2A error type. The title is derived by converting the PascalCase
116
+ * error type name to title case.
117
+ *
118
+ * @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
119
+ * @param detail - Human-readable explanation specific to this occurrence
120
+ * @param extensions - Optional additional members to include in the response
121
+ * @returns A fully formed {@link ProblemDetails} object
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const problem = createProblemDetails('TaskNotFound', 'No task with id xyz');
126
+ * // { type: 'https://a2a-protocol.org/errors/task-not-found', title: 'Task Not Found', status: 404, detail: '...' }
127
+ * ```
74
128
  */
75
129
  export declare function createProblemDetails(errorType: A2AErrorType, detail: string, extensions?: Record<string, unknown>): ProblemDetails;
76
130
  /**
77
131
  * Create an RFC 9457 Problem Details object bridging A2A error types with LAFS error data.
78
- * Includes LAFS agent-actionable extension fields from the LAFSError.
79
132
  *
80
- * @param errorType - The A2A error type name
133
+ * @remarks
134
+ * Extends the base Problem Details with LAFS agent-actionable fields such as
135
+ * `retryable`, `agentAction`, `retryAfterMs`, `escalationRequired`,
136
+ * `suggestedAction`, and `docUrl` extracted from the provided LAFSError.
137
+ *
138
+ * @param errorType - The A2A error type name (e.g. `"InvalidAgentResponse"`)
81
139
  * @param lafsError - The LAFS error object to extract extension fields from
82
- * @param requestId - Optional request identifier for the `instance` field
140
+ * @param requestId - Optional request identifier used as the `instance` field
141
+ * @returns A {@link ProblemDetails} object with LAFS extension fields
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * const problem = createLafsProblemDetails('InvalidAgentResponse', {
146
+ * code: 'E_AGENT_RESPONSE',
147
+ * message: 'Upstream agent returned invalid JSON',
148
+ * retryable: true,
149
+ * retryAfterMs: 5000,
150
+ * }, 'req-123');
151
+ * ```
83
152
  */
84
153
  export declare function createLafsProblemDetails(errorType: A2AErrorType, lafsError: LAFSError, requestId?: string): ProblemDetails;
85
154
  /**
86
155
  * Build a URL by substituting path parameters.
87
- * @param endpoint - HTTP endpoint definition (from HTTP_ENDPOINTS)
88
- * @param params - Path parameter values (keys without leading colon)
156
+ *
157
+ * @remarks
158
+ * Replaces `:param` placeholders in the endpoint path template with
159
+ * URI-encoded values from the `params` object.
160
+ *
161
+ * @param endpoint - HTTP endpoint definition from {@link HTTP_ENDPOINTS}
162
+ * @param params - Path parameter values keyed by name (without leading colon)
163
+ * @returns The resolved URL path string with parameters substituted
164
+ *
165
+ * @example
166
+ * ```ts
167
+ * const url = buildUrl(HTTP_ENDPOINTS.GetTask, { id: 'task-42' });
168
+ * // '/tasks/task-42'
169
+ * ```
89
170
  */
90
171
  export declare function buildUrl(endpoint: HttpEndpoint, params?: Record<string, string>): string;
91
- /** Parsed query parameters for ListTasks (spec Section 11.5) */
172
+ /**
173
+ * Parsed query parameters for the ListTasks endpoint.
174
+ *
175
+ * @remarks
176
+ * Represents the camelCase query parameters defined in A2A spec Section 11.5.
177
+ * All fields are optional for flexible filtering.
178
+ */
92
179
  export interface ListTasksQueryParams {
180
+ /**
181
+ * Filter tasks by context identifier.
182
+ * @defaultValue undefined
183
+ */
93
184
  contextId?: string;
185
+ /**
186
+ * Filter tasks by state (e.g. `"submitted"`, `"working"`).
187
+ * @defaultValue undefined
188
+ */
94
189
  state?: string;
190
+ /**
191
+ * Maximum number of tasks to return.
192
+ * @defaultValue undefined
193
+ */
95
194
  limit?: number;
195
+ /**
196
+ * Pagination token from a previous response.
197
+ * @defaultValue undefined
198
+ */
96
199
  pageToken?: string;
97
200
  }
98
201
  /**
99
202
  * Parse camelCase query parameters for the ListTasks endpoint.
100
- * Handles type coercion for numeric fields.
203
+ *
204
+ * @remarks
205
+ * Handles type coercion for numeric fields (e.g. `limit` is parsed from
206
+ * string to integer). Undefined values are preserved as-is.
207
+ *
208
+ * @param query - Raw query parameter map from the HTTP request
209
+ * @returns A typed {@link ListTasksQueryParams} object with coerced values
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * const params = parseListTasksQuery({ contextId: 'ctx-1', limit: '10' });
214
+ * // { contextId: 'ctx-1', limit: 10 }
215
+ * ```
101
216
  */
102
217
  export declare function parseListTasksQuery(query: Record<string, string | undefined>): ListTasksQueryParams;
218
+ //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AC,MAAM,EAAE,OAAO,CAAC,GACnC,cAAc,CAWhB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,SAAS,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,cAAc,CAehB;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAQxF;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACxC,oBAAoB,CAOtB"}
@@ -7,24 +7,50 @@
7
7
  // ============================================================================
8
8
  // Endpoint Constants (spec Section 11.3)
9
9
  // ============================================================================
10
- /** HTTP+JSON endpoint definitions for each A2A operation */
10
+ /**
11
+ * HTTP+JSON endpoint definitions for each A2A operation.
12
+ *
13
+ * @remarks
14
+ * Each entry specifies the HTTP method and path template per A2A spec Section 11.3.
15
+ * Path parameters are prefixed with `:` (e.g. `:id`).
16
+ */
11
17
  export const HTTP_ENDPOINTS = {
18
+ /** Send a single message to an agent */
12
19
  SendMessage: { method: 'POST', path: '/message:send' },
20
+ /** Send a streaming message to an agent */
13
21
  SendStreamingMessage: { method: 'POST', path: '/message:stream' },
22
+ /** Retrieve a task by identifier */
14
23
  GetTask: { method: 'GET', path: '/tasks/:id' },
24
+ /** List tasks matching query criteria */
15
25
  ListTasks: { method: 'GET', path: '/tasks' },
26
+ /** Cancel a running task */
16
27
  CancelTask: { method: 'POST', path: '/tasks/:id:cancel' },
28
+ /** Subscribe to task events via SSE */
17
29
  SubscribeToTask: { method: 'GET', path: '/tasks/:id:subscribe' },
30
+ /** Set push notification configuration for a task */
18
31
  SetTaskPushNotificationConfig: { method: 'POST', path: '/tasks/:id/pushNotificationConfig' },
32
+ /** Get push notification configuration for a task */
19
33
  GetTaskPushNotificationConfig: { method: 'GET', path: '/tasks/:id/pushNotificationConfig' },
34
+ /** List push notification configurations for a task */
20
35
  ListTaskPushNotificationConfig: { method: 'GET', path: '/tasks/:id/pushNotificationConfig:list' },
21
- DeleteTaskPushNotificationConfig: { method: 'DELETE', path: '/tasks/:id/pushNotificationConfig/:configId' },
36
+ /** Delete push notification configuration for a task */
37
+ DeleteTaskPushNotificationConfig: {
38
+ method: 'DELETE',
39
+ path: '/tasks/:id/pushNotificationConfig/:configId',
40
+ },
41
+ /** Retrieve the authenticated extended agent card */
22
42
  GetExtendedAgentCard: { method: 'GET', path: '/agent/authenticatedExtendedCard' },
23
43
  };
24
44
  // ============================================================================
25
45
  // HTTP Status Codes (spec Section 5.4)
26
46
  // ============================================================================
27
- /** Maps A2A error types to HTTP status codes */
47
+ /**
48
+ * Maps A2A error types to HTTP status codes.
49
+ *
50
+ * @remarks
51
+ * Used by the HTTP binding to determine the appropriate response status
52
+ * code for each A2A error type per spec Section 5.4.
53
+ */
28
54
  export const A2A_HTTP_STATUS_CODES = {
29
55
  TaskNotFound: 404,
30
56
  TaskNotCancelable: 409,
@@ -39,7 +65,13 @@ export const A2A_HTTP_STATUS_CODES = {
39
65
  // ============================================================================
40
66
  // Error Type URIs (spec Section 5.4)
41
67
  // ============================================================================
42
- /** RFC 9457 Problem Details type URIs for A2A errors */
68
+ /**
69
+ * RFC 9457 Problem Details type URIs for A2A errors.
70
+ *
71
+ * @remarks
72
+ * Each URI uniquely identifies an A2A error type and is used as the
73
+ * `type` field in RFC 9457 Problem Details responses.
74
+ */
43
75
  export const A2A_ERROR_TYPE_URIS = {
44
76
  TaskNotFound: 'https://a2a-protocol.org/errors/task-not-found',
45
77
  TaskNotCancelable: 'https://a2a-protocol.org/errors/task-not-cancelable',
@@ -53,9 +85,22 @@ export const A2A_ERROR_TYPE_URIS = {
53
85
  };
54
86
  /**
55
87
  * Create an RFC 9457 Problem Details object for an A2A error.
56
- * @param errorType - The A2A error type name
57
- * @param detail - Human-readable explanation of the error
58
- * @param extensions - Additional members to include in the response
88
+ *
89
+ * @remarks
90
+ * Resolves the `type` URI, `title`, and `status` automatically from
91
+ * the A2A error type. The title is derived by converting the PascalCase
92
+ * error type name to title case.
93
+ *
94
+ * @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
95
+ * @param detail - Human-readable explanation specific to this occurrence
96
+ * @param extensions - Optional additional members to include in the response
97
+ * @returns A fully formed {@link ProblemDetails} object
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const problem = createProblemDetails('TaskNotFound', 'No task with id xyz');
102
+ * // { type: 'https://a2a-protocol.org/errors/task-not-found', title: 'Task Not Found', status: 404, detail: '...' }
103
+ * ```
59
104
  */
60
105
  export function createProblemDetails(errorType, detail, extensions) {
61
106
  // Convert PascalCase to Title Case: "TaskNotFound" -> "Task Not Found"
@@ -70,11 +115,26 @@ export function createProblemDetails(errorType, detail, extensions) {
70
115
  }
71
116
  /**
72
117
  * Create an RFC 9457 Problem Details object bridging A2A error types with LAFS error data.
73
- * Includes LAFS agent-actionable extension fields from the LAFSError.
74
118
  *
75
- * @param errorType - The A2A error type name
119
+ * @remarks
120
+ * Extends the base Problem Details with LAFS agent-actionable fields such as
121
+ * `retryable`, `agentAction`, `retryAfterMs`, `escalationRequired`,
122
+ * `suggestedAction`, and `docUrl` extracted from the provided LAFSError.
123
+ *
124
+ * @param errorType - The A2A error type name (e.g. `"InvalidAgentResponse"`)
76
125
  * @param lafsError - The LAFS error object to extract extension fields from
77
- * @param requestId - Optional request identifier for the `instance` field
126
+ * @param requestId - Optional request identifier used as the `instance` field
127
+ * @returns A {@link ProblemDetails} object with LAFS extension fields
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * const problem = createLafsProblemDetails('InvalidAgentResponse', {
132
+ * code: 'E_AGENT_RESPONSE',
133
+ * message: 'Upstream agent returned invalid JSON',
134
+ * retryable: true,
135
+ * retryAfterMs: 5000,
136
+ * }, 'req-123');
137
+ * ```
78
138
  */
79
139
  export function createLafsProblemDetails(errorType, lafsError, requestId) {
80
140
  const base = createProblemDetails(errorType, lafsError.message);
@@ -84,7 +144,9 @@ export function createLafsProblemDetails(errorType, lafsError, requestId) {
84
144
  retryable: lafsError.retryable,
85
145
  ...(lafsError.agentAction != null && { agentAction: lafsError.agentAction }),
86
146
  ...(lafsError.retryAfterMs != null && { retryAfterMs: lafsError.retryAfterMs }),
87
- ...(lafsError.escalationRequired != null && { escalationRequired: lafsError.escalationRequired }),
147
+ ...(lafsError.escalationRequired != null && {
148
+ escalationRequired: lafsError.escalationRequired,
149
+ }),
88
150
  ...(lafsError.suggestedAction != null && { suggestedAction: lafsError.suggestedAction }),
89
151
  ...(lafsError.docUrl != null && { docUrl: lafsError.docUrl }),
90
152
  };
@@ -94,8 +156,20 @@ export function createLafsProblemDetails(errorType, lafsError, requestId) {
94
156
  // ============================================================================
95
157
  /**
96
158
  * Build a URL by substituting path parameters.
97
- * @param endpoint - HTTP endpoint definition (from HTTP_ENDPOINTS)
98
- * @param params - Path parameter values (keys without leading colon)
159
+ *
160
+ * @remarks
161
+ * Replaces `:param` placeholders in the endpoint path template with
162
+ * URI-encoded values from the `params` object.
163
+ *
164
+ * @param endpoint - HTTP endpoint definition from {@link HTTP_ENDPOINTS}
165
+ * @param params - Path parameter values keyed by name (without leading colon)
166
+ * @returns The resolved URL path string with parameters substituted
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const url = buildUrl(HTTP_ENDPOINTS.GetTask, { id: 'task-42' });
171
+ * // '/tasks/task-42'
172
+ * ```
99
173
  */
100
174
  export function buildUrl(endpoint, params) {
101
175
  let path = endpoint.path;
@@ -108,7 +182,19 @@ export function buildUrl(endpoint, params) {
108
182
  }
109
183
  /**
110
184
  * Parse camelCase query parameters for the ListTasks endpoint.
111
- * Handles type coercion for numeric fields.
185
+ *
186
+ * @remarks
187
+ * Handles type coercion for numeric fields (e.g. `limit` is parsed from
188
+ * string to integer). Undefined values are preserved as-is.
189
+ *
190
+ * @param query - Raw query parameter map from the HTTP request
191
+ * @returns A typed {@link ListTasksQueryParams} object with coerced values
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const params = parseListTasksQuery({ contextId: 'ctx-1', limit: '10' });
196
+ * // { contextId: 'ctx-1', limit: 10 }
197
+ * ```
112
198
  */
113
199
  export function parseListTasksQuery(query) {
114
200
  return {
@@ -118,3 +204,4 @@ export function parseListTasksQuery(query) {
118
204
  pageToken: query['pageToken'],
119
205
  };
120
206
  }
207
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/a2a/bindings/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,wCAAwC;IACxC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;IACtD,2CAA2C;IAC3C,oBAAoB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACjE,oCAAoC;IACpC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE;IAC9C,yCAAyC;IACzC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5C,4BAA4B;IAC5B,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EA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AS,CAAC,MAAM,IAAI,IAAI,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAsB,EAAE,MAA+B;IAC9E,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAc,CAAC;IACnC,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAoCD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAyC;IAEzC,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;QAC7B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QAChE,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC;KAC9B,CAAC;AACJ,CAAC"}
@@ -3,33 +3,107 @@
3
3
  *
4
4
  * Re-exports all binding modules and provides cross-binding
5
5
  * error code mapping for consistent error handling across transports.
6
+ *
7
+ * @packageDocumentation
6
8
  */
7
- export * from './jsonrpc.js';
8
- export * from './http.js';
9
9
  export * from './grpc.js';
10
+ export * from './http.js';
11
+ export * from './jsonrpc.js';
10
12
  import { type A2AErrorType } from './jsonrpc.js';
11
- /** Complete error code mapping across all three transports */
13
+ /**
14
+ * Complete error code mapping across all three transports.
15
+ *
16
+ * @remarks
17
+ * Provides a unified view of how a single A2A error type maps to
18
+ * JSON-RPC, HTTP, and gRPC error representations.
19
+ */
12
20
  export interface ErrorCodeMapping {
13
- /** JSON-RPC numeric error code */
21
+ /** JSON-RPC numeric error code (e.g. `-32001`) */
14
22
  jsonRpcCode: number;
15
- /** HTTP response status code */
23
+ /** HTTP response status code (e.g. `404`) */
16
24
  httpStatus: number;
17
25
  /** RFC 9457 Problem Details type URI */
18
26
  httpTypeUri: string;
19
- /** gRPC status name (e.g. NOT_FOUND) */
27
+ /** gRPC status name (e.g. `"NOT_FOUND"`) */
20
28
  grpcStatus: string;
21
- /** gRPC numeric status code */
29
+ /** gRPC numeric status code (e.g. `5`) */
22
30
  grpcCode: number;
23
31
  }
24
- /** Precomputed cross-binding error mapping for all 9 A2A error types */
32
+ /**
33
+ * Precomputed cross-binding error mapping for all 9 A2A error types.
34
+ *
35
+ * @remarks
36
+ * Built once at module load and immutable thereafter. Each entry maps an
37
+ * A2A error type to its JSON-RPC, HTTP, and gRPC representations.
38
+ */
25
39
  export declare const A2A_ERROR_MAPPINGS: ReadonlyMap<A2AErrorType, ErrorCodeMapping>;
26
40
  /**
27
41
  * Get the complete error code mapping for a given A2A error type.
28
- * Returns consistent values across JSON-RPC, HTTP, and gRPC.
42
+ *
43
+ * @remarks
44
+ * Looks up the precomputed mapping from {@link A2A_ERROR_MAPPINGS}. Throws
45
+ * if the error type is not one of the 9 known A2A error types.
46
+ *
47
+ * @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
48
+ * @returns The {@link ErrorCodeMapping} with JSON-RPC, HTTP, and gRPC codes
49
+ * @throws Error if the error type is not a known A2A error type
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const mapping = getErrorCodeMapping('TaskNotFound');
54
+ * // { jsonRpcCode: -32001, httpStatus: 404, httpTypeUri: '...', grpcStatus: 'NOT_FOUND', grpcCode: 5 }
55
+ * ```
29
56
  */
30
57
  export declare function getErrorCodeMapping(errorType: A2AErrorType): ErrorCodeMapping;
31
58
  export { A2A_GRPC_ERROR_REASONS } from './grpc.js';
59
+ /**
60
+ * Supported A2A protocol versions.
61
+ *
62
+ * @remarks
63
+ * Tuple of version strings that this implementation can handle.
64
+ */
32
65
  export declare const SUPPORTED_A2A_VERSIONS: readonly ["1.0"];
66
+ /**
67
+ * Default A2A protocol version used when none is requested.
68
+ *
69
+ * @remarks
70
+ * Applied when the client does not provide an `a2a-version` header.
71
+ */
33
72
  export declare const DEFAULT_A2A_VERSION: "1.0";
73
+ /**
74
+ * Parse the `a2a-version` header into an array of version strings.
75
+ *
76
+ * @remarks
77
+ * Splits the comma-separated header value, trims whitespace, and filters
78
+ * empty segments. Returns an empty array when the header is absent.
79
+ *
80
+ * @param headerValue - The raw `a2a-version` header value, or `undefined` if absent
81
+ * @returns An array of version strings extracted from the header
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * parseA2AVersionHeader('1.0, 2.0'); // ['1.0', '2.0']
86
+ * parseA2AVersionHeader(undefined); // []
87
+ * ```
88
+ */
34
89
  export declare function parseA2AVersionHeader(headerValue: string | undefined): string[];
90
+ /**
91
+ * Negotiate an A2A protocol version from the client's requested versions.
92
+ *
93
+ * @remarks
94
+ * Returns the first requested version that is also in {@link SUPPORTED_A2A_VERSIONS}.
95
+ * Falls back to {@link DEFAULT_A2A_VERSION} when the request list is empty.
96
+ * Returns `null` if no requested version is supported.
97
+ *
98
+ * @param requestedVersions - Array of version strings requested by the client
99
+ * @returns The negotiated version string, or `null` if no common version exists
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * negotiateA2AVersion(['1.0', '2.0']); // '1.0'
104
+ * negotiateA2AVersion([]); // '1.0' (default)
105
+ * negotiateA2AVersion(['3.0']); // null
106
+ * ```
107
+ */
35
108
  export declare function negotiateA2AVersion(requestedVersions: string[]): string | null;
109
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/a2a/bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAI7B,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,cAAc,CAAC;AAM1E;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgCD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,YAAY,EAAE,gBAAgB,CAAmB,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,GAAG,gBAAgB,CAM7E;AAID,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAMnD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kBAAmB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAG,KAAc,CAAC;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAM/E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAY9E"}
@@ -3,13 +3,15 @@
3
3
  *
4
4
  * Re-exports all binding modules and provides cross-binding
5
5
  * error code mapping for consistent error handling across transports.
6
+ *
7
+ * @packageDocumentation
6
8
  */
7
- export * from './jsonrpc.js';
8
- export * from './http.js';
9
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';
10
+ export * from './http.js';
11
+ export * from './jsonrpc.js';
12
12
  import { A2A_GRPC_STATUS_CODES, GRPC_STATUS_CODE } from './grpc.js';
13
+ import { A2A_ERROR_TYPE_URIS, A2A_HTTP_STATUS_CODES } from './http.js';
14
+ import { JSONRPC_A2A_ERROR_CODES } from './jsonrpc.js';
13
15
  /** All 9 A2A error types */
14
16
  const ERROR_TYPES = [
15
17
  'TaskNotFound',
@@ -36,11 +38,30 @@ function buildMappings() {
36
38
  }
37
39
  return map;
38
40
  }
39
- /** Precomputed cross-binding error mapping for all 9 A2A error types */
41
+ /**
42
+ * Precomputed cross-binding error mapping for all 9 A2A error types.
43
+ *
44
+ * @remarks
45
+ * Built once at module load and immutable thereafter. Each entry maps an
46
+ * A2A error type to its JSON-RPC, HTTP, and gRPC representations.
47
+ */
40
48
  export const A2A_ERROR_MAPPINGS = buildMappings();
41
49
  /**
42
50
  * Get the complete error code mapping for a given A2A error type.
43
- * Returns consistent values across JSON-RPC, HTTP, and gRPC.
51
+ *
52
+ * @remarks
53
+ * Looks up the precomputed mapping from {@link A2A_ERROR_MAPPINGS}. Throws
54
+ * if the error type is not one of the 9 known A2A error types.
55
+ *
56
+ * @param errorType - The A2A error type name (e.g. `"TaskNotFound"`)
57
+ * @returns The {@link ErrorCodeMapping} with JSON-RPC, HTTP, and gRPC codes
58
+ * @throws Error if the error type is not a known A2A error type
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const mapping = getErrorCodeMapping('TaskNotFound');
63
+ * // { jsonRpcCode: -32001, httpStatus: 404, httpTypeUri: '...', grpcStatus: 'NOT_FOUND', grpcCode: 5 }
64
+ * ```
44
65
  */
45
66
  export function getErrorCodeMapping(errorType) {
46
67
  const mapping = A2A_ERROR_MAPPINGS.get(errorType);
@@ -55,8 +76,36 @@ export { A2A_GRPC_ERROR_REASONS } from './grpc.js';
55
76
  // ============================================================================
56
77
  // Version Negotiation
57
78
  // ============================================================================
79
+ /**
80
+ * Supported A2A protocol versions.
81
+ *
82
+ * @remarks
83
+ * Tuple of version strings that this implementation can handle.
84
+ */
58
85
  export const SUPPORTED_A2A_VERSIONS = ['1.0'];
86
+ /**
87
+ * Default A2A protocol version used when none is requested.
88
+ *
89
+ * @remarks
90
+ * Applied when the client does not provide an `a2a-version` header.
91
+ */
59
92
  export const DEFAULT_A2A_VERSION = '1.0';
93
+ /**
94
+ * Parse the `a2a-version` header into an array of version strings.
95
+ *
96
+ * @remarks
97
+ * Splits the comma-separated header value, trims whitespace, and filters
98
+ * empty segments. Returns an empty array when the header is absent.
99
+ *
100
+ * @param headerValue - The raw `a2a-version` header value, or `undefined` if absent
101
+ * @returns An array of version strings extracted from the header
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * parseA2AVersionHeader('1.0, 2.0'); // ['1.0', '2.0']
106
+ * parseA2AVersionHeader(undefined); // []
107
+ * ```
108
+ */
60
109
  export function parseA2AVersionHeader(headerValue) {
61
110
  if (!headerValue)
62
111
  return [];
@@ -65,6 +114,24 @@ export function parseA2AVersionHeader(headerValue) {
65
114
  .map((v) => v.trim())
66
115
  .filter(Boolean);
67
116
  }
117
+ /**
118
+ * Negotiate an A2A protocol version from the client's requested versions.
119
+ *
120
+ * @remarks
121
+ * Returns the first requested version that is also in {@link SUPPORTED_A2A_VERSIONS}.
122
+ * Falls back to {@link DEFAULT_A2A_VERSION} when the request list is empty.
123
+ * Returns `null` if no requested version is supported.
124
+ *
125
+ * @param requestedVersions - Array of version strings requested by the client
126
+ * @returns The negotiated version string, or `null` if no common version exists
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * negotiateA2AVersion(['1.0', '2.0']); // '1.0'
131
+ * negotiateA2AVersion([]); // '1.0' (default)
132
+ * negotiateA2AVersion(['3.0']); // null
133
+ * ```
134
+ */
68
135
  export function negotiateA2AVersion(requestedVersions) {
69
136
  if (requestedVersions.length === 0) {
70
137
  return DEFAULT_A2A_VERSION;
@@ -77,3 +144,4 @@ export function negotiateA2AVersion(requestedVersions) {
77
144
  }
78
145
  return null;
79
146
  }
147
+ //# sourceMappingURL=index.js.map