Commit Graph
16 Commits
Author SHA1 Message Date
yetoneandump45nose 3618bf9f22 zed 0.1.14: a Gemini model's effort variants are keyed lowercase, and its thinking level reaches Zed uppercase (#215)
Zed's cloud parses a Google request with its own serde enums (zed
crates/google_ai): ThinkingLevel is rename_all UPPERCASE (MINIMAL, LOW,
MEDIUM, HIGH) and FunctionCallingMode rename_all lowercase (auto, any,
none). A thinking budget reached it as thinkingLevel "low" and was
answered 400 "failed to parse Google AI request: unknown variant `low`,
expected one of `MINIMAL`, `LOW`, `MEDIUM`, `HIGH`" (iron-water, #215).

- The gemini wire in providerRequest() now goes through geminiEnums(),
  from ump45nose's #587: the thinking level is uppercased (an empty one
  left out) and the tool-calling mode lowercased, as 0.1.13 already did,
  with VALIDATED, which Zed has no variant for, asked as auto.
- Zed's /models now lists a Gemini model's supported_effort_levels
  uppercase (LOW/MEDIUM/HIGH; Yezike-yyy's Student-plan list on #215), so
  the variants were keyed LOW and carried thinkingLevel "LOW". magpie's pi
  profile, which maps efforts by key, matched none of them, and
  @ai-sdk/google (thinkingLevel z.enum minimal/low/medium/high) refuses
  an uppercase level. effortsOf() now lowercases the values whatever case
  /models writes, once each, so a variant keeps the AI SDK's lowercase
  spelling (the owner's review on #587) and only the wire is uppercase.
  This covers every vendor's efforts, not only Google's.
- _internal exports model() so the test checks provider.models' variants.

Tests: gemini-enums.test.mjs builds its model list from the
supported_effort_levels Yezike-yyy pasted on #215, byte for byte, and its
fake /completions refuses both enums with Zed's error text.

Run on mote at f4e2ac3 plus this change: packages/zed `bun test` 61 pass,
0 fail; root `HOME=$(mktemp -d) bun test` 4545 pass, 0 fail; `bun
scripts/check.mjs` ok. (A root run with a HOME outside tmpdir gives the
same 20 devin/isolated-home reds on origin/main as with this change.)
Broken by hand:
- origin/main's index.mjs under the new test: 7 of 7 fail;
- effortsOf without the lowercase: 4 fail;
- the wire level not uppercased: 2 fail;
- VALIDATED not mapped to auto: 1 fail.
Not tried: a live request to cloud.zed.dev and OpenCode with the real
@ai-sdk/google (no Zed account here). Yezike-yyy reports the same two
changes, patched into 0.1.13, answered 200 for low/medium/high on
zed/gemini-4-argon through magpie on Windows with pi.

Thanks to Yezike-yyy for the uppercase /models finding and its check
through pi.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-11-01 23:44:10 +08:00
yetoneandggbdpq f4e2ac36fe zed 0.1.13: a Gemini request's tool-calling mode goes to Zed's cloud in lowercase (magpie#4657)
Zed's cloud reads toolConfig.functionCallingConfig.mode with lowercase
variants only (auto, any, none). The Gemini API's proto enums, which the
AI SDK's @ai-sdk/google and magpie's Code Assist envelope both write
(AUTO, ANY, NONE), were answered 400 "failed to parse Google AI request:
unknown variant `AUTO`, expected one of `auto`, `any`, `none`", so every
Gemini turn that declared a tool failed while plain chat and a model test
worked (atticuskk on magpie#4657). providerRequest's gemini case now
lowercases the mode; nothing else in the request moves.

ggbdpq (gua2100) found the cause and proposed the fix on magpie's side
(a body fitter for the zed account). It is made here instead, where the
request is fitted to Zed's cloud: the plugin is what knows Zed's wire, and
OpenCode users of this plugin, whose @ai-sdk/google writes AUTO too, are
covered the same way.

Run (mote): cd packages/zed && bun test: 54 pass, 0 fail;
bun scripts/check.mjs zed: ok. Broken by hand: the lowercase line off ->
gemini-tool-mode.test.mjs red (3 fail, 400 for AUTO, ANY, NONE).
Not tried: a live request to cloud.zed.dev (no Zed account here).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-01 22:23:14 +08:00
yetone 3e940bc81b zed 0.1.12: a string message content goes to Zed's cloud as a text block
Zed's cloud parses an Anthropic body's message content as blocks only, and
answers a string, which Anthropic's own API takes, with 400 "failed to parse
Anthropic request: invalid type: string \"hi\", expected a sequence".
magpie's Test models sends {"role":"user","content":"hi"}, so every Claude
model failed its test in Zed's provider page (Been on Discord, 0.1.11). The
anthropic wire now turns each turn's string content into one text block; a
top-level system string is left as sent (Zed takes it either way).

Not here: Gemini's "missing field contents" in the same test is magpie
sending a non-Gemini body to a plugin's @ai-sdk/google model; fixed in
magpie.

Run (mote-run, bun 1.4.2): packages/zed bun test, 49 pass 0 fail.
Broken by hand: with index.mjs reverted, string-content.test.mjs is 0
pass 2 fail. system-role.test.mjs's effort test now expects blocks.
2026-10-31 22:03:06 +08:00
yetone 3d355d349d zed 0.1.11: a {role: "system"} message inside an Anthropic request reaches Zed as user text where it was said, not as a role Zed refuses
Roy on Discord, Claude Code through magpie on a Zed subscription:
"API Error: 400 Zed: failed to parse Anthropic request: unknown variant
system, expected user or assistant".

Cause: Claude Code (2.1.288 on) writes {role: "system"} messages inside
messages[]: an empty one carrying a turn's effort as output_config, and
(2.1.296) one after tool results with its hooks' notices, <total_tokens>
and what the user typed while a tool ran. Anthropic's API takes them in
place. magpie's gateway passes them on as written (anthropic_shapes.go
mends only after a refusal matching `messages.N.role`, which Zed's serde
message doesn't), and the plugin's providerRequest "anthropic" case
forwarded them to Zed, whose Anthropic Role is user | assistant only.

Fix: providerRequest's anthropic case runs withoutSystemTurns. Each
system message's text goes, as text blocks (cache_control kept), into a
user turn at the same place: appended to the user message before it;
else after the leading tool_result blocks of the user message after it
(tool results must stay first); else a user message of its own. One with
no text (an effort alone) is left out; the request's top-level
output_config still carries the effort.

Why in place and not folded into the top-level system: the prompt cache's
prefix is tools, then system, then messages. Text appended to system on
each turn that has a notice changes the prefix ahead of every message, so
the whole conversation misses the cache from then on, while merging in
place changes only bytes at the conversation's tail, which the next
request repeats unchanged (the transform is deterministic per message).
It also keeps the meaning Anthropic's API gives the message: said at that
point in the turn, not standing instructions for the whole conversation.
magpie's own withSystemOnTop folds to the top for Command Code, which
refuses the role by name; that path never fires for Zed's wording.

Siblings, not changed: responses (OpenAI Responses) and chat (xAI Chat
Completions) both have system/developer roles in their own message
schemas, so a system message there is not this error; gemini has no
system role in contents (the AI SDK sends systemInstruction). None was
tried against Zed's cloud with a mid-conversation system message, and
there is no report of one.

Tests (system-role.test.mjs, built from Claude Code's shapes and
checking the provider_request the plugin hands Zed's /completions):
a hook notice after tool results joins their user turn after the
results and system stays as sent; an empty effort-only system message
is left out; system text before a tool-result user turn goes after the
results, and one after an assistant turn becomes a user turn. With
index.mjs reverted to 43ffb46 all 3 fail; with the fix all pass.

Run at 43ffb46 + this change: `HOME=$(mktemp -d) bun test` in
packages/zed: 47 pass, 0 fail. `bun scripts/check.mjs`: ok (exit 0).
Not tried: a real Zed account (none in a sandbox HOME here); the shape
Zed accepts is Anthropic's user/assistant messages, as the plugin
already sends for every request without system messages.
2026-10-22 10:00:12 +08:00
yetone 5a836745fb zed 0.1.10: the organization with a plan is the one asked under, not a default without one, and a 402 for the saved one moves the account (#232, ReneXiong)
ReneXiong's account has two organizations: the personal one on
zed_student and a non-personal default with no plan. orgOf() always took
default_organization_id, minted the model token for it, and /models and
/completions answered 402 "Organization does not have an active
subscription". planOf() fell back to the account's plan_v3, so the card
said Student over an organization with none.

What Zed's editor does (zed-industries/zed 56934ec): user.rs
update_authenticated_user starts in the default organization, else the
first; the title bar's organization menu calls set_current_organization,
which the LLM token's auth context (language_models cloud.rs
ClientTokenProvider) follows; plan() is plans_by_organization[current],
none when it has no entry (current_organization_has_no_active_subscription
treats a missing entry as no subscription; an unknown plan as Free). The
plugin has no switcher, so it now picks as a user switching would:
- the organization the sign-in saved, while it still has a plan that
  calls models (any but Free) and models aren't turned off for it;
- else the default, if it has one; else the personal one with one; else
  any with one;
- none with one: what Zed picks (saved, else default, else first).
planOf names the picked organization's own plan ("" without an entry);
only a reply with no organizations falls back to plan_v3.

A sign-in saved before this under the unsubscribed default is moved on
the first 402 (llm_tokens, /models, /completions) or empty list: the
account is read again, moved if another organization has a plan, the
move saved through client.auth.set (and kept in memory in case the save
doesn't land), and the request asked once more. The usage hook re-picks
the same way. The model-token cache and the model list are keyed by
organization now, so a move mints and lists anew. There is no explicit
organization choice in the plugin or in magpie to respect; the saved
organization is the sticky one.

Run (bun 1.4.2, macOS, worktree at origin/main 8cdf2d2 + this):
- packages/zed/org.test.mjs (new, no network: fetch stubbed): 11 pass.
  With the old index.mjs and the new tests: 10 fail, 1 pass (the
  no-plan fallback the old code also did).
- HOME=$(mktemp -d) bun test (whole repo): 1802 pass, 0 fail.
- bun scripts/check.mjs: every package ok.
Not tried against a real Zed account; the reporter's /users/me shape is
from the issue's sanitized read.
2026-10-19 01:04:57 +08:00
yetone 779388ba04 zed 0.1.9: a signed-in account whose model list was never read says why, instead of showing the six pre-sign-in models as its own (#229, ReneXiong)
ReneXiong's Zed Student account (an organization without an active
subscription) showed "zed (Zed, 6 models)" with no error: the six
models the config hook declares before sign-in, with their hard-coded
limits. provider.models handed those back whenever /models failed and no
list had been read for the account. The likely path for this account is
a 200 whose models are all disabled: parseModels throws "Zed lists no
models for this account", the hook returned the declared list, and
magpie's host, seeing the last fetch answer 200, didn't mark the list as
fallen back, so nothing said it wasn't the account's.

Now, with no list ever read for the account, the hook throws the reason
(Zed's own "Zed: ... (status)", "Zed lists no models for this account
...", or "Zed: this account's models couldn't be read: <cause>"). magpie's
host takes a thrown models error as fellBack with that message as
listError, and the editor and `magpie providers` show "couldn't list its
models: <reason>". A list read before is still kept on a later failure,
as it was. A 401 for the model token still marks the sign-in expired.

Tests (bun 1.4.2, packages/zed): models.test.mjs 7 pass. With the old
index.mjs and the new tests, 3 fail: "the list refused with the token
just minted", "Zed down before any list", "a 200 listing nothing
callable" (each got the declared models back). Whole package: 33 pass,
0 fail.

Siblings: minimax, qoder, trae, raccoon, workbuddy and opendesign also
return provider.models on a failed list. Each of those checks a
response status magpie's host sees, so a failed read is marked as
fallen back with its HTTP status; not changed here. Not tried against a
real Zed account.
2026-10-18 21:45:42 +08:00
yetone 47a8bb40d2 zed 0.1.8: a free account's card says "No plan", as the built-in's did, and the README says what the plugin and magpie now do
What changed:
- usage: magpie's built-in zedLoginQuota showed a free account's card
  (plan_v3 zed_free, or none) as "No plan", unless an overdue invoice was
  its error, while the account row kept zed.PlanName's "Free". magpie's
  card knows "No plan" (app.js noPlan) and translates it. The plugin's card
  said "Free". It now says "No plan" in the same case; the sign-in still
  saves planName "Free", and an overdue free card keeps "Free" with its
  error, as the built-in's switch did.
- README: "Not included" listed the plan display, which the usage hook has
  shown since 0.1.x, and several accounts and the web-search stand-in,
  which magpie gives a plugin provider itself (plugin_accounts.go, the
  gateway's generic searchReply path). It is now a "Usage" section and an
  "In magpie, not the plugin" section.

What was run:
- usage.test.mjs: the free-account test (zed_free, "" and an overdue free
  account) fails on 0.1.7's index.mjs ("Free" for "No plan"), passes now.
- packages/zed under a scratch HOME: 31 pass, 0 fail (4 files).
- bun scripts/check.mjs zed passes.

Not tried: a real free Zed account.
2026-10-16 17:36:24 +08:00
yetone e105f567db zed 0.1.7: a streamed xAI (chat) reply Zed breaks off after it said something ends cut short, with a note, instead of failing the turn (#91)
This is the sibling of zen-free 0.1.4 (6a5dd01). magpie's gateway goes on
with an Anthropic or Responses reply that was cut short, but not with a
Chat Completions one. For those, the error frame after a 200 threw away
the reply the client had already been shown.

Now, when a chat stream loses Zed's stream_ended, the plugin looks at what
the choices already said:
- If no choice is still open, only [DONE] is added.
- If a choice said text or reasoning and has no tool call half written,
  each open choice gets the note and a `stop`, then [DONE].
- If nothing was said, or a tool call is still unfinished, it fails as
  before.
Anthropic, Responses and non-streamed replies are unchanged.

Run: HOME=$(mktemp -d) bun test packages/zed gave 31 pass. The whole
repo's bun test gave 1129 pass, 0 fail. bun scripts/check.mjs passed. On
the old index.mjs, the 2 new tests that cover the cut-short endings fail.
With the tool-call guard removed by hand, the tool-call test fails.

Not tried: a real Zed account (there is none to test with). The
upstream's cut can't be triggered.
2026-10-12 20:31:33 +08:00
yetone 8f25b63718 publish from GitHub Actions with npm's trusted publishing, no one-time password [skip ci]
.github/workflows/publish.yml runs the tests (in a throwaway HOME) and
scripts/publish.sh on each package.json change pushed to main, or by hand;
npm's OIDC exchange stands in for a token and an OTP. Every package now
names magpie-community/plugins' publish.yml as its trusted publisher on
npmjs.com, and gets the repository field npm checks it against.
2026-10-03 00:00:23 +08:00
yetone 7b072d798b zed 0.1.6: a model token Zed refuses while listing the models marks the account, as the built-in's zedLapse did there — the models hook throws with signIn: expired on the refusal (magpie 78c3229 reads it), and falls back to the listed models on any other failure as before. models.test.mjs fails without the change. 2026-10-01 06:34:07 +08:00
yetone 85d7dd0d0a all: each plugin fails with its built-in's status and marks the sign-in as it did, through X-Magpie-Sign-In (要保证插件跟内置的所有逻辑都要一模一样) — Factory's and MiMo's refused renewals are the built-ins' 502 marked expired, not 401s; Qoder's vendor 403 is the built-in's 401 kept, its model list's failure a 400, its job refresh refused marked expired; Zed's retried 401 is a 401 kept, not a 403; Kiro's unreachable refresh a 401 kept; Cursor's expired trial a 401 kept; a vendor 401 WorkBuddy, Grok, Devin, Command Code and ZCode passed on no longer marks the account, as their built-ins never did, and Grok and MiMo no longer retry what their built-ins sent once. Messages take the built-ins' words. New tests fail against the previous index.mjs. 2026-10-01 04:47:03 +08:00
yetone 53e0db6648 zed 0.1.4: a streamed reply is held until it says something, as the built-in's relayStatus holds it, and a failure before that is answered with its status rather than a 200 carrying it — Zed's failed status keeps the status its code names (upstream_http_401 a 401, http_403 a 403, billing a 402, where magpie read the old stream's chat and Responses errors as 502s), the provider's own error event is a 502 with its message, a reply ended with nothing said is a 502 "Zed ended without an answer" and one cut short a 502; a whole reply carrying the provider's error is that error (it was a 200 with nothing in it), and a code outside 400–599 is a 502. errors.test.mjs fails without the change. 2026-10-01 03:45:58 +08:00
yetone 3d3f3b7bf1 zed 0.1.3: an account reply that can't be read is the card's error, as zed.FetchMe says it (Zed: an unreadable account: <encoding/json's words>), not a plan-less card; a free account reads Free, as the built-in's row names it (zed.PlanName); a model token refused right after it was minted is a 403, not a 401 magpie would take for a lapsed sign-in; errors no longer start with "Zed: ", which magpie adds; a model Zed gives no limits has none made up (was 200000/32000) 2026-10-01 03:12:11 +08:00
yetone c8f4d448df Parity with magpie's built-ins: a failed sign-in says why, CLI-backed Command Code and Devin accounts follow the CLI's key, Factory's refused renewal is a 401 in the caller's API shape
- every {type:"failed"} carries an error reason magpie shows
- commandcode/devin: accounts taken from the CLI are marked metadata.cli and re-read its credentials on each request, usage and models
- factory: a refused refresh answers 401 authentication_error (Anthropic shape on /llm/a/, OpenAI's elsewhere) instead of throwing; the whoami back-off is per account; 403 hints name the account to sign in again
- versions: factory/devin/commandcode/cursor/kiro/mimo/zed/zcode 0.1.2, workbuddy 0.1.3
2026-10-01 00:55:50 +08:00
yetone bd9c0780cc zed 0.1.1: usage shows as magpie's built-in did — plan, period, windows and what they count, balancezed 2026-09-30 23:03:11 +08:00
yetone 620cf1329f zed: Zed — browser sign-in with Zed's key pair, model tokens minted as Zed does, Anthropic/OpenAI/Google/xAI requests wrapped for Zed's /completions 2026-09-30 17:08:36 +08:00