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

Captures a routed file with exact retained bytes and source revision.

Returns command environment entries for this context.

Deletes a file through the session router.

Edits a file through the session router.

Fetches exact retained bytes from this record's artifact owner without replaying a tool.

Scopes a record-owned artifact capability to one durably admitted tool call.

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

capture_key()

@type capture_key() :: {:delivery, String.t(), String.t()}

image_tool_result_delivery()

@type image_tool_result_delivery() ::
  MingaAgent.ModelSelection.image_tool_result_delivery()

t()

@type t() :: %MingaAgent.Tool.Context{
  artifact_store: GenServer.server() | nil,
  capture_key: capture_key() | nil,
  image_tool_result_delivery: image_tool_result_delivery(),
  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

capture_file(context, path, opts \\ [])

@spec capture_file(t(), String.t(), keyword()) ::
  {:ok, MingaAgent.Tool.Output.t()}
  | {:error, MingaAgent.Tool.Output.t() | term()}

Captures a routed file with exact retained bytes and source revision.

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.

fetch_output(context, reference, range)

@spec fetch_output(
  t(),
  MingaAgent.Tool.Output.Reference.t(),
  MingaAgent.Tool.Output.Range.t()
) ::
  {:ok, term()} | {:error, term()}

Fetches exact retained bytes from this record's artifact owner without replaying a tool.

for_tool_call(context, artifact_store, checkpoint_id, tool_call_id)

@spec for_tool_call(t(), GenServer.server(), String.t(), String.t()) :: t()

Scopes a record-owned artifact capability to one durably admitted tool call.

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.