ExAthena.ToolContext (ExAthena v0.4.5)

Copy Markdown View Source

Context handed to every tool execution.

Carries the working directory the loop should treat as root, the current permission mode, the session id (if any), and a free-form assigns map for custom tools to stash arbitrary data the consumer needs (project id, conversation id, ticket id — whatever the host cares about).

Tools that don't care about context can ignore it, but cwd and phase are load-bearing for any tool that touches the filesystem or checks permissions.

Summary

Functions

Build a context. :cwd is required; everything else defaults.

Resolve a user-supplied relative path against ctx.cwd, rejecting traversal.

Types

phase()

@type phase() :: :plan | :default | :accept_edits | :trusted | :bypass_permissions

t()

@type t() :: %ExAthena.ToolContext{
  assigns: map(),
  cwd: Path.t(),
  phase: phase(),
  session_id: String.t() | nil,
  tool_call_id: String.t() | nil
}

Functions

new(opts)

@spec new(keyword()) :: t()

Build a context. :cwd is required; everything else defaults.

resolve_path(arg1, path)

@spec resolve_path(t(), String.t()) :: {:ok, Path.t()} | {:error, term()}

Resolve a user-supplied relative path against ctx.cwd, rejecting traversal.