WardrikTriggers.Target behaviour (wardrik_triggers v0.1.0-rc.1)

Copy Markdown

Connects triggers to your agents. Given to WardrikTriggers as :target, as {module, config}.

Each callback gets config as its first argument.

Summary

Callbacks

Asks agent_id prompt.

Called after every run of trigger, with how it went.

Returns the secret name held for agent_id. A webhook names it as ${NAME}.

Callbacks

ask(config, agent_id, prompt, opts)

@callback ask(
  config :: term(),
  agent_id :: String.t(),
  prompt :: String.t(),
  opts :: [trigger: String.t(), overlap: :skip | :queue, labels: [String.t()]]
) :: :asked | :busy | :no_agent | {:error, term()}

Asks agent_id prompt.

Options

  • :trigger - the trigger's name.
  • :overlap - :skip to return :busy and ask nothing while the agent is busy. :queue to ask anyway.
  • :labels - ["outside"] when the prompt holds feed entries or a webhook body. [] otherwise.

Return :no_agent if there's no such agent. {:error, reason} is logged and reported as :failed.

fired(config, agent_id, trigger, status)

@callback fired(
  config :: term(),
  agent_id :: String.t(),
  trigger :: String.t(),
  WardrikTriggers.Trigger.status()
) :: :ok

Called after every run of trigger, with how it went.

resolve_secret(config, agent_id, name)

@callback resolve_secret(config :: term(), agent_id :: String.t(), name :: String.t()) ::
  {:ok, String.t()} | :error

Returns the secret name held for agent_id. A webhook names it as ${NAME}.