0e072cdf096c027bcabb32305194cd2624a95bf0
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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. |
||
|
|
f42a59adf5 |
codearts: an OfficeAce card for the same Huawei Cloud account (#522)
codearts: an OfficeAce card for the same Huawei Cloud account (#522, MYCF711) Adds the OfficeAce (AgentArts) provider to the codearts package, replacing officeace-auth; accounts signed in there keep working. Each card signs in on its own and holds its own record and refresh token, because a Huawei Cloud STS refresh token is spent once. A renewal writes only the record being renewed, so a removed account never comes back. Reviewed over eight rounds; reviewed head f7c2526. r8 is words only plus the writeSharedRecord -> writeProviderRecord rename (every caller and the test updated). Run at f7c2526 on mote: node --test packages/codearts/index.test.mjs 164/164 pass; bun scripts/check.mjs exit 0, codearts ok. Not tried: a real Huawei Cloud sign-in on either card. |
||
|
|
4d8d0310f9 |
codearts 0.2.6: an IAM internal id is never the account's display name (#518)
An account whose IAM phone read yields nothing no longer shows iam::<domain>:user:<name>, the hw... account name, a urn:, a uuid or a bare hex id as its card name. accountIdentityOf() walks the same candidates in the same order and skips any that looks like an id; with none left the name is "" and the host shows the provider's name. id/uid/accountId are unchanged (still the URN, as #483 settled), so no account is renamed. The only reader of .name is usage()'s `user` fallback. Reviewed at d8583da plus the reviewer's version bump (0.2.5 -> 0.2.6) at f77e5bb. Run on mote (macOS, Bun 1.4.2) at f77e5bb, from the repo root: - HOME=$(mktemp -d) bun test: 3763 pass / 0 fail (3771 tests, 298 files) - bun scripts/check.mjs: exit 0 Red on the old code: the PR's tests against main's index.mjs, 125 pass / 2 fail (both new tests). Broken by hand: displayNameOf without the looksLikeIdentifier skip -> "accountIdentityOf never makes an IAM id the account's name" red (126/1). Not tried: a real CodeArts sign-in whose phone read fails. |
||
|
|
b850c9da3d |
codearts 0.2.5: the card names the account by its phone, not by IAM's URN (#483)
The card names a CodeArts account by its masked phone (138****8000), read from IAM once per account (6h cache), while accountId stays the IAM URN, the account's identity. A renewal keeps the phone, reads it once for an account signed in before 0.2.5, never renames a named account, and gives an account stored without an accountId the URN. Reviewed at fa5aaae (round 4). Run on mote (macOS, Node 22, Bun 1.4.2) in a sandbox HOME, at that head: - node --test packages/codearts/index.test.mjs: 125 pass / 0 fail - bun test packages/codearts/index.test.mjs: 125 pass / 0 fail - bun scripts/check.mjs codearts: ok Broken by hand, each red at the test it should hit: - sign-in accountId: identity.id -> identity.name (index.mjs:2746): "a sign-in names the account by its URN while the card shows the phone" red (124/1). - refresh reads no phone (identified = next): "auth.refresh keeps a named account's identity ..." red (124/1). CI (test, on-npm) green at fa5aaae. Version 0.2.4 -> 0.2.5. Not tried: a real Huawei Cloud account. |
||
|
|
c2eb8de4f7 |
codearts 0.2.4: every model is text only, and an image it refuses is a 400
star21321321124 (Discord, magpie 0.1.1818, codearts 0.2.3): DeepSeek V4.1
Flash through a Codex-like agent failed often with "CodeArts: The request
model is not multimodal (InferHub.001001020.406) (502: you can retry your
request)", while CodeArts' own client served it.
Cause: the plugin listed its models with capabilities.input { text: true }
and no image key, and the config hook gave no modalities. magpie's host
reads image as said only when it is a boolean (imageSaid), so every
CodeArts model was "unknown" to magpie: an agent's screenshot or a tool
result's image went upstream as sent, instead of being described by the
Vision model or left out (textOnlyBody). CodeArts then answered
InferHub.001001020.406 inside a 200, which embeddedErrorStatus counted 502,
and magpie told the agent to retry, so it asked again with the same image.
- The config hook declares attachment false and modalities text in, text
out; provider.models says input.image false (and audio, video, pdf) for
every listed model. A kind the user's own config says stands. The -vl
models were already left out of the list.
- InferHub.001001020.406 / "not multimodal" is a 400: inside a 200 (stream
and folded JSON), and with any HTTP status. foldAnswer's own error now
goes through embeddedErrorStatus too, instead of a flat 502.
Run (on mote): packages/codearts HOME=$(mktemp -d) bun test, 117 pass;
the whole repo's bun test, 2985 tests 0 fail; bun scripts/check.mjs ok.
Broken by hand: the new tests against origin/main's index.mjs go red, 3
of 3 (the 400 on every path, the text-only declaration, the status map).
Not tried: a real CodeArts account with an image (none here); the exact
body CodeArts sends is taken from the reporter's message (error_code /
error_msg shape as its other embedded errors).
|
||
|
|
bace91473b |
codearts 0.2.3: a queued request leaves the queue at once when magpie has another candidate
As Qoder's 0.2.40 (axuhere on X: a free model held in a queue while another provider could answer). When magpie says another account, provider or routing group member follows this request (x-magpie-fallback: 1), a 429 with queue-status: queued isn't polled for up to 5 minutes: the trace leaves the queue (DELETE, as giving up does) and the plugin answers 503 with the queue's retry-after, "CodeArts queued the request; try again in 20s", so magpie asks the next. The header is read and dropped before anything is signed or sent. Without it, the wait is as before. Run: packages/codearts `bun test` (115 pass) and `node --test index.test.mjs` (115 pass); `bun scripts/check.mjs` all green. Broken by hand: index.mjs as before: the new test red (it waits in the queue instead). Not tried: a real CodeArts account queued live; the 429 headers are the shape the existing queue tests use. |
||
|
|
b1bc778edf |
codearts 0.2.2: tool names over 64 characters go cut and unique, and come back as the agent's own (#432)
CodeArts turned away ZCode's android emulator MCP tool, mcp__plugin_android-emulator_android-emulator__android_discover_project (71 characters), with "Function name [...] length over limit, maximum is 64 (InferHub.001001017.413)", so every ZCode chat with that MCP on failed. A name over 64 now goes as magpie's FlatName cuts one: its first 55 characters, "_" and 8 hex of its SHA-256 (64 in all). It is cut in every place the body names a tool: tools, functions, tool_choice, function_call, the history's tool_calls and a tool message's name, so the history keeps matching its tool on every turn. A cut that equals another tool's own name, or another cut, is cut again with a salt. The answer gets the agent's names back: in a folded (non-streaming) reply and in the stream, where a name the gateway sends whole, repeated in a later delta, or in pieces (the part past 55 held until the name is whole) is put back. Events that name no cut tool pass byte for byte, and a body whose names all fit is not touched at all. Run: packages/codearts `bun test` (114 pass) and `node --test index.test.mjs` (114 pass); `bun scripts/check.mjs` all green. New tests use the reporter's literal tool name, two names alike for 55 characters, a short tool named exactly like a long one's cut, a stream round trip through the loader's fetch (whole name, name in three pieces across the 55th character, a name that fits), a gateway repeating the name, and a folded reply. Broken by hand: restoreToolNamesInStream returning the stream as it came (stream and repeat tests red); no salt on a collision (collision test red); no shortening in prepareChatBody (4 tests red). Not tried: a real CodeArts account (its refresh token is single-use, so no live sign-in was copied into a sandbox); whether CodeArts ever sends a tool name in pieces (handled, not seen). |
||
|
|
515d94e3a2 |
codearts 0.2.1: signs only for its two hosts and follows no redirect, a callback without a code fails at once, fixes since #284 (#286)
The follow-ups from #284's merge review and fixes since: credentials are
signed only for snap-access.cn-north-4.myhuaweicloud.com and
opengw.developer.huaweicloud.com (one signFor every signed call passes),
and no signed or token request follows a redirect (redirect: "error" set
after the caller's init); a callback without a code fails at once and the
callback path is matched as sent; one renewal per refresh token per
account, and a transient renewal failure keeps the sign-in (503, kept);
the free model's TPM limit inside a 200 is a 429, not an empty reply;
benefit claims across Beijing midnight; Content-Length dropped from a
reshaped body; bounded queue polls that leave the queue after failed
polls; a busy callback port is retried. A check-in re-confirms only a claim
this plugin made and failed to confirm (kept for its Beijing day in the
account's state and the ledger's _unconfirmed key); a claim answering
id: null is never confirmed, as the IDE does.
Earlier review at cb14faf asked for three changes (re-confirm of id:null
claims, redirects carrying the security token, a test for leaving the
queue); 1c04a71 and 2447c5f answer them.
Run at the reviewed head 2447c5f9a118098e05439f96b1ff87a9bedc8d83, on
macOS, bun 1.4.2, node 24:
- packages/codearts: bun test 108 pass, node --test 108 pass.
- Whole repo at the head: 2033 pass, 0 fail; merged onto main
|
||
|
|
6579f0682a |
codearts 0.2.0: Huawei Cloud CodeArts (码道) coding plans, with Huawei Cloud OAuth sign-in (#284)
New package @magpie-community/opencode-codearts-auth 0.2.0 (Sakura-Natsu): Huawei Cloud CodeArts (码道) coding plans, with Huawei Cloud OAuth sign-in, request signing (SDK-HMAC-SHA256), a per-account cap of 3 in-flight sessions, per-account free/regular model lists, and requests signed only for https Huawei Cloud hosts. Reviewed head 31099104 (two rounds; the first asked for changes at a793ca5, all fixed here). Run at the reviewed head, macOS, bun 1.4.2, with a preload that allows only loopback network: - HOME=$(mktemp -d) bun test packages/codearts: 91 pass, 0 fail - HOME=$(mktemp -d) bun test (whole repo): 2011 pass, 0 fail - bun scripts/check.mjs: 21 ok - 10 parallel bun test --rerun-each 40 in packages/codearts: 0 fail - 22 hand breaks (signature, DPoP proof, 403 expired mark, session clamp, host check, per-account lists, callback server, refresh mark); 21 went red. The one green is the callback's prefix-path match (follow-up). Not tried against Huawei's real API (no credentials); sign-in, signature acceptance, session counting and metering rest on the author's use on two accounts. Follow-ups: list the exact Huawei hosts instead of *.myhuaweicloud.com / *.huaweicloud.com; fail at once on a callback with no code; drop the unused ticketId; exact callback path match. This is a new npm name, so its first publish needs an owner. |