Commit Graph
248 Commits
Author SHA1 Message Date
yetone a810ee7e88 zen-free 0.1.6: a free-model request carries exactly the headers OpenCode 1.19.0 sends to Zen, and none of the caller's (xiaoxiaofeixz on magpie's Discord, #100, #108)
Since 10-13 Zen answers 403 FreeTierError ("OpenCode's free tier can only
be used from within OpenCode") to a free-model request that isn't
OpenCode's. npm still serves 0.1.1, which gets that 403 on every model;
0.1.5's OpenCode-form session id (9074723) fixed it but never reached npm.
The owner allows mimicking OpenCode's client on this route (client
mimicry is allowed for every vendor but Claude Code), so this reverses
643ef50's README note.

Diffed against the release binary itself: OpenCode 1.19.0
(anomalyco/opencode v1.19.0) run in a sandbox HOME with the opencode
provider's baseURL pointed at a local capture server, on chat, responses
and messages. It sends accept */*, content-type, user-agent
"opencode/1.19.0 ai-sdk/provider-utils/<v> runtime/bun/1.3.14" (4.0.23
chat, 4.0.40 responses, 4.0.46 messages), x-opencode-project, -session,
-request, -client, -session-id, and the key (authorization, or x-api-key
with anthropic-version). It sends no x-session-id or x-session-affinity
to its own gateway (session/llm/request.ts). 0.1.5 differed in: those two
extra headers, accept text/event-stream, the chat UA on every protocol,
and every header the caller sent going on (through magpie: the agent's
own User-Agent, x-stainless-*, anthropic-beta...).

0.1.6 builds the upstream headers from that list alone: the caller's are
read only for the session and project, anthropic-version/-beta kept on
messages. The new per-protocol test checks the exact set and fails on
0.1.5 (4 fails); the forced-streaming test now expects no
x-session-id/x-session-affinity.

Run:
- bun test in packages/zen-free: 169 pass, 3 runs; bun scripts/check.mjs
  zen-free passes.
- Real opencode.ai, anonymous key "public": npm's 0.1.1 gets 403
  FreeTierError on big-pickle, mimo-v2.6-flash-free and
  muse-spark-1.3-contributor-free, streamed and not. 0.1.6's
  tools-smoke.mjs: 200 with a Bash call on all three streamed and on
  big-pickle not streamed; muse non-streamed 200 without a call;
  mimo non-streamed timed out at 90s, the same on 0.1.5.
- magpie 0.1.1208 in a sandbox HOME (scripts/try.sh zen-free): sign-in
  with public, then `provider test opencode-zen-free`: chat (big-pickle)
  and responses (muse-spark) both pass.
Not tried: a messages-protocol free model (Zen has none free now), Windows.
2026-10-14 18:57:57 +08:00
yetone 98911ae4d4 trae 0.2.13: publish #106 (the call a service left mid-wrapper in a native call's name)
#106 merged as 0.2.12, which main had already published for the cache
fix (4df82ce), so it needs its own version to reach npm. Version bump
only. Ran: bun test in packages/trae, 129 pass.
2026-10-14 18:36:53 +08:00
YuCreateandyu b32b510c9d trae 0.2.12: the call a service left mid-wrapper in a native call's name is read as the call (#106)
trae-cn/glm-5.3 under DSH (2026-10-13): over three turns, 28 of 54 native calls
arrived with the model's call in `function.name` instead of `function.arguments`
— the JSON wrapper the tool prompt asks for, with GLM's own
<arg_key>/<arg_value> tags where Trae's service stopped reading it, and a value
whose close left off:

  {"name":"bash","arguments":{"command</arg_key><arg_value>ls -la</arg_value>
  {"name":"bash","arguments":{"command":"grep -n x a.ts | head -3</arg_value>
  {"name":"bash","arguments":{"command":"grep -n "x" a.ts","description":"…"}}
  bash_abstract_command_0>{"name":"bash","arguments":{"command":"…scan.mjs</description>Re-run scan</arg_value>

Each went out under a name no request declares, so the agent answered "unknown
tool" and the call was lost — twelve steps in a row before the model recovered.
All 28 sit in the context the session compacted at the end of turn 8: turn 9's
input went from ~5k to 94.5k tokens. Whether the compaction is what makes the
service hand a call back this way is not established — only that the two line
up, and that the session's earlier turns on workbuddy-ai/hy4-preview-f and
group/auto-hy4-preview-f sent 270 whole calls and none of this shape. No
workbuddy/glm-5.3 call was routed that day, so nothing is claimed about it.

- A name holding the wrapper is read as the call: the tool, then the fields the
  text between the tags still spells out. The tags are the service's own
  handoff, so what stands between them is the model's text as the model wrote
  it: a quote left unescaped is read as the quote it is, a value the service
  cut at its tag keeps the text it got, a comma inside a value is the model's
  own (`sed -n 1,9p` reads whole), and a closing tag that is a field's own
  (`</description>`) ends the value before it — what follows such a tag is the
  service's text, not the model's.
- A field the tool's schema says is no string is its JSON where the text is
  one, and its text where it isn't.
- The native call's own arguments are kept, and the name's fields are filled in
  beside them: the service moves the arguments it read into the call and leaves
  the rest in the name, so the two halves are one call (command in the name,
  description/workdir in the call).
- A name whose tool the request doesn't have, or one no field can be read from,
  goes on as written, as any other unknown tool does — including one the
  service cut before it wrote a value (at a key, at a colon, at an open quote),
  where an empty call read out of it would be a call the model never wrote.
  Calls already written into a session's history under a mangled name still go
  back on as that name; the plugin reads what it is handed and cannot rewrite
  what was already sent.
- What main already read of a whole name keeps reading the same (`input`,
  `parameters`, arguments given as a string, the flat fields, a wrapper written
  with a space), and a call's own arguments that are not a set of fields — text
  the service cut, a value that isn't a call's fields — go on as they stand, as
  main passed them, for the agent to answer.

The wrapper and the tags are upstream's; the plugin reads what it was handed.
The same shapes are already handled by the DSH-ecosystem relays (trae2api's
_ARG_KEY_VALUE_RE takes a key whose opening <arg_key> was dropped) and by
@ai-sdk-tool/parser's GLM-5 name resolution (a declared name followed by a
structural tag is that tool), which is where the fail-closed reading of an
unknown name comes from.

Run: namecall.test.mjs (16 tests; the real payloads, a name in front of the
wrapper, a field's closing tag cut into a value, a comma inside a value, the
whole-name shapes main reads, the shapes the reader must leave alone, and the
streamed path) — 11 of 16 fail on main's index.mjs, the five that pass being
the ones that pin what main reads.
HOME=<tmp> bun test, 125 pass 0 fail; bun scripts/check.mjs trae green. The 28
payloads this was drawn from were replayed through NativeCalls.take: 28
recovered into calls to tools the request declares, and the 270 calls that
arrived whole in the same session unchanged, byte for byte. Against the same
names and calls main can take (187 pairs) the only differences are the fields
the name's side fills in beside the call's own, and the names main could not
read at all.

Co-authored-by: yu <wowyuarm@users.noreply.github.com>
2026-10-14 18:36:39 +08:00
unship a6f09a0e9a qoder: add PAT (Personal Access Token) sign-in method (#103)
* qoder: add PAT (Personal Access Token) sign-in method

Add a new auth method that exchanges a PAT for a job token via
/api/v1/jobToken/exchange, bypassing the OAuth device flow. PATs are
long-lived (up to 1 year), avoiding the ~3-day re-authentication cycle
of OAuth refresh tokens.

Changes:
- Add patSignIn function for PAT → job token exchange
- Add "Sign in with Qoder PAT" method with password prompt
- Handle PAT accounts in usage (no device token available)
- Add pat.test.mjs with 10 tests covering both sites
- Update vpc.test.mjs for new method count

* qoder: use text prompt type for PAT (magpie has no password type)

magpie's prompt system only supports "text" and "select" types.
Change the PAT prompt from "password" to "text" to match.

* qoder: use password prompt type for PAT input

Now that magpie supports "password" prompt type, use it for PAT input
so the token is masked when typed in both GUI and TUI.

* qoder: address PR review — PAT kept, fields read as Qoder's client does

1. Store the PAT on the credential; when the job refresh lapses
   (SignInGone from refreshJob), re-exchange the PAT instead of
   marking the account signed out. The PAT lasts a year, the refresh
   two days.

2. Read the exchange response as Qoder's client does:
   - token from token, device_token or access_token
   - refresh from refresh_token or refreshToken
   - expiry from expire_time or expires_at (date) first, then
     expires_in in seconds (not milliseconds)

3. Use the openapi() helper for the exchange (no custom User-Agent);
   400/401/403 say "refused the PAT" rather than passing through the
   raw body.

4. Try the usage endpoint with the job token for PAT accounts; fall
   back to the "PAT" plan label if it won't accept it.

5. Exclude the PAT method from Qoder CN: its CLI uses device chat
   directly and never makes a job token, so a PAT exchange may not
   produce one the chat endpoint accepts.

* qoder: fix expires_in unit — milliseconds, not seconds

The real exchange response shows expires_in: 86400000 (24h in ms),
not 86400 (seconds). The expires_at date field takes precedence in
exchangeExpiry, so the fallback was not hit in practice, but correct
it for completeness.

* qoder: drive the renew test through the real refresh path, usage through fetchUsage

The renew test called the PAT sign-in directly, so it never met the
fallback it was named for. It now loads a stored expired credential
whose job refresh is refused, and checks the exchange is asked with the
stored PAT, the request goes on with the new token, and the saved
credential still carries the PAT — and fails when the fallback is
taken out. A second case keeps no PAT on the credential and expects
the sign-in gone to come out.

The PAT branch of usage built fetchUsage's request by hand and turned
every error into a plan of its own; it calls fetchUsage now, its
errors surfacing as the device path's do. A live PAT account answered
the usage endpoint 200 with a qoder envelope on the job token from the
exchange, said so in the comment there.

* qoder: a refused PAT re-exchange ends the sign-in

The renew fallback let a refused PAT through as a plain error, which
magpie read as a server fault and kept the account on. A PAT lapses
like a device sign-in does — expired, or revoked — so renew turns the
exchange's refusal into a lapsed sign-in: usage says "expired" and the
request answers 401, asking for a new PAT. Interactive sign-in keeps
the plain error.
2026-10-14 18:34:37 +08:00
yetone e87ea310c3 zen-free tests: the other 32+ MiB guard tests get the CRLF test's 60 s timeout
"cumulative pending chat tools are limited across choices and calls" and
"chat: completed tool buffers release their cumulative budget" push 33-34
MiB through guardToolResponse and timed out at bun's 5 s default on a
machine at load ~200-280 (5104 ms, 5299 ms, 5525 ms). The CRLF test had
the same cause and already carries { timeout: 60_000 }; its two siblings
that also move 32+ MiB ("single SSE event limit is 32 MiB...", "text
streams larger than 32 MiB...") get it too. The work itself is the
point of the tests (the 32 MiB limit), so it isn't shrunk.

Run: bun test in packages/zen-free 3x at load ~200: 166 pass each time.
Before the change the same file failed at this load. Tests only, no
version bump, nothing published.
2026-10-14 18:28:35 +08:00
yetone 2170a3781e factory 0.1.27: droid's Fast Mode models, and fast asked of their base model goes to them (#119)
psylch on #119 (plugin 0.1.26): claude-opus-5-5-fast answered "Factory:
Not found.", and Opus 5.5 asked with speed "fast" was recorded as
tier_asked fast, tier_served standard, with nothing said.

The plugin now offers droid 0.240.0's Fast Mode models: Opus 5.5/5/4.8
Fast on Anthropic's API, GPT-5.5/5.4/5.3-Codex Fast on Responses, each
at its base model's limits and efforts. They go out as droid 0.240.0
sends them (read from its binary, saved in testdata/droid-0.240.0-fast.txt):
the Fast Mode id itself as the model, with speed "fast" and the
fast-mode-2026-02-01 beta for anthropicFastMode models, at service_tier
"priority" for the GPT ones (their apiRequest Ee). A request asking a base
model for fast (speed "fast" on Messages, service_tier "priority" on
Responses) is sent to its Fast Mode model, as droid's fast toggle
switches to it. A model with no Fast Mode model is sent as asked. Left
out: Opus 4.6/4.7 Fast and GPT-5.4 Mini Fast (base not offered), GPT-5.6
Sol Fast (unreleased:!0), GLM-5.2 Fast (feature flag, a Baseten id).

Run: the full bun test (1222 pass, 0 fail) with a sandbox HOME; the new
fast.test.mjs and the picker test fail on the old index.mjs (4 fail).
Not tried: a real Factory account (none signed in here), so whether
Factory serves the Fast Mode ids at fast speed to a plan, and what its
usage says about speed, is unverified. A non-stream request magpie
translates for a plugin account drops speed before the plugin sees it,
so there only the -fast ids reach fast.
2026-10-14 17:53:22 +08:00
yetone 779e9b2368 kiro 0.1.11: a thinking model offers xhigh as its own level, so Claude Code's xhigh isn't routed as max (#120)
The variants came from BUDGETS (low, medium, high, max), while thinking()
already read xhigh. magpie fits an effort the model doesn't offer to the
nearest it does, so Claude Code's xhigh on a moved Kiro was recorded and
sent as max: 166 of the reporter's requests on 10-14, after the built-in,
which takes xhigh, had served it as xhigh the day before.

BUDGETS now has xhigh at 50k, the budget thinking() and the built-in's
kiroThinkingBudget give it, so what Kiro is asked is unchanged; only the
level magpie records and passes is. Both configModel and runtimeModel
read BUDGETS.

Run: bun test across the repo (TMPDIR+HOME in the scratchpad), all pass;
the new effort.test.mjs fails on the old BUDGETS. Not tried with a real
Kiro account (none signed in on this machine).
2026-10-14 17:28:46 +08:00
yetone 15d16f5ff0 workbuddy 0.1.21: a model free only at night is never said free; a whole-day discount shows the price before it (#121)
WorkBuddy's /v3/config prices a model by its "credits" and by a
modelPromotions list the picker reads for its badges: Hy3 限时免费 (whole
days to 10-31), Step-5-Preview 独家限免 (10-12..10-25), Hy4 preview 夜间免费
(free 23:00–8:00 only), GLM-5.2 and DeepSeek 夜间折扣. The plugin read only
"credits", and magpie keeps a plugin's model list until it next asks, so a
list read at night said Hy4 preview was free all day (#121's screenshot:
免费 in magpie, 0.29x and 夜间免费 in WorkBuddy).

priceOf now reads both. A model under a promotion with daily hours is given
at its full price and never as free (unpriced when the credits read 0 under
a night discount). A running whole-day discount is the price now, with the
credits before it as rateWas, which magpie already shows struck through.

Run:
- bun test across the repo (TMPDIR+HOME in the scratchpad): 1219 pass. The
  new price.test.mjs, built from the promotions copilot.tencent.com gave on
  2026-10-14, fails 3 on the old code.
- The owner's real WorkBuddy and WorkBuddy AI accounts through liveModels
  (17:10 CST): Hy4 preview 0.29, Hy3 and Step-5-Preview free, the rest at
  their credits, matching WorkBuddy's picker.

Not tried: the config as served at night (whether "credits" itself reads
x0.00 then); the unpriced branch covers that case.
2026-10-14 17:16:39 +08:00
yetone 4df82ce1b5 trae 0.2.12: what Trae's token_usage says the prompt cache read and wrote reaches magpie (01huadalang on magpie's Discord: K3, 53 calls, every one 0 cache hits)
tokensOf kept only prompt_tokens, completion_tokens and total_tokens of
Trae's token_usage, so every request reached magpie with no cache count
and Usage/Routing showed 0 hits. Trae's event carries more: TRAE SOLO
CN 3.5.20's ai-agent (libai_agent.dylib, the serde field list of
infrastructure/adapter/llm/event.rs's TokenUsageEvent, read from the
binary's __DATA_CONST) is name, prompt_tokens, completion_tokens,
total_tokens, reasoning_tokens, cache_creation_input_tokens,
cache_read_input_tokens, prompt_tokens_total, completion_tokens_total.

cache_read_input_tokens and cache_creation_input_tokens now go on in the
OpenAI usage under those names; magpie's gateway (chat.go cUsage) reads
them beside prompt_tokens as it reads a relay's in front of Claude, and
judges there whether prompt_tokens counts them too. An OpenAI
prompt_tokens_details.cached_tokens, if Trae sends one, is kept as it
came, and reasoning_tokens goes as completion_tokens_details. No cache
count adds no field.

cache.test.mjs (stream and single answer with the TokenUsageEvent's
fields, OpenAI's details, none) fails 3 of 4 on 0.2.11 and passes;
bun test (113 pass) and bun scripts/check.mjs trae under a temp HOME pass.
Not tried with a real Trae account (none here): that Trae fills the
cache fields for K3 in particular is not known.
2026-10-14 17:05:06 +08:00
yetone cff78b3424 devin 0.1.16: SWE-2 is free, so a used-up day and week don't hold it
太陽と向日葵 on magpie's Discord: SWE-2 costs nothing, but with the
account's quota used up magpie said so and didn't send SWE-2 to the
account, while a test of the model worked.

Devin's GetCliModelConfigs gives each model a model_cost_tier (field 24;
the CLI labels 1-4 "Low cost", "Med cost", "High cost", "Free"). On the
owner's account on 2026-10-14, of 262 configs only swe-2-high, -medium
and -max were 4. The plugin now reads that (parseFree), lists those
models and the entries standing only for them (swe-2) with free: true,
and gives the "1 day" and "7 days" windows notModels with their ids, so
magpie's allowance no longer counts them. ACUs are unchanged. When
Devin's configs can't be read, nothing is marked free and the windows
count every model, as before.

Run: bun test in packages/devin (58 pass) with HOME and TMPDIR in a
scratchpad dir; bun scripts/check.mjs. Broke it by hand: FREE_TIER=5
fails 3 of free.test.mjs's tests; dropping notModels fails the usage
one. Not tried: an account whose quota is really used up (the owner's
had 100% of the day and week left), so that Devin itself serves SWE-2
then is the reporter's word, not checked here.
2026-10-14 17:03:50 +08:00
yetone 95f7b51737 devin 0.1.15: every account's model list is Devin's own for its token, so Gemini 4 Argon is listed on Windows and without the CLI (#115)
On Windows the devin CLI reads %APPDATA%\devin\ whatever folder it is
given (#17), so cliAnswersFor turned it away for every account before
looking at whose sign-in it reads, and an account without the CLI never
asked at all. Both kept the 2026-09-30 SNAPSHOT, which has no Gemini 4
Argon; moving a built-in Devin with it ticked then failed with "the
plugin doesn't serve Gemini 4 Argon" (NieiR).

The list now comes from GetCliModelConfigs, asked with the account's
token (the call the plugin already made for images): its configs carry
each model's label, context (18), output (model_info 13), family uid
(model_info 23) and family label (30.1). Read over Devin's real response
for the owner's account, parseConfigFamilies gives exactly the 52
families and 262 variants `devin models list --format json` prints, in
its order, less Adaptive and Fusion. When Devin can't be asked, the CLI's
list is used if the CLI names the account Devin names the token's, even
when it reads its own folder (the Windows case); else SNAPSHOT, now
refreshed from the CLI (Gemini 4 Argon and Claude Haiku 5.5 added,
Inkling and Claude Sonnet 4.5 kept for the accounts still offered them).

Run:
- TMPDIR/HOME in a scratch dir, bun test packages/devin: 54 pass, 0 fail.
  With index.mjs put back to 0.1.14, the 4 new identity tests fail
  (parseConfigFamilies missing; familiesFor without gemini-4-argon;
  "models list" never run for a same-account CLI reading its own folder;
  provider.models without gemini-4-argon).
- bun scripts/check.mjs devin passes.
- Real account (owner's Devin, sandbox HOME, no devin CLI on PATH):
  provider.models gave 85 models with gemini-4-argon (1048576/1000000)
  and claude-haiku-5-5; 0.1.14 gave the declared list only.
Not tried: the Windows box itself; the new path doesn't run the CLI.
2026-10-14 15:57:04 +08:00
yetone 5c0aebce8f zcode 0.1.18: ZCode app's sign-in reads ZCode 3.15's plan key from config.json, so a valid GLM Coding Plan no longer reads as "no plan" (yetone/magpie#2130)
What changed: ZCode 3.15 keeps no coding plan key in credentials.json any
more. The key it uses is in config.json, at provider["builtin:bigmodel-
coding-plan" / "builtin:zai-coding-plan"].options.apiKey; ZCode 3.15.3's
host reads that value as it is. ownSignIn found no key, so a signed-in
GLM Coding Plan account fell to the Start Plan and read as having no plan.

ownSignIn now falls back to config.json (configKey) when credentials.json
has no key: Z.ai's first, then BigModel. It also takes the provider ids
3.15 normalizes to (account:*-individual-coding-plan) and a value written
encrypted. A value that isn't a key, such as "{env:...}", is skipped. A key
in credentials.json and a team switch still come first. This matches
magpie's built-in (magpie 1d8e83a79, zcodeOwn/zcodeConfigKey).

What was run:
- The new own.test.mjs case uses the reporter's layout (BigModel sign-in,
  no key in credentials.json, key in config.json). It fails without the
  fallback ("j1" in place of "bm.secret").
- Every packages/zcode test file passes under a scratch HOME/TMPDIR:
  dual 25, gift 20, models 1, moved 1, own 6, signin 3, start 10, usage 15.
- bun scripts/check.mjs passes.

Not tried: a real ZCode 3.15 account.
2026-10-14 15:45:44 +08:00
yetone e7d37b0801 factory 0.1.26: Gemini 4 Argon and Gemini 3.x on Factory's Gemini route (yetone/magpie#2080), a 413 retried with older images left out and said as Factory's byte limit (yetone/magpie#2082) 2026-10-14 14:26:29 +08:00
yetone 1bd6d172c1 factory: a 413 is asked once more with older images left out, then said as Factory's byte limit (yetone/magpie#2082)
Ziqi-Cui's Codex session on Opus 5.5 gathered nine screenshots, ~4.5 MB
of data URLs, and Factory answered every request after with 413 "Request
Entity Too Large". The plugin passed the 413 on as it came, which reads
as the context window; it is Factory's limit on a body's bytes.

On a 413 from Factory the plugin now sends the request once more with
every image and file but the newest replaced, in place, by a line saying
it was left out (droid 0.239.0 removes older images/PDFs from large
requests the same way). Anthropic image/document blocks, Responses
input_image/input_file, chat image_url/file and Gemini inlineData/fileData
are found wherever they are, tool results included, so every tool call
keeps its result; a Gemini function response's parts, which take inline
data alone, drop the image instead. One retry, never more; none when
there is nothing older to leave out.

If the 413 stands, or nothing could be left out, the error (Anthropic's
request_too_large, else invalid_request_error) gives Factory's words,
says the limit is on the body's bytes and what was left out, and carries
magpie's gateway 413 hint word for word (compact, or start a new
session), so the gateway, finding it, doesn't add it twice and OpenCode
users get it too. The words avoid what the gateway reads as a context
overflow, so it stays a 413.

The caller's own session and files are untouched: only the body sent to
Factory changes, and only on the retry.

Run: bun test in packages/factory (134 pass), bun scripts/check.mjs.
Broken by hand: without the 413 branch, three of size.test.mjs's four
tests fail. Not tried: a real Factory account (none here) or Factory's
real limit, which neither droid's binary nor its changelog states; the
fake upstream refuses over a chosen size.
2026-10-14 14:26:08 +08:00
yetone 60c905410e factory: Gemini 4 Argon and Gemini 3.x reach Factory's own Gemini route (yetone/magpie#2080)
The plugin offered no Gemini model, so Gemini 4 Argon, new in droid
0.241.1's picker, and the Gemini 3.x models magpie's built-in has were
missing for everyone moved onto the plugin.

- Gemini 4 Argon, Gemini 3.1 Pro, Gemini 3.8/3.7/3.6/3.5 Flash and
  Gemini 3 Flash are offered on @ai-sdk/google at /api/llm/g/v1, with
  droid 0.241.1's names, total context 1M, output 65536, efforts and
  images. Each effort is a thinkingConfig thinkingLevel, as the zed
  plugin sends Gemini's.
- send() takes the Google package's models/<id>:streamGenerateContent
  to Factory's /api/llm/g/v1/generate, as the built-in does (pathOf
  Gemini, FactoryGemini): the model in the body, no stream field, the
  system instruction without a role and opened with droid's line like
  factoryDroidGoogle. x-api-provider is google; the Google package's
  x-goog-api-key is dropped. A rewritten body no longer keeps the
  caller's content-length.
- Gemini counts in standard's windows, not Droid Core's, as the
  built-in's factoryCore has it.
- Gemini 4 Argon is behind a Factory feature flag (featureFlag
  Gemini4Argon, unreleased) in droid 0.241.1; an account it isn't on for
  may be refused it.

testdata/droid-0.241.1-gemini.txt is droid 0.241.1's picker and Gemini
entries, byte for byte from @factory/cli-darwin-arm64@0.241.1 bin/droid
(each line checked present in the binary). muse-spark-1.2, also new in
that picker, is not added here.

Run: bun test in packages/factory (130 pass), bun scripts/check.mjs.
Broken by hand: without the route rewrite the three gemini.test.mjs
tests fail; without google in CORE's exclusion usage.test.mjs fails.
Not tried: a real Factory account (none signed in here), so neither
Factory's answer to these bodies nor Gemini 4 Argon's flag was seen.
2026-10-14 14:25:43 +08:00
yetone a4f81786a7 workbuddy 0.1.20: tool results followed by the user's message reach WorkBuddy AI's gemini-3.8-flash (#113)
WorkBuddy AI's gemini-3.8-flash answers 400 code 11153 "the conversation
must end with a user message" to a chat whose tool results are followed by
a user message. magpie sends exactly that for Claude Code's tool_result
plus reminder text, a user's words typed mid-task, and a tool's images, so
Claude Code on that model failed on its first tool result (wuasakura).

The loader now sends such a chat again with an empty assistant message
between the results and the user's message, and does so up front for a
model that refused it once in this run. Any other refusal, and a chat
ending with the assistant's message (a prefill), passes on as before.

Verified with the owner's real WorkBuddy AI account (direct to
www.workbuddy.ai through the plugin's loader):
- 17 models with tool results then a user message: only gemini-3.8-flash
  refuses (11153); the rest serve it.
- On gemini-3.8-flash: tool->user, tool->user(parts), two tools->user,
  tool->user->user and tool->user(image) are refused before, served after.
  With the empty assistant message the model follows the user's ask ("Red
  PINEAPPLE"); folded into the tool result instead, it ignored the ask, so
  folding was not used.
- Through magpie's gateway (main eb0d5750f, nogui build, sandbox HOME, the
  local package added): a Claude Code-shaped /v1/messages request
  (tool_result + system-reminder text) gave "WorkBuddy AI: the conversation
  must end with a user message" with 0.1.19's index.mjs, and "3 PINEAPPLE"
  with this one.

Tests: HOME=$(mktemp -d) bun test in packages/workbuddy, 80 pass; bun
scripts/check.mjs workbuddy passes. aftertools.test.mjs: with 0.1.19's
index.mjs the retry and up-front tests fail (Expected 200, Received 400);
with the remembering removed, the up-front test fails.

Not tried: WorkBuddy (China), whose model list has no Gemini.
A prefill to gemini-3.8-flash is still refused with the same 11153.
2026-10-14 13:14:32 +08:00
yetone 386a2ba5ad kiro 0.1.10: the caller's prompt-cache marks reach Kiro as cachePoints (#110)
What: buildKiro dropped every cache_control, so Kiro was never asked to
cache a prompt and its tokenUsage reported no cache reads ("kiro cli
cache 率为 0"). Kiro's generateAssistantResponse takes Bedrock's cachePoint
({"type":"default"}) on a userInputMessage, on an assistantResponseMessage
and as an entry of the tools: the CodeWhisperer streaming model's
UserInputMessage.cachePoint, AssistantResponseMessage.cachePoint and
Tool::CachePoint (aws/amazon-q-developer-cli's generated client), and
Kiro CLI 2.27's model list carries supportsPromptCaching and
maximumCacheCheckpointsPerRequest. A message holding a marked block now
gets a cachePoint on the entry it ends up in (merged turns included; a
marked system prompt marks the first message, where the instructions
go), and a marked tool is followed by a cachePoint entry, as kirocc and
AIClient2API send. Four at most, the last kept, as Anthropic allows.
conversationId is left per request: a cachePoint caches the prompt's
prefix, not a conversation.

Run: TMPDIR=<scratch> HOME=<scratch> bun test (1191 pass, 0 fail) and bun
scripts/check.mjs kiro. cache-points.test.mjs's first fixture places the
marks where a captured Claude Code 2.1.296 request had them (two system
blocks and the trailing system-role hook message; texts cut short); the
second is the shape magpie's buildAnthropic hands a plugin for a
translated request. With the two cachePoint lines taken out, 3 of its 4
tests fail. Not tried against a real Kiro account (none signed in here),
so whether Kiro then reports cacheReadInputTokens is not seen yet.
2026-10-14 12:54:44 +08:00
yetone 643ef5018e zen-free: README says the free tier now works only inside OpenCode itself (#100, #108)
Since 10-13 Zen answers free-tier requests from anything but OpenCode
with 403 FreeTierError. OpenCode limits it on purpose, so the plugin
won't get past it: the README now says so and points to an OpenCode Zen
paid key or OpenCode Go instead.

README only. No version bump, so the publish workflow (which runs on
packages/*/package.json) doesn't run, and 0.1.5 stays unpublished. The
code on main is left as it is.
2026-10-14 07:53:51 +08:00
yetone e4023d9912 factory 0.1.25: Haiku 5.5 and Mistral Large 4, in droid 0.240.0's picker, reach Factory through magpie (JL on Discord)
JL (Windows, droid 0.240.0, Factory desktop 0.197.1, magpie 0.1.1226,
plugin 0.1.24): droid and Factory desktop offer claude-haiku-5-5, droid
through magpie didn't, as the plugin's model table didn't have it.

How droid gets its models: its npm package (@factory/cli 0.240.0, the
platform binary @factory/cli-darwin-arm64) bundles the model registry in
bin/droid; the picker lists that registry (order `y`), gated by
availableInCLI, unreleased, feature flags and legacy grouping. Diffing the
registry of 0.233.0 (the release the plugin's table was last matched to)
against 0.240.0 gives three new models: claude-haiku-5-5, mistral-large-4
and gpt-6-astra-ultrafast.

- Haiku 5.5: Anthropic Messages, x-api-provider anthropic, context
  872000 / output 128000 (contextLimits ce, as Sonnet 5.5 and Opus 5.5),
  efforts low..max (droid's "off" is the request without a level).
- Mistral Large 4: generic chat completions, x-api-provider mistral, Droid
  Core (billingPool core), 524288 / 64000, images, effort high.
- GPT-6 Astra Ultra Fast stays out: droid offers it only once the user has
  accepted Factory's high-cost terms (explicitOptInRequirement high_cost).

models.test.mjs is new; its fixture (testdata/droid-0.240.0-models.txt) is
the registry's own bytes: the picker order, the context helper and the three
entries. It checks the two models as droid has them and that every model in
droid's picker is offered or on a named list left out (router, Gemini,
unreleased, opt-in, the older generations the plugin never offered). With
the Haiku 5.5 line removed both tests fail. usage.test.mjs's Core list
gains Mistral Large 4.

Run: bun test in packages/factory (126 pass), bun scripts/check.mjs factory;
a fake Factory saw /api/llm/a/v1/messages with x-api-provider anthropic for
claude-haiku-5-5 and /api/llm/o/v1/chat/completions with mistral for
mistral-large-4. Not tried against Factory itself (no Factory account here);
droid itself was not run.
2026-10-13 23:29:44 +08:00
yetone 65a76769d6 zcode 0.1.17: ZCode app's sign-in follows a ZCode whose data was moved to another folder
What changed: ZCode 3.14 has a 数据存储路径 (data storage path) setting.
Changing it copies ~/.zcode/v2 to <folder>/.zcode/v2 (all but setting.json,
copyDataDirectory's filter) and from the next start ZCode reads
credentials.json and runtime/provider from there. The choice stays in the
home folder's .zcode/v2/setting.json as dataBaseDir
(readBootstrapDataBaseDirFromDisk), and setting.json itself is always read
from the home folder (getSettingsFile: ZCODE_DESKTOP_HOME_DIR, HOME,
USERPROFILE). The plugin read credentials.json and runtime/provider from
~/.zcode/v2 only, so for such a user "ZCode app's sign-in" read the stale
copy left at home (or nothing). It now reads dataBaseDir as magpie's built-in
does (magpie 41972b25f, internal/appdir ZCodeDataIn: trimmed, ignored when
empty, not a string or not absolute) for credentials.json and the
zcode-builtin.json walk, and keeps reading setting.json (the team plan)
from the home folder. The credential key's seed is unchanged: ZCode builds
it from os.homedir(), not the data folder.

Read from ZCode 3.14.3's app.asar (a copy): out/main/index.js (bootstrap),
out/main/chunk-*.js and out/host/chunk-*.js (getDataBaseDir,
getAppConfigDir, copyDataDirectory, getCredentialsFile, the settings file
under the home folder, defaultCredentialSecret).

What was run:
- moved.test.mjs (new): with dataBaseDir set, ownSignIn takes the moved
  folder's key and session over the stale home copy, and a team plan named
  in the home setting.json; "", blank, relative, number and null keep the
  home folder. With zcodeDir put back on homedir() it fails (old key read).
- HOME=$(mktemp -d) bun test at the repo root: 1185 pass, 0 fail.
- bun scripts/check.mjs zcode.
- Not run: a real ZCode with a moved folder, Windows.
2026-10-13 16:33:29 +08:00
yetone c3bcb5cdf3 trae 0.2.11: what GLM leaves before </tool_call> is dropped, not sent as the answer, and a call whose JSON closed early is read whole or not at all (magpie#1945)
XcodeFish (trae-cn/glm-5.3-flash under Codex) saw eight texts of their own
beside real calls: ]</tool_call>, </tool_call>, }</tool_call>,
]}]}}"}}}}</tool_call>, }}</tool_call>, "></tool_call>. And an
exec_command's heredoc reached Codex cut wrong.

- After a call's JSON, braces, brackets, quotes, a > and blanks up to the
  close are taken with the close (held while only those have come).
- A close with no call open is dropped with that leftover before it: when
  nothing but blanks came since the start or the last call (the tail of a
  call Trae's service read itself), or when the leftover is right before
  it. A close a sentence names in passing, or one in backticks, stays.
- A call's object that ends early, with other text after it before the
  close, is a quote inside a string left unescaped: the block is read up
  to the close (quoteFix reads the heredoc whole), and when it can't be,
  the turn fails as unreadable, so the gateway can try again, instead of
  a cut command plus the rest as text.

Not reproduced: the issue's cmd that swallowed ","yield_time_ms":180000}.
No mutation of quotes and backslashes in a JSON or string-encoded call
(624 tried) gives it through this parser; it may have come from Trae's own
tool_calls. Asked the reporter for the raw stream.

Run: tailjunk.test.mjs (6 tests, the issue's tails at piece sizes 0/1/3/7,
a native call with its tail split across events, the heredoc) fails 5 of
6 on the old index.mjs; HOME=<tmpdir home> bun test for the repo, 1184
pass 0 fail; bun scripts/check.mjs green.
2026-10-13 15:45:53 +08:00
geoqiao 4aae1ce7b9 cursor 0.2.11: a step's usage is its own; what it collected of earlier steps is magpie_deferred (#101)
A tool step whose usage event shows after its wait reports 0, and the
conversation's next step collects it. That step used to add it to its own
prompt_tokens, which clients read as context occupancy: pi saw 366940 tokens
(181270 + 185670) on a 300k window and compacted, though 185670 were in use.

Now a step's standard usage fields are its own Run's only. What it collected
of earlier steps goes in usage.magpie_deferred (prompt_tokens,
completion_tokens, cached_tokens, cache_write_tokens), which magpie bills with
the step (yetone/magpie PR) and clients ignore. ledger() also splits collected
events by timestamp: an event stamped from the Run's start on (less 1 s) is
the Run's own; earlier ones and carried counts are deferred. Before, a late
event of an earlier Run could land in a step's own count through gather().

Verified: bun test on packages/cursor, 88 pass (86 before, plus
deferred-usage.test.mjs); bun scripts/check.mjs. With the old index.mjs the
new test fails with Expected 185670, Received 366940. Against real Cursor
(composer-2.5, STEP_WAIT shortened to force late events, 2 rounds) the
deferred totals matched the dashboard's usage events token for token.
The repo-wide bun test has 2 failures in packages/trae that fail the same on
9074723 without this change.
2026-10-13 14:51:26 +08:00
yetone 9074723932 zen-free 0.1.5: a request carries a session id OpenCode itself could have made, so Zen's free tier serves it again (#100, xqvvu)
Zen's chat endpoints now answer the free tier's requests 403 FreeTierError
("can only be used from within OpenCode") unless x-opencode-session looks
like an id OpenCode made. 0.1.4 sent a sha256 cut to the ses_ shape; Zen
decodes the id as OpenCode's identifier.ts lays it out (12 hex of
~(Date.now()*0x1000 + counter), then 14 base62) and turns away one whose
counter is not small.

Bisected against the real upstream by replaying 0.1.4's captured request:
- 0.1.4's ses_e9283da055b15JwOAra76bwUx4: 403. The same request with the
  session of a real OpenCode 1.19.0 run: 200. The real UA alone, or a real
  msg_ request id alone: still 403.
- Any timestamp passes (epoch 0, a year back, an hour ahead); the low 3 hex
  ffe/ffd/ff0 (counter 1/2/15) pass, f00/c00/800/001 get 403; 25 or 27
  characters after ses_ get 403.

Now:
- sessionID makes a real descending id with the current time and counter,
  kept per conversation (sha256 of the signal, at most 1000 kept) so a
  conversation's turns share one session. An id the caller sent through
  that OpenCode could have made is passed on unchanged.
- x-opencode-request is an ascending msg_ id, x-opencode-session-id is
  sent too, and the User-Agent is OpenCode 1.19.0's
  (opencode/1.19.0 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14), as
  captured from the real client.

Run: bun test in packages/zen-free, 166 pass. With 0.1.4's hash put back,
the new session tests and the streaming header test go red (3 fail).
tools-smoke.mjs against the real opencode.ai: big-pickle,
mimo-v2.6-flash-free and muse-spark-1.3-contributor-free each 200 with a
Bash call, streamed and not; 0.1.4's provider.mjs in the same run: 403
FreeTierError.

Not done here: magpie maps this 403 to permission_error, which reads as a
sign-in problem; that is magpie's gateway, not this package.
2026-10-13 13:10:07 +08:00
yetone 169e4e607c workbuddy 0.1.19: an enterprise account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (magpie #1904, CnsMaple)
An enterprise (team) account's /billing/meter/get-user-resource-summary
answers with an empty Packages list, so the card had no window and no
error ("暂无额度数据"). WorkBuddy's own usage page reads
/billing/meter/get-enterprise-user-usage for such an account, which
answers credit / limitNum and the cycle's start and reset (UTC+8).

auth.usage now asks the enterprise meter when the summary gives no
credits, and shows a Credits window of credit used of limitNum, resetting
at cycleResetTime, with span from cycleStartTime; plan "Enterprise" when
the sign-in has none. A personal account's refusal of that meter (400
10001 "uid or enterpriseID is empty", seen on a real WorkBuddy AI account)
leaves the card as the summary said. An account with packages never asks
it.

Run: HOME=$(mktemp -d) bun test (1172 pass), bun scripts/check.mjs.
The new enterprise test uses the reporter's two answers byte for byte;
with the fallback turned off it fails (no window, plan Free). A real
personal WorkBuddy AI account's usage read through this index.mjs is
unchanged (same window, no enterprise request). Not tried with a real
enterprise account: none here.
2026-10-13 11:39:45 +08:00
yetone 7b09c423c8 trae 0.2.10: the sign-in page offers the enterprise (SaaS) sign-in (@shad70w0 on X)
@shad70w0 on X: "magpie + Trae 插件实测没办法走企业订阅" - a Trae enterprise
subscription couldn't be used through this plugin. The sign-in URL sent
hide_saas_login=true (copied from the relays in 6c048c7), which hides the
enterprise/SSO sign-in on www.trae.cn/authorization and
www.trae.ai/authorization, so an enterprise user could only sign in as a
personal account.

What changed:
- the authorization URL sends hide_saas_login=false.
- traeHost: a host a sign-in names is taken only when it is a well-formed
  https host (no port, credentials, query) on trae.cn, trae.ai or
  mchost.guru; anything else is ignored and the consumer host used, as
  before.
- Trae CN: a sign-in host on mchost.guru / trae-api-*, or another trae.cn
  host than www/api/grow*, is the account's model host. Trae Global: a
  trae.ai host other than www/api-*/grow* is too, after the existing
  US/coresg rules. Personal hosts (api.trae.cn, api-us-east, api-sg-central,
  growsg-normal, coresg-normal) route as before.
- the sign-in's host (host), a token host the callback names (authHost /
  auth_host / userInfo.AuthHost, on the realm's own domain only) and the
  userInfo's tenant/enterprise/login-type fields (account; no field that
  looks like a secret) are kept in the auth record. Renewal (sign-in and
  refresh) goes to authHost when one is kept. Nothing new is sent.
- README: enterprise sign-in is offered, not tried with a real enterprise
  account.

Run: bun test in packages/trae (103 pass, 6 new in enterprise.test.mjs);
the whole repo's bun test with HOME under a scratch TMPDIR (1168 pass, 0
fail); bun scripts/check.mjs. Each change broken by hand turns
enterprise.test.mjs red: hide_saas_login back to true, no enterprise CN
host, no domain check, http allowed, refresh at the consumer host, no
account kept, api.trae.cn taken as a model host, a secret-looking field kept.

Not tried: no real enterprise account. Which host(s) and fields an
enterprise sign-in sends back is unknown; the hosts in the tests are made
up, and whether the callback ever names an auth host is a guess.
2026-10-13 11:13:49 +08:00
yetone f98026557e grok 0.1.14: a window offered without a k (grok-4.7@131072) asks Grok for that model at that window (yetone/magpie#1679)
labelOf writes a window no multiple of 1000 as its digits alone, so
windowsOf offers grok-4.7@131072 beside grok-4.7@500k. modelOf read only
"<n>k", so that id went to Grok as an x-grok-model-override of its own
("grok-4.7@131072", a model Grok doesn't list) with no
x-grok-context-window. It now reads the digits as the window itself, and
a k as thousands, as the built-in's grokWindowed does after
yetone/magpie#1679 (ggbdpq's patch). An id with no model before the @,
or a window of 0, is no window, as the built-in reads it.

Not tried against Grok: today every window xAI lists is a multiple of
1000, so no real model is offered without the k.

Run: TMPDIR and HOME set to an empty scratch dir, bun test
packages/grok: 41 pass, 0 fail. The new test FAILs with modelOf put
back (expected { model: "grok-4.7", window: 131072 }, got the id as a
model with window 0). node --check packages/grok/index.mjs, bun
scripts/check.mjs grok and git diff --check are clean.
2026-10-13 09:53:12 +08:00
86b4760f55 factory 0.1.24: a session continued after Claude Code compaction reaches Factory (#66)
* factory 0.1.23: a resumed turn's restored skills reach Factory wherever they sit

#68 took 0.1.22, so this moves to 0.1.23.

Claude Code 2.1.292 session 1a2063e5 is the turn Factory answered 403.
Its transcript renders the post-compaction attachments, in order, as system
reminders: a token marker, a restored Read and its result, an omitted-file
note, the invoked-skills reminder, the agent-type list, MCP server
instructions, the environment paragraph and the model line. No token marker
follows the skills reminder. The snapshot's contextRendering is "announced",
so the same paragraphs also travel unwrapped in one system turn. The request
bytes were not in the routing log; the fixture is those rendered paragraphs,
unwrapped, in that order.

announcedContext used to reassemble the reminder only when a token marker
came right after it, and then treated everything up to that marker as skill
text. A reminder at the end of the turn, or followed by a Read, the
environment or a hook, kept the refused opening. A reminder with other
attachments and a later token swallowed those attachments into the skill
encoding.

The refused part is the fixed opening plus the complete IMPORTANT paragraph.
That complete reminder is rephrased wherever it sits. Skill text now ends at
the next paragraph the adapter already knows (token marker, hook, restored
Read, omitted-file note, Read result, environment, model line, skill-list
header, changed-file note, agent-type list, MCP instructions) or at the end
of the turn. Those following paragraphs stay themselves and are adapted on
their own. A second pass is byte-for-byte. Quoted fragments, an incomplete
IMPORTANT paragraph, a hook that owns the reminder and assistant content stay
untouched.

0.1.22 was not tried against Factory: the installed copy stayed 0.1.21, and
this change was not sent to Factory either.

Run: HOME set to an empty temp dir, bun test packages/factory: 120 pass,
0 fail. node --check packages/factory/index.mjs, bun scripts/check.mjs
factory, and git diff --check are clean. The new test covers the captured
order plus a reminder at the end of the turn, a reminder followed by Read,
environment and a hook, and a quoted skill body. Fetch is stubbed.

* factory 0.1.23: restored skills open a resumed turn without token metadata

A resumed turn can start with the complete invoked-skills reminder when no
files were restored and totalTokensReminder is off. restoredContext now
recognizes its exact opening and IMPORTANT paragraph through the existing
invokedSkillsMatch and attachment boundaries. A restored-file opening can
also use the complete skills reminder as evidence when it ends the turn.
Adapted openings, incomplete reminders, quotations and hook-owned output
retain their existing behavior.

Cover no-token system turns and folded user text on inference and token
counting, including standalone reminders, trailing tokens, omitted-file and
Read prefixes, exact skill decoding, cache metadata and byte-for-byte second
passes. Each of the six boundaries missing independent regression coverage
now follows a quoted skill directly. README documents the no-token forms.

Run with HOME set to an empty temporary directory: bun test packages/factory,
121 pass, 0 fail. node --check packages/factory/index.mjs,
bun scripts/check.mjs factory and git diff --check pass.
Removing each of the omitted-note, Read-result, model, skill-list, MCP and
changed-file boundaries makes the new independent regression test fail.
The whole-project test suite is left to CI. Fetch is stubbed; no request was
sent to a real Factory account.

* factory 0.1.24: main already published 0.1.23 (#71), so this change takes the next version

#71 shipped factory 0.1.23 while this PR waited, so npm has 0.1.23. This
only moves the version, so the squash publishes as 0.1.24.

Run: merged onto main a885a16, HOME=<scratch> bun test packages/factory:
124 pass, 0 fail; bun scripts/check.mjs: all pass.

---------

Co-authored-by: chenguoqing <chenguoqing@kemai.cn>
Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-13 09:05:49 +08:00
yetone a885a16190 cursor 0.2.10: a Team member with no limit of their own spends the team's on-demand pool, which is shown and counted as the limit, not as unlimited (yetone/magpie#1868)
PaSSw0rds' Team account has on-demand turned on for the whole
organization: spendLimitUsage has no individualLimit, pooledLimit
"45120000" and pooledRemaining "38785730" are int64 strings, pooledUsed
6334270 a number, and GetHardLimit answers {"hardLimit": 451200} with or
without a team id. onDemandOf read that as "unlimited", as cursor-agent's
own usage view does, so the On-demand row showed only the member's own
$198.55 at 0%, and a spent team pool never counted the account used up.

Now a team member with no individualLimit and a pooledLimit > 0 gets a
fixed On-demand window on the pool: used = pooledUsed / pooledLimit,
display "$63,342.70 / $451,200.00 (you: $198.55)", not aside, so magpie
stops routing to it when the pool is spent. A hard limit that forbids
on-demand still reads as disabled; a team with no pool and a hard limit
still reads as unlimited. Dollar figures group thousands.

Run: bun test in packages/cursor (86 pass), bun scripts/check.mjs (exit 0).
The new test, built from the payloads quoted in yetone/magpie#1476, fails
on the old index.mjs (On-demand "$198.55", used 0, aside) and on a fix
that shows the member's spend against the pool instead of the pool's own.
Not tried against a real Team account.
2026-10-13 06:00:37 +08:00
yetone 9814cca34d workbuddy 0.1.18: a desktop sign-in WorkBuddy 5.6+ keeps encrypted says so and points to the browser sign-in, not "isn't signed in" (#18)
seavenlin on #18: on WorkBuddy desktop 5.8.1 the tokens in
workbuddy-desktop[-ai].info are sealed ({$wbEncrypted: 1, envelope}), so
the desktop sign-in failed as "isn't signed in" while the app was signed
in, and one made before the app sealed it fell back to the built-in list
and its chats failed.

The sealed tokens are not opened (only the app opens them; #18's way of
running the app's binary to take its key is declined). Sign-in, usage and
chats now say the app keeps its sign-in encrypted and to use the browser
sign-in. The app's file is still only read.

Run: the new test fails on the old index.mjs and passes here; HOME=$(mktemp
-d) bun test for the repo, 1155 pass 0 fail; bun scripts/check.mjs green.
Not tried with a real WorkBuddy 5.8.1 install; the file shape is the one
in #18 and seavenlin's comment.
2026-10-13 04:46:47 +08:00
yetone 6579c01711 cursor 0.2.9: when the default's own branch stops short, an id of it asked past that goes as its nearest, not the default's id at the effort asked (#55)
With the default on the branch without thinking (thinking=false, low to
high) and xhigh only with thinking, claude-opus-5-low asked at xhigh went
as the default's slug with effort=xhigh: an id and parameters at odds.
branch() returned early whenever what was asked differed from the default
in the effort alone.

Decided: that early return now holds only when no variant at all is named
for the effort asked, so claude-opus-5-5-xhigh (no xhigh variant
anywhere) still goes at xhigh as a listed model does, and an effort
another branch has makes the default's branch go to its nearest.

Run: the new test (the issue's picker, plus every id x effort x fast
agreeing with its parameters) fails on the old index.mjs and passes here;
HOME=$(mktemp -d) bun test for the repo, 1154 pass 0 fail; bun
scripts/check.mjs green. Not seen on a real account (as the issue says).
2026-10-13 04:45:03 +08:00
yetone 0e2a52efdc trae 0.2.9: <toolcall> without the underscore is read as <tool_call>, and a reply that ends inside an opener is cut short, not the answer (#38)
XcodeFish's two leaks on 0.2.6, still on 0.2.8: glm-5.3-flash wrote
<toolcall></toolcall>, and a reply ended at "<tool_call name". Both went
out as the answer with a 200.

- The opener, close, leftovers and held marks take <toolcall> and
  </toolcall> too; an empty block is dropped as <tool_call></tool_call>
  is, one with JSON or parameters is a call, one that can't be read is
  the error it is for <tool_call>.
- At the end of a reply, an opener still open (<tool_call, <tool_call
  name) outside backticks or a fence ends the turn with the cut-short
  error.

Run: the issue's repro (A-G) on main and on this; the new test fails on
the old index.mjs (1 fail) and passes here; HOME=$(mktemp -d) bun test
for the repo, 1153 pass 0 fail; bun scripts/check.mjs green.
2026-10-13 04:40:26 +08:00
yetone 66facacf14 kiro 0.1.9: a tool's images reach the model, as the built-in sends them (yetone/magpie#1861)
What: buildKiro read a tool_result's content for its text alone, so an
image a tool returned (Codex's view_image, a computer-use screenshot,
Claude Code's Read of a PNG) never reached Kiro: the model got
"(no output)" and said it saw nothing. Its image blocks (base64) now go
with the message that answers the call, beside any image the user sent,
as magpie's built-in has sent them since yetone/magpie#369. Kiro's tool
results hold text alone. The "only the latest images" rule is unchanged;
an image named only by a URL still has no bytes to send and is left out.

Why: simonsmh reported Codex's view_image unreadable through Kiro on
magpie v0.1.1215 (#1861). A moved Kiro is served by this plugin, which
never got #369's fix.

Run: HOME=<scratch> TMPDIR=<scratch> bun test (1152 pass, 0 fail) and
bun scripts/check.mjs. tool-images.test.mjs's fixture is the Anthropic body
magpie's gateway hands the plugin for Codex 0.162's view_image output
([{"type":"input_image","image_url":"data:...","detail":"high"}]), dumped
from magpie's buildAnthropic; 3 of its 4 tests fail on 0.1.8. Not tried
against a real Kiro account (none signed in here); #369 checked the same
body shape on the built-in against a real account.
2026-10-13 03:40:07 +08:00
yetone caf3908eff workbuddy 0.1.17: a restricted account's 403 11140 says it is restricted, so magpie rests it for hours (magpie #1849)
WorkBuddy answers an account it restricted for "unusual activity" with
403 {"code":11140,"msg":"request illegal","displayMsg":{...}}. explained()
let it through as it came, so magpie saw "request illegal" and retried
the account every few minutes.

explained() now knows the restriction by its code 11140 (top level, under
data or error, number or string, matched whole so 111400 isn't it) or by
its displayMsg words, and ends the message with RESTRICTED_HINT, word for
word magpie's provider.WBRestrictedHint. magpie's routing rests an account
whose error carries that hint for 2h and tells it as restricted, with the
appeal as the way back. type permission_error, code 11140; the sign-in is
kept.

Run: HOME=$(mktemp -d) bun test (1148 pass, 0 fail), bun scripts/check.mjs.
refused.test.mjs uses the reporter's literal body. With detection removed
by hand, 2 of the new tests went red. Not tried against a real restricted
account.
2026-10-13 02:32:10 +08:00
yetone cb9093181d workbuddy 0.1.16: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord)
What: for the workbuddy-ai provider only, a model whose id starts with
glm- is listed without image input (capabilities.input.image and
attachment false), whatever /v3/config's supportsImages says.

Why: checked on 2026-10-13 with a real WorkBuddy AI account. Its
www.workbuddy.ai/v3/config marks every model supportsImages: true, but
an image sent to glm-5.3-flash, glm-5.3 or glm-5.2 is taken out by the
server and replaced with "[System reminder: the current model does not
support images. Content filtered. ...]". Its other models
(deepseek-v4.1-flash, kimi, gemini, grok, gpt) read images, and WorkBuddy
(China, copilot.tencent.com)'s glm-5.3-flash does too. Listed as taking
images, magpie sent them straight through and the model never saw them;
listed text-only, magpie's image-describing model reads them first. A
user who set the model's image support by hand in magpie keeps it
(magpie's ModelImages setting is applied over the provider's list).

Scoped by site (SITES["workbuddy-ai"].noImages = /^glm-/) and family,
not a list of three ids, so a later GLM on WorkBuddy AI is covered.

Run: TMPDIR=<scratch> HOME=<scratch>/home bun test in packages/workbuddy:
68 pass. The new test fails on the old index.mjs (glm-5.3-flash listed
with images). bun scripts/check.mjs green. Not run: a live chat through
the plugin with an image (the account check above was done before this
change).
2026-10-13 01:48:32 +08:00
yetone 49e9d89d59 commandcode 0.1.12: each plan lists only the models it may use; a Go account no longer lists GOAT's (01huadalang on Discord)
01huadalang, signed in on the Go plan, was shown models only GOAT and above
may use. Command Code's /provider/v1/models is the same 87 models for every
plan (read with a GOAT key and without one on 2026-10-13: the same but for
"created"); which of them a plan may use is the CLI's own table (command-code
1.79.2, evaluateModelAccess: each model's category, premium or open, and
each plan's allowedCategories and blockedModels), and the Provider API turns
the rest away only when asked (403 "MODEL_NOT_IN_PLAN: Claude Opus 5.5
available in Provider and above plans or extra on demand usage").

Cause: the plugin filtered Go's list by a copy of CLI 1.73.0's table, which
didn't have Claude Haiku 5.5 (1.79.2: "haiku 5.5 in goat plan", blocked for
Go), and didn't filter any other plan at all, so GOAT, Pro and Provider were
shown models their plan refuses (a real GOAT account listed all 87, Claude
Opus 5.5 and GPT-6 Sol among them).

Now:
- PLAN_MODELS is CLI 1.79.2's table by plan name: Go and GOAT the open
  models only, Go also blocked from GOAT's (Sonnet 5.5, Haiku 5.5, GPT-5.6
  Sol, Grok 4.6/4.7, Muse Spark 1.2/1.3, Gemini 3.7/3.8 Flash, MiMo V2.6 Pro
  UltraSpeed), Pro blocked from Opus, Fable, GPT-6 Astra, GPT-6.1 Sol and
  Fugu Ultra, Provider from GPT-6.1 Sol, Max/Ultra/Teams Pro everything.
  GO_REFUSED is derived from it. Blocks are by id: the CLI's own block of
  "vercel-ai-gateway:xiaomi/mimo-v2.6-pro-ultraspeed" misses its "cai"
  model, and Go stays kept off it as before.
- provider.models filters every plan's list (and the default list standing
  in when the list can't be read) by it.
- A plan not read (billing/subscriptions failing, nothing saved), "No plan",
  or a plan name the table doesn't know keeps the whole list.
- Bought or free credits (billing/credits) let every model, as the CLI does;
  credits not read are taken as last read, else none, so the plan's list
  stands and a model it leaves out is still refused by Command Code.
- The refusal itself is unchanged: the Provider API's 403 reaches the agent
  as it came, and on Go's endpoint failure() says "Model not in plan: …".

Tests: plan-models.test.mjs is new, built from real bytes in testdata
(models-2026-10-13.json, a GOAT account's subscriptions and credits replies
with its ids zeroed, the two MODEL_NOT_IN_PLAN refusals). The Go case uses
the GOAT reply with Go's planId: there is no Go account here. All 7 fail on
0.1.11. Broken by hand, each goes red: Haiku 5.5 unblocked for Go (Go test),
no plan filter (5 tests), credits ignored, an unread plan refusing premium,
the stand-in list unfiltered, credits unread taken as extra.
models.test.mjs's pictures test moves from Pro to Max, since Pro's list no
longer has Claude Opus 5.5.

Ran: TMPDIR=<scratch> HOME=<scratch>/home bun test (all packages, 1144 pass,
0 fail) and bun scripts/check.mjs commandcode. The new provider.models hook
against the owner's real GOAT account (saved plan and none) lists 66 models:
Sonnet 5.5, Haiku 5.5 and GPT-5.6 Sol in, Opus 5.5, Sonnet 5 and GPT-6 Sol
out; a 1-token request confirmed GOAT gets Haiku 5.5 (200) and is refused
Sonnet 5 (403 MODEL_NOT_IN_PLAN).
Not tried: a real Go account (none here), an account with bought credits,
and the new version inside a running OpenCode/magpie; magpie needs the
mover's min raised to 0.1.12 for moved users to get it.
2026-10-13 00:44:50 +08:00
yetone f573cfdcba qoder: Qoder's queue (code 10605) is a 503 to retry after its wait, not a lapsed sign-in (#98); 0.2.14
failure() turned every 401/403 into "the sign-in lapsed — sign in again".
Qoder answered every chat on a real trial account (2026-10-12) with
403 {"code":"10605","message":"{...\"retryAfterSeconds\":30,
\"serviceAvailable\":false...}"}: its queue for the model, while the same
token read the models and usage.

Codes are now read as Qoder's own client reads them (the QoderErrorCode
table in Qoder.app's qoder-agent-sdk worker), whatever the HTTP status:
- 10605, or a queue state with isQueued or serviceAvailable false: 503
  with Retry-After from retryAfterSeconds (30 when absent), no
  X-Magpie-Sign-In. magpie's gateway counts a 503 as busy and asks again
  after Retry-After (patience.go busy/noteBusy).
- 110, 112-119, 122 (usage/credits used up): 429.
- 406, 416, 430, 80411, 80412, 100400-100403 (refusals of the request): 400.
- 105 (loginExpired) or no code: the 401 as before.
Both the HTTP status path and the in-stream statusCodeValue path go
through failure(); errorResponse sends Retry-After.

Run: bun test (sandbox HOME) 1137 pass 0 fail; bun scripts/check.mjs ok.
busy.test.mjs uses the literal body as testdata; its 4 tests all fail
against the previous index.mjs and pass with this one. Not tried: a real
10605 after the change (the account's queue was open again by then: a
real chat on fast answered "ok"); the quota and request codes' HTTP
status from Qoder is not seen, only their meaning from Qoder's client.
2026-10-12 21:22:50 +08:00
yetone 04e188aaec qoder 0.2.13: an account lists the models Qoder's app shows, Fast (0.8×) among them, and keeps Performance (#97)
Qoder's model listing (/algo/api/v2/model/list) has a list per scene. The
plugin read only "chat", while its requests are sent as Qoder's app
(product and session_type "app"). On 2026-10-12 the app scene lists Fast
(key fast, 0.8×) where chat still lists Performance (1.1×), so magpie
showed Performance and never Fast, which Qoder's app shows (yygutn, #97).

The models hook now lists the app scene in its order and adds each model
only chat still lists after the model it follows there, so a pick of
Performance stays served. Each key once; the app's entry wins. A listing
with one scene gives that one. New app models show from the account's
own listing without a plugin release. The fallback list gains Fast.

Verified:
- The real listing read through the plugin on the owner's Qoder account
  (sandbox HOME, credential copied in memory, nothing written, no token
  renewed): fast "Fast" rate 0.8 and performance rate 1.1 both listed.
- models.test.mjs runs on that real listing (testdata/listing.json, the
  chat and app scenes); all 4 tests fail with modelInfos put back to
  listing.chat, and pass with the change.
- bun test (sandbox HOME/TMPDIR): 1133 pass, 0 fail. bun scripts/check.mjs ok.

Not verified: a real chat on fast. Every model on that account (fast,
performance, efficient, qfmodel) was refused with 403 code 10605
(serviceAvailable false, queueType p3, retryAfterSeconds 30) though the
trial has 143/300 credits; the plugin reports that as a lapsed sign-in,
filed separately. Qoder CN's listing wasn't read (no CN account).
2026-10-12 21:04:10 +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 ff2d815249 commandcode 0.1.11: a streamed Go reply Command Code stops before its finish line ends cut short, with a note, instead of failing the turn (#91)
This is the sibling of zen-free 0.1.4 (6a5dd01). /alpha/generate's reply
is turned into a Chat Completions stream, which magpie's gateway can't go
on with, so the error frame threw away what the client was already shown.

Now a streamed reply that said something (text, reasoning or a tool call)
and then lost its finish line ends with the note, a finish (`stop`, or
`tool_calls` after a call) and [DONE]. Tool calls arrive whole here, so
none can be half written. A reply that said nothing, or one that wasn't
streamed, is still a 502, so magpie retries it.

Run: HOME=$(mktemp -d) bun test packages/commandcode gave 37 pass. The
whole repo's bun test gave 1129 pass, 0 fail. bun scripts/check.mjs passed.
On the old index.mjs, 3 of the 4 new tests fail. With the cut branch
disabled by hand they fail again.

Not tried: a real Go account. The owner's two Command Code accounts aren't
on Go, and the real upstream can't be made to cut a stream. A streamed
request through the patched loader on those accounts still takes the
Provider API path, which this commit doesn't touch.
2026-10-12 20:31:33 +08:00
YuCreate 80bd2d9241 workbuddy 0.1.15: normalize chat request fields (#96) 2026-10-12 20:26:02 +08:00
yetone 6f1605f01d grok: the login and refresh tests' fake CLI is /bin/sh, not a script just written, so a busy Mac doesn't time them out (#65)
What waited was not a timer in the tests. On macOS the first run of an
executable just written waits for the system's scan of it: 4-15s each
here on a busy machine (a fresh `#!/bin/sh` file timed at 3.8-15.4s on
its first run, 0.00s after; a hard link or symlink to a scanned file, or
the same file read by sh, 0.00s). login.test.mjs wrote a new fake per
test, refresh.test.mjs one per file, so each paid it inside a test.

The fake grok is now a symlink to /bin/sh, and the plugin's own
`grok models` / `grok login --device-auth` become `sh models` /
`sh login …`, which read a plain script in the folder the plugin runs
the CLI in (root above the account's home; the home folder for login,
which login.test.mjs now only uses when HOME is a temp home). No
timeout was raised; refresh's `sleep 0.2` (for the joined-run test)
stays.

Run:
- With 14 `yes` burners of mine (load ~45): origin/main's two files
  5 and 6 fail (bun's 5s), this commit 0 fail in 1.5-1.9s, 3 runs.
- Idle: 10 pass, ~1.2s, 3 runs. Linux (oven/bun:1.4.2, /bin/sh = dash):
  10 pass.
- Broken by hand: links not taken (1 red), the CLI's last line not the
  reason (2 red), renewals not joined (1 red).
2026-10-12 18:22:47 +08:00
yetone b033987516 zen-free: a declared name of separators only matches only itself, and the unused injected set is gone (#76 follow-up, tkhs101)
foldsTo kept a declared name whose fold is "" (an agent declaring "_"),
so any call of separators only ("--", "-", "__") was handed that tool:
an empty fold matching an empty fold, not a name matching a name. Such a
name is now skipped in the fold maps, so it matches only itself and the
other calls are left out with the note like any unknown name.

normalizeTools still built and returned `injected`, which nothing has
read since the guard folds over `declared` alone; it is gone. The "Never
call this tool" stubs are sent as before.

Run: packages/zen-free `bun test` 162 pass; the new test goes red with
the foldsTo change taken out. Whole repo `bun test` (temp HOME and
TMPDIR) and `node --test packages/zen-free` pass; `bun scripts/check.mjs
zen-free` ✓. Rides in 0.1.4 with the #91 change.
2026-10-12 18:18:36 +08:00
yetone 6a5dd01d5d zen-free 0.1.4: a streamed Chat reply Zen closes before its [DONE] ends cut short, with a note, instead of failing the turn (#91, tkhs101)
Zen now and then closes a space-bunny-free Chat Completions stream after
some frames, with no finish_reason, usage or [DONE] (~0.1% of turns in
the reporter's logs). The tool guard turned that into an error frame at
the end of the 200 stream, so the agent threw away the reasoning and text
it already had, and magpie can't ask a Zen Chat reply to go on.

Now, for a client that streams, a Chat reply cut short that has said
something (text or reasoning) and has no tool call pending ends as an
ordinary answer: each open choice gets the note "(The reply was cut
short: Zen closed the stream before it finished. Ask again to go on.)"
and finish_reason "stop", then [DONE]. A reply whose every choice had
finished only gets its [DONE]. It still fails when a tool call is
pending (its arguments may be half written), when nothing was said
(an empty reply), and when the reply is collapsed for a client that
doesn't stream (nothing reached the client yet, so magpie can ask
again). Anthropic Messages and Responses streams cut short still fail:
magpie's gateway tells such a reply from a whole one itself (#370) and,
for an Anthropic upstream reached through translation, goes on with it
(continuation.go); a made-up message_stop or response.completed here
would stop that. The error that remains names the reply's id, the
events and bytes received, and an unfinished tool call, as the reporter
asked. The README also says the free tier needs tools, which is why the
five core tools are sent.

Run: packages/zen-free `bun test` and `node --test` (161 pass). The new
tests use the reporter's three frames byte for byte, at chunk sizes 7, 31
and 4096; all 6 go red on the old tool-response.mjs/provider.mjs.
Broken by hand: dropping the pending-call check turns the "still fails"
test red; ending cut short for non-streaming clients too turns the loader
test and the "still fails" test red. Whole repo `bun test` with a temp
HOME and TMPDIR: 1109 pass. `bun scripts/check.mjs`: all ✓. Through the
plugin's loader against a node fake upstream on 127.0.0.1:3720 that sends
role, reasoning and two text frames 50 ms apart and FINs: streamed → 200
with the text, the note, stop and [DONE]; not streamed → 502 "Upstream SSE
ended without a completion marker (reply x2, 4 events, 659 bytes
received)". Not run: real Zen (the cut can't be provoked) or magpie's
plugin host.
2026-10-12 18:18:35 +08:00
moxuunandyetone 01fdc091c0 grok 0.1.13: import a CLIProxyAPI (CPA) xAI account from its file (#92)
* grok 0.1.13: import a CLIProxyAPI (CPA) xAI account from its file

CPA (CLIProxyAPI) keeps each of its accounts in ~/.cli-proxy-api as a flat
JSON file: {type: "xai", auth_kind: "oauth", access_token, refresh_token,
expired, last_refresh, sub, email, disabled, …}. Its xAI accounts sign in
with the same OAuth client Grok Build does, so such an account is a sign-in
Grok Build can hold — but the plugin could only take the CLI's own sign-in
or make a new one, so an account that lives in CPA could not be used here.

The third sign-in method takes the path to one of those files, reads it and
writes Grok Build's own shape (key, auth_mode: "oidc", create_time,
user_id, email, refresh_token, expires_at, oidc_issuer, oidc_client_id)
into a home of the plugin's own, as a device-code sign-in does. The
imported file is only read, and only the fields above are carried over:
base_url is not honored and expires_in is not turned into a lifetime
measured from the import.

A file is refused, before any home is made, when it is not an enabled
(type xai, auth_kind oauth, not disabled) xAI account with tokens, identity
and timestamps, or when the token's own iss/aud are not the Grok Build
xAI ones. The refresh token rotates and both clients would spend it, so the
prompt and the README say to stop using the account in CPA first. Nothing
here refreshes a live token or touches CPA.

bun test: 39 pass on the grok package (4 new in import.test.mjs: the
translated home, the refusals, no Grok Build, and a home that can't be
made). bun scripts/check.mjs grok and node --check pass.

* grok: string timestamps, and import.test.mjs off POSIX

`Date.parse` coerces, so a `last_refresh` or `expired` that was a list or an
object read as a date: the file must say a string before it is parsed.

The test's fake CLI is named for the platform (`grok.exe` on Windows), PATH
joins with the platform delimiter, and the 0600 file is only checked where
POSIX gives it. The mkdir that fails is what the last test covers, not the
cleanup after a write that fails, and it now says so.

* grok: the import's placeholder names the file CPA writes, xai-<email>.json (review of #92)

CLIProxyAPI's xAI sign-in saves each account as xai-<email>.json
(internal/auth/xai/token.go CredentialFileName), not cpa_*.json.
Text only; import.test.mjs still 5 pass.

---------

Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-12 18:16:23 +08:00
yetone 08614da5c5 cursor 0.2.8: an empty reply says what the Run sent before it (#60, congee949)
An "an empty reply" (502) said nothing of why, so #60's 14 empty replies
on grok-4.7-fast over seven days can't be told apart: a turn of thinking
only, a turn spent asking for Cursor's own tools (which the plugin
refuses), something Cursor now sends that decode doesn't read, or an end
frame that carried words without a Connect code (which failure() treated
as a clean end and dropped). Its message now names them, e.g.

  an empty reply (Cursor ended the turn; after 31 chars of thinking, no
  text and no tool call; Cursor counted 41 output tokens; Cursor's own
  tools asked for and refused: #14; try again)

and, when the stream itself ended, the end frame's JSON (cut at 300
chars). Field numbers are agent.v1's. Status, retry and behaviour are
unchanged: magpie's gateway retries on the 502, not on the words.

Run: HOME=<tmp> bun test, 1103 pass, 0 fail (a first run under load
average 16 had 7 bun 5s timeouts in other packages' CLI/login tests,
#65's class; the rerun was green); bun scripts/check.mjs cursor passes.
The two decode tests go red with the old index.mjs. Through the plugin's
loader against a local HTTP/2 fake Run (thinking, an own-tool exec,
TurnEnded, no text): the unstreamed 502 and the streamed error frame
both carry the message above. Not tried against real Cursor: no cause is
proved; this is to name it on the next occurrence.
2026-10-12 18:14:57 +08:00
yetone d2be892d70 zcode 0.1.16: the ZCode app's sign-in follows ZCode only while it is signed in to the same account (LingYi_Stu on X)
The app's sign-in stores the account ZCode is signed in to, and stateOf
read ~/.zcode/v2 again for every request. After ZCode switched to account
B and the app's sign-in was added again, both entries read B's
credentials: A's sent B's requests and its usage card showed B.

stateOf now follows ZCode's own credentials only when ZCode's user is the
entry's accountId. Otherwise (ZCode signed out, or on another account) it
uses the snapshot saved at sign-in, which holds the coding plan key, the
Start Plan JWT, the team project and the device. A snapshot whose JWT has
run out says EXPIRED (sign in again), as a lapsed sign-in already did,
instead of borrowing B's session.

own.test.mjs: two app sign-ins (A, then B) with ZCode on B; A's request
carries A's key and no request (messages, plan, usage) carries B's key or
JWT; and A with only an expired JWT says sign in again without sending
B's. Both fail on 0.1.15 (A sent idB.secretB; the expired case was served
with B's JWT). The first test now keeps the account's user_info as ZCode
signs in again. HOME=$(mktemp -d) bun test packages/zcode: 79 pass.
bun scripts/check.mjs zcode passes.
2026-10-12 14:41:07 +08:00
yetone 7e67b980aa commandcode 0.1.10: a Go request says the agent's folder and git repository, not the home's (#86)
Found beside #86. A Go key's chat completion goes to /alpha/generate with
the CLI's config, which said workingDir: homedir() and isGitRepo: false
whatever folder the agent worked in. It now takes the folder and the git
state magpie tells the plugin's fetch (x-magpie-work-dir,
x-magpie-work-git). Untold, it is the CLI's config outside a project in
the home, as before (a git word without a folder means nothing). The
headers are taken off every request, the Provider API's too.

Run: bun test in packages/commandcode (33 pass, new workplace.test.mjs),
bun scripts/check.mjs commandcode. With the old index.mjs both new tests
fail. Not tried with a real Go account.
2026-10-11 21:36:02 +08:00
yetone baa788b1e4 zcode 0.1.15: a Start Plan request says the agent's folder, not magpie's, and leaves out what it doesn't know (#86, Hipple)
The plugin runs in magpie's plugin host, so process.cwd() is magpie's own
folder (C:\Users\<user>\.config\magpie on Windows). The Start Plan's
"# Environment" section said it as "Primary working directory", with a
constant "Is a git repository: no" and magpie's shell, and the model went
looking in magpie's folder.

Now the folder and the git state are the agent's, as magpie tells the
plugin's fetch in x-magpie-work-dir (percent-encoded) and
x-magpie-work-git (yes/no) (yetone/magpie, provider.WorkDirHeader). Each
line is left out when magpie doesn't tell it (an older magpie, an agent
that names no folder, a folder not on this computer). The Shell line is
gone: the agent's shell isn't known here. Platform and OS Version stay;
they are this computer's, as the X-Os-* headers already say. The headers
are taken off before anything is sent, on the coding plan too.

Run: bun test in packages/zcode (77 pass), bun scripts/check.mjs zcode.
With the old index.mjs the new tests fail (6 fail). One real request
through the plugin with the owner's z.ai account (coding plan; its Start
Plan balance is empty, so the dressed Start Plan path was not tried
against the real service): 200.
2026-10-11 21:36:02 +08:00
yetone f0274d69f7 workbuddy 0.1.14: the Credits window says when the soonest credits left run out (runsOutAt, runsOut), for magpie's smart routing to spend those first (cdredfox on X)
cdredfox: with several WorkBuddy accounts in one smart routing group, the
account whose credits expire soonest should be used first. WorkBuddy's own
client lists each package with its end (the billing page's paid and free
package lists); the plugin now reads them too.

- /billing/meter/get-user-resource-paid-packages and -free-packages, asked
  as the client asks: PageSize 200 up to 10 pages, Status [0,3], its
  COMMODITY_CODES (without them the API answers 10001 "PackageCodes
  required"), NeedRenewInfo / today's SlicePeriod (UTC+8).
- A package's end is DeductionEndTime, else ExpiredTime, else CycleEndTime
  read as UTC+8 (the API's own DeductionEndTime for the same package says
  so). Only packages the summary counts, with credits left; the daily Free
  Plan slice (CapacityType 4, code 001) is left out, since it ends at the
  same midnight on every account.
- The soonest end goes on the Credits window as runsOutAt (RFC 3339) and
  the credits lost then as runsOut. A list that can't be read leaves both
  out; the card stands as before.

Run: HOME=<tmp> bun test in packages/workbuddy, 63 pass (3 new); with
index.mjs back at 0.1.13, 2 of the 3 new go red. Tried live on a real
WorkBuddy AI account: packagesOf + runsOutOf gave the Bonus Pack's 232.4
credits ending 2026-10-12T16:39:27Z, before Pro's 10-28T16:40:52Z, with
the Free Plan slice left out. Not tried on a CN workbuddy account (its
stored token here is stale); the paths and body are the same on both.
2026-10-11 19:39:13 +08:00
8260d97941 grok 0.1.12: a model Grok lists at two windows is offered at each (#83, guoqchen1001)
* grok 0.1.12: a model Grok lists at two windows is offered at each

context_window stays the plain id, so a saved grok-4.7 keeps the default
256k window. Each other size in context_windows is listed beside it
(grok-4.7@500k) with that window. A request for it sends the plain model
and x-grok-context-window: 500000, which is the window a client such as
Claude Code compacts against. The proxy serves up to its largest window
either way and refuses past it.

* grok: a window model's api.id keeps its @size, so x-grok-context-window is sent

The models hook gave grok-4.7@500k the api.id grok-4.7. magpie
(internal/provider/plugins.go, modelAPIID + withModel) and OpenCode's AI
SDK both put api.id in the request body, so the plugin's fetch only ever
saw grok-4.7 and never sent x-grok-context-window. api.id is now the
offered id; fetch strips the window (modelOf) before Grok sees the body.

Run: HOME=$(mktemp -d) bun test packages/grok (35 pass);
bun scripts/check.mjs grok. The new round-trip test (models hook ->
api.id -> fetch) is red on f4872fb and red again with the body rewrite
removed by hand. Real use against the owner's Grok account (copied
home): /v1/models lists 4 models at 256k and 500k; grok-4.7 and
grok-4.7@500k each answered 200, the latter with x-grok-context-window:
500000 and model grok-4.7 in the body.

---------

Co-authored-by: chenguoqing <chenguoqing@kemai.cn>
Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-11 19:37:48 +08:00