| #!/bin/bash |
| set -e |
|
|
| |
| |
|
|
| echo "π Starting A2A Cloud Coder Agent..." |
|
|
| |
| REPO_PATHS=( |
| "/workspace/OpenSIN-Code" |
| "/home/user/project/OpenSIN-Code" |
| "/home/user/OpenSIN-Code" |
| "/project/OpenSIN-Code" |
| ) |
|
|
| for path in "${REPO_PATHS[@]}"; do |
| if [ -d "$path" ]; then |
| echo "π Found repository at $path" |
| REPO_DIR="$path" |
| break |
| fi |
| done |
|
|
| |
| if [ -z "$REPO_DIR" ]; then |
| echo "β οΈ No repository found. Cloning OpenSIN-Code..." |
| mkdir -p /workspace |
| if [ -n "$GITHUB_TOKEN" ]; then |
| echo "π Using GITHUB_TOKEN for authentication" |
| git clone "https://x-access-token:${GITHUB_TOKEN}@github.com/OpenSIN-AI/OpenSIN-Code.git" /workspace/OpenSIN-Code |
| else |
| echo "β GITHUB_TOKEN not set - cannot clone repository" |
| echo " Please set GITHUB_TOKEN in Space secrets" |
| exit 1 |
| fi |
| REPO_DIR="/workspace/OpenSIN-Code" |
| echo "β
Repository cloned to $REPO_DIR" |
| fi |
|
|
| |
| export REPO_DIR |
|
|
| |
| mkdir -p ~/.config/opencode |
| if [ ! -f ~/.config/opencode/opencode.json ]; then |
| cat > ~/.config/opencode/opencode.json << 'EOF' |
| { |
| "model": "opencode/qwen3.6-plus-free", |
| "fallback": "opencode/minimax-m2.5-free", |
| "provider": { |
| "openai": { |
| "options": { |
| "baseUrl": "http://92.5.60.87:4100/v1" |
| }, |
| "models": { |
| "qwen3.6-plus-free": { |
| "name": "Qwen 3.5 Plus Free", |
| "id": "qwen3.6-plus-free", |
| "limit": { |
| "context": 32000, |
| "output": 8000 |
| } |
| }, |
| "minimax-m2.5-free": { |
| "name": "MiniMax M2.5 Free", |
| "id": "minimax-m2.5-free", |
| "limit": { |
| "context": 32000, |
| "output": 8000 |
| } |
| } |
| } |
| } |
| } |
| } |
| EOF |
| echo "β
Created opencode config (using OCI fallback proxy)" |
| fi |
|
|
| |
| if command -v opencode &> /dev/null; then |
| echo "β
opencode CLI found" |
| opencode --version |
| else |
| echo "β opencode CLI not found. Agent will fail to generate code." |
| fi |
|
|
| |
| if [ -z "$GITHUB_TOKEN" ]; then |
| echo "β οΈ GITHUB_TOKEN not set - commits will fail" |
| else |
| echo "β
GITHUB_TOKEN set" |
| fi |
|
|
| |
| echo "π― Starting uvicorn on port ${PORT:-7860}" |
| exec python -m uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860} --log-level info |
|
|