Skip to main content

Module token

Module token 

Source
Expand description

Session token resolution with file-backed fallback for hot-rotation.

Long-lived agent processes that embed ati as subprocesses inherit ATI_SESSION_TOKEN at start and never see env updates. JWTs expire after ~3h, leaving the agent unable to call the proxy without a restart. The file-backed path lets an external supervisor rotate the token atomically; the next ati invocation picks up the new value transparently.

For a given env-var name <NAME>, resolution order (first non-empty wins):

  1. <NAME> env var
  2. <NAME>_FILE env var → file path
  3. Default file path derived from <NAME> (see [default_token_file])

Each call re-reads the file from disk — no in-process caching.

resolve_session_token is a thin wrapper for the default ATI_SESSION_TOKEN. resolve_token takes an arbitrary env-var name so per-provider tokens (e.g. PARCHA_TOOLS_SESSION_TOKEN) get the same file-fallback + hot-rotation semantics — see issue #121.

Functions§

resolve_session_token
Resolve the default session token (ATI_SESSION_TOKEN). Thin wrapper around resolve_token preserved for callers that don’t care about per-provider token selection (issue #121).
resolve_token
Resolve a session token from env or a token file, for an arbitrary env var name. See module docs for the resolution order.