-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnegotiation-contract.json
More file actions
274 lines (274 loc) · 8.27 KB
/
negotiation-contract.json
File metadata and controls
274 lines (274 loc) · 8.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://xap.agentralabs.tech/schemas/v0.2/negotiation-contract.json",
"title": "NegotiationContract",
"description": "XAP v0.2 — Bilateral negotiation between two agents. Four states: OFFER, COUNTER, ACCEPT, REJECT. Every message is signed and chained via previous_state_hash.",
"type": "object",
"required": [
"negotiation_id",
"state",
"round_number",
"from_agent",
"to_agent",
"task",
"pricing",
"sla",
"expires_at",
"xap_version",
"created_at",
"signature"
],
"properties": {
"negotiation_id": {
"type": "string",
"pattern": "^neg_[a-f0-9]{8}$",
"description": "Unique negotiation identifier. Immutable once created."
},
"state": {
"type": "string",
"enum": ["OFFER", "COUNTER", "ACCEPT", "REJECT"],
"description": "Current negotiation state. Exactly four states. ACCEPT and REJECT are terminal."
},
"round_number": {
"type": "integer",
"minimum": 1,
"description": "Which round this is. OFFER is round 1. Each COUNTER increments."
},
"max_rounds": {
"type": "integer",
"minimum": 1,
"default": 20,
"description": "Maximum COUNTER rounds before auto-reject."
},
"from_agent": {
"type": "string",
"pattern": "^agent_[a-f0-9]{8}$",
"description": "Agent sending this message."
},
"to_agent": {
"type": "string",
"pattern": "^agent_[a-f0-9]{8}$",
"description": "Agent receiving this message."
},
"task": {
"type": "object",
"description": "What work is being negotiated.",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"description": "Task capability name. Must match a capability in the payee's AgentIdentity."
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+",
"description": "Required capability version (semver)."
},
"description": {
"type": "string",
"maxLength": 1000,
"description": "Human/LLM-readable task description."
},
"input_spec": {
"$ref": "#/$defs/IOSpec"
},
"output_spec": {
"$ref": "#/$defs/IOSpec"
},
"constraints": {
"type": "object",
"description": "Additional task constraints."
}
},
"additionalProperties": false
},
"pricing": {
"type": "object",
"description": "Proposed price and conditions. All amounts in integer minor units.",
"required": ["amount_minor_units", "currency", "model", "per"],
"properties": {
"amount_minor_units": {
"type": "integer",
"minimum": 0,
"description": "Base price in minor currency units (e.g., cents for USD)."
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3,6}$",
"description": "ISO 4217 currency code or crypto symbol (e.g., USD, USDC)."
},
"model": {
"type": "string",
"enum": ["fixed", "dynamic", "auction", "outcome_based"],
"description": "Pricing model."
},
"per": {
"type": "string",
"enum": ["request", "token", "second", "output_unit"],
"description": "Price unit."
},
"conditions": {
"type": "array",
"description": "Conditional pricing adjustments.",
"items": {
"$ref": "#/$defs/PricingCondition"
}
}
},
"additionalProperties": false
},
"sla": {
"type": "object",
"description": "Performance guarantees declared before execution.",
"required": ["max_latency_ms"],
"properties": {
"max_latency_ms": {
"type": "integer",
"minimum": 1,
"description": "Maximum acceptable latency in milliseconds."
},
"min_quality_score_bps": {
"type": "integer",
"minimum": 0,
"maximum": 10000,
"description": "Minimum quality threshold in basis points (0-10000)."
},
"availability_bps": {
"type": "integer",
"minimum": 0,
"maximum": 10000,
"description": "Required availability in basis points (0-10000)."
},
"max_retries": {
"type": "integer",
"minimum": 0,
"description": "Maximum acceptable retries."
}
},
"additionalProperties": false
},
"expires_at": {
"type": "string",
"format": "date-time",
"description": "When this offer/counter expires. Must be in the future at creation time."
},
"previous_state_hash": {
"type": "string",
"pattern": "^sha256:[a-f0-9]{64}$",
"description": "SHA-256 hash of the previous message in this negotiation chain. Absent for initial OFFER."
},
"parent_negotiation_id": {
"type": "string",
"pattern": "^neg_[a-f0-9]{8}$",
"description": "For renegotiation: references the original negotiation."
},
"identity_snapshot": {
"type": "object",
"description": "Snapshot of counterparty's AgentIdentity at offer time for audit.",
"required": ["agent_id", "snapshot_at"],
"properties": {
"agent_id": {
"type": "string",
"description": "Counterparty's agent_id at time of offer."
},
"reputation_snapshot": {
"type": "object",
"description": "Counterparty's reputation at time of offer."
},
"capabilities_hash": {
"type": "string",
"pattern": "^[a-f0-9]{64}$",
"description": "SHA-256 hash of counterparty's capabilities at time of offer."
},
"snapshot_at": {
"type": "string",
"format": "date-time",
"description": "When snapshot was taken."
}
},
"additionalProperties": false
},
"xap_version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+",
"description": "Protocol version (semver)."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "When this message was created."
},
"signature": {
"type": "string",
"description": "Ed25519 signature of the entire object by from_agent."
}
},
"additionalProperties": false,
"if": {
"not": {
"properties": {
"state": { "const": "OFFER" }
},
"required": ["state"]
}
},
"then": {
"required": ["previous_state_hash"]
},
"$defs": {
"IOSpec": {
"type": "object",
"description": "Input or output format specification.",
"required": ["format"],
"properties": {
"format": {
"type": "string",
"enum": ["plaintext", "json", "markdown", "binary", "image", "audio", "custom"],
"description": "Data format."
},
"max_tokens": {
"type": "integer",
"minimum": 1,
"description": "Maximum token count."
},
"schema_ref": {
"type": "string",
"format": "uri",
"description": "Reference to a JSON schema for structured input/output."
},
"content_type": {
"type": "string",
"description": "MIME type for binary/custom formats."
}
},
"additionalProperties": false
},
"PricingCondition": {
"type": "object",
"description": "Conditional pricing adjustment based on a metric.",
"required": ["metric", "operator", "threshold", "modifier_bps"],
"properties": {
"metric": {
"type": "string",
"description": "What is measured (e.g., latency_ms, quality_score, token_count)."
},
"operator": {
"type": "string",
"enum": ["lte", "gte", "eq", "lt", "gt"],
"description": "Comparison operator."
},
"threshold": {
"type": "integer",
"description": "The threshold value."
},
"modifier_bps": {
"type": "integer",
"minimum": 0,
"maximum": 10000,
"description": "Price modifier in basis points (10000 = full price, 5000 = 50%)."
}
},
"additionalProperties": false
}
}
}