From 8c17aed1fc26fd6913edb3bc3eafb9aa13fc506f Mon Sep 17 00:00:00 2001 From: senior Date: Sat, 4 Jul 2026 07:12:15 +0000 Subject: [PATCH 1/2] =?UTF-8?q?@senior:=20issue=20#29=20=E2=80=94=20derive?= =?UTF-8?q?=20Ollama=20Cloud=20provider=20models=20from=20the=20agent=20re?= =?UTF-8?q?gistry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The agent→model registry in route.sh is now the single source of truth for Ollama Cloud model IDs. route.sh publishes the full registry as a step output (agents=...), and install-opencode.sh derives the ollama-cloud provider models: map from it (unprefixed IDs), instead of hardcoding a second copy. The two files can no longer drift silently — adding/changing a cloud model in the registry automatically updates the provider config. - route.sh: emit agents=$(jq -c '.' /tmp/agents.json) to GITHUB_OUTPUT - agent.yml: pass steps.prep.outputs.agents as AGENTS env to install-opencode.sh - install-opencode.sh: derive CMODELS from $AGENTS; // {} keeps it valid when no agent uses an ollama-cloud model (non-ollama repos) --- .gitea/workflows/agent.yml | 1 + .gitea/workflows/scripts/install-opencode.sh | 14 ++++++++++---- .gitea/workflows/scripts/route.sh | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index 0d41bc1..17842df 100644 --- a/.gitea/workflows/agent.yml +++ b/.gitea/workflows/agent.yml @@ -78,6 +78,7 @@ jobs: OLLAMA_CLOUD_API_KEY: ${{ secrets.OLLAMA_CLOUD_API_KEY }} NAME: ${{ steps.prep.outputs.name }} SKILLS: ${{ steps.prep.outputs.skills }} # JSON array of skills this agent may load + AGENTS: ${{ steps.prep.outputs.agents }} # full agent registry — single source of truth for model IDs run: bash "$SCRIPTS/install-opencode.sh" - name: Set up read-only SSH alias `node1` (+ opencode skill so the agent actually knows about it) diff --git a/.gitea/workflows/scripts/install-opencode.sh b/.gitea/workflows/scripts/install-opencode.sh index a026875..2758aea 100755 --- a/.gitea/workflows/scripts/install-opencode.sh +++ b/.gitea/workflows/scripts/install-opencode.sh @@ -2,7 +2,7 @@ # 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 +# AGENTS GITHUB_PATH HOME set -eu curl -fsSL https://opencode.ai/install | bash @@ -27,11 +27,17 @@ 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). -jq -n --argjson mcp "$MCP" --argjson perm "$PERM" --arg url "$OLLAMA_URL" --arg ckey "$OLLAMA_CLOUD_API_KEY" '{ +# Derive the Ollama Cloud `models:` map from the agent registry itself — single source of truth, +# so the provider config and the agent→model mapping in route.sh can't drift. Registry model IDs +# are prefixed `ollama-cloud/...`; the provider's are the unprefixed IDs. `// {}` keeps it valid +# JSON when no agent uses an ollama-cloud model (e.g. a repo where every agent is anthropic/*). +AGENTS="${AGENTS:-{}}" +CMODELS=$(printf '%s' "$AGENTS" | jq -c '([.[].model | select(startswith("ollama-cloud/")) | sub("^ollama-cloud/";"")] | unique | map({(.):{}}) | add) // {}') +# Two ollama providers: local self-hosted (ornith) + Ollama Cloud (derived above). +jq -n --argjson mcp "$MCP" --argjson perm "$PERM" --argjson cmodels "$CMODELS" --arg url "$OLLAMA_URL" --arg ckey "$OLLAMA_CLOUD_API_KEY" '{ provider: { ollama: {npm:"@ai-sdk/openai-compatible", options:{baseURL:($url+"/v1")}, models:{"ornith:35b":{}}}, - "ollama-cloud": {npm:"@ai-sdk/openai-compatible", options:{baseURL:"https://ollama.com/v1", apiKey:$ckey}, models:{"glm-5.2:cloud":{},"gemma4:cloud":{},"kimi-k2.7-code:cloud":{},"minimax-m3:cloud":{}}} + "ollama-cloud": {npm:"@ai-sdk/openai-compatible", options:{baseURL:"https://ollama.com/v1", apiKey:$ckey}, models:$cmodels} }, permission: $perm, mcp: $mcp diff --git a/.gitea/workflows/scripts/route.sh b/.gitea/workflows/scripts/route.sh index 7237d46..fff8664 100755 --- a/.gitea/workflows/scripts/route.sh +++ b/.gitea/workflows/scripts/route.sh @@ -43,6 +43,9 @@ mode=$(jq -r --arg a "$name" '.[$a].mode' /tmp/agents.json) skills=$(jq -c --arg a "$name" '.[$a].skills // []' /tmp/agents.json) echo "Routing to @$name (model=$model vision=$vision mode=$mode skills=$skills)" { echo "name=$name"; echo "model=$model"; echo "vision=$vision"; echo "mode=$mode"; echo "skills=$skills"; } >> "$GITHUB_OUTPUT" +# Publish the full agent registry so install-opencode.sh can derive the provider `models:` map +# from it — single source of truth for Ollama Cloud model IDs, so the two files can't drift. +echo "agents=$(jq -c '.' /tmp/agents.json)" >> "$GITHUB_OUTPUT" # Act as the agent's own Gitea user when its token is set; else the built-in bot. case "$name" in -- 2.54.0 From 1a43d6f5077b7bcd681f4af06228c4453b3cf798 Mon Sep 17 00:00:00 2001 From: senior Date: Sat, 4 Jul 2026 07:12:18 +0000 Subject: [PATCH 2/2] @senior: issue #29 --- .agents-workflow | 1 + 1 file changed, 1 insertion(+) create mode 160000 .agents-workflow diff --git a/.agents-workflow b/.agents-workflow new file mode 160000 index 0000000..b3deee7 --- /dev/null +++ b/.agents-workflow @@ -0,0 +1 @@ +Subproject commit b3deee74125b632249a680d0040dafd36c85eb44 -- 2.54.0