Skip to content

feat(services): thread Account through API helpers (Task #3)#19

Open
lubobill1990 wants to merge 2 commits into
feat/02-multi-account-skeletonfrom
feat/03-service-token-threading
Open

feat(services): thread Account through API helpers (Task #3)#19
lubobill1990 wants to merge 2 commits into
feat/02-multi-account-skeletonfrom
feat/03-service-token-threading

Conversation

@lubobill1990
Copy link
Copy Markdown
Collaborator

Summary

  • ApiContext (Account + VSCode version) flows through every upstream helper
  • handlers acquire/release from state.pool per request (real load balancing in Task [Task 04] Handler withAccount wrapper #4)
  • legacy state.copilotToken / state.githubToken removed

Test plan

  • 57 tests pass
  • typecheck clean

Refs #3

🤖 Generated with Claude Code

lubobill1990 and others added 2 commits April 25, 2026 14:21
All upstream-calling helpers now take an ApiContext (Account + VSCode
version) instead of reading from the global state. Handlers acquire an
account from the pool inline (real load-balancing comes in Task #4).

- src/lib/api-config.ts: copilotBaseUrl/copilotHeaders/githubHeaders take ApiContext
- src/services/{copilot,github}/*.ts: all signatures accept ctx as first arg
- src/lib/state.ts: drop legacy githubToken/copilotToken fields
- src/lib/token.ts: setupCopilotTokenFor uses makeApiContext; setupGitHubToken returns the token instead of mutating state
- src/lib/utils.ts: makeApiContext / defaultApiContext helpers; cacheModels uses pool's first account
- src/routes/{chat-completions,messages,embeddings}/*.ts: pool.acquire/release around upstream call
- src/routes/usage,token/route.ts: use defaultApiContext / defaultAccount
- src/check-usage.ts: build a temporary ApiContext from the loaded GitHub token

Refs #3

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
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