Files
jobboard/desk/tools/credentials.py
T
WolfandClaude Opus 5.5 248ea1636d Bring in desk from news
The plugin contract, the model task and the tools roledesk imports, copied
rather than reached through an editable install of news, which also exposes
a package named pipeline. news stays the source of truth for desk.

Refreshed from news/desk at a275c38a1aa0fe80a7ec7dd5781ecccf683f71c6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:29:17 +02:00

33 lines
1.2 KiB
Python

"""Local credential settings. Read per call so running workers see replacements."""
import os
import sqlite3
from contextlib import closing
from desk.config import AgentConfig
def saved_token(settings: AgentConfig) -> str:
if not settings.credentials_database:
return ""
with closing(sqlite3.connect(settings.credentials_database)) as conn:
if not conn.execute(
"SELECT 1 FROM sqlite_master WHERE type='table' AND name='credentials'"
).fetchone():
return ""
row = conn.execute("SELECT value FROM credentials WHERE name='claude_oauth'").fetchone()
return row[0] if row else ""
def token(settings: AgentConfig) -> str:
return saved_token(settings) or os.environ.get("CLAUDE_CODE_OAUTH_TOKEN", "")
def save_token(settings: AgentConfig, value: str) -> None:
with closing(sqlite3.connect(settings.credentials_database)) as conn, conn:
conn.execute("CREATE TABLE IF NOT EXISTS credentials (name TEXT PRIMARY KEY, value TEXT NOT NULL)")
if value:
conn.execute("INSERT OR REPLACE INTO credentials VALUES ('claude_oauth', ?)", (value,))
else:
conn.execute("DELETE FROM credentials WHERE name='claude_oauth'")