@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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/dist/schemas/v1/conformance-profiles.json +39 -0
  4. package/dist/schemas/v1/envelope.schema.json +306 -0
  5. package/dist/schemas/v1/error-registry.json +162 -0
  6. package/dist/src/a2a/bindings/grpc.d.ts +67 -0
  7. package/dist/src/a2a/bindings/grpc.js +148 -0
  8. package/dist/src/a2a/bindings/http.d.ts +102 -0
  9. package/dist/src/a2a/bindings/http.js +120 -0
  10. package/dist/src/a2a/bindings/index.d.ts +35 -0
  11. package/dist/src/a2a/bindings/index.js +79 -0
  12. package/dist/src/a2a/bindings/jsonrpc.d.ts +77 -0
  13. package/dist/src/a2a/bindings/jsonrpc.js +114 -0
  14. package/dist/src/a2a/bridge.d.ts +175 -0
  15. package/dist/src/a2a/bridge.js +286 -0
  16. package/dist/src/a2a/extensions.d.ts +121 -0
  17. package/dist/src/a2a/extensions.js +205 -0
  18. package/dist/src/a2a/index.d.ts +40 -0
  19. package/dist/src/a2a/index.js +76 -0
  20. package/dist/src/a2a/streaming.d.ts +74 -0
  21. package/dist/src/a2a/streaming.js +265 -0
  22. package/dist/src/a2a/task-lifecycle.d.ts +109 -0
  23. package/dist/src/a2a/task-lifecycle.js +313 -0
  24. package/dist/src/budgetEnforcement.d.ts +84 -0
  25. package/dist/src/budgetEnforcement.js +328 -0
  26. package/dist/src/circuit-breaker/index.d.ts +121 -0
  27. package/dist/src/circuit-breaker/index.js +249 -0
  28. package/dist/src/cli.d.ts +16 -0
  29. package/dist/src/cli.js +63 -0
  30. package/dist/src/compliance.d.ts +31 -0
  31. package/dist/src/compliance.js +89 -0
  32. package/dist/src/conformance.d.ts +7 -0
  33. package/dist/src/conformance.js +248 -0
  34. package/dist/src/conformanceProfiles.d.ts +11 -0
  35. package/dist/src/conformanceProfiles.js +34 -0
  36. package/dist/src/deprecationRegistry.d.ts +13 -0
  37. package/dist/src/deprecationRegistry.js +39 -0
  38. package/dist/src/discovery.d.ts +286 -0
  39. package/dist/src/discovery.js +350 -0
  40. package/dist/src/envelope.d.ts +60 -0
  41. package/dist/src/envelope.js +136 -0
  42. package/dist/src/errorRegistry.d.ts +28 -0
  43. package/dist/src/errorRegistry.js +36 -0
  44. package/dist/src/fieldExtraction.d.ts +67 -0
  45. package/dist/src/fieldExtraction.js +133 -0
  46. package/dist/src/flagResolver.d.ts +46 -0
  47. package/dist/src/flagResolver.js +47 -0
  48. package/dist/src/flagSemantics.d.ts +16 -0
  49. package/dist/src/flagSemantics.js +45 -0
  50. package/dist/src/health/index.d.ts +105 -0
  51. package/dist/src/health/index.js +220 -0
  52. package/dist/src/index.d.ts +24 -0
  53. package/dist/src/index.js +34 -0
  54. package/dist/src/mcpAdapter.d.ts +28 -0
  55. package/dist/src/mcpAdapter.js +281 -0
  56. package/dist/src/mviProjection.d.ts +19 -0
  57. package/dist/src/mviProjection.js +116 -0
  58. package/dist/src/problemDetails.d.ts +34 -0
  59. package/dist/src/problemDetails.js +45 -0
  60. package/dist/src/shutdown/index.d.ts +69 -0
  61. package/dist/src/shutdown/index.js +160 -0
  62. package/dist/src/tokenEstimator.d.ts +87 -0
  63. package/dist/src/tokenEstimator.js +238 -0
  64. package/dist/src/types.d.ts +135 -0
  65. package/dist/src/types.js +12 -0
  66. package/dist/src/validateEnvelope.d.ts +15 -0
  67. package/dist/src/validateEnvelope.js +31 -0
  68. package/lafs.md +819 -0
  69. package/package.json +88 -0
  70. package/schemas/v1/agent-card.schema.json +230 -0
  71. package/schemas/v1/conformance-profiles.json +39 -0
  72. package/schemas/v1/context-ledger.schema.json +70 -0
  73. package/schemas/v1/discovery.schema.json +132 -0
  74. package/schemas/v1/envelope.schema.json +306 -0
  75. package/schemas/v1/error-registry.json +162 -0
@@ -0,0 +1,306 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://lafs.dev/schemas/v1/envelope.schema.json",
4
+ "title": "LAFS Envelope v1",
5
+ "type": "object",
6
+ "required": [
7
+ "$schema",
8
+ "_meta",
9
+ "success",
10
+ "result"
11
+ ],
12
+ "properties": {
13
+ "$schema": {
14
+ "type": "string",
15
+ "const": "https://lafs.dev/schemas/v1/envelope.schema.json"
16
+ },
17
+ "_meta": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": [
21
+ "specVersion",
22
+ "schemaVersion",
23
+ "timestamp",
24
+ "operation",
25
+ "requestId",
26
+ "transport",
27
+ "strict",
28
+ "mvi",
29
+ "contextVersion"
30
+ ],
31
+ "properties": {
32
+ "specVersion": {
33
+ "type": "string",
34
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
35
+ },
36
+ "schemaVersion": {
37
+ "type": "string",
38
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
39
+ },
40
+ "timestamp": {
41
+ "type": "string",
42
+ "format": "date-time"
43
+ },
44
+ "operation": {
45
+ "type": "string",
46
+ "minLength": 1,
47
+ "maxLength": 128
48
+ },
49
+ "requestId": {
50
+ "type": "string",
51
+ "minLength": 3,
52
+ "maxLength": 128
53
+ },
54
+ "transport": {
55
+ "type": "string",
56
+ "enum": ["cli", "http", "grpc", "sdk"]
57
+ },
58
+ "strict": {
59
+ "type": "boolean"
60
+ },
61
+ "mvi": {
62
+ "type": "string",
63
+ "enum": ["minimal", "standard", "full", "custom"],
64
+ "description": "Disclosure level: minimal (MVI only), standard (common fields), full (all fields), custom (per _fields parameter)"
65
+ },
66
+ "contextVersion": {
67
+ "type": "integer",
68
+ "minimum": 0
69
+ },
70
+ "sessionId": {
71
+ "type": "string",
72
+ "minLength": 1,
73
+ "maxLength": 256,
74
+ "description": "Session identifier for correlating multi-step agent workflows"
75
+ },
76
+ "warnings": {
77
+ "type": "array",
78
+ "items": {
79
+ "type": "object",
80
+ "properties": {
81
+ "code": { "type": "string", "description": "Warning identifier (e.g., DEPRECATED_FIELD)" },
82
+ "message": { "type": "string", "description": "Human-readable warning" },
83
+ "deprecated": { "type": "string", "description": "The deprecated feature or field name" },
84
+ "replacement": { "type": "string", "description": "Suggested replacement, if any" },
85
+ "removeBy": { "type": "string", "description": "Version when the deprecated feature will be removed" }
86
+ },
87
+ "required": ["code", "message"]
88
+ },
89
+ "description": "Non-fatal advisory warnings (deprecations, migration hints)"
90
+ }
91
+ }
92
+ },
93
+ "success": {
94
+ "type": "boolean"
95
+ },
96
+ "result": {
97
+ "type": ["object", "array", "null"]
98
+ },
99
+ "error": {
100
+ "type": ["object", "null"],
101
+ "additionalProperties": true,
102
+ "required": [
103
+ "code",
104
+ "message",
105
+ "category",
106
+ "retryable",
107
+ "retryAfterMs",
108
+ "details"
109
+ ],
110
+ "properties": {
111
+ "code": {
112
+ "type": "string",
113
+ "pattern": "^E_[A-Z0-9]+_[A-Z0-9_]+$"
114
+ },
115
+ "message": {
116
+ "type": "string",
117
+ "minLength": 1,
118
+ "maxLength": 1024
119
+ },
120
+ "category": {
121
+ "type": "string",
122
+ "enum": [
123
+ "VALIDATION",
124
+ "AUTH",
125
+ "PERMISSION",
126
+ "NOT_FOUND",
127
+ "CONFLICT",
128
+ "RATE_LIMIT",
129
+ "TRANSIENT",
130
+ "INTERNAL",
131
+ "CONTRACT",
132
+ "MIGRATION"
133
+ ]
134
+ },
135
+ "retryable": {
136
+ "type": "boolean"
137
+ },
138
+ "retryAfterMs": {
139
+ "type": ["integer", "null"],
140
+ "minimum": 0
141
+ },
142
+ "details": {
143
+ "type": "object"
144
+ },
145
+ "agentAction": {
146
+ "type": "string",
147
+ "enum": ["retry", "retry_modified", "escalate", "stop", "wait", "refresh_context", "authenticate"],
148
+ "description": "Machine-actionable instruction for the consuming agent"
149
+ },
150
+ "escalationRequired": {
151
+ "type": "boolean",
152
+ "description": "Whether human/owner intervention is required"
153
+ },
154
+ "suggestedAction": {
155
+ "type": "string",
156
+ "maxLength": 512,
157
+ "description": "Brief actionable instruction for error recovery"
158
+ },
159
+ "docUrl": {
160
+ "type": "string",
161
+ "format": "uri",
162
+ "description": "Documentation URL for this error type"
163
+ }
164
+ }
165
+ },
166
+ "page": {
167
+ "type": ["object", "null"],
168
+ "additionalProperties": false,
169
+ "required": ["mode"],
170
+ "properties": {
171
+ "mode": {
172
+ "type": "string",
173
+ "enum": ["offset", "cursor", "none"]
174
+ },
175
+ "limit": {
176
+ "type": "integer",
177
+ "minimum": 1,
178
+ "maximum": 1000
179
+ },
180
+ "offset": {
181
+ "type": "integer",
182
+ "minimum": 0
183
+ },
184
+ "nextCursor": {
185
+ "type": ["string", "null"],
186
+ "maxLength": 2048
187
+ },
188
+ "hasMore": {
189
+ "type": "boolean"
190
+ },
191
+ "total": {
192
+ "type": ["integer", "null"],
193
+ "minimum": 0
194
+ }
195
+ },
196
+ "allOf": [
197
+ {
198
+ "if": {
199
+ "type": "object",
200
+ "properties": { "mode": { "const": "cursor" } },
201
+ "required": ["mode"]
202
+ },
203
+ "then": {
204
+ "required": ["mode", "nextCursor", "hasMore"],
205
+ "properties": {
206
+ "mode": true,
207
+ "nextCursor": true,
208
+ "hasMore": true,
209
+ "limit": true,
210
+ "total": true
211
+ }
212
+ }
213
+ },
214
+ {
215
+ "if": {
216
+ "type": "object",
217
+ "properties": { "mode": { "const": "offset" } },
218
+ "required": ["mode"]
219
+ },
220
+ "then": {
221
+ "required": ["mode", "limit", "offset", "hasMore"],
222
+ "properties": {
223
+ "mode": true,
224
+ "limit": true,
225
+ "offset": true,
226
+ "hasMore": true,
227
+ "total": true
228
+ }
229
+ }
230
+ },
231
+ {
232
+ "if": {
233
+ "type": "object",
234
+ "properties": { "mode": { "const": "none" } },
235
+ "required": ["mode"]
236
+ },
237
+ "then": {
238
+ "required": ["mode"],
239
+ "properties": {
240
+ "mode": true
241
+ }
242
+ }
243
+ }
244
+ ]
245
+ },
246
+ "_extensions": {
247
+ "type": "object",
248
+ "description": "Vendor extensions. Keys SHOULD use x- prefix (e.g., x-myvendor-trace-id).",
249
+ "additionalProperties": true
250
+ }
251
+ },
252
+ "allOf": [
253
+ {
254
+ "if": {
255
+ "properties": {
256
+ "success": { "const": true }
257
+ }
258
+ },
259
+ "then": {
260
+ "properties": {
261
+ "error": { "type": "null" }
262
+ }
263
+ }
264
+ },
265
+ {
266
+ "if": {
267
+ "properties": {
268
+ "success": { "const": false }
269
+ }
270
+ },
271
+ "then": {
272
+ "required": ["error"],
273
+ "properties": {
274
+ "error": { "type": "object" }
275
+ }
276
+ }
277
+ },
278
+ {
279
+ "if": {
280
+ "properties": {
281
+ "_meta": {
282
+ "type": "object",
283
+ "properties": {
284
+ "strict": { "const": true }
285
+ }
286
+ }
287
+ }
288
+ },
289
+ "then": {
290
+ "additionalProperties": false,
291
+ "properties": {
292
+ "$schema": true,
293
+ "_meta": true,
294
+ "success": true,
295
+ "result": true,
296
+ "error": true,
297
+ "page": true,
298
+ "_extensions": true
299
+ }
300
+ },
301
+ "else": {
302
+ "additionalProperties": true
303
+ }
304
+ }
305
+ ]
306
+ }
@@ -0,0 +1,162 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "version": "1.0.0",
4
+ "codes": [
5
+ {
6
+ "code": "E_FORMAT_CONFLICT",
7
+ "category": "CONTRACT",
8
+ "description": "Mutually exclusive format flags requested",
9
+ "retryable": false,
10
+ "httpStatus": 400,
11
+ "grpcStatus": "INVALID_ARGUMENT",
12
+ "cliExit": 2,
13
+ "agentAction": "stop",
14
+ "typeUri": "https://lafs.dev/errors/v1/format-conflict",
15
+ "docUrl": "https://lafs.dev/docs/errors/format-conflict"
16
+ },
17
+ {
18
+ "code": "E_VALIDATION_SCHEMA",
19
+ "category": "VALIDATION",
20
+ "description": "Input failed schema validation",
21
+ "retryable": false,
22
+ "httpStatus": 400,
23
+ "grpcStatus": "INVALID_ARGUMENT",
24
+ "cliExit": 2,
25
+ "agentAction": "retry_modified",
26
+ "typeUri": "https://lafs.dev/errors/v1/validation-schema",
27
+ "docUrl": "https://lafs.dev/docs/errors/validation-schema"
28
+ },
29
+ {
30
+ "code": "E_NOT_FOUND_RESOURCE",
31
+ "category": "NOT_FOUND",
32
+ "description": "Referenced resource was not found",
33
+ "retryable": false,
34
+ "httpStatus": 404,
35
+ "grpcStatus": "NOT_FOUND",
36
+ "cliExit": 4,
37
+ "agentAction": "stop",
38
+ "typeUri": "https://lafs.dev/errors/v1/not-found-resource",
39
+ "docUrl": "https://lafs.dev/docs/errors/not-found-resource"
40
+ },
41
+ {
42
+ "code": "E_CONFLICT_VERSION",
43
+ "category": "CONFLICT",
44
+ "description": "Version or concurrency conflict",
45
+ "retryable": true,
46
+ "httpStatus": 409,
47
+ "grpcStatus": "ABORTED",
48
+ "cliExit": 7,
49
+ "agentAction": "refresh_context",
50
+ "typeUri": "https://lafs.dev/errors/v1/conflict-version",
51
+ "docUrl": "https://lafs.dev/docs/errors/conflict-version"
52
+ },
53
+ {
54
+ "code": "E_RATE_LIMITED",
55
+ "category": "RATE_LIMIT",
56
+ "description": "Rate limit exceeded",
57
+ "retryable": true,
58
+ "httpStatus": 429,
59
+ "grpcStatus": "RESOURCE_EXHAUSTED",
60
+ "cliExit": 8,
61
+ "agentAction": "wait",
62
+ "typeUri": "https://lafs.dev/errors/v1/rate-limited",
63
+ "docUrl": "https://lafs.dev/docs/errors/rate-limited"
64
+ },
65
+ {
66
+ "code": "E_TRANSIENT_UPSTREAM",
67
+ "category": "TRANSIENT",
68
+ "description": "Upstream dependency temporary failure",
69
+ "retryable": true,
70
+ "httpStatus": 503,
71
+ "grpcStatus": "UNAVAILABLE",
72
+ "cliExit": 9,
73
+ "agentAction": "retry",
74
+ "typeUri": "https://lafs.dev/errors/v1/transient-upstream",
75
+ "docUrl": "https://lafs.dev/docs/errors/transient-upstream"
76
+ },
77
+ {
78
+ "code": "E_INTERNAL_UNEXPECTED",
79
+ "category": "INTERNAL",
80
+ "description": "Unexpected internal failure",
81
+ "retryable": false,
82
+ "httpStatus": 500,
83
+ "grpcStatus": "INTERNAL",
84
+ "cliExit": 1,
85
+ "agentAction": "escalate",
86
+ "typeUri": "https://lafs.dev/errors/v1/internal-unexpected",
87
+ "docUrl": "https://lafs.dev/docs/errors/internal-unexpected"
88
+ },
89
+ {
90
+ "code": "E_CONTEXT_MISSING",
91
+ "category": "CONTRACT",
92
+ "description": "Required context ledger fields are missing",
93
+ "retryable": false,
94
+ "httpStatus": 400,
95
+ "grpcStatus": "FAILED_PRECONDITION",
96
+ "cliExit": 6,
97
+ "agentAction": "retry_modified",
98
+ "typeUri": "https://lafs.dev/errors/v1/context-missing",
99
+ "docUrl": "https://lafs.dev/docs/errors/context-missing"
100
+ },
101
+ {
102
+ "code": "E_CONTEXT_STALE",
103
+ "category": "CONFLICT",
104
+ "description": "Context ledger or references are stale",
105
+ "retryable": true,
106
+ "httpStatus": 409,
107
+ "grpcStatus": "ABORTED",
108
+ "cliExit": 7,
109
+ "agentAction": "refresh_context",
110
+ "typeUri": "https://lafs.dev/errors/v1/context-stale",
111
+ "docUrl": "https://lafs.dev/docs/errors/context-stale"
112
+ },
113
+ {
114
+ "code": "E_MIGRATION_UNSUPPORTED_VERSION",
115
+ "category": "MIGRATION",
116
+ "description": "Requested protocol/schema version unsupported",
117
+ "retryable": false,
118
+ "httpStatus": 426,
119
+ "grpcStatus": "FAILED_PRECONDITION",
120
+ "cliExit": 10,
121
+ "agentAction": "stop",
122
+ "typeUri": "https://lafs.dev/errors/v1/migration-unsupported-version",
123
+ "docUrl": "https://lafs.dev/docs/errors/migration-unsupported-version"
124
+ },
125
+ {
126
+ "code": "E_DISCLOSURE_UNKNOWN_FIELD",
127
+ "category": "VALIDATION",
128
+ "description": "Unrecognized expansion field in _expand parameter",
129
+ "retryable": false,
130
+ "httpStatus": 400,
131
+ "grpcStatus": "INVALID_ARGUMENT",
132
+ "cliExit": 2,
133
+ "agentAction": "retry_modified",
134
+ "typeUri": "https://lafs.dev/errors/v1/disclosure-unknown-field",
135
+ "docUrl": "https://lafs.dev/docs/errors/disclosure-unknown-field"
136
+ },
137
+ {
138
+ "code": "E_MVI_BUDGET_EXCEEDED",
139
+ "category": "VALIDATION",
140
+ "description": "Response exceeds declared MVI budget (token, byte, or item limit)",
141
+ "retryable": false,
142
+ "httpStatus": 413,
143
+ "grpcStatus": "RESOURCE_EXHAUSTED",
144
+ "cliExit": 2,
145
+ "agentAction": "retry_modified",
146
+ "typeUri": "https://lafs.dev/errors/v1/mvi-budget-exceeded",
147
+ "docUrl": "https://lafs.dev/docs/errors/mvi-budget-exceeded"
148
+ },
149
+ {
150
+ "code": "E_FIELD_CONFLICT",
151
+ "category": "CONTRACT",
152
+ "description": "Mutually exclusive field selection modes (single-field extraction and multi-field filtering cannot be combined)",
153
+ "retryable": false,
154
+ "httpStatus": 400,
155
+ "grpcStatus": "INVALID_ARGUMENT",
156
+ "cliExit": 2,
157
+ "agentAction": "stop",
158
+ "typeUri": "https://lafs.dev/errors/v1/field-conflict",
159
+ "docUrl": "https://lafs.dev/docs/errors/field-conflict"
160
+ }
161
+ ]
162
+ }