Service API (source builds)
axlr-serve is the service adapter in the tui Go module. It reuses the console's turn and tool-resolution use cases. The JSON worker remains a one-request process. The REST route and payload reference is OpenAPI v1. See service operations for probes, a direct-read smoke check and recovery.
The same service capabilities are available through gRPC and an authenticated Streamable HTTP MCP server at /mcp. The transport parity contract lists all 19 verbs, shared schemas, approvals and event delivery; the OpenAPI document also describes POST /v1/operations/{verb} and /mcp. Set optional grpc_listen to a separate address such as 127.0.0.1:9443; an omitted field leaves it disabled. Existing REST payloads and probe routes remain available.
Build with GOWORK=off go -C tui build -trimpath -o /tmp/axlr-serve ./cmd/axlr-serve; run /tmp/axlr-serve --config=/absolute/path/service.json. --version prints the injected build version. The service configuration is strict JSON (at most 64 KiB) with absolute file paths and explicit listeners. This template names existing files/services; replace every placeholder before launch:
{
"api_listen": "127.0.0.1:8443",
"probe_listen": "127.0.0.1:8081",
"workspace": "/absolute/workspace",
"state_dir": "/absolute/private/axlr-state",
"server_cert_file": "/absolute/secrets/api/tls.crt",
"server_key_file": "/absolute/secrets/api/tls.key",
"client_ca_file": "/absolute/secrets/client-ca/ca.crt",
"principals_file": "/absolute/secrets/principals.json",
"model_api_key_file": "/absolute/secrets/openrouter-key",
"kmp": {
"endpoint": "kmp.example.internal:50051",
"server_name": "kmp.example.internal",
"tls_dir": "/absolute/secrets/kmp",
"command": "/absolute/bin/kmp-mcp"
},
"made": {
"endpoint": "made.example.internal:50051",
"server_name": "made.example.internal",
"tls_dir": "/absolute/secrets/made",
"command": "/absolute/bin/made-mcp"
}
}
Each engine TLS directory contains ca.crt, tls.crt and tls.key. The adapters run over stdio and connect to remote gRPC with mutual TLS. Both engines are mandatory configuration entries. The service does not load console mcp.json or plugin packages, reads a console settings.json only through settings_file, and has no work-mode API. /v1/sessions starts normal sessions. Install engine policies/definitions through their operator channels; AXLR's service config does not bootstrap them.
The API listener requires TLS 1.3, a client certificate signed by the configured CA, and an entry in the private principals file. A certificate that chains to the CA but is not mapped is forbidden. The policy is JSON:
{"version":1,"entries":[{"certificate_sha256":"64-lowercase-hex-characters","principal_id":"alice","roles":["session_client","approver","tool_operator"]}]}
certificate_sha256 is SHA-256 of the client's DER leaf certificate. Roles are session_client, approver, tool_operator, and admin. Sessions belong to the creating principal; admin can access any session. An approver can decide a pending exact call. A tool_operator can create a direct call. mTLS authentication never approves a tool by itself.
All command bodies use application/json, UTF-8, at most 4 MiB, and reject unknown fields. Idempotency-Key (16–128 safe ASCII characters) is required for turns, approvals and direct calls. A repeated key with the same method, route, body and principal returns the original resource; conflicting reuse returns 409 idempotency_conflict. expected_revision guards decisions and cancellation. Errors have error.code, error.message and error.request_id; the same ID is returned in X-Request-Id.
Typical flow:
POST /v1/sessionswith{"model":"provider/model"}; saveidandrevision.POST /v1/sessions/{id}/turnswith{"prompt":"...","expected_revision":1}and an idempotency key; save theoperation_id.GET /v1/sessions/{id}/eventswithAccept: text/event-stream. UseLast-Event-IDor?after=Nto resume after sequenceN; the query takes precedence if both are supplied. A cursor ahead of the journal returns400 invalid_cursor. Closing the stream does not cancel the turn.- If an
approval.requiredevent appears, inspect the session's first pending call andPOST /v1/sessions/{id}/approvals/{call_id}with{"decision":"approve","expected_revision":N}and a new idempotency key. - Read the result from
GET /v1/sessions/{id}(result), or from the payload of the event that ended the turn (approval.required,turn.completed,turn.interrupted,operation.failed): the runtime contract's object, with the status, the answer, the pending call, every call with what became of it, and the usage and cost. It is null until a turn ends.
GET /v1/tools lists exact local and connected MCP identities and schemas. POST /v1/tool-calls creates a durable direct-call intent. Its POST /v1/tool-calls/{id}/decisions endpoint approves or denies that one call. Effectful calls persist a checkpoint before execution. An uncertain result after an interrupted effectful call requires operator inspection; AXLR does not retry it automatically or expose a reconciliation endpoint. The shipped service uses manual approvals for local and engine tools. There is no separate continue endpoint: interrupted pending calls can be decided through their approval route; an interrupted session with no pending calls can accept a new prompt.
The state directory contains session snapshots, event journals, call arguments and audit records. On Windows, service startup replaces inherited ACLs on that directory and its existing contents with access for the current account, SYSTEM and Administrators; it refuses reparse points. Use a dedicated directory owned by the service account.
/livez and /readyz are available only on the separate loopback probe listener. Readiness checks a configured nonempty model key and discovery through both KMP and MADE MCP adapters. It does not verify account credit, make a model completion or prove that an engine write/ceremony action is authorized. Missing or empty model credentials stop startup; engine transport failures can leave the API alive with failing readiness. axlr-serve --probe=livez and --probe=readyz always query loopback port 8081, matching the chart; query the configured endpoint directly if you use another probe port.
The console's loop in the service🔗
Since 23 October 2026 the service composes its turns with the console's loop (tui/compose): the context cap and its successor sessions, the session's MADE instance, Jev, forged and catalog tools, the memory tools, the cost cap and the exec sandbox. A client such as a bot needs these facts:
-
Result. The session and the event that ends a turn carry the execution's result, the same object
axlr-tui --exec --jsonwrites last (runtime contract); a bot reads it instead of the transcript. -
Policy.
CreateSessiontakespolicy, the runtime contract's policy per execution: an autonomy level and the tools the session may and may not use. The session keeps it,GetSessionshows it, and a call it forbids is refused outside the model before anyapproval.required, with statusforbiddenin the result; a tool it forbids is not offered to the model. An invalid policy is422 invalid_policy. -
Budget.
CreateSessiontakesbudget, the contract's budget per execution (seconds,requests,tool_calls,usd), enforced outside the model;GetSessionshows it. The seconds count from the session's creation. At the first limit reached the turn ends inturn.interruptedwhose result saysbudget_exceededwith the limit inerror(budget: requests 20 reached); nooperation.failedfollows, the session stays resumable, and a call thetool_callslimit refused stays pending, where a decision under the same budget refuses it again. An invalid budget is422 invalid_budget. The budget follows the session into the successor the context cap opens. -
Artifacts. A turn's
axlr_delivercalls hand over deliverables: a workspace file by path, which runs without an approver as a read, or inline content written to.axlr/deliverables/<session>/<name>, which waits for anapproveras a write does. Each is journaled as anartifactevent after itstool.completedand listed in the result'sartifactswith its size, sha256 and workspace-relativereference(the contract). -
Sandbox.
CreateSessiontakessandbox, the contract's sandbox per execution (profilenone,processorcontainer;egressnone,allowlistwith itsallowlist, orfull;writable,readable,container), which confines the session'slocal_execand forged tools;GetSessionshows it with its egress spelled out. The service checks it on this host before creating the session: one it cannot give (bwrap or the container runtime missing, user namespaces refused, the image not on the host) is422 sandbox_unavailable, never a weaker one, and an invalid one422 invalid_sandbox. Underexec_sandbox.mode: requiredin the service's settings the profile cannot benone. The model requests and MCP servers stay outside it. The sandbox follows the session into the successor the context cap opens. -
Routing.
CreateSessiontakesrouting, the contract's routing per execution (candidates,objectivecost,latencyorquality-first,allow_remote_providers,max_context_tokens,max_request_usd), which chooses the model of each request;GetSessionshows it withallow_remote_providersspelled out. With a routing,modelmay be left out: the first candidate becomes the session's model. A session created without one takes the service'ssettings.jsonrouting, if any. Each request is journaledmodel.routedwith itsmodelandroute(ranked, orfallbackwithfromanderrorwhen the candidate ranked first failed before any output and the next one took the request), and the receipt names the routing and each request's route. A request no candidate may take ends the turn inturn.interrupted, never on another model. An invalid routing is422 invalid_routing; neither model nor routing is422 invalid_model. The routing follows the session into the successor the context cap opens. -
Skills.
CreateSessiontakesskills, the contract's skills per execution: a list of{name, version, catalog?}pins the session's catalog skills to those versions, resolved against the skills installed under the service's state directory (axlr-tui skills --state <state_dir> install <name>@<version> --yes, with asettings.jsonwhosecatalogsname the catalog); one not installed is422 skills_unavailable, an invalid list422 invalid_skills.GetSessionshows them with their catalog andbundle_sha256. Withoutskillsa session reads the newest installed version of each. The service's system prompt lists the console's own skills and the session's catalog skills, which the model reads withaxlr_skill. -
Receipt.
GetSessionshowsreceipt(null until a turn ends): every model request of the session with its model, provider, usage and cost, every call with the sha256 of its arguments and outcome and how long it ran, and the policy, budget, sandbox, pinned skills, routing and correlation, read from a journal written as each request and call starts and ends, so it survives a restart; a request the process died in is listedinterrupted(the contract). -
Correlation.
CreateSessiontakescorrelation, the contract's ids per execution (bot_id,task_id,execution_id,trace_id);GetSessionshows it, every event the service journals for the session carries it in its payload ascorrelation, the result repeats it, and the session's MADE record and KMP entries are labelled with it. An invalid correlation is422 invalid_correlation. -
Approvals. Every tool call a model makes in a service session stops at
approval.required, except the ones the console approves by itself: reads of the workspace (local_read,local_search) and its own read-only tools, which go fromtool.requestedtotool.completed. The service's policy is manual for every other tool.approval.requiredis the last event of its operation; the turn waits until a principal with theapproverrole posts a decision. A bot that lets strangers prompt it must not approve on its own; give it a human approver or keep the session's tools to reads. -
Context cap. Past the cap (
prompt_tokens, 75,000 by default) the turn stops, the session's instance closes and the service opens a successor owned by the same principal. The capped session's journal getssession.continuedwithsuccessor_idandoperation_id; the successor's first turn starts by itself with the capped prompt. Follow the successor's events and read its revision before the next turn: it starts at revision 2, because the successor is saved once to create it and once to set its owner. -
CloseSession.
POST /v1/sessions/{id}/closewithexpected_revision(verbCloseSession, MCPaxlr_close_session) ends the session's MADE instance and journalssession.closed; the transcript stays and a later turn continues in the instance's successor. It refuses a running turn with409 operation_in_progress. The service closes every open instance when it stops and, at start, ends as abandoned those a crash left open. -
settings_file. An optional absolute path to a consolesettings.json. The service honourslocal_models,models,prompt_tokens/context_tokens,jev,forged_tools,catalogs,max_session_usd,turn_tool_calls,ceremony_profile,reviewer_modelandexec_sandbox. A file the configuration names must exist. -
Local commands.
local_execand the forged tools that run through it get the console's environment (tui/compose/exec_environment.go): the absolute folders of the service's ownPATH, or/usr/local/bin:/usr/bin:/binwhen it names none (on Windows the system folders it lacks are added, withSystemRootandUSERPROFILE), and an absoluteHOME. Nothing else reaches a command: not the model key, not alocal_modelsapi_key_env, not Jev's key. There is no configuration key for this path; to change what commands find, change the service's ownPATH(a systemd unit'sEnvironment=PATH=…, the container's environment). The published image is distroless, with no shell or coreutils, so a command there finds only the image's own binaries unless you build an image on it. Before 25 October 2026 the service gave its commands noPATH, and everylocal_execfailedprogram "…" not found in configured PATH. -
Grok without OpenRouter. A
local_modelsentry reaches any OpenAI-compatible server over HTTPS with its key in an environment variable:{"local_models":[{"id":"xai/grok","url":"https://api.x.ai/v1","model":"grok-4","api_key_env":"XAI_API_KEY","context_tokens":131072}]}Create sessions with
{"model":"xai/grok"}. Through OpenRouter, anx-ai/…id works without settings.model_api_key_fileis still required either way. -
MADE. The session instance needs
axlr_sessionpublished in MADE and theaxlractor granted to claim it; otherwise the service says so at start and sessions run without an instance.