mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-02 22:00:19 +00:00
Adds a "local" cloud provider that installs and runs agents directly on the user's machine without any cloud provisioning. This is useful for local development and testing. - local/lib/common.sh: Cloud lib with local execution functions - local/claude.sh: Claude Code agent script - local/openclaw.sh: OpenClaw agent script - local/nanoclaw.sh: NanoClaw agent script - manifest.json: Added local cloud + matrix entries - test/: Updated record.sh and mock.sh for local cloud support Fixes #378 Agent: issue-fixer Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
85 lines
2.2 KiB
Bash
85 lines
2.2 KiB
Bash
#!/bin/bash
|
|
set -eo pipefail
|
|
# Common bash functions for local machine spawn scripts
|
|
# No cloud provisioning — runs agents directly on the user's machine
|
|
|
|
# ============================================================
|
|
# Provider-agnostic functions
|
|
# ============================================================
|
|
|
|
# Source shared provider-agnostic functions (local or remote fallback)
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
if [[ -n "${SCRIPT_DIR}" && -f "${SCRIPT_DIR}/../../shared/common.sh" ]]; then
|
|
source "${SCRIPT_DIR}/../../shared/common.sh"
|
|
else
|
|
eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/shared/common.sh)"
|
|
fi
|
|
|
|
# ============================================================
|
|
# Local machine functions
|
|
# ============================================================
|
|
|
|
# No authentication needed for local machine
|
|
ensure_local_ready() {
|
|
log_info "Running on local machine"
|
|
|
|
# Ensure basic tools are available
|
|
if ! command -v curl &>/dev/null; then
|
|
log_error "curl is required but not installed"
|
|
return 1
|
|
fi
|
|
|
|
check_python_available || return 1
|
|
}
|
|
|
|
# No server name needed — use hostname
|
|
get_server_name() {
|
|
local name
|
|
name=$(hostname 2>/dev/null || echo "local")
|
|
echo "${name}"
|
|
}
|
|
|
|
# No server creation — it's the local machine
|
|
create_server() {
|
|
local name="${1}"
|
|
log_info "Using local machine: ${name}"
|
|
}
|
|
|
|
# No cloud-init needed
|
|
wait_for_cloud_init() {
|
|
:
|
|
}
|
|
|
|
# Run a command locally
|
|
# The command string is passed directly to bash -c for shell parsing.
|
|
# All callers pass trusted, hardcoded command strings (not user input).
|
|
run_server() {
|
|
local cmd="${1}"
|
|
bash -c "${cmd}"
|
|
}
|
|
|
|
# Copy a file locally
|
|
upload_file() {
|
|
local local_path="${1}"
|
|
local remote_path="${2}"
|
|
# Expand ~ in remote_path
|
|
local expanded_path="${remote_path/#\~/$HOME}"
|
|
mkdir -p "$(dirname "${expanded_path}")"
|
|
cp "${local_path}" "${expanded_path}"
|
|
}
|
|
|
|
# Start an interactive session locally
|
|
interactive_session() {
|
|
local cmd="${1}"
|
|
bash -c "${cmd}"
|
|
}
|
|
|
|
# No server to destroy
|
|
destroy_server() {
|
|
log_info "Nothing to destroy (local machine)"
|
|
}
|
|
|
|
# No servers to list
|
|
list_servers() {
|
|
printf '%s\n' "$(hostname 2>/dev/null || echo "local")"
|
|
}
|