MingaAgent.Runtime (Minga v0.1.0)

Copy Markdown View Source

Public API for the Minga agent runtime.

Unifies session management, tool execution, and introspection into a single entry point. External clients (API gateway, CLI tools, IDE extensions) should call this module rather than reaching into SessionManager, Tool.Registry, or Tool.Executor directly.

All functions here are Layer 1 (MingaAgent.*). They work in both headless mode (Minga.Runtime.start/1) and full editor mode.

Summary

Functions

Aborts the current operation on a session.

Returns a capabilities manifest describing the runtime.

Returns structured descriptions of all active sessions.

Returns structured descriptions of all registered tools.

Executes a tool by name with the given arguments.

Looks up the PID for a session ID.

Looks up a tool spec by name.

Lists all active sessions as {id, pid, metadata} tuples.

Returns all registered tool specs.

Sends a user prompt to a session.

Starts the API gateway (WebSocket + JSON-RPC).

Starts a new agent session. Returns {:ok, session_id, pid}.

Stops a session by its human-readable ID.

Returns true if a tool with the given name is registered.

Functions

abort(session_id)

@spec abort(String.t()) :: :ok | {:error, :not_found}

Aborts the current operation on a session.

capabilities()

Returns a capabilities manifest describing the runtime.

describe_sessions()

@spec describe_sessions() :: [MingaAgent.Introspection.session_description()]

Returns structured descriptions of all active sessions.

describe_tools()

@spec describe_tools() :: [MingaAgent.Introspection.tool_description()]

Returns structured descriptions of all registered tools.

execute_tool(name, args)

@spec execute_tool(String.t(), map()) :: MingaAgent.Tool.Executor.result()

Executes a tool by name with the given arguments.

get_session(session_id)

@spec get_session(String.t()) :: {:ok, pid()} | {:error, :not_found}

Looks up the PID for a session ID.

get_tool(name)

@spec get_tool(String.t()) :: {:ok, MingaAgent.Tool.Spec.t()} | :error

Looks up a tool spec by name.

list_sessions()

@spec list_sessions() :: [{String.t(), pid(), MingaAgent.SessionMetadata.t()}]

Lists all active sessions as {id, pid, metadata} tuples.

list_tools()

@spec list_tools() :: [MingaAgent.Tool.Spec.t()]

Returns all registered tool specs.

send_prompt(session_id, prompt)

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

Sends a user prompt to a session.

start_gateway(opts \\ [])

@spec start_gateway(keyword()) :: {:ok, pid()} | {:error, term()}

Starts the API gateway (WebSocket + JSON-RPC).

Does not start by default. Call explicitly from headless mode or when external clients need to connect. The Editor boot path never calls this.

Options:

  • :port - TCP port to listen on (default: 4820)

start_session(opts \\ [])

@spec start_session(keyword()) :: {:ok, String.t(), pid()} | {:error, term()}

Starts a new agent session. Returns {:ok, session_id, pid}.

stop_session(session_id)

@spec stop_session(String.t()) :: :ok | {:error, :not_found}

Stops a session by its human-readable ID.

tool_registered?(name)

@spec tool_registered?(String.t()) :: boolean()

Returns true if a tool with the given name is registered.