Principle:777genius Agent teams ai CLI Runtime Detection
| Knowledge Sources | |
|---|---|
| Domains | Runtime_Detection, Provider_Management |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Pattern for detecting, installing, and authenticating multiple CLI runtimes (Claude, Codex, OpenCode) from a desktop application with status aggregation and diagnostic logging.
Description
CLI Runtime Detection is the process of discovering whether CLI binaries are installed on the system, whether they are authenticated, and what capabilities they support. The detection runs periodically and on-demand, with a timeout-bounded status gathering phase and a diagnostic NDJSON log for troubleshooting "not logged in" issues in packaged builds.
Key challenges:
- Multi-provider status: Each provider (Claude, Codex, OpenCode) has independent installation and authentication states that must be gathered concurrently.
- Timeout safety: Status gathering can hang on slow disk or network; an overall timeout returns partial results rather than blocking indefinitely.
- Authority projection: Raw status is projected through `projectProviderAuthority()` to derive authoritative team-launch capability based on authentication, capabilities, and catalog freshness.
- Diagnostic logging: Each `getStatus()` call appends one NDJSON line to a diagnostic file (capped at 512 KiB) for troubleshooting packaged-build login issues.
- IPC deduplication: Rapid UI polls are deduplicated with a 5-second TTL to avoid redundant status gathering.
Usage
Use this principle when designing a system that must detect and manage multiple external CLI tools from a desktop application, especially when tool states change asynchronously and the UI needs periodic refresh.
Theoretical Basis
The detection follows a timeout-bounded concurrent gather with authority projection pattern:
# Abstract algorithm (NOT real implementation)
async def get_status(options):
result = create_initial_status()
generation = next_generation()
try:
await race(
gather_status(result, generation, options.mode),
timeout(GET_STATUS_TIMEOUT_MS)
)
return project_authority(result, now())
finally:
schedule_diag_write(result, timing_info)
Related Pages
Implemented By
- Implementation:777genius_Agent_teams_ai_CliInstallerService_getStatus
- Implementation:777genius_Agent_teams_ai_projectProviderAuthority