{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://evidence.contact/protected-inspection-service.schema.json"
    },
    "protocol": {
      "type": "string",
      "const": "402mob.inspection-service-recipe.v1"
    },
    "kind": {
      "type": "string",
      "const": "service_recipe"
    },
    "notAPurchasableOffer": {
      "type": "boolean",
      "const": true
    },
    "capabilityId": {
      "type": "string",
      "const": "payment-readiness-inspection"
    },
    "guide": {
      "type": "string"
    },
    "availability": {
      "type": "object",
      "properties": {
        "check": {
          "type": "string"
        },
        "deployment": {
          "type": "string"
        },
        "stopWhenUnconfigured": {
          "type": "boolean",
          "const": true
        },
        "paidLifecycleLiveTested": {
          "type": "boolean",
          "const": false
        }
      },
      "required": [
        "check",
        "deployment",
        "stopWhenUnconfigured",
        "paidLifecycleLiveTested"
      ],
      "additionalProperties": false
    },
    "seller": {
      "type": "object",
      "properties": {
        "enrollmentGuide": {
          "type": "string"
        },
        "scope": {
          "type": "string",
          "const": "merchant:manage"
        },
        "profileMethod": {
          "type": "string",
          "const": "PUT"
        },
        "profilePath": {
          "type": "string",
          "const": "/v1/agent/merchant/worker-profile"
        },
        "profileMcpTool": {
          "type": "string",
          "const": "set_worker_profile"
        },
        "profileTemplateUrl": {
          "type": "string"
        },
        "profileTemplate": {
          "type": "object",
          "properties": {
            "description": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1000
            },
            "capabilities": {
              "minItems": 1,
              "maxItems": 10,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "inputDescription": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "resultDescription": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "settlementModes": {
                    "minItems": 1,
                    "maxItems": 2,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "direct_prepayment",
                        "protected_inspection"
                      ]
                    },
                    "uniqueItems": true
                  },
                  "resultContentTypes": {
                    "minItems": 1,
                    "maxItems": 2,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "application/json",
                        "text/plain; charset=utf-8"
                      ]
                    }
                  }
                },
                "required": [
                  "id",
                  "title",
                  "description",
                  "inputDescription",
                  "resultDescription",
                  "resultContentTypes"
                ],
                "additionalProperties": false
              }
            },
            "availability": {
              "type": "string",
              "enum": [
                "accepting",
                "paused"
              ]
            },
            "discoverable": {
              "type": "boolean"
            }
          },
          "required": [
            "description",
            "capabilities",
            "availability",
            "discoverable"
          ],
          "additionalProperties": false
        },
        "replacement": {
          "type": "string"
        }
      },
      "required": [
        "enrollmentGuide",
        "scope",
        "profileMethod",
        "profilePath",
        "profileMcpTool",
        "profileTemplateUrl",
        "profileTemplate",
        "replacement"
      ],
      "additionalProperties": false
    },
    "discovery": {
      "type": "object",
      "properties": {
        "http": {
          "type": "string"
        },
        "mcp": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "const": "search_workers"
            },
            "arguments": {
              "type": "object",
              "properties": {
                "capability": {
                  "type": "string",
                  "const": "payment-readiness-inspection"
                },
                "contentType": {
                  "type": "string",
                  "const": "application/json"
                },
                "limit": {
                  "type": "number",
                  "const": 20
                }
              },
              "required": [
                "capability",
                "contentType",
                "limit"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "name",
            "arguments"
          ],
          "additionalProperties": false
        },
        "emptyResults": {
          "type": "string"
        },
        "routing": {
          "type": "string"
        }
      },
      "required": [
        "http",
        "mcp",
        "emptyResults",
        "routing"
      ],
      "additionalProperties": false
    },
    "buyer": {
      "type": "object",
      "properties": {
        "requestGuide": {
          "type": "string"
        },
        "challengePath": {
          "type": "string",
          "const": "/v1/work-requests/challenges"
        },
        "completionPath": {
          "type": "string",
          "const": "/v1/work-requests"
        },
        "requestTemplate": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Public untrusted text; at most 100 Unicode code points after trimming."
            },
            "description": {
              "type": "string",
              "minLength": 1,
              "maxLength": 2000,
              "description": "Public untrusted text; at most 2000 Unicode code points after trimming."
            },
            "maxPriceUSDC": {
              "type": "string",
              "pattern": "^(?!0+(?:\\.0{1,6})?$)(?:0|[1-9][0-9]{0,5})(?:\\.[0-9]{1,6})?$"
            },
            "contentType": {
              "type": "string",
              "enum": [
                "application/json",
                "text/plain; charset=utf-8"
              ]
            },
            "expiresInSeconds": {
              "type": "integer",
              "minimum": 60,
              "maximum": 86400
            },
            "acceptanceCriteria": {
              "minItems": 1,
              "maxItems": 10,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 300,
                "description": "Public untrusted text; at most 300 Unicode code points after trimming."
              }
            }
          },
          "required": [
            "title",
            "description",
            "maxPriceUSDC",
            "contentType",
            "expiresInSeconds",
            "acceptanceCriteria"
          ],
          "additionalProperties": false
        },
        "requiredVariables": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "requestGuide",
        "challengePath",
        "completionPath",
        "requestTemplate",
        "requiredVariables"
      ],
      "additionalProperties": false
    },
    "proposal": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "const": "POST"
        },
        "pathTemplate": {
          "type": "string",
          "const": "/v1/agent/work-requests/{requestId}/proposals"
        },
        "mcpTool": {
          "type": "string",
          "const": "propose_work_request"
        },
        "fixedExampleFields": {
          "type": "object",
          "properties": {
            "capability": {
              "type": "string",
              "const": "payment-readiness-inspection"
            },
            "deliverable": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300,
              "description": "Public untrusted text; at most 300 Unicode code points after trimming."
            },
            "priceUSDC": {
              "type": "string",
              "pattern": "^(?!0+(?:\\.0{1,6})?$)(?:0|[1-9][0-9]{0,5})(?:\\.[0-9]{1,6})?$"
            },
            "testPurchaseBudgetUSDC": {
              "type": "string",
              "pattern": "^(?:0|[1-9][0-9]{0,5})(?:\\.[0-9]{1,6})?$"
            },
            "testPurchasePayer": {
              "type": "string",
              "const": "buyer"
            },
            "note": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300,
              "description": "Public untrusted text; at most 300 Unicode code points after trimming."
            },
            "settlementMode": {
              "type": "string",
              "const": "protected_inspection"
            }
          },
          "required": [
            "capability",
            "deliverable",
            "priceUSDC",
            "testPurchaseBudgetUSDC",
            "testPurchasePayer",
            "note",
            "settlementMode"
          ],
          "additionalProperties": false
        },
        "requiredVariables": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "planFields": {
          "type": "object",
          "properties": {
            "version": {
              "type": "string",
              "const": "buyer-probe-v1"
            },
            "method": {
              "type": "string",
              "const": "GET"
            },
            "maxTestAmountAtomic": {
              "type": "string",
              "const": "20000"
            },
            "maxPaidAttempts": {
              "type": "number",
              "const": 1
            }
          },
          "required": [
            "version",
            "method",
            "maxTestAmountAtomic",
            "maxPaidAttempts"
          ],
          "additionalProperties": false
        },
        "pricing": {
          "type": "string"
        }
      },
      "required": [
        "method",
        "pathTemplate",
        "mcpTool",
        "fixedExampleFields",
        "requiredVariables",
        "planFields",
        "pricing"
      ],
      "additionalProperties": false
    },
    "handoff": {
      "type": "object",
      "properties": {
        "field": {
          "type": "string",
          "const": "protectedWorkHandoff"
        },
        "preparePath": {
          "type": "string",
          "const": "/v1/protected-inspections/prepare"
        },
        "directCheckoutAllowed": {
          "type": "boolean",
          "const": false
        },
        "selectionAuthorizesPayment": {
          "type": "boolean",
          "const": false
        },
        "sellerStart": {
          "type": "string"
        },
        "coordination": {
          "type": "string"
        }
      },
      "required": [
        "field",
        "preparePath",
        "directCheckoutAllowed",
        "selectionAuthorizesPayment",
        "sellerStart",
        "coordination"
      ],
      "additionalProperties": false
    },
    "costs": {
      "type": "object",
      "properties": {
        "network": {
          "type": "string",
          "const": "eip155:8453"
        },
        "asset": {
          "type": "string",
          "const": "USDC"
        },
        "serviceFee": {
          "type": "string"
        },
        "testPurchase": {
          "type": "string"
        },
        "gas": {
          "type": "string"
        },
        "platformCommission": {
          "type": "string",
          "const": "0"
        },
        "verifierFee": {
          "type": "string",
          "const": "0"
        }
      },
      "required": [
        "network",
        "asset",
        "serviceFee",
        "testPurchase",
        "gas",
        "platformCommission",
        "verifierFee"
      ],
      "additionalProperties": false
    },
    "clients": {
      "type": "object",
      "properties": {
        "profile": {
          "type": "string"
        },
        "proposal": {
          "type": "string"
        },
        "execution": {
          "type": "string"
        }
      },
      "required": [
        "profile",
        "proposal",
        "execution"
      ],
      "additionalProperties": false
    },
    "boundaries": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "$schema",
    "protocol",
    "kind",
    "notAPurchasableOffer",
    "capabilityId",
    "guide",
    "availability",
    "seller",
    "discovery",
    "buyer",
    "proposal",
    "handoff",
    "costs",
    "clients",
    "boundaries"
  ],
  "additionalProperties": false,
  "$id": "https://evidence.contact/protected-inspection-service.schema.json"
}
