Extractors
extractors
¶
Extracts vendor-specific credentials from auth container mounts.
Each extractor reads a vendor-specific credential file from a temporary
auth container mount and returns a normalized dict suitable for storage
in CredentialDB. The dict must contain at least
one of access_token, token, or key --- the vault server
uses these fields to inject the real auth header.
All file shapes live in
vendor_files as Pydantic
models. Vendors own those formats, so the models are deliberately lax
(extra="ignore"); only the fields we depend on are typed-checked.
EXTRACTORS = {'claude': (extract_claude_oauth,), 'codex': (extract_codex_oauth,), 'vibe': (extract_api_key_env, '.env', 'MISTRAL_API_KEY'), 'gh': (extract_gh_token,), 'glab': (extract_glab_token,), 'blablador': (extract_json_api_key, 'config.json'), 'kisski': (extract_json_api_key, 'config.json')}
module-attribute
¶
Maps provider name → (extractor_fn, *extra_args).
extract_claude_oauth(base_dir)
¶
Extract Claude credentials --- OAuth tokens or API key.
Claude stores OAuth state in .credentials.json under
claudeAiOauth. If that block is missing or token-less (for
example, because the user authenticated with an API key only), we
fall back to config.json's api_key field.
Source code in src/terok_executor/credentials/extractors.py
extract_codex_oauth(base_dir)
¶
Extract Codex (OpenAI) OAuth tokens from auth.json.
Also preserves the source id_token JWT and account_id when
present — the shared synthetic auth.json writer derives a safe
claim-only JWT from it so Codex's plan-tier and workspace UI keeps
working without leaking the real OAuth tokens.
Source code in src/terok_executor/credentials/extractors.py
extract_api_key_env(base_dir, filename='.env', var_name='')
¶
Extract an API key from a dotenv-style file (e.g. Vibe's .env).
Looks for VAR_NAME=value lines. If var_name is empty, takes
the first non-comment, non-empty value. Dotenv is line-oriented and
not JSON — a Pydantic model adds no value here, so the parse stays
inline.
Source code in src/terok_executor/credentials/extractors.py
extract_json_api_key(base_dir, filename='config.json')
¶
Extract an API key from a JSON config file (blablador, kisski).
Expects {"api_key": "..."} at the top level.
Source code in src/terok_executor/credentials/extractors.py
extract_gh_token(base_dir)
¶
Extract GitHub token from hosts.yml.
Tokens are stored per host under <host>.oauth_token; we prefer
github.com and fall back to any other host present.
Source code in src/terok_executor/credentials/extractors.py
extract_glab_token(base_dir)
¶
Extract GitLab token from config.yml.
Tokens live under hosts.<host>.token; the first non-empty entry wins.
Source code in src/terok_executor/credentials/extractors.py
extract_credential(provider, base_dir)
¶
Run the appropriate extractor for provider against base_dir.
Raises ValueError if no extractor is registered or extraction fails.