Skip to content

refactor(cloud-agent-next): migrate to git-token-service RPC#1158

Draft
eshurakov wants to merge 8 commits intomainfrom
eshurakov/cloud-agent-git-token-service
Draft

refactor(cloud-agent-next): migrate to git-token-service RPC#1158
eshurakov wants to merge 8 commits intomainfrom
eshurakov/cloud-agent-git-token-service

Conversation

@eshurakov
Copy link
Contributor

@eshurakov eshurakov commented Mar 17, 2026

Summary

Migrates cloud-agent-next from local GitHub token generation (Hyperdrive DB lookup + @octokit/auth-app + KV caching) to the centralized git-token-service worker via Cloudflare service binding RPC.

  • Replaced session-prepare GitHub flow: The two-step lookup-then-generate pattern (InstallationLookupServiceGitHubTokenService) is replaced by a single GIT_TOKEN_SERVICE.getTokenForRepo() RPC call that returns a ready-to-use token.
  • Added GitLab auto-token-lookup: When platform === 'gitlab' and no client token is provided, calls GIT_TOKEN_SERVICE.getGitLabToken() to automatically resolve a token. Stores a gitlabTokenManaged flag in DO state so the token is refreshed on session resume.
  • Token refresh on resume: Both initiatePrepared and follow-up execution paths now call the git-token-service for fresh tokens instead of using the local GitHubTokenService.
  • Removed local token infrastructure: Deleted github-token-service.ts and installation-lookup-service.ts. Removed @octokit/auth-app and @kilocode/db dependencies. Removed HYPERDRIVE, GITHUB_TOKEN_CACHE KV, and GitHub App secret env vars from wrangler.jsonc and Env type.
  • Added GIT_TOKEN_SERVICE service binding in wrangler.jsonc (prod → git-token-service, dev → git-token-service-dev).

Verification

  • pnpm typecheck — passed (all 28 workspace projects)
  • pnpm lint — passed
  • pnpm test — 2632 passed, 6 skipped, 166 suites
  • Manual testing (user)

Visual Changes

N/A

Reviewer Notes

  • Clean break: Hyperdrive, KV cache, and GitHub App secret env vars are removed entirely — no fallback path. The git-token-service worker owns all token generation.
  • Commit attribution vars (GITHUB_APP_SLUG, GITHUB_APP_BOT_USER_ID, and _LITE_ variants) are retained — they're used for git commit email/author, not token generation.
  • gitlabTokenManaged flag is stored in DO state to distinguish auto-resolved GitLab tokens (which need refresh) from client-provided tokens (which don't).
  • The worker-configuration.d.ts diff includes Cloudflare runtime type updates (e.g., HostedImagesBinding, aiSearch()) from running pnpm run types — these are generated and unrelated to this change.

@eshurakov eshurakov changed the title feat(git-token-service): add GitLab token support with OAuth refresh refactor(cloud-agent-next): migrate to git-token-service RPC Mar 17, 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