Implementa Fases 1+2 do plano Captain Codex OAuth.
Fase 1 — Auth módulo:
- Migration captain_codex_credentials (tokens AR-encrypted)
- Model Captain::CodexCredential (singleton-ish com .current)
- Captain::Codex::AuthService com device flow completo:
start_device_login, poll_once, exchange_for_credential,
valid_access_token (auto-refresh), refresh!
- Rake task captain:codex:{login,status,refresh}
- Sidekiq job Captain::Codex::RefreshTokensJob rodando a cada 30min
Fase 2 — Proxy Chat Completions → Responses:
- Captain::Codex::Translator (chat ↔ responses, tools, tool_calls)
- Captain::Codex::Client (streaming SSE → agregado)
- Api::Internal::CodexProxyController expondo
POST /codex/v1/chat/completions
- 10 specs do Translator passando
Próximo: Fase 3 (feature flag + fallback) e reconfiguração dos
clientes RubyLLM/Agents/ruby-openai pra apontarem pro proxy quando
CAPTAIN_LLM_PROVIDER=openai_codex_oauth.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19 lines
576 B
Ruby
19 lines
576 B
Ruby
class CreateCaptainCodexCredentials < ActiveRecord::Migration[7.1]
|
|
def change
|
|
create_table :captain_codex_credentials do |t|
|
|
t.text :access_token, null: false
|
|
t.text :refresh_token, null: false
|
|
t.datetime :expires_at, null: false
|
|
t.datetime :last_refresh_at
|
|
t.string :chatgpt_account_id
|
|
t.string :chatgpt_plan_type
|
|
t.string :email
|
|
t.string :status, null: false, default: 'active'
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :captain_codex_credentials, :status
|
|
add_index :captain_codex_credentials, :expires_at
|
|
end
|
|
end
|