Skip to content

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

feat([issue-4777]): seed Claude Code providers against SGLang's Anthropic Messages API

[._.]/ Adam Eivy88b63f6e984e
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 3d30a152ba..15c1fae38c 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -935,7 +935,8 @@ describe('supportsModelRefresh', () => {
// have a usable fetcher or stay out of this list.
expect(withButton).toEqual([
'antigravity-cli', 'antigravity-tui', 'cerebras', 'claude-code',
- 'claude-code-bedrock', 'claude-ollama', 'claude-ollama-tui', 'cursor-cli',
+ 'claude-code-bedrock', 'claude-ollama', 'claude-ollama-tui',
+ 'claude-sglang', 'claude-sglang-tui', 'cursor-cli',
'cursor-tui', 'grok', 'lmstudio', 'mtplx', 'nvidia-kimi', 'ollama',
'opencode-llama-tui',
'opencode-mtplx', 'opencode-mtplx-tui', 'opencode-ollama',
diff --git a/data.reference/providers.json b/data.reference/providers.json
index c937bbb43e..c106513f8a 100644
--- a/data.reference/providers.json
+++ b/data.reference/providers.json
@@ -327,6 +327,61 @@
"tuiPromptDelayMs": 2500,
"tuiIdleTimeoutMs": 180000
},
+ "claude-sglang": {
+ "id": "claude-sglang",
+ "name": "Claude SGLang (Qwen3.8-27B)",
+ "type": "cli",
+ "command": "claude",
+ "args": ["--print"],
+ "endpoint": "http://127.0.0.1:18021/v1",
+ "apiKey": "",
+ "models": ["qwen3.8-27b"],
+ "defaultModel": "qwen3.8-27b",
+ "sglangBacked": true,
+ "timeout": 600000,
+ "enabled": false,
+ "envVars": {
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:18021",
+ "ANTHROPIC_AUTH_TOKEN": "sglang",
+ "API_TIMEOUT_MS": "3000000",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
+ "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.8-27b"
+ },
+ "secretEnvVars": ["ANTHROPIC_AUTH_TOKEN"],
+ "headlessArgs": ["--no-session-persistence", "--disable-slash-commands", "--tools", ""]
+ },
+ "claude-sglang-tui": {
+ "id": "claude-sglang-tui",
+ "name": "Claude SGLang TUI (Qwen3.8-27B)",
+ "type": "tui",
+ "command": "claude",
+ "args": ["--dangerously-skip-permissions"],
+ "endpoint": "http://127.0.0.1:18021/v1",
+ "apiKey": "",
+ "models": ["qwen3.8-27b"],
+ "defaultModel": "qwen3.8-27b",
+ "sglangBacked": true,
+ "timeout": 600000,
+ "enabled": false,
+ "envVars": {
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:18021",
+ "ANTHROPIC_AUTH_TOKEN": "sglang",
+ "API_TIMEOUT_MS": "3000000",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
+ "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.8-27b"
+ },
+ "secretEnvVars": ["ANTHROPIC_AUTH_TOKEN"],
+ "tuiPromptDelayMs": 2500,
+ "tuiIdleTimeoutMs": 180000
+ },
"orcarouter": {
"id": "orcarouter",
"name": "OrcaRouter",
diff --git a/docs/features/sglang-qwen38.md b/docs/features/sglang-qwen38.md
index 5b5532c9c4..d4e9bb0a09 100644
--- a/docs/features/sglang-qwen38.md
+++ b/docs/features/sglang-qwen38.md
@@ -4,7 +4,8 @@ The third CUDA path for CoS agents, alongside the Ampere-only
[vLLM container](./qwen38-rtx3090.md) and the Apple Silicon
[MTPLX](./mtplx.md) / [DSpark](./dflash2.md) runtimes. It serves Qwen3.8-27B from
SGLang's official `lmsysorg/sglang:qwen38-27b` image on `127.0.0.1:18021`, behind
-two disabled-by-default OpenCode wrappers.
+disabled-by-default OpenCode and Claude Code wrappers — the container speaks both
+the OpenAI and the Anthropic wire protocols, so either harness can drive it.
**PortOS never starts this container, never pulls the image, and never downloads
the weights.** It holds the whole GPU, so local image/video generation cannot run
@@ -148,7 +149,7 @@ docker, refuses when the compose file is missing, and refuses when it cannot
confirm the weights are on disk. It never pulls the image and never downloads
weights.
-## Use it from an agent
+## Use it from an agent (OpenCode)
Migration `290-opencode-sglang-providers` seeds two disabled presets on
**AI Providers**:
@@ -176,6 +177,59 @@ Qwen3.8-27B has thinking **on** by default. CoS coding wants it **off** — that
what keeps the tool-call format reliable — but PortOS does not seed the setting,
so turn it off on the provider yourself.
+## Claude Code against the same container
+
+SGLang serves an **Anthropic-compatible `/v1/messages` endpoint on every server**,
+with no extra flag — the same trick Claude Ollama plays with the Ollama daemon. So
+the Claude Code harness can drive this container directly, no LiteLLM in between.
+The vLLM stack cannot: it is OpenAI-only, which is why the 3090 path stays
+OpenCode-only.
+
+Migration `291-claude-sglang-providers` seeds a second disabled pair:
+
+| Preset | Type | Command | `ANTHROPIC_BASE_URL` |
+| --- | --- | --- | --- |
+| `claude-sglang` | cli | `claude --print` | `http://127.0.0.1:18021` |
+| `claude-sglang-tui` | tui | `claude --dangerously-skip-permissions` | `http://127.0.0.1:18021` |
+
+These are **additional**, not a replacement — two harnesses over one daemon, and
+they carry `sglangBacked: true` too, so the readiness checklist, the usage/quota
+skip, and the GPU-exclusivity probe treat all four presets as the same container.
+
+### The env vars that are load-bearing
+
+- **`CLAUDE_CODE_ATTRIBUTION_HEADER=0`** — without it, Claude Code prepends a
+ per-request hash to the system prompt. That hash is the first token to differ
+ between turns, so SGLang's radix prefix cache misses and **re-prefills the whole
+ conversation on every CoS turn**. The 3090 bring-up measured a 24× TTFT
+ difference between a prefix-cache hit and a miss; this flag is what makes that
+ win reachable here. `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is a *different*
+ control and does not remove the attribution block — both are set.
+- **`ANTHROPIC_BASE_URL` is the server root**, `http://127.0.0.1:18021`, with no
+ `/v1`. The Anthropic SDK appends `/v1/messages` itself; append it yourself and
+ the server 404s in a way that reads as "model not found". The `/v1` form lives
+ on the preset's `endpoint` field, which is the OpenAI-compatible listing the
+ readiness probe hits — the two URLs are deliberately different, and swapping
+ them breaks the harness while leaving the checklist green.
+- **`ANTHROPIC_AUTH_TOKEN` must be non-empty.** SGLang accepts any value unless
+ you started it with `--api-key`, but the SDK refuses to send a request with a
+ blank one. It ships as `sglang` and is marked secret.
+- **`API_TIMEOUT_MS=3000000`** — reasoning plus a long CoS prompt runs well past
+ the SDK default.
+
+Tool calls also need **`--tool-call-parser qwen3_coder`** on the serve line (see
+[Why these flags](#why-these-flags)). Without it the schemas are accepted, the
+calls come back as raw text, and Claude Code executes nothing.
+
+**No `[1m]` suffix on the model name.** Native context is 262,144. Claiming Claude
+Code's 1M beta while the serve line does not raise `--context-length` caps the
+window incorrectly in the other direction. Every tier
+(`ANTHROPIC_DEFAULT_HAIKU_MODEL` through `_OPUS_MODEL`, plus
+`ANTHROPIC_SMALL_FAST_MODEL`) points at the one served `qwen3.8-27b`, so a
+haiku-tier sub-call cannot ask the container for a model it has never heard of.
+
+Thinking still rides Qwen's `enable_thinking`, and CoS coding still wants it off.
+
## GPU exclusivity
An enabled `sglangBacked` provider whose endpoint answers is treated as a GPU
diff --git a/scripts/migrations/291-claude-sglang-providers.js b/scripts/migrations/291-claude-sglang-providers.js
new file mode 100644
index 0000000000..cae095bbdd
--- /dev/null
+++ b/scripts/migrations/291-claude-sglang-providers.js
@@ -0,0 +1,121 @@
+/**
+ * Ship disabled Claude-Code-against-SGLang provider presets to existing installs.
+ *
+ * SGLang serves an Anthropic-compatible `/v1/messages` endpoint on every server
+ * with no extra flag, so the Claude Code harness can drive the local
+ * Qwen3.8-27B container directly — the same trick Claude Ollama plays with the
+ * Ollama daemon (migration 146). vLLM cannot do this (OpenAI-only), which is why
+ * the Ampere/3090 stack stays OpenCode-only. These presets are ADDITIONAL to the
+ * OpenCode SGLang wrappers of migration 290, not a replacement: OpenCode and
+ * Claude Code are two harnesses over one daemon, and an operator picks per task.
+ *
+ * The env set carries three things that are easy to get wrong, and all three are
+ * load-bearing:
+ *
+ * 1. `CLAUDE_CODE_ATTRIBUTION_HEADER=0` — without it Claude Code prepends a
+ * per-request hash to the system prompt. That hash is the FIRST token to
+ * differ between turns, so SGLang's radix prefix cache misses and re-prefills
+ * the entire conversation every turn. The 3090 bring-up measured a 24× TTFT
+ * difference between a prefix-cache hit and a miss. Note that
+ * `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` does NOT remove the attribution
+ * block — it is a separate flag and both are set here.
+ * 2. `ANTHROPIC_BASE_URL` is the server ROOT (`http://127.0.0.1:18021`), NOT
+ * `…/v1`. The Anthropic SDK appends `/v1/messages` itself; pointing it at
+ * `/v1` 404s in a way that reads as "model not found". The `/v1` form lives
+ * on the record's `endpoint` field instead, which is the OpenAI-compatible
+ * listing the readiness probe hits — the two URLs are deliberately different.
+ * 3. `ANTHROPIC_AUTH_TOKEN` must be non-empty. SGLang accepts any value unless
+ * the operator started it with `--api-key`, but an empty token is rejected
+ * by the SDK before a request leaves the box. It ships in `secretEnvVars`
+ * for the same reason migration 284 put Claude Ollama's there: a blank field
+ * would otherwise be indistinguishable from an ambient override.
+ *
+ * Tool calls additionally need `--tool-call-parser qwen3_coder` on the serve
+ * line, which the runtime owns (see docs/features/sglang-qwen38.md). Without it
+ * the schemas are accepted but calls come back as raw text and Claude Code
+ * executes nothing.
+ *
+ * The model name carries NO `[1m]` suffix: native context is 262,144, and
+ * claiming the 1M beta while the serve line does not raise `--context-length`
+ * would cap the window incorrectly in the other direction.
+ *
+ * Both presets are DISABLED and this migration installs nothing — no image pull,
+ * no weights, no container, no request to the endpoint. `sglangBacked: true`
+ * puts them under the same readiness probe and GPU-exclusivity rules as the
+ * OpenCode pair, so both harnesses are understood as one daemon.
+ *
+ * Kept in lockstep with data.reference/providers.json and
+ * server/lib/aiToolkit/defaults/providers.sample.json. These frozen literals are
+ * the historical upgrade payload; later default changes require a new migration
+ * rather than rewriting this record.
+ */
+
+import { makeProviderSeedMigration } from './_lib.js';
+
+// The OpenAI-compatible listing endpoint the readiness probe and the GPU-blocker
+// probe hit. Deliberately NOT the same string as ANTHROPIC_BASE_URL below.
+const ENDPOINT = 'http://127.0.0.1:18021/v1';
+
+const MODEL = 'qwen3.8-27b';
+
+const ANTHROPIC_ENV = {
+ // Server ROOT — the SDK appends /v1/messages. See the header note.
+ ANTHROPIC_BASE_URL: 'http://127.0.0.1:18021',
+ ANTHROPIC_AUTH_TOKEN: 'sglang',
+ // Reasoning plus a long CoS prompt runs well past the SDK's default deadline.
+ API_TIMEOUT_MS: '3000000',
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
+ // The prefix-cache flag. Do not drop it — see the header note.
+ CLAUDE_CODE_ATTRIBUTION_HEADER: '0',
+ // One served model, so every tier points at it; otherwise a haiku-tier
+ // sub-call asks the container for a model it has never heard of.
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: MODEL,
+ ANTHROPIC_DEFAULT_SONNET_MODEL: MODEL,
+ ANTHROPIC_DEFAULT_OPUS_MODEL: MODEL,
+ ANTHROPIC_SMALL_FAST_MODEL: MODEL,
+};
+
+const CLAUDE_SGLANG_CLI = {
+ id: 'claude-sglang',
+ name: 'Claude SGLang (Qwen3.8-27B)',
+ type: 'cli',
+ command: 'claude',
+ args: ['--print'],
+ endpoint: ENDPOINT,
+ // Blank, and usually STAYS blank: this is the OpenAI-probe credential, which
+ // SGLang requires only behind `--api-key`. The Anthropic-side token is the
+ // non-empty ANTHROPIC_AUTH_TOKEN above and is a different thing.
+ apiKey: '',
+ models: [MODEL],
+ defaultModel: MODEL,
+ sglangBacked: true,
+ timeout: 600000,
+ enabled: false,
+ envVars: { ...ANTHROPIC_ENV },
+ secretEnvVars: ['ANTHROPIC_AUTH_TOKEN'],
+ headlessArgs: ['--no-session-persistence', '--disable-slash-commands', '--tools', ''],
+};
+
+const CLAUDE_SGLANG_TUI = {
+ id: 'claude-sglang-tui',
+ name: 'Claude SGLang TUI (Qwen3.8-27B)',
+ type: 'tui',
+ command: 'claude',
+ args: ['--dangerously-skip-permissions'],
+ endpoint: ENDPOINT,
+ apiKey: '',
+ models: [MODEL],
+ defaultModel: MODEL,
+ sglangBacked: true,
+ timeout: 600000,
+ enabled: false,
+ envVars: { ...ANTHROPIC_ENV },
+ secretEnvVars: ['ANTHROPIC_AUTH_TOKEN'],
+ tuiPromptDelayMs: 2500,
+ tuiIdleTimeoutMs: 180000,
+};
+
+export default makeProviderSeedMigration({
+ label: 'Claude SGLang (Qwen3.8-27B)',
+ defs: [CLAUDE_SGLANG_CLI, CLAUDE_SGLANG_TUI],
+});
diff --git a/scripts/migrations/291-claude-sglang-providers.test.js b/scripts/migrations/291-claude-sglang-providers.test.js
new file mode 100644
index 0000000000..8d48a4e524
--- /dev/null
+++ b/scripts/migrations/291-claude-sglang-providers.test.js
@@ -0,0 +1,196 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync } from 'fs';
+import { tmpdir } from 'os';
+import { join, resolve, dirname } from 'path';
+import { fileURLToPath } from 'url';
+
+import migration from './291-claude-sglang-providers.js';
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+
+const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
+
+const IDS = ['claude-sglang', 'claude-sglang-tui'];
+
+describe('migration 291 — Claude SGLang providers', () => {
+ let rootDir;
+ let providersPath;
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-291-'));
+ mkdirSync(join(rootDir, 'data'), { recursive: true });
+ providersPath = join(rootDir, 'data/providers.json');
+ });
+
+ afterEach(() => rmSync(rootDir, { recursive: true, force: true }));
+
+ it('adds both Claude SGLang presets, disabled, without changing the active provider', async () => {
+ writeJson(providersPath, {
+ activeProvider: 'claude-code',
+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },
+ });
+
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ expect(out.providers['claude-sglang']).toMatchObject({
+ name: 'Claude SGLang (Qwen3.8-27B)',
+ type: 'cli',
+ command: 'claude',
+ args: ['--print'],
+ endpoint: 'http://127.0.0.1:18021/v1',
+ models: ['qwen3.8-27b'],
+ defaultModel: 'qwen3.8-27b',
+ sglangBacked: true,
+ enabled: false,
+ });
+ expect(out.providers['claude-sglang-tui']).toMatchObject({
+ type: 'tui',
+ command: 'claude',
+ args: ['--dangerously-skip-permissions'],
+ sglangBacked: true,
+ enabled: false,
+ tuiPromptDelayMs: 2500,
+ tuiIdleTimeoutMs: 180000,
+ });
+ expect(out.activeProvider).toBe('claude-code');
+ });
+
+ it('sets CLAUDE_CODE_ATTRIBUTION_HEADER to "0" on both presets', async () => {
+ // Load-bearing, not cosmetic: with the attribution block present, Claude Code
+ // prepends a per-request hash to the system prompt, which is the first token
+ // to differ between turns — so SGLang's radix prefix cache misses and
+ // re-prefills the whole conversation every turn.
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ for (const id of IDS) {
+ expect(out.providers[id].envVars.CLAUDE_CODE_ATTRIBUTION_HEADER).toBe('0');
+ // The nonessential-traffic flag is a SEPARATE control and does not remove
+ // the attribution block — both are required.
+ expect(out.providers[id].envVars.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC).toBe('1');
+ }
+ });
+
+ it('points ANTHROPIC_BASE_URL at the server root, never a /v1 suffix', async () => {
+ // The Anthropic SDK appends /v1/messages itself; a base URL that already ends
+ // in /v1 404s in a way that reads as "model not found". The /v1 form belongs
+ // on `endpoint`, which is the OpenAI-compatible listing the readiness probe
+ // hits — the two URLs are deliberately different.
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ for (const id of IDS) {
+ const baseUrl = out.providers[id].envVars.ANTHROPIC_BASE_URL;
+ expect(baseUrl).toBe('http://127.0.0.1:18021');
+ expect(baseUrl).not.toMatch(/\/v\d+\/?$/);
+ expect(out.providers[id].endpoint).toBe('http://127.0.0.1:18021/v1');
+ }
+ });
+
+ it('ships a non-empty auth token, marked secret', async () => {
+ // SGLang accepts any value unless started with --api-key, but the SDK rejects
+ // an empty token before a request leaves the box. `secretEnvVars` mirrors what
+ // migration 284 did for Claude Ollama.
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ for (const id of IDS) {
+ expect(out.providers[id].envVars.ANTHROPIC_AUTH_TOKEN).toBe('sglang');
+ expect(out.providers[id].secretEnvVars).toContain('ANTHROPIC_AUTH_TOKEN');
+ }
+ });
+
+ it('points every model tier at the one served model, with no [1m] suffix', async () => {
+ // Native context is 262,144. Claiming the 1M beta while the serve line does
+ // not raise --context-length would cap the window incorrectly the other way.
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ for (const id of IDS) {
+ const { envVars, models, defaultModel } = out.providers[id];
+ for (const key of [
+ 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
+ 'ANTHROPIC_DEFAULT_SONNET_MODEL',
+ 'ANTHROPIC_DEFAULT_OPUS_MODEL',
+ 'ANTHROPIC_SMALL_FAST_MODEL',
+ ]) {
+ expect(envVars[key]).toBe('qwen3.8-27b');
+ }
+ expect(models).toEqual(['qwen3.8-27b']);
+ expect(defaultModel).toBe('qwen3.8-27b');
+ expect(JSON.stringify(out.providers[id])).not.toContain('[1m]');
+ }
+ });
+
+ it('never seeds a thinking default — CoS coding wants it off, but the operator chooses', async () => {
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+
+ for (const id of IDS) {
+ expect(out.providers[id].thinking).toBeUndefined();
+ }
+ });
+
+ it('leaves the OpenCode SGLang wrappers alone — the two harnesses share one daemon', async () => {
+ const opencode = {
+ id: 'opencode-sglang-tui', type: 'tui', command: 'opencode',
+ endpoint: 'http://127.0.0.1:18021/v1', sglangBacked: true, enabled: true,
+ };
+ writeJson(providersPath, { providers: { 'opencode-sglang-tui': opencode } });
+
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+ expect(out.providers['opencode-sglang-tui']).toEqual(opencode);
+ expect(out.providers['claude-sglang-tui'].command).toBe('claude');
+ });
+
+ it('preserves an existing customized Claude SGLang provider', async () => {
+ const existing = {
+ id: 'claude-sglang-tui',
+ name: 'Custom Claude SGLang TUI',
+ type: 'tui',
+ command: 'claude',
+ endpoint: 'http://127.0.0.1:19000/v1',
+ envVars: { ANTHROPIC_BASE_URL: 'http://127.0.0.1:19000' },
+ enabled: true,
+ };
+ writeJson(providersPath, { providers: { 'claude-sglang-tui': existing } });
+
+ await migration.up({ rootDir });
+ const out = readJson(providersPath);
+ expect(out.providers['claude-sglang-tui']).toEqual(existing);
+ // The sibling it did not already own is still added.
+ expect(out.providers['claude-sglang']).toBeDefined();
+ });
+
+ it('is idempotent — a second run changes nothing', async () => {
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const first = readFileSync(providersPath, 'utf-8');
+
+ const second = await migration.up({ rootDir });
+ expect(second).toMatchObject({ ok: true, reason: 'already-present', added: 0 });
+ expect(readFileSync(providersPath, 'utf-8')).toBe(first);
+ });
+
+ it('ships the same records the install seeds do', async () => {
+ // The migration is the upgrade path for an existing install; data.reference
+ // (and the toolkit sample it stays in parity with) is the fresh-install path.
+ // A divergence gives the two populations different providers.
+ writeJson(providersPath, { providers: {} });
+ await migration.up({ rootDir });
+ const migrated = readJson(providersPath).providers;
+ const reference = readJson(resolve(__dirname, '../../data.reference/providers.json')).providers;
+
+ for (const id of IDS) {
+ expect(migrated[id]).toEqual(reference[id]);
+ }
+ });
+});
diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.json
index ca6083be56..294d336984 100644
--- a/server/lib/aiToolkit/defaults/providers.sample.json
+++ b/server/lib/aiToolkit/defaults/providers.sample.json
@@ -247,6 +247,61 @@
"tuiPromptDelayMs": 2500,
"tuiIdleTimeoutMs": 180000
},
+ "claude-sglang": {
+ "id": "claude-sglang",
+ "name": "Claude SGLang (Qwen3.8-27B)",
+ "type": "cli",
+ "command": "claude",
+ "args": ["--print"],
+ "endpoint": "http://127.0.0.1:18021/v1",
+ "apiKey": "",
+ "models": ["qwen3.8-27b"],
+ "defaultModel": "qwen3.8-27b",
+ "sglangBacked": true,
+ "timeout": 600000,
+ "enabled": false,
+ "envVars": {
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:18021",
+ "ANTHROPIC_AUTH_TOKEN": "sglang",
+ "API_TIMEOUT_MS": "3000000",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
+ "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.8-27b"
+ },
+ "secretEnvVars": ["ANTHROPIC_AUTH_TOKEN"],
+ "headlessArgs": ["--no-session-persistence", "--disable-slash-commands", "--tools", ""]
+ },
+ "claude-sglang-tui": {
+ "id": "claude-sglang-tui",
+ "name": "Claude SGLang TUI (Qwen3.8-27B)",
+ "type": "tui",
+ "command": "claude",
+ "args": ["--dangerously-skip-permissions"],
+ "endpoint": "http://127.0.0.1:18021/v1",
+ "apiKey": "",
+ "models": ["qwen3.8-27b"],
+ "defaultModel": "qwen3.8-27b",
+ "sglangBacked": true,
+ "timeout": 600000,
+ "enabled": false,
+ "envVars": {
+ "ANTHROPIC_BASE_URL": "http://127.0.0.1:18021",
+ "ANTHROPIC_AUTH_TOKEN": "sglang",
+ "API_TIMEOUT_MS": "3000000",
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
+ "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-27b",
+ "ANTHROPIC_SMALL_FAST_MODEL": "qwen3.8-27b"
+ },
+ "secretEnvVars": ["ANTHROPIC_AUTH_TOKEN"],
+ "tuiPromptDelayMs": 2500,
+ "tuiIdleTimeoutMs": 180000
+ },
"orcarouter": {
"id": "orcarouter",
"name": "OrcaRouter",
diff --git a/server/lib/aiToolkit/internal/modelFetchers.test.js b/server/lib/aiToolkit/internal/modelFetchers.test.js
index ab98e5fc98..8c0bc20259 100644
--- a/server/lib/aiToolkit/internal/modelFetchers.test.js
+++ b/server/lib/aiToolkit/internal/modelFetchers.test.js
@@ -25,6 +25,10 @@ const SHIPPED_REFRESHABLE = [
// SGLang publishes its served catalog through the same OpenAI-compatible
// `/v1/models` contract as the vLLM pair, so its wrappers refresh too.
'opencode-sglang', 'opencode-sglang-tui',
+ // The Claude Code pair points at the SAME container through its Anthropic
+ // `/v1/messages` endpoint, but the catalog still comes from the OpenAI-side
+ // listing — the `sglangBacked` marker selects that fetcher, not the command.
+ 'claude-sglang', 'claude-sglang-tui',
];
const SHIPPED_NOT_REFRESHABLE = [
'claude-code-tui', 'claude-code-tui-bedrock', 'codex', 'codex-tui',
diff --git a/server/lib/cliChildEnv.test.js b/server/lib/cliChildEnv.test.js
index b752979332..302c301086 100644
--- a/server/lib/cliChildEnv.test.js
+++ b/server/lib/cliChildEnv.test.js
@@ -4,6 +4,10 @@ import { posixPath } from './testHelper.js';
import { buildCliChildEnv, composeProviderEnv } from './cliChildEnv.js';
import { AGENT_GUARD_BIN } from './agentGuard/index.js';
import { collectServerSources, readServerSource } from './testHelper.js';
+import { readFileSync } from 'node:fs';
+// Read, not `import … with { type: 'json' }` — the repo avoids JSON import
+// attributes (see promptSystemStages.js).
+const SHIPPED_PROVIDERS = JSON.parse(readFileSync(new URL('../../data.reference/providers.json', import.meta.url), 'utf8'));
// An OpenCode provider that IS ollama-backed — the only shape for which
// buildOpencodeEnvVars returns anything. Everyone else gets `{}`, which is why
@@ -195,6 +199,28 @@ describe('composeProviderEnv — delta for sites that do not spawn directly', ()
expect(declaredModels(delta).sort()).toEqual(['llama3.1:8b', 'qwen2.5:7b']);
});
+ it('hands the shipped Claude SGLang TUI its Anthropic wiring, and no OpenCode config', () => {
+ // Acceptance path for the seeded pair: a CoS task assigned this provider
+ // spawns `claude --dangerously-skip-permissions` with exactly this env.
+ const provider = SHIPPED_PROVIDERS.providers['claude-sglang-tui'];
+ expect(provider.command).toBe('claude');
+ expect(provider.args).toEqual(['--dangerously-skip-permissions']);
+
+ const env = composeProviderEnv({ provider, model: 'qwen3.8-27b' });
+
+ // Without this, Claude Code's per-request attribution hash is the first
+ // token to differ between turns and SGLang re-prefills the whole prompt.
+ expect(env.CLAUDE_CODE_ATTRIBUTION_HEADER).toBe('0');
+ // Server ROOT: the Anthropic SDK appends /v1/messages itself.
+ expect(env.ANTHROPIC_BASE_URL).toBe('http://127.0.0.1:18021');
+ expect(env.ANTHROPIC_BASE_URL).not.toMatch(/\/v\d+\/?$/);
+ expect(env.ANTHROPIC_AUTH_TOKEN).toBe('sglang');
+
+ // `sglangBacked` also marks the OpenCode wrappers, but the OpenCode config
+ // is gated on the COMMAND — a `claude` harness must not receive one.
+ expect(env.OPENCODE_CONFIG_CONTENT).toBeUndefined();
+ });
+
it('is what buildCliChildEnv layers over its base env', () => {
const layers = { before: { A: '1' }, provider: { envVars: { B: '2' } }, extra: { C: '3' } };
expect(buildCliChildEnv({ baseEnv: {}, ...layers })).toEqual(composeProviderEnv(layers));