Wardrik.Definition (wardrik_protocol v0.1.0-rc.1)

Copy Markdown

What an agent is and what it may do: an agent file's frontmatter, as a struct.

definition =
  Wardrik.Definition.new!(
    model: "anthropic:claude-haiku-4-5",
    instructions: "You watch the incident queue.",
    tools: ["linear/*"],
    policy: [ask: ["linear/*"]]
  )

Wardrik.Agent.define(scope, "acme/triage", definition)
#=> {:ok, %Wardrik.Agent{id: "acme/triage", status: :idle, ...}}

Its fields follow the protocol's agent_definition schema. Tools and policies it names must be ones Wardrik offers. See Wardrik.start_link/1.

:policy, :workspace, :context, :retries, :compaction and :notify stay as the protocol's JSON. Each of :triggers is a Wardrik.Trigger.

Summary

Functions

Builds one from the protocol's JSON.

Names each unnamed trigger by its position: trigger-1, trigger-2, and so on.

Builds a definition from a keyword list or map. Raises ArgumentError if it doesn't match the schema.

Returns the principal the agent id acts as: its user, as acme/@maria, or its org, as acme.

Returns it as the protocol's JSON, without fields that are nil.

Types

t()

@type t() :: %Wardrik.Definition{
  channels: term(),
  compaction: term(),
  context: term(),
  description: term(),
  display_name: term(),
  idle_timeout: term(),
  instructions: term(),
  max_iterations: term(),
  model: term(),
  notify: term(),
  policy: term(),
  retries: term(),
  timeout: term(),
  tools: term(),
  triggers: term(),
  workspace: term()
}

Functions

from_json(json)

@spec from_json(map()) :: t()

Builds one from the protocol's JSON.

named(definition)

@spec named(map()) :: map()

Names each unnamed trigger by its position: trigger-1, trigger-2, and so on.

Takes and returns the definition as the protocol's JSON.

new!(fields)

@spec new!(keyword() | map()) :: t()

Builds a definition from a keyword list or map. Raises ArgumentError if it doesn't match the schema.

principal(id)

@spec principal(String.t()) :: WardrikCore.Principal.t()

Returns the principal the agent id acts as: its user, as acme/@maria, or its org, as acme.

Raises MatchError if id isn't an agent ID.

to_json(value)

@spec to_json(t()) :: map()

Returns it as the protocol's JSON, without fields that are nil.