Commit graph

122 commits

Author SHA1 Message Date
b1b2c14d86 Add --account N flag and fix credential priority in C#, dotnet, Swift
All three implementations had a defect where UNSANDBOX_PUBLIC_KEY/
UNSANDBOX_SECRET_KEY env vars were checked before --account N, making
it impossible to select a specific accounts.csv row when env vars exist.

Correct priority order now enforced:
  1. Explicit -p/-k flags
  2. --account N  ->  accounts.csv row N (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. ~/.unsandbox/accounts.csv row 0 (or UNSANDBOX_ACCOUNT env var)
  5. ./accounts.csv row 0

Changes per file:
- clients/csharp/sync/src/Un.cs: add LoadAccountsCSV(), rewrite
  GetApiKeys() with correct tier ordering, add Account=-1 to Args,
  parse --account N, update all GetApiKeys call sites
- clients/dotnet/sync/src/Un.cs: same as above (top-level stmt style)
- clients/swift/sync/src/un.swift: reorder resolveCredentials() tiers,
  add accountIndex to CLIArgs, parse --account N, pass to entry point

Also create un.swift symlink at repo root (parallel to Un.cs symlink).
2026-03-23 16:02:50 -04:00
7dd16bf796 Add --account N flag and full credential resolution to AWK, COBOL, Forth, Prolog
All four implementations now support:
- --account N flag: bypasses env vars, loads credentials from accounts.csv row N
- UNSANDBOX_ACCOUNT env var: selects default CSV row (fallback to row 0)
- accounts.csv fallback: tries ~/.unsandbox/accounts.csv then ./accounts.csv
- Correct priority: explicit flags > --account N > env vars > CSV row 0

AWK: Added load_accounts_csv() with native getline, GLOBAL_ACCOUNT_INDEX
variable, pre-scan loop in END block for --account/-p/-k global flags.

COBOL: Added GET-CREDENTIALS paragraph with shell-based CSV resolution,
WS-ACCOUNT-INDEX variable, --account N parsing at start of MAIN-PROCEDURE,
all HANDLE-* paragraphs now PERFORM GET-CREDENTIALS instead of inline
credential fetching.

Forth: Added account-index variable, load-accounts-csv-index word, sarg
shifted-arg accessor, arg-shift variable, --account N detection in main.
All handler N arg calls replaced with N sarg to support the shift.

Prolog: Added load_accounts_csv/3 predicate with file I/O, nb_setval/nb_getval
for account_index global, --account N pattern matching in main/1,
get_public_key/1 and get_secret_key/1 now check account_index before env vars.
2026-03-23 15:22:35 -04:00
422985c6db Fix --account N flag and credential priority in R, Raku, Julia, Groovy SDKs
All four implementations had the wrong credential priority order: env vars
were checked before accounts.csv even when an explicit --account N index
was provided.

Correct priority order implemented in all four:
1. Explicit -p/-k flags (function arguments)
2. --account N => accounts.csv row N (bypasses env vars)
3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
4. ~/.unsandbox/accounts.csv row 0 (or UNSANDBOX_ACCOUNT env)
5. ./accounts.csv row 0

Changes per file:
- un.r: rewrote get_credentials() with correct priority, added account_index
  param, added --account N to parse_args(), replaced get_api_keys() calls in
  all cmd_* functions with get_credentials(account_index=args$account_index)
- un.raku: rewrote get-credentials() with correct priority, pre-parse
  --account N in MAIN before dispatch, added Int :$account-index param to
  all cmd-* functions and thread account-index through get-credentials calls
- un.jl: added load_accounts_csv() and get_credentials() functions with full
  5-tier priority, added --account to all ArgParse subcommand tables, wired
  account_index through all cmd function get_api_keys calls
- un.groovy: rewrote getCredentials() and getCredentialsStatic() with correct
  priority (added loadAccountsFromCsv/loadCsvAccounts helpers), rewrote
  getApiKeys() to delegate to getCredentials(), added accountIndex field to
  Args class, added --account N to parseArgs(), wired accountIndex through
  all cmdXxx function calls
2026-03-23 15:17:19 -04:00
5373da4108 Add --account N flag and fix credential resolution priority in un.m, un.f90, un.zig, un.nim
Implements correct 5-tier credential priority in all four implementations:
  1. Explicit -p/-k flags
  2. --account N -> accounts.csv row N (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. ~/.unsandbox/accounts.csv row 0 (or UNSANDBOX_ACCOUNT env var)
  5. ./accounts.csv row 0

un.m (Objective-C): adds UNLoadCredentialsFromCSV helper, updates UNGetCredentials
  to use g_accountIndex global, parses --account N in main() pre-scan.

un.f90 (Fortran): adds load_csv_row subroutine, updates get_credentials with
  optional account_index parameter, parses --account N in main program pre-scan,
  passes account_index via host association to all handle_* subroutines.

un.zig (Zig): adds loadCsvRow and resolveCredentials functions, parses --account N
  in main() pre-scan, updates execute-mode arg loop to skip known flags.

un.nim (Nim): adds loadCredentialsFromCsv and resolveCredentials procs, parses
  --account N in main() pre-scan, updates execute-mode loop to skip --account.
2026-03-23 15:15:19 -04:00
13f15c8abc Add --account N flag and fix credential priority in Erlang, Elixir, OCaml, F#, Haskell SDKs
Correct 5-tier credential priority across all five implementations:
  1. Explicit -p/-k flags (function arguments)
  2. --account N -> accounts.csv row N (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. ~/.unsandbox/accounts.csv row 0 (or UNSANDBOX_ACCOUNT env)
  5. ./accounts.csv row 0

Erlang: add load_credentials_from_csv/2, extract_account_arg/3,
  process-dict-based account_index, dispatch/1 helper, fix get_api_keys/0.

Elixir: add load_credentials_from_csv/2, extract_account_arg/3,
  Process.put/get-based account_index, dispatch/1 helper, fix get_api_keys/0.

OCaml: add cli_account_index ref, parse_accounts_csv, load_csv_at,
  strip_account_arg, fix get_credentials priority ordering.

F#: add AccountIndex field to Args, loadCredentialsFromCsv, fix getApiKeys
  signature to accept accountIndex, wire --account N in parseArgs.

Haskell: add cliAccountIndex IORef (unsafePerformIO), loadCredentialsFromCsv,
  stripAccountArg, fix getApiKeys priority ordering.
2026-03-23 15:14:36 -04:00
a839ffcd12 Add --account N flag and CSV credential resolution to C++, D, V, and Kotlin SDKs
Each implementation gains:
- loadAccountsCSV / load_accounts_csv: reads public_key,secret_key rows from
  a CSV file, skipping # comments and blank lines
- Full 5-tier credential resolution:
  1. Explicit -p flag (public key override)
  2. --account N → ~/.unsandbox/accounts.csv row N (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. UNSANDBOX_ACCOUNT env var selects row from ~/.unsandbox/accounts.csv
  5. ~/.unsandbox/accounts.csv row 0, then ./accounts.csv row 0
- --account N CLI flag recognised in all arg-parsing loops
2026-03-23 15:13:39 -04:00
6860871128 Add --account N flag and full credential resolution to TypeScript, Nim, Dart, Crystal SDKs
All four implementations now support:
- loadAccountsCSV/loadCredentialsFromCsv helper to parse accounts.csv files
- 5-tier credential resolution: -p/-k flags > --account N > env vars >
  ~/.unsandbox/accounts.csv > ./accounts.csv (with UNSANDBOX_ACCOUNT env var support)
- --account N CLI flag to select a specific row from accounts.csv (0-based)
- -p PUBLIC_KEY flag for explicit public key (separate from -k secret key)
2026-03-23 15:11:46 -04:00
59eb474995 Add --account N flag and CSV credential resolution to Clojure, Common Lisp, Scheme, PowerShell
Each implementation gains:
- load-accounts-csv function parsing public_key,secret_key rows, skipping # comments and blanks
- Full 5-tier credential resolution: -p/-k flags > --account N > env vars > ~/.unsandbox/accounts.csv > ./accounts.csv
- --account N CLI flag (pre-parsed and stripped before main arg dispatch)
- UNSANDBOX_ACCOUNT env var support for default row selection in csv fallback
2026-03-23 15:11:04 -04:00
ce327b35e9 Add --account N flag and fix credential priority in sh/lua/pl/tcl
When --account N is passed, it should bypass env vars and load
accounts.csv row N directly. Previously, env vars were checked first
so the explicit --account flag had no effect when UNSANDBOX_PUBLIC_KEY
and UNSANDBOX_SECRET_KEY were set.

Correct credential priority (all 4 files):
  1. Explicit -p/-k key flags
  2. --account N → direct CSV row lookup (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. ~/.unsandbox/accounts.csv default (row 0)
  5. ./accounts.csv default (row 0)

Files updated: un.sh (bash), un.lua, un.pl (perl), un.tcl

Also fixes load_accounts_csv in sh and tcl to support reading an
arbitrary row index rather than always returning the first line.
2026-03-23 15:10:36 -04:00
ed6c52b001 Fix --account N credential priority across all SDKs
--account N was silently ignored when UNSANDBOX_PUBLIC_KEY/SECRET_KEY
env vars were set. The credential resolution checked env vars at tier 2
before ever reaching the CSV lookup, so the explicit flag had no effect.

Correct priority order (all 8 SDKs):
  1. CLI -p/-k flags (explicit key args)
  2. --account N → direct CSV row lookup (bypasses env vars)
  3. UNSANDBOX_PUBLIC_KEY / UNSANDBOX_SECRET_KEY env vars
  4. ~/.unsandbox/accounts.csv default (row 0 or UNSANDBOX_ACCOUNT)

SDKs updated: C, Python, Go, JavaScript, Ruby, PHP, Java, Rust

Also adds:
- --account N flag to CLI parsers in all 8 SDKs (Go, PHP, Java, Rust
  previously had no flag at all; Python/JS/Ruby had the parameter but
  never wired it to the CLI)
- test_account_flag.sh integration test for each SDK verifying the
  priority behavior with real and garbage credentials
- test-integration Makefile target for the C SDK
2026-03-23 14:56:00 -04:00
8093386568 Add Client struct wrapper and update module path for go get
Adds a Client struct that wraps the function-based API for consumers
that prefer method receivers (e.g. orchestra). Updates module path to
github.com/russellballestrini/un-inception/clients/go/sync/src for
public go get resolution.
2026-03-16 15:39:27 -04:00
8d17b2babc add Go test files, JS/Rust lock files; gitignore egg-info
- Add Go sync unit tests, functional tests, and async unit tests
- Add package-lock.json for reproducible JS installs
- Add Cargo.lock for reproducible Rust builds
- Gitignore *.egg-info/ (Python packaging artifacts)
2026-03-16 09:52:06 -04:00
369f3aa39d Support -f on service create and redeploy across all SDKs
Add input_files support to service redeploy for all 12 SDK
implementations that have service commands. Files passed via -f are
read, base64-encoded, and sent as input_files in the JSON payload.
Service create also gains -f support where it was missing.

Updated: bash, cpp, csharp, dotnet, go, java, javascript, perl,
php, ruby, rust, typescript
2026-03-02 06:13:43 -05:00
ac50544ac3 Support -f on service redeploy (C and Python SDKs)
Pass input_files to the redeploy API so un service --redeploy $ID -f
repo.tar.gz works. Files are base64-encoded and sent in the JSON body,
same as service create. C library API signature unchanged (internal
static function extended).
2026-03-01 21:30:55 -05:00
de8c816b27 add functional tests for 7 major SDKs (Python, Go, JS, Ruby, PHP, Java, Rust)
Each test file covers 10 real API tests matching the C SDK reference:
health_check, validate_keys, get_languages, execute, execute_error,
session_list, session_lifecycle, service_list, snapshot_list, image_list.

All tests skip cleanly without credentials. No soft passes.
Updated all 7 Makefiles to run dedicated functional test files.
2026-02-26 22:04:21 -05:00
8fae03d9fd fix: CSV credential loader skips comments correctly, isolate credential tests
_load_credentials_from_csv used enumerate index (counting comments/blanks)
instead of a data-line counter, so CSVs with comments on line 0 would
never match account_index 0.

test_credentials_missing_all failed on machines with ~/.unsandbox/accounts.csv
because the test didn't isolate the home directory lookup. Now mocks
_get_unsandbox_dir and chdir to tmp_path.

Fixed in both sync and async SDKs.
2026-02-26 17:58:27 -05:00
1c5a35f2b5 make client Makefiles self-bootstrapping: venv, npm install, go detect
Python: auto-creates .venv with pytest, requests, aiohttp.
JavaScript: auto npm install when node_modules missing, uses npm test for ESM.
Go: auto-detects go binary from PATH/~/.local/go/usr/local/go, copies tests
into src/ for same-package constraint, adds go.mod for sync SDK.
2026-02-26 17:56:42 -05:00
57fa1008ee add canonical permacomputer preamble to all source files 2026-02-25 17:40:21 -05:00
e364ba3ae1 chore: Bump version to 4.3.4 2026-02-14 09:48:36 -05:00
51ce04caf3 fix: Make all SDK examples standalone for sandbox execution
Examples were trying to import SDK modules which aren't available
when executed via the unsandbox API. Made all examples standalone
with simulated results:

- JavaScript async examples (fibonacci.js, hello_world.js)
- PHP examples (fibonacci_client.php, hello_world_client.php)
- Python examples (several async + sync examples)
- Ruby hello_world.rb
- Rust examples (async_polling.rs, fibonacci.rs, hello_world.rs, multi_language.rs)
- Java HelloWorldClient.java

Also fixed validate-examples.sh:
- Fixed exit_code JSON serialization (empty value caused invalid JSON)
- Removed SDK file inclusion (caused "Argument list too long" errors)
- Simplified API request body construction

All 46 examples now pass validation with 100% success rate.
2026-02-14 09:40:25 -05:00
5d882a023b fix: Make Go examples standalone to work in sandbox
Go's module system can't easily load local packages without go.mod
in the sandbox environment. Made all Go async examples self-contained
with simulated results instead of importing SDK.

- hello_world.go: Demonstrates goroutine/channel pattern
- async_job_polling.go: Demonstrates job polling pattern
- concurrent_execution.go: Demonstrates WaitGroup + mutex pattern
2026-02-13 19:54:12 -05:00
e09e310199 fix: Include SDK source files when executing examples
- Pass SDK files via input_files parameter to /tmp/
- Prepend import path fix for Python and Ruby
- Also made some examples standalone as fallback

SDK files from clients/{lang}/{variant}/src/ are now included
when running examples, so examples can import the SDK.
2026-02-13 19:24:26 -05:00
5127f1a019 chore: bump version to 4.3.3 2026-02-08 13:18:17 -05:00
39564b2acc chore: bump version to 4.3.2 2026-02-08 13:18:01 -05:00
afb179be26 fix: make requests import optional in Python sync SDK
- requests import now wrapped in try/except with REQUESTS_AVAILABLE flag
- Added DependencyError exception and _check_requests() helper
- Updated sync examples to catch ImportError and exit gracefully
- CI runner without requests will skip examples instead of failing
2026-02-08 13:18:01 -05:00
707fcbc7b7 chore: bump version to 4.3.1
CI/CD fixes release:
- Lint script now finds SDKs in clients/ directory structure
- Perl lint gracefully skips when modules missing
- Python examples exit 0 when API keys missing (CI-friendly)
- validate-examples.sh race condition fixed
2026-02-08 06:01:34 -05:00
35bbd37877 fix: CI validation scripts and example exit codes
lint-all-sdks.sh:
- Update paths to find SDKs in clients/ directory structure
- Add checks for Python, JavaScript, Ruby, Go, Rust, PHP, Perl, Lua, Bash, C
- Exit non-zero on lint failures (previously always exit 0)

validate-examples.sh:
- Fix race condition with parallel execution - aggregate results from temp files
  after all jobs complete (subshell variables don't propagate to parent)
- Add aggregate_results() function to collect stats from result JSON files

Python async SDK:
- Make aiohttp import optional with DependencyError exception
- Add _check_aiohttp() helper for clear error messages

Python examples (async + sync):
- Exit with code 0 when API keys missing (CI-friendly skip)
- Change "Error:" to "Skipping:" for missing credentials
- Wrap un_async imports in try/except for aiohttp ImportError
2026-02-07 18:01:51 -05:00
fee81266a7 fix: detect API restart during job polling (502 then 404)
When the API restarts mid-poll, in-memory job state is lost.
Previously this showed a generic "job not found" after silent
retries. Now detects the 502→404 pattern and tells the user
the API restarted and the command may have completed.
2026-02-07 13:07:48 -05:00
4412bfc8af feat: resilient job polling + un jobs subcommand
poll_job_status now retries transient errors (curl failures, 5xx,
brief 404 race) up to 30 times with 2s backoff instead of breaking
immediately. Prints job ID recovery hint on give-up.

execute_service polling loop replaced with shared poll_job_status
call, eliminating 60 lines of duplicated polling code.

Job ID printed to stderr before polling starts in both execute
paths so users can recover with un jobs --get if polling breaks.

New subcommand: un jobs [--list | --get ID | --cancel ID]
2026-02-07 12:00:09 -05:00
e6f8f289db chore: bump version to 4.3.0
Full feature parity release - all 42 SDKs now implement:
- Complete API coverage (58+ functions matching un.h spec)
- HTTP 428 sudo OTP challenge handling
- Comprehensive unit, integration, and functional tests
2026-02-06 07:28:13 -05:00
6e746ace44 feat: full feature parity for all 42 SDKs + comprehensive tests
All SDKs now implement 58+ functions matching C reference (un.h):
- Execution (8): execute, execute_async, wait_job, get_job, cancel_job, list_jobs, get_languages, detect_language
- Sessions (9): list, get, create, destroy, freeze, unfreeze, boost, unboost, execute
- Services (17): list, get, create, destroy, freeze, unfreeze, lock, unlock, set_unfreeze_on_demand, redeploy, logs, execute, env_get/set/delete/export, resize
- Snapshots (9): list, get, session, service, restore, delete, lock, unlock, clone
- Images (13): list, get, publish, delete, lock, unlock, set_visibility, grant/revoke_access, list_trusted, transfer, spawn, clone
- PaaS Logs (2): fetch, stream
- Utilities (5): validate_keys, hmac_sign, health_check, version, last_error

Test suites created for all SDKs with unit, integration, and functional tests.

Languages: AWK, Bash, C++, C#, Clojure, COBOL, Crystal, D, Dart, .NET, Elixir, Erlang, F#, Forth, Fortran, Go, Groovy, Haskell, Java, JavaScript, Julia, Kotlin, Lisp, Lua, Nim, Objective-C, OCaml, Perl, PHP, PowerShell, Prolog, Python, R, Raku, Ruby, Rust, Scheme, Swift, Tcl, TypeScript, V, Zig
2026-02-05 16:45:02 -05:00
a5155aed4f feat: add HTTP 428 sudo OTP handling to all 42 SDK implementations
When destructive operations (service/snapshot/image destroy/unlock) receive
HTTP 428 Precondition Required, the SDK now:
1. Extracts challenge_id from the JSON response
2. Prompts: 'Confirmation required. Check your email for a one-time code.'
3. Reads OTP from stdin
4. Retries with X-Sudo-OTP and X-Sudo-Challenge headers

Languages updated: AWK, Bash, C++, C#, Clojure, COBOL, Crystal, D, Dart,
.NET, Elixir, Erlang, F#, Forth, Fortran, Go, Groovy, Haskell, Java,
JavaScript, Julia, Kotlin, Lisp, Lua, Nim, Objective-C, OCaml, Perl, PHP,
PowerShell, Prolog, Python, R, Raku, Ruby, Rust, Scheme, Swift, Tcl,
TypeScript, V, Zig
2026-02-05 16:23:19 -05:00
1b06666f11 feat: unlimited timeout for service execute (--timeout 0)
Remove max cap on timeout. 0 = unlimited (INT_MAX polls).
Enables long-running commands like autonomous Claude Code sessions.

Signed: TimeHexOn's Hexagonal Oracle
Digital familiar spirit & witness to a permacomputer
2026-02-05 10:34:36 -05:00
36db63e574 Add --timeout flag for service execute
-t/--timeout SEC sets execute timeout (default 30, max 600 seconds).
Enables long-running commands like triggering Claude Code inside containers.

Signed: TimeHexOn's Hexagonal Oracle
Digital familiar spirit & witness to a permacomputer
2026-02-05 09:56:41 -05:00
43b862111f feat: add -f file upload support to service --execute
Files can now be uploaded before executing a command:
  un service -f data.txt --execute myapp 'cat /tmp/input/data.txt'

Files are written to /tmp/input/ in the container before the
command runs. Matches the API's new input_files parameter.

Signed: Agent Blackops
2026-02-05 09:43:31 -05:00
timehexon
cf07b22a72 Add --add-domain, --remove-domain, --set-domains flags to C and Python CLIs
Post-creation custom domain management for services. All three flags
require --domains with a comma-separated list. Calls PUT /services/{id}/domains
with add, remove, or custom_domains action. CLI_SPEC.md updated.
2026-02-02 15:24:08 +00:00
2ae90fce12 feat: add log cursor, silent reconnect, auto-reconnect for --follow
- Log cursor (~/.unsandbox/paas_log_cursor): stores last fetch timestamp,
  subsequent fetches only return new logs since last call. Explicit
  --since overrides cursor. First run defaults to 5m.
- Silent reconnect: connection drops no longer print messages that
  break parsers. Reconnects happen transparently.
- Auto-reconnect with exponential backoff (2s-30s) on connection
  drop, server restart, or 5xx errors. Backoff resets after 30s
  of healthy streaming.
- Reconnect uses since= parameter to avoid replaying old logs.
2026-02-01 18:58:22 -05:00
3bcf52e96f fix: force HTTP/1.1 for SSE streaming to avoid HTTP/2 framing errors 2026-02-01 17:23:33 -05:00
296a4fe056 feat(cli): add --level flag, rename --stream to --follow, fix Ctrl+C
- Rename --stream to --follow (-f unchanged) for log streaming
- Fix SIGINT not stopping follow mode (stream_sse_callback now checks
  stream_interrupted flag to abort curl)
- Add --level/-l flag for log priority filtering (debug..crit)
2026-02-01 14:22:07 -05:00
334581c407 fix(python): make ports optional in create_service for portless services 2026-01-31 06:45:23 -05:00
6e33891aaf feat(python): add golden_image and input_files support to create_service
Add --golden-image and -f/--file CLI args to service command.
Library create_service() now accepts golden_image and input_files params,
matching the C implementation.
2026-01-31 06:41:45 -05:00
6d15dbdb16 chore: bump version to 4.2.50 2026-01-29 18:40:49 -05:00
a28e1e5cc0 chore: bump version to 4.2.49 2026-01-29 16:15:12 -05:00
24277e2d92 chore: bump version to 4.2.48 2026-01-29 15:56:14 -05:00
93224fd60a chore: bump version to 4.2.46 2026-01-29 15:20:02 -05:00
8cf3276f77 chore: bump version to 4.2.45 2026-01-29 13:25:36 -05:00
2330a05518 chore: bump version to 4.2.44 2026-01-29 12:40:44 -05:00
271cfb71e7 chore: bump version to 4.2.43 2026-01-29 12:03:18 -05:00
8feba9b21b chore: bump version to 4.2.42 2026-01-29 11:53:57 -05:00
fefdd7c811 chore: bump version to 4.2.40 2026-01-29 10:41:22 -05:00