Declarative routing rule compiled from Spectre.Agent DSL.
Rules are internal domain data. They normalize DSL options such as regexes, examples, checks, and handler declarations before any router plug sees them.
rule =
Spectre.Rule.new(%{
label: :help,
flow: :support,
regex: ~r/^help$/i,
handler: {:reply, :help, []}
})
Summary
Functions
Returns true when all checks pass against an input.
Returns true when any deterministic regex on the rule matches the text.
Builds a normalized routing rule from DSL metadata.
Types
@type t() :: %Spectre.Rule{ bag: [String.t()], cache: boolean(), checks: [{atom() | String.t(), term()}], constraints: [Spectre.Flow.Constraint.t()], definition_injections: [Spectre.Prompt.Operation.t()], embedding: [String.t()], flow: atom() | nil, flow_path: [atom()], global?: boolean(), handler: handler(), injections: [Spectre.Prompt.Operation.t()], jaro: [String.t()], label: atom(), learn: boolean(), opts: keyword(), owner: module() | nil, regex: [Regex.t()], scope: Spectre.Definition.scope(), via: [atom()] }
Functions
@spec checks_match?(t(), Spectre.Input.t()) :: boolean()
Returns true when all checks pass against an input.
Spectre.Rule.checks_match?(rule, input)
Returns true when any deterministic regex on the rule matches the text.
Spectre.Rule.match?(rule, "hello")
Builds a normalized routing rule from DSL metadata.
%Spectre.Rule{} = Spectre.Rule.new(%{label: :hello, regex: ~r/hello/})