16 Commits
Author SHA1 Message Date
yetone 1c9ade6c81 loomy 0.1.12: a 401/403 from a proxy no longer signs an account out
jenxingyoung on X: four Loomy accounts behind a proxy, a different one
signed out each day, none used anywhere else.

Loomy's gateway never answers a dead session with a 401 or 403. A made-up,
dropped or missing token gets HTTP 200 with code 100002 on every path
(chat, draw, models, points records, first-login; probed 2026-11-16 and
2026-11-17). The plugin still read any 401/403 as "signed out": chat and
draw returned a bare 401 (magpie's host marks the account lapsed on that),
and usage and check-in threw an expired error. So a proxy or firewall
turning one request away marked a good account for sign-in again, a
different account each time.

- 401/403 is a sign-in verdict only when its body carries 020002/100002.
  Otherwise chat and draw answer 502 with x-magpie-sign-in: kept (magpie
  tries the next account and leaves this one signed in), usage reports
  the error with signIn "kept", check-in reports "failed". The message
  names the status, says it isn't a sign-out, and quotes the body.
- A lapsed account's message gives the day it was signed in (signedInAt,
  kept at SMS sign-in; older accounts from expires - 14 days). No
  lifetime is claimed: the client asks for 14 days, but agent2api found
  sessions served past that.
- SMS sign-in returns uid (the vendor's userid) beside the masked phone.
- A pasted session is named by its last six characters instead of the
  one name "手动粘贴" every paste shared, which made a second pasted
  account replace the first in magpie's account list.

No renewal exists to add: Loomy's client 0.9.39, its web app,
magpie-providers-hub and agent2api only sign in again. A truly lapsed
account still needs an SMS code; magpie's "Sign in again" on the row is
one click.

Run (mote, HEAD afe4c086 + this change):
- HOME=<temp> bun test packages/loomy: 46 pass, 0 fail.
- HOME=$(mktemp -d) bun test (root): packages/loomy 46 pass, 0 fail.
  Other packages red on mote only (7910 pass, 563 fail: kimi-desktop,
  zen-free, inkstone, zcode, qoder ...), none touched here; CI's test
  job is green at afe4c086 on ubuntu. bun scripts/check.mjs: ok.
Broken by hand: index.mjs at afe4c086 with the new tests and fake: 9 of
the 10 new or changed tests fail (37 pass, 9 fail). The pasted-session
"names no day" test is a guard and passes on both.
Not tried: a real Loomy account (none here), so the session's real
lifetime is unmeasured, and the user's proxy's actual 401/403 body is
not seen; the fix holds for any body without a sign-in code.
2026-11-17 10:08:33 +08:00
yetone 7f351a101c loomy 0.1.11: a dropped session's 200 with code 100002 on chat and draw is a 401 that says the sign-in expired
jenxingyoung on X: "loomy老是轮着掉登录". Loomy's gateway refuses a dropped
or unknown session with HTTP 200 and a business code on every path, chat
included. Measured 2026-11-16 with a made-up token: /api/v1/chat/completions
(stream asked for), /api/v1/models and /api/v2/points/records each answered
200 application/json {"code":"100002","desc":"登录已失效,请重新登录"}, and with
no token 200 {"code":"100002","desc":"缺少 token"}. None of them answered 401.

The loader passed that 200 through as the model's answer. magpie took it as a
success: the agent got no completion, the next account wasn't tried, and the
account's signed-out mark (set by the usage read, which does read 100002)
came off, until the next usage read set it again. A dead account was shown
signed out, then signed in, then signed out again, one account after another.

Now a JSON 200 with a top-level code other than 000000 on chat or draw is a
refusal: 020002/100002 is a 401 with x-magpie-sign-in: expired, so the
account stays marked and magpie moves on to the next account; any other
code is a 502 with the vendor's words. SSE streams, completions and draws
(none of which has a top-level code) go through as they came.

The fake answered a refused session with HTTP 401, which is why the old
"a refused session says 401" test passed; it now answers as the real gateway
does.

Run (mote):
- new tests against the old index.mjs: 4 fail (chat refused session, chat
  100002 stream/non-stream, chat other code, draw 100002), 34 pass
- HOME=$(mktemp -d) bun test at the root: 9001 pass, 20 skip, 0 fail
  (9021 tests, 630 files); bun scripts/check.mjs ok

Not tried: a real Loomy account (no credentials), so the session's real
lifetime and whether signing in on the Loomy app drops magpie's session are
unmeasured. HTTP 401/403 from the vendor still read as signed out; no 401/403
was seen from the vendor in these probes, so that path is unchanged.
2026-11-16 18:04:25 +08:00
yetone 209afdbf68 loomy 0.1.10: a refusal in a 200, or a failed read, gives the given list marked fell back
A non-OK business code in a 200 answer (the host saw an OK fetch) returned the static table unmarked; so did a throw. fake.mjs can now answer the models read with a code.

Archivemylife on X (agy-cli): "配置后报存提示成功,再打开还是全部都启用".
The same class as agy-cli 0.1.61: a list that isn't the account's own,
handed back as if it were, makes magpie relist on it and drop the models
the user picked that aren't in it. Marked with
Symbol.for("magpie.fellBack"), magpie's plugin host keeps the last good
list (keepListed) and the picks.

Run (mote-run, HOME=mktemp -d): index.test.mjs 34 pass on this change: all pass.
Red on the old code with the new test: "a refusal in a 200 gives the static table marked" fails.
Not tried: a real account.
2026-11-15 14:03:54 +08:00
yetone 09e5970996 loomy: the total names no reset while only permanent credits are left (#1153)
With the daily credits spent and permanent ones left, the 积分合计 window
still said it reset at Beijing midnight. magpie's smart routing ranks the
soonest reset first, so such an account went ahead of trae-cn's, Qoder's
and WorkBuddy's day and month windows, whose credits are lost at their
reset, while midnight loses nothing of Loomy's. The total now names a
reset (and its span: magpie reads a span with no reset as renewing a span
from now) only while daily credits are left, or when nothing is left at
all, so a used-up account still says when it is back. The daily wallet
beside it, set aside for routing, keeps showing midnight.

loomy 0.1.9.

Run on mica (Bun 1.4.2), sandbox HOME: bun test in packages/loomy 33
pass; scripts/check.mjs loomy clean. Broken by hand: with main's
index.mjs the usage test fails (resetsAt 1794672000000, expected none).
Checked in magpie origin/main: Smart puts a window with no known reset
after those with one (internal/routes/strategies.go), and a window
set aside never enters the allowance (provider/routing.go).
Not tried: a real Loomy account in routing.
2026-11-14 22:53:12 +08:00
yetone da17052c0c loomy 0.1.8: the vendor's vision, reasoning and tool calls reach the host (#1141)
The models hook gave each listed model in OpenCode's config shape
(modalities, reasoning, tool_call), and replaced the entry it was given
with it. The host (magpie's and OpenCode's) reads a listed model by its
runtime shape: capabilities.input.image, capabilities.reasoning,
capabilities.toolcall. So a model models.dev doesn't know, like
deepseek-v4-flash-1017, went as one of no known vision, and its
reasoning and tool calls were dropped too.

listedModel now merges over the existing entry, keeps the config's
fields, and sets capabilities from what the vendor says; what it
doesn't say keeps what was known of the model.

Run (mica, temp HOME): packages/loomy bun test 33 pass; bun
scripts/check.mjs loomy ok. With main's index.mjs the new test fails
(32 pass, 1 fail). Not tried against a real Loomy account.
2026-11-14 17:48:20 +08:00
yetone 0a2cf4734c loomy 0.1.7: deepseek-v4-flash-1017 keeps its image_url parts; only the old DeepSeek line gets the base64 marker (#1139)
prefersTagFormat exempted only ids spelling v4.1 / v4-1, so
deepseek-v4-flash-1017, which reads OpenAI image_url parts, had its
images turned into <image_base64> text and never saw them (7,368 prompt
tokens against 232, per the reporter's side-by-side). The marker is now
for deepseek-v4-flash and deepseek-v4-flash-0731 only, the ids it was
made for; any other DeepSeek id keeps OpenAI's shape, since Loomy
renames them freely and the newer ones take image_url.

Run (mica, sandbox HOME): bun test packages/loomy 32 pass;
scripts/check.mjs loomy ok. Broken by hand: main's index.mjs fails
"which models get the base64 marker" on the 1017 ids.
Not tried: a real Loomy request (the reporter's table is the evidence).
2026-11-14 17:03:23 +08:00
yetone fbeda91fb3 loomy 0.1.6: routing reads the daily and permanent credits added up (gocccy0 on X)
gocccy0 on X: Loomy's usage sent the permanent credits (永久积分) as aside
text, and the daily credits (每日赠送积分) either as aside text too (no
dailyLimitPoints pair: routing had no window, "quota unknown") or as the
one window routing reads (with the pair: at 100% it stopped an account
that still had permanent credits).

Now usage leads with 积分合计, the window routing reads (totalOf): spent
is what the daily wallet has spent, limit is spent + daily left +
permanent balance, used its share; with nothing left at all it is 100%.
It renews at Beijing midnight with the daily wallet, and the daily
credits left are lost then (runsOutAt, runsOut), so magpie's Smart and
Least used first spend them first. With the permanent balance alone it
has no reset. The two wallets are still shown, both set aside, as
WorkBuddy shows its plan and extra credits beside their total. No
magpie change: plugin windows already carry amount/limit/runsOutAt, and
40c8d0c81 already shows an all-aside account's read.

Run (mote, HOME=$(mktemp -d)): bun test in packages/loomy, 32 pass,
including the new test (daily spent + 1,200 permanent is 80.6% not 100%;
both 0 is 100%; 3,000 daily left run out at midnight; no limit pair; the
permanent balance alone). Root HOME=$(mktemp -d) bun test: 8648 pass, 20 skip, 0 fail;
scripts/check.mjs ok.
Broken by hand: no total window (the old shape) turns the new test red
(2 counted windows, expected 1).

Not tried: a real Loomy account (the reporter's reply shape is assumed
to be one of the ones tested); magpie's GUI with the plugin installed.
2026-11-13 17:40:41 +08:00
yetone 0135b7b0ea agy-cli 0.1.32: the first model list after warming has agy's Claude and GPT models (#1064)
On a signed-in agy, `agy models` takes about 4.4s and `agy acp`'s
session/new about 3s. provider.models() needed three calls before
claude-opus-5-5, claude-sonnet-5-5 and gpt-oss-120b showed up, and
OpenCode 2.x calls it once.

What changed:
- packages/agy-cli/index.mjs:
  - The offered-model probe now starts in listAgyModels' .then, as soon as
    a non-empty list arrives and a caller asked for probeOffered. It no
    longer waits for the next models() call. A hung or failed `agy models`
    still never spawns the probe.
  - probeSignedIn reuses the `agy models` stdout it already has. The same
    parser (parseAgyModels, split out of listAgyModels) fills
    cachedModelCatalog, and the probe starts. Sign-in waits for the probe
    for at most 3s.
  - The offer (acpOfferedModels, acpOfferedKey, offeredProbeAt and any
    in-flight probe) is forgotten when agyPath changes and after a new
    sign-in finishes. A generation counter drops the answer of a probe
    that started before the reset.
  - provider.warming() returns a promise while a list or probe is still
    running, and null when nothing is.
- scripts/opencode2.mjs, copied byte for byte to every
  packages/*/opencode2.mjs: after the first background refresh, the
  adapter awaits hooks.provider.warming() once, for at most 60s, and then
  refreshes once more. It does not loop. Plugins without warming() behave
  as before.
- Not done: the issue's on-disk catalog cache (point 3), skipped as asked.

Known gap: agy-cli has no `config` hook, so under OpenCode 2.x the adapter
lists no provider for it. refresh() returns before it calls
provider.models(), so the follow-up refresh can't add agy's models on 2.x
until agy-cli gets a config hook.

Tests: test/testkit.mjs's fake agy takes a sessionNewDelayMs. The new
tests in test/catalog.mjs set 1.5s on both `agy models` and session/new
and wait for state through warming(), with no fixed sleeps:
- On a slow cold start, the first models() after warming lists Claude and
  GPT, from one probe spawn.
- authorize() on a signed-in agy fills the catalog, and the next models()
  runs no second `agy models`.
- The sign-in wait is bounded: with a 6s session/new, sign-in returns in
  about 4.5s.
- Changing agyPath probes again.
The hang test now awaits warming() before it counts acp spawns.
scripts/opencode2.test.mjs: the warming list is read a second time when
warming ends, and only once when nothing is warming.

Run on Linux (a separate test Mac was over its load limit):
- packages/agy-cli bun test: 17 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.
- bun scripts/check.mjs (all packages): ok.
- Root bun test in a temp HOME: 8530 pass, 19 skip, 0 fail.

Broken by hand on Linux, each red, then restored green:
- No probe in the .then: the slow cold-start test.
- probeSignedIn drops the list: the authorize and bounded-wait tests.
- agyPath change keeps the old offer: the agyPath test.
- Unbounded sign-in wait: the bounded-wait test (7514ms).
- Probe also on a failed listing: the hang test.
- origin/main's index.mjs with the new tests: all four #1064 tests.
- Adapter reads the list once: the warming adapter test, and the
  copy-identity check.

Not tried: a real agy (no Google sign-in, no network). The reset after
login.finish has no unit test of its own.

Reported-by: hiee3
2026-11-13 10:59:13 +08:00
yetone c61d83d0a1 loomy 0.1.5: the daily wallet sends the share spent and the credits spent (#889)
magpie reads a window's `used` as the share spent (0-100) and `amount`
as what was spent of `limit`. Loomy sent the credits spent as `used` and
what was left as `amount`, so 800 spent of 5,000 read as 800%, and an
account window cap of 4 credits compared the 4,200 left with the cap:
it held a fresh account and let a spending one go past it (9won_25273
on Discord, over by more than 1,000). Now 16 and 800. A zero allowance
is 0, never NaN. The permanent wallet comes back as a balance alone, with
no total, so it stays an amount shown aside.

Run on mote at origin/main f54991b9 + this: bun test in packages/loomy
31/31. Broken by hand (the old used/amount put back): 3 usage tests red,
the new fresh-and-empty test among them.
Not tried: a real Loomy account.

Reported-by: 9won_25273 on Discord
2026-11-10 00:26:38 +08:00
我是一条没有名字的区 087c36123d inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator):

- Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all.
  - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none.
  - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal.
- The body rewrite strips the reasoning fields and sets image detail to auto.
- A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key.
  - Neither browser method is offered when no Chromium-family browser is found (#825).
- The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry".
- The #826 metadata token read is kept, and its test is back.
- The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows.
- maxConcurrency is 4.
- The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included.

Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME:
- full bun test: 6853 pass / 0 fail; both checks exit 0
- bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0
- 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed)

Not tried: a real InkStone account or sign-in, Windows and Linux runs.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 e7004d9354 inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern
InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id
`intern-inkstone`. Community package by yunwang2442-creator.

What it does:
- Browser sign-in (Edge/Chrome, its own profile under
  $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or
  %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no
  debugging port. A headless CDP read takes the uaa-token cookie, and the
  same read renews it silently later.
- Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs.
- Chat: a pasted ink-* API key, or one the sign-in creates, named
  ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An
  idempotency clash (-15109) retries with a fresh name, up to three times.
  Pruning is on by default. It only touches this machine's and account's
  prefix, keeps the newest two and the key this sign-in created, and never
  deletes manual keys or keys of unknown age.
- Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover
  browsers are matched by --user-data-dir=<escaped profile>, and Windows
  uses .Contains().
- The login wait comes from an injected waitForLogin in tests. No env
  hook is left in production code.
- Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn,
  127.0.0.1 (CDP).

Outside the package: scripts/opencode2.mjs lets a prompt with
`required: false` stay optional (`p.required !== false`). Every package's
copy is synced byte for byte, so all 39 copies in the merged tree are blob
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
yetone 7a2599bdae loomy 0.1.4: DeepSeek-V4.1-Flash keeps its image_url parts (#811)
prefersTagFormat() sent every model id containing "deepseek" through
rewriteImagesToTags(), which turns data-URI image_url parts into
<image_base64> text. That rule came with the plugin (6a9c528a, from
agent2api's images.rs) for the DeepSeek models of the time; the test
fixture's model is "deepseek-v4-flash", listed as "DeepSeek V4 Flash 0731".
The reporter's direct calls show DeepSeek-V4.1-Flash now reads OpenAI
image_url parts (prompt 244 tokens, right answer on two accounts) and
reads the marker as plain text (prompt 10,533, all output spent on
reasoning, empty reply). deepseek-v4-flash-0731 reads neither shape, so
it keeps the marker as before; nothing here makes it worse.

Now a deepseek id with v4.1 / v4-1 in it keeps its parts as sent; every
other deepseek id is rewritten as before.

Run (on mote, via mote-run):
- bun test packages/loomy: 30 pass, 0 fail
- bun scripts/check.mjs loomy: registry.json and loomy ok
- HOME=$(mktemp -d) bun test (whole repo, as CI runs it): 6499 pass,
  1 fail. The fail is sap-aicore's "late failure does not delete a
  newer candidate" under load; it passes 3 of 3 alone, filed as #812.
  (A first run without a sandbox HOME failed devin and zcode tests that
  refuse to run under a real HOME; not a red.)
Broken by hand:
- prefersTagFormat back to "every deepseek": the two new tests (the
  reporter's DeepSeek-V4.1-Flash request through the loader, and the id
  table) go red, 28 pass / 2 fail.
- prefersTagFormat always false: the original 0731 marker test and the id
  table go red, 28 pass / 2 fail.
Not tried: a real Loomy account; the ids and token counts are the
reporter's.

Reported-by: gcq909893267
2026-11-07 02:11:17 +08:00
yetone 17e5ef7457 all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin
must export a default definition with an id and an effect or setup
function. (cause: SchemaError(Missing key at ["default"]))". 2.x
imports a package's exports["."] (a plugin dir and an npm install
alike) and has no V1 path at all, so every package here that serves
models failed the same way, not only trae.

Every one of the 32 model packages now has:
- opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an
  adapter that runs the package's V1 plugins inside 2.x's promise
  API. Config providers become 2.x providers (package pinned so the
  aisdk sdk hook runs), V1 auth methods become integration methods
  (oauth auto/code with forms; api without authorize as a key method),
  V1 credentials are kept in metadata.v1, the loader's baseURL,
  apiKey, headers and fetch are applied through the sdk hook, an
  auth.set renewal is stored per credential, and credential.switched
  /updated reload the account's own model list.
- opencode.mjs, main: re-exports the V1 plugin functions only.
  OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's
  main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin
  export is not a function"); the new main fixes that too.
- both files in "files"; patch version bumped. devin already had 2.x
  and is unchanged.

scripts/check.mjs fails a model package whose 2.x entry has no default
{id, setup}, whose opencode2.mjs differs from the canonical one, whose
entry is missing from files, or whose main exports a non-plugin.

Run at this head (mote):
- HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail
  (4914 tests, 374 files). A first run set globalThis.fetch for the
  whole process from opencode2.test and failed 528 tests in other
  packages; the block is now set and put back around that file's tests.
- bun scripts/check.mjs: every package passes. With the network
  blocked cloudflare-workers-ai fails on its fetched catalog, the same
  on origin/main.
- Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae
  0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN"
  and trae-global "Trae Global" with their browser sign-ins; `auth
  login` starts the trae.cn authorization and waits (cancelled there);
  with a fake credential POSTed to /api/credential, `opencode models`
  lists trae-cn's six models.
- Real 2.2.5 with a fake V1 key plugin through the same adapter
  against a local fake server: `auth login` with a key, `models`,
  `opencode run` reached /real/v1/chat/completions with the loader's
  "Bearer loader-sk-fake" and header, and printed the fake's reply;
  with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key
  from the loader. This run found the key method missing after 2.x's
  second integration transform (a once-only flag outside the
  transform); fixed, and opencode2.test checks a rebuild.
- Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models`
  lists trae-cn and trae-global models; 0.2.26 failed there.

Broken by hand (scratch copy, bun test scripts/ and check.mjs):
- trae's exports back to "./index.mjs": the trae 2.x test fails
  (default.id undefined), check fails trae with "OpenCode 2.x:
  ./index.mjs has no default {id, setup} (plugins#657)".
- zed's opencode2.mjs changed: the copies test fails, check fails zed
  "differs from scripts/opencode2.mjs".
- the key flag back outside the transform: the 1.x plugin test fails
  on the rebuilt sign-ins (key missing).

Not tried: a real sign-in with a real account on 2.x; Windows (the
reporter's OS); chat.headers, chat.params, usage and tool hooks, which
the adapter doesn't carry to 2.x; the tools/pages packages (calc,
goanyapi, layerfs, search1api, aelios, agent-console, chat,
fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
2026-11-03 13:54:26 +08:00
yetone 53e38206ba loomy 0.1.2: the loader serves /images/generations, so the three image models draw (#609)
The loader's fetch answered every path but /chat/completions with
404 "only chat completions are served", so doubao-seedream-5-lite,
qwen-image-3.0-pro and Hy-Image-3.5-preview, which /api/v1/models lists
with output_modalities ["image"] and magpie offers in its image picker,
could not draw (lakegan measured 404 with no ep in usage.jsonl).

A request to .../images/generations now goes to
{modelBase}/images/generations with the session in token and
Authorization, Content-Type application/json;charset=utf-8 and
Accept: application/json (not text/event-stream), the body as magpie
wrote it, and the upstream's JSON comes back as it is. 401/403 say the
sign-in has lapsed (401), as the chat path does; another error keeps its
status with the upstream's text. The chat path is unchanged.

/images/edits is not served: magpie's gateway sends a plugin's edit as
multipart (internal/gateway/draw.go drawImages), and what Loomy's gateway
takes for an edit hasn't been measured. It still answers 404, now
"only chat completions and image generations are served".

The fake gateway answers /api/v1/images/generations with the reporter's
literal 200 body. Tests: a draw is sent with the session and JSON accept
and passes the body and reply through, a Request object's body too,
401/403 become 401, a 400 keeps its status, chat streams after a draw,
and embeddings and /images/edits still 404.

Run (mote, at this tree on 8db0a05):
- packages/loomy: bun test, 28 pass 0 fail.
- whole repo: HOME=$(mktemp -d) bun test, 4555 pass 9 skip 0 fail
  (352 files); bun scripts/check.mjs loomy ok.
Broken by hand, each red on mote, then restored:
- draw route off (old guard): the 5 new image tests red.
- Accept: text/event-stream on the draw: the forward test red.
- draw's 401/403 mapping removed: the 401 test red.
Not tried: a real Loomy account (none here); the reporter's measured
call is the evidence the route works. Not done: #563 (an update-safe
local patch) is separate.
2026-11-02 02:35:20 +08:00
MYCF711 b177d69b83 loomy: a too-long refusal is reworded so magpie tries a longer window (#529)
When Loomy answers 400, 413 or 422 with a body that says the content is too long (内容太长了 / 内容过长), the plugin now rewords that body to 上下文超出长度限制, the phrase magpie's too-long matcher recognises. The status code is kept. magpie then treats the reply as a context-length refusal and tries a model with a longer window, where before it gave up on the request. The rewrite is in retryableRefusal() and runs on the loader's !res.ok path. fake.mjs gains chatRefusal. Version 0.1.0 -> 0.1.1.

Reviewed at 2bb41e0 (Mac mini, Bun 1.4.2, through mote-run, sandbox HOME):
- Repo suite (`HOME=$(mktemp -d) bun test`): 3813 pass, 8 skip, 0 fail.
- `bun scripts/check.mjs`: exit 0.
- Broken by hand: with retryableRefusal returning null, 3 loomy tests go red (the over-length Kimi-k2.6 chat test, the 400 rewrite, and the 413/422 cases). They pass again once it is restored.
2026-10-30 23:06:49 +08:00
lin2670 6a9c528a5c loomy: add the iFlytek Loomy plugin (#175)
Adds packages/loomy (iFlytek Loomy): SMS sign-in, paste-a-session sign-in, models, chat, daily wallet usage and check-in. Hosts: account.xfinfr.com and loomyad.xunfei.cn only; no dependencies or scripts.

Answers the 10-17 review: the paste method now returns { url, instructions, method, callback } as internal/plugin/host.js calls it; the limit/remaining pair alone renders the daily wallet; a failed pre-check-in read reports failed instead of refreshing.

Run at fd963f1 (PR head 836ed7b with origin/main merged; registry.json conflict resolved keeping both entries), on mote with a sandbox HOME:
- bun test packages/loomy: 18 pass, 0 fail
- bun scripts/check.mjs: exit 0 (loomy ✓); bun test scripts: 3 pass, 0 fail
- Broken by hand, each red then restored: paste callback reverted (1 fail), pairPresent removed (1 fail), pre-read failure reverted (1 fail)

Not tried: a real Loomy account. Not on npm yet: served from the dist branch until the first version is published by hand.
2026-10-29 21:11:14 +08:00