MingaAgent.Tool.Context (Minga v0.1.0)

Copy Markdown View Source

Per-session runtime context for building executable agent tools.

This is a narrow capability object. It gives tool builders the project root, routed workspace access, command working directory data, and correlation ids without exposing raw session state.

Summary

Types

t()

Opaque-ish runtime context passed to source-owned tool builders.

Functions

Returns command environment entries for this context.

Deletes a file through the session router.

Edits a file through the session router.

Builds a tool context from runtime values.

Reads a file through the session router.

Returns opts accepted by MingaAgent.Tools.all/1.

Returns the command working directory for this context.

Writes a file through the session router.

Types

t()

@type t() :: %MingaAgent.Tool.Context{
  metadata: map(),
  project_root: String.t(),
  router_context: MingaAgent.ToolRouter.Context.t(),
  session_id: String.t() | nil
}

Opaque-ish runtime context passed to source-owned tool builders.

Functions

command_env(context)

@spec command_env(t()) :: [{String.t(), String.t()}]

Returns command environment entries for this context.

delete_file(context, path)

@spec delete_file(t(), String.t()) :: :ok | :passthrough | {:error, term()}

Deletes a file through the session router.

edit_file(context, path, old_text, new_text)

@spec edit_file(t(), String.t(), String.t(), String.t()) ::
  :ok | :passthrough | {:error, term()}

Edits a file through the session router.

new(attrs)

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

Builds a tool context from runtime values.

read_file(context, path)

@spec read_file(t(), String.t()) :: {:ok, binary()} | {:error, term()}

Reads a file through the session router.

tools_opts(context)

@spec tools_opts(t()) :: keyword()

Returns opts accepted by MingaAgent.Tools.all/1.

working_dir(context)

@spec working_dir(t()) :: String.t() | nil

Returns the command working directory for this context.

write_file(context, path, content)

@spec write_file(t(), String.t(), binary()) :: :ok | :passthrough | {:error, term()}

Writes a file through the session router.