small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs network.md
5.7 kB · 119 lines
Markdown
at main

Outbound proxies #

The network settings section sends outbound connections directly or through a named proxy, for everything or per service. sdk/network declares the section, parses its values, and resolves a service's route. core_settings registers it beside the daemon's other sections, so /config lists it under Tools. This is separate from the inbound OpenAI-compatible proxy.

Configure routes #

The section has three optional fields in extensions.json:

  • proxies names proxy URLs.
  • services picks a route per service id. default is the route for every service without its own, and unset default connects directly.
  • profiles picks a route per provider profile name for that profile's model requests (generation, Fast and Daybreak checks, Codex image generation), overriding its extension's service route. Quota polls, sign-in, catalogs, and discovery share accounts across profiles and keep the service route.

A route is direct or a name from proxies. /config shows services and profiles as one picker per service or saved profile. A proxy URL has a scheme, host, and port:

  • socks5://host:port resolves the destination locally.
  • socks5h://host:port sends the destination hostname to the proxy.
  • http://host:port uses HTTP CONNECT, including for HTTP destinations.

A user, password, path, query, or fragment is refused. Proxy authentication is not supported. Setting a route does not start a proxy; it must already be reachable from the machine that connects.

{
  "network": {
    "proxies": {
      "tunnel": "socks5h://127.0.0.1:1080",
      "tor": "socks5h://127.0.0.1:9050"
    },
    "services": { "default": "tunnel", "models": "direct" },
    "profiles": { "work": "tor" }
  }
}

The service ids are honcho, photon, discord, colab, mcp, models (the models.dev catalog), and each provider or search extension's id, such as claude, codex, openai, or exa; an unknown id is refused. Tool jobs, SSH commands, and the browser opened for OAuth are not routed.

A model request takes its profile's route, else its service's, else default, else goes direct. The first one set wins, direct included, so direct on a service bypasses a default proxy. network.route applies that order to an already parsed section and reads no settings. resolve and resolve_model load the section and call it. Test the policy there, through settings.parse, rather than with a daemon per combination.

Failures #

An invalid saved value fails every routed call rather than connecting directly, and so does a proxy that refuses or cannot be reached. Destination TLS still verifies the certificate and hostname through the tunnel. Command-based quota feeds and AWS credential_process cannot honor a proxy, so they are refused under one.

Ownership #

A route is the albedo_http package's route.Route: Direct, or a Proxy with its scheme, host, and port. sdk/network owns only the policy that picks one. The client never looks a route up; its caller passes one in.

network_context keeps the route for the calling process. routed(service, run) resolves and runs under a service's route; a spawned worker keeps its caller's route through carried, which is also the carry a parallel map takes in map_carrying. connection_options() turns the current route, with albedo's trusted roots, into the options a connection opens with. The roots are the host's: core's trust policy keeps the OS store without the roots albedo blocks, and the host lends them through host resources, which connection_options reads each time a connection opens; sdk/http, MCP's HTTP transport, and Codex image generation pass it. transport() adds the provider budget cap to those options for the stream pump albedo_model_stream/http, which takes them as an argument and reads no route itself. Build either in the process that sends, since a route belongs to the calling process. sdk/http passes it to albedo_http/buffered, which sends a direct request through httpc and a proxied one through the streaming client, and verifies HTTPS against those roots either way. Do not set process-wide proxy environment variables or the global httpc proxy to route one service.

extension routes model provider requests, streams, catalogs, and search by extension id. Quota and oauth_flows route polls and sign-in exchanges the same way. The client's connection coordinator negotiates the tunnel before destination TLS, and pool keys distinguish routes. The Discord helper and Colab's SSH bridge get the route as ALBEDO_OUTBOUND_PROXY, read by albedo_plugins.proxy.