PhoenixKitAgent.Web.ToolAvailability (PhoenixKitAgent v0.1.0)

Copy Markdown View Source

The card "What the assistant can use now" of the admin pages: the admin tools of every module, the ones that read and the ones that write, as core shows them for a scope (PhoenixKit.API.Executor.tool_availability/1) — available, or closed and why. The assistant sees exactly the available ones (PhoenixKitAgent.Turns.Tools: core's visible_for/3 with allow: :all, no filter of the module's own), and a write still waits for the user's confirmation.

Settings → AI Agent shows it for the scope of the viewer's session, the role it acts as (PhoenixKitAgent.Web.Access.session_scope/1); Users → Configure for the chosen user by every role they hold (Scope.for_user/2 with narrow: false), which the role of a session can narrow. Core's list names every admin tool whatever the scope, so only the pages gated by agent.manage show it. It is read when the page or the form opens, not on every render.

Summary

Types

One module and its admin tools, as Executor.tool_availability/1 shows them.

Functions

The card. subject says whose rights the list is by: :session (the viewer's session, its role) or :user (the chosen user's roles).

The admin tools for scope, by module, in core's order (module name, then tool name). No scope (a session that can no longer act): nothing — never the list by the settings alone, which would show more than such a session may call.

Types

module_tools()

@type module_tools() :: %{
  key: String.t() | nil,
  name: String.t(),
  tools: [PhoenixKit.API.Executor.availability()]
}

One module and its admin tools, as Executor.tool_availability/1 shows them.

Functions

assistant_tools(assigns)

The card. subject says whose rights the list is by: :session (the viewer's session, its role) or :user (the chosen user's roles).

Attributes

  • id (:string) (required)
  • modules (:list) (required)
  • subject (:atom) (required) - Must be one of :session, or :user.

for_scope(scope)

@spec for_scope(term()) :: [module_tools()]

The admin tools for scope, by module, in core's order (module name, then tool name). No scope (a session that can no longer act): nothing — never the list by the settings alone, which would show more than such a session may call.