BB.MCP.Robots (bb_mcp v0.1.0)

Copy Markdown View Source

Resolves between agent-facing robot name strings and robot modules.

Robot names are derived from the last segment of the module name, lowercased.

MyApp.WX200    -> "wx200"
MyApp.SO101    -> "so101"
MyApp.Robot    -> "robot"
MyApp.Two.Word -> "two_word" (only when the segment is itself camel-cased,
                              e.g. `MyApp.TwoWord` -> "two_word")

Summary

Functions

Build a name → module map from a list of robot modules, raising on collisions.

Look up a robot module by name. Returns {:ok, module} or {:error, :unknown_robot}.

The agent-facing name for a robot module.

List all configured robots as {name, module} tuples, sorted by name.

Types

config()

@type config() :: %{required(String.t()) => module()}

Functions

build!(modules)

@spec build!([module()]) :: config()

Build a name → module map from a list of robot modules, raising on collisions.

fetch(config, name)

@spec fetch(config(), String.t()) :: {:ok, module()} | {:error, :unknown_robot}

Look up a robot module by name. Returns {:ok, module} or {:error, :unknown_robot}.

name_for(module)

@spec name_for(module()) :: String.t()

The agent-facing name for a robot module.

to_list(config)

@spec to_list(config()) :: [{String.t(), module()}]

List all configured robots as {name, module} tuples, sorted by name.