diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index 45a0c29..9ed2d92 100644 --- a/.gitea/workflows/agent.yml +++ b/.gitea/workflows/agent.yml @@ -149,6 +149,7 @@ jobs: SCRIPTS: ${{ runner.temp }}/agents-scripts OLLAMA_URL: ${{ secrets.OLLAMA_URL }} OLLAMA_CLOUD_API_KEY: ${{ secrets.OLLAMA_CLOUD_API_KEY }} + XAI_API_KEY: ${{ secrets.XAI_API_KEY }} NAME: ${{ steps.prep.outputs.name }} SKILLS: ${{ steps.prep.outputs.skills }} # JSON array of skills this agent may load run: bash "$SCRIPTS/install-opencode.sh" diff --git a/.gitea/workflows/scripts/install-opencode.sh b/.gitea/workflows/scripts/install-opencode.sh index 0c1f7df..a236034 100755 --- a/.gitea/workflows/scripts/install-opencode.sh +++ b/.gitea/workflows/scripts/install-opencode.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # Install opencode + provider config (+ Playwright MCP for browser agents). # -# Required env (provided by the workflow step): OLLAMA_URL OLLAMA_CLOUD_API_KEY NAME SKILLS -# GITHUB_PATH HOME +# Required env (provided by the workflow step): OLLAMA_URL OLLAMA_CLOUD_API_KEY XAI_API_KEY +# NAME SKILLS GITHUB_PATH HOME set -eu # PIN the opencode version: an unpinned `latest` means a breaking release (CLI flags, or the @@ -38,19 +38,22 @@ esac SKILLS="${SKILLS:-[]}" PERM=$(jq -nc --argjson s "$SKILLS" ' {skill: ( {"*":"deny"} + (reduce $s[] as $k ({}; . + {($k):"allow"})) )}') -# Two ollama providers: local self-hosted (ornith) + Ollama Cloud (gemma4/kimi-k2.7-code/glm-5.2/minimax-m3). -# The provider `models:` maps are DERIVED from agents.json (the single source of truth, shared with -# route.sh) so every model an agent is routed to is always declared in the provider config. -# `ollama-cloud/` prefix models go to the cloud provider; `ollama/` prefix models go to the local -# provider. Built-in providers (e.g. `xai/grok-4.5` for @lead/@ops) are not derived here. +# Three OpenAI-compatible providers: local self-hosted ollama (ornith) + Ollama Cloud +# (gemma4/kimi-k2.7-code/glm-5.2/minimax-m3) + xAI (grok-4.5). The provider `models:` maps are +# DERIVED from agents.json (the single source of truth, shared with route.sh) so every model an +# agent is routed to is always declared in the provider config. `ollama-cloud/` prefix models go to +# the cloud provider; `ollama/` prefix models go to the local provider; `xai/` prefix models go to +# the xAI provider (OpenAI-compatible, https://api.x.ai/v1). No other built-in providers remain. # See issue #31. AGENTS_JSON="${SCRIPTS:-$(dirname -- "$0")}/agents.json" CLOUD_MODELS=$(jq -r '[.[] | .model | select(startswith("ollama-cloud/")) | sub("^ollama-cloud/";"")] | map({(.):{}}) | add // {}' "$AGENTS_JSON") LOCAL_MODELS=$(jq -r '[.[] | .model | select(startswith("ollama/")) | sub("^ollama/";"")] | map({(.):{}}) | add // {"ornith:35b":{}}' "$AGENTS_JSON") -jq -n --argjson mcp "$MCP" --argjson perm "$PERM" --argjson cloud "$CLOUD_MODELS" --argjson local "$LOCAL_MODELS" --arg url "$OLLAMA_URL" --arg ckey "$OLLAMA_CLOUD_API_KEY" '{ +XAI_MODELS=$(jq -r '[.[] | .model | select(startswith("xai/")) | sub("^xai/";"")] | map({(.):{}}) | add // {}' "$AGENTS_JSON") +jq -n --argjson mcp "$MCP" --argjson perm "$PERM" --argjson cloud "$CLOUD_MODELS" --argjson local "$LOCAL_MODELS" --argjson xai "$XAI_MODELS" --arg url "$OLLAMA_URL" --arg ckey "$OLLAMA_CLOUD_API_KEY" --arg xkey "$XAI_API_KEY" '{ provider: { ollama: {npm:"@ai-sdk/openai-compatible", options:{baseURL:($url+"/v1")}, models:$local}, - "ollama-cloud": {npm:"@ai-sdk/openai-compatible", options:{baseURL:"https://ollama.com/v1", apiKey:$ckey}, models:$cloud} + "ollama-cloud": {npm:"@ai-sdk/openai-compatible", options:{baseURL:"https://ollama.com/v1", apiKey:$ckey}, models:$cloud}, + xai: {npm:"@ai-sdk/openai-compatible", options:{baseURL:"https://api.x.ai/v1", apiKey:$xkey}, models:$xai} }, permission: $perm, mcp: $mcp