Vault config
vault_config
¶
Patches provider config files to route API traffic through the vault.
Applies shared_config_patch from the YAML roster after authentication
and — crucially — on every task start. Writes vault URLs / socket paths
(not secrets) to provider config files so agents route traffic through the
vault instead of hitting upstream directly with phantom tokens.
Two template tokens are substituted into patch values:
{vault_url}— HTTP URL the container should reach the vault on.{vault_socket}— filesystem path of a Unix socket the container can connect to for the vault.
The concrete values are mode-dependent (socket vs TCP transport) and resolved centrally — agent YAMLs only need to reference the tokens.
ConfigPatchError
¶
Bases: RuntimeError
Raised when a shared config patch fails and the task must not start.
VaultLocation(url, socket)
dataclass
¶
Container-side addresses of the vault in both transports.
One or both fields are set depending on the active transport:
- Socket mode: socket points at the mounted host socket; url points at the in-container TCP→UNIX loopback bridge for HTTP-only clients.
- TCP mode: url points at
host.containers.internal:<broker_port>; socket points at a local socat bridge that forwards to the same broker over TCP (for clients that can only speak HTTP-over-UNIX).
write_vault_config(name, credential_set='default')
¶
Apply an entry's provider.config_patch from the YAML roster after auth.
Patches a TOML or YAML config file in the entry's shared config dir to
redirect API traffic through the vault. name is the auth-provider name
(agent OR tool — e.g. gh); the patch rides on the entry's vault route
(sourced from its provider: binding). No provider-specific code needed.
credential_set selects which stored credential's type drives a
by_credential_type overlay (codex's ChatGPT-backend vs /v1 routing).
Source code in src/terok_executor/credentials/vault_config.py
apply_shared_config_patches(roster, mounts_base, *, providers=None, disabled_providers=None, credential_set='default')
¶
Reconcile shared_config_patch for enabled and disabled providers.
Called during task start so shared mount directories (which may have been recreated empty) always contain the correct vault addresses. Idempotent: safe to call on every launch. Disabled providers have previously managed values removed only when the live config still matches the sidecar value terok wrote last time; user-edited values are preserved and ownership is dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roster
|
AgentRoster
|
Loaded agent roster. |
required |
mounts_base
|
Path
|
Shared config mount root. |
required |
providers
|
frozenset[str] | None
|
|
None
|
disabled_providers
|
frozenset[str] | None
|
Provider subset whose previously managed patch values should
be reconciled away. |
None
|
Raises ConfigPatchError on failure — callers must not start
the container if vault routing cannot be established.
Source code in src/terok_executor/credentials/vault_config.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
resolve_vault_location(token_broker_port=None)
¶
Return the in-container vault address.
URL is always the loopback bridge on
LOOPBACK_VAULT_PORT
— the bridge runs in both transports and forwards to the
transport-specific target (host unix socket or per-container host
TCP port). token_broker_port picks the socket-facade shape for
socket-only clients: /run/terok/vault.sock in socket mode (the
bind-mounted host socket), /tmp/terok-vault.sock in TCP mode
(in-container socat unix→host-TCP).