View Source Jido behaviour (Jido v1.0.0-rc.3)

Jido is a flexible framework for building distributed AI Agents and Workflows in Elixir. It enables intelligent automation in Elixir, with a focus on Actions, Workflows, Bots, Agents, Sensors, and Signals for creating dynamic and adaptive systems.

This module provides the main interface for interacting with Jido components, including:

  • Listing and retrieving Actions, Sensors, and Domains
  • Filtering and paginating results
  • Generating unique slugs for components

Examples

iex> Jido.list_actions()
[%{module: MyApp.SomeAction, name: "some_action", description: "Does something", slug: "abc123de"}]

iex> Jido.get_action_by_slug("abc123de")
%{module: MyApp.SomeAction, name: "some_action", description: "Does something", slug: "abc123de"}

Summary

Functions

Callback used by the generated start_link/0 function. This is where we actually call Jido.Supervisor.start_link.

Retrieves an Action by its slug.

Retrieves an Agent by its slug.

Retrieves a Sensor by its slug.

Lists all Actions with optional filtering and pagination.

Lists all Agents with optional filtering and pagination.

Lists all Sensors with optional filtering and pagination.

Retrieves a prompt file from the priv/prompts directory by its name.

Types

component_metadata()

@type component_metadata() :: %{
  module: module(),
  name: String.t(),
  description: String.t(),
  slug: String.t(),
  category: atom() | nil,
  tags: [atom()] | nil
}

Callbacks

config()

@callback config() :: keyword()

Functions

ensure_started(jido_module)

@spec ensure_started(module()) :: Supervisor.on_start()

Callback used by the generated start_link/0 function. This is where we actually call Jido.Supervisor.start_link.

get_action_by_slug(slug)

@spec get_action_by_slug(String.t()) :: component_metadata() | nil

Retrieves an Action by its slug.

Parameters

  • slug: A string representing the unique identifier of the Action.

Returns

The Action metadata if found, otherwise nil.

Examples

iex> Jido.get_action_by_slug("abc123de")
%{module: MyApp.SomeAction, name: "some_action", description: "Does something", slug: "abc123de"}

iex> Jido.get_action_by_slug("nonexistent")
nil

get_agent_by_slug(slug)

@spec get_agent_by_slug(String.t()) :: component_metadata() | nil

Retrieves an Agent by its slug.

Parameters

  • slug: A string representing the unique identifier of the Agent.

Returns

The Agent metadata if found, otherwise nil.

Examples

iex> Jido.get_agent_by_slug("ghi789jk")
%{module: MyApp.SomeAgent, name: "some_agent", description: "Represents an agent", slug: "ghi789jk"}

iex> Jido.get_agent_by_slug("nonexistent")
nil

get_sensor_by_slug(slug)

@spec get_sensor_by_slug(String.t()) :: component_metadata() | nil

Retrieves a Sensor by its slug.

Parameters

  • slug: A string representing the unique identifier of the Sensor.

Returns

The Sensor metadata if found, otherwise nil.

Examples

iex> Jido.get_sensor_by_slug("def456gh")
%{module: MyApp.SomeSensor, name: "some_sensor", description: "Monitors something", slug: "def456gh"}

iex> Jido.get_sensor_by_slug("nonexistent")
nil

list_actions(opts \\ [])

@spec list_actions(keyword()) :: [component_metadata()]

Lists all Actions with optional filtering and pagination.

Parameters

  • opts: A keyword list of options for filtering and pagination. Available options:
    • :limit: Maximum number of results to return.
    • :offset: Number of results to skip before starting to return.
    • :name: Filter Actions by name (partial match).
    • :description: Filter Actions by description (partial match).
    • :category: Filter Actions by category (exact match).
    • :tag: Filter Actions by tag (must have the exact tag).

Returns

A list of Action metadata.

Examples

iex> Jido.list_actions(limit: 10, offset: 5, category: :utility)
[%{module: MyApp.SomeAction, name: "some_action", description: "Does something", slug: "abc123de", category: :utility}]

list_agents(opts \\ [])

@spec list_agents(keyword()) :: [component_metadata()]

Lists all Agents with optional filtering and pagination.

Parameters

  • opts: A keyword list of options for filtering and pagination. Available options:
    • :limit: Maximum number of results to return.
    • :offset: Number of results to skip before starting to return.
    • :name: Filter Agents by name (partial match).
    • :description: Filter Agents by description (partial match).
    • :category: Filter Agents by category (exact match).
    • :tag: Filter Agents by tag (must have the exact tag).

Returns

A list of Agent metadata.

Examples

iex> Jido.list_agents(limit: 10, offset: 5, category: :business)
[%{module: MyApp.SomeAgent, name: "some_agent", description: "Represents an agent", slug: "ghi789jk", category: :business}]

list_sensors(opts \\ [])

@spec list_sensors(keyword()) :: [component_metadata()]

Lists all Sensors with optional filtering and pagination.

Parameters

  • opts: A keyword list of options for filtering and pagination. Available options:
    • :limit: Maximum number of results to return.
    • :offset: Number of results to skip before starting to return.
    • :name: Filter Sensors by name (partial match).
    • :description: Filter Sensors by description (partial match).
    • :category: Filter Sensors by category (exact match).
    • :tag: Filter Sensors by tag (must have the exact tag).

Returns

A list of Sensor metadata.

Examples

iex> Jido.list_sensors(limit: 10, offset: 5, category: :monitoring)
[%{module: MyApp.SomeSensor, name: "some_sensor", description: "Monitors something", slug: "def456gh", category: :monitoring}]

prompt(name)

@spec prompt(atom()) :: String.t()

Retrieves a prompt file from the priv/prompts directory by its name.

Parameters

  • name: An atom representing the name of the prompt file (without .txt extension)

Returns

The contents of the prompt file as a string if found, otherwise raises an error.

Examples

iex> Jido.prompt(:system)
"You are a helpful AI assistant..."

iex> Jido.prompt(:nonexistent)
** (File.Error) could not read file priv/prompts/nonexistent.txt