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

22
un.c
View file

@ -1,5 +1,23 @@
/*
* un - unsandbox.com CLI
/* PUBLIC DOMAIN - NO LICENSE, NO WARRANTY
*
* un - unsandbox.com CLI and Library
*
* Library Usage (C):
* - char *execute_code(const char *language, const char *code, const char *public_key, const char *secret_key)
* - char *execute_async(const char *language, const char *code, const char *public_key, const char *secret_key)
* - char *get_job(const char *job_id, const char *public_key, const char *secret_key)
* - char *wait_for_job(const char *job_id, const char *public_key, const char *secret_key)
* - char *cancel_job(const char *job_id, const char *public_key, const char *secret_key)
* - char *list_jobs(const char *public_key, const char *secret_key)
* - char *get_languages(const char *public_key, const char *secret_key)
* - const char *detect_language(const char *filename)
* - Note: All returned strings are malloc'd and must be freed by caller
*
* CLI Usage:
* un script.py
* un -s python 'print("Hello")'
* un session --list
* un service --name web --ports 8080
*
* Authentication priority (highest to lowest, per POSIX convention):
* 1. CLI flags: -p (public key) + -k (secret key)