Skip to content

API change + more usage - #1

Open
martinKupec wants to merge 6 commits into
ScriptSmith:mainfrom
martinKupec:main
Open

martinKupec wants to merge 6 commits into
ScriptSmith:mainfrom
martinKupec:main

Conversation

@martinKupec

Copy link
Copy Markdown

I have changed the API from web-based to OAuth based (Claude code message configurable).

What it gains:

  • No need to manually fill token. It reads token from ~/.claude/.credentials.json
  • It can also show other usages past the default two.

There is a problem with rate-limit on OAuth endpoints, if you hit the limit, you can change preferences to use responces from /v1/message API. This is how Claude Code shows usage.

There is no auto fallback, as the message API actually uses tokens (should be 1+1 token per request).

martinKupec and others added 6 commits May 12, 2026 13:52
Switches authentication from manual browser session cookie to the OAuth
token written by Claude Code CLI, so no credentials need to be entered
manually. Uses the Anthropic OAuth usage endpoint instead of the
claude.ai web API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pack.sh wraps gnome-extensions pack with the extra sources
  (credentials.js, claude-session-hook.py) to produce a distributable zip
- install.sh now copies claude-session-hook.py to the extension directory
  so hooks in ~/.claude/settings.json can point to the installed path
- README updated with installed hook path and packing instructions
- .gitignore excludes the generated .shell-extension.zip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dynamically inserts menu items for every non-null usage bucket returned
by the API (Sonnet, Opus, Claude Cowork, Claude Design, etc.) between
the weekly section and the last-updated line. Items are rebuilt on each
refresh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The /api/oauth/usage endpoint shares a tight per-token rate-limit bucket
that the extension routinely trips. Claude Code's own /usage falls back
to anthropic-ratelimit-unified-* response headers populated by regular
/v1/messages traffic, which is why it keeps working when /api/oauth/usage
is 429.

This adds a 'usage-source' setting to choose between the OAuth endpoint
and a 1-token /v1/messages probe that reads the same unified-ratelimit
headers. The probe path costs ~1-2 tokens per fetch but rarely hits
limits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Opening the state file with 'w' truncated it before fcntl took the lock, so
the extension's file monitor read zero bytes mid-write — 79% of reads in a
concurrent-write test — flooding the journal with JSON.parse "unexpected end
of data". Write a temp file and os.replace instead.

The monitor now also coalesces the event burst from one write into a single
read and keeps the last good state on a short read.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ScriptSmith

Copy link
Copy Markdown
Owner

Hi @martinKupec, sorry I missed this.

Have you had any further issues using this credential? I'd be worried about the rate limiting you mentioned + identifying the extension as being claude code. I could merge if that were made optional and rebased onto main. Otherwise I might cherry-pick your most recent bug fix commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants