Skip to content

authRequired — suspend for authorization

Elixir · package toolnexus · SPEC §10

The auth-shaped suspension: hand back a URL, resume once the user has granted access.

Build the auth-shaped suspension by hand: a %Toolnexus.ToolResult{} whose metadata.pending carries a %Toolnexus.Request{kind: "authorization"} with a :url instead of expecting typed input:

%Toolnexus.ToolResult{
output: "Log in",
is_error: true,
metadata: %{
pending: %Toolnexus.Request{
id: "pnd-2",
kind: "authorization",
prompt: "Log in",
url: "https://example.com/login"
}
}
}

Same wire shape as every other port’s authRequired/1, same id correlation discipline as pending — only the constructor is missing, not the behavior. Toolnexus.ToolResult.pending?/1 reads either shape back identically.