TRILHA 6

🌐 Connectivity

Domine o bridge remoto, autenticacao OAuth, integracao Git, upstream proxy, cron scheduling e o sistema de voz do Claude Code.

6
Modulos
~36
Topicos
~5h
Duracao
Avancado
Nivel

Navegacao Rapida

6.1 ~60 min

Bridge & Remote

Como o Claude Code conecta o REPL local ao claude.ai via bridge bidirecional, com duas arquiteturas (v1 env-based e v2 env-less) e transport layer assimetrico.

1
🌉 Bridge v1 vs v2 Architecture
Env-based polling vs env-less direct OAuth
2
📡 Transport Layer: WebSocket, SSE & Hybrid
ReplBridgeTransport interface e backpressure
3
🔒 Permission Bridge Protocol
control_request/response e synthetic messages
4
⚙️ /remote-control Command & Entitlements
BridgeToggle, 5 pre-flight checks, CCR mirror
5
☁️ CCR Integration & SDK Adapter
SessionsWebSocket, SDKMessage conversion
6
🖥️ Standalone Bridge Server Mode
runBridgeLoop, multi-session pool, token refresh
Ver Completo
6.2 ~50 min

OAuth Authentication

OAuth 2.0 Authorization Code com PKCE, auto vs manual flow racing, token storage em keychain, refresh com scope expansion e logout seguro.

1
🔐 PKCE Primitives & Sequence
Code verifier, S256 challenge, state CSRF
2
🏁 Auto vs Manual Flow Racing
Dual flow, localhost callback, paste fallback
3
💾 Token Storage & Keychain Architecture
macOS keychain hex encoding, stale-while-error
4
🔄 Token Refresh & Profile Skip
5-min buffer, scope expansion, 7M req/day saving
5
🚪 Logout & Scopes
performLogout() teardown, 6 OAuth scopes
6
🏢 Enterprise & FedStart Configuration
Custom OAuth URLs, strict allowlist enforcement
Ver Completo
6.3 ~50 min

Git Integration

Leitura zero-subprocess do estado Git via filesystem direto, config parser, GitFileWatcher com cache dirty-bit, e operation tracking via regex.

1
📁 Zero-Subprocess Design Philosophy
5 source files, direct .git/ filesystem reads
2
📝 Git Config Parser & HEAD Reading
INI format, case rules, ref resolution
3
👀 GitFileWatcher: Dirty-Bit Cache
fs.watchFile, lazy recompute, branch switch
4
🛡️ Security: Ref Validation
isSafeRefName, isValidGitSha, injection defense
5
🔍 Operation Tracking & PR Auto-Linking
Regex parsing, gh/glab/curl detection
6
🔐 GitHub Auth & Global Gitignore
gh auth token offline check, ~/.config/git/ignore
Ver Completo
6.4 ~45 min

Upstream Proxy

HTTPS CONNECT proxy MITM-capable via WebSocket tunnel em containers CCR, com protobuf hand-rolled, prctl anti-ptrace e dual authentication.

1
🏗️ Initialization Sequence
6 steps, fails-open design, token lifecycle
2
🔀 CONNECT-over-WebSocket Relay
Two-phase state machine, TCP coalescing race
3
📦 Hand-Rolled Protobuf Encoding
Tag 0x0a, varint length, zero-length keepalive
4
🛡️ Security Model & Dual Auth
prctl anti-ptrace, WS auth vs CONNECT auth
5
🔧 Bun vs Node Runtime & Backpressure
writeBuf drain queue, WebSocket proxy agent
6
🌐 Environment Variable Propagation
8 env vars, NO_PROXY triple format, HTTPS only
Ver Completo
6.5 ~50 min

Cron & Scheduling

Scheduler cron built-in com JSON file storage, distributed lock, jitter deterministico por task ID e integracao React via hook.

1
📋 CronTask Data Model
Durable vs session-only, recurring vs one-shot
2
⏱️ Scheduler Lifecycle & Check Loop
1s tick, lazy enable, chokidar watcher
3
🔒 Multi-Session Distributed Lock
PID-based liveness probe, session task exemption
4
🎯 Deterministic Jitter System
Forward vs backward jitter, fleet load spreading
5
🛠️ CronCreate/Delete/List Tools
50-job cap, off-minute heuristic, teammate scoping
6
🔄 REPL Wiring & Missed Tasks
useScheduledTasks hook, startup catch-up, injection defense
Ver Completo
6.6 ~45 min

Voice System

Pipeline push-to-talk com WebSocket STT, multi-backend audio capture (NAPI/arecord/SoX), hold threshold, silent-drop replay e focus mode.

1
🎤 Feature Gating & Audio Backends
Double gate (GrowthBook + OAuth), NAPI/arecord/SoX chain
2
📶 WebSocket STT Protocol
voice_stream endpoint, finalize() 4 triggers
3
🤚 Hold-to-Talk Mechanics
5-press threshold, stripTrailing(), release detection
4
🔄 Session State Machine & Silent-Drop Replay
idle/recording/processing, 1% bug workaround
5
🎯 Focus Mode & Language/Keyterms
Terminal focus trigger, 5s silence timeout, STT boosting
6
📊 Audio Visualization & React Context
RMS computation, sqrt curve, Store-based state
Ver Completo