Why this design exists
Without a shared tool layer, one operation can turn into three separate implementations:- A CLI command for terminal users
- An agent tool for LLM-driven actions
- An HTTP endpoint for the web UI and external clients
Architecture overview
The Tool is the unit of functionality. CLI commands and the AI agent can call tools in process. HTTP callers go through the Tool Registry, which gives the server one dispatch point for browser and API requests.Responsibilities
| Layer | Owns | Does not own |
|---|---|---|
| Tool | Operation behavior, validation, typed result | Console rendering, HTTP response shape, UI state |
| CLI | Argument parsing and terminal output | Business logic |
| AI agent | Tool selection through the model runtime | Separate tool implementations |
| HTTP API | Request/response transport | Operation-specific logic |
| Tool Registry | HTTP dispatch, policy hooks, discoverability | Per-caller UI behavior |
Tool Registry boundary
The Tool Registry is the server-side entry point for callers that cannot import the Python tools directly. It keeps one registered instance of each tool and dispatches requests by name. This matters because it gives Hiro League a single place to add cross-cutting behavior for HTTP and future remote callers:- Source-based restrictions
- Role-based access
- Destructive operation confirmation
- Rate limiting
- Audit logging
Caller model
CLI commands run outside the server process. They import tools directly, call them, and render terminal output. This keeps lifecycle operations available even when the server is stopped. AI agent tools run inside the server process. The agent receives tool schemas derived from the same tool definitions and invokes the selected tool in process. HTTP API callers use registry endpoints. The web UI discovers available tools and invokes them through the server, without hardcoding operation-specific routes.Benefits summary
| Concern | Design answer |
|---|---|
| Single source of truth | Operation behavior lives in one tool definition. |
| Less schema drift | Tool metadata feeds CLI, agent, and HTTP surfaces. |
| Uniform policy enforcement | Registry dispatch is the policy boundary for HTTP callers. |
| Discoverability | The server can expose registered tools dynamically. |
| Offline CLI | CLI commands can run without a live server. |
| In-process agent | Agent calls avoid an unnecessary HTTP boundary. |
| Incremental growth | New operations follow one repeatable registration path. |
