From 55e00871f9aad722d71f6933a8a6203e8210a850 Mon Sep 17 00:00:00 2001 From: senior Date: Fri, 17 Jul 2026 09:03:03 +0000 Subject: [PATCH] feat(agents): wire xAI provider, move @lead to xai/grok-4.5 (issue #12) Add an xai provider (OpenAI-compatible, https://api.x.ai/v1) to install-opencode.sh, with its models map derived from agents.json exactly like the ollama providers. Pass XAI_API_KEY into both the Install-opencode and Run-agent steps of agent.yml. Switch @lead's model from anthropic/claude-opus-4-8 to xai/grok-4.5 (vision-capable, so @lead keeps image reading). All other agents unchanged; ANTHROPIC_API_KEY is retained for @ops and not removed. --- .gitea/workflows/agent.yml | 2 ++ .gitea/workflows/scripts/agents.json | 2 +- .gitea/workflows/scripts/install-opencode.sh | 13 ++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index 76227ec..b82d93a 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" @@ -212,6 +213,7 @@ jobs: env: SCRIPTS: ${{ runner.temp }}/agents-scripts ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + XAI_API_KEY: ${{ secrets.XAI_API_KEY }} # SELF_TOKEN = the RUNNING agent's OWN token (TOKEN_PM for @pm, TOKEN_OPS for @ops, …). # Only this agent's token is placed in its process env, so no agent can act as another. # Powers the gitea-api / gitea-admin skills — each agent calls Gitea as itself. Every diff --git a/.gitea/workflows/scripts/agents.json b/.gitea/workflows/scripts/agents.json index 38fb05c..d675dcb 100644 --- a/.gitea/workflows/scripts/agents.json +++ b/.gitea/workflows/scripts/agents.json @@ -25,7 +25,7 @@ "desc": "Senior dev — complex, multi-file implementation (GLM-5.2 via Ollama Cloud, text-only)." }, "lead": { - "model": "anthropic/claude-opus-4-8", + "model": "xai/grok-4.5", "vision": true, "mode": "pr", "skills": [ diff --git a/.gitea/workflows/scripts/install-opencode.sh b/.gitea/workflows/scripts/install-opencode.sh index 761d57a..1bc0dc3 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 @@ -42,15 +42,18 @@ PERM=$(jq -nc --argjson s "$SKILLS" ' # 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. `anthropic/claude-opus-4-8` for @lead) are not derived here. +# provider. `xai/` prefix models go to the xAI provider (OpenAI-compatible, https://api.x.ai/v1). +# Built-in providers (e.g. `anthropic/claude-opus-4-8` for @ops) are not derived here. # 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 -- 2.54.0