Pi.Plugin behaviour (pi_bridge v0.6.22)

Copy Markdown View Source

Behaviour for supervised pi_bridge plugins.

Summary

Types

command_result()

@type command_result() :: {:ok, String.t()} | {:error, String.t()} | String.t()

tool_call_result()

@type tool_call_result() :: :ok | {:ok, map()} | {:block, String.t()}

tool_result_result()

@type tool_result_result() :: :ok | {:ok, map()}

Callbacks

apis()

(optional)
@callback apis() :: [Pi.Plugin.API.t() | keyword() | map()]

commands()

(optional)
@callback commands() :: [Pi.Plugin.Command.t() | keyword() | map()]

handle_command(atom, t, term)

(optional)
@callback handle_command(atom(), String.t(), term()) ::
  {command_result(), term()} | command_result()

handle_event(map, term)

(optional)
@callback handle_event(map(), term()) :: {:noreply, term()} | term()

init(keyword)

(optional)
@callback init(keyword()) :: {:ok, term()} | {:error, term()} | term()

shutdown(term)

(optional)
@callback shutdown(term()) :: :ok | term()

tool_call(map, map, term)

(optional)
@callback tool_call(map(), map(), term()) ::
  {tool_call_result(), term()} | tool_call_result()

tool_result(map, map, term)

(optional)
@callback tool_result(map(), map(), term()) ::
  {tool_result_result(), term()} | tool_result_result()

Functions

api(attrs)

(macro)

command(attrs)

(macro)