mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-12 06:00:25 +00:00
Migrates AWS Lightsail from 609-line bash (aws/lib/common.sh) to TypeScript, following the established Fly.io/local provider patterns. Type safety eliminates SigV4 signing bugs, @clack/prompts provides interactive bundle/region pickers, and error handling is explicit. - cli/src/aws/aws.ts — Core: AWS CLI wrapper, SigV4 REST API, auth, provisioning, SSH - cli/src/aws/agents.ts — Agent configs and install helpers - cli/src/aws/main.ts — Orchestrator - aws/*.sh — Converted to thin bun shims with bash fallback (curl|bash compatible) - cli/package.json — Version bump to 0.6.0 Fixes #1675 Agent: complexity-hunter Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
33 lines
1.3 KiB
Bash
Executable file
33 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
set -eo pipefail
|
|
|
|
# Thin shim: ensures bun is available, runs bundled aws.js (local or from GitHub release)
|
|
|
|
_ensure_bun() {
|
|
if command -v bun &>/dev/null; then return 0; fi
|
|
printf '\033[0;36mInstalling bun...\033[0m\n' >&2
|
|
curl -fsSL https://bun.sh/install | bash >/dev/null 2>&1 || { printf '\033[0;31mFailed to install bun\033[0m\n' >&2; exit 1; }
|
|
export PATH="$HOME/.bun/bin:$PATH"
|
|
command -v bun &>/dev/null || { printf '\033[0;31mbun not found after install\033[0m\n' >&2; exit 1; }
|
|
}
|
|
|
|
_ensure_bun
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
|
|
# Local checkout — run from source
|
|
if [[ -n "$SCRIPT_DIR" && -f "$SCRIPT_DIR/../cli/src/aws/main.ts" ]]; then
|
|
exec bun run "$SCRIPT_DIR/../cli/src/aws/main.ts" opencode "$@"
|
|
fi
|
|
|
|
# Remote — fall back to bash implementation
|
|
eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/aws/lib/common.sh)"
|
|
|
|
log_info "OpenCode on AWS Lightsail"
|
|
echo ""
|
|
|
|
agent_install() { install_agent "OpenCode" "$(opencode_install_cmd)" cloud_run; }
|
|
agent_env_vars() { generate_env_config "OPENROUTER_API_KEY=${OPENROUTER_API_KEY}"; }
|
|
agent_launch_cmd() { echo 'source ~/.spawnrc 2>/dev/null; source ~/.zshrc 2>/dev/null; opencode'; }
|
|
|
|
spawn_agent "OpenCode" "opencode" "aws"
|