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

Copy Markdown

Parses agent IDs.

Wardrik.AgentID.parse("acme/@jon/triage/C1-1696.1234")
#=> {:ok, %Wardrik.AgentID{owner: "acme/@jon", name: "triage", conversation: "C1-1696.1234"}}

An ID is one of:

  • acme/triage - an org's agent.
  • acme/@jon/triage - a person's agent.
  • acme/triage/C1-1696.1234 or acme/@jon/triage/C1-1696.1234 - a conversation. It runs on its agent's definition, with its own history.

No segment may be empty or contain :, * or ?. : marks people known elsewhere, as slack:T0123/U024BE7LH. * and ? are for patterns.

Summary

Functions

Returns the ID of the agent whose definition id runs on.

Returns true if id is a conversation ID.

Parses id. Returns :error if it isn't an agent or conversation ID.

Types

t()

@type t() :: %Wardrik.AgentID{
  conversation: String.t() | nil,
  name: String.t(),
  owner: String.t()
}

Functions

agent(id)

@spec agent(String.t()) :: String.t()

Returns the ID of the agent whose definition id runs on.

Wardrik.AgentID.agent("acme/triage/C1-1696.1234")
#=> "acme/triage"

Returns id unchanged if it's an agent ID or doesn't parse.

conversation?(id)

@spec conversation?(String.t()) :: boolean()

Returns true if id is a conversation ID.

parse(id)

@spec parse(String.t()) :: {:ok, t()} | :error

Parses id. Returns :error if it isn't an agent or conversation ID.