Files
junction/examples/olivia.conf
T
Hermes Agent 87e6348642 junction: per-target 'as', example config for the van, C WoL helper
- A rule may send a different model name per target: 'pass peer-a as M, peer-b, cloud'
  rewrites only for peer-a, so a mixed local/cloud rule still asks the cloud for the
  name the client wanted.
- examples/olivia.conf: peers on the tunnel, embedding box, sleeping workstation with
  WoL + energy gate, cloud fallback, and the policy rules each with its reason.
- tools/junction-wol.c replaces the Python magic-packet helper; hooks stay shell.
- Forwarding no longer duplicates Host/Content-Length/X-Forwarded-*: Ollama answered
  400 to a request that was valid because it arrived with two Host headers.
- need_tokens: embeddings produce a vector, not tokens, so they are not charged
  default_max_tokens (a 2048-context embed endpoint refused every request).
- /status lists every target with its model, plus the rule's need window.
2026-10-29 14:13:46 +00:00

157 lines
6.1 KiB
Plaintext

# ============================================================================
# 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
chars_per_token 4 # rough, only used to pick an endpoint
default_max_tokens 4096 # assumed when the request does not say
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
# 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 peers on the workstation, over the WireGuard tunnel. They serve the big
# local model when its kanban is idle, so "reachable" is not the same as "free":
# check-http.sh asks /v1/models, and hook_retry gives them a moment to finish.
# ---------------------------------------------------------------------------
endpoint peer-a {
base http://172.25.206.3:8081/v1
kind local
context 64000
priority 10
timeout 1800 # long jobs are fine: 30 minutes of wall clock
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 64000
priority 20
timeout 1800
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 is run once, and the request waits up to four minutes for it to come
# back. WoL is layer 2: junction-wol sends to a broadcast address, so this works
# on the segment n95 sits on, not across the tunnel.
# ---------------------------------------------------------------------------
endpoint desk {
base http://192.168.1.99:8080/v1
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 cloud. 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 cloud {
base https://opencode.ai/zen/go/v1
kind cloud
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, cloud
# Embeddings stay local. No cloud 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
# Nothing needs more than the peers' 64k? Then the peers are not a candidate at
# all — pick the only boxes that can hold the request.
req need >64000 pass desk, cloud
# Coding work wants the big context local box; the workstation gets woken for it,
# then the peers, then (reluctantly) the cloud.
req for "*coder*" check hooks retry 300 pass desk, peer-a, peer-b, cloud
# The peers answer to a different id than clients ask for: "as <model>" after a target
# rewrites the model field for THAT target only, so the cloud still gets the name the
# client asked for.
req for "Qwen3.8-Flash-Next*" retry 60 pass peer-a as "qwen3.8-flash-next-q1m", peer-b as "qwen3.8-flash-next-q1m", cloud
# 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 cloud
req for "gpt-*" pass cloud
# 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, cloud only when nothing local answers.
req for "*" pass peer-a, peer-b, desk, cloud