Imp.ACP.Host (Imp v0.5.0)

Copy Markdown View Source

A session-bound handle to capabilities supplied by an ACP host.

ACP calls the user-facing application the client. Imp.ACP.Host uses the product-facing name instead: it is the Toad, editor, or future chat application that mounted the workspace and advertised filesystem or terminal capabilities. The handle is created by Imp.ACP and passed to a :program_factory as session.host.

tools/2 turns those host capabilities into ordinary Imp.Tool values. The tools still cross Imp's per-execution authorization boundary before a write or command is sent. ExMCP remains responsible for ACP capability negotiation, request encoding, request cancellation, and response validation.

Summary

Functions

Delegates authorization for tools built by tools/2 to the ACP host.

Returns whether the connected ACP host advertised a tool's capability.

Builds tools for the capabilities advertised by the connected ACP host.

Types

t()

@type t() :: %Imp.ACP.Host{
  agent: GenServer.server(),
  client_capabilities: map(),
  cwd: Path.t(),
  session_id: String.t()
}

Functions

permission_policy(map, session)

@spec permission_policy(Imp.Execution.Authorization.t(), map()) :: :allow | :client

Delegates authorization for tools built by tools/2 to the ACP host.

Use this as Imp.ACP.run/1's :permission_policy only when the catalog entries with these names came from this module. Imp records a local allow at its execution boundary, but the tool immediately calls the connected ACP host, which applies its own capability policy and returns success or denial. This keeps one human decision at the host-owned effect boundary.

Other tool names retain the ordinary ACP permission request.

supported?(host, atom)

@spec supported?(t(), :read_file | :write_file | :run_command) :: boolean()

Returns whether the connected ACP host advertised a tool's capability.

tools(host, opts \\ [])

@spec tools(t(), keyword()) :: [Imp.Tool.t()]

Builds tools for the capabilities advertised by the connected ACP host.

All three host tools are requested by default, but unsupported tools are omitted. ACP treats omitted capabilities as unsupported, so an agent never advertises an effect that its host cannot perform.

Options

  • :only - The host tools to request. The default value is [:read_file, :write_file, :run_command].