Commit graph

46 commits

Author SHA1 Message Date
Sprite
fa2dc64438 refactor: consolidate cloud-init userdata to shared/common.sh
Moved duplicate get_cloud_init_userdata() function from all 4 cloud
provider common.sh files to shared/common.sh. This eliminates 60+ lines
of duplication and centralizes cloud-init configuration.

Changes:
- Added get_cloud_init_userdata() to shared/common.sh with detailed comments
- Removed duplicate function from hetzner/lib/common.sh
- Removed duplicate function from digitalocean/lib/common.sh
- Removed duplicate function from vultr/lib/common.sh
- Removed duplicate function from linode/lib/common.sh
- Added comment that clouds can override if needed

All tests pass (42 passed, 0 failed).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:45:44 +00:00
Sprite
26f8205cd9 refactor: Improve error messages for missing API tokens
Enhanced error messages across all cloud providers to be more actionable:
- Changed generic "API token/key is required" to "cannot be empty"
- Added specific authentication failure messages with provider URLs
- Included permission verification hints
- Added non-interactive mode environment variable suggestions

Benefits:
- Users get clear guidance on how to fix authentication issues
- Error messages now include direct links to token management pages
- Better UX for both interactive and non-interactive usage

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:45:06 +00:00
Sprite
8ead0752d5 refactor: consolidate SSH_OPTS to shared/common.sh
Moved duplicate SSH_OPTS constant from all 4 cloud provider common.sh
files to shared/common.sh. This removes 4 lines of duplication and
centralizes SSH configuration.

Changes:
- Added SSH_OPTS to shared/common.sh with comment explaining clouds can override
- Removed SSH_OPTS from hetzner/lib/common.sh
- Removed SSH_OPTS from digitalocean/lib/common.sh
- Removed SSH_OPTS from vultr/lib/common.sh
- Removed SSH_OPTS from linode/lib/common.sh

All tests pass (42 passed, 0 failed).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:44:19 +00:00
Sprite
595d6f7f59 refactor: hetzner/lib - add bash safety flags
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:44:08 +00:00
Sprite
0e5712a634 refactor: Add detailed architecture documentation to CLAUDE.md
Added comprehensive file structure explanation:
- shared/common.sh pattern and its utilities
- Cloud-specific lib/common.sh extensions
- Agent script structure and sourcing pattern
- Benefits: DRY, consistency, maintainability
- Example source pattern for contributors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:44:03 +00:00
Sprite
8b150a09f7 refactor: sprite/lib - add bash safety flags
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:43:34 +00:00
Sprite
69cc92a52e refactor: Update README.md to document shared/common.sh architecture
Added "Architecture" section explaining:
- Library structure (shared/common.sh + cloud-specific extensions)
- How shared utilities reduce duplication across providers
- Benefits: DRY, consistency, maintainability, extensibility

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:43:31 +00:00
Sprite
5954455030 refactor: Add comprehensive bash safety flags to all agent scripts
- Changed 'set -e' to 'set -euo pipefail' in all 35 agent scripts
- Provides better error handling:
  - 'e': Exit on command failure
  - 'u': Exit on undefined variable usage
  - 'o pipefail': Exit on any pipe command failure
- Improves script reliability and debugging
- All tests pass (42/42)

Affected files:
- sprite/{aider,claude,codex,goose,interpreter,nanoclaw,openclaw}.sh
- hetzner/{aider,claude,codex,goose,interpreter,nanoclaw,openclaw}.sh
- digitalocean/{aider,claude,codex,goose,interpreter,nanoclaw,openclaw}.sh
- linode/{aider,claude,codex,goose,interpreter,nanoclaw,openclaw}.sh
- vultr/{aider,claude,codex,goose,interpreter,nanoclaw,openclaw}.sh

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 20:06:51 +00:00
Sprite
7162f9c236 refactor: secure temp files with chmod 600 before writing credentials
Added chmod 600 to all temporary files that contain sensitive data (API keys, tokens, configs):
- ENV_TEMP: 35 files (all agent scripts across 5 clouds)
- OPENCLAW_CONFIG_TEMP: 5 files (already done in previous commit)
- SETTINGS_TEMP: 5 files (Claude Code settings)
- GLOBAL_STATE_TEMP: 5 files (Claude Code global state)
- DOTENV_TEMP: 5 files (NanoClaw .env files)

Total: 55 temp files secured

This prevents race conditions where sensitive data could be read by other users
between mktemp creation (mode 600 by default) and data being written.

Security hardening for task #23.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 20:03:55 +00:00
Sprite
da7724da68 refactor: Extract SSH key management helpers to reduce nesting
Created helper functions in shared/common.sh to simplify ensure_ssh_key():
- generate_ssh_key_if_missing(key_path): Generate SSH key if needed
- get_ssh_fingerprint(pub_path): Get MD5 fingerprint
- json_escape(string): JSON-escape strings for API bodies

Refactored ensure_ssh_key() in all cloud providers to use these helpers:
- Reduced function length from 35-52 lines to 24-28 lines
- Eliminated nested conditionals
- Made the code flow more linear and readable
- Centralized SSH key generation and fingerprint logic

Benefits:
- Single source of truth for SSH key operations
- Reduced code duplication (~40 lines per provider → 3 helper functions)
- Easier to maintain and test
- More consistent error handling

All tests pass (42/42).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 20:03:43 +00:00
Sprite
528694123d refactor: Extract SSH wait logic to shared generic_ssh_wait function
Created generic_ssh_wait() in shared/common.sh to eliminate ~100 lines
of duplicated waiting logic across all cloud providers.

Changes:
- Added generic_ssh_wait(ip, ssh_opts, test_cmd, description, max_attempts, interval)
  to shared/common.sh
- Refactored verify_server_connectivity() in all clouds to use generic_ssh_wait
- Refactored wait_for_cloud_init() in all clouds to use generic_ssh_wait

Benefits:
- Single source of truth for SSH polling logic
- Consistent error messages across providers
- Reduced code duplication (~20 lines per provider → 2 lines)
- Easier to maintain and test

All tests pass (42/42).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 20:01:29 +00:00
Sprite
ed40229b5b refactor: Quote numeric variables in shared/common.sh
Improved bash safety by quoting numeric comparison variables:
- $elapsed and $timeout in OAuth timeout loop
- $server_pid in process cleanup (kill and wait)

This prevents potential word splitting and follows bash best practices
for variable quoting in numeric contexts.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:59:07 +00:00
Sprite
895fc9e90b refactor: vultr/lib - add bash safety flags and variable quoting
- Add set -euo pipefail for strict error handling
- Make color constants readonly (RED, GREEN, YELLOW, NC)
- Make VULTR_API_BASE and SSH_OPTS readonly
- Quote numeric comparison variables in verify_server_connectivity
- Quote numeric comparison variables in wait_for_cloud_init
- Quote numeric comparison variables in create_server
- Quote process IDs and timeout variables in try_oauth_flow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:55:49 +00:00
Sprite
a403578721 refactor: linode/lib - add bash safety flags and variable quoting
- Add set -euo pipefail for strict error handling
- Make color constants readonly (RED, GREEN, YELLOW, NC)
- Make LINODE_API_BASE and SSH_OPTS readonly
- Quote numeric comparison variables in verify_server_connectivity
- Quote numeric comparison variables in wait_for_cloud_init
- Quote numeric comparison variables in create_server
- Quote process IDs and timeout variables in try_oauth_flow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:54:11 +00:00
Sprite
68d114eecb refactor: digitalocean/lib - add bash safety flags and variable quoting
- Add set -euo pipefail for strict error handling
- Make color constants readonly (RED, GREEN, YELLOW, NC)
- Make DO_API_BASE and SSH_OPTS readonly
- Quote numeric comparison variables in verify_server_connectivity
- Quote numeric comparison variables in wait_for_cloud_init
- Quote numeric comparison variables in create_server
- Quote process IDs and timeout variables in try_oauth_flow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:52:45 +00:00
Sprite
d689f6f06c security: Add MODEL_ID input validation to prevent injection
Added validate_model_id() function to all common.sh files to prevent
command injection via user-supplied MODEL_ID values. MODEL_ID is used
in JSON configs, shell commands, and exported to remote systems, so
validation is critical.

Validation enforces that MODEL_ID contains only safe characters:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Separators: / - _ : .

Rejects dangerous characters like backticks, $(), quotes, semicolons
that could be used for command injection.

Changes:
- Added validate_model_id() to all lib/common.sh files
- Added validation calls after MODEL_ID input in all agent scripts
- Tests pass for all sprite scripts

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:52:07 +00:00
Sprite
bb4c41be3e Add validate_model_id function to digitalocean/lib/common.sh 2026-02-07 19:51:36 +00:00
Sprite
0d31aba9f0 refactor: hetzner/lib - add bash safety flags and variable quoting
- Add set -euo pipefail for strict error handling
- Make color constants readonly (RED, GREEN, YELLOW, NC)
- Make HETZNER_API_BASE and SSH_OPTS readonly
- Quote numeric comparison variables in verify_server_connectivity
- Quote numeric comparison variables in wait_for_cloud_init
- Quote process IDs and timeout variables in try_oauth_flow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:51:18 +00:00
Sprite
4504246d30 refactor: sprite/lib/common.sh - add proper variable quoting
Added quotes to numeric and process ID variables for safer bash execution:
- Quoted $attempt, $max_attempts in while loop conditions
- Quoted $nc_status in conditional checks
- Quoted $server_pid in kill and wait commands
- Quoted $elapsed, $timeout in timeout loop

This prevents potential issues with word splitting and glob expansion.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:48:21 +00:00
Sprite
355c330507 security: Fix command injection in openclaw.sh files
Fixed command injection vulnerability in sprite/openclaw.sh where
OPENCLAW_CONFIG was echoed directly into remote shell command with
user-controlled MODEL_ID variable. Changed to use temp file + secure
upload instead of inline echo.

Also added chmod 600 to all OPENCLAW_CONFIG_TEMP files across all
cloud providers (linode, vultr, digitalocean, hetzner, sprite) to
prevent race condition where credentials could be exposed in temp
files before being written.

Changes:
- sprite/openclaw.sh: Replaced echo with temp file + sprite exec -file
- All openclaw.sh: Added chmod 600 after mktemp for credentials

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:48:09 +00:00
Sprite
180b1637c7 refactor: sprite/lib/common.sh - add bash safety flags
Added `set -euo pipefail` for safer bash execution:
- set -e: Exit immediately on error
- set -u: Exit on undefined variable usage
- set -o pipefail: Catch errors in piped commands

Made color constants readonly to prevent accidental modification.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 19:47:05 +00:00
L
4f4d87c234
Add Open Interpreter as seventh agent across all clouds (#13)
Open Interpreter provides a natural language interface for computer control.
Works with OpenRouter via OPENAI_BASE_URL=https://openrouter.ai/api/v1.

- Implemented on all 5 clouds: sprite, hetzner, digitalocean, vultr, linode
- Matrix now 7 agents x 5 clouds = 35/35 implemented

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 09:30:27 -08:00
L
e781506604
Add Linode (Akamai) as fifth cloud provider with all 6 agents (#12)
Linode instances via REST API v4, with cloud-init via metadata.user_data.
- linode/lib/common.sh: API wrapper, token management, instance lifecycle
- All 6 agents: claude, openclaw, nanoclaw, aider, goose, codex

Matrix now 6 agents x 5 clouds = 30/30 implemented.

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 09:26:31 -08:00
L
5a2f82cdbe
Add Codex CLI (OpenAI) as sixth agent across all clouds (#11)
OpenAI's open-source coding agent, works with OpenRouter via
OPENAI_BASE_URL=https://openrouter.ai/api/v1 override.

- sprite/codex.sh, hetzner/codex.sh, digitalocean/codex.sh, vultr/codex.sh
- Matrix now 6 agents x 4 clouds = 24/24 implemented

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 09:21:23 -08:00
L
38167283d2
Add Vultr as fourth cloud provider with all 5 agents (#10)
Vultr Cloud Compute via REST API (v2), with cloud-init + SSH provisioning.
- vultr/lib/common.sh: API wrapper, token management, instance lifecycle
- vultr/claude.sh, openclaw.sh, nanoclaw.sh, aider.sh, goose.sh

Matrix now 5 agents x 4 clouds = 20/20 implemented.

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 09:02:53 -08:00
L
7de02db81b
Add Goose agent (Block) across all clouds (#9)
Goose is Block's open-source model-agnostic AI coding agent.
Supports OpenRouter via GOOSE_PROVIDER=openrouter env var.

- sprite/goose.sh, hetzner/goose.sh, digitalocean/goose.sh
- Matrix now 5 agents x 3 clouds = 15/15 implemented

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 08:58:51 -08:00
L
ff531d00b8
Add Aider as fourth agent across all clouds (#8)
Aider is the most popular open-source AI pair programming CLI.
Natively supports OpenRouter via OPENROUTER_API_KEY env var
and --model openrouter/... flag.

- sprite/aider.sh, hetzner/aider.sh, digitalocean/aider.sh
- Matrix now 4 agents x 3 clouds = 12/12 implemented

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 08:56:07 -08:00
L
2b129ecaaa
Add DigitalOcean as third cloud provider (#7)
New cloud provider with full agent coverage:
- digitalocean/lib/common.sh: DO API wrapper, token management, droplet lifecycle
- digitalocean/claude.sh, openclaw.sh, nanoclaw.sh: all 3 agents

Matrix is now 3 agents x 3 clouds = 9/9 implemented.

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 08:53:16 -08:00
L
78e009176b
Add OpenClaw and NanoClaw scripts for Hetzner Cloud (#6)
Fills the remaining 2 gaps in the agents x clouds matrix:
- hetzner/openclaw.sh: provisions Hetzner server with OpenClaw gateway + TUI
- hetzner/nanoclaw.sh: provisions Hetzner server with NanoClaw WhatsApp agent

Matrix is now 100% complete (3 agents x 2 clouds = 6/6 implemented).

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 08:49:11 -08:00
L
6002e6c7f7
Add continuous improvement workflow for spawn matrix (#5)
- manifest.json: tracks agents x clouds matrix with metadata
- CLAUDE.md: instructions for Claude Code to fill gaps and discover new agents/clouds
- improve.sh: loop script that launches Claude Code to expand the matrix

Current matrix: 3 agents (claude, openclaw, nanoclaw) x 2 clouds (sprite, hetzner)
with 2 gaps remaining (hetzner/openclaw, hetzner/nanoclaw).

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 08:47:21 -08:00
L
bd30565d86
Add Hetzner Cloud spawn system for provisioning servers via REST API (#4)
Parallel to the existing sprite/ directory, adds hetzner/ scripts that
provision Hetzner Cloud servers with Claude Code + OpenRouter using
curl-based API calls (no hcloud CLI dependency).

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 07:25:03 -08:00
Sprite
fa02572d8c Improve OAuth callback page with animated checkmark and auto-close
Add styled success page with CSS-animated checkmark, fade-in messaging,
and auto-close after 3 seconds with fallback text if browser blocks it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 06:16:56 +00:00
L
2f3a6be011
Fix OAuth server and browser opener for Termux environments (#3)
- Add nc_listen helper that detects busybox nc and uses -p flag accordingly
- Add termux-open-url support to open_browser
- Deduplicate inline browser opener in try_oauth_flow to use open_browser

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-06 21:55:53 -08:00
Sprite
d6e957b039 Fix OAuth server and browser opener for Termux environments
- Add nc_listen helper that detects busybox nc and uses -p flag accordingly
- Add termux-open-url support to open_browser
- Deduplicate inline browser opener in try_oauth_flow to use open_browser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 05:52:01 +00:00
L
f43c52eb61
Add NanoClaw spawn script (#2)
* Add NanoClaw spawn script

NanoClaw is a lightweight WhatsApp-based Claude AI assistant that runs
agents in isolated containers. This script sets up a sprite with
nanoclaw pre-configured: clones the repo, installs dependencies,
configures the API key, and launches in dev mode for WhatsApp QR auth.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Fix verify_sprite_connectivity exiting script early after single failed check

Retry connectivity up to 6 attempts (30s) instead of trying once and
silently continuing, which caused the next sprite exec to fail under set -e.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add test harness for spawn scripts

Mocks the sprite CLI and runs each script end-to-end verifying:
- common.sh sources correctly and all functions resolve
- Log functions write to stderr (not stdout)
- Env var flow (SPRITE_NAME, OPENROUTER_API_KEY)
- Sprite commands called in correct order
- Temp files created and cleaned up
- Each script reaches its final interactive launch

Usage: bash test/run.sh

42 tests, all passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Sprite <noreply@sprite.dev>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 21:23:18 -08:00
Sprite
302a9b7896 Fix verify_sprite_connectivity exiting script early after single failed check
Retry connectivity up to 6 attempts (30s) instead of trying once and
silently continuing, which caused the next sprite exec to fail under set -e.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-07 05:22:58 +00:00
Sprite
c38f8ba3f6 Remove extra documentation files, keep only scripts and README
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:11:16 +00:00
Sprite
ce95cef78e Clean up README with consistent curl flags and split agent examples
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:08:41 +00:00
Sprite
780e2de9d3 Fix TTY detection and log output for non-interactive environments
- safe_read(): Test /dev/tty is functional before using it (exists
  but fails in containers/VMs)
- Log functions: Write to stderr so they don't pollute stdout in
  command substitutions like $(get_sprite_name)
- ensure_sprite_exists(): Fix grep regex (use -E for ERE)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:05:12 +00:00
Sprite
71246abc26 Fix source detection for process substitution (bash <(curl ...))
BASH_SOURCE[0] is /proc/self/fd/N with process substitution, not
"-" or "bash". Instead of guessing execution context, just check
if the local lib/common.sh file actually exists.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:03:02 +00:00
Sprite
7ff684ca1e Document interactive curl execution with process substitution
## Problem
The command `curl URL | bash` isn't interactive because curl's output
consumes bash's stdin, preventing user prompts from working.

## Solution
Use bash process substitution instead: `bash <(curl URL)`

This keeps stdin available for the script while downloading from curl.

## Changes

- Added INTERACTIVE_CURL.md - Complete guide to interactive execution
- Added NON_INTERACTIVE_MODE.md - Guide to automation/CI usage
- Updated README.md to recommend `bash <(curl ...)` format
- Documented OpenRouter URL alias pattern

## Recommended Usage

Interactive (best UX):
  bash <(curl -fsSL https://openrouter.ai/lab/spawn/sprite/claude.sh)

Non-interactive (CI/CD):
  SPRITE_NAME=dev-mk1 curl URL | bash

## Why Process Substitution?

- Stdin available for prompts 
- Works like normal bash script 
- No /dev/tty workarounds needed 
- Better user experience 

Both methods are supported for maximum compatibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 04:59:26 +00:00
Sprite
10ada0e04d Fix non-interactive mode for curl | bash execution
The scripts were failing when run via curl | bash because they tried
to read from /dev/tty which doesn't exist in piped contexts.

## Changes

- Added safe_read() helper function that gracefully handles TTY absence
- Updated get_sprite_name() to support SPRITE_NAME env variable
- Updated all read commands to use safe_read()
- Added clear error messages for non-interactive usage
- Updated README with non-interactive mode documentation

## Usage

Interactive:
  curl URL | bash

Non-interactive:
  SPRITE_NAME=dev-mk1 curl URL | bash
  SPRITE_NAME=dev-mk1 OPENROUTER_API_KEY=sk-xxx curl URL | bash

## Fixes

- /dev/tty: No such device or address error
- Scripts now work in CI/CD and automated contexts
- OAuth fallback still works via OPENROUTER_API_KEY env var

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 04:48:48 +00:00
L
c0536e3882
Merge pull request #1 from OpenRouterTeam/refactor/shared-lib-oauth-fallback
Refactor spawn scripts with shared library and OAuth fallback
2026-02-06 20:39:35 -08:00
Sprite
640af6260c Refactor spawn scripts with shared library and OAuth fallback
Major refactoring to improve code maintainability and reliability:

## Shared Library Architecture
- Created sprite/lib/common.sh with reusable bash functions
- Reduced openclaw.sh from 258 to 93 lines (-64%)
- Reduced claude.sh from 272 to 101 lines (-63%)
- Eliminated ~330 lines of duplicate code

## OAuth Fallback Mechanism
- Added automatic fallback to manual API key entry
- Handles missing netcat (nc) gracefully
- Handles port conflicts and timeouts
- Validates API key format with override option
- Works in headless and minimal environments

## Dual Execution Support
- Local: bash sprite/openclaw.sh
- Remote: curl URL | bash
- Auto-detects context and sources library appropriately

## New Shared Functions
- Logging: log_info(), log_warn(), log_error()
- Sprite setup: ensure_sprite_installed/authenticated/exists()
- Environment: setup_shell_environment()
- OAuth: get_openrouter_api_key_oauth() with fallback
- Utilities: run_sprite(), verify_sprite_connectivity()

## Documentation
- REFACTORING.md - Architecture and benefits
- OAUTH_FALLBACK.md - Fallback mechanism guide
- CURL_BASH_SOLUTION.md - Execution mode details
- EXAMPLES.md - Usage scenarios
- CHANGELOG.md - Complete change history

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 04:06:11 +00:00
lab
57bf0ca2fc
Sprite setup scripts for Claude Code and OpenClaw
- OAuth authentication flow with OpenRouter to mint API keys
- Automatic sprite creation and environment configuration
- Claude Code setup with bypassed onboarding and dark theme
- OpenClaw setup with gateway and TUI launch
- Shell environment setup (bun PATH, zsh switch)
2026-02-05 13:25:30 -06:00
lab
3eaf6321a1
Initial commit: OpenClaw sprite setup script 2026-02-02 15:08:15 -06:00