@redditech/agent-protocol 0.0.0-stage → 0.2.1

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 (55) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +394 -2
  4. package/dist/adl.d.ts +141 -0
  5. package/dist/adl.js +3601 -0
  6. package/dist/agent-stack-fixtures.d.ts +743 -0
  7. package/dist/agent-stack-fixtures.js +1554 -0
  8. package/dist/ai-catalog.d.ts +128 -0
  9. package/dist/ai-catalog.js +373 -0
  10. package/dist/attestation-reputation.d.ts +102 -0
  11. package/dist/attestation-reputation.js +279 -0
  12. package/dist/audd-rail-config.d.ts +102 -0
  13. package/dist/audd-rail-config.js +294 -0
  14. package/dist/browser-wallet-approval.d.ts +293 -0
  15. package/dist/browser-wallet-approval.js +1201 -0
  16. package/dist/discovery-source.d.ts +115 -0
  17. package/dist/discovery-source.js +251 -0
  18. package/dist/evidence-archive.d.ts +73 -0
  19. package/dist/evidence-archive.js +238 -0
  20. package/dist/index.d.ts +23 -0
  21. package/dist/index.js +23 -0
  22. package/dist/mpp-tempo-receipt-shapes.d.ts +201 -0
  23. package/dist/mpp-tempo-receipt-shapes.js +330 -0
  24. package/dist/okf-adapter.d.ts +229 -0
  25. package/dist/okf-adapter.js +556 -0
  26. package/dist/okf-conformance.d.ts +208 -0
  27. package/dist/okf-conformance.js +651 -0
  28. package/dist/okf-instruction-safety.d.ts +192 -0
  29. package/dist/okf-instruction-safety.js +509 -0
  30. package/dist/onboarding-analyser-handoff.d.ts +391 -0
  31. package/dist/onboarding-analyser-handoff.js +959 -0
  32. package/dist/onboarding-state-machine.d.ts +228 -0
  33. package/dist/onboarding-state-machine.js +432 -0
  34. package/dist/payment-records.d.ts +181 -0
  35. package/dist/payment-records.js +599 -0
  36. package/dist/policy.d.ts +33 -0
  37. package/dist/policy.js +45 -0
  38. package/dist/provider-trust.d.ts +113 -0
  39. package/dist/provider-trust.js +346 -0
  40. package/dist/quasar-registry-compatibility.d.ts +113 -0
  41. package/dist/quasar-registry-compatibility.js +214 -0
  42. package/dist/ranking-explainability.d.ts +202 -0
  43. package/dist/ranking-explainability.js +302 -0
  44. package/dist/receipt-v2.d.ts +202 -0
  45. package/dist/receipt-v2.js +418 -0
  46. package/dist/repo-explorer-evidence-manifest.d.ts +387 -0
  47. package/dist/repo-explorer-evidence-manifest.js +1187 -0
  48. package/dist/source-diagnostics.d.ts +84 -0
  49. package/dist/source-diagnostics.js +193 -0
  50. package/dist/source-trust-conformance-matrix.d.ts +207 -0
  51. package/dist/source-trust-conformance-matrix.js +672 -0
  52. package/examples/ard-no-spend-ai-catalog.json +51 -0
  53. package/examples/ard-no-spend-demo.mjs +355 -0
  54. package/examples/interpretation-guide-scenarios.mjs +302 -0
  55. package/package.json +144 -4
package/dist/adl.js ADDED
@@ -0,0 +1,3601 @@
1
+ /**
2
+ * Agent Definition Language (ADL) v0.3 for the Reddi Agent Protocol.
3
+ *
4
+ * ADL is owned by nissan/reddiagent-lab: `specs/ADL-v0.3.md`, its JSON Schema
5
+ * and the Python conformance checker `scripts/adl_v03_conformance.py`. This
6
+ * module is the TypeScript port the platform runs: the same schema (a copy at the
7
+ * end of this file, kept in step by `scripts/sync-adl-v03.mjs`) and the same
8
+ * level checks, so a document passes here exactly when it passes in the lab.
9
+ * The tests hold every lab example to the lab checker's verdict.
10
+ *
11
+ * The protocol fee is 5% (500 bps), with an optional `launchRate` block that
12
+ * must say 2.5% (250 bps) for payouts before 2027-04-01T00:00:00Z, the rates
13
+ * in `@redditech/x402-solana` and the program.
14
+ *
15
+ * It also builds the ADL document a per-token provider publishes
16
+ * (`buildProviderAdl`) and reads a provider's listing terms back out of one
17
+ * (`providerTermsFromAdl`), so a listing and its ADL cannot say different
18
+ * things.
19
+ *
20
+ * Validating a document never makes a payment and proves nothing about a
21
+ * deployment. No network access.
22
+ */
23
+ import Ajv2020Module from "ajv/dist/2020.js";
24
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
25
+ export const ADL_V03_API_VERSION = "reddiagent.dev/v0.3";
26
+ export const ADL_V03_RECEIPT_FORMAT = "reddi.receipt.v2";
27
+ export const ADL_V03_LIVE_RAIL = "solana";
28
+ /** The protocol fee: 5% of the amount actually paid. */
29
+ export const ADL_V03_PROTOCOL_FEE_BPS = 500;
30
+ /** The launch rate: 2.5% for payouts before `endsAt`. */
31
+ export const ADL_V03_LAUNCH_RATE = Object.freeze({ bps: 250, endsAt: "2027-04-01T00:00:00Z" });
32
+ export const ADL_V03_PROTOCOL_FEE_SOL_CAP = "0.1";
33
+ /** Mints the escrow program accepts on Solana mainnet-beta. Devnet mints are the operator's choice. */
34
+ export const ADL_V03_MAINNET_MINTS = Object.freeze({
35
+ USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
36
+ AUDD: "AUDDttiEpCydTm7joUMbYddm72jAWXZnCpPZtDoxqBSw",
37
+ PYUSD: "2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",
38
+ USDG: "2u1tszSeqZ3qBWF3uNGPFc8TzMk2tdiwknnRMWGWjGWH",
39
+ });
40
+ /** The largest ADL document the parser accepts, in UTF-8 bytes. */
41
+ export const ADL_MAX_DOCUMENT_BYTES = 64 * 1024;
42
+ const LIVE_GATED_BEFORE_LEVEL_3 = "payment/reputation extension requires Level 3 or higher";
43
+ const LIVE_GATED_BEFORE_LEVEL_4 = "production deployment descriptor requires Level 4";
44
+ const MIGRATION_NOTE = "docs/ADL-V0.2-TO-V0.3-MIGRATION.md";
45
+ const PRODUCTION_RUNTIME_TARGETS = new Set(["hosted-container", "serverless", "platform-native", "openclaw"]);
46
+ const OBSERVABILITY_EVENTS_BY_LEVEL = {
47
+ 1: ["trace.started", "trace.completed", "task.completed", "task.failed"],
48
+ 2: ["model.called", "policy.checked", "eval.checked"],
49
+ 3: ["payment.intent.created", "receipt.emitted", "reputation.signal.emitted"],
50
+ 4: ["deployment.health.checked", "adapter.loss.reported"],
51
+ };
52
+ const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
53
+ const obj = (value) => (isObj(value) ? value : {});
54
+ const list = (value) => (Array.isArray(value) ? value : []);
55
+ /**
56
+ * Reads an ADL document from YAML or JSON text. YAML 1.1 rules, as the lab's
57
+ * PyYAML reads it. Refuses documents over `ADL_MAX_DOCUMENT_BYTES`, aliases
58
+ * beyond a small bound, duplicate keys and a top level that is not a mapping.
59
+ */
60
+ export function parseAdlDocument(text) {
61
+ if (typeof text !== "string" || text.trim() === "")
62
+ return { ok: false, message: "The ADL document is empty." };
63
+ if (new TextEncoder().encode(text).length > ADL_MAX_DOCUMENT_BYTES)
64
+ return { ok: false, message: `The ADL document is larger than ${ADL_MAX_DOCUMENT_BYTES / 1024} KB.` };
65
+ let value;
66
+ try {
67
+ value = parseYaml(text, { version: "1.1", uniqueKeys: true, maxAliasCount: 50, prettyErrors: false });
68
+ }
69
+ catch (error) {
70
+ return { ok: false, message: `The ADL document is not valid YAML or JSON: ${error instanceof Error ? error.message.split("\n")[0] : "parse error"}` };
71
+ }
72
+ if (!isObj(value))
73
+ return { ok: false, message: "The ADL document must be a mapping at the top level." };
74
+ return { ok: true, document: value };
75
+ }
76
+ /** The document as YAML text, for publishing. */
77
+ export function formatAdlDocument(document) {
78
+ // Written under YAML 1.1 rules so strings such as dates and "yes" are quoted and read back as strings.
79
+ return stringifyYaml(document, { version: "1.1", lineWidth: 0 });
80
+ }
81
+ // ajv ships CommonJS; under NodeNext its default export is the module object.
82
+ const Ajv2020 = (Ajv2020Module.default ?? Ajv2020Module);
83
+ let compiled;
84
+ function schemaValidator() {
85
+ // The lab validates with jsonschema's Draft 2020-12 validator, which does not assert formats.
86
+ compiled ??= new Ajv2020({ allErrors: true, strict: false, validateFormats: false }).compile(ADL_V03_SCHEMA);
87
+ return compiled;
88
+ }
89
+ function schemaDiagnostics(doc) {
90
+ if (doc.apiVersion !== ADL_V03_API_VERSION) {
91
+ return [{ path: "apiVersion", message: `expected ${ADL_V03_API_VERSION}, found ${JSON.stringify(doc.apiVersion ?? null)}; earlier versions are not valid ADL v0.3, see ${MIGRATION_NOTE}` }];
92
+ }
93
+ const validate = schemaValidator();
94
+ if (validate(doc))
95
+ return [];
96
+ return (validate.errors ?? []).map((error) => {
97
+ const extra = error.params && "additionalProperty" in error.params ? ` (${String(error.params.additionalProperty)})` : "";
98
+ return { path: error.instancePath.replace(/^\//, "").replace(/\//g, ".") || "$", message: `${error.message ?? "is invalid"}${extra}` };
99
+ });
100
+ }
101
+ function hasPath(doc, dotted) {
102
+ let value = doc;
103
+ for (const part of dotted.split(".")) {
104
+ if (!isObj(value) || !(part in value))
105
+ return false;
106
+ value = value[part];
107
+ }
108
+ if (value === null || value === undefined)
109
+ return false;
110
+ if (typeof value === "string" || Array.isArray(value))
111
+ return value.length > 0;
112
+ if (isObj(value))
113
+ return Object.keys(value).length > 0;
114
+ return true;
115
+ }
116
+ /** Equal as decimals, both given as decimal strings. */
117
+ function decimalEqual(left, right) {
118
+ if (typeof left !== "string" || typeof right !== "string")
119
+ return false;
120
+ const norm = (s) => {
121
+ const m = /^\s*([+-]?)(\d*)(?:\.(\d*))?\s*$/.exec(s);
122
+ if (!m || (m[2] === "" && (m[3] ?? "") === ""))
123
+ return undefined;
124
+ const int = m[2].replace(/^0+/, "");
125
+ const frac = (m[3] ?? "").replace(/0+$/, "");
126
+ const sign = int === "" && frac === "" ? "" : m[1] === "-" ? "-" : "";
127
+ return `${sign}${int}.${frac}`;
128
+ };
129
+ const a = norm(left);
130
+ const b = norm(right);
131
+ return a !== undefined && a === b;
132
+ }
133
+ /** Deep equality of JSON-like values, as Python's `==` on parsed YAML. */
134
+ function same(a, b) {
135
+ if (a === b)
136
+ return true;
137
+ if (Array.isArray(a) && Array.isArray(b))
138
+ return a.length === b.length && a.every((v, i) => same(v, b[i]));
139
+ if (isObj(a) && isObj(b)) {
140
+ const ka = Object.keys(a);
141
+ return ka.length === Object.keys(b).length && ka.every((k) => k in b && same(a[k], b[k]));
142
+ }
143
+ return false;
144
+ }
145
+ const x402Of = (doc) => obj(obj(doc.extensions).x402);
146
+ const paymentMode = (doc) => (typeof x402Of(doc).mode === "string" ? x402Of(doc).mode : null);
147
+ const paymentIntents = (doc) => list(x402Of(doc).intents).filter(isObj);
148
+ function policiesById(doc) {
149
+ const map = new Map();
150
+ for (const policy of list(obj(doc.harness).policies))
151
+ if (isObj(policy) && typeof policy.id === "string")
152
+ map.set(policy.id, policy);
153
+ return map;
154
+ }
155
+ function receiptsByIntent(doc) {
156
+ const map = new Map();
157
+ for (const ref of list(obj(obj(doc.extensions).receipts).refs))
158
+ if (isObj(ref) && typeof ref.intentRef === "string")
159
+ map.set(ref.intentRef, ref);
160
+ return map;
161
+ }
162
+ function authorityMatchesIntent(intent) {
163
+ const authority = obj(intent.authority);
164
+ if (Object.keys(authority).length === 0)
165
+ return false;
166
+ for (const key of ["asset", "rail", "purpose", "scope"])
167
+ if (!same(authority[key], intent[key]))
168
+ return false;
169
+ return decimalEqual(authority.maxAmount, intent.maxAmount);
170
+ }
171
+ function policyMatchesIntent(policy, intent) {
172
+ const limits = obj(policy.limits);
173
+ const enforcement = obj(policy.enforcement);
174
+ if (policy.capability !== "payment")
175
+ return false;
176
+ if (policy.resource !== `x402:intent:${String(intent.id)}`)
177
+ return false;
178
+ if (policy.action !== intent.direction)
179
+ return false;
180
+ if (policy.effect !== "allow")
181
+ return false;
182
+ if (enforcement.target !== "policy-engine" || enforcement.phase !== "before-execution")
183
+ return false;
184
+ if (limits.requireReceipt !== true)
185
+ return false;
186
+ const price = obj(intent.price);
187
+ const bound = intent.direction === "charge" ? (price.per === "token" ? price.maxPerCall : price.amount) : intent.maxAmount;
188
+ return limits.asset === obj(intent.asset).symbol && decimalEqual(limits.maxAmount, bound);
189
+ }
190
+ function paymentSemanticDiagnostics(doc) {
191
+ const problems = [];
192
+ const x402 = x402Of(doc);
193
+ const mode = paymentMode(doc);
194
+ const fee = x402.protocolFee;
195
+ if (isObj(fee)) {
196
+ if (fee.bps !== ADL_V03_PROTOCOL_FEE_BPS)
197
+ problems.push(`extensions.x402.protocolFee.bps must be ${ADL_V03_PROTOCOL_FEE_BPS}`);
198
+ if ("launchRate" in fee) {
199
+ const launch = obj(fee.launchRate);
200
+ if (launch.bps !== ADL_V03_LAUNCH_RATE.bps || launch.endsAt !== ADL_V03_LAUNCH_RATE.endsAt)
201
+ problems.push(`extensions.x402.protocolFee.launchRate must be ${ADL_V03_LAUNCH_RATE.bps} bps ending ${ADL_V03_LAUNCH_RATE.endsAt}`);
202
+ }
203
+ const cap = obj(fee.cap);
204
+ if (cap.symbol !== "SOL" || !decimalEqual(cap.amount, ADL_V03_PROTOCOL_FEE_SOL_CAP))
205
+ problems.push(`extensions.x402.protocolFee.cap must be ${ADL_V03_PROTOCOL_FEE_SOL_CAP} SOL`);
206
+ }
207
+ for (const intent of paymentIntents(doc)) {
208
+ const id = String(intent.id ?? "None");
209
+ const holders = [["", intent]];
210
+ if (isObj(intent.authority))
211
+ holders.push([".authority", intent.authority]);
212
+ for (const [suffix, holder] of holders) {
213
+ const asset = obj(holder.asset);
214
+ const symbol = typeof asset.symbol === "string" ? asset.symbol : "";
215
+ if (asset.network === "solana-mainnet-beta" && symbol in ADL_V03_MAINNET_MINTS && asset.mint !== ADL_V03_MAINNET_MINTS[symbol]) {
216
+ problems.push(`extensions.x402.intents[${id}]${suffix}.asset.mint is not the allowlisted ${symbol} mint on solana-mainnet-beta`);
217
+ }
218
+ }
219
+ if (intent.direction === "charge") {
220
+ const perToken = obj(intent.price).per === "token";
221
+ const metered = intent.settlement === "metered-escrow";
222
+ if (perToken && !metered)
223
+ problems.push(`extensions.x402.intents[${id}].settlement must be metered-escrow for a per-token price`);
224
+ else if (metered && !perToken)
225
+ problems.push(`extensions.x402.intents[${id}].settlement=metered-escrow needs a per-token price`);
226
+ }
227
+ if (mode === "live") {
228
+ if (intent.rail !== ADL_V03_LIVE_RAIL)
229
+ problems.push(`extensions.x402.intents[${id}].rail=${String(intent.rail ?? "None")} is an unsupported live payment rail`);
230
+ if (intent.direction === "charge" && !isObj(fee))
231
+ problems.push("extensions.x402.protocolFee is required for a live charge");
232
+ }
233
+ }
234
+ return problems;
235
+ }
236
+ function authorityMissingFields(doc) {
237
+ const policies = policiesById(doc);
238
+ const receipts = receiptsByIntent(doc);
239
+ const missing = [];
240
+ for (const intent of paymentIntents(doc)) {
241
+ if (typeof intent.id !== "string")
242
+ continue;
243
+ const id = intent.id;
244
+ const direction = intent.direction;
245
+ if (direction !== "spend" && direction !== "refund" && direction !== "charge")
246
+ continue;
247
+ if (direction !== "charge" || isObj(intent.authority)) {
248
+ if (!authorityMatchesIntent(intent))
249
+ missing.push(`extensions.x402.intents[${id}].authority`);
250
+ }
251
+ const receipt = receipts.get(id);
252
+ if (!receipt)
253
+ missing.push(`extensions.receipts.refs[intentRef=${id}]`);
254
+ else if (receipt.format !== ADL_V03_RECEIPT_FORMAT)
255
+ missing.push(`extensions.receipts.refs[intentRef=${id}].format=${ADL_V03_RECEIPT_FORMAT}`);
256
+ const matched = list(intent.policyRefs).some((ref) => {
257
+ const policy = typeof ref === "string" ? policies.get(ref) : undefined;
258
+ return policy !== undefined && policyMatchesIntent(policy, intent);
259
+ });
260
+ if (!matched)
261
+ missing.push(`harness.policies[payment:x402:intent:${id}]`);
262
+ }
263
+ return missing;
264
+ }
265
+ function hasProductionRuntime(doc) {
266
+ const target = obj(obj(doc.harness).runtime).target;
267
+ return typeof target === "string" && PRODUCTION_RUNTIME_TARGETS.has(target);
268
+ }
269
+ function hasDeploymentDescriptor(doc) {
270
+ const deployment = obj(doc.harness).deployment;
271
+ if (!isObj(deployment) || Object.keys(deployment).length === 0)
272
+ return false;
273
+ if (["container", "serverless", "platform-native", "openclaw"].includes(deployment.target))
274
+ return true;
275
+ if (["preview", "staging", "production"].includes(deployment.environment))
276
+ return true;
277
+ const rollback = obj(deployment.rollback);
278
+ if (Object.keys(rollback).length > 0 && rollback.mode !== "none")
279
+ return true;
280
+ return ["region", "resources", "secretRefs", "networkPolicy", "storage", "scheduler", "observability", "healthCheck", "constraints"].some((f) => f in deployment);
281
+ }
282
+ function missingObservabilityEvents(doc, level) {
283
+ const declared = new Set(list(obj(obj(doc.harness).observability).events).filter(isObj).map((e) => e.name).filter((n) => typeof n === "string"));
284
+ return (OBSERVABILITY_EVENTS_BY_LEVEL[level] ?? []).filter((e) => !declared.has(e)).map((e) => `harness.observability.events.${e}`);
285
+ }
286
+ function levelMissingFields(doc, level) {
287
+ if (level === 0)
288
+ return [];
289
+ if (level === 1) {
290
+ const missing = ["harness.instructions", "harness.runtime.target", "harness.evalGates"].filter((f) => !hasPath(doc, f));
291
+ return [...missing, ...missingObservabilityEvents(doc, 1)];
292
+ }
293
+ if (level === 2) {
294
+ const missing = ["model.capability", "model.providers.preferred", "model.requirements", "harness.policies", "harness.evalGates"].filter((f) => !hasPath(doc, f));
295
+ return [...missing, ...missingObservabilityEvents(doc, 2)];
296
+ }
297
+ if (level === 3) {
298
+ const missing = [];
299
+ const extensions = obj(doc.extensions);
300
+ const x402 = obj(extensions.x402);
301
+ if (x402.enabled !== true)
302
+ missing.push("extensions.x402.enabled=true");
303
+ const intents = x402.intents;
304
+ if (!Array.isArray(intents) || intents.length === 0)
305
+ missing.push("extensions.x402.intents");
306
+ else if (intents.some((i) => isObj(i) && !hasValue(i.policyRefs)))
307
+ missing.push("extensions.x402.intents[*].policyRefs");
308
+ if (obj(extensions.receipts).required !== true)
309
+ missing.push("extensions.receipts.required=true");
310
+ if (!hasValue(obj(extensions.reputation).emitSignals))
311
+ missing.push("extensions.reputation.emitSignals");
312
+ if (paymentMode(doc) === null)
313
+ missing.push("extensions.x402.mode");
314
+ return [...missing, ...authorityMissingFields(doc), ...paymentSemanticDiagnostics(doc), ...missingObservabilityEvents(doc, 3)];
315
+ }
316
+ if (level === 4) {
317
+ const missing = [];
318
+ if (!hasProductionRuntime(doc))
319
+ missing.push("harness.runtime.target in hosted-container|serverless|platform-native|openclaw");
320
+ for (const f of ["harness.deployment.environment", "harness.deployment.rollback", "harness.observability.events", "harness.recovery.disable"])
321
+ if (!hasPath(doc, f))
322
+ missing.push(f);
323
+ return [...missing, ...missingObservabilityEvents(doc, 4)];
324
+ }
325
+ throw new Error(`Unknown ADL v0.3 conformance level: ${level}`);
326
+ }
327
+ /** Python truthiness for the values a YAML document holds. */
328
+ function hasValue(value) {
329
+ if (value === null || value === undefined || value === false || value === 0 || value === "")
330
+ return false;
331
+ if (Array.isArray(value))
332
+ return value.length > 0;
333
+ if (isObj(value))
334
+ return Object.keys(value).length > 0;
335
+ return true;
336
+ }
337
+ function levelForbidden(doc, level) {
338
+ const forbidden = [];
339
+ if (level < 3 && x402Of(doc).enabled)
340
+ forbidden.push(LIVE_GATED_BEFORE_LEVEL_3);
341
+ if (level < 4 && (hasProductionRuntime(doc) || hasDeploymentDescriptor(doc)))
342
+ forbidden.push(LIVE_GATED_BEFORE_LEVEL_4);
343
+ return forbidden;
344
+ }
345
+ /**
346
+ * Checks an ADL v0.3 document against the schema and every conformance level
347
+ * up to the requested one (the option, else `conformance.requestedLevel`,
348
+ * else 0). The same verdict as the lab's `adl_v03_conformance.py`.
349
+ */
350
+ export function checkAdlConformance(doc, options = {}) {
351
+ const schemaErrors = schemaDiagnostics(doc);
352
+ const declared = obj(doc.conformance).requestedLevel;
353
+ const requested = options.requestedLevel ?? (typeof declared === "number" && Number.isInteger(declared) && declared >= 0 && declared <= 4 ? declared : 0);
354
+ const missingFieldsByLevel = {};
355
+ const forbiddenCapabilitiesByLevel = {};
356
+ if (schemaErrors.length === 0) {
357
+ for (let level = 0; level <= requested; level++) {
358
+ missingFieldsByLevel[String(level)] = levelMissingFields(doc, level);
359
+ forbiddenCapabilitiesByLevel[String(level)] = levelForbidden(doc, level);
360
+ }
361
+ }
362
+ let achieved = -1;
363
+ if (schemaErrors.length === 0) {
364
+ achieved = 0;
365
+ for (let level = 1; level <= 4; level++) {
366
+ if (levelMissingFields(doc, level).length > 0)
367
+ break;
368
+ achieved = level;
369
+ }
370
+ }
371
+ const requestedMissing = Object.values(missingFieldsByLevel).flat();
372
+ const requestedForbidden = forbiddenCapabilitiesByLevel[String(requested)] ?? [];
373
+ const pass = schemaErrors.length === 0 && requestedMissing.length === 0 && requestedForbidden.length === 0 && achieved >= requested;
374
+ const mode = paymentMode(doc);
375
+ return {
376
+ agent: typeof obj(doc.metadata).name === "string" ? obj(doc.metadata).name : "",
377
+ apiVersion: ADL_V03_API_VERSION,
378
+ requestedLevel: requested,
379
+ achievedLevel: achieved,
380
+ status: pass ? "pass" : "fail",
381
+ schemaDiagnostics: schemaErrors,
382
+ missingFieldsByLevel,
383
+ forbiddenCapabilitiesByLevel,
384
+ payment: { mode, paymentMade: false, liveRailDeclared: mode === "live" },
385
+ };
386
+ }
387
+ /** Every problem in a report, one line each, schema problems first. */
388
+ export function adlProblems(report) {
389
+ return [
390
+ ...report.schemaDiagnostics.map((d) => `${d.path}: ${d.message}`),
391
+ ...Object.values(report.missingFieldsByLevel).flat(),
392
+ ...(report.forbiddenCapabilitiesByLevel[String(report.requestedLevel)] ?? []),
393
+ ];
394
+ }
395
+ const INTENT_ID = "charge-inference";
396
+ const RECEIPT_ID = "charge-inference-receipt";
397
+ const POLICY_ID = "allow-inference-charge";
398
+ const RECEIPT_EVIDENCE = "receipt:charge-inference";
399
+ /**
400
+ * The schema's provider family for a model id: providers speak the
401
+ * OpenAI-compatible API, so anything not plainly Anthropic, Gemini or Ollama
402
+ * is "openai". The exact model is `extensions.identity.declaredModel`.
403
+ */
404
+ export function adlProviderFamily(model) {
405
+ const m = (model ?? "").toLowerCase();
406
+ if (m.startsWith("anthropic/") || m.startsWith("claude"))
407
+ return "anthropic";
408
+ if (m.startsWith("google/") || m.startsWith("gemini"))
409
+ return "gemini";
410
+ if (m.startsWith("ollama/"))
411
+ return "ollama";
412
+ return "openai";
413
+ }
414
+ /** A `metadata.name` the schema accepts: lowercase letters, digits and dashes, 2 to 63 characters. */
415
+ export function adlNameSlug(name) {
416
+ const slug = name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63).replace(/-+$/g, "");
417
+ return slug.length >= 2 ? slug : `${slug || "provider"}${slug ? "-provider" : ""}`;
418
+ }
419
+ /**
420
+ * The ADL v0.3 document for a provider on the Reddi Agent Protocol: a charge
421
+ * on the Solana rail, priced per token and settled through metered escrow (or
422
+ * priced per call and settled through escrow), with the protocol fee, a
423
+ * reddi.receipt.v2 receipt and reputation signals. It passes Level 3. The
424
+ * caller checks its inputs; a bad input gives a document that fails
425
+ * `checkAdlConformance`, never a silently different one.
426
+ */
427
+ export function buildProviderAdl(input) {
428
+ const asset = { symbol: input.currency, network: input.network, mint: input.mint };
429
+ const perToken = input.price.per === "token";
430
+ const bound = input.price.per === "token" ? input.price.maxPerCall : input.price.amount;
431
+ const serves = input.model ? `serves ${input.model}` : "takes paid work";
432
+ const description = (input.description?.trim() || `${input.name} ${serves} through the Reddi Agent Protocol.`).replace(/\s+/g, " ");
433
+ const event = (name, type, extra = {}) => ({ name, type, required: true, evidenceRef: `trace:${name}`, scope: "task", ...extra });
434
+ const what = input.model ? ` with ${input.model}` : "";
435
+ return {
436
+ apiVersion: ADL_V03_API_VERSION,
437
+ kind: "Agent",
438
+ metadata: { name: adlNameSlug(input.name), description },
439
+ model: {
440
+ capability: "chat",
441
+ providers: { preferred: adlProviderFamily(input.model) },
442
+ requirements: { streaming: false },
443
+ },
444
+ conformance: { requestedLevel: 3, evidenceRefs: [RECEIPT_EVIDENCE] },
445
+ harness: {
446
+ instructions: {
447
+ inline: perToken
448
+ ? `Answer paid requests${what}. Charge only for the tokens used, at the listed per-token price, through a metered escrow the buyer locked; never more than the buyer's lock. Return a signed ${ADL_V03_RECEIPT_FORMAT} receipt with every paid answer.`
449
+ : `Deliver each paid job${what} for the listed price, paid through an escrow the buyer locked. Return a signed ${ADL_V03_RECEIPT_FORMAT} receipt with every paid answer.`,
450
+ },
451
+ policies: [
452
+ {
453
+ id: POLICY_ID,
454
+ capability: "payment",
455
+ subject: "agent",
456
+ resource: `x402:intent:${INTENT_ID}`,
457
+ action: "charge",
458
+ effect: "allow",
459
+ scope: { type: "task", value: INTENT_ID },
460
+ limits: { asset: input.currency, maxAmount: bound, requireReceipt: true },
461
+ approval: { required: false, mode: "none" },
462
+ enforcement: { target: "policy-engine", phase: "before-execution", targetRef: `x402:intent:${INTENT_ID}` },
463
+ },
464
+ ],
465
+ evalGates: [
466
+ {
467
+ id: "inference-receipt-required",
468
+ type: "receipt-check",
469
+ rule: "A signed receipt must be returned with every paid answer.",
470
+ required: true,
471
+ severity: "critical",
472
+ appliesTo: { scope: "receipt", targetRef: "extensions.receipts.refs" },
473
+ evidence: { ref: RECEIPT_EVIDENCE, schema: { type: "object", required: ["status"], properties: { status: { enum: ["pass", "fail"] } } } },
474
+ retryable: false,
475
+ onFailure: { completion: "block", defaultStatus: "fail", visibility: "trace-and-receipt" },
476
+ },
477
+ ],
478
+ runtime: { target: "local-python", network: { access: "none", allowlist: [], denyByDefault: true }, storage: { mode: "ephemeral" }, scheduler: { trigger: "manual" }, activation: { mode: "blocked" } },
479
+ observability: {
480
+ events: [
481
+ event("trace.started", "trace"),
482
+ event("trace.completed", "trace"),
483
+ event("task.completed", "task"),
484
+ event("task.failed", "task"),
485
+ event("model.called", "model"),
486
+ event("policy.checked", "policy"),
487
+ event("eval.checked", "eval"),
488
+ event("payment.intent.created", "payment", { receiptRef: RECEIPT_ID }),
489
+ { name: "receipt.emitted", type: "receipt", required: true, evidenceRef: RECEIPT_EVIDENCE, scope: "receipt", receiptRef: RECEIPT_ID },
490
+ event("reputation.signal.emitted", "reputation"),
491
+ ],
492
+ summaries: [
493
+ {
494
+ id: "paid_call_summary",
495
+ type: "run-summary",
496
+ destinationRef: "provider_log",
497
+ eventRefs: ["task.completed", "task.failed", "payment.intent.created", "receipt.emitted"],
498
+ humanReadable: true,
499
+ },
500
+ ],
501
+ destinations: [{ id: "provider_log", type: "file", mode: "local-only", ref: "file://./.rap-provider/sessions.jsonl", redaction: { mode: "payload-redacted", fields: ["prompt", "output"] } }],
502
+ retention: { mode: "ephemeral", purgeOnCompletion: true },
503
+ redaction: { mode: "payload-redacted", fields: ["prompt", "output"] },
504
+ },
505
+ },
506
+ extensions: {
507
+ x402: {
508
+ enabled: true,
509
+ mode: input.mode ?? "live",
510
+ protocolFee: { bps: ADL_V03_PROTOCOL_FEE_BPS, launchRate: { ...ADL_V03_LAUNCH_RATE }, rounding: "down", paidBy: "provider", cap: { symbol: "SOL", amount: ADL_V03_PROTOCOL_FEE_SOL_CAP }, base: "actual-cost" },
511
+ intents: [
512
+ {
513
+ id: INTENT_ID,
514
+ direction: "charge",
515
+ asset,
516
+ rail: ADL_V03_LIVE_RAIL,
517
+ maxAmount: bound,
518
+ purpose: perToken ? `Charge a buyer for one call, priced per token.` : `Charge a buyer for one job at a fixed price.`,
519
+ scope: { type: "task", value: INTENT_ID },
520
+ requireReceipt: true,
521
+ receiptRef: RECEIPT_ID,
522
+ policyRefs: [POLICY_ID],
523
+ price: input.price.per === "token"
524
+ ? { per: "token", inputPerMillion: input.price.inputPerMillion, outputPerMillion: input.price.outputPerMillion, maxPerCall: input.price.maxPerCall }
525
+ : { per: "call", amount: input.price.amount },
526
+ payTo: input.payTo,
527
+ settlement: perToken ? "metered-escrow" : "escrow",
528
+ },
529
+ ],
530
+ },
531
+ receipts: { required: true, refs: [{ id: RECEIPT_ID, intentRef: INTENT_ID, format: ADL_V03_RECEIPT_FORMAT, evidenceRef: RECEIPT_EVIDENCE, policyRefs: [POLICY_ID] }] },
532
+ reputation: { emitSignals: ["taskCompleted", "receiptVerified"], basis: ["receipt", "policy"], evidenceRefs: [RECEIPT_EVIDENCE] },
533
+ identity: { wallet: input.payTo, ...(input.model ? { declaredModel: input.model } : {}), ...(input.endpointUrl ? { endpoint: input.endpointUrl } : {}) },
534
+ },
535
+ };
536
+ }
537
+ /**
538
+ * A provider's listing terms from its ADL: the document must pass Level 3 and
539
+ * hold exactly one charge intent on the Solana rail, in a token, priced per
540
+ * token (metered escrow) or per call (escrow).
541
+ */
542
+ export function providerTermsFromAdl(doc) {
543
+ const report = checkAdlConformance(doc, { requestedLevel: 3 });
544
+ if (report.status !== "pass")
545
+ return { ok: false, problems: adlProblems(report), report };
546
+ const charges = paymentIntents(doc).filter((i) => i.direction === "charge");
547
+ if (charges.length !== 1)
548
+ return { ok: false, problems: [`extensions.x402.intents must hold exactly one charge intent for a listing; found ${charges.length}`], report };
549
+ const intent = charges[0];
550
+ const price = obj(intent.price);
551
+ const asset = obj(intent.asset);
552
+ if (intent.rail !== ADL_V03_LIVE_RAIL)
553
+ return { ok: false, problems: ["the charge intent must use the solana rail"], report };
554
+ if (typeof asset.mint !== "string" || (asset.network !== "solana-devnet" && asset.network !== "solana-mainnet-beta"))
555
+ return { ok: false, problems: ["the charge intent must pay in a token on solana-devnet or solana-mainnet-beta"], report };
556
+ let listed;
557
+ if (price.per === "token" && intent.settlement === "metered-escrow")
558
+ listed = { per: "token", inputPerMillion: String(price.inputPerMillion), outputPerMillion: String(price.outputPerMillion), maxPerCall: String(price.maxPerCall) };
559
+ else if (price.per === "call" && intent.settlement === "escrow")
560
+ listed = { per: "call", amount: String(price.amount) };
561
+ else
562
+ return { ok: false, problems: ["the charge intent must be priced per token and settled by metered-escrow, or priced per call and settled by escrow"], report };
563
+ const metadata = obj(doc.metadata);
564
+ const identity = obj(obj(doc.extensions).identity);
565
+ return {
566
+ ok: true,
567
+ report,
568
+ terms: {
569
+ name: String(metadata.name ?? ""),
570
+ description: String(metadata.description ?? ""),
571
+ ...(typeof identity.declaredModel === "string" && identity.declaredModel ? { declaredModel: identity.declaredModel } : {}),
572
+ ...(typeof identity.endpoint === "string" && identity.endpoint ? { endpointUrl: identity.endpoint } : {}),
573
+ mode: paymentMode(doc) === "live" ? "live" : "dry-run",
574
+ network: asset.network,
575
+ currency: String(asset.symbol),
576
+ mint: asset.mint,
577
+ payTo: String(intent.payTo),
578
+ price: listed,
579
+ },
580
+ };
581
+ }
582
+ // BEGIN GENERATED ADL v0.3 SCHEMA
583
+ // Generated by scripts/sync-adl-v03.mjs from nissan/reddiagent-lab
584
+ // specs/ADL-v0.3.schema.json (sha256 07ef5112a2efeb7db746897fab209e91de18d78a31ed8756f534a64ac21df9e0). Do not edit by hand.
585
+ /** SHA-256 of the lab's ADL v0.3 JSON Schema this copy was made from. */
586
+ export const ADL_V03_SCHEMA_SHA256 = "07ef5112a2efeb7db746897fab209e91de18d78a31ed8756f534a64ac21df9e0";
587
+ /** The ADL v0.3 JSON Schema (draft 2020-12). */
588
+ export const ADL_V03_SCHEMA = {
589
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
590
+ "$id": "https://reddiagent.dev/schemas/adl-v0.2.schema.json",
591
+ "title": "ReddiAgent ADL v0.3",
592
+ "type": "object",
593
+ "additionalProperties": false,
594
+ "required": [
595
+ "apiVersion",
596
+ "kind",
597
+ "metadata",
598
+ "model",
599
+ "harness"
600
+ ],
601
+ "properties": {
602
+ "apiVersion": {
603
+ "const": "reddiagent.dev/v0.3"
604
+ },
605
+ "kind": {
606
+ "const": "Agent"
607
+ },
608
+ "metadata": {
609
+ "type": "object",
610
+ "additionalProperties": true,
611
+ "required": [
612
+ "name",
613
+ "description"
614
+ ],
615
+ "properties": {
616
+ "name": {
617
+ "type": "string",
618
+ "pattern": "^[a-z0-9][a-z0-9-]{1,62}$"
619
+ },
620
+ "description": {
621
+ "type": "string",
622
+ "minLength": 1
623
+ }
624
+ }
625
+ },
626
+ "model": {
627
+ "type": "object",
628
+ "additionalProperties": false,
629
+ "required": [
630
+ "capability",
631
+ "providers",
632
+ "requirements"
633
+ ],
634
+ "properties": {
635
+ "capability": {
636
+ "type": "string",
637
+ "enum": [
638
+ "chat",
639
+ "reasoning",
640
+ "code",
641
+ "vision",
642
+ "audio",
643
+ "embedding",
644
+ "reranking"
645
+ ]
646
+ },
647
+ "providers": {
648
+ "type": "object",
649
+ "additionalProperties": false,
650
+ "required": [
651
+ "preferred"
652
+ ],
653
+ "properties": {
654
+ "preferred": {
655
+ "$ref": "#/$defs/providerId"
656
+ },
657
+ "fallbacks": {
658
+ "type": "array",
659
+ "items": {
660
+ "$ref": "#/$defs/providerId"
661
+ },
662
+ "uniqueItems": true
663
+ }
664
+ }
665
+ },
666
+ "requirements": {
667
+ "type": "object",
668
+ "additionalProperties": false,
669
+ "properties": {
670
+ "toolCalling": {
671
+ "type": "boolean"
672
+ },
673
+ "structuredOutput": {
674
+ "type": "boolean"
675
+ },
676
+ "streaming": {
677
+ "type": "boolean"
678
+ },
679
+ "jsonMode": {
680
+ "type": "boolean"
681
+ },
682
+ "contextWindow": {
683
+ "type": "integer",
684
+ "minimum": 1
685
+ },
686
+ "maxOutputTokens": {
687
+ "type": "integer",
688
+ "minimum": 1
689
+ },
690
+ "modalities": {
691
+ "type": "array",
692
+ "items": {
693
+ "$ref": "#/$defs/modality"
694
+ },
695
+ "uniqueItems": true
696
+ }
697
+ }
698
+ },
699
+ "cost": {
700
+ "type": "object",
701
+ "additionalProperties": true,
702
+ "properties": {
703
+ "latencyBudget": {
704
+ "type": "string",
705
+ "minLength": 1
706
+ },
707
+ "maxUsdPerTask": {
708
+ "type": "string",
709
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
710
+ }
711
+ }
712
+ }
713
+ }
714
+ },
715
+ "harness": {
716
+ "type": "object",
717
+ "additionalProperties": false,
718
+ "required": [
719
+ "instructions",
720
+ "runtime"
721
+ ],
722
+ "properties": {
723
+ "instructions": {
724
+ "type": "object",
725
+ "additionalProperties": false,
726
+ "oneOf": [
727
+ {
728
+ "required": [
729
+ "inline"
730
+ ],
731
+ "not": {
732
+ "required": [
733
+ "path"
734
+ ]
735
+ }
736
+ },
737
+ {
738
+ "required": [
739
+ "path"
740
+ ],
741
+ "not": {
742
+ "required": [
743
+ "inline"
744
+ ]
745
+ }
746
+ }
747
+ ],
748
+ "properties": {
749
+ "inline": {
750
+ "type": "string",
751
+ "minLength": 1
752
+ },
753
+ "path": {
754
+ "type": "string",
755
+ "minLength": 1
756
+ }
757
+ }
758
+ },
759
+ "tools": {
760
+ "type": "array",
761
+ "items": {
762
+ "$ref": "#/$defs/tool"
763
+ }
764
+ },
765
+ "functions": {
766
+ "type": "array",
767
+ "items": {
768
+ "$ref": "#/$defs/tool"
769
+ }
770
+ },
771
+ "skills": {
772
+ "type": "array",
773
+ "items": {
774
+ "$ref": "#/$defs/namedRef"
775
+ }
776
+ },
777
+ "dataSources": {
778
+ "type": "array",
779
+ "items": {
780
+ "$ref": "#/$defs/dataSource"
781
+ }
782
+ },
783
+ "memory": {
784
+ "$ref": "#/$defs/memory"
785
+ },
786
+ "policies": {
787
+ "type": "array",
788
+ "items": {
789
+ "$ref": "#/$defs/policy"
790
+ },
791
+ "uniqueItems": true
792
+ },
793
+ "evalGates": {
794
+ "type": "array",
795
+ "items": {
796
+ "$ref": "#/$defs/evalGate"
797
+ }
798
+ },
799
+ "runtime": {
800
+ "type": "object",
801
+ "additionalProperties": false,
802
+ "required": [
803
+ "target"
804
+ ],
805
+ "properties": {
806
+ "target": {
807
+ "type": "string",
808
+ "enum": [
809
+ "local-python",
810
+ "hosted-container",
811
+ "serverless",
812
+ "platform-native",
813
+ "openclaw"
814
+ ]
815
+ },
816
+ "network": {
817
+ "$ref": "#/$defs/runtimeNetwork"
818
+ },
819
+ "secretRefs": {
820
+ "$ref": "#/$defs/secretRefs"
821
+ },
822
+ "storage": {
823
+ "$ref": "#/$defs/runtimeStorage"
824
+ },
825
+ "scheduler": {
826
+ "$ref": "#/$defs/runtimeScheduler"
827
+ },
828
+ "activation": {
829
+ "$ref": "#/$defs/runtimeActivation"
830
+ },
831
+ "constraints": {
832
+ "$ref": "#/$defs/targetConstraints"
833
+ }
834
+ }
835
+ },
836
+ "deployment": {
837
+ "$ref": "#/$defs/deployment"
838
+ },
839
+ "observability": {
840
+ "$ref": "#/$defs/observability"
841
+ },
842
+ "recovery": {
843
+ "$ref": "#/$defs/recovery"
844
+ }
845
+ }
846
+ },
847
+ "conformance": {
848
+ "type": "object",
849
+ "additionalProperties": false,
850
+ "required": [
851
+ "requestedLevel"
852
+ ],
853
+ "properties": {
854
+ "requestedLevel": {
855
+ "type": "integer",
856
+ "minimum": 0,
857
+ "maximum": 4
858
+ },
859
+ "evidenceRefs": {
860
+ "type": "array",
861
+ "items": {
862
+ "type": "string",
863
+ "minLength": 1
864
+ },
865
+ "uniqueItems": true
866
+ }
867
+ }
868
+ },
869
+ "extensions": {
870
+ "type": "object",
871
+ "additionalProperties": false,
872
+ "patternProperties": {
873
+ "^x-[A-Za-z0-9_.-]+$": {
874
+ "type": "object",
875
+ "additionalProperties": true
876
+ },
877
+ "^https?://[^\\s]+$": {
878
+ "type": "object",
879
+ "additionalProperties": true
880
+ }
881
+ },
882
+ "properties": {
883
+ "x402": {
884
+ "$ref": "#/$defs/x402"
885
+ },
886
+ "receipts": {
887
+ "$ref": "#/$defs/receiptExtension"
888
+ },
889
+ "reputation": {
890
+ "$ref": "#/$defs/reputationExtension"
891
+ },
892
+ "identity": {
893
+ "type": "object",
894
+ "additionalProperties": true
895
+ }
896
+ }
897
+ }
898
+ },
899
+ "$defs": {
900
+ "providerId": {
901
+ "type": "string",
902
+ "enum": [
903
+ "openai",
904
+ "anthropic",
905
+ "gemini",
906
+ "ollama"
907
+ ]
908
+ },
909
+ "modality": {
910
+ "type": "string",
911
+ "enum": [
912
+ "text",
913
+ "image",
914
+ "audio",
915
+ "embedding"
916
+ ]
917
+ },
918
+ "namedRef": {
919
+ "type": "object",
920
+ "additionalProperties": true,
921
+ "required": [
922
+ "id"
923
+ ],
924
+ "properties": {
925
+ "id": {
926
+ "type": "string",
927
+ "minLength": 1
928
+ },
929
+ "type": {
930
+ "type": "string"
931
+ },
932
+ "description": {
933
+ "type": "string"
934
+ }
935
+ }
936
+ },
937
+ "dataSource": {
938
+ "type": "object",
939
+ "additionalProperties": false,
940
+ "required": [
941
+ "id",
942
+ "type",
943
+ "description",
944
+ "sourceRef",
945
+ "trust",
946
+ "citationRequired",
947
+ "sourceCheck"
948
+ ],
949
+ "properties": {
950
+ "id": {
951
+ "type": "string",
952
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
953
+ },
954
+ "type": {
955
+ "type": "string",
956
+ "enum": [
957
+ "file",
958
+ "url",
959
+ "api",
960
+ "database",
961
+ "vector-index",
962
+ "mcp"
963
+ ]
964
+ },
965
+ "description": {
966
+ "type": "string",
967
+ "minLength": 1
968
+ },
969
+ "sourceRef": {
970
+ "type": "string",
971
+ "pattern": "^(file|url|api|database|vector-index|mcp):[A-Za-z0-9._~:/?#\\[\\]@!$&'()*+,;=%-]+$"
972
+ },
973
+ "path": {
974
+ "type": "string",
975
+ "minLength": 1
976
+ },
977
+ "url": {
978
+ "type": "string",
979
+ "pattern": "^https?://[^\\s]+$"
980
+ },
981
+ "api": {
982
+ "type": "object",
983
+ "additionalProperties": false,
984
+ "required": [
985
+ "endpoint",
986
+ "method"
987
+ ],
988
+ "properties": {
989
+ "endpoint": {
990
+ "type": "string",
991
+ "pattern": "^https?://[^\\s]+$"
992
+ },
993
+ "method": {
994
+ "type": "string",
995
+ "enum": [
996
+ "GET",
997
+ "POST",
998
+ "PUT",
999
+ "PATCH",
1000
+ "DELETE"
1001
+ ]
1002
+ },
1003
+ "authRef": {
1004
+ "type": "string",
1005
+ "minLength": 1
1006
+ }
1007
+ }
1008
+ },
1009
+ "database": {
1010
+ "type": "object",
1011
+ "additionalProperties": false,
1012
+ "required": [
1013
+ "engine",
1014
+ "connectionRef"
1015
+ ],
1016
+ "properties": {
1017
+ "engine": {
1018
+ "type": "string",
1019
+ "enum": [
1020
+ "sqlite",
1021
+ "postgres",
1022
+ "mysql",
1023
+ "duckdb",
1024
+ "other"
1025
+ ]
1026
+ },
1027
+ "connectionRef": {
1028
+ "type": "string",
1029
+ "minLength": 1
1030
+ },
1031
+ "schemaRef": {
1032
+ "type": "string",
1033
+ "minLength": 1
1034
+ }
1035
+ }
1036
+ },
1037
+ "vectorIndex": {
1038
+ "type": "object",
1039
+ "additionalProperties": false,
1040
+ "required": [
1041
+ "indexRef"
1042
+ ],
1043
+ "properties": {
1044
+ "indexRef": {
1045
+ "type": "string",
1046
+ "minLength": 1
1047
+ },
1048
+ "embeddingModel": {
1049
+ "type": "string",
1050
+ "minLength": 1
1051
+ },
1052
+ "namespace": {
1053
+ "type": "string",
1054
+ "minLength": 1
1055
+ }
1056
+ }
1057
+ },
1058
+ "mcp": {
1059
+ "type": "object",
1060
+ "additionalProperties": false,
1061
+ "required": [
1062
+ "serverRef",
1063
+ "outputShape"
1064
+ ],
1065
+ "properties": {
1066
+ "serverRef": {
1067
+ "type": "string",
1068
+ "minLength": 1
1069
+ },
1070
+ "toolName": {
1071
+ "type": "string",
1072
+ "minLength": 1
1073
+ },
1074
+ "outputShape": {
1075
+ "type": "string",
1076
+ "enum": [
1077
+ "metadata-only",
1078
+ "source-citable-output"
1079
+ ]
1080
+ }
1081
+ }
1082
+ },
1083
+ "trust": {
1084
+ "type": "string",
1085
+ "enum": [
1086
+ "approved",
1087
+ "untrusted",
1088
+ "unknown"
1089
+ ]
1090
+ },
1091
+ "citationRequired": {
1092
+ "type": "boolean"
1093
+ },
1094
+ "sourceCheck": {
1095
+ "type": "object",
1096
+ "additionalProperties": false,
1097
+ "required": [
1098
+ "required",
1099
+ "expectation"
1100
+ ],
1101
+ "properties": {
1102
+ "required": {
1103
+ "type": "boolean"
1104
+ },
1105
+ "expectation": {
1106
+ "type": "string",
1107
+ "enum": [
1108
+ "approved-source",
1109
+ "manual-review",
1110
+ "not-citable"
1111
+ ]
1112
+ },
1113
+ "gateRef": {
1114
+ "type": "string",
1115
+ "minLength": 1
1116
+ }
1117
+ }
1118
+ }
1119
+ },
1120
+ "allOf": [
1121
+ {
1122
+ "if": {
1123
+ "properties": {
1124
+ "type": {
1125
+ "const": "file"
1126
+ }
1127
+ },
1128
+ "required": [
1129
+ "type"
1130
+ ]
1131
+ },
1132
+ "then": {
1133
+ "required": [
1134
+ "path"
1135
+ ],
1136
+ "properties": {
1137
+ "sourceRef": {
1138
+ "pattern": "^file:"
1139
+ }
1140
+ },
1141
+ "not": {
1142
+ "anyOf": [
1143
+ {
1144
+ "required": [
1145
+ "url"
1146
+ ]
1147
+ },
1148
+ {
1149
+ "required": [
1150
+ "api"
1151
+ ]
1152
+ },
1153
+ {
1154
+ "required": [
1155
+ "database"
1156
+ ]
1157
+ },
1158
+ {
1159
+ "required": [
1160
+ "vectorIndex"
1161
+ ]
1162
+ },
1163
+ {
1164
+ "required": [
1165
+ "mcp"
1166
+ ]
1167
+ }
1168
+ ]
1169
+ }
1170
+ }
1171
+ },
1172
+ {
1173
+ "if": {
1174
+ "properties": {
1175
+ "type": {
1176
+ "const": "url"
1177
+ }
1178
+ },
1179
+ "required": [
1180
+ "type"
1181
+ ]
1182
+ },
1183
+ "then": {
1184
+ "required": [
1185
+ "url"
1186
+ ],
1187
+ "properties": {
1188
+ "sourceRef": {
1189
+ "pattern": "^url:"
1190
+ }
1191
+ },
1192
+ "not": {
1193
+ "anyOf": [
1194
+ {
1195
+ "required": [
1196
+ "path"
1197
+ ]
1198
+ },
1199
+ {
1200
+ "required": [
1201
+ "api"
1202
+ ]
1203
+ },
1204
+ {
1205
+ "required": [
1206
+ "database"
1207
+ ]
1208
+ },
1209
+ {
1210
+ "required": [
1211
+ "vectorIndex"
1212
+ ]
1213
+ },
1214
+ {
1215
+ "required": [
1216
+ "mcp"
1217
+ ]
1218
+ }
1219
+ ]
1220
+ }
1221
+ }
1222
+ },
1223
+ {
1224
+ "if": {
1225
+ "properties": {
1226
+ "type": {
1227
+ "const": "api"
1228
+ }
1229
+ },
1230
+ "required": [
1231
+ "type"
1232
+ ]
1233
+ },
1234
+ "then": {
1235
+ "required": [
1236
+ "api"
1237
+ ],
1238
+ "properties": {
1239
+ "sourceRef": {
1240
+ "pattern": "^api:"
1241
+ }
1242
+ },
1243
+ "not": {
1244
+ "anyOf": [
1245
+ {
1246
+ "required": [
1247
+ "path"
1248
+ ]
1249
+ },
1250
+ {
1251
+ "required": [
1252
+ "url"
1253
+ ]
1254
+ },
1255
+ {
1256
+ "required": [
1257
+ "database"
1258
+ ]
1259
+ },
1260
+ {
1261
+ "required": [
1262
+ "vectorIndex"
1263
+ ]
1264
+ },
1265
+ {
1266
+ "required": [
1267
+ "mcp"
1268
+ ]
1269
+ }
1270
+ ]
1271
+ }
1272
+ }
1273
+ },
1274
+ {
1275
+ "if": {
1276
+ "properties": {
1277
+ "type": {
1278
+ "const": "database"
1279
+ }
1280
+ },
1281
+ "required": [
1282
+ "type"
1283
+ ]
1284
+ },
1285
+ "then": {
1286
+ "required": [
1287
+ "database"
1288
+ ],
1289
+ "properties": {
1290
+ "sourceRef": {
1291
+ "pattern": "^database:"
1292
+ }
1293
+ },
1294
+ "not": {
1295
+ "anyOf": [
1296
+ {
1297
+ "required": [
1298
+ "path"
1299
+ ]
1300
+ },
1301
+ {
1302
+ "required": [
1303
+ "url"
1304
+ ]
1305
+ },
1306
+ {
1307
+ "required": [
1308
+ "api"
1309
+ ]
1310
+ },
1311
+ {
1312
+ "required": [
1313
+ "vectorIndex"
1314
+ ]
1315
+ },
1316
+ {
1317
+ "required": [
1318
+ "mcp"
1319
+ ]
1320
+ }
1321
+ ]
1322
+ }
1323
+ }
1324
+ },
1325
+ {
1326
+ "if": {
1327
+ "properties": {
1328
+ "type": {
1329
+ "const": "vector-index"
1330
+ }
1331
+ },
1332
+ "required": [
1333
+ "type"
1334
+ ]
1335
+ },
1336
+ "then": {
1337
+ "required": [
1338
+ "vectorIndex"
1339
+ ],
1340
+ "properties": {
1341
+ "sourceRef": {
1342
+ "pattern": "^vector-index:"
1343
+ }
1344
+ },
1345
+ "not": {
1346
+ "anyOf": [
1347
+ {
1348
+ "required": [
1349
+ "path"
1350
+ ]
1351
+ },
1352
+ {
1353
+ "required": [
1354
+ "url"
1355
+ ]
1356
+ },
1357
+ {
1358
+ "required": [
1359
+ "api"
1360
+ ]
1361
+ },
1362
+ {
1363
+ "required": [
1364
+ "database"
1365
+ ]
1366
+ },
1367
+ {
1368
+ "required": [
1369
+ "mcp"
1370
+ ]
1371
+ }
1372
+ ]
1373
+ }
1374
+ }
1375
+ },
1376
+ {
1377
+ "if": {
1378
+ "properties": {
1379
+ "type": {
1380
+ "const": "mcp"
1381
+ }
1382
+ },
1383
+ "required": [
1384
+ "type"
1385
+ ]
1386
+ },
1387
+ "then": {
1388
+ "required": [
1389
+ "mcp"
1390
+ ],
1391
+ "properties": {
1392
+ "sourceRef": {
1393
+ "pattern": "^mcp:"
1394
+ }
1395
+ },
1396
+ "not": {
1397
+ "anyOf": [
1398
+ {
1399
+ "required": [
1400
+ "path"
1401
+ ]
1402
+ },
1403
+ {
1404
+ "required": [
1405
+ "url"
1406
+ ]
1407
+ },
1408
+ {
1409
+ "required": [
1410
+ "api"
1411
+ ]
1412
+ },
1413
+ {
1414
+ "required": [
1415
+ "database"
1416
+ ]
1417
+ },
1418
+ {
1419
+ "required": [
1420
+ "vectorIndex"
1421
+ ]
1422
+ }
1423
+ ]
1424
+ }
1425
+ }
1426
+ },
1427
+ {
1428
+ "if": {
1429
+ "properties": {
1430
+ "trust": {
1431
+ "const": "approved"
1432
+ }
1433
+ },
1434
+ "required": [
1435
+ "trust"
1436
+ ]
1437
+ },
1438
+ "then": {
1439
+ "properties": {
1440
+ "citationRequired": {
1441
+ "const": true
1442
+ },
1443
+ "sourceCheck": {
1444
+ "properties": {
1445
+ "required": {
1446
+ "const": true
1447
+ },
1448
+ "expectation": {
1449
+ "const": "approved-source"
1450
+ }
1451
+ },
1452
+ "required": [
1453
+ "required",
1454
+ "expectation"
1455
+ ]
1456
+ }
1457
+ }
1458
+ }
1459
+ },
1460
+ {
1461
+ "if": {
1462
+ "properties": {
1463
+ "trust": {
1464
+ "enum": [
1465
+ "untrusted",
1466
+ "unknown"
1467
+ ]
1468
+ }
1469
+ },
1470
+ "required": [
1471
+ "trust"
1472
+ ]
1473
+ },
1474
+ "then": {
1475
+ "properties": {
1476
+ "citationRequired": {
1477
+ "const": true
1478
+ },
1479
+ "sourceCheck": {
1480
+ "properties": {
1481
+ "required": {
1482
+ "const": true
1483
+ },
1484
+ "expectation": {
1485
+ "enum": [
1486
+ "manual-review",
1487
+ "not-citable"
1488
+ ]
1489
+ }
1490
+ },
1491
+ "required": [
1492
+ "required",
1493
+ "expectation"
1494
+ ]
1495
+ }
1496
+ }
1497
+ }
1498
+ }
1499
+ ]
1500
+ },
1501
+ "memory": {
1502
+ "type": "object",
1503
+ "additionalProperties": false,
1504
+ "required": [
1505
+ "mode"
1506
+ ],
1507
+ "properties": {
1508
+ "mode": {
1509
+ "type": "string",
1510
+ "enum": [
1511
+ "none",
1512
+ "session",
1513
+ "persistent",
1514
+ "external"
1515
+ ]
1516
+ },
1517
+ "retention": {
1518
+ "type": "string",
1519
+ "minLength": 1
1520
+ },
1521
+ "scope": {
1522
+ "type": "string",
1523
+ "enum": [
1524
+ "task",
1525
+ "session",
1526
+ "project",
1527
+ "user",
1528
+ "workspace",
1529
+ "external"
1530
+ ]
1531
+ },
1532
+ "storageRef": {
1533
+ "type": "string",
1534
+ "minLength": 1
1535
+ },
1536
+ "privacyPolicy": {
1537
+ "type": "string",
1538
+ "minLength": 1
1539
+ }
1540
+ },
1541
+ "allOf": [
1542
+ {
1543
+ "if": {
1544
+ "properties": {
1545
+ "mode": {
1546
+ "enum": [
1547
+ "persistent",
1548
+ "external"
1549
+ ]
1550
+ }
1551
+ },
1552
+ "required": [
1553
+ "mode"
1554
+ ]
1555
+ },
1556
+ "then": {
1557
+ "required": [
1558
+ "retention",
1559
+ "privacyPolicy"
1560
+ ]
1561
+ }
1562
+ }
1563
+ ]
1564
+ },
1565
+ "secretRefs": {
1566
+ "type": "array",
1567
+ "items": {
1568
+ "$ref": "#/$defs/secretRef"
1569
+ },
1570
+ "uniqueItems": true
1571
+ },
1572
+ "secretRef": {
1573
+ "type": "object",
1574
+ "additionalProperties": false,
1575
+ "required": [
1576
+ "name",
1577
+ "provider"
1578
+ ],
1579
+ "properties": {
1580
+ "name": {
1581
+ "type": "string",
1582
+ "pattern": "^[A-Z][A-Z0-9_]{1,127}$"
1583
+ },
1584
+ "provider": {
1585
+ "type": "string",
1586
+ "enum": [
1587
+ "env",
1588
+ "vault",
1589
+ "onepassword",
1590
+ "cloud-secret-manager",
1591
+ "openclaw-secret-ref"
1592
+ ]
1593
+ },
1594
+ "ref": {
1595
+ "type": "string",
1596
+ "minLength": 1
1597
+ },
1598
+ "scope": {
1599
+ "type": "string",
1600
+ "enum": [
1601
+ "runtime",
1602
+ "deployment",
1603
+ "provider",
1604
+ "tool"
1605
+ ]
1606
+ },
1607
+ "required": {
1608
+ "type": "boolean"
1609
+ }
1610
+ },
1611
+ "allOf": [
1612
+ {
1613
+ "not": {
1614
+ "properties": {
1615
+ "ref": {
1616
+ "pattern": "^(sk-|sk_live_|sk_test_|xox[baprs]-|gh[pousr]_|AKIA|AIza|-----BEGIN )"
1617
+ }
1618
+ },
1619
+ "required": [
1620
+ "ref"
1621
+ ]
1622
+ }
1623
+ }
1624
+ ]
1625
+ },
1626
+ "runtimeNetwork": {
1627
+ "type": "object",
1628
+ "additionalProperties": false,
1629
+ "required": [
1630
+ "access"
1631
+ ],
1632
+ "properties": {
1633
+ "access": {
1634
+ "type": "string",
1635
+ "enum": [
1636
+ "none",
1637
+ "egress",
1638
+ "ingress",
1639
+ "egress-and-ingress"
1640
+ ]
1641
+ },
1642
+ "allowlist": {
1643
+ "type": "array",
1644
+ "items": {
1645
+ "type": "string",
1646
+ "minLength": 1
1647
+ },
1648
+ "uniqueItems": true
1649
+ },
1650
+ "denyByDefault": {
1651
+ "type": "boolean"
1652
+ }
1653
+ },
1654
+ "allOf": [
1655
+ {
1656
+ "if": {
1657
+ "properties": {
1658
+ "access": {
1659
+ "const": "none"
1660
+ }
1661
+ },
1662
+ "required": [
1663
+ "access"
1664
+ ]
1665
+ },
1666
+ "then": {
1667
+ "properties": {
1668
+ "allowlist": {
1669
+ "maxItems": 0
1670
+ },
1671
+ "denyByDefault": {
1672
+ "const": true
1673
+ }
1674
+ }
1675
+ }
1676
+ },
1677
+ {
1678
+ "if": {
1679
+ "properties": {
1680
+ "access": {
1681
+ "enum": [
1682
+ "egress",
1683
+ "ingress",
1684
+ "egress-and-ingress"
1685
+ ]
1686
+ }
1687
+ },
1688
+ "required": [
1689
+ "access"
1690
+ ]
1691
+ },
1692
+ "then": {
1693
+ "required": [
1694
+ "allowlist",
1695
+ "denyByDefault"
1696
+ ]
1697
+ }
1698
+ }
1699
+ ]
1700
+ },
1701
+ "runtimeStorage": {
1702
+ "type": "object",
1703
+ "additionalProperties": false,
1704
+ "required": [
1705
+ "mode"
1706
+ ],
1707
+ "properties": {
1708
+ "mode": {
1709
+ "type": "string",
1710
+ "enum": [
1711
+ "none",
1712
+ "ephemeral",
1713
+ "persistent",
1714
+ "external"
1715
+ ]
1716
+ },
1717
+ "refs": {
1718
+ "type": "array",
1719
+ "items": {
1720
+ "type": "string",
1721
+ "minLength": 1
1722
+ },
1723
+ "uniqueItems": true
1724
+ },
1725
+ "retention": {
1726
+ "type": "string",
1727
+ "minLength": 1
1728
+ }
1729
+ },
1730
+ "allOf": [
1731
+ {
1732
+ "if": {
1733
+ "properties": {
1734
+ "mode": {
1735
+ "enum": [
1736
+ "persistent",
1737
+ "external"
1738
+ ]
1739
+ }
1740
+ },
1741
+ "required": [
1742
+ "mode"
1743
+ ]
1744
+ },
1745
+ "then": {
1746
+ "required": [
1747
+ "refs",
1748
+ "retention"
1749
+ ]
1750
+ }
1751
+ }
1752
+ ]
1753
+ },
1754
+ "runtimeScheduler": {
1755
+ "type": "object",
1756
+ "additionalProperties": false,
1757
+ "required": [
1758
+ "trigger"
1759
+ ],
1760
+ "properties": {
1761
+ "trigger": {
1762
+ "type": "string",
1763
+ "enum": [
1764
+ "manual",
1765
+ "cron",
1766
+ "event",
1767
+ "webhook",
1768
+ "queue"
1769
+ ]
1770
+ },
1771
+ "schedule": {
1772
+ "type": "string",
1773
+ "minLength": 1
1774
+ },
1775
+ "eventRef": {
1776
+ "type": "string",
1777
+ "minLength": 1
1778
+ },
1779
+ "timezone": {
1780
+ "type": "string",
1781
+ "minLength": 1
1782
+ }
1783
+ },
1784
+ "allOf": [
1785
+ {
1786
+ "if": {
1787
+ "properties": {
1788
+ "trigger": {
1789
+ "const": "cron"
1790
+ }
1791
+ },
1792
+ "required": [
1793
+ "trigger"
1794
+ ]
1795
+ },
1796
+ "then": {
1797
+ "required": [
1798
+ "schedule",
1799
+ "timezone"
1800
+ ]
1801
+ }
1802
+ },
1803
+ {
1804
+ "if": {
1805
+ "properties": {
1806
+ "trigger": {
1807
+ "enum": [
1808
+ "event",
1809
+ "webhook",
1810
+ "queue"
1811
+ ]
1812
+ }
1813
+ },
1814
+ "required": [
1815
+ "trigger"
1816
+ ]
1817
+ },
1818
+ "then": {
1819
+ "required": [
1820
+ "eventRef"
1821
+ ]
1822
+ }
1823
+ }
1824
+ ]
1825
+ },
1826
+ "runtimeActivation": {
1827
+ "type": "object",
1828
+ "additionalProperties": false,
1829
+ "required": [
1830
+ "mode"
1831
+ ],
1832
+ "properties": {
1833
+ "mode": {
1834
+ "type": "string",
1835
+ "enum": [
1836
+ "blocked",
1837
+ "approval-required",
1838
+ "approved-bounded"
1839
+ ]
1840
+ },
1841
+ "approvalRef": {
1842
+ "type": "string",
1843
+ "minLength": 1
1844
+ },
1845
+ "expiresAt": {
1846
+ "type": "string",
1847
+ "minLength": 1
1848
+ }
1849
+ },
1850
+ "allOf": [
1851
+ {
1852
+ "if": {
1853
+ "properties": {
1854
+ "mode": {
1855
+ "const": "approved-bounded"
1856
+ }
1857
+ },
1858
+ "required": [
1859
+ "mode"
1860
+ ]
1861
+ },
1862
+ "then": {
1863
+ "required": [
1864
+ "approvalRef",
1865
+ "expiresAt"
1866
+ ]
1867
+ }
1868
+ }
1869
+ ]
1870
+ },
1871
+ "targetConstraints": {
1872
+ "type": "object",
1873
+ "additionalProperties": false,
1874
+ "properties": {
1875
+ "runtimeVersion": {
1876
+ "type": "string",
1877
+ "minLength": 1
1878
+ },
1879
+ "image": {
1880
+ "type": "string",
1881
+ "minLength": 1
1882
+ },
1883
+ "region": {
1884
+ "type": "string",
1885
+ "minLength": 1
1886
+ },
1887
+ "maxDurationSeconds": {
1888
+ "type": "integer",
1889
+ "minimum": 1
1890
+ },
1891
+ "maxConcurrency": {
1892
+ "type": "integer",
1893
+ "minimum": 1
1894
+ }
1895
+ }
1896
+ },
1897
+ "deployment": {
1898
+ "type": "object",
1899
+ "additionalProperties": false,
1900
+ "properties": {
1901
+ "target": {
1902
+ "type": "string",
1903
+ "enum": [
1904
+ "local",
1905
+ "container",
1906
+ "serverless",
1907
+ "platform-native",
1908
+ "openclaw"
1909
+ ]
1910
+ },
1911
+ "environment": {
1912
+ "type": "string",
1913
+ "enum": [
1914
+ "local",
1915
+ "preview",
1916
+ "staging",
1917
+ "production"
1918
+ ]
1919
+ },
1920
+ "region": {
1921
+ "type": "string",
1922
+ "minLength": 1
1923
+ },
1924
+ "resources": {
1925
+ "$ref": "#/$defs/deploymentResources"
1926
+ },
1927
+ "secretRefs": {
1928
+ "$ref": "#/$defs/secretRefs"
1929
+ },
1930
+ "networkPolicy": {
1931
+ "$ref": "#/$defs/runtimeNetwork"
1932
+ },
1933
+ "storage": {
1934
+ "$ref": "#/$defs/runtimeStorage"
1935
+ },
1936
+ "scheduler": {
1937
+ "$ref": "#/$defs/runtimeScheduler"
1938
+ },
1939
+ "observability": {
1940
+ "$ref": "#/$defs/observability"
1941
+ },
1942
+ "rollback": {
1943
+ "$ref": "#/$defs/rollback"
1944
+ },
1945
+ "healthCheck": {
1946
+ "$ref": "#/$defs/healthCheck"
1947
+ },
1948
+ "constraints": {
1949
+ "$ref": "#/$defs/targetConstraints"
1950
+ }
1951
+ }
1952
+ },
1953
+ "deploymentResources": {
1954
+ "type": "object",
1955
+ "additionalProperties": false,
1956
+ "properties": {
1957
+ "cpu": {
1958
+ "type": "string",
1959
+ "minLength": 1
1960
+ },
1961
+ "memory": {
1962
+ "type": "string",
1963
+ "minLength": 1
1964
+ },
1965
+ "timeoutSeconds": {
1966
+ "type": "integer",
1967
+ "minimum": 1
1968
+ }
1969
+ }
1970
+ },
1971
+ "observability": {
1972
+ "type": "object",
1973
+ "additionalProperties": false,
1974
+ "required": [
1975
+ "events",
1976
+ "summaries",
1977
+ "destinations",
1978
+ "retention",
1979
+ "redaction"
1980
+ ],
1981
+ "properties": {
1982
+ "events": {
1983
+ "type": "array",
1984
+ "minItems": 1,
1985
+ "items": {
1986
+ "$ref": "#/$defs/observabilityEvent"
1987
+ },
1988
+ "uniqueItems": true
1989
+ },
1990
+ "summaries": {
1991
+ "type": "array",
1992
+ "minItems": 1,
1993
+ "items": {
1994
+ "$ref": "#/$defs/observabilitySummary"
1995
+ },
1996
+ "uniqueItems": true
1997
+ },
1998
+ "destinations": {
1999
+ "type": "array",
2000
+ "minItems": 1,
2001
+ "items": {
2002
+ "$ref": "#/$defs/observabilityDestination"
2003
+ },
2004
+ "uniqueItems": true
2005
+ },
2006
+ "sinks": {
2007
+ "type": "array",
2008
+ "items": {
2009
+ "$ref": "#/$defs/observabilityDestination"
2010
+ },
2011
+ "uniqueItems": true
2012
+ },
2013
+ "evidenceRefs": {
2014
+ "type": "array",
2015
+ "items": {
2016
+ "$ref": "#/$defs/observabilityEvidenceRef"
2017
+ },
2018
+ "uniqueItems": true
2019
+ },
2020
+ "traceRef": {
2021
+ "type": "string",
2022
+ "minLength": 1
2023
+ },
2024
+ "retention": {
2025
+ "$ref": "#/$defs/observabilityRetention"
2026
+ },
2027
+ "redaction": {
2028
+ "$ref": "#/$defs/observabilityRedaction"
2029
+ },
2030
+ "receipts": {
2031
+ "$ref": "#/$defs/observabilityRelationship"
2032
+ },
2033
+ "exports": {
2034
+ "$ref": "#/$defs/observabilityRelationship"
2035
+ }
2036
+ }
2037
+ },
2038
+ "observabilityEventName": {
2039
+ "type": "string",
2040
+ "enum": [
2041
+ "trace.started",
2042
+ "model.called",
2043
+ "tool.called",
2044
+ "policy.checked",
2045
+ "eval.checked",
2046
+ "payment.intent.created",
2047
+ "payment.settled",
2048
+ "receipt.emitted",
2049
+ "reputation.signal.emitted",
2050
+ "deployment.health.checked",
2051
+ "adapter.loss.reported",
2052
+ "task.completed",
2053
+ "task.failed",
2054
+ "trace.completed"
2055
+ ]
2056
+ },
2057
+ "observabilityEvent": {
2058
+ "type": "object",
2059
+ "additionalProperties": false,
2060
+ "required": [
2061
+ "name",
2062
+ "type",
2063
+ "required",
2064
+ "evidenceRef"
2065
+ ],
2066
+ "properties": {
2067
+ "name": {
2068
+ "$ref": "#/$defs/observabilityEventName"
2069
+ },
2070
+ "type": {
2071
+ "type": "string",
2072
+ "enum": [
2073
+ "trace",
2074
+ "model",
2075
+ "tool",
2076
+ "policy",
2077
+ "eval",
2078
+ "payment",
2079
+ "receipt",
2080
+ "reputation",
2081
+ "deployment",
2082
+ "adapter",
2083
+ "task"
2084
+ ]
2085
+ },
2086
+ "required": {
2087
+ "type": "boolean"
2088
+ },
2089
+ "evidenceRef": {
2090
+ "$ref": "#/$defs/observabilityEvidenceRef"
2091
+ },
2092
+ "scope": {
2093
+ "type": "string",
2094
+ "enum": [
2095
+ "task",
2096
+ "session",
2097
+ "runtime",
2098
+ "deployment",
2099
+ "adapter",
2100
+ "receipt",
2101
+ "export"
2102
+ ]
2103
+ },
2104
+ "summaryRef": {
2105
+ "type": "string",
2106
+ "minLength": 1
2107
+ },
2108
+ "receiptRef": {
2109
+ "type": "string",
2110
+ "minLength": 1
2111
+ },
2112
+ "exportRef": {
2113
+ "type": "string",
2114
+ "minLength": 1
2115
+ }
2116
+ }
2117
+ },
2118
+ "observabilitySummary": {
2119
+ "type": "object",
2120
+ "additionalProperties": false,
2121
+ "required": [
2122
+ "id",
2123
+ "type",
2124
+ "destinationRef",
2125
+ "eventRefs"
2126
+ ],
2127
+ "properties": {
2128
+ "id": {
2129
+ "type": "string",
2130
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
2131
+ },
2132
+ "type": {
2133
+ "type": "string",
2134
+ "enum": [
2135
+ "run-summary",
2136
+ "trace-summary",
2137
+ "adapter-loss-summary",
2138
+ "deployment-readiness-summary"
2139
+ ]
2140
+ },
2141
+ "destinationRef": {
2142
+ "type": "string",
2143
+ "minLength": 1
2144
+ },
2145
+ "eventRefs": {
2146
+ "type": "array",
2147
+ "minItems": 1,
2148
+ "items": {
2149
+ "$ref": "#/$defs/observabilityEventName"
2150
+ },
2151
+ "uniqueItems": true
2152
+ },
2153
+ "humanReadable": {
2154
+ "type": "boolean"
2155
+ }
2156
+ }
2157
+ },
2158
+ "observabilityDestination": {
2159
+ "type": "object",
2160
+ "additionalProperties": false,
2161
+ "required": [
2162
+ "id",
2163
+ "type",
2164
+ "mode",
2165
+ "ref",
2166
+ "redaction"
2167
+ ],
2168
+ "properties": {
2169
+ "id": {
2170
+ "type": "string",
2171
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
2172
+ },
2173
+ "type": {
2174
+ "type": "string",
2175
+ "enum": [
2176
+ "stdout",
2177
+ "file",
2178
+ "otlp",
2179
+ "webhook",
2180
+ "openclaw-trace"
2181
+ ]
2182
+ },
2183
+ "mode": {
2184
+ "type": "string",
2185
+ "enum": [
2186
+ "local-only",
2187
+ "adapter-managed",
2188
+ "external-reviewed"
2189
+ ]
2190
+ },
2191
+ "ref": {
2192
+ "type": "string",
2193
+ "minLength": 1
2194
+ },
2195
+ "redaction": {
2196
+ "$ref": "#/$defs/observabilityRedaction"
2197
+ }
2198
+ }
2199
+ },
2200
+ "observabilityEvidenceRef": {
2201
+ "type": "string",
2202
+ "pattern": "^(trace|evidence|receipt|export):[A-Za-z0-9._~:/?#\\[\\]@!$&'()*+,;=%-]+$"
2203
+ },
2204
+ "observabilityRetention": {
2205
+ "type": "object",
2206
+ "additionalProperties": false,
2207
+ "required": [
2208
+ "mode"
2209
+ ],
2210
+ "properties": {
2211
+ "mode": {
2212
+ "type": "string",
2213
+ "enum": [
2214
+ "ephemeral",
2215
+ "time-bound",
2216
+ "external-managed"
2217
+ ]
2218
+ },
2219
+ "maxAge": {
2220
+ "type": "string",
2221
+ "minLength": 1
2222
+ },
2223
+ "storageRef": {
2224
+ "type": "string",
2225
+ "minLength": 1
2226
+ },
2227
+ "purgeOnCompletion": {
2228
+ "type": "boolean"
2229
+ }
2230
+ },
2231
+ "allOf": [
2232
+ {
2233
+ "if": {
2234
+ "properties": {
2235
+ "mode": {
2236
+ "enum": [
2237
+ "time-bound",
2238
+ "external-managed"
2239
+ ]
2240
+ }
2241
+ },
2242
+ "required": [
2243
+ "mode"
2244
+ ]
2245
+ },
2246
+ "then": {
2247
+ "required": [
2248
+ "maxAge",
2249
+ "storageRef"
2250
+ ]
2251
+ }
2252
+ }
2253
+ ]
2254
+ },
2255
+ "observabilityRedaction": {
2256
+ "type": "object",
2257
+ "additionalProperties": false,
2258
+ "required": [
2259
+ "mode"
2260
+ ],
2261
+ "properties": {
2262
+ "mode": {
2263
+ "type": "string",
2264
+ "enum": [
2265
+ "metadata-only",
2266
+ "payload-redacted",
2267
+ "full"
2268
+ ]
2269
+ },
2270
+ "fields": {
2271
+ "type": "array",
2272
+ "items": {
2273
+ "type": "string",
2274
+ "minLength": 1
2275
+ },
2276
+ "uniqueItems": true
2277
+ }
2278
+ }
2279
+ },
2280
+ "observabilityRelationship": {
2281
+ "type": "object",
2282
+ "additionalProperties": false,
2283
+ "required": [
2284
+ "include",
2285
+ "eventRefs"
2286
+ ],
2287
+ "properties": {
2288
+ "include": {
2289
+ "type": "boolean"
2290
+ },
2291
+ "eventRefs": {
2292
+ "type": "array",
2293
+ "items": {
2294
+ "$ref": "#/$defs/observabilityEventName"
2295
+ },
2296
+ "uniqueItems": true
2297
+ },
2298
+ "requiredEvidenceRefs": {
2299
+ "type": "array",
2300
+ "items": {
2301
+ "$ref": "#/$defs/observabilityEvidenceRef"
2302
+ },
2303
+ "uniqueItems": true
2304
+ }
2305
+ }
2306
+ },
2307
+ "rollback": {
2308
+ "type": "object",
2309
+ "additionalProperties": false,
2310
+ "required": [
2311
+ "mode"
2312
+ ],
2313
+ "properties": {
2314
+ "mode": {
2315
+ "type": "string",
2316
+ "enum": [
2317
+ "none",
2318
+ "dry-run-disable",
2319
+ "previous-version",
2320
+ "operator-reviewed"
2321
+ ]
2322
+ },
2323
+ "ref": {
2324
+ "type": "string",
2325
+ "minLength": 1
2326
+ },
2327
+ "requiresApproval": {
2328
+ "type": "boolean"
2329
+ }
2330
+ }
2331
+ },
2332
+ "healthCheck": {
2333
+ "type": "object",
2334
+ "additionalProperties": false,
2335
+ "required": [
2336
+ "type",
2337
+ "ref"
2338
+ ],
2339
+ "properties": {
2340
+ "type": {
2341
+ "type": "string",
2342
+ "enum": [
2343
+ "none",
2344
+ "http",
2345
+ "command",
2346
+ "trace-event"
2347
+ ]
2348
+ },
2349
+ "ref": {
2350
+ "type": "string",
2351
+ "minLength": 1
2352
+ },
2353
+ "intervalSeconds": {
2354
+ "type": "integer",
2355
+ "minimum": 1
2356
+ }
2357
+ }
2358
+ },
2359
+ "recovery": {
2360
+ "type": "object",
2361
+ "additionalProperties": false,
2362
+ "properties": {
2363
+ "disable": {
2364
+ "type": "object",
2365
+ "additionalProperties": false,
2366
+ "required": [
2367
+ "mode"
2368
+ ],
2369
+ "properties": {
2370
+ "mode": {
2371
+ "type": "string",
2372
+ "enum": [
2373
+ "manual",
2374
+ "operator-reviewed",
2375
+ "policy-engine"
2376
+ ]
2377
+ },
2378
+ "ref": {
2379
+ "type": "string",
2380
+ "minLength": 1
2381
+ },
2382
+ "requiresApproval": {
2383
+ "type": "boolean"
2384
+ }
2385
+ }
2386
+ },
2387
+ "restart": {
2388
+ "type": "object",
2389
+ "additionalProperties": false,
2390
+ "required": [
2391
+ "mode"
2392
+ ],
2393
+ "properties": {
2394
+ "mode": {
2395
+ "type": "string",
2396
+ "enum": [
2397
+ "none",
2398
+ "manual",
2399
+ "bounded-retry"
2400
+ ]
2401
+ },
2402
+ "maxAttempts": {
2403
+ "type": "integer",
2404
+ "minimum": 0,
2405
+ "maximum": 10
2406
+ }
2407
+ }
2408
+ }
2409
+ }
2410
+ },
2411
+ "tool": {
2412
+ "type": "object",
2413
+ "additionalProperties": true,
2414
+ "required": [
2415
+ "id",
2416
+ "type",
2417
+ "description"
2418
+ ],
2419
+ "properties": {
2420
+ "id": {
2421
+ "type": "string",
2422
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
2423
+ },
2424
+ "type": {
2425
+ "type": "string",
2426
+ "enum": [
2427
+ "function",
2428
+ "mcp",
2429
+ "http",
2430
+ "native"
2431
+ ]
2432
+ },
2433
+ "description": {
2434
+ "type": "string",
2435
+ "minLength": 1
2436
+ },
2437
+ "inputSchema": {
2438
+ "type": "object"
2439
+ },
2440
+ "outputSchema": {
2441
+ "type": "object"
2442
+ },
2443
+ "permissions": {
2444
+ "type": "array",
2445
+ "items": {
2446
+ "type": "string",
2447
+ "enum": [
2448
+ "tool",
2449
+ "network",
2450
+ "payment",
2451
+ "shell",
2452
+ "filesystem",
2453
+ "messaging",
2454
+ "mcp",
2455
+ "mutation"
2456
+ ]
2457
+ },
2458
+ "uniqueItems": true
2459
+ },
2460
+ "sideEffects": {
2461
+ "type": "object",
2462
+ "additionalProperties": false,
2463
+ "required": [
2464
+ "mode"
2465
+ ],
2466
+ "properties": {
2467
+ "mode": {
2468
+ "type": "string",
2469
+ "enum": [
2470
+ "none",
2471
+ "read",
2472
+ "write",
2473
+ "network",
2474
+ "payment",
2475
+ "messaging",
2476
+ "shell",
2477
+ "filesystem",
2478
+ "mcp",
2479
+ "multiple"
2480
+ ]
2481
+ },
2482
+ "mutatesState": {
2483
+ "type": "boolean"
2484
+ },
2485
+ "external": {
2486
+ "type": "boolean"
2487
+ },
2488
+ "resources": {
2489
+ "type": "array",
2490
+ "items": {
2491
+ "type": "string",
2492
+ "minLength": 1
2493
+ },
2494
+ "uniqueItems": true
2495
+ }
2496
+ }
2497
+ },
2498
+ "timeout": {
2499
+ "type": "object",
2500
+ "additionalProperties": false,
2501
+ "required": [
2502
+ "seconds"
2503
+ ],
2504
+ "properties": {
2505
+ "seconds": {
2506
+ "type": "integer",
2507
+ "minimum": 1,
2508
+ "maximum": 3600
2509
+ },
2510
+ "behavior": {
2511
+ "type": "string",
2512
+ "enum": [
2513
+ "fail-closed",
2514
+ "cancel",
2515
+ "retry"
2516
+ ]
2517
+ }
2518
+ }
2519
+ },
2520
+ "retryPolicy": {
2521
+ "type": "object",
2522
+ "additionalProperties": false,
2523
+ "required": [
2524
+ "maxAttempts"
2525
+ ],
2526
+ "properties": {
2527
+ "maxAttempts": {
2528
+ "type": "integer",
2529
+ "minimum": 0,
2530
+ "maximum": 10
2531
+ },
2532
+ "backoff": {
2533
+ "type": "string",
2534
+ "enum": [
2535
+ "none",
2536
+ "fixed",
2537
+ "exponential"
2538
+ ]
2539
+ },
2540
+ "retryOn": {
2541
+ "type": "array",
2542
+ "items": {
2543
+ "type": "string",
2544
+ "minLength": 1
2545
+ },
2546
+ "uniqueItems": true
2547
+ }
2548
+ }
2549
+ },
2550
+ "auditLevel": {
2551
+ "type": "string",
2552
+ "enum": [
2553
+ "none",
2554
+ "metadata",
2555
+ "event",
2556
+ "payload-redacted",
2557
+ "full"
2558
+ ]
2559
+ },
2560
+ "policyRefs": {
2561
+ "type": "array",
2562
+ "minItems": 1,
2563
+ "items": {
2564
+ "type": "string",
2565
+ "minLength": 1
2566
+ },
2567
+ "uniqueItems": true
2568
+ }
2569
+ },
2570
+ "allOf": [
2571
+ {
2572
+ "if": {
2573
+ "properties": {
2574
+ "type": {
2575
+ "const": "mcp"
2576
+ }
2577
+ },
2578
+ "required": [
2579
+ "type"
2580
+ ]
2581
+ },
2582
+ "then": {
2583
+ "required": [
2584
+ "policyRefs"
2585
+ ]
2586
+ }
2587
+ },
2588
+ {
2589
+ "if": {
2590
+ "properties": {
2591
+ "permissions": {
2592
+ "contains": {
2593
+ "enum": [
2594
+ "network",
2595
+ "payment",
2596
+ "shell",
2597
+ "filesystem",
2598
+ "messaging",
2599
+ "mcp",
2600
+ "mutation"
2601
+ ]
2602
+ }
2603
+ }
2604
+ },
2605
+ "required": [
2606
+ "permissions"
2607
+ ]
2608
+ },
2609
+ "then": {
2610
+ "required": [
2611
+ "policyRefs"
2612
+ ]
2613
+ }
2614
+ },
2615
+ {
2616
+ "if": {
2617
+ "properties": {
2618
+ "sideEffects": {
2619
+ "properties": {
2620
+ "mode": {
2621
+ "enum": [
2622
+ "write",
2623
+ "network",
2624
+ "payment",
2625
+ "messaging",
2626
+ "shell",
2627
+ "filesystem",
2628
+ "mcp",
2629
+ "multiple"
2630
+ ]
2631
+ }
2632
+ },
2633
+ "required": [
2634
+ "mode"
2635
+ ]
2636
+ }
2637
+ },
2638
+ "required": [
2639
+ "sideEffects"
2640
+ ]
2641
+ },
2642
+ "then": {
2643
+ "required": [
2644
+ "policyRefs"
2645
+ ]
2646
+ }
2647
+ }
2648
+ ]
2649
+ },
2650
+ "policy": {
2651
+ "type": "object",
2652
+ "additionalProperties": false,
2653
+ "required": [
2654
+ "id",
2655
+ "capability",
2656
+ "subject",
2657
+ "resource",
2658
+ "action",
2659
+ "effect",
2660
+ "scope",
2661
+ "enforcement"
2662
+ ],
2663
+ "properties": {
2664
+ "id": {
2665
+ "type": "string",
2666
+ "minLength": 1
2667
+ },
2668
+ "capability": {
2669
+ "type": "string",
2670
+ "enum": [
2671
+ "tool",
2672
+ "network",
2673
+ "filesystem",
2674
+ "payment",
2675
+ "messaging",
2676
+ "shell",
2677
+ "human-approval",
2678
+ "data",
2679
+ "memory",
2680
+ "runtime"
2681
+ ]
2682
+ },
2683
+ "subject": {
2684
+ "type": "string",
2685
+ "minLength": 1
2686
+ },
2687
+ "resource": {
2688
+ "type": "string",
2689
+ "minLength": 1
2690
+ },
2691
+ "action": {
2692
+ "type": "string",
2693
+ "minLength": 1
2694
+ },
2695
+ "effect": {
2696
+ "type": "string",
2697
+ "enum": [
2698
+ "allow",
2699
+ "deny"
2700
+ ]
2701
+ },
2702
+ "scope": {
2703
+ "type": "object",
2704
+ "additionalProperties": true,
2705
+ "required": [
2706
+ "type"
2707
+ ],
2708
+ "properties": {
2709
+ "type": {
2710
+ "type": "string",
2711
+ "enum": [
2712
+ "task",
2713
+ "session",
2714
+ "project",
2715
+ "workspace",
2716
+ "agent",
2717
+ "resource",
2718
+ "external"
2719
+ ]
2720
+ },
2721
+ "value": {
2722
+ "type": "string",
2723
+ "minLength": 1
2724
+ }
2725
+ }
2726
+ },
2727
+ "limits": {
2728
+ "type": "object",
2729
+ "additionalProperties": true
2730
+ },
2731
+ "approval": {
2732
+ "type": "object",
2733
+ "additionalProperties": false,
2734
+ "required": [
2735
+ "required"
2736
+ ],
2737
+ "properties": {
2738
+ "required": {
2739
+ "type": "boolean"
2740
+ },
2741
+ "mode": {
2742
+ "type": "string",
2743
+ "enum": [
2744
+ "none",
2745
+ "human",
2746
+ "operator",
2747
+ "policy-engine"
2748
+ ]
2749
+ },
2750
+ "threshold": {
2751
+ "type": "string",
2752
+ "minLength": 1
2753
+ },
2754
+ "approver": {
2755
+ "type": "string",
2756
+ "minLength": 1
2757
+ }
2758
+ }
2759
+ },
2760
+ "enforcement": {
2761
+ "type": "object",
2762
+ "additionalProperties": false,
2763
+ "required": [
2764
+ "target",
2765
+ "phase"
2766
+ ],
2767
+ "properties": {
2768
+ "target": {
2769
+ "type": "string",
2770
+ "enum": [
2771
+ "static-validator",
2772
+ "runtime-adapter",
2773
+ "policy-engine",
2774
+ "human-review"
2775
+ ]
2776
+ },
2777
+ "phase": {
2778
+ "type": "string",
2779
+ "enum": [
2780
+ "compatibility",
2781
+ "before-execution",
2782
+ "during-execution",
2783
+ "after-execution"
2784
+ ]
2785
+ },
2786
+ "targetRef": {
2787
+ "type": "string",
2788
+ "minLength": 1
2789
+ }
2790
+ }
2791
+ }
2792
+ },
2793
+ "allOf": [
2794
+ {
2795
+ "if": {
2796
+ "properties": {
2797
+ "capability": {
2798
+ "const": "human-approval"
2799
+ }
2800
+ },
2801
+ "required": [
2802
+ "capability"
2803
+ ]
2804
+ },
2805
+ "then": {
2806
+ "required": [
2807
+ "approval"
2808
+ ],
2809
+ "properties": {
2810
+ "approval": {
2811
+ "properties": {
2812
+ "required": {
2813
+ "const": true
2814
+ }
2815
+ },
2816
+ "required": [
2817
+ "required"
2818
+ ]
2819
+ },
2820
+ "enforcement": {
2821
+ "properties": {
2822
+ "target": {
2823
+ "const": "human-review"
2824
+ }
2825
+ },
2826
+ "required": [
2827
+ "target"
2828
+ ]
2829
+ }
2830
+ }
2831
+ }
2832
+ }
2833
+ ]
2834
+ },
2835
+ "policyRefList": {
2836
+ "type": "array",
2837
+ "items": {
2838
+ "type": "string",
2839
+ "minLength": 1
2840
+ },
2841
+ "uniqueItems": true
2842
+ },
2843
+ "evalGate": {
2844
+ "type": "object",
2845
+ "additionalProperties": true,
2846
+ "required": [
2847
+ "id",
2848
+ "type",
2849
+ "rule",
2850
+ "required",
2851
+ "severity",
2852
+ "appliesTo",
2853
+ "evidence",
2854
+ "retryable",
2855
+ "onFailure"
2856
+ ],
2857
+ "properties": {
2858
+ "id": {
2859
+ "type": "string",
2860
+ "minLength": 1
2861
+ },
2862
+ "type": {
2863
+ "type": "string",
2864
+ "enum": [
2865
+ "output-check",
2866
+ "source-check",
2867
+ "tool-check",
2868
+ "budget-check",
2869
+ "receipt-check",
2870
+ "human-review"
2871
+ ]
2872
+ },
2873
+ "rule": {
2874
+ "type": "string",
2875
+ "minLength": 1
2876
+ },
2877
+ "required": {
2878
+ "type": "boolean"
2879
+ },
2880
+ "severity": {
2881
+ "type": "string",
2882
+ "enum": [
2883
+ "info",
2884
+ "warning",
2885
+ "error",
2886
+ "critical"
2887
+ ]
2888
+ },
2889
+ "appliesTo": {
2890
+ "type": "object",
2891
+ "additionalProperties": true,
2892
+ "required": [
2893
+ "scope"
2894
+ ],
2895
+ "properties": {
2896
+ "scope": {
2897
+ "type": "string",
2898
+ "enum": [
2899
+ "task",
2900
+ "output",
2901
+ "tool",
2902
+ "source",
2903
+ "budget",
2904
+ "receipt",
2905
+ "human-review"
2906
+ ]
2907
+ },
2908
+ "targetRef": {
2909
+ "type": "string",
2910
+ "minLength": 1
2911
+ }
2912
+ }
2913
+ },
2914
+ "evidence": {
2915
+ "type": "object",
2916
+ "additionalProperties": true,
2917
+ "required": [
2918
+ "ref",
2919
+ "schema"
2920
+ ],
2921
+ "properties": {
2922
+ "ref": {
2923
+ "type": "string",
2924
+ "minLength": 1
2925
+ },
2926
+ "schema": {
2927
+ "type": "object",
2928
+ "additionalProperties": true
2929
+ }
2930
+ }
2931
+ },
2932
+ "retryable": {
2933
+ "type": "boolean"
2934
+ },
2935
+ "onFailure": {
2936
+ "type": "object",
2937
+ "additionalProperties": false,
2938
+ "required": [
2939
+ "completion",
2940
+ "defaultStatus"
2941
+ ],
2942
+ "properties": {
2943
+ "completion": {
2944
+ "type": "string",
2945
+ "enum": [
2946
+ "block",
2947
+ "warn"
2948
+ ]
2949
+ },
2950
+ "defaultStatus": {
2951
+ "type": "string",
2952
+ "enum": [
2953
+ "pass",
2954
+ "fail",
2955
+ "warn",
2956
+ "skipped"
2957
+ ]
2958
+ },
2959
+ "visibility": {
2960
+ "type": "string",
2961
+ "enum": [
2962
+ "trace",
2963
+ "receipt",
2964
+ "trace-and-receipt"
2965
+ ]
2966
+ }
2967
+ }
2968
+ }
2969
+ },
2970
+ "allOf": [
2971
+ {
2972
+ "if": {
2973
+ "properties": {
2974
+ "required": {
2975
+ "const": true
2976
+ }
2977
+ },
2978
+ "required": [
2979
+ "required"
2980
+ ]
2981
+ },
2982
+ "then": {
2983
+ "properties": {
2984
+ "severity": {
2985
+ "enum": [
2986
+ "error",
2987
+ "critical"
2988
+ ]
2989
+ },
2990
+ "onFailure": {
2991
+ "properties": {
2992
+ "completion": {
2993
+ "const": "block"
2994
+ },
2995
+ "defaultStatus": {
2996
+ "const": "fail"
2997
+ }
2998
+ },
2999
+ "required": [
3000
+ "completion",
3001
+ "defaultStatus"
3002
+ ]
3003
+ }
3004
+ }
3005
+ }
3006
+ },
3007
+ {
3008
+ "if": {
3009
+ "properties": {
3010
+ "required": {
3011
+ "const": false
3012
+ }
3013
+ },
3014
+ "required": [
3015
+ "required"
3016
+ ]
3017
+ },
3018
+ "then": {
3019
+ "properties": {
3020
+ "severity": {
3021
+ "enum": [
3022
+ "info",
3023
+ "warning"
3024
+ ]
3025
+ },
3026
+ "onFailure": {
3027
+ "properties": {
3028
+ "completion": {
3029
+ "const": "warn"
3030
+ },
3031
+ "defaultStatus": {
3032
+ "const": "warn"
3033
+ }
3034
+ },
3035
+ "required": [
3036
+ "completion",
3037
+ "defaultStatus"
3038
+ ]
3039
+ }
3040
+ }
3041
+ }
3042
+ }
3043
+ ]
3044
+ },
3045
+ "x402": {
3046
+ "type": "object",
3047
+ "additionalProperties": false,
3048
+ "properties": {
3049
+ "enabled": {
3050
+ "type": "boolean"
3051
+ },
3052
+ "intents": {
3053
+ "type": "array",
3054
+ "items": {
3055
+ "$ref": "#/$defs/paymentIntent"
3056
+ },
3057
+ "uniqueItems": true
3058
+ },
3059
+ "mode": {
3060
+ "type": "string",
3061
+ "enum": [
3062
+ "dry-run",
3063
+ "live"
3064
+ ]
3065
+ },
3066
+ "protocolFee": {
3067
+ "type": "object",
3068
+ "additionalProperties": false,
3069
+ "required": [
3070
+ "bps",
3071
+ "rounding",
3072
+ "paidBy"
3073
+ ],
3074
+ "properties": {
3075
+ "bps": {
3076
+ "type": "integer",
3077
+ "minimum": 0,
3078
+ "maximum": 10000
3079
+ },
3080
+ "launchRate": {
3081
+ "type": "object",
3082
+ "additionalProperties": false,
3083
+ "required": [
3084
+ "bps",
3085
+ "endsAt"
3086
+ ],
3087
+ "description": "A lower rate for payouts before endsAt (UTC); bps applies from endsAt on. The protocol's launch rate is 250 bps until 2027-04-01T00:00:00Z.",
3088
+ "properties": {
3089
+ "bps": {
3090
+ "type": "integer",
3091
+ "minimum": 0,
3092
+ "maximum": 10000
3093
+ },
3094
+ "endsAt": {
3095
+ "type": "string",
3096
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
3097
+ }
3098
+ }
3099
+ },
3100
+ "rounding": {
3101
+ "const": "down"
3102
+ },
3103
+ "paidBy": {
3104
+ "const": "provider"
3105
+ },
3106
+ "cap": {
3107
+ "type": "object",
3108
+ "additionalProperties": false,
3109
+ "required": [
3110
+ "symbol",
3111
+ "amount"
3112
+ ],
3113
+ "description": "Most the fee can be on one payment in this asset. The protocol caps SOL payments at 0.1 SOL; stablecoins have no cap.",
3114
+ "properties": {
3115
+ "symbol": {
3116
+ "const": "SOL"
3117
+ },
3118
+ "amount": {
3119
+ "type": "string",
3120
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3121
+ }
3122
+ }
3123
+ },
3124
+ "base": {
3125
+ "const": "actual-cost",
3126
+ "description": "The fee is taken from the amount actually paid: the price per call, or the settled cost of a per-token call."
3127
+ }
3128
+ }
3129
+ }
3130
+ },
3131
+ "required": [
3132
+ "mode"
3133
+ ]
3134
+ },
3135
+ "paymentIntent": {
3136
+ "type": "object",
3137
+ "additionalProperties": false,
3138
+ "required": [
3139
+ "id",
3140
+ "direction",
3141
+ "asset",
3142
+ "rail"
3143
+ ],
3144
+ "properties": {
3145
+ "id": {
3146
+ "type": "string",
3147
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
3148
+ },
3149
+ "direction": {
3150
+ "type": "string",
3151
+ "enum": [
3152
+ "spend",
3153
+ "charge",
3154
+ "refund"
3155
+ ]
3156
+ },
3157
+ "maxAmount": {
3158
+ "type": "string",
3159
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3160
+ },
3161
+ "purpose": {
3162
+ "type": "string",
3163
+ "minLength": 1
3164
+ },
3165
+ "scope": {
3166
+ "$ref": "#/$defs/paymentScope"
3167
+ },
3168
+ "authority": {
3169
+ "$ref": "#/$defs/paymentAuthority"
3170
+ },
3171
+ "receiptRef": {
3172
+ "type": "string",
3173
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
3174
+ },
3175
+ "requireReceipt": {
3176
+ "type": "boolean"
3177
+ },
3178
+ "policyRefs": {
3179
+ "$ref": "#/$defs/policyRefList"
3180
+ },
3181
+ "asset": {
3182
+ "$ref": "#/$defs/paymentAsset"
3183
+ },
3184
+ "rail": {
3185
+ "type": "string",
3186
+ "enum": [
3187
+ "solana",
3188
+ "base",
3189
+ "stripe",
3190
+ "other-x402"
3191
+ ]
3192
+ },
3193
+ "price": {
3194
+ "oneOf": [
3195
+ {
3196
+ "type": "object",
3197
+ "additionalProperties": false,
3198
+ "required": [
3199
+ "amount",
3200
+ "per"
3201
+ ],
3202
+ "properties": {
3203
+ "amount": {
3204
+ "type": "string",
3205
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3206
+ },
3207
+ "per": {
3208
+ "const": "call"
3209
+ }
3210
+ }
3211
+ },
3212
+ {
3213
+ "type": "object",
3214
+ "additionalProperties": false,
3215
+ "required": [
3216
+ "per",
3217
+ "inputPerMillion",
3218
+ "outputPerMillion",
3219
+ "maxPerCall"
3220
+ ],
3221
+ "properties": {
3222
+ "per": {
3223
+ "const": "token"
3224
+ },
3225
+ "inputPerMillion": {
3226
+ "type": "string",
3227
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3228
+ },
3229
+ "outputPerMillion": {
3230
+ "type": "string",
3231
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3232
+ },
3233
+ "maxPerCall": {
3234
+ "type": "string",
3235
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3236
+ }
3237
+ }
3238
+ }
3239
+ ]
3240
+ },
3241
+ "payTo": {
3242
+ "type": "string",
3243
+ "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
3244
+ },
3245
+ "settlement": {
3246
+ "type": "string",
3247
+ "enum": [
3248
+ "direct",
3249
+ "escrow",
3250
+ "metered-escrow"
3251
+ ]
3252
+ }
3253
+ },
3254
+ "allOf": [
3255
+ {
3256
+ "if": {
3257
+ "properties": {
3258
+ "direction": {
3259
+ "enum": [
3260
+ "spend",
3261
+ "refund"
3262
+ ]
3263
+ }
3264
+ },
3265
+ "required": [
3266
+ "direction"
3267
+ ]
3268
+ },
3269
+ "then": {
3270
+ "required": [
3271
+ "maxAmount",
3272
+ "purpose",
3273
+ "scope",
3274
+ "authority",
3275
+ "requireReceipt",
3276
+ "receiptRef",
3277
+ "policyRefs"
3278
+ ],
3279
+ "properties": {
3280
+ "requireReceipt": {
3281
+ "const": true
3282
+ }
3283
+ }
3284
+ }
3285
+ },
3286
+ {
3287
+ "if": {
3288
+ "properties": {
3289
+ "direction": {
3290
+ "const": "charge"
3291
+ }
3292
+ },
3293
+ "required": [
3294
+ "direction"
3295
+ ]
3296
+ },
3297
+ "then": {
3298
+ "required": [
3299
+ "price",
3300
+ "payTo",
3301
+ "settlement",
3302
+ "requireReceipt",
3303
+ "receiptRef",
3304
+ "policyRefs"
3305
+ ],
3306
+ "properties": {
3307
+ "requireReceipt": {
3308
+ "const": true
3309
+ }
3310
+ }
3311
+ }
3312
+ }
3313
+ ]
3314
+ },
3315
+ "paymentScope": {
3316
+ "type": "object",
3317
+ "additionalProperties": false,
3318
+ "required": [
3319
+ "type",
3320
+ "value"
3321
+ ],
3322
+ "properties": {
3323
+ "type": {
3324
+ "type": "string",
3325
+ "enum": [
3326
+ "task",
3327
+ "session",
3328
+ "resource",
3329
+ "service"
3330
+ ]
3331
+ },
3332
+ "value": {
3333
+ "type": "string",
3334
+ "minLength": 1
3335
+ }
3336
+ }
3337
+ },
3338
+ "paymentAuthority": {
3339
+ "type": "object",
3340
+ "additionalProperties": false,
3341
+ "required": [
3342
+ "principal",
3343
+ "spender",
3344
+ "maxAmount",
3345
+ "asset",
3346
+ "rail",
3347
+ "purpose",
3348
+ "scope",
3349
+ "expiresAt",
3350
+ "revocation",
3351
+ "audit"
3352
+ ],
3353
+ "properties": {
3354
+ "principal": {
3355
+ "type": "string",
3356
+ "pattern": "^[a-zA-Z0-9_.:-]+$"
3357
+ },
3358
+ "spender": {
3359
+ "type": "string",
3360
+ "pattern": "^[a-zA-Z0-9_.:-]+$"
3361
+ },
3362
+ "maxAmount": {
3363
+ "type": "string",
3364
+ "pattern": "^[0-9]+(\\.[0-9]+)?$"
3365
+ },
3366
+ "purpose": {
3367
+ "type": "string",
3368
+ "minLength": 1
3369
+ },
3370
+ "scope": {
3371
+ "$ref": "#/$defs/paymentScope"
3372
+ },
3373
+ "expiresAt": {
3374
+ "type": "string",
3375
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
3376
+ },
3377
+ "revocation": {
3378
+ "type": "object",
3379
+ "additionalProperties": false,
3380
+ "required": [
3381
+ "mode",
3382
+ "path"
3383
+ ],
3384
+ "properties": {
3385
+ "mode": {
3386
+ "type": "string",
3387
+ "enum": [
3388
+ "operator",
3389
+ "policy-engine",
3390
+ "human-review"
3391
+ ]
3392
+ },
3393
+ "path": {
3394
+ "type": "string",
3395
+ "minLength": 1
3396
+ }
3397
+ }
3398
+ },
3399
+ "audit": {
3400
+ "type": "object",
3401
+ "additionalProperties": false,
3402
+ "required": [
3403
+ "path",
3404
+ "evidenceRef"
3405
+ ],
3406
+ "properties": {
3407
+ "path": {
3408
+ "type": "string",
3409
+ "minLength": 1
3410
+ },
3411
+ "evidenceRef": {
3412
+ "$ref": "#/$defs/observabilityEvidenceRef"
3413
+ }
3414
+ }
3415
+ },
3416
+ "asset": {
3417
+ "$ref": "#/$defs/paymentAsset"
3418
+ },
3419
+ "rail": {
3420
+ "type": "string",
3421
+ "enum": [
3422
+ "solana",
3423
+ "base",
3424
+ "stripe",
3425
+ "other-x402"
3426
+ ]
3427
+ }
3428
+ }
3429
+ },
3430
+ "receiptExtension": {
3431
+ "type": "object",
3432
+ "additionalProperties": false,
3433
+ "required": [
3434
+ "required"
3435
+ ],
3436
+ "properties": {
3437
+ "required": {
3438
+ "type": "boolean"
3439
+ },
3440
+ "refs": {
3441
+ "type": "array",
3442
+ "items": {
3443
+ "$ref": "#/$defs/receiptRequirement"
3444
+ },
3445
+ "uniqueItems": true
3446
+ }
3447
+ },
3448
+ "allOf": [
3449
+ {
3450
+ "if": {
3451
+ "properties": {
3452
+ "required": {
3453
+ "const": true
3454
+ }
3455
+ },
3456
+ "required": [
3457
+ "required"
3458
+ ]
3459
+ },
3460
+ "then": {
3461
+ "required": [
3462
+ "refs"
3463
+ ]
3464
+ }
3465
+ }
3466
+ ]
3467
+ },
3468
+ "receiptRequirement": {
3469
+ "type": "object",
3470
+ "additionalProperties": false,
3471
+ "required": [
3472
+ "id",
3473
+ "intentRef",
3474
+ "format",
3475
+ "evidenceRef",
3476
+ "policyRefs"
3477
+ ],
3478
+ "properties": {
3479
+ "id": {
3480
+ "type": "string",
3481
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
3482
+ },
3483
+ "intentRef": {
3484
+ "type": "string",
3485
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
3486
+ },
3487
+ "evidenceRef": {
3488
+ "$ref": "#/$defs/observabilityEvidenceRef"
3489
+ },
3490
+ "policyRefs": {
3491
+ "$ref": "#/$defs/policyRefList"
3492
+ },
3493
+ "format": {
3494
+ "type": "string",
3495
+ "enum": [
3496
+ "reddi.receipt.v2"
3497
+ ]
3498
+ }
3499
+ }
3500
+ },
3501
+ "reputationExtension": {
3502
+ "type": "object",
3503
+ "additionalProperties": false,
3504
+ "properties": {
3505
+ "emitSignals": {
3506
+ "type": "array",
3507
+ "items": {
3508
+ "type": "string",
3509
+ "enum": [
3510
+ "taskCompleted",
3511
+ "evalPassed",
3512
+ "receiptVerified",
3513
+ "policyCompliant",
3514
+ "refundIssued",
3515
+ "disputeOpened"
3516
+ ]
3517
+ },
3518
+ "uniqueItems": true
3519
+ },
3520
+ "basis": {
3521
+ "type": "array",
3522
+ "items": {
3523
+ "type": "string",
3524
+ "enum": [
3525
+ "eval",
3526
+ "receipt",
3527
+ "policy",
3528
+ "human-review"
3529
+ ]
3530
+ },
3531
+ "uniqueItems": true
3532
+ },
3533
+ "evidenceRefs": {
3534
+ "type": "array",
3535
+ "items": {
3536
+ "$ref": "#/$defs/observabilityEvidenceRef"
3537
+ },
3538
+ "uniqueItems": true
3539
+ }
3540
+ }
3541
+ },
3542
+ "paymentAsset": {
3543
+ "type": "object",
3544
+ "additionalProperties": false,
3545
+ "required": [
3546
+ "symbol",
3547
+ "network"
3548
+ ],
3549
+ "properties": {
3550
+ "symbol": {
3551
+ "type": "string",
3552
+ "enum": [
3553
+ "SOL",
3554
+ "USDC",
3555
+ "PYUSD",
3556
+ "USDG",
3557
+ "AUDD"
3558
+ ]
3559
+ },
3560
+ "network": {
3561
+ "type": "string",
3562
+ "enum": [
3563
+ "solana-devnet",
3564
+ "solana-mainnet-beta"
3565
+ ]
3566
+ },
3567
+ "mint": {
3568
+ "type": "string",
3569
+ "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
3570
+ }
3571
+ },
3572
+ "allOf": [
3573
+ {
3574
+ "if": {
3575
+ "properties": {
3576
+ "symbol": {
3577
+ "const": "SOL"
3578
+ }
3579
+ },
3580
+ "required": [
3581
+ "symbol"
3582
+ ]
3583
+ },
3584
+ "then": {
3585
+ "not": {
3586
+ "required": [
3587
+ "mint"
3588
+ ]
3589
+ }
3590
+ },
3591
+ "else": {
3592
+ "required": [
3593
+ "mint"
3594
+ ]
3595
+ }
3596
+ }
3597
+ ]
3598
+ }
3599
+ }
3600
+ };
3601
+ // END GENERATED ADL v0.3 SCHEMA