Wardrik. Server behaviour
(wardrik_protocol v0.1.0-rc.6)
Copy Markdown
A behaviour for what runs Wardrik's operations. Wardrik implements it.
Wardrik.Agent and the other operation modules call the server in their Wardrik.Scope. So
packages call them without depending on wardrik. WardrikTesting.Server implements it for tests.
Summary
Callbacks
Answers the worker's call with the JSON-RPC message.
Sends the input to the agent and streams its answer
Offers a worker's tools, as MCP's tools/list returns them. The calling process then receives
Runs the request's operation.
Runs the request's streamed operation. Streams {event, cursor}: kept events, then new ones.
Callbacks
Answers the worker's call with the JSON-RPC message.
@callback follow(Wardrik.Server.Follow.t(), opts :: keyword()) :: Enumerable.t()
Sends the input to the agent and streams its answer:
{:text, chunk}, any number of times.- One of
{:done, %Wardrik.Reply{}},{:waiting, interrupts}or{:failed, why}.
Raises Wardrik.Error if the agent can't be reached.
@callback offer(Wardrik.Scope.t(), tools :: [map()]) :: :ok | {:error, term()}
Offers a worker's tools, as MCP's tools/list returns them. The calling process then receives:
{Wardrik.Workers, :call, call, name, arguments, meta}for each call to a tool.{Wardrik.Workers, :cancel, call}when a call is cancelled.
@callback run(Wardrik.Server.Request.t()) :: {:ok, term()} | {:error, Wardrik.Error.t()}
Runs the request's operation.
@callback stream(Wardrik.Server.Request.t()) :: {:ok, Enumerable.t()} | {:error, Wardrik.Error.t()}
Runs the request's streamed operation. Streams {event, cursor}: kept events, then new ones.