Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
ship Claude Ollama provider (CLI + TUI) and deliver it to existing installs
[._.]/ Adam Eivy757e1dde8efe
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9fa4c30d77..4f6f6bd8ab 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,7 +2,7 @@## AI Providers-- **[issue-1776] Run CoS agent tasks on a local model with the new "Clawed Ollama" provider.** If your only LLM is Ollama or LM Studio, you couldn't run file-writing agent tasks — those providers return plain text with no Read/Write/Edit harness. The new **Clawed Ollama** sample provider (AI Providers → Add Sample) runs the full Claude Code harness on top of your local model: it's a `claude` CLI pre-wired to your Ollama daemon, and its **Refresh Models** pulls the installed Ollama models filtered to the **tool-use-capable** ones the agent loop depends on. The task form now offers **only coding providers** — raw Ollama / LM Studio / kimi are excluded (with an inline advisory pointing you to Clawed Ollama when they're all you have), and a server-side guard rejects an API provider that slips into the spawn path instead of silently writing nothing. Includes a copy-ready global `~/.claude/settings.json` example and a setup guide with the tool-use model caveat. (`docs/features/clawed-ollama.md`, `docs/examples/`)+- **[issue-1776] Run CoS agent tasks on a local model with the new "Claude Ollama" provider (CLI + TUI).** If your only LLM is Ollama or LM Studio, you couldn't run file-writing agent tasks — those providers return plain text with no Read/Write/Edit harness. **Claude Ollama** runs the full Claude Code harness on top of your local model: it's a `claude` CLI/TUI pre-wired to your Ollama daemon, and its **Refresh Models** pulls the installed Ollama models filtered to the **tool-use-capable** ones the agent loop depends on. It now ships in **two variants** — **Claude Ollama (local model)** (`cli`, headless) and **Claude Ollama TUI (local model)** (`tui`, interactive) — and **both arrive on the AI Providers page after `./update.sh`** (migration `146-claude-ollama-providers.js` adds them to existing installs and renames the earlier "Clawed Ollama" sample, preserving your settings; previously it lived only in the toolkit sample and never reached the merge path). The task form offers **only coding providers** — raw Ollama / LM Studio / kimi are excluded (with an inline advisory pointing you to Claude Ollama when they're all you have), and a server-side guard rejects an API provider that slips into the spawn path instead of silently writing nothing. Includes a copy-ready global `~/.claude/settings.json` example and a setup guide with the tool-use model caveat. (`data.reference/providers.json`, `server/lib/aiToolkit/`, `scripts/migrations/146-claude-ollama-providers.js`, `docs/features/claude-ollama.md`, `docs/examples/`)## Dashboarddiff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsxindex 9de7e6a772..f106fb408f 100644--- a/client/src/components/cos/TaskAddForm.jsx+++ b/client/src/components/cos/TaskAddForm.jsx@@ -72,7 +72,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa// (CLI/TUI agents with a file-writing harness). HTTP `api` providers (raw// Ollama / LM Studio / nvidia-kimi) return plain text and can't write files, so// they're not valid task runners; a user who only has those should use the- // "Clawed Ollama" sample (a `claude` CLI pointed at Ollama) instead.+ // "Claude Ollama" sample (a `claude` CLI/TUI pointed at Ollama) instead.const enabledProviders = useMemo(() =>providers?.filter(p => p.enabled && isProcessProvider(p)) || [],[providers]@@ -563,7 +563,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa</div>{apiOnlyProviders && (<div className="px-3 py-2 bg-port-warning/10 border border-port-warning/40 rounded-lg text-xs text-port-warning">- Your enabled providers (Ollama / LM Studio) are HTTP API providers with no file-writing harness, so they can't run agent tasks. Add the <span className="font-semibold">Clawed Ollama</span> sample provider (a <code>claude</code> CLI pointed at your local model) from AI Providers → Add Sample to run file-writing tasks on a local model.+ Your enabled providers (Ollama / LM Studio) are HTTP API providers with no file-writing harness, so they can't run agent tasks. Add the <span className="font-semibold">Claude Ollama</span> sample provider (a <code>claude</code> CLI/TUI pointed at your local model) from AI Providers → Add Sample to run file-writing tasks on a local model.</div>)}{/* Screenshot and Attachment Upload */}diff --git a/data.reference/providers.json b/data.reference/providers.jsonindex 4028c8b66d..097378081f 100644--- a/data.reference/providers.json+++ b/data.reference/providers.json@@ -35,6 +35,25 @@},"secretEnvVars": ["AWS_BEARER_TOKEN_BEDROCK"]},+ "claude-ollama": {+ "id": "claude-ollama",+ "name": "Claude Ollama (local model)",+ "type": "cli",+ "command": "claude",+ "args": ["--print"],+ "models": [],+ "defaultModel": null,+ "ollamaBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "ANTHROPIC_BASE_URL": "http://localhost:11434",+ "ANTHROPIC_AUTH_TOKEN": "ollama",+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen2.5:7b"+ },+ "secretEnvVars": [],+ "headlessArgs": ["--no-session-persistence", "--disable-slash-commands", "--tools", ""]+ },"codex": {"id": "codex","name": "Codex CLI",@@ -117,6 +136,26 @@"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000},+ "claude-ollama-tui": {+ "id": "claude-ollama-tui",+ "name": "Claude Ollama TUI (local model)",+ "type": "tui",+ "command": "claude",+ "args": ["--dangerously-skip-permissions"],+ "models": [],+ "defaultModel": null,+ "ollamaBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "ANTHROPIC_BASE_URL": "http://localhost:11434",+ "ANTHROPIC_AUTH_TOKEN": "ollama",+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen2.5:7b"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"antigravity-tui": {"id": "antigravity-tui","name": "Antigravity TUI",diff --git a/docs/examples/README.md b/docs/examples/README.mdindex 5e498bcda3..2343dc1754 100644--- a/docs/examples/README.md+++ b/docs/examples/README.md@@ -19,14 +19,14 @@ keeping the full Read/Write/Edit/Bash tool harness.- **Global (`~/.claude/settings.json`)** — copy this file's `env` block in. The stock`claude-code` provider in PortOS then works as-is, with no custom provider. Downside:it routes *all* local `claude` usage (interactive too) through Ollama.-- **Scoped (recommended)** — add the **Clawed Ollama** sample provider in PortOS- (AI Providers → Add Sample). It carries the same env *per provider*, so you keep- cloud Claude and a local-model option side by side and pick per task. See- [docs/features/clawed-ollama.md](../features/clawed-ollama.md).+- **Scoped (recommended)** — use the **Claude Ollama** provider in PortOS (shipped on+ the AI Providers page; CLI and TUI variants). It carries the same env *per provider*,+ so you keep cloud Claude and a local-model option side by side and pick per task. See+ [docs/features/claude-ollama.md](../features/claude-ollama.md).> ⚠️ **Tool-use caveat.** The agent harness depends on reliable tool-calling. Small> generic models (Mistral 7B, base Llama, etc.) "run" but fail ~35–85% of tool calls> and silently stop writing files. Use a tool-capable model — **Qwen 2.5/3, Llama> 3.1+, Mistral Small 24B, GLM-4, Granite 3, gpt-oss**. Q4_K_M is the practical quant-> floor. The Clawed Ollama provider's model refresh filters its list to tool-capable+> floor. The Claude Ollama provider's model refresh filters its list to tool-capable> models for you.diff --git a/docs/features/clawed-ollama.md b/docs/features/claude-ollama.mdsimilarity index 66%rename from docs/features/clawed-ollama.mdrename to docs/features/claude-ollama.mdindex 6da4c5625c..bd95d185b8 100644--- a/docs/features/clawed-ollama.md+++ b/docs/features/claude-ollama.md@@ -1,8 +1,14 @@-# Clawed Ollama — run CoS agent tasks on a local model+# Claude Ollama — run CoS agent tasks on a local model-**Clawed Ollama** lets a user whose only LLM is **Ollama / LM Studio** run+**Claude Ollama** lets a user whose only LLM is **Ollama / LM Studio** runfile-writing **CoS agent tasks** — create/edit files, run tests, ship a PR — by-running the **Claude Code harness on top of a local model**.+running the **Claude Code harness on top of a local model**. It ships in two+variants:++- **Claude Ollama (local model)** — a `cli` provider (`claude --print`), headless.+- **Claude Ollama TUI (local model)** — a `tui` provider+ (`claude --dangerously-skip-permissions`), the interactive harness CoS agents+ drive in TUI mode.## Why a special provider?@@ -17,9 +23,9 @@ PortOS has two provider classes:Claude Code's harness is **independent of which model serves tokens**. Point the`claude` CLI at a local model via `ANTHROPIC_BASE_URL` and you keep the *entire*-file-editing harness while Ollama does the generation. **Clawed Ollama** is exactly-that: a `cli` provider (`command: claude`) whose `envVars` route Claude Code to your-Ollama daemon, with its model list pulled live from Ollama.+file-editing harness while Ollama does the generation. **Claude Ollama** is exactly+that: a `claude` CLI/TUI provider whose `envVars` route Claude Code to your Ollama+daemon, with its model list pulled live from Ollama.## Setup@@ -28,17 +34,20 @@ Ollama daemon, with its model list pulled live from Ollama.2. **Run Ollama ≥ 0.14** (locally or on a remote box) — it natively serves theAnthropic Messages API, so no proxy is needed. (LM Studio / vLLM / older Ollama:put **LiteLLM** in front to translate Anthropic ↔ OpenAI.)-3. **Add the sample provider** — in PortOS, **AI Providers → Add Sample → "Clawed- Ollama (local model)"**. Edit `ANTHROPIC_BASE_URL` if your Ollama isn't on- `localhost:11434` (e.g. `http://<remote-host>:11434`).+3. **Pick a variant** — after `./update.sh`, both **Claude Ollama (local model)**+ (CLI) and **Claude Ollama TUI (local model)** appear on the **AI Providers** page.+ (On older installs you can also adopt them via **Add Sample**.) Edit+ `ANTHROPIC_BASE_URL` if your Ollama isn't on `localhost:11434`+ (e.g. `http://<remote-host>:11434`).4. **Refresh models** — hit the provider's **Refresh Models** button. PortOS pulls theinstalled Ollama models and **keeps only the tool-use-capable ones** (the harness- depends on reliable tool-calling), then pick a default.-5. **Run a task** — set Clawed Ollama as the active provider (or pin it per task) and+ depends on reliable tool-calling), then pick a default. This works for both the CLI+ and TUI variant.+5. **Run a task** — set Claude Ollama as the active provider (or pin it per task) andcreate a CoS agent task. It now writes files and ships a PR backed by your local model.-The provider is `enabled: false` by default — adopting the sample doesn't change your-active provider until you choose it.+Both providers are `enabled: false` by default — adopting them doesn't change your+active provider until you choose one.## Coding-task restrictions@@ -48,7 +57,7 @@ active provider until you choose it.- A server-side guard in `agentProviderResolution` rejects an `api` provider thatreaches the spawn path (via a task pin or the fallback chain) with a clear error,rather than spawning a child process that can't write files.-- Clawed Ollama's model list is filtered to **tool-use-capable** models (Qwen 2.5/3,+- Claude Ollama's model list is filtered to **tool-use-capable** models (Qwen 2.5/3,Llama 3.1+, Mistral/Mixtral, Cohere Command, GLM-4, Granite 3, gpt-oss, Hermes, …).## ⚠️ Tool-use caveatdiff --git a/docs/features/cos-agent-runner.md b/docs/features/cos-agent-runner.mdindex 5c7ed4a144..ca73fa2784 100644--- a/docs/features/cos-agent-runner.md+++ b/docs/features/cos-agent-runner.md@@ -43,4 +43,4 @@ A separate `portos-cos` PM2 process that:- [Chief of Staff](./chief-of-staff.md) - Main orchestration system- [Error Handling](./error-handling.md) - Agent error recovery-- [Clawed Ollama](./clawed-ollama.md) - Run agent tasks on a local Ollama/LM Studio model+- [Claude Ollama](./claude-ollama.md) - Run agent tasks on a local Ollama/LM Studio modeldiff --git a/scripts/migrations/146-claude-ollama-providers.js b/scripts/migrations/146-claude-ollama-providers.jsnew file mode 100644index 0000000000..f886e307e4--- /dev/null+++ b/scripts/migrations/146-claude-ollama-providers.js@@ -0,0 +1,148 @@+/**+ * Ship the "Claude Ollama" provider pair (CLI + TUI) to existing installs, and+ * rename the earlier "Clawed Ollama" sample to "Claude Ollama".+ *+ * Background: issue-1776 (commit b2c0a4931) added a `clawed-ollama` sample —+ * a `claude` CLI pre-wired to a local Ollama daemon so api-only users can run+ * file-writing CoS agent tasks on a local model. But it was added ONLY to the+ * aiToolkit sample file, never to `data.reference/providers.json`, so the+ * `setup-data.js` merge (which only knows about data.reference) never delivered+ * it on `./update.sh` — existing installs never saw it. The name was also a pun+ * users found confusing; the canonical name is now "Claude Ollama".+ *+ * This migration:+ * 1. Promotes an existing `clawed-ollama` provider to `claude-ollama`,+ * preserving the user's customizations (enabled flag, refreshed model+ * list, edited envVars, etc.). The user's config wins even if the fresh+ * `claude-ollama` default was already merged in by setup-data this run.+ * Default-name "Clawed Ollama (local model)" → "Claude Ollama (local model)".+ * 2. Rewrites `activeProvider` + any `fallbackProvider` references pointing at+ * the retired `clawed-ollama` id.+ * 3. Adds the shipped `claude-ollama` (cli) and `claude-ollama-tui` (tui)+ * providers when missing — so a plain server restart delivers them even+ * without a setup-data merge, and so installs that never had clawed get+ * both variants. Idempotent: existing keys are left untouched.+ *+ * `setup-data.js` merges *missing* provider entries but never renames or updates+ * existing ones, so deployed installs need this migration to pick up the rename.+ */++import { readFile, writeFile } from 'fs/promises';+import { join } from 'path';++const PROVIDERS_REL_PATH = 'data/providers.json';++const OLD_ID = 'clawed-ollama';+const NEW_ID = 'claude-ollama';+const TUI_ID = 'claude-ollama-tui';++const OLD_DEFAULT_NAME = 'Clawed Ollama (local model)';+const NEW_DEFAULT_NAME = 'Claude Ollama (local model)';++// Shipped definitions — kept in lockstep with data.reference/providers.json and+// server/lib/aiToolkit/defaults/providers.sample.json. Frozen here as the+// historical record this migration installs; later default changes ride their+// own migrations rather than mutating this one.+const CLAUDE_OLLAMA_CLI = {+ id: NEW_ID,+ name: NEW_DEFAULT_NAME,+ type: 'cli',+ command: 'claude',+ args: ['--print'],+ models: [],+ defaultModel: null,+ ollamaBacked: true,+ timeout: 600000,+ enabled: false,+ envVars: {+ ANTHROPIC_BASE_URL: 'http://localhost:11434',+ ANTHROPIC_AUTH_TOKEN: 'ollama',+ ANTHROPIC_SMALL_FAST_MODEL: 'qwen2.5:7b',+ },+ secretEnvVars: [],+ headlessArgs: ['--no-session-persistence', '--disable-slash-commands', '--tools', ''],+};++const CLAUDE_OLLAMA_TUI = {+ id: TUI_ID,+ name: 'Claude Ollama TUI (local model)',+ type: 'tui',+ command: 'claude',+ args: ['--dangerously-skip-permissions'],+ models: [],+ defaultModel: null,+ ollamaBacked: true,+ timeout: 600000,+ enabled: false,+ envVars: {+ ANTHROPIC_BASE_URL: 'http://localhost:11434',+ ANTHROPIC_AUTH_TOKEN: 'ollama',+ ANTHROPIC_SMALL_FAST_MODEL: 'qwen2.5:7b',+ },+ secretEnvVars: [],+ tuiPromptDelayMs: 2500,+ tuiIdleTimeoutMs: 180000,+};++export default {+ async up({ rootDir }) {+ const providersPath = join(rootDir, PROVIDERS_REL_PATH);+ const raw = await readFile(providersPath, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (raw == null) {+ console.log(`📄 ${PROVIDERS_REL_PATH} not present — skipping (fresh install seeds Claude Ollama from data.reference)`);+ return;+ }++ let config;+ try {+ config = JSON.parse(raw);+ } catch (err) {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: invalid JSON, skipping (${err.message})`);+ return;+ }++ if (!config || typeof config !== 'object' || !config.providers || typeof config.providers !== 'object') {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: unexpected shape, skipping`);+ return;+ }++ const providers = config.providers;+ let changed = false;++ // 1. Promote an existing clawed-ollama to claude-ollama, preserving the+ // user's config (it wins over any fresh default merged in this run).+ const clawed = providers[OLD_ID];+ if (clawed) {+ const promoted = { ...clawed, id: NEW_ID };+ if (promoted.name === OLD_DEFAULT_NAME) promoted.name = NEW_DEFAULT_NAME;+ providers[NEW_ID] = promoted;+ delete providers[OLD_ID];++ if (config.activeProvider === OLD_ID) config.activeProvider = NEW_ID;+ for (const p of Object.values(providers)) {+ if (p && p.fallbackProvider === OLD_ID) p.fallbackProvider = NEW_ID;+ }+ changed = true;+ console.log(`📝 ${PROVIDERS_REL_PATH}: renamed ${OLD_ID} → ${NEW_ID} (preserving your settings)`);+ }++ // 2. Add the shipped CLI + TUI providers when missing (idempotent).+ for (const def of [CLAUDE_OLLAMA_CLI, CLAUDE_OLLAMA_TUI]) {+ if (!providers[def.id]) {+ providers[def.id] = { ...def };+ changed = true;+ console.log(`📝 ${PROVIDERS_REL_PATH}: added ${def.id} provider`);+ }+ }++ if (!changed) {+ console.log(`✅ ${PROVIDERS_REL_PATH}: Claude Ollama providers already present — no change`);+ return;+ }++ await writeFile(providersPath, `${JSON.stringify(config, null, 2)}\n`);+ },+};diff --git a/scripts/migrations/146-claude-ollama-providers.test.js b/scripts/migrations/146-claude-ollama-providers.test.jsnew file mode 100644index 0000000000..3c08cf3d44--- /dev/null+++ b/scripts/migrations/146-claude-ollama-providers.test.js@@ -0,0 +1,159 @@+/**+ * Test for migration 146 — rename clawed-ollama → claude-ollama and add the+ * Claude Ollama CLI + TUI shipped providers. Picked up by server/vitest.config.js's+ * `../scripts/**\/*.test.js` glob.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import migration from './146-claude-ollama-providers.js';++const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++const clawed = (overrides = {}) => ({+ id: 'clawed-ollama',+ name: 'Clawed Ollama (local model)',+ type: 'cli',+ command: 'claude',+ args: ['--print'],+ models: [],+ defaultModel: null,+ ollamaBacked: true,+ enabled: false,+ envVars: { ANTHROPIC_BASE_URL: 'http://localhost:11434', ANTHROPIC_AUTH_TOKEN: 'ollama' },+ ...overrides,+});++describe('migration 146 — Claude Ollama providers', () => {+ let rootDir;+ let providersPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-146-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ providersPath = join(rootDir, 'data/providers.json');+ });++ afterEach(() => {+ rmSync(rootDir, { recursive: true, force: true });+ });++ it('renames clawed-ollama → claude-ollama, preserving customizations', async () => {+ writeJson(providersPath, {+ activeProvider: 'clawed-ollama',+ providers: {+ 'clawed-ollama': clawed({ enabled: true, models: ['qwen2.5:7b'], defaultModel: 'qwen2.5:7b' }),+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ expect(out.providers['clawed-ollama']).toBeUndefined();+ const claude = out.providers['claude-ollama'];+ expect(claude.id).toBe('claude-ollama');+ expect(claude.name).toBe('Claude Ollama (local model)');+ // user customizations preserved+ expect(claude.enabled).toBe(true);+ expect(claude.models).toEqual(['qwen2.5:7b']);+ expect(claude.defaultModel).toBe('qwen2.5:7b');+ // activeProvider reference rewritten+ expect(out.activeProvider).toBe('claude-ollama');+ // TUI variant added+ expect(out.providers['claude-ollama-tui']).toBeDefined();+ expect(out.providers['claude-ollama-tui'].type).toBe('tui');+ });++ it('keeps a user-customized provider name but still renames the id', async () => {+ writeJson(providersPath, {+ providers: { 'clawed-ollama': clawed({ name: 'My Local Beast' }) },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ expect(out.providers['claude-ollama'].name).toBe('My Local Beast');+ });++ it('rewrites fallbackProvider references off the retired id', async () => {+ writeJson(providersPath, {+ providers: {+ 'clawed-ollama': clawed(),+ 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude', fallbackProvider: 'clawed-ollama' },+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ expect(out.providers['claude-code'].fallbackProvider).toBe('claude-ollama');+ });++ it('prefers the user clawed config over a fresh-merged default claude-ollama', async () => {+ // Simulates the update.sh order: setup-data merged the default claude-ollama+ // BEFORE this migration runs, while the user still has their old clawed one.+ writeJson(providersPath, {+ providers: {+ 'clawed-ollama': clawed({ enabled: true, models: ['qwen2.5:7b'] }),+ 'claude-ollama': { ...clawed({ id: 'claude-ollama', name: 'Claude Ollama (local model)' }) },+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ expect(out.providers['clawed-ollama']).toBeUndefined();+ // the user's real (enabled, model-populated) config wins+ expect(out.providers['claude-ollama'].enabled).toBe(true);+ expect(out.providers['claude-ollama'].models).toEqual(['qwen2.5:7b']);+ });++ it('adds both shipped providers to an install that never had clawed', async () => {+ writeJson(providersPath, {+ activeProvider: 'claude-code',+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ const cli = out.providers['claude-ollama'];+ const tui = out.providers['claude-ollama-tui'];+ expect(cli.type).toBe('cli');+ expect(cli.ollamaBacked).toBe(true);+ expect(cli.envVars.ANTHROPIC_BASE_URL).toBe('http://localhost:11434');+ expect(tui.type).toBe('tui');+ expect(tui.args).toEqual(['--dangerously-skip-permissions']);+ expect(tui.ollamaBacked).toBe(true);+ // unrelated providers untouched, active provider preserved+ expect(out.activeProvider).toBe('claude-code');+ });++ it('is idempotent — a second run makes no changes', async () => {+ writeJson(providersPath, {+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },+ });++ await migration.up({ rootDir });+ const afterFirst = readFileSync(providersPath, 'utf-8');+ await migration.up({ rootDir });+ expect(readFileSync(providersPath, 'utf-8')).toBe(afterFirst);+ });++ it('is a no-op when data/providers.json does not exist (fresh install)', async () => {+ await migration.up({ rootDir });+ expect(existsSync(providersPath)).toBe(false);+ });++ it('does not modify the file on invalid JSON', async () => {+ writeFileSync(providersPath, '{ not valid json');+ const before = readFileSync(providersPath, 'utf-8');++ await migration.up({ rootDir });++ expect(readFileSync(providersPath, 'utf-8')).toBe(before);+ });+});diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.jsonindex 80b33fbe37..415a52b1b1 100644--- a/server/lib/aiToolkit/defaults/providers.sample.json+++ b/server/lib/aiToolkit/defaults/providers.sample.json@@ -38,9 +38,9 @@"secretEnvVars": ["AWS_BEARER_TOKEN_BEDROCK"],"headlessArgs": ["--no-session-persistence", "--disable-slash-commands", "--tools", ""]},- "clawed-ollama": {- "id": "clawed-ollama",- "name": "Clawed Ollama (local model)",+ "claude-ollama": {+ "id": "claude-ollama",+ "name": "Claude Ollama (local model)","type": "cli","command": "claude","args": ["--print"],@@ -57,6 +57,26 @@"secretEnvVars": [],"headlessArgs": ["--no-session-persistence", "--disable-slash-commands", "--tools", ""]},+ "claude-ollama-tui": {+ "id": "claude-ollama-tui",+ "name": "Claude Ollama TUI (local model)",+ "type": "tui",+ "command": "claude",+ "args": ["--dangerously-skip-permissions"],+ "models": [],+ "defaultModel": null,+ "ollamaBacked": true,+ "timeout": 600000,+ "enabled": false,+ "envVars": {+ "ANTHROPIC_BASE_URL": "http://localhost:11434",+ "ANTHROPIC_AUTH_TOKEN": "ollama",+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen2.5:7b"+ },+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000+ },"codex": {"id": "codex","name": "Codex CLI",diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.jsindex 7ed53efa7e..21f3a4a4cd 100644--- a/server/lib/aiToolkit/providers.js+++ b/server/lib/aiToolkit/providers.js@@ -39,7 +39,7 @@ const TOOL_USE_RE = new RegExp([].join('|'), 'i');/**- * A CLI provider (command `claude`) is "Ollama-backed" — the Clawed Ollama+ * A `claude` CLI/TUI provider is "Ollama-backed" — the Claude Ollama* pattern — when it carries the `ollamaBacked` marker or its ANTHROPIC_BASE_URL* points at an Ollama daemon. Such a provider runs the full Claude Code harness* but generates tokens from a local model, so its model list must come from@@ -374,7 +374,7 @@ export function createProviderService(config = {}) {contextWindow: providerData.contextWindow || null,timeout: providerData.timeout || 300000,enabled: providerData.enabled !== false,- // Clawed Ollama marker — preserve so adopting the sample via POST drives+ // Claude Ollama marker — preserve so adopting the sample via POST drives// ollama-backed model refresh (see isOllamaBackedProvider)....(providerData.ollamaBacked === true ? { ollamaBacked: true } : {}),envVars: providerData.envVars || {},@@ -498,6 +498,11 @@ export function createProviderService(config = {}) {models = await this._refreshAPIProviderModels(provider);} else if (provider.type === 'cli') {models = await this._refreshCLIProviderModels(provider);+ } else if (provider.type === 'tui' && isOllamaBackedProvider(provider)) {+ // TUI providers normally don't refresh (their model is fixed by the+ // CLI/config), but the Claude-Ollama TUI variant still needs its+ // tool-use-capable Ollama model list pulled live, same as the CLI one.+ models = await this._fetchOllamaToolCapableModels(provider);}} catch (error) {console.error(`Failed to refresh models for ${provider.name}:`, error.message);@@ -560,7 +565,7 @@ export function createProviderService(config = {}) {async _refreshCLIProviderModels(provider) {const providerName = provider.name.toLowerCase();- // Clawed Ollama: a `claude` CLI pointed at a local Ollama daemon. Pull the+ // Claude Ollama: a `claude` CLI pointed at a local Ollama daemon. Pull the// installed Ollama models (filtered to tool-use-capable ones — the agent// harness depends on reliable tool-calling) instead of the static Anthropic// list. Checked BEFORE the generic claude branch below.diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.jsindex a1530ef7f0..e2d0ded9c8 100644--- a/server/lib/aiToolkit/providers.test.js+++ b/server/lib/aiToolkit/providers.test.js@@ -593,7 +593,7 @@ describe('Provider Service', () => {});});- describe('Clawed Ollama (ollama-backed CLI) model refresh', () => {+ describe('Claude Ollama (ollama-backed) model refresh', () => {afterEach(() => {vi.unstubAllGlobals();});@@ -622,7 +622,7 @@ describe('Provider Service', () => {});const p = await providerService.createProvider({- name: 'Clawed Ollama (local model)',+ name: 'Claude Ollama (local model)',type: 'cli',command: 'claude',ollamaBacked: true,@@ -638,7 +638,7 @@ describe('Provider Service', () => {stubOllama(['qwen2.5:7b', 'gemma2:9b'], {}); // no capabilities reported for anyconst p = await providerService.createProvider({- name: 'Clawed Ollama',+ name: 'Claude Ollama',type: 'cli',command: 'claude',envVars: { ANTHROPIC_BASE_URL: 'http://127.0.0.1:11434' },@@ -648,6 +648,39 @@ describe('Provider Service', () => {// qwen matches the tool-use heuristic; gemma2 does not.expect(updated.models).toEqual(['qwen2.5:7b']);});++ it('refreshes models for an ollama-backed TUI provider too', async () => {+ stubOllama(['qwen2.5:7b', 'gemma2:9b'], {+ 'qwen2.5:7b': ['completion', 'tools'],+ 'gemma2:9b': ['completion', 'vision'],+ });++ const p = await providerService.createProvider({+ name: 'Claude Ollama TUI (local model)',+ type: 'tui',+ command: 'claude',+ ollamaBacked: true,+ envVars: { ANTHROPIC_BASE_URL: 'http://localhost:11434', ANTHROPIC_AUTH_TOKEN: 'ollama' },+ });++ const updated = await providerService.refreshProviderModels(p.id);+ expect(updated).not.toBeNull();+ expect(updated.models).toEqual(['qwen2.5:7b']);+ });++ it('does not refresh a non-ollama-backed TUI provider (returns null)', async () => {+ // A plain claude TUI provider has no Ollama backing — refresh is a no-op+ // for tui type, so it returns null (models left as configured).+ const p = await providerService.createProvider({+ name: 'Claude Code TUI',+ type: 'tui',+ command: 'claude',+ models: ['claude-opus-4-8'],+ });++ const updated = await providerService.refreshProviderModels(p.id);+ expect(updated).toBeNull();+ });});describe('_refreshAPIProviderModels — network layer', () => {diff --git a/server/lib/aiToolkit/validation.js b/server/lib/aiToolkit/validation.jsindex ec068fd1fc..f3cfb9a1bd 100644--- a/server/lib/aiToolkit/validation.js+++ b/server/lib/aiToolkit/validation.js@@ -34,8 +34,8 @@ export const providerSchema = z.object({contextWindow: z.number().int().min(512).max(2097152).nullable().optional(),timeout: z.number().int().min(1000).max(1800000).optional(),enabled: z.boolean().optional(),- // Marks a CLI provider (command `claude`) whose ANTHROPIC_BASE_URL points at a- // local Ollama daemon — the "Clawed Ollama" pattern. Drives model refresh to+ // Marks a `claude` CLI/TUI provider whose ANTHROPIC_BASE_URL points at a+ // local Ollama daemon — the "Claude Ollama" pattern. Drives model refresh to// pull tool-use-capable Ollama models instead of the static Anthropic list.ollamaBacked: z.boolean().optional(),envVars: z.record(z.string()).optional(),diff --git a/server/lib/localModelHeuristics.js b/server/lib/localModelHeuristics.jsindex 7fb04e91ed..c8deacc71c 100644--- a/server/lib/localModelHeuristics.js+++ b/server/lib/localModelHeuristics.js@@ -110,7 +110,7 @@ export function isVisionModel(model) {// Tool-use (function-calling) capable model families. The CoS agent harness// (Read/Write/Edit/Bash + the agent loop) depends entirely on reliable-// tool-calling, so a Claude-on-Ollama ("Clawed Ollama") provider must only+// tool-calling, so a Claude-on-Ollama ("Claude Ollama") provider must only// surface models that can actually drive tools. Ollama's /api/show reports a// `tools` capability that is authoritative when present — this id regex is the// fallback for bare model-id strings (e.g. LM Studio, or a stored providerdiff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.jsindex 8dca0e6d05..7a8212b778 100644--- a/server/services/agentProviderResolution.js+++ b/server/services/agentProviderResolution.js@@ -95,12 +95,12 @@ export async function resolveAgentProviderAndModel(task) {// child process that writes nothing to disk. Fail clearly instead. This catches// an api provider arriving via a task pin OR via the fallback chain (the default// fallback priority includes lmstudio/ollama). The fix for users: add a CLI- // coding provider — e.g. the "Clawed Ollama" sample (a `claude` CLI pointed at+ // coding provider — e.g. the "Claude Ollama" sample (a `claude` CLI/TUI pointed at// Ollama) gives the full file-writing harness on a local model.if (provider.type === 'api') {return {ok: false,- error: `Provider "${provider.id}" is an HTTP API provider with no file-writing harness — CoS agent tasks need a CLI/TUI coding provider (claude, codex, or the "Clawed Ollama" Claude-on-Ollama sample).`,+ error: `Provider "${provider.id}" is an HTTP API provider with no file-writing harness — CoS agent tasks need a CLI/TUI coding provider (claude, codex, or the "Claude Ollama" Claude-on-Ollama sample).`,providerId: provider.id};}