mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
- Add github-copilot as LLM provider flavor in schema - Implement GitHub Copilot API integration using OpenAI-compatible endpoint - Add OAuth Device Flow implementation (RFC 8628) for GitHub authentication - Configure GitHub OAuth endpoints and client ID - Add comprehensive documentation for GitHub Copilot integration This allows users to authenticate with GitHub and use GitHub Copilot models (GPT-4o, GPT-4, etc.) directly in Rowboat using device code flow authentication.
4.3 KiB
4.3 KiB
GitHub Copilot Integration for Rowboat
Esta implementación agrega soporte completo para GitHub Copilot en Rowboat usando Device Flow OAuth (RFC 8628).
¿Qué se implementó?
1. Schema de Proveedores (apps/x/packages/shared/src/models.ts)
- Agregado
"github-copilot"como flavor de proveedor LLM
2. Provider LLM (apps/x/packages/core/src/models/models.ts)
- Implementado case para
github-copilotque usa la API compatible con OpenAI de GitHub Models - Base URL:
https://models.github.com/api/openai/
3. Configuración OAuth (apps/x/packages/core/src/auth/providers.ts)
- Agregado proveedor
github-copilotcon:- Authorization endpoint:
https://github.com/login/oauth/authorize - Token endpoint:
https://github.com/login/oauth/access_token - Client ID:
Iv1.b507a08c87ecfe98(GitHub Copilot CLI Client ID oficial) - Scopes:
read:user,user:email,gist
- Authorization endpoint:
4. Device Flow Implementation (apps/x/packages/core/src/auth/github-copilot-device-flow.ts)
Nuevo archivo que implementa RFC 8628:
requestDeviceCode()- Solicita un device code a GitHubpollForToken()- Sondea GitHub para obtener el tokenstartGitHubCopilotAuth()- Flujo completo de autenticación
Cómo usar
1. Instalación
cd apps/x
pnpm install
npm run deps
2. Configuración Manual (archivo JSON)
Edita ~/.rowboat/config/models.json:
{
"provider": {
"flavor": "github-copilot",
"apiKey": null
},
"model": "gpt-4o"
}
3. Autenticación con Device Flow
Cuando Rowboat se inicia con GitHub Copilot configurado:
- Se solicita un device code a GitHub
- Se muestra un código de usuario (ej:
ABCD-1234) - Se abre
https://github.com/login/device - Usuario ingresa el código
- Rowboat automáticamente sondea y obtiene el token
┌ GitHub Copilot Authentication
│
│ Visit: https://github.com/login/device
│ Enter code: ABCD-1234
│
│ Waiting for authorization...
└
4. Modelos disponibles
GitHub Copilot soporta estos modelos:
gpt-4o- GPT-4 Omni (más capaz, más caro)gpt-4-turbo- GPT-4 Turbogpt-3.5-turbo- GPT-3.5 Turbo (rápido, económico)claude-opus- Claude Opus (si está disponible)
Flujo técnico
┌─────────────────────────────────────────────────────────┐
│ Rowboat Application │
└─────────┬───────────────────────────────────────────────┘
│
├─► requestDeviceCode()
│ └─► POST /login/device/code
│ └─ client_id, scope
│
├─► Display: Visit https://github.com/login/device
│ Enter code: ABCD-1234
│
├─► pollForToken()
│ └─► POST /login/oauth/access_token (loop)
│ └─ device_code, client_id, grant_type
│
└─► createProvider() con apiKey = access_token
└─► POST https://models.github.com/api/openai/v1/chat/completions
└─ Bearer token auth
Manejo de errores
El código maneja varios estados de error de GitHub:
| Error | Acción |
|---|---|
authorization_pending |
Continúa sondeando |
slow_down |
Aumenta intervalo de sondeo |
expired_token |
Falla con mensaje claro |
access_denied |
Usuario rechazó |
Próximos pasos
Para completar la integración:
- UI de autenticación - Integrar en el onboarding step de Rowboat
- Almacenamiento de tokens - Guardar en
~/.rowboat/config/auth.json - Renovación de tokens - Implementar refresh token si GitHub lo soporta
- Selección de modelos - Descubrir modelos disponibles automáticamente
- Tests - Agregar tests unitarios para device flow
Referencia
- RFC 8628: Device Authorization Grant - https://tools.ietf.org/html/rfc8628
- GitHub Device Flow Docs - https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow
- GitHub Models API - https://docs.github.com/en/github/copilot/github-copilot-in-the-cli/about-github-copilot-in-the-cli