# ============================================================================ # junction.conf — Olivia # # One front door for every model endpoint in the van. Clients (Hermes, scripts, # editors) talk to 127.0.0.1:8090 and never learn which machine answered. # # Shape of the file: keyword, arguments, braces. '#' comments, "" groups words, # first matching rule wins. A typo is a hard error with a line number — this file # decides where requests go, so silence would be the worst behaviour. # ============================================================================ listen 0.0.0.0:8090 # Same thing over TLS, no proxy in front (clients must then use https://): # listen 0.0.0.0:8443 tls /etc/junction/tls/olivia-cert.pem /etc/junction/tls/olivia-key.pem log_prefix olivia connect_timeout_ms 1200 # a box that cannot answer a SYN in 1.2 s is asleep offline_hold_s 20 # stop retrying a dead box for this long max_body_bytes 67108864 # 64 MiB: a long conversation, not a file upload # Two slots in flight; everything else waits its turn instead of being refused. A # streaming client is told why it waits (SSE comments, invisible to any parser). max_inflight 2 queue_timeout 300 # Answers to identical requests, kept in RAM. Only complete, non-streamed 200s are # stored; streams and "no-store" responses never are. 0 disables the cache. cache_ttl 120 cache_entries 256 cache_bytes 67108864 # --------------------------------------------------------------------------- # The two slots on the workstation, over the WireGuard tunnel. Both serve the same # loaded model, and only while its kanban is idle, so "reachable" is not the same as # "free": check-http.sh asks /v1/models and hook_retry gives it a moment to finish. # The real id, as their own /v1/models reports it, is # Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M # A single-model box answers to that id and can hang on any other name, which is what # the "as" rewrites below are for. # --------------------------------------------------------------------------- endpoint peer-a { base http://172.25.206.3:8081/v1 kind local context 65536 priority 10 timeout 900 # long jobs are fine, but not unbounded idle_timeout 45 # ... as long as something arrives every 45 s cooldown 60 hook /usr/local/share/junction/hooks/check-http.sh hook_retry 45 # up to 45 s of "kanban still running, wait" hook_backoff 5 header "X-Junction-Peer: a" } endpoint peer-b { base http://172.25.206.3:8082/v1 kind local context 65536 priority 20 timeout 900 idle_timeout 45 cooldown 60 hook /usr/local/share/junction/hooks/check-http.sh hook_retry 45 hook_backoff 5 header "X-Junction-Peer: b" } # --------------------------------------------------------------------------- # The embedding model on the other machine: small, always on, never woken. # --------------------------------------------------------------------------- endpoint kitt-embed { base http://192.168.1.116:11434/v1 kind local context 2048 priority 5 timeout 120 idle_timeout 15 cooldown 120 cache off # embeddings are cheap to repeat, not worth the RAM } # --------------------------------------------------------------------------- # A machine that sleeps. The hooks decide whether it is worth waking, the wake # command runs once, and the request waits up to four minutes for it to come back. # WoL is layer 2 and does NOT cross the tunnel, so this endpoint is a box on n95's # own segment. For a tunnel peer, the wake hook must talk to something on THAT side # (a router's WoL feature, a small helper host) instead of broadcasting here. # --------------------------------------------------------------------------- endpoint desk { base http://192.168.1.99:8080/v1 # placeholder: your box on this LAN kind local context 128000 priority 5 timeout 3600 idle_timeout 60 cooldown 120 wake /usr/local/share/junction/hooks/wake-wol.sh hook_retry 240 hook_backoff 10 hook /usr/local/share/junction/hooks/check-http.sh hook /usr/local/share/junction/hooks/check-budget.sh # only when the sun pays } # --------------------------------------------------------------------------- # The opencode-go. Last resort for context that does not fit, models the van does not # have, and anything the local boxes refuse. Key never lives in this file. # --------------------------------------------------------------------------- endpoint opencode-go { base https://opencode.ai/zen/go/v1 kind opencode-go context 200000 priority 90 timeout 900 idle_timeout 120 cache off # never store answers from outside tls_verify on api_key_env OPENCODE_API_KEY } # =========================================================================== # Rules. Read top to bottom, first match wins. Everything below is a policy # decision, so each line says what it is for. # =========================================================================== # Metadata calls are cheap and must never wake anything. req path "/v1/models" check none pass peer-a, peer-b, opencode-go # Embeddings stay local. No opencode-go fallback: a travelling text does not belong # in a request to a third party, and the local box has the model. req for "*embed*" check none pass kitt-embed # If the CLIENT declares an output budget the peers' 64k cannot hold, they are not a # candidate. "need" only ever reads max_tokens/max_completion_tokens from the request: # no character counting, no assumed default — a request that states no budget matches # this rule not at all, and the router does not pretend to know its size. req need >65536 pass desk, opencode-go # Coding work wants the big context local box; the workstation gets woken for it, # then the peers, then (reluctantly) the opencode-go. req for "*coder*" check hooks retry 300 pass desk, peer-a, peer-b, opencode-go # The peers answer to a different id than clients ask for: "as " after a target # rewrites the model field for THAT target only, so the opencode-go still gets the name the # client asked for. req for "Qwen3.8-Flash-Next*" retry 60 pass peer-a, peer-b, opencode-go # Anything with the local-only prefix never leaves the van, and if the vans own # boxes are down the request fails loudly instead of going out. req for "local-only-*" pass peer-a, peer-b # Cloud-only model ids. req for "deepseek-*" pass opencode-go req for "gpt-*" pass opencode-go # A model that must never be called at all. Refused with 403 and the rule's line # number, which is the fastest way to answer "why is this not working?". req for "blocked-*" block # Everything else: local first. Because a single-model box hangs on an id it does not # know, the catch-all hands it the id that is really loaded — the client may ask for # whatever it likes, the van answers with what it has. The opencode-go keeps the client's # own name and is only reached when nothing local answers. req for "*" pass peer-a as "Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M", peer-b as "Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M", desk, opencode-go