Skip to content

feat(media): image_edit — edit or upscale an existing image (v0.138.0)#233

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/image-edit
Jul 13, 2026
Merged

feat(media): image_edit — edit or upscale an existing image (v0.138.0)#233
vikasprogrammer merged 1 commit into
mainfrom
feat/image-edit

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

What

New governed MCP tool image_edit — agents can now transform an image they already have, not just draw from scratch:

  • Prompt-guided edit (image-to-image): "make it a watercolor", "remove the background", "add a hat"
  • Upscale: pass scale of 2 or 4

The source image accepts the same three places a session's image can live (shared resolver): a Library artifact id, a working-folder file path (written or terminal-uploaded), or an http(s) URL. The result is saved as a new Library image — the source is never mutated — plus an inbox card.

How

  • src/edge/image-gen.ts: ImageBackend gains editImage(). AtlasBackend implements it and shares a new submitAndPoll() with generate() — edit and upscale ride the same generateImage submit+poll, only the body differs (images[]+prompt for edit, image+outscale for upscale). OpenRouter throws (its image API is text-to-image only).
  • src/terminal.ts: editImage() mirrors generateImage — resolve ref → gate image.edit (cost estimate → money-cap) → backend.editImageingest as a new image artifact + inbox card → audit image.edited.
  • src/server.ts: POST /api/agent/image/edit (loopback, session-secret gated).
  • src/memory/memory-mcp.ts: IMAGE_EDIT_TOOL + handler + dispatch, exposed with image_generate.
  • Defaults: edit → google/nano-banana-2/edit, upscale → atlascloud/image-upscaler (override via model).

Governance

Classified image.edit with an amountUsd estimate — the wildcard money-cap never rule applies automatically (no policy change). Audited image.edited. Source ref resolution reuses containedPath containment (no folder escapes).

Verified

  • Live Atlas API, in-process through the real adapter: edit → nano-banana-2/edit (2 MB PNG), upscale → image-upscaler (812 KB JPG). Both return stored image bytes.
  • typecheck, build, test:governance (68/68) pass.

Atlas-only. New route needs a server restart on the live box; the new MCP tool needs a session relaunch to appear.

🤖 Generated with Claude Code

New governed MCP tool: takes a source image (Library id, working-folder
path, or URL) + a prompt (image-to-image edit) or scale (upscale), and
saves the result as a NEW Library image. Extends the Atlas image backend
with editImage (shared generateImage submit+poll); route
/api/agent/image/edit; classified image.edit (money-capped), audited
image.edited. Verified live (edit + upscale return images).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vikasprogrammer vikasprogrammer merged commit f14cefe into main Jul 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant