diff --git a/README.md b/README.md
index 5339f2f73..715b768ac 100644
--- a/README.md
+++ b/README.md
@@ -82,7 +82,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
diff --git a/docs/reference.md b/docs/reference.md
index 8c9c2f4e6..4e4e5b4f0 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -157,6 +157,7 @@ line; agents connected to magpie lose it when it quits.
| OpenBot | `OpenBot/openbot-custom-providers-v1.json` in the app data folder: `~/Library/Application Support` (macOS), `%APPDATA%` (Windows), `$XDG_CONFIG_HOME` or `~/.config` (Linux) | provider (a keyless `magpie` endpoint at `/agent/openbot/v1`, magpie's models in its model picker; the user's endpoints kept; OpenBot reads it at start, so restart it) |
| Craft Agents | `~/.craft-agent/config.json` (or `$CRAFT_CONFIG_DIR`) | model (a keyless `pi_compat` connection `magpie` at `/agent/craft-agents/v1`, made the default; the user's connections and default kept and put back on off; new sessions use it) |
| Obsidian | Copilot for Obsidian 4+'s `.obsidian/plugins/copilot/data.json` in each vault `obsidian.json` lists (`~/Library/Application Support/obsidian`, `%APPDATA%\obsidian`, `$XDG_CONFIG_HOME/obsidian`, Flatpak, Snap) | provider (a keyless `magpie` provider at `/agent/obsidian/v1`, magpie's models in Copilot's chat picker and the default; the user's settings kept; reload Copilot or restart Obsidian) |
+| Tuanjie Cowork | `~/.codely/settings.json` | model (a `magpie` entry in `customModelProviders`, the gateway's `/v1` with Cowork's own key, and a `magpie` entry in `customModels` on `wireApi` `chat`; the user's providers and models kept; pick " (magpie)" in Cowork's model menu once, restarting Cowork if it isn't listed yet) |
| NewMax | `newmax.db` (SQLite, the row `app` of its `settings` table) in `$NEWMAX_USER_DATA_DIR`, else `~/.newmax` (every OS) | provider (a `magpie-gateway` entry in its `providers` and `providerOrder`, magpie's models in its model picker; the rest of the row kept byte for byte; refused while NewMax runs, as it writes its settings back whenever one changes) |
| LiveAgent | `config.json` (JSONC, K-brain's) in `$LIVEAGENT_HOME`, else `$K_BRAIN_HOME`, else the folder `~/.liveagent/data-dir.json` points to, else `~/.liveagent` (every OS) | provider (`magpie`, `magpie-responses` and `magpie-anthropic` entries in its `providers`, each model on the one of the API it is served on natively: Chat Completions and Responses at the gateway's `/v1` as OpenAI providers whose request format the user can switch in LiveAgent and magpie keeps, Anthropic Messages at its root; magpie's models in its model picker; a model or provider of magpie's deleted in LiveAgent stays out; a default still K-brain's own demo model becomes magpie's first; refused while LiveAgent or its `k-brain` backend runs, as it writes its settings back whenever one changes) |
| T3 Code | `~/.t3/userdata/settings.json` (`$T3CODE_HOME/userdata`) | provider (a `magpie` provider instance on Claude Code, magpie's models as its custom models; a `magpie-codex` instance on Codex, whose `launchArgs` are Codex's own `-c` overrides to magpie and a `magpie-codex-models.json` catalog beside the settings. The harness is picked in T3's model picker) |
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md
index 8b7842ae8..56147b23f 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -100,6 +100,7 @@ something else shows up as drift.
- OpenBot (nightly-labs/openbot, openbot.run; jiezhengj on Discord) keeps the OpenAI-compatible endpoints its model picker lists in `openbot-custom-providers-v1.json` in Electron's userData folder, app data joined with `OpenBot`: `~/Library/Application Support/OpenBot` on a Mac, `%APPDATA%\OpenBot` on Windows, `$XDG_CONFIG_HOME/OpenBot` or `~/.config/OpenBot` on Linux (`openBot` in [`openbot.go`](../../internal/agent/openbot.go); its `custom-provider-store.ts` and `opencode-config.ts`, v0.58.0). magpie adds one entry to `providers`, `id: magpie` at the gateway's `/agent/openbot/v1` with `secret: null`: an entry's key and headers are one safeStorage ciphertext (the Keychain, DPAPI) that magpie doesn't open, so OpenBot hands the entry to OpenCode keyless, the gateway takes it as a request from this computer, and the address, not OpenCode's User-Agent, names it OpenBot's (`gateway.AgentURL`; before, it counted as OpenCode's, SSNQT on X). An entry written at `/v1` is rewritten at the next sync, and OpenBot reads it after a restart. OpenBot's list decoders fail closed (one entry or model it wouldn't take empties the list), so the models are the picked ones whose `magpie/` OpenBot accepts (ASCII letters, digits and `._:/[],=-`, at most 160), at most 64, with a context window only inside 1,024 to 100,000,000. The user's other entries stay, and so do the `name`, `harness` and `secret` they give magpie's entry; a sync with nothing to change doesn't write. A file whose `version` isn't the number 1, or whose `providers` isn't a list, is one OpenBot itself refuses, so magpie leaves it alone. Disconnect takes the entry out, and the file when only the version and an empty list are left. OpenBot reads the file once at start and writes it whole only when an endpoint is saved, edited or removed there, so the notice (while it runs) says to restart it before doing that. The model is picked in OpenBot's picker (`ListsModels`). Detected by its userData folder, `OpenBot.app` (`app.openbot.desktop`), or `OpenBot.exe` under `%LOCALAPPDATA%\Programs` or `%ProgramFiles%`. In the Library it takes skills, in `~/.agents/skills`, the only folder it reads (`home-skills.ts`). Its MCP servers live in its SQLite database, which magpie doesn't write (#5896), so it isn't in the MCP picker: magpie's `/mcp/magpie/…` servers are added there by hand as HTTP servers.
- Craft Agents (lukilabs/craft-agents-oss, thecraftagents.com; springg1998 on X) keeps its connections in `config.json` under `$CRAFT_CONFIG_DIR` or `~/.craft-agent` (`craftAgents` in [`craftagents.go`](../../internal/agent/craftagents.go); its `config/paths.ts`, `config/storage.ts` and `config/llm-connections.ts`, v0.15.8). magpie adds one entry to `llmConnections`, slug `magpie`, `providerType: pi_compat` and `authType: none` at the gateway's `/agent/craft-agents/v1` with `customEndpoint.api: openai-completions`: Pi sends a keyless loopback request, which the gateway takes as this computer's, and the address names it Craft's. Its `models` are magpie's picked ones as objects, and `defaultModel` is always one of them, since Craft resets a default its list hasn't to the first. magpie makes it `defaultLlmConnection`; the user's default is stashed (as JSON, `""` for none) and put back on off when that connection is still there, and the `name` they give magpie's entry stays. A session keeps the connection it started on, and a workspace default goes over the global one, so the notice says new sessions use it. A `config.json` with no `workspaces` list is one Craft doesn't load, so magpie never makes one: Craft is opened once first. Picking one of the user's own models takes magpie's entry out and sets that model as their default connection's `defaultModel`. Craft re-reads the file on each lookup. Detected by `~/.craft-agent` or `Craft Agents.app` (`com.lukilabs.craft-agent`), or `Craft Agents.exe` under `%LOCALAPPDATA%\Programs\@craft-agentelectron`. In the Library it takes skills, in `~/.agents/skills`.
- Obsidian (`obsidian` in [`obsidian.go`](../../internal/agent/obsidian.go); shirotokiren on X) has no AI of its own; magpie wires its plugin Copilot for Obsidian (logancyang/obsidian-copilot, plugin id `copilot`, 4.0 and later) in every vault that has it. The vaults come from Obsidian's `obsidian.json` (`vaults..path`) in `~/Library/Application Support/obsidian` (macOS), `%APPDATA%\obsidian` (Windows), or on Linux `$XDG_CONFIG_HOME/obsidian`, the Flatpak's `~/.var/app/md.obsidian.Obsidian/config/obsidian` and the Snap's `~/snap/obsidian/current/.config/obsidian`; a vault has Copilot when `.obsidian/plugins/copilot/manifest.json` is there. In its `data.json` magpie adds `providers.magpie` (`openai-compatible`, `baseUrl` the gateway's `/agent/obsidian/v1`, `requiresApiKey: false` and no keychain id, `enableCors: false` so Copilot streams through the window's fetch, answered by the gateway's CORS for `app://obsidian.md`), one `configuredModels` entry per magpie model (provider `magpie`, ids made from the model's, uuid v5, so a sync finds them again; limits, image input and reasoning efforts from the catalog), each new one in `backends.chat.enabledModels`, and on the first wire `defaultModelKey` (the old one kept in the stash). A sync keeps a model the user turned off off, their default, and the name and key they give the provider; it writes only the keys that change, through a temp file renamed over the old (`edit.PatchJSON`, `edit.WriteAtomic`), and nothing when nothing does. Disconnect takes out the provider, its models and their ids in every backend, and puts the default back when magpie's is still it. Copilot 3 (`activeModels`) is refused with a message to update it, and so is no vault with Copilot. Obsidian holds the settings in memory, so the notice (while it runs) says to reload Copilot or restart Obsidian. Smart Connections is not wired: its free plugin embeds with a local model only, and its API providers are in the closed Pro plugin, with keys in the keychain.
+- Tuanjie Cowork (`tuanjiecowork.go`, codely.tuanjie.cn; Charles24209792 on X), a Tauri app (`dev.codelycowork.desktop`), keeps its Custom Models in `~/.codely/settings.json`: `customModelProviders` (`{id, name, baseUrl, apiKey, authType}`) and `customModels` (`{id, model, providerId, displayName, roles, wireApi, supportsMultimodal}`, an id unique across providers). Its core reads the file afresh on every lookup and writes it whole, other keys kept; a session gets its provider's baseUrl and key as `OPENAI_BASE_URL`/`OPENAI_API_KEY` (wireApi `chat`). magpie adds a provider and a model both with id `magpie`: the gateway's `/v1`, Cowork's own key (it is how the gateway tells Cowork apart), and the model picked. A name or roles given them in Cowork are kept, and an id `magpie` of the user's own is refused, not written over. Which model a chat is on is Cowork's pick in its model menu (per workspace GUI state, by model id), which magpie doesn't write; because the id stays `magpie`, that pick follows a model changed in magpie. Set of a model of Cowork's own is refused for the same reason. Off takes both entries out, and the file too where magpie made it. Cowork's startup migrations only move models without a `providerId`, so magpie's entries stay. Windows' Tauri NSIS per-user folder isn't under `%LOCALAPPDATA%\Programs`, so there it is detected by `~/.codely` alone.
- Antigravity, Google's desktop app (not Antigravity IDE, `com.google.antigravity-ide`), takes a gateway from `~/.antigravity/settings.json` from 2.15 on, and from `~/.gemini/config/config.json` (beside its `userSettings` and `plugins`) from 2.30 on, which reads only that file (YujunT46308 on X). magpie writes the same block into both, and a wiring made before 2.30 is carried into the new file at magpie's next start: Google's Antigravity Enterprise Gateway (docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/connect-enterprise-gateway; `antigravity` in [`antigravity.go`](../../internal/agent/antigravity.go), ryougi_hachi on X). magpie writes `gateway` as `{enabled: true, url: , apiKey: , wireProtocol: openai}` and the model it starts on as `models.defaultModelId`, and takes out `models.list`, which would narrow the picker to the user's own. It also points `models.listSource`, the app's remote model catalog, at `/v1/models?format=antigravity` (`gateway.antigravityModels`): `{"list": [{modelId, displayName, maxTokens, maxOutputTokens, supportsImages, supportsThinking}]}`, the models the key may use. The backend (2.29.0) resolves models from `models.list`, then `listSource` (fetched with the gateway key), then `/v1/models`, then its built-in catalog. From `/v1/models` it reads the id alone, and a model its catalog doesn't know gets its family's defaults, a 200K window whatever the model's, so every magpie model had 200K (YujunT46308 on X); `context_window`, `context_length` and `max_input_tokens` there are not read. A bare array or `{"list": …}` is read; `{"models": …}` is not. A field magpie doesn't know is left out and the app's default stands. The picker shows `displayName`, so the names follow magpie's (`ListsModels`, not `NoNames`). The app's picker (its `main.js`, 2.29.0) offers effort only by grouping entries named ` (Low)`, `(Medium)`, `(High)`, `(XHigh)` or `(Max)` (its regex also takes `(Low thinking)`) under one row with an effort menu, two levels or more, starting on medium when a group has it, else the lowest; a model listed once had no effort control at all (YujunT46308 on X). So a model with two or more of those levels is listed once a level, `:` named ` ()` (`antigravityLevels`), and the request goes out under the chosen entry's id, whose `:level` suffix the gateway sends upstream ahead of the row's pick; the app's own `reasoning_effort` (`low` whatever was chosen, in a 2.29.0 run) loses to it. `models.defaultModelId` names one of those entries, since an id the catalog doesn't list starts the app on its first model: `gateway.AntigravityModel` adds the row's effort, fitted, else medium, else the lowest. The row's effort sets that start level (and is what a model with fewer than two levels is asked for); `Sync` moves a file written before onto a level, keeping a level already there. The model field shows the id without the level.`Sync` adds `listSource` to a file wired before, at the gateway's current address, stashing one of the user's. On the openai protocol the backend streams `/v1/chat/completions` with the key as a bearer token and a User-Agent of `antigravity/hub/`. The user's gateway, default model, list and `listSource` are stashed and put back on disconnect, or when a model of their own is picked; `caCertPath` and the rest of the file are never touched, and a `Sync` keeps what the user added to magpie's block (`customHeaders`). On a gateway the app uses no Google sign-in, and its backend asks Google for nothing (no `cloud_code_endpoint` or `api_server_url` call in a headless run): Google's docs say a gateway and a Google Account can't be used at once. What Google's servers turn on for a signed-in account, its experiments and the commands behind them (`/boost`, `/teamwork`, `/plugin`, `/generative_ui`, YujunT46308), is off while it is on magpie. No key in the file keeps both (`proxy` only routes the app's own HTTP), so the notice shown on connecting names what is lost and that turning it off gives it back. An organisation's `admin_settings.json` and the `AGY_LLM_GATEWAY_*` variables win over the file, so `Check` says when either sets a gateway. agy reads the same file below its own settings: an agy connected on its own row keeps its route, one that isn't follows the app's gateway, as the notice says. `~/.antigravity` is Antigravity IDE's and agy's too, so the app is found by its bundle at 2.15 or later (`desktopApps`) or `~/.gemini/antigravity/agyhub_summaries_proto.pb`, which only its backend writes. The app reads the file at start, so the notice asks for a restart. The Antigravity accounts magpie signs in (provider `antigravity`) are a separate thing: those send magpie's requests to Google.
- NewMax (newmax.cc, an Electron app on the Claude Agent SDK) keeps its settings as JSON in the row `app` of the `settings` table of `newmax.db`, a SQLite database in WAL mode in `$NEWMAX_USER_DATA_DIR`, else `~/.newmax` on every system (`newMax` in [`newmax.go`](../../internal/agent/newmax.go); its main bundle's `configureAppDataPaths`, `loadPersistedAppSettings` and the renderer's `mergeProviders`, v1.1.22). magpie adds one entry to `providers` in the shape NewMax's own import writes, `id: magpie-gateway` (its own preset is `magpie`, its import's ids hold `%3A`), `apiFormat: anthropic` at the gateway's root (NewMax appends `/v1/messages`) with `ANTHROPIC_AUTH_TOKEN` and a key naming NewMax, at most 20 models (`MAX_MODELS`) as `models` and `enabledModels` with their context windows, and its id at the end of `providerOrder`. The row is edited in place in one immediate transaction, so every other byte stays; the user's `name` and `enabled` for magpie's entry and the fields NewMax adds to it stay through a sync, and a sync with nothing to change doesn't write. A row that isn't a JSON object, or whose `providers` or `providerOrder` isn't a list, is left alone. With no row (NewMax at its defaults), magpie writes one with its entry alone, as NewMax lays its defaults and presets under the row; with no database yet, it asks to open NewMax once. Disconnect takes the entry and the id out, sets a pick of it back to `default`, and takes the row out when only what magpie made is left. NewMax holds its settings in memory and writes the whole row back whenever one changes, so a change is refused while `NewMax` (`newmax` on Linux) runs (Windows can't be asked, so the notice says to quit it first). The model is picked in NewMax's model picker, so the field is whether magpie is in it (`ListsModels`). Detected by its data folder or `NewMax.app` (`cc.newmax.desktop`).
- LiveAgent (Stack-Cairn/LiveAgent v2, a Tauri app) runs its models through K-brain, a Go backend it starts with its data folder, which keeps every provider in `config.json` there: `$LIVEAGENT_HOME`, else `$K_BRAIN_HOME`, else the folder `~/.liveagent/data-dir.json` points to (`{"path": …}`, set when the user moves LiveAgent's data), else `~/.liveagent` on every system (`liveAgent` in [`liveagent.go`](../../internal/agent/liveagent.go); LiveAgent's `data_home.rs` and `kbrain_backend.rs`, K-brain v0.107.12's `internal/config`). The file is JSONC in Pi's provider shape, decoded with unknown fields refused, so magpie writes only K-brain's fields. K-brain asks all of a provider's models on its one API, so magpie writes up to three providers and puts each model on the one of the API it is served on natively (`catalog.Model.APIs`, as dsh's routes): `providers.magpie-responses` for Responses and `providers.magpie` for every other OpenAI-side model (Chat Completions), each `type: codex` with `api` and `requestFormat` as LiveAgent's own settings write an OpenAI-compatible provider, `baseUrl` the gateway's `/v1` (K-brain appends only `/chat/completions` or `/responses`); `providers.magpie-anthropic` for Messages, `type: claude_code` and `api: anthropic-messages`, `baseUrl` the gateway's root (K-brain appends `/v1` and posts to `/messages` with `X-Api-Key`). LiveAgent's settings lock an Anthropic provider's API and let the user switch an OpenAI one between Chat Completions and Responses; a sync keeps the format they picked (Discord, xiaoxiaofei). A provider left with no model is taken out. Each has a key naming LiveAgent, `activeModels: null` (every model on), magpie's order as `modelOrder`, and `models` sorted by id as K-brain writes them, with each one's display name, context window, output limit and `input: [text, image]` when it takes images. Comments and every other key stay. Through a sync the user's name for each entry, the models they turned off (`activeModels`), their order and the fields K-brain adds (its `metadata`) stay; a model that moves to another of magpie's providers (a `config.json` from before, with every model on one Anthropic `magpie`) brings its name and off with it, and a pick of it follows; a model new to magpie's list is on and goes last, and a sync with nothing to change doesn't write. A model of magpie's the user deleted in LiveAgent, or a whole provider of magpie's, stays out until they put it back or magpie is turned off and on for LiveAgent (zero2sin on Discord: every sync, so every restart, wrote magpie's twenty or thirty models back): magpie keeps, per `config.json`, which of its models and providers LiveAgent has had (`liveAgentKept`, in the stash). One magpie added while LiveAgent ran is pending under the processes then (`liveAgentPIDs`), since LiveAgent's next save drops a model it never read: missing under those processes, or after they quit, it is written again; once other processes run it counts as had. On Windows, which can't be asked what runs, each counts as had at once. A default (or compact) model still K-brain's own, `model1` of its endpoint-less `demo` provider, becomes magpie's first; one the user picked stays. A file K-brain wouldn't read as providers (not an object, `providers` not an object, a top-level `models`, one provider written bare) is left alone. Disconnect takes magpie's entries out and a pick of them back to K-brain's default; a file left with no provider gets K-brain's `demo` back, since K-brain takes one with none as written over and restores `config.json.bak`, which can still hold magpie's; a file with nothing but what magpie made goes. LiveAgent's backend makes the file as `{}` when there is none (so a disconnect that takes the file away is undone the next start, harmlessly), reads it when it starts and writes it whole whenever a setting changes, so a change is refused while `liveagent` or `k-brain` runs (Windows can't be asked, so the notice says to quit it first). A model id another provider of the user's lists too has its metadata shared by K-brain, so a sync may write that model's limits back each time. The model is picked in LiveAgent's model picker, so the field is whether magpie is in it (`ListsModels`). Detected by its data folder, `LiveAgent.app` (`com.xiaofei.liveagent`) or its Windows install. Its logo is the app's own 64px icon (`src-tauri/icons/64x64.png`, MIT) in an SVG.
diff --git a/internal/agent/agents.go b/internal/agent/agents.go
index 6a119d6fb..b3985c336 100644
--- a/internal/agent/agents.go
+++ b/internal/agent/agents.go
@@ -318,6 +318,7 @@ func onMachine(home, cfg string) []*Agent {
openBot(home, cfg),
craftAgents(home),
obsidian(home, cfg),
+ tuanjieCowork(home),
newMax(home),
liveAgent(home),
raycast(home),
diff --git a/internal/agent/desktopapp.go b/internal/agent/desktopapp.go
index d5f8e2a79..1fb52376c 100644
--- a/internal/agent/desktopapp.go
+++ b/internal/agent/desktopapp.go
@@ -114,7 +114,13 @@ var desktopApps = map[string]desktopApp{
// with its "/" taken out (getWindowsInstallationDirName; the README's
// own path); guid is the UUID v5 of the appId, as dsh's above.
"craft-agents": {id: "com.lukilabs.craft-agent", names: []string{"Craft Agents.app"}, win: filepath.Join("@craft-agentelectron", "Craft Agents.exe"), guid: "61dc82ee-e3b9-557b-98c4-20b9178a0f78"},
- "penguin": {id: "com.prismshadow.penguinharness", names: []string{"PenguinHarness.app"}, win: filepath.Join("PenguinHarness", "PenguinHarness.exe"), guid: "8bb9acb7-2bdc-596b-9669-7b014ab1c47f"},
+ // Tuanjie Cowork (2.1.6-stable: Tuanjie Cowork.app,
+ // dev.codelycowork.desktop, a Tauri app) reads ~/.codely on its own
+ // (tuanjiecowork.go). Its Windows build is a Tauri NSIS installer, whose
+ // per-user folder isn't under %LOCALAPPDATA%\Programs, so on Windows
+ // it is found by its ~/.codely folder alone.
+ "tuanjie-cowork": {id: "dev.codelycowork.desktop", names: []string{"Tuanjie Cowork.app"}},
+ "penguin": {id: "com.prismshadow.penguinharness", names: []string{"PenguinHarness.app"}, win: filepath.Join("PenguinHarness", "PenguinHarness.exe"), guid: "8bb9acb7-2bdc-596b-9669-7b014ab1c47f"},
// The CodeBuddy IDE (Tencent's VS Code fork, 4.12.2: CodeBuddy.app,
// com.tencent.codebuddy, from codebuddy.ai; CodeBuddy CN.app,
// com.tencent.codebuddycn, from codebuddy.cn) reads the CodeBuddy Code
diff --git a/internal/agent/handwired_test.go b/internal/agent/handwired_test.go
index bfe453f41..376c1eafa 100644
--- a/internal/agent/handwired_test.go
+++ b/internal/agent/handwired_test.go
@@ -140,7 +140,7 @@ func TestPiConnectedBeforeStaysConnected(t *testing.T) {
func TestHandWiredMagpieProviderSiblings(t *testing.T) {
ids := []string{"agy", "opencode", "openchamber", "mimocode", "deveco", "pi", "aside", "omo", "prime-agent", "mu", "goose", "zed", "vscode",
"crush", "dsh", "ds-bot", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "nanobot", "miniq", "paimon", "craft-agents", "minimax-code", "droid",
- "qoder", "qoder-cn", "grok", "atomcode", "cline", "snow"}
+ "qoder", "qoder-cn", "grok", "atomcode", "cline", "snow", "tuanjie-cowork"}
for _, id := range ids {
t.Run(id, func(t *testing.T) {
if id == "aside" {
diff --git a/internal/agent/tuanjiecowork.go b/internal/agent/tuanjiecowork.go
new file mode 100644
index 000000000..c54565ad8
--- /dev/null
+++ b/internal/agent/tuanjiecowork.go
@@ -0,0 +1,264 @@
+package agent
+
+// Tuanjie Cowork (codely.tuanjie.cn, Unity China's coworker app;
+// Charles24209792 on X) is a Tauri app, dev.codelycowork.desktop, whose core
+// runs Codely sessions. Its models of one's own are its Settings' Custom
+// Models, kept in ~/.codely/settings.json (the core's settings path:
+// homedir/.codely; read at 2.1.6-stable). The file is read afresh on every
+// lookup and written whole, JSON with two-space indent, other keys kept:
+//
+// "customModelProviders": [{"id":"custom-provider","name":…,
+// "baseUrl":…,"apiKey":…,"authType":"openai",
+// "flashModelId"?,"multimodalModelId"?}, …],
+// "customModels": [{"id":…,"model":…,"providerId":…,"displayName":…,
+// "roles":["model"],"wireApi":"chat"|"responses"|"messages",
+// "supportsMultimodal":…}, …]
+//
+// A model's id is unique across providers. A session on one is started with
+// its provider's baseUrl and key as OPENAI_BASE_URL and OPENAI_API_KEY
+// (ANTHROPIC_* for wireApi messages), and Cowork lists a provider's models
+// at baseUrl + /models when baseUrl ends in /v1.
+//
+// So magpie adds a provider and a model of its own, both with id "magpie":
+// the gateway's /v1 with magpie's key for Cowork (the key names it), and
+// the model picked, on chat completions. The user's providers and models
+// stay as they are. Which model a chat is on is Cowork's own pick in its
+// model menu (per workspace, by model id), which magpie doesn't write: the
+// user picks " (magpie)" there once, and since the id stays
+// "magpie", a model changed in magpie later is the one Cowork's pick then
+// sends. Cowork's startup migrations (migratedToMultiProvider) only move
+// models with no providerId, so magpie's entries are left alone.
+
+import (
+ "encoding/json"
+ "errors"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/tidwall/gjson"
+
+ "github.com/yetone/magpie/internal/edit"
+)
+
+const (
+ coworkProviders = "customModelProviders"
+ coworkModels = "customModels"
+)
+
+// coworkProc is Tuanjie Cowork's app process: the .app's cowork, the
+// Windows build's cowork.exe.
+var coworkProc = []string{`Tuanjie Cowork\.app/Contents/MacOS/cowork`, `(^|[/\\])cowork\.exe`}
+
+var noticeCowork = newNotice("Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.")
+
+func tuanjieCowork(home string) *Agent { return tuanjieCoworkAt(here(home)) }
+
+// tuanjieCoworkAt is Tuanjie Cowork with its home at at.home.
+func tuanjieCoworkAt(at place) *Agent {
+ const id = "tuanjie-cowork"
+ dir := at.join(".codely")
+ path := filepath.Join(dir, "settings.json")
+ // keyNew marks a settings.json magpie made
+ keyNew := id + ":" + path + ":new"
+ key := func() string { return agentKeyAt(id, at.gw()) }
+ read := func() gjson.Result {
+ raw, err := edit.Read(path)
+ if err != nil {
+ return gjson.Result{}
+ }
+ return gjson.ParseBytes(raw)
+ }
+ find := func(c gjson.Result, list, k, v string) gjson.Result {
+ for _, x := range c.Get(list).Array() {
+ if x.Get(k).String() == v {
+ return x
+ }
+ }
+ return gjson.Result{}
+ }
+ // prov and model are magpie's provider and model, where they are
+ prov := func(c gjson.Result) gjson.Result { return find(c, coworkProviders, "id", magpieID) }
+ model := func(c gjson.Result) gjson.Result {
+ m := find(c, coworkModels, "id", magpieID)
+ if m.Get("providerId").String() != magpieID {
+ return gjson.Result{}
+ }
+ return m
+ }
+ // mine: the provider with magpie's id is magpie's, known by magpie's
+ // key for Cowork, which stays where the gateway's port moved (Check
+ // tells the address apart), or by the gateway's own address
+ mine := func(p gjson.Result) bool {
+ return p.Exists() && (keyHolds(p.Get("apiKey").String(), key()) ||
+ sameGateway(p.Get("baseUrl").String(), at.v1()))
+ }
+ on := func(c gjson.Result) bool { return mine(prov(c)) && model(c).Exists() }
+ // rest is a list as written with magpie's entries left out
+ rest := func(c gjson.Result, list, owner string) []json.RawMessage {
+ out := []json.RawMessage{}
+ for _, x := range c.Get(list).Array() {
+ if x.Get(owner).String() == magpieID {
+ continue
+ }
+ out = append(out, json.RawMessage(x.Raw))
+ }
+ return out
+ }
+ // merged is an entry as written with v laid over it
+ merged := func(x gjson.Result, v map[string]any) json.RawMessage {
+ m := map[string]any{}
+ if x.Exists() {
+ json.Unmarshal([]byte(x.Raw), &m)
+ }
+ for k, val := range v {
+ m[k] = val
+ }
+ b, _ := json.Marshal(m)
+ return b
+ }
+ images := func(ref string) bool {
+ for _, m := range sharedModels(id) {
+ if m.ID == ref {
+ return m.Images
+ }
+ }
+ return false
+ }
+ // wire writes magpie's provider and model, ref the model, keeping a
+ // name, roles or other fields given them in Cowork
+ wire := func(c gjson.Result, ref string) error {
+ p := prov(c)
+ pv := map[string]any{"id": magpieID, "baseUrl": at.v1(), "apiKey": key(), "authType": "openai"}
+ if p.Get("name").String() == "" {
+ pv["name"] = magpieID
+ }
+ m := model(c)
+ mv := map[string]any{
+ "id": magpieID, "providerId": magpieID, "model": ref, "displayName": ref,
+ "wireApi": "chat", "supportsMultimodal": images(ref),
+ }
+ if !m.Get("roles").IsArray() || len(m.Get("roles").Array()) == 0 {
+ mv["roles"] = []string{"model"}
+ }
+ ps := append(rest(c, coworkProviders, "id"), merged(p, pv))
+ ms := append(rest(c, coworkModels, "providerId"), merged(m, mv))
+ if !isFile(path) {
+ if err := os.MkdirAll(dir, 0o755); err != nil {
+ return err
+ }
+ // it holds keys, as Cowork's own does
+ if f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600); err == nil {
+ f.WriteString("{}\n")
+ f.Close()
+ }
+ }
+ return edit.SetJSON(path, edit.KV{Path: coworkProviders, Value: ps}, edit.KV{Path: coworkModels, Value: ms})
+ }
+ // unwire takes magpie's provider and models out, and the file where
+ // magpie made it and nothing else is left
+ unwire := func(c gjson.Result) error {
+ made := unstash(keyNew) != ""
+ if !prov(c).Exists() && !find(c, coworkModels, "providerId", magpieID).Exists() {
+ return nil
+ }
+ ps, ms := rest(c, coworkProviders, "id"), rest(c, coworkModels, "providerId")
+ if err := edit.SetJSON(path, edit.KV{Path: coworkProviders, Value: ps}, edit.KV{Path: coworkModels, Value: ms}); err != nil {
+ return err
+ }
+ if !made || len(ps) > 0 || len(ms) > 0 {
+ return nil
+ }
+ left := read().Map()
+ delete(left, coworkProviders)
+ delete(left, coworkModels)
+ if len(left) == 0 {
+ return edit.Remove(path)
+ }
+ return nil
+ }
+ return atomic(&Agent{
+ ID: id, Name: "Tuanjie Cowork", Icon: "tuanjie-cowork-color",
+ Aliases: []string{"tuanjie", "tjcowork", "codely-cowork", "tuanjiecowork"},
+ Spelled: prefixed, NoNames: true,
+ Dir: dir, Path: path,
+ // its folder once it has run, else its app
+ detect: func() bool { return isDir(dir) || (&Agent{ID: id}).HasApp() },
+ Notice: func() string {
+ if on(read()) && Running(coworkProc...) {
+ return noticeCowork.String()
+ }
+ return ""
+ },
+ Check: func() string {
+ c := read()
+ p := prov(c)
+ if !mine(p) {
+ return ""
+ }
+ if !model(c).Exists() {
+ return "Tuanjie Cowork's magpie model (settings.json) is gone, so it no longer reaches magpie"
+ }
+ return wiringOff("Tuanjie Cowork", path, func(k string) (string, bool) {
+ r := p.Get(k)
+ return r.String(), r.Exists()
+ }, "baseUrl", at.v1(), "apiKey", key())
+ },
+ Sync: func() error {
+ c := read()
+ if !on(c) {
+ return nil
+ }
+ p := prov(c)
+ if p.Get("baseUrl").String() == at.v1() && p.Get("apiKey").String() == key() && p.Get("authType").String() == "openai" {
+ return nil
+ }
+ return wire(c, model(c).Get("model").String())
+ },
+ Fields: []Field{{
+ Key: "model", Label: "model",
+ Get: func() string {
+ c := read()
+ if on(c) {
+ return magpieID + "/" + model(c).Get("model").String()
+ }
+ return ""
+ },
+ Set: func(v string) error {
+ c := read()
+ if ref, ok := strings.CutPrefix(v, magpieID+"/"); ok && isMagpie(ref) {
+ if raw, err := edit.Read(path); err == nil && len(strings.TrimSpace(string(raw))) > 0 && !c.IsObject() {
+ return errors.New(path + " isn't settings Tuanjie Cowork reads, so magpie leaves it alone")
+ }
+ if p := prov(c); p.Exists() && !mine(p) {
+ return errors.New("Tuanjie Cowork has a model provider of its own with the id magpie (" + path + "), so magpie leaves it alone")
+ }
+ if m := find(c, coworkModels, "id", magpieID); m.Exists() && m.Get("providerId").String() != magpieID {
+ return errors.New("Tuanjie Cowork has a model of its own with the id magpie (" + path + "), so magpie leaves it alone")
+ }
+ if !prov(c).Exists() {
+ forget(keyNew)
+ if !isFile(path) {
+ stash(map[string]string{keyNew: "1"})
+ }
+ }
+ return wire(c, ref)
+ }
+ if mine(prov(c)) {
+ if err := unwire(c); err != nil {
+ return err
+ }
+ } else {
+ forget(keyNew)
+ }
+ if v == "" {
+ return nil
+ }
+ return errors.New("Tuanjie Cowork picks its own models in its model menu, so magpie can't set " + v + " there")
+ },
+ Options: func(cur map[string]string) []Option {
+ return withVia(group("Tuanjie Cowork", nil), id, magpieID+"/")
+ },
+ }},
+ }, path)
+}
diff --git a/internal/agent/tuanjiecowork_test.go b/internal/agent/tuanjiecowork_test.go
new file mode 100644
index 000000000..7324adf5e
--- /dev/null
+++ b/internal/agent/tuanjiecowork_test.go
@@ -0,0 +1,219 @@
+package agent
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/edit"
+)
+
+// coworkUser is a ~/.codely/settings.json as Tuanjie Cowork 2.1.6 saves
+// one: a provider and a model of the user's, and settings of its own.
+const coworkUser = `{
+ "migratedToSingleProvider": true,
+ "migratedToMultiProvider": true,
+ "customModelProviders": [
+ {
+ "id": "custom-provider",
+ "name": "My Relay",
+ "baseUrl": "https://relay.example/v1",
+ "apiKey": "sk-own",
+ "authType": "openai",
+ "flashModelId": "glm-4.5"
+ }
+ ],
+ "customModels": [
+ {
+ "id": "glm-4.5",
+ "model": "glm-4.5",
+ "providerId": "custom-provider",
+ "displayName": "glm-4.5",
+ "roles": ["model", "flashModel"],
+ "wireApi": "chat",
+ "supportsMultimodal": false
+ }
+ ],
+ "language": "zh-CN"
+}
+`
+
+func coworkRead(t *testing.T, path string) map[string]any {
+ t.Helper()
+ var m map[string]any
+ b, _ := os.ReadFile(path)
+ if err := json.Unmarshal(b, &m); err != nil {
+ t.Fatalf("%v\n%s", err, b)
+ }
+ return m
+}
+
+// coworkEntry is the entry of list in m whose id is id, nil for none.
+func coworkEntry(m map[string]any, list, id string) map[string]any {
+ xs, _ := m[list].([]any)
+ for _, x := range xs {
+ if x, _ := x.(map[string]any); x["id"] == id {
+ return x
+ }
+ }
+ return nil
+}
+
+// TestTuanjieCowork: magpie adds a provider and a model of its own to
+// Tuanjie Cowork's Custom Models, at the gateway's /v1 with Cowork's key
+// on chat completions (Charles24209792 on X), the user's own left as they
+// are; stepping out takes them out again.
+func TestTuanjieCowork(t *testing.T) {
+ home, _ := museHome(t)
+ path := filepath.Join(home, ".codely", "settings.json")
+ writeFile(t, path, coworkUser)
+ want := coworkRead(t, path)
+ a := tuanjieCowork(home)
+ if a.Path != path {
+ t.Fatalf("path: %s", a.Path)
+ }
+ if !a.Detected() {
+ t.Fatal("not detected with ~/.codely")
+ }
+ f := a.Field("model")
+ if v := f.Get(); v != "" {
+ t.Fatalf("before: %q", v)
+ }
+ at := here(home)
+ if err := f.Set("magpie/deepseek/pro"); err != nil {
+ t.Fatal(err)
+ }
+ m := coworkRead(t, path)
+ p := coworkEntry(m, "customModelProviders", "magpie")
+ if p == nil || p["baseUrl"] != at.v1() || p["apiKey"] != agentKeyAt("tuanjie-cowork", at.gw()) || p["authType"] != "openai" || p["name"] != "magpie" {
+ t.Fatalf("provider: %v", p)
+ }
+ mm := coworkEntry(m, "customModels", "magpie")
+ if mm == nil || mm["providerId"] != "magpie" || mm["model"] != "deepseek/pro" || mm["displayName"] != "deepseek/pro" ||
+ mm["wireApi"] != "chat" || !reflect.DeepEqual(mm["roles"], []any{"model"}) {
+ t.Fatalf("model: %v", mm)
+ }
+ // the user's own, and the rest of the file, as written
+ if !reflect.DeepEqual(coworkEntry(m, "customModelProviders", "custom-provider"), coworkEntry(want, "customModelProviders", "custom-provider")) ||
+ !reflect.DeepEqual(coworkEntry(m, "customModels", "glm-4.5"), coworkEntry(want, "customModels", "glm-4.5")) ||
+ m["language"] != "zh-CN" || m["migratedToMultiProvider"] != true {
+ t.Fatalf("the user's settings changed: %v", m)
+ }
+ if v := f.Get(); v != "magpie/deepseek/pro" {
+ t.Fatalf("get: %q", v)
+ }
+ if c := a.Check(); c != "" {
+ t.Fatalf("check: %s", c)
+ }
+
+ // renamed and given a role in Cowork: kept when the model changes,
+ // one model still, its id the one Cowork's pick holds
+ edit.SetJSON(path, edit.KV{Path: "customModelProviders.1.name", Value: "Mine"},
+ edit.KV{Path: "customModels.1.roles", Value: []string{"model", "multimodalModel"}})
+ if err := f.Set("magpie/deepseek/flash"); err != nil {
+ t.Fatal(err)
+ }
+ m = coworkRead(t, path)
+ if p := coworkEntry(m, "customModelProviders", "magpie"); p["name"] != "Mine" {
+ t.Fatalf("name: %v", p)
+ }
+ if mm := coworkEntry(m, "customModels", "magpie"); mm["model"] != "deepseek/flash" || !reflect.DeepEqual(mm["roles"], []any{"model", "multimodalModel"}) {
+ t.Fatalf("model: %v", mm)
+ }
+ if n := len(m["customModels"].([]any)); n != 2 {
+ t.Fatalf("%d models", n)
+ }
+
+ // the gateway moved: Sync writes the new address
+ edit.SetJSON(path, edit.KV{Path: "customModelProviders.1.baseUrl", Value: "http://127.0.0.1:1/v1"})
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ if p := coworkEntry(coworkRead(t, path), "customModelProviders", "magpie"); p["baseUrl"] != at.v1() {
+ t.Fatalf("after Sync: %v", p)
+ }
+
+ if err := f.Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if got := coworkRead(t, path); !reflect.DeepEqual(got, want) {
+ t.Fatalf("not put back:\n%v\nwant\n%v", got, want)
+ }
+ if v := f.Get(); v != "" {
+ t.Fatalf("after: %q", v)
+ }
+ // a model of Cowork's own is its pick, not magpie's to set
+ if err := f.Set("glm-4.5"); err == nil || !strings.Contains(err.Error(), "model menu") {
+ t.Fatalf("own model: %v", err)
+ }
+ if got := coworkRead(t, path); !reflect.DeepEqual(got, want) {
+ t.Fatalf("an own model wrote: %v", got)
+ }
+}
+
+// TestTuanjieCoworkMadeFile: with no settings.json magpie makes one, kept
+// private as Cowork's own, and takes it away again on off.
+func TestTuanjieCoworkMadeFile(t *testing.T) {
+ home, _ := museHome(t)
+ path := filepath.Join(home, ".codely", "settings.json")
+ a := tuanjieCowork(home)
+ if a.Detected() {
+ t.Fatal("detected with no ~/.codely and no app")
+ }
+ f := a.Field("model")
+ if err := f.Set("magpie/deepseek/pro"); err != nil {
+ t.Fatal(err)
+ }
+ fi, err := os.Stat(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if runtime.GOOS != "windows" && fi.Mode().Perm() != 0o600 {
+ t.Fatalf("mode %v", fi.Mode())
+ }
+ if v := f.Get(); v != "magpie/deepseek/pro" {
+ t.Fatalf("get: %q", v)
+ }
+ if err := f.Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if isFile(path) {
+ b, _ := os.ReadFile(path)
+ t.Fatalf("left behind: %s", b)
+ }
+}
+
+// TestTuanjieCoworkLeavesTheUsersMagpie: an id magpie of the user's own,
+// a provider or a model, is theirs, and magpie writes nothing over it.
+func TestTuanjieCoworkLeavesTheUsersMagpie(t *testing.T) {
+ for name, file := range map[string]string{
+ "provider": `{"customModelProviders":[{"id":"magpie","name":"m","baseUrl":"https://relay.example/v1","apiKey":"sk-own","authType":"openai"}],"customModels":[]}`,
+ "model": `{"customModelProviders":[{"id":"custom-provider","name":"m","baseUrl":"https://relay.example/v1","apiKey":"sk-own","authType":"openai"}],"customModels":[{"id":"magpie","model":"x","providerId":"custom-provider","roles":["model"],"wireApi":"chat"}]}`,
+ } {
+ t.Run(name, func(t *testing.T) {
+ home, _ := museHome(t)
+ path := filepath.Join(home, ".codely", "settings.json")
+ writeFile(t, path, file)
+ a := tuanjieCowork(home)
+ if err := a.Field("model").Set("magpie/deepseek/pro"); err == nil || !strings.Contains(err.Error(), "of its own") {
+ t.Fatalf("set: %v", err)
+ }
+ if b, _ := os.ReadFile(path); string(b) != file {
+ t.Fatalf("written: %s", b)
+ }
+ if v := a.Field("model").Get(); v != "" {
+ t.Fatalf("get: %q", v)
+ }
+ if err := a.Field("model").Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if b, _ := os.ReadFile(path); string(b) != file {
+ t.Fatalf("written on off: %s", b)
+ }
+ })
+ }
+}
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 401756854..d7aa4432f 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -4684,6 +4684,7 @@ const I18N = {
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo 启动时读取配置,需重启已打开的 empryo 会话才会生效。",
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot 的 gateway 和 WebUI 会在下一次回复时用上它;已打开的 `nanobot agent` 对话需重启才会生效。",
"Craft Agents starts its new sessions on this; a session already open stays on the connection it started on.": "Craft Agents 的新会话会用上它;已打开的会话仍使用它开始时的连接。",
+ "Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.": "在 Tuanjie Cowork 的模型菜单里选 magpie 的模型;若还没出现,请重启 Tuanjie Cowork。",
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "重启 miniQ 才会生效:正在运行的后台仍用启动时的服务商。",
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI 启动时读取设置,需重启已打开的 gemini 会话才能看到。",
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose 启动时加载供应商,需退出并重新打开 Goose(以及已打开的 goose 会话)才能使用 magpie 的模型。",
@@ -9605,6 +9606,7 @@ const I18N = {
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo 啟動時讀取設定,需重啟已打開的 empryo 會話才會生效。",
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot 的 gateway 和 WebUI 會在下一次回覆時用上它;已開啟的 `nanobot agent` 對話需重啟才會生效。",
"Craft Agents starts its new sessions on this; a session already open stays on the connection it started on.": "Craft Agents 的新工作階段會用上它;已開啟的工作階段仍使用它開始時的連線。",
+ "Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.": "在 Tuanjie Cowork 的模型選單裡選 magpie 的模型;若還沒出現,請重新啟動 Tuanjie Cowork。",
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "重新啟動 miniQ 才會生效:正在執行的背景服務仍用啟動時的服務商。",
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI 啟動時讀取設定,需重啟已打開的 gemini 會話才能看到。",
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose 啟動時載入供應商,需退出並重新打開 Goose(以及已打開的 goose 會話)才能使用 magpie 的模型。",
@@ -14528,6 +14530,7 @@ const I18N = {
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo は起動時に設定を読み込みます。反映するには開いている empryo セッションを再起動してください。",
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot の gateway と WebUI は次の返信からこれを使います。開いている `nanobot agent` のチャットは再起動すると反映されます。",
"Craft Agents starts its new sessions on this; a session already open stays on the connection it started on.": "Craft Agents の新しいセッションからこれを使います。開いているセッションは開始時の接続のままです。",
+ "Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.": "Tuanjie Cowork のモデルメニューで magpie のモデルを選んでください。まだ表示されない場合は Tuanjie Cowork を再起動してください。",
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "反映するには miniQ を再起動してください。実行中のデーモンは起動時のプロバイダーを使い続けます。",
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI は起動時に設定を読み込みます。反映するには開いている gemini セッションを再起動してください。",
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose は起動時にプロバイダを読み込みます。magpie のモデルを使うには Goose(と開いている goose セッション)を終了して開き直してください。",
@@ -19451,6 +19454,7 @@ const I18N = {
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo liest seine Konfiguration beim Start – offene empryo-Sitzungen neu starten, damit es gilt.",
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobots Gateway und WebUI übernehmen das bei der nächsten Antwort; einen offenen `nanobot agent`-Chat neu starten, damit es dort gilt.",
"Craft Agents starts its new sessions on this; a session already open stays on the connection it started on.": "Neue Craft-Agents-Sitzungen nutzen das; eine offene Sitzung bleibt bei der Verbindung, mit der sie begonnen hat.",
+ "Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.": "Wähle das Modell von magpie im Modellmenü von Tuanjie Cowork; fehlt es dort noch, starte Tuanjie Cowork neu.",
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "Starte miniQ neu, damit es gilt: sein laufender Daemon behält den Anbieter, mit dem er gestartet ist.",
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI liest seine Einstellungen beim Start – offene gemini-Sitzungen neu starten, um es zu sehen.",
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose lädt seine Anbieter beim Start – Goose (und offene goose-Sitzungen) beenden und neu öffnen, um magpies Modelle zu nutzen.",
@@ -19737,6 +19741,7 @@ const NOTICES = [
"Empryo reads its config at start-up — restart open empryo sessions to use this.",
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.",
"Craft Agents starts its new sessions on this; a session already open stays on the connection it started on.",
+ "Pick magpie's model in Tuanjie Cowork's model menu; if it isn't there yet, restart Tuanjie Cowork.",
"Restart miniQ to use this: its running daemon keeps the provider it started with.",
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.",
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.",
diff --git a/internal/gui/assets/icons/tuanjie-cowork-color.svg b/internal/gui/assets/icons/tuanjie-cowork-color.svg
new file mode 100644
index 000000000..fdab3f35f
--- /dev/null
+++ b/internal/gui/assets/icons/tuanjie-cowork-color.svg
@@ -0,0 +1 @@
+
diff --git a/internal/library/targets.go b/internal/library/targets.go
index bc48edeb7..5e1918649 100644
--- a/internal/library/targets.go
+++ b/internal/library/targets.go
@@ -349,6 +349,12 @@ func targetOf(a *agent.Agent) *Target {
// workspaces' own. Its MCP servers are sources of a workspace,
// which magpie doesn't write.
t.Skills = sharedSkillsDir()
+ case "tuanjie-cowork":
+ // Tuanjie Cowork counts ~/.agents/skills as the user's skills beside
+ // Codely's own ~/.codely-cli/skills (its core's skill scan, scope
+ // "user-alias", 2.1.6-stable). Its MCP servers are Codely's settings,
+ // which magpie doesn't write for it.
+ t.Skills = sharedSkillsDir()
case "openbot":
// OpenBot reads skills only from ~/.agents/skills (home-skills.ts,
// HOME_SKILL_FOLDER). Its MCP servers are rows in its SQLite
diff --git a/site/public/icons/tuanjie-cowork-color.svg b/site/public/icons/tuanjie-cowork-color.svg
new file mode 100644
index 000000000..fdab3f35f
--- /dev/null
+++ b/site/public/icons/tuanjie-cowork-color.svg
@@ -0,0 +1 @@
+
diff --git a/site/public/index.html b/site/public/index.html
index 115465392..a95c43a85 100644
--- a/site/public/index.html
+++ b/site/public/index.html
@@ -523,6 +523,7 @@ footer a:hover { color: var(--ink); }