Skip to main content

Module gateway_fwd

Module gateway_fwd 

Source
Expand description

The gateway forwarder: how a container agent’s model-gateway request is tied to its own container where srv cannot see which container it comes from (Docker Desktop: every container arrives from one address).

A helper container, container_name, runs agentmux-mcp gateway-fwd on the agents network. Container agents are pointed at it (key_route); it sees each one’s own address, puts it in a stamp (agentmux_common::gateway_stamp) on the request, and passes the request to srv. srv accepts the stamp only with the proof made from this launch’s secret (verify_stamp), so the address in it is the one the forwarder saw.

The helper gets no agent token, no Vault access, no mount and no capability. The secret reaches it only in its environment at creation, is made for each srv launch, and is never logged or written to a file. It is not restarted, it is removed when it stops, and srv removes it when srv ends (remove); one left by a srv that did not end cleanly has another launch’s secret and is replaced at the next turn.

Constants§

CONTAINER_PREFIX
What every forwarder’s name starts with.
HELPER_LABEL
The label that names the helper as AgentMux’s, and what the container list says it is.
HELPER_TEXT
PORT
The port it listens on, on the agents network.

Functions§

container_name
This srv instance’s forwarder’s name: the prefix and a short mark of its data directory. Two AgentMux instances on one machine (another channel, a dev build) share the Docker daemon and the agents network, and each has its own secret, so each has its own forwarder and neither replaces or removes the other’s. The same instance makes the same name at every launch. Its address on the agents network is found by this name (Docker’s own DNS on that network).
is_forwarder_name
Whether a container name is a gateway forwarder’s, any instance’s.
remove
Removes the forwarder, if there is one: when srv ends, and before a launch’s own is made. Best effort.
url
The forwarder’s base URL, as a container on the agents network reaches it.
verify_stamp
The container a request was stamped for, when its stamp is good for this request now.