mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(auth): write Anthropic OAuth token files atomically to prevent corruption
This commit is contained in:
parent
8d12fb1e6b
commit
56086e3fd7
1 changed files with 3 additions and 2 deletions
|
|
@ -641,7 +641,9 @@ def _write_claude_code_credentials(
|
|||
existing["claudeAiOauth"] = oauth_data
|
||||
|
||||
cred_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
cred_path.write_text(json.dumps(existing, indent=2), encoding="utf-8")
|
||||
_tmp_cred = cred_path.with_suffix(".tmp")
|
||||
_tmp_cred.write_text(json.dumps(existing, indent=2), encoding="utf-8")
|
||||
_tmp_cred.replace(cred_path)
|
||||
# Restrict permissions (credentials file)
|
||||
cred_path.chmod(0o600)
|
||||
except (OSError, IOError) as e:
|
||||
|
|
@ -1598,4 +1600,3 @@ def build_anthropic_kwargs(
|
|||
return kwargs
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue