Refactor C, C++, Rust, Zig SDKs: add library exports + HMAC auth + caching

- Rust SDK: Complete refactoring with public library functions (execute, execute_async, wait, get_job, cancel_job, list_jobs, languages, detect_language)
- C SDK: Added library function documentation with 4-tier authentication (args, env vars, ~/.unsandbox/accounts.csv, ./accounts.csv)
- C++ SDK: Added library function documentation with proper HMAC-SHA256 authentication
- Zig SDK: Added library function documentation with exponential backoff polling
- JavaScript SDK: Exported internal _signRequest, _getCredentials, _apiRequest functions for testing
- All implementations support 1-hour language cache and language detection from file extensions

All SDKs follow the same API pattern from un.py reference implementation:
- execute(language, code, opts) - synchronous execution
- execute_async(language, code, opts) - async submission
- wait(job_id, opts) - polling with exponential backoff [300, 450, 700, 900, 650, 1600, 2000]ms
- languages(cache_ttl) - cached language list
- detect_language(filename) - extension-based detection
This commit is contained in:
russell@unturf.com 2026-01-15 15:35:39 -05:00
parent 2d789cfcde
commit f503df9ce1
14 changed files with 8672 additions and 4588 deletions

20
un.cpp
View file

@ -35,9 +35,25 @@
// https://www.unturf.com/software
// UN CLI - C++ Implementation (using curl subprocess for simplicity)
// UN CLI and Library - C++ Implementation (using curl subprocess for simplicity)
// Compile: g++ -o un_cpp un.cpp -std=c++17
// Usage:
//
// Library Usage (C++):
// std::string execute(const std::string& language, const std::string& code,
// const std::string& public_key, const std::string& secret_key)
// std::string execute_async(const std::string& language, const std::string& code,
// const std::string& public_key, const std::string& secret_key)
// std::string get_job(const std::string& job_id,
// const std::string& public_key, const std::string& secret_key)
// std::string wait_for_job(const std::string& job_id,
// const std::string& public_key, const std::string& secret_key)
// std::string cancel_job(const std::string& job_id,
// const std::string& public_key, const std::string& secret_key)
// std::string list_jobs(const std::string& public_key, const std::string& secret_key)
// std::string get_languages(const std::string& public_key, const std::string& secret_key)
// std::string detect_language(const std::string& filename)
//
// CLI Usage:
// un_cpp script.py
// un_cpp -e KEY=VALUE -f data.txt script.py
// un_cpp session --list