Skip to content

feat(trae): daily credit check-in - #205

Closed
xingyicjj wants to merge 3 commits into
caigee-cmd:mainfrom
xingyicjj:feat/trae-auto-checkin
Closed

xingyicjj wants to merge 3 commits into
caigee-cmd:mainfrom
xingyicjj:feat/trae-auto-checkin

Conversation

@xingyicjj

Copy link
Copy Markdown
Contributor

Wires up the Trae CN daily credit check-in. The client already carried the two call sites but nothing ever called them.

What this adds

  • trae.Client.DailyCheckin / Keepalive drive the existing checkin_credits/status and checkin_credits/claim endpoints. CheckinStatus / CheckinClaim were already in the tree, unused. The status leg runs first, so a day already claimed is recorded as already instead of firing a second request.
  • accounts.Manager replaces its WorkBuddy-only ops field with a per-provider maintainer registry. SupportsCheckin now derives from that registry, so the HTTP layer and the maintenance loop stop hardcoding a provider name.
  • The console shows the check-in toggle, "check in now" and the history entry for any provider with registered check-in ops.
  • The existing workbuddy_auto_checkin / workbuddy_checkin_time columns are reused as the account-level opt-in and time. No new SQLite migration.

Two fixes that ride along

Device id shape. The UG check-in backend keys its per-device daily limit on X-Device-Id and answers a bare hex id with 9074 当前参与用户太多 (the message reads as a rate limit, but it is a device-identity rejection). Every account failed to check in while the Trae client, which sends aha-<hex>, succeeded from the same host and the same minute. SetUgHeaders now normalises the stored id to that shape, so existing credentials work without a re-login, and each account still maps to its own device.

Broken merge on main. c00d361 left internal/translate/compat.go with an unbalanced brace plus a duplicated block, tools.go without the closing brace of responseToolNames, and the namespace qualification in translateResponsesToolChoice unreachable after its case "function" returned early. main does not compile without the first commit here, so this branch carries that minimal repair (union of b415dd0 and 66b2ffb). Drop it if you have since fixed it another way.

Verification

  • go build ./..., go vet ./..., go test ./... pass.
  • Check-in verified against the live service with four Trae CN accounts: a bare hex device id returns 9074 on every claim, the same id prefixed with aha- returns {"code":0,"message":"success"} and the account flips to checked_in: true.
  • Console assets regenerated with cd frontend && npm run sync.

Merge c00d361 left compat.go with an unbalanced brace and a duplicated block, tools.go without the closing brace of responseToolNames, and the namespace qualification in translateResponsesToolChoice unreachable after the function case returned early. main does not compile without this.

Restore the union of b415dd0 and 66b2ffb: qualify the namespace inside the function case and keep the custom case on EncodeCustomToolName.
trae.Client gains DailyCheckin and Keepalive, plus AlreadyCheckedInError so a day already claimed is recorded as already instead of writing chat cooldown. The status leg runs first, the claim body is literal {} and the floating grant size is read back from the response rather than assumed.

accounts.Manager replaces its WorkBuddy-only ops field with a per-provider maintainer registry. SupportsCheckin derives from that registry, so the API layer and the maintenance loop stop hardcoding a provider name. The existing workbuddy_auto_checkin and workbuddy_checkin_time columns are reused as the account-level opt-in and time, so no new SQLite migration is needed.

Console shows the check-in toggle, the check-in-now action and the history button for every provider with registered check-in ops.
The UG checkin endpoint keys its per-device daily limit on X-Device-Id and answers a bare hex id with code 9074, whose message reads as a rate limit. Every account was therefore unable to check in while the Trae client, which sends aha-<hex>, succeeded.

Normalise the stored id in SetUgHeaders so existing credentials work without a re-login, and keep distinct ids distinct so each account still maps to its own device.
@xingyicjj

Copy link
Copy Markdown
Contributor Author

Closing: Trae CN check-in landed upstream in #200 (feat/provider-checkin), so the check-in half of this PR is duplicate work. The one thing upstream still lacks is the aha device-id shape the check-in backend requires - that is now #206, rebased onto current main and narrowed to that single change.

@xingyicjj xingyicjj closed this Sep 19, 2026
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.

1 participant