@cleocode/lafs 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/schemas/v1/conformance-profiles.json +39 -0
- package/dist/schemas/v1/envelope.schema.json +306 -0
- package/dist/schemas/v1/error-registry.json +162 -0
- package/dist/src/a2a/bindings/grpc.d.ts +67 -0
- package/dist/src/a2a/bindings/grpc.js +148 -0
- package/dist/src/a2a/bindings/http.d.ts +102 -0
- package/dist/src/a2a/bindings/http.js +120 -0
- package/dist/src/a2a/bindings/index.d.ts +35 -0
- package/dist/src/a2a/bindings/index.js +79 -0
- package/dist/src/a2a/bindings/jsonrpc.d.ts +77 -0
- package/dist/src/a2a/bindings/jsonrpc.js +114 -0
- package/dist/src/a2a/bridge.d.ts +175 -0
- package/dist/src/a2a/bridge.js +286 -0
- package/dist/src/a2a/extensions.d.ts +121 -0
- package/dist/src/a2a/extensions.js +205 -0
- package/dist/src/a2a/index.d.ts +40 -0
- package/dist/src/a2a/index.js +76 -0
- package/dist/src/a2a/streaming.d.ts +74 -0
- package/dist/src/a2a/streaming.js +265 -0
- package/dist/src/a2a/task-lifecycle.d.ts +109 -0
- package/dist/src/a2a/task-lifecycle.js +313 -0
- package/dist/src/budgetEnforcement.d.ts +84 -0
- package/dist/src/budgetEnforcement.js +328 -0
- package/dist/src/circuit-breaker/index.d.ts +121 -0
- package/dist/src/circuit-breaker/index.js +249 -0
- package/dist/src/cli.d.ts +16 -0
- package/dist/src/cli.js +63 -0
- package/dist/src/compliance.d.ts +31 -0
- package/dist/src/compliance.js +89 -0
- package/dist/src/conformance.d.ts +7 -0
- package/dist/src/conformance.js +248 -0
- package/dist/src/conformanceProfiles.d.ts +11 -0
- package/dist/src/conformanceProfiles.js +34 -0
- package/dist/src/deprecationRegistry.d.ts +13 -0
- package/dist/src/deprecationRegistry.js +39 -0
- package/dist/src/discovery.d.ts +286 -0
- package/dist/src/discovery.js +350 -0
- package/dist/src/envelope.d.ts +60 -0
- package/dist/src/envelope.js +136 -0
- package/dist/src/errorRegistry.d.ts +28 -0
- package/dist/src/errorRegistry.js +36 -0
- package/dist/src/fieldExtraction.d.ts +67 -0
- package/dist/src/fieldExtraction.js +133 -0
- package/dist/src/flagResolver.d.ts +46 -0
- package/dist/src/flagResolver.js +47 -0
- package/dist/src/flagSemantics.d.ts +16 -0
- package/dist/src/flagSemantics.js +45 -0
- package/dist/src/health/index.d.ts +105 -0
- package/dist/src/health/index.js +220 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.js +34 -0
- package/dist/src/mcpAdapter.d.ts +28 -0
- package/dist/src/mcpAdapter.js +281 -0
- package/dist/src/mviProjection.d.ts +19 -0
- package/dist/src/mviProjection.js +116 -0
- package/dist/src/problemDetails.d.ts +34 -0
- package/dist/src/problemDetails.js +45 -0
- package/dist/src/shutdown/index.d.ts +69 -0
- package/dist/src/shutdown/index.js +160 -0
- package/dist/src/tokenEstimator.d.ts +87 -0
- package/dist/src/tokenEstimator.js +238 -0
- package/dist/src/types.d.ts +135 -0
- package/dist/src/types.js +12 -0
- package/dist/src/validateEnvelope.d.ts +15 -0
- package/dist/src/validateEnvelope.js +31 -0
- package/lafs.md +819 -0
- package/package.json +88 -0
- package/schemas/v1/agent-card.schema.json +230 -0
- package/schemas/v1/conformance-profiles.json +39 -0
- package/schemas/v1/context-ledger.schema.json +70 -0
- package/schemas/v1/discovery.schema.json +132 -0
- package/schemas/v1/envelope.schema.json +306 -0
- package/schemas/v1/error-registry.json +162 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# LAFS Protocol
|
|
2
|
+
|
|
3
|
+
**LLM-Agent-First Specification** — a response envelope contract for AI agent systems.
|
|
4
|
+
|
|
5
|
+
LAFS defines a standard envelope format for structured responses from LLM-powered agents and tools. It complements transport protocols like [MCP](https://modelcontextprotocol.io/) and [A2A](https://github.com/google/A2A) by standardizing what comes back — not how it gets there.
|
|
6
|
+
|
|
7
|
+
**Current version:** 1.5.0 | [📚 Documentation](https://codluv.gitbook.io/lafs/) | [Spec](lafs.md) | [Migration Guides](migrations/)
|
|
8
|
+
|
|
9
|
+
[](https://codluv.gitbook.io/lafs/)
|
|
10
|
+
[](https://www.npmjs.com/package/@cleocode/lafs)
|
|
11
|
+
|
|
12
|
+
## What LAFS provides
|
|
13
|
+
|
|
14
|
+
| Layer | Files | Description |
|
|
15
|
+
|-------|-------|-------------|
|
|
16
|
+
| **Spec** | `lafs.md` | Protocol specification with RFC 2119 language |
|
|
17
|
+
| **Schemas** | `schemas/v1/envelope.schema.json` | Envelope schema (Draft-07) with conditional pagination validation |
|
|
18
|
+
| | `schemas/v1/context-ledger.schema.json` | Context ledger for state tracking across request/response cycles |
|
|
19
|
+
| | `schemas/v1/error-registry.json` | 12 registered error codes with HTTP/gRPC/CLI transport mappings |
|
|
20
|
+
| **Tooling** | `src/` | TypeScript validation, conformance runner, CLI diagnostic tool |
|
|
21
|
+
| **A2A** | `src/a2a/` | Agent-to-Agent integration: extensions, task lifecycle, protocol bindings (JSON-RPC/HTTP/gRPC) |
|
|
22
|
+
| **Tests** | `tests/` | Tests covering envelope, pagination, strict mode, error handling, A2A extensions, task lifecycle, bindings |
|
|
23
|
+
| **Fixtures** | `fixtures/` | 14 JSON fixtures (valid + invalid) for conformance testing |
|
|
24
|
+
| **Docs** | `docs/` | [GitBook documentation](https://codluv.gitbook.io/lafs/) with guides, SDK reference, and specs |
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @cleocode/lafs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import {
|
|
36
|
+
createEnvelope,
|
|
37
|
+
parseLafsResponse,
|
|
38
|
+
LafsError,
|
|
39
|
+
validateEnvelope,
|
|
40
|
+
runEnvelopeConformance,
|
|
41
|
+
isRegisteredErrorCode,
|
|
42
|
+
} from "@cleocode/lafs";
|
|
43
|
+
|
|
44
|
+
// Build envelope with defaults
|
|
45
|
+
const envelope = createEnvelope({
|
|
46
|
+
success: true,
|
|
47
|
+
result: { items: [] },
|
|
48
|
+
meta: { operation: "example.list", requestId: "req_1" },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Validate an envelope against the schema
|
|
52
|
+
const validation = validateEnvelope(envelope);
|
|
53
|
+
if (!validation.valid) {
|
|
54
|
+
console.error(validation.errors);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Parse envelope responses with one function
|
|
58
|
+
try {
|
|
59
|
+
const parsed = parseLafsResponse(envelope);
|
|
60
|
+
console.log(parsed);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error instanceof LafsError) {
|
|
63
|
+
console.error(error.code, error.message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Run full conformance suite (schema + invariants + error codes + strict mode + pagination)
|
|
68
|
+
const report = runEnvelopeConformance(envelope);
|
|
69
|
+
console.log(report.ok); // true if all checks pass
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## LLM-agent implementation guides
|
|
73
|
+
|
|
74
|
+
- `docs/guides/llm-agent-guide.md` - parser, success/error handling, strict JSON policy
|
|
75
|
+
- `docs/guides/schema-extension.md` - operation-specific result validation on top of core schema
|
|
76
|
+
- `docs/guides/compliance-pipeline.md` - generation middleware with validate + conformance gates
|
|
77
|
+
- `docs/llms.txt` - LLM-oriented index and canonical sources
|
|
78
|
+
|
|
79
|
+
## CLI
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Run conformance checks on a fixture
|
|
83
|
+
npm run conformance -- --envelope fixtures/valid-success-envelope.json
|
|
84
|
+
|
|
85
|
+
# Run tests
|
|
86
|
+
npm test
|
|
87
|
+
|
|
88
|
+
# Type check
|
|
89
|
+
npm run typecheck
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Envelope structure
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"$schema": "https://lafs.dev/schemas/v1/envelope.schema.json",
|
|
97
|
+
"_meta": {
|
|
98
|
+
"specVersion": "1.0.0",
|
|
99
|
+
"schemaVersion": "1.0.0",
|
|
100
|
+
"timestamp": "2026-02-13T00:00:00Z",
|
|
101
|
+
"operation": "example.list",
|
|
102
|
+
"requestId": "req_01",
|
|
103
|
+
"transport": "http",
|
|
104
|
+
"strict": true,
|
|
105
|
+
"mvi": "standard",
|
|
106
|
+
"contextVersion": 1
|
|
107
|
+
},
|
|
108
|
+
"success": true,
|
|
109
|
+
"result": { "items": [{ "id": "1", "title": "Example" }] },
|
|
110
|
+
"page": {
|
|
111
|
+
"mode": "cursor",
|
|
112
|
+
"nextCursor": "eyJpZCI6IjEwIn0=",
|
|
113
|
+
"hasMore": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Key features
|
|
119
|
+
|
|
120
|
+
- **Conditional pagination** — cursor, offset, and none modes with mode-specific required fields
|
|
121
|
+
- **Strict/lenient mode** — `strict: true` rejects unknown properties; `strict: false` allows them
|
|
122
|
+
- **MVI disclosure levels** — `minimal`, `standard`, `full`, `custom` control response verbosity
|
|
123
|
+
- **Field selection** (`_fields`) and **expansion** (`_expand`) request parameters
|
|
124
|
+
- **Context ledger** — tracks state across request/response cycles with monotonic versioning
|
|
125
|
+
- **Error registry** — 12 codes with category, retryability, and transport-specific status mappings
|
|
126
|
+
- **Extension mechanism** — `_extensions` field for vendor metadata (`x-` prefix convention)
|
|
127
|
+
- **Adoption tiers** — Core, Standard, Complete with progressive conformance requirements
|
|
128
|
+
- **A2A integration** — Agent Card discovery, extension negotiation, task lifecycle management, protocol bindings
|
|
129
|
+
|
|
130
|
+
## A2A Integration
|
|
131
|
+
|
|
132
|
+
LAFS integrates with the [A2A Protocol](https://github.com/google/A2A) via `@a2a-js/sdk`. Import from the `@cleocode/lafs/a2a` subpath:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import {
|
|
136
|
+
// Extensions
|
|
137
|
+
buildLafsExtension,
|
|
138
|
+
extensionNegotiationMiddleware,
|
|
139
|
+
LAFS_EXTENSION_URI,
|
|
140
|
+
|
|
141
|
+
// Task lifecycle
|
|
142
|
+
TaskManager,
|
|
143
|
+
attachLafsEnvelope,
|
|
144
|
+
isTerminalState,
|
|
145
|
+
|
|
146
|
+
// Protocol bindings
|
|
147
|
+
getErrorCodeMapping,
|
|
148
|
+
createJsonRpcRequest,
|
|
149
|
+
createProblemDetails,
|
|
150
|
+
} from "@cleocode/lafs/a2a";
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Agent Card with LAFS extension** — use `autoIncludeLafsExtension` in discovery config:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { discoveryMiddleware } from "@cleocode/lafs/discovery";
|
|
157
|
+
|
|
158
|
+
app.use(discoveryMiddleware({
|
|
159
|
+
agent: { name: "my-agent", /* ... */ },
|
|
160
|
+
autoIncludeLafsExtension: true,
|
|
161
|
+
}));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Protocol bindings** are also available as a standalone subpath:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { getErrorCodeMapping } from "@cleocode/lafs/a2a/bindings";
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Conformance checks
|
|
171
|
+
|
|
172
|
+
| Check | Description | Tier |
|
|
173
|
+
|-------|-------------|------|
|
|
174
|
+
| `envelope_schema_valid` | Validates against JSON Schema | Core |
|
|
175
|
+
| `envelope_invariants` | success/result/error consistency | Core |
|
|
176
|
+
| `error_code_registered` | Error code exists in registry | Core |
|
|
177
|
+
| `meta_mvi_present` | Valid MVI disclosure level | Standard |
|
|
178
|
+
| `meta_strict_present` | Strict mode declared | Standard |
|
|
179
|
+
| `strict_mode_behavior` | Optional fields omitted (not null) in strict mode | Standard |
|
|
180
|
+
| `strict_mode_enforced` | Additional properties rejected/allowed per mode | Standard |
|
|
181
|
+
| `pagination_mode_consistent` | Page fields match declared mode | Standard |
|
|
182
|
+
|
|
183
|
+
## Project layout
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
lafs.md # Protocol specification
|
|
187
|
+
schemas/v1/
|
|
188
|
+
envelope.schema.json # Envelope schema (Draft-07)
|
|
189
|
+
context-ledger.schema.json # Context ledger schema
|
|
190
|
+
error-registry.json # Error code registry
|
|
191
|
+
src/
|
|
192
|
+
types.ts # TypeScript types (discriminated unions)
|
|
193
|
+
validateEnvelope.ts # Ajv-based schema validator
|
|
194
|
+
conformance.ts # Conformance runner (8 checks)
|
|
195
|
+
errorRegistry.ts # Error code helpers
|
|
196
|
+
flagSemantics.ts # Format flag resolution
|
|
197
|
+
discovery.ts # A2A Agent Card discovery middleware
|
|
198
|
+
cli.ts # CLI diagnostic tool
|
|
199
|
+
a2a/
|
|
200
|
+
bridge.ts # A2A SDK integration & result wrapper
|
|
201
|
+
extensions.ts # Extension negotiation & LAFS extension builder
|
|
202
|
+
task-lifecycle.ts # Task state machine & lifecycle management
|
|
203
|
+
bindings/
|
|
204
|
+
jsonrpc.ts # JSON-RPC 2.0 method/error constants & builders
|
|
205
|
+
http.ts # HTTP endpoints, RFC 9457 Problem Details
|
|
206
|
+
grpc.ts # gRPC status codes & service definitions (types only)
|
|
207
|
+
index.ts # Barrel export & cross-binding error mapping
|
|
208
|
+
tests/ # Tests (vitest)
|
|
209
|
+
fixtures/ # JSON test fixtures
|
|
210
|
+
docs/
|
|
211
|
+
POSITIONING.md # MCP/A2A complementary positioning
|
|
212
|
+
VISION.md # Project vision and primary persona
|
|
213
|
+
CONFORMANCE.md # Conformance checks and adoption tiers
|
|
214
|
+
migrations/
|
|
215
|
+
v0.3.0-to-v0.4.0.md # Envelope rationalization migration
|
|
216
|
+
v0.4.0-to-v0.5.0.md # Pagination & MVI schema migration
|
|
217
|
+
CONTRIBUTING.md # Contributor guidelines, RFC process
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Version history
|
|
221
|
+
|
|
222
|
+
| Version | Phase | Description |
|
|
223
|
+
|---------|-------|-------------|
|
|
224
|
+
| **v1.2.3** | **4** | **A2A v1.0+ compliance: extension negotiation, task lifecycle, protocol bindings (JSON-RPC/HTTP/gRPC)** |
|
|
225
|
+
| v1.0.0 | 3 | Production release: Token budgets, agent discovery, MCP integration, complete SDKs |
|
|
226
|
+
| v0.5.0 | 2B | Conditional pagination, MVI field selection/expansion, context ledger schema |
|
|
227
|
+
| v0.4.0 | 2A | Optional page/error, extensions, strict/lenient mode, warnings |
|
|
228
|
+
| v0.3.0 | 1 | Strategic positioning, vision alignment, adoption tiers |
|
|
229
|
+
| v0.2.0 | 0 | Protocol cleanup, fixtures, governance, security considerations |
|
|
230
|
+
| v0.1.1 | — | Initial npm publish |
|
|
231
|
+
| v0.1.0 | — | Bootstrap |
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"tiers": {
|
|
5
|
+
"core": [
|
|
6
|
+
"envelope_schema_valid",
|
|
7
|
+
"envelope_invariants",
|
|
8
|
+
"error_code_registered"
|
|
9
|
+
],
|
|
10
|
+
"standard": [
|
|
11
|
+
"envelope_schema_valid",
|
|
12
|
+
"envelope_invariants",
|
|
13
|
+
"error_code_registered",
|
|
14
|
+
"agent_action_valid",
|
|
15
|
+
"error_registry_agent_action",
|
|
16
|
+
"transport_mapping_consistent",
|
|
17
|
+
"meta_mvi_present",
|
|
18
|
+
"meta_strict_present",
|
|
19
|
+
"strict_mode_behavior",
|
|
20
|
+
"pagination_mode_consistent",
|
|
21
|
+
"strict_mode_enforced"
|
|
22
|
+
],
|
|
23
|
+
"complete": [
|
|
24
|
+
"envelope_schema_valid",
|
|
25
|
+
"envelope_invariants",
|
|
26
|
+
"error_code_registered",
|
|
27
|
+
"agent_action_valid",
|
|
28
|
+
"error_registry_agent_action",
|
|
29
|
+
"transport_mapping_consistent",
|
|
30
|
+
"context_mutation_failure",
|
|
31
|
+
"context_preservation_valid",
|
|
32
|
+
"meta_mvi_present",
|
|
33
|
+
"meta_strict_present",
|
|
34
|
+
"strict_mode_behavior",
|
|
35
|
+
"pagination_mode_consistent",
|
|
36
|
+
"strict_mode_enforced"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -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
|
+
}
|