4794de398ea8337d223a91e207181c56fcf4ad76
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f0dc9ea695 |
imagemcp, gateway: a 4K image a relay answers by URL is saved, and one that can't be downloaded is answered with its URL, not lost (#1576, david-zdw)
What the reporter saw: generate_image (magpie mcp image) failed on 4K and 2048x1152 with "image 1: context deadline exceeded" and "no image: context deadline exceeded", while the same request to /v1/images/generations came back in ~40 s, and usage.jsonl showed the upstream's 200. Their relay answers with a URL whatever response_format says. Two causes, one per error: - "image 1: context deadline exceeded" was generate_image's own download of the URL (imagemcp.download): 2 minutes for the whole of it, on http.DefaultTransport, which knows the global proxy but not a provider's own (#237). A 10 MB PNG that was still coming was cut, and the error dropped the URL of an image already drawn and paid for. Any earlier image of n was saved but not said either. - "no image: context deadline exceeded" (the usage log's 502s at 300002-300032 ms) was the gateway's drawTimeout (5 min) expiring while it read a vendor's answer that had already begun: sendWith passed the bare context error up. The vendor really took over 5 minutes there; this commit doesn't change that limit, it says what happened. What changed: - gateway: an images caller that asks response_format "b64_json" gets the image itself. One the vendor gave only a URL for is fetched by the gateway's own client, through the provider's proxy (p.Via), after the draw and outside drawTimeout. One that can't be fetched is answered by its URL, as before, never dropped. A caller that asks no format still gets the URL. Nothing is sent to the vendor differently. - gateway.FetchImage: an image download gives up when nothing has come for ImageStall (1 min) or it has taken ImageLongest (5 min), and says which and how much had come. A slow download goes on while it moves. The edits' fetchPicture uses it too. - gateway: a vendor that began answering but hadn't finished in drawTimeout is a 504 "<name> began answering after Ns (200 OK) but hadn't sent all of its answer in 5m0s", not a 502 "context deadline exceeded". - imagemcp: asks for b64_json; downloads a URL the gateway still hands it with FetchImage; an image it can't have is answered with the vendor's URL to download it from, beside the ones saved (an error only when none was). Its client to the gateway waits ToolTimeout (11 min), past the draw and the fetch together, not 6 minutes. What was run: - Reproduced on the old code: the new TestFourKImageByURLIsSaved (a real 3840x2160 PNG, 9.8 MB, served by URL in 256 KB pieces over ~4 s) with the old download's 2-minute cap scaled to 1 s fails with the reporter's exact "image 1: context deadline exceeded"; the stalled case fails the same way, with no URL in the error. - Broke each part by hand and watched its test go red: no inline fetch, fetch not through the provider's proxy, the bare deadline message, the stall timer not reset (a total cap again), a lost image ending the call, the MCP not asking b64_json. - go test ./internal/imagemcp/ ./internal/gateway/ ; the full go test -tags nogui ./... ; gofmt -l ; GOOS=linux and GOOS=windows go vet on both packages. - On the Windows box (Windows 11 x64): imagemcp.test.exe all passed, and gateway.test.exe for the new tests and the images/ModelScope tests. Not tried: the reporter's relay itself (never contacted), and a real 4K draw end to end. Why their URL took over 2 minutes from the MCP when their own download took 7.5 s isn't known from here: a provider proxy the MCP didn't use is one way it happens; a slow file host is another. Both are covered now. |
||
|
|
16539c2ea9 |
imagemcp: generate_video and the Magpie Image card name every video model the gateway makes videos with, not a Grok subscription alone (#1399)
shen-joe (#1399) wants images and videos from magpie in PI-Desktop and WorkBuddy. Neither app sends video generation to a custom provider: PI-Desktop has no video generation at all, and WorkBuddy's VideoGen/ImageGen post to copilot.tencent.com's /v2/videos|images/generations with the account token. So the way those agents get videos is Library → MCP → Magpie Image (`magpie mcp image`). Its generate_video tool told the agent it works only "with a Grok subscription signed in to Magpie (it has no other video model yet)", and the Library card said the same, while gateway.Videomakers also makes videos with a preset plan's videos (Volcengine Ark Agent Plan's Seedance), another magpie, and a custom provider whose model list marks video models (#1446). An agent reading that can tell a Seedance user they need Grok. - imagemcp.go: generate_video's description and the package doc name each kind of video model. - library/market.go: the Magpie Image card says "a video model set up in Magpie (Grok Imagine, Seedance)"; zh, zh-TW, ja and de follow. - Tests: TestVideoToolSaysEveryVideoModel and TestMagpieImageSaysVideoModels fail on the old text and pass now. Run: go test -tags nogui ./internal/imagemcp ./internal/library ./internal/gui ./internal/gateway (ok) and ./... (only TestNoCommandBypassesProc red, from |
||
|
|
c426994196 | library, imagemcp: magpie's own image server is given to agents in WSL, started through WSL's interop with the paths crossing over (#900, cjyrainbow) — on Windows the Library names magpie-image by this machine's binary ('D:\tools\Magpie\magpie-windows-amd64.exe' mcp image), and turning it on for "Codex · WSL Ubuntu" or "Claude Code · WSL Ubuntu" failed: a Windows program was refused for every agent in WSL. WSL's interop starts a Windows .exe from inside the distro, so magpie's own server (args mcp image, whatever its binary) is now written for an agent in WSL by the binary's path in the distro, asked of the distro itself (wslpath -u, so a custom automount root is followed; asked once in ten minutes; /mnt/<drive>/ when it can't be asked), with --wsl <distro>, --mount where the drives aren't under /mnt/, --home the distro's $HOME, and WSLENV naming the variables it is given (MAGPIE_ADDR), which a Windows program otherwise doesn't get. A distro whose interop is off (no WSLInterop in binfmt_misc) is told so: turn it on in /etc/wsl.conf. A user's own Windows program is still refused, as before: its paths and variables wouldn't cross over. A Linux magpie in the distro isn't looked for: the Windows one reaches the gateway at 127.0.0.1 and reads this machine's settings, the same version as the app, which a Linux one would need the gateway's address from inside WSL for. With --wsl, magpie mcp image opens the paths the agent gives (its roots, reference images, where to save, ~/) as the distro's — /home/me/x through \\wsl.localhost\<distro>\home\me\x (\\wsl$\ where that isn't), /mnt/c/x as C:\x — answers the saved paths as the distro's (/home/me/app/generated-images/…, /mnt/c/…), and with no project falls back to the distro's ~/Pictures/Magpie. Tested on the Windows 11 test box: in a WSL2 Ubuntu 24.04 distro the library's probe gave /mnt/c/…/magpie.exe and interop:on, and this build, started from the distro as the library writes it (the .exe's /mnt/c path, mcp image --wsl, MAGPIE_GATEWAY through WSLENV to a stand-in gateway in the distro), answered initialize and generate_image with a root of /home/yeton/m900proj: a relative path and an absolute reference image (sent as /v1/images/edits), ~/m900proj/home.png and /mnt/c/… were each saved there and answered as the distro's paths. TestWSLMagpieImage (the /mnt/d command, --wsl, WSLENV, nothing rewritten or asked again at the next sync, a custom mount, interop off as a problem) and TestLinuxHome in internal/library, TestWSLPaths in internal/imagemcp are new and fail without the change; TestWSLServers (npx.cmd still refused) passes. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass (internal/provider failed once under load and passes alone). | ||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
01a7b55050 |
imagemcp: an image that takes longer than the agent gives a tool call is answered "still being made" before the agent gives up, and is saved all the same (#575: 图片生成的mcp经常遇到超时问题 — "Tool execution timed out after 30000ms" in one agent, "Error: Request timed out" in another; the agent then looked for the file, found none, and asked for the image again, and again timed out) — generate_image held its tools/call open until the gateway's image came back, and an image model (gpt-image at quality high, 1024x1536, through a subscription) often takes a minute or more, while agents give an MCP tool call as little as 30 s, the MCP SDK's default is 60 s, and only Codex and Goose have a timeout magpie writes for them (tool_timeout_sec, timeout). So the call was cut short, the generation went on unseen, and the agent's retry started another one that was cut short too. Now each generate_image and generate_video call runs as a job that goes on to its end whatever becomes of the call, and the call waits for it at most answerWithin (20 s, under the shortest of those limits): what is ready by then is answered as before (errors too); what is not is answered, not as an error, that it is still being made, where it will be saved, not to ask for it again, and an id for the new tool generation_result, which waits on the job the same 20 s at a time and answers its paths once it is saved. A call given a progressToken is sent notifications/progress every 5 s while it waits, for clients that wait longer on progress, and magpie mcp image waits for jobs still running when the agent closes it (up to ToolTimeout) so what is being made is saved. TestSlowImageAnswersBeforeTheAgentGivesUp (a gateway taking 700 ms against a 150 ms answerWithin: the call answers in time with an id and progress notifications, generation_result then answers the saved file, the gateway was asked once, an unknown id is a tool error) fails without the change (the call took 703 ms and answered only when the image was saved). go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass (TestFXInState's known TempDir cleanup flake aside); go test -race ./internal/imagemcp passes.
|
||
|
|
0361189f9e | test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass. | ||
|
|
f1906bca6a |
gateway: draw and film through a Grok subscription (Grok Imagine) (#360)
* gateway: draw through a Grok subscription (Grok Imagine) A Grok subscription (SuperGrok, X Premium+) could not draw: Drawers() returned nothing for it and draw() refused with "Grok (SuperGrok) can't draw: magpie draws only through an OpenAI-compatible API, and Grok (SuperGrok) has none". Grok Build's own image_gen / image_edit tools call the backend's Imagine API at <cli-chat-proxy.grok.com/v1>/images/generations and /images/edits with the CLI's sign-in, which magpie already uses for chat. - drawsGrok / grokDrawers: a Grok account draws with grok-imagine-image and grok-imagine-image-quality, like a ChatGPT account does with GPT Image - the Imagine API takes an aspect ratio, not a size or quality: size WIDTHxHEIGHT is matched to the nearest ratio it accepts (aspectAmong, aspectOf is unchanged); the image is asked for as base64 - an edit is JSON with the images as data URLs - a plan's images cost nothing extra, so AutoDrawer ranks Grok with ChatGPT (ChatGPT still wins a tie on release date) - provider.grokBase is exported as GrokBase, like CodexBase, for the test Tested against a real SuperGrok account through the gateway: generation, 16:9, the quality model and an edit. Video is not covered: the Grok CLI's video tools need zero data retention off or a storage bucket. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * gateway: film through a Grok subscription, and a generate_video tool for agents A Grok account that draws (c6578bc) can make videos too: Grok Imagine's video endpoints sit behind the same sign-in. The gateway speaks OpenAI's Videos API, so its SDK works as it is: POST /v1/videos, GET /v1/videos/{id}, GET /v1/videos/{id}/content. A request is taken on at once and polled; the id carries the provider and the vendor's request id, so nothing is kept in the gateway and a restart loses no video. Status is mapped (pending at 0% -> queued, pending -> in_progress, done -> completed, failed/expired -> failed, with why). seconds (1-15, the vendor's limit, which it says when exceeded), size (-> aspect ratio and 480p/720p/1080p by the shorter side), input_reference for image-to-video (URL, data URL, {image_url}, or a multipart file) and reference_images are taken; a model that isn't a Grok video model is refused by name. /content answers 409 until the video is ready. `magpie mcp image` lists a second tool, generate_video: it starts the video, waits (up to 10 minutes), saves the mp4 into the project (generated-videos/ unless path says where, never over a file) and says where, so an agent can animate an image it just drew by passing its path. Checked against a real SuperGrok account: text-to-video, image-to-video (input_reference), reference_images, both video models, the OpenAI Python SDK (videos.create/retrieve/download_content), the MCP tool end to end with two videos at once, and the error paths. Unit tests use a fake Grok upstream. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * gateway: videos follow the Settings' off switch, and an id can't change the vendor's path Review of the video change: - Image generation "off" turns off the video a request that names no model gets (videomaker, beside drawer), so generate_video says it is off too. - A video id is put in the vendor's URL with the account's token: its parts must be [A-Za-z0-9_-]+ (parseVideoID) and the vendor id is path-escaped, so video_grok.x%3Fa=1.1 and %2F answer 404 and ask the vendor nothing. - The id carries a short mark of the account that started it; after a switch the video says it was started with another account instead of the vendor's not-found. - generate_video waits up to ten minutes, and Codex gives a tool a minute: magpie-image's Codex entry gets tool_timeout_sec (Goose's timeout) of eleven minutes, the user's own value kept. - grok-imagine-video stops at 720p (the vendor turns 1080p away for it; 1.5 makes 1080p), so a 1080p size is asked at 720p there. - A model may be named without its provider (grok-imagine-video). - "seconds": 6.0 is 6; 6.5 is still refused. - completed_at is left out: the vendor doesn't say when a video finished, and a time made up at each poll changed each time. Checked against a real SuperGrok account: bare model name, seconds 2.0, 1080p on the base model asked at 720p (the mp4 is 1280x720), 1080p accepted on 1.5, both malformed ids, no completed_at. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * gateway: TestVideoModelByItsBareName asks its two models in a fixed order It checked the body of the second request the upstream got, but asked the two models by ranging over a map, so it failed about one run in seven (Ubuntu CI). Ask them from a slice. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * library: an installed magpie-image gets the longer tool timeout on the next sync magpie-image already ships, so many users have it in Codex and Goose as it was written before: no tool_timeout_sec in Codex, and the timeout: 300 every Goose server was given. syncMCP skipped an entry whose command, args and env were unchanged, so an upgrade left Codex at its one-minute default, and Goose kept 300 as if the user had chosen it. - mcpFile.behind says an entry lacks the timeout magpie gives the server now: Codex's tool_timeout_sec is missing, or Goose's timeout is still exactly the 300 magpie wrote. syncMCP rewrites such an entry; merged() doesn't keep that 300 as the user's. A value the user chose (any other number) is left alone. - Test: an entry as main wrote it is given 660 in both, one the user set stays, and a second sync changes nothing. It fails without the change ("changed []"). Also, from the review: - seconds is validated once in readFilming: a decimal number that is whole and at least 1 (hex, inf, nan, underscores, negatives and 0 are refused), and the object echoes 6 for 6.0. - imagemcp: Run's doc comment is above Run again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
3ee4ebbf62 |
images: agents can generate and edit images with a model set in Magpie (让Magpie支持配置图像识别模型以及生图模型, part 2) — the gateway answers /v1/images/generations and /v1/images/edits for any model that draws: an images-API model (gpt-image-1, dall-e, imagen, a relay's) is sent the vendor's own images request (an edit as multipart, image[] per reference); a chat model that answers with images (OpenRouter's Nano Banana and GPT-5 Image, gpt-5-image) is asked with modalities ["image","text"], the size given as an aspect ratio, once per image asked for; Gemini's own image models over generateContent. Either way the answer is the images API's (b64_json with its mime_type, the model's text, usage), recorded in usage like any request. The model is Settings → Images → Image generation: Automatic (a model that draws among the providers set up, from the catalog's image-output models), Off, or any model; a request that names none is drawn by it, and with it Off is refused saying where to set one. Subscriptions draw nothing yet. magpie mcp image is a stdio MCP server with one tool, generate_image (prompt, size, n, path, reference_images): it asks the agent for its roots, saves each image in the project (assets/ by default, a name from the prompt, never over a file, the extension of what came back — a JPEG asked for as hero.png is hero.jpg), and says where; reference images are read from the project and sent as an edit. Its requests carry the agent's own name (claude-code/… magpie-image/1) so usage says which agent drew. Library → MCP servers → Discover has it as Magpie Image, opt-in: no agent is given it until picked, since every image costs what the model charges. Checked in a sandbox HOME against real vendors: OpenRouter's gemini-3.1-flash-lite-image drew a 3:2 magpie over MCP as Claude Code and edited it from the saved file as Codex (usage: claude, codex), AIHubMix's gpt-image-1 answered /v1/images/generations with a 1024² PNG; the Settings row and picker in light and dark, the Library card and its opt-in sheet
|