What’s the idiomatic way of defining the return type for a call then? Do you use variants with @tag("type") as @as("agent_start")? Or is there another way?
And how can I check during runtime that the shape actually matches the expected variant? Do I just use sury and redefine the type as a schema or has ReScript built in mechanisms to do that for me?
I’d say Sury or any other encoding/decoding library is the idiomatic way in any programming language, not only ReScript. You don’t want to depend on an API response structure for your domain types anyway.
In many cases a library like sury make sense, but if you wouldn’t like to rely on a library, you could also use for example the built-in json type to parse it.