Skip to main content

Gateway

Struct Gateway 

Source
pub struct Gateway { /* private fields */ }
Expand description

Gateway state shared by the HTTP handler and the Station channel.

Implementations§

Source§

impl Gateway

Enables the browser link routes with a persistent Noise identity.

§Errors

The key cannot be read or created, or it is of another method.

Source

pub fn start_browser_webtransport( &self, address: SocketAddr, tls: Arc<ServerConfig>, ) -> Result<BrowserWebTransport>

Starts the opt-in UDP listener. Drop the returned guard to stop accepting links.

§Errors

WebTransport is off, TLS or the UDP listener could not start, or no Tokio runtime is active.

Source§

impl Gateway

Source

pub fn with_station_auth( self, shared: SharedStationToken, replay_entries: usize, ) -> Self

How the gateway treats the shared Station token, and how many proof nonces it keeps (each for twice the clock skew; a proof is refused when they are all in use). The default is SharedStationToken::Auto and DEFAULT_REPLAY_ENTRIES.

Source

pub fn shared_station_token_accepted(&self) -> bool

Whether the shared Station token is accepted now.

Source

pub fn station_auth_weakenings(&self) -> Vec<String>

What keeps the Stations’ credentials from being what they should be, one line each, for the log and for a person who reads the Stations: the shared token being accepted, and a gateway that cannot tell Stations apart.

Source§

impl Gateway

Source

pub async fn serve_tls<F>( self, listener: TcpListener, config: Arc<ServerConfig>, shutdown: F, ) -> Result<()>
where F: Future<Output = ()> + Send + 'static,

Serves the gateway on listener over TLS with config (see tls_server_config) until shutdown: each request carries the client’s address and the certificates it proved.

§Errors

The listener fails to accept.

Source§

impl Gateway

Source

pub fn set_login_limits(&self, limits: &LoginLimits)

Makes the login and resume routes count tries by limits from now on. The counts held so far start over, so an address or name that was being held off is let through once.

Source

pub fn new(config: GatewayConfig) -> Self

Creates the bounded gateway state and the one authenticated Station input queue.

Source

pub fn with_secret_requester(self, signer: Signer, lifetime: f64) -> Self

Signs the secret requests this gateway leaves with signer, each valid for lifetime seconds. Without one they are unsigned, and only a Station told to accept that acts on them.

Source

pub fn with_secret_trust(self, trust: Trust) -> Self

Verifies the scope-key records it plans from, the Station certificates it seals to and the answers it reports against trust. The default pins no root, so every secret request is refused until one is set.

Source

pub fn with_registry( config: GatewayConfig, registry: Arc<dyn RegistryBackend>, ) -> Self

Creates a gateway backed by the shared Registry for user access tokens.

Source

pub fn with_access( config: GatewayConfig, registry: Arc<dyn RegistryBackend>, access: AccessProviders, ) -> Self

Creates a gateway backed by the shared Registry and configured user access providers.

Source

pub fn with_liaison(self, config: LiaisonConfig) -> Self

Serves A2A to config’s peers: on the HTTP JSON-RPC binding at /v1/a2a to a person signed in as a peer’s principal, and on links through Gateway::liaison and a liaison::LinkListener. Without it /v1/a2a answers 404.

Serves the links to people’s own agents: the WebSocket a relay dials at /v1/assistant/agent-link and the routes that ask for its codes and list and revoke its links, proving the gateway by the key kept at identity (made the first time, by Noise).

§Errors

GatewayError::InvalidConfiguration when the key cannot be read or made.

Source

pub fn liaison(&self) -> Option<Liaison>

Liaison’s A2A agent over this gateway, when Gateway::with_liaison set one up.

Source

pub fn with_roster(self, source: Arc<dyn ConfigProvider>) -> Self

Serves roster administration (/v1/user/roster/...) from source, the roster every Station reads. Edits need a source that takes changes, such as a SQL roster; without a source those routes answer 503.

Source

pub fn with_source_facts(self, facts: SourceFactsFn) -> Self

Reads what is known of a Source instance (its web page, intake labels) through facts; published_source_facts reads what the Stations publish at check-in, since this gateway loads no Source provider. An instance facts knows nothing of lists no page, and takes intake labels from its own labels.

Source

pub fn with_access_admin(self, access: Arc<LiveAccess>) -> Self

Serves the access administration routes (/v1/user/access, an Operation’s access) over access, the policy in force.

Source

pub fn with_own_providers(self, providers: Vec<ProviderEntry>) -> Self

Reports the providers this gateway has loaded (its sign-in, directory and authorizer providers) under the host name gateway.

Source

pub fn with_degraded(self, degraded: Vec<Degradation>) -> Self

Reports what keeps this gateway from being whole, on /v1/stations to a person who reads a Station.

Source

pub fn with_accounts(self, accounts: Arc<dyn Accounts>) -> Self

Serves the account routes (/v1/user/accounts) over accounts, the provider that keeps the accounts people sign in with.

Source

pub fn assistant_agent(&self) -> Option<String>

The roster Agent that is Moneypenny while she is on, as a conversation or turn that starts now would find her.

Source

pub fn set_assistant(&self, enabled: bool, config: Option<AssistantConfig>)

Turns Moneypenny on or off and gives the conversations and turns that start from now on config (when there is one to give); a turn already running finishes as it began. A gateway built without Gateway::with_assistant has no one to change.

Source

pub fn config(&self) -> &Arc<GatewayConfig> ⓘ

The limits and trusted origin this gateway runs by.

Source

pub fn with_assistant(self, config: AssistantConfig) -> Self

Serves Moneypenny, the operator’s assistant: the app’s conversation socket, her tools’ MCP endpoint and the Stations’ assistant routes. Her model runs on a Station as the roster Agent the config names. Without it the socket answers 503.

Source

pub fn with_job_poll_max_wait(self, max_wait: Duration) -> Self

How long a Station’s assistant job poll is held while Moneypenny is not served ([assistant.gateway] max_wait); once she is, her config decides.

Source

pub fn with_pages(self, config: PagesConfig) -> Result<Self, GatewayError>

Keeps the pages Moneypenny publishes in config.dir and serves them: under /pages/ on the API’s own origin, or, with config.origin, only on the pages’ own listener (Gateway::pages_router). Needs Gateway::with_assistant to publish anything.

§Errors

The directory cannot be made or read, or the origin is not an origin.

Source

pub fn pages_router(&self) -> Option<Router>

The router of the pages’ own listener: page routes only, no /v1. None unless Gateway::with_pages gave an origin.

Source

pub async fn serve_pages<F>( self, address: SocketAddr, shutdown: F, ) -> Result<(), Error>
where F: Future<Output = ()> + Send + 'static,

Serves the pages’ own listener on address until shutdown.

§Errors

The address cannot be bound, or there is no pages origin.

Source

pub fn authenticate_station(&self, presented: &str) -> Result<(), GatewayError>

Checks whether a presented secret is the configured Station channel credential.

Source

pub async fn register_run( &self, station_token: &str, operation_id: OperationId, mission_id: MissionId, run_id: RunId, ) -> Result<(), GatewayError>

Registers one active Run after authenticating the Station.

Source

pub async fn next_sequence( &self, station_token: &str, run_id: &RunId, ) -> Result<u64, GatewayError>

Returns the next event cursor for an authenticated registered Run.

Source

pub async fn board_runs(&self) -> Vec<BoardRun>

Returns the Runs, their latest lifecycle states and the Agent of each one’s Mission.

The Registry’s Run records say what ended or is waiting to be checked, which no Station sends again after the gateway restarts; the lifecycle frames received since say what is happening now and win while their sequence is above zero, unless the record has closed. Records past [gateway] board_runs, the least recently updated, are left out.

Source

pub async fn board_missions(&self) -> Vec<BoardMission>

Returns registered Missions grouped by Station with their Runs.

Source

pub async fn publish_lifecycle( &self, station_token: &str, event: LifecycleEvent, ) -> Result<(), GatewayError>

Encodes and publishes one lifecycle event for a registered Run.

Source

pub async fn publish_terminal_output( &self, station_token: &str, run_id: RunId, sequence: u64, bytes: Vec<u8>, ) -> Result<(), GatewayError>

Encodes and publishes raw terminal output without requiring the Station to encode guatiao.

Source

pub fn terminal_bytes(&self, run_id: &RunId) -> usize

The most terminal output that fits one frame of run_id at any sequence, and that the wire contract allows: what a Station is told, so that it splits longer output itself.

Source

pub async fn issue_attach_token( &self, station_token: &str, grant: AttachGrant, ) -> Result<String, GatewayError>

Mints an opaque, short-lived, single-use token for an existing Run.

Source

pub async fn exchange_attach_token( &self, token: &str, ) -> Result<String, GatewayError>

Exchanges an attach token for a cookie-only, one-connection ticket.

Source

pub async fn attach( &self, run_id: &RunId, ticket: &str, after_sequence: u64, ) -> Result<Attachment, GatewayError>

Consumes a connection ticket and grants one bounded viewer slot.

The returned replay starts with the latest schema announcement for each channel, followed by scrollback newer than after_sequence. Where that scrollback starts later than after_sequence or skips a sequence, a TerminalGap says so, ahead of the frame after it.

Source

pub async fn ingest( &self, station_token: &str, run_id: &RunId, sequence: u64, frame: Vec<u8>, ) -> Result<(), GatewayError>

Validates and records a Station-originated guatiao frame, then fans it out.

Source

pub async fn submit_input( &self, run_id: &RunId, connection_id: &str, frame: Vec<u8>, ) -> Result<(), GatewayError>

Queues one browser frame for the Station after confirming an active write lease.

Source

pub async fn disconnect(&self, attachment: Attachment)

Releases a viewer slot and its write lease when a socket closes.

Source

pub async fn disconnect_connection(&self, run_id: &RunId, connection_id: &str)

Releases an active connection by its non-secret internal handle.

Source

pub async fn receive_agent_input(&self) -> Option<AgentInput>

Waits for the next terminal input from an authenticated Station connection.

Source

pub async fn receive_agent_input_within( &self, wait: Duration, ) -> Option<AgentInput>

Waits at most wait for the next input; None when none came.

Source

pub fn public_origin(&self) -> &str

Returns the configured public HTTPS origin for same-origin checks.

Source

pub fn router(self) -> Router

Returns the Axum service for the Station channel, browser attach and terminal sockets.

Source

pub async fn serve_loopback<F>( self, port: u16, shutdown: F, ) -> Result<(), Error>
where F: Future<Output = ()> + Send + 'static,

Serves the gateway on loopback so browsers reach it only through the configured HTTPS reverse proxy. Once shutdown resolves and the open requests end, it waits up to [assistant.gateway] log_flush_timeout for Moneypenny’s conversation log.

Trait Implementations§

Source§

impl Clone for Gateway

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Gateway

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more