mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-04 23:00:20 +00:00
refactor: introduce cloud adapter + spawn_agent runner system (#1340)
Eliminate ~70% boilerplate across 149 agent scripts by introducing a standard cloud_* adapter interface and spawn_agent orchestration runner. Each cloud's lib/common.sh now exports 7 adapter functions (cloud_authenticate, cloud_provision, cloud_wait_ready, cloud_run, cloud_upload, cloud_interactive, cloud_label) that wrap cloud-specific operations behind a uniform interface. Agent scripts define hooks (agent_install, agent_env_vars, agent_launch_cmd, etc.) and call `spawn_agent "Agent Name"` — the runner handles the full deployment flow: auth → provision → wait → install → API key → env → config → launch. - shared/common.sh: add spawn_agent(), _fn_exists(), _spawn_inject_env_vars() - 10 cloud lib/common.sh files: add cloud_* adapter functions - 149 agent scripts: rewrite to hook pattern (~40-80 lines → ~20-35 lines) - test/run.sh: update 2 sprite test patterns for new adapter paths - Net reduction: ~4,300 lines (2,257 added, 6,563 removed) Co-authored-by: lab <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0461222955
commit
ec81c74594
161 changed files with 2123 additions and 6429 deletions
|
|
@ -12,22 +12,8 @@ fi
|
|||
log_info "OpenCode on Hetzner Cloud"
|
||||
echo ""
|
||||
|
||||
# Provision server
|
||||
ensure_hcloud_token
|
||||
ensure_ssh_key
|
||||
SERVER_NAME=$(get_server_name)
|
||||
create_server "${SERVER_NAME}"
|
||||
verify_server_connectivity "${HETZNER_SERVER_IP}"
|
||||
wait_for_cloud_init "${HETZNER_SERVER_IP}" 60
|
||||
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 ~/.zshrc && opencode'; }
|
||||
|
||||
# Set up callbacks
|
||||
RUN="run_server ${HETZNER_SERVER_IP}"
|
||||
UPLOAD="upload_file ${HETZNER_SERVER_IP}"
|
||||
SESSION="interactive_session ${HETZNER_SERVER_IP}"
|
||||
|
||||
# Install, configure, launch
|
||||
install_agent "OpenCode" "$(opencode_install_cmd)" "$RUN"
|
||||
get_or_prompt_api_key
|
||||
inject_env_vars_cb "$RUN" "$UPLOAD" \
|
||||
"OPENROUTER_API_KEY=${OPENROUTER_API_KEY}"
|
||||
launch_session "Hetzner server" "$SESSION" "source ~/.zshrc && opencode"
|
||||
spawn_agent "OpenCode"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue