spawn/sprite/opencode.sh
Ahmed Abushagur a063fe61cd
fix: sprite npm PATH resolution and gateway timeout (#1484)
* fix: sprite npm PATH resolution and gateway timeout

Sprites use nvm-managed node, so npm global bin is at
/.sprite/languages/node/nvm/.../bin/ which isn't in default PATH.
Dynamically resolve $(npm prefix -g)/bin in install, launch, and
gateway commands for all sprite agents.

Also increase openclaw gateway timeout from 30s to 60s — gateway
starts slowly on sprites but TUI connects once ready.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add opencode bin dir to PATH in sprite launch command

OpenCode installs to $HOME/.opencode/bin/ which isn't in the sprite's
default PATH or the npm prefix path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:49:52 -05:00

28 lines
811 B
Bash
Executable file

#!/bin/bash
set -eo pipefail
# Source common functions - try local file first, fall back to remote
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
if [[ -f "${SCRIPT_DIR}/lib/common.sh" ]]; then
source "${SCRIPT_DIR}/lib/common.sh"
else
eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/sprite/lib/common.sh)"
fi
log_info "OpenCode on Sprite"
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; export PATH=$HOME/.opencode/bin:$(npm prefix -g 2>/dev/null)/bin:$HOME/.bun/bin:/.sprite/languages/bun/bin:$PATH; opencode'
}
spawn_agent "OpenCode"