7 Commits

Author SHA1 Message Date
小橙子
506c4c8754
fix(image-gen): auto-detect /v1 prefix and return image_url blocks for inline rendering (#63)
- Add /v1 path auto-detection: when BASE_URL omits /v1 and gets 403/404,
  automatically retry with /v1 prefix (generate, edit, list_models)
- Add minimal params fallback after /v1 retry for providers that reject
  response_format (e.g. Agnes)
- Return image_url content block for URL results so Desktop IDE renders
  images inline in the conversation

Co-authored-by: 你的姓名 <you@example.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-16 22:55:12 +08:00
你的姓名
ddc3570562 test: add tests for image-gen plugin, options API, and config modal
- MCP server tests (21 cases): initialize, tools/list, list_providers
  with capabilities, generate_image validation, edit_image capability
  check, SSRF protection (IPv4/IPv6/protocol), model capabilities
  matching, unknown tool, ping
- Server API tests: GET/POST /api/plugins/options with schema filtering,
  sensitive value masking, missing field validation
- Desktop component tests: PluginConfigModal render, fetch, save with
  masked sensitive field skip, error handling, cancel flow
- Fix MCP server async message handling: track pending promises and
  wait for completion before process exit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 15:12:40 +08:00
你的姓名
4fbf567874 fix(plugins): address PR review findings for image-gen plugin
HIGH fixes:
- Complete SSRF protection: add IPv6 private (fc00::, fe80::),
  IPv4-mapped IPv6 (::ffff:10.x), and 0.0.0.0 to blocklist
- Validate provider baseUrl against private IP ranges at load time
- Extract shared validateUrlSafety() for reuse

MEDIUM fixes:
- Skip unchanged masked sensitive fields on save (prevent '********'
  from overwriting real API keys)
- Filter POST /api/plugins/options to only schema-declared keys
- Whitelist img src to http/https/data protocols only
- Improve model capabilities matching: exact → prefix → contains
- Cache providers at startup instead of per-tool-call

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 14:47:11 +08:00
你的姓名
d290e15177 fix(plugins): fix IPv6 SSRF bypass in image-gen plugin
Strip brackets from hostname returned by new URL() for IPv6 literals
like [::1]. Previously the check compared against '::1' (unbracketed)
but new URL() returns '[::1]' (bracketed), allowing the SSRF block
to be bypassed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 14:06:26 +08:00
你的姓名
da1137e468 feat(plugins): add model capabilities database to image-gen
Agent can now query provider capabilities via list_providers to know:
- Supported image sizes per model
- Whether the model supports image editing
- Whether transparent background is supported
- Max number of images per request (n)
- Response format (url vs b64_json)

Built-in database covers: Agnes image, GPT-image-2, DALL-E 2/3,
Gemini image, Flux, Stable Diffusion. Unknown models get pattern-based
defaults or "unknown" with full compatibility fallback.

generate_image now validates size against capabilities and warns on
mismatch. edit_image checks if any provider supports editing before
attempting.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 13:16:05 +08:00
你的姓名
4c128e0764 fix(plugins): address code review findings for image-gen plugin
HIGH fixes:
- SSRF protection: block private/link-local IPs and file:// URLs
  in edit_image image_url parameter
- Mask sensitive values in GET /api/plugins/options response

MEDIUM fixes:
- Clamp n parameter to 1-10 to prevent API bill exhaustion
- Validate prompt is non-empty string before API call
- Return empty array when no providers configured (clear error)
- Add 1MB buffer limit for JSON-RPC line accumulation
- Fix PluginConfigModal useEffect re-fetch loop on parent re-render

LOW fixes:
- Remove unused requestId variable

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 13:00:44 +08:00
你的姓名
58dd7ac816 feat(plugins): add image-gen MCP plugin with multi-provider fallback
Add image generation plugin that supports OpenAI-compatible APIs (Agnes,
GPT-image-2, Gemini image, nano-banana, DALL-E, Flux, etc.) with
automatic provider fallback and parameter compatibility retry.

New plugin:
- plugins/image-gen/ — MCP server (zero-dependency ESM, stdio JSON-RPC)
- 4 tools: generate_image, edit_image, list_providers, list_models
- Up to 3 configurable provider slots with fill-in-the-blank UI
- Each provider: full params → minimal params retry (spriteflow pattern)

Desktop UI enhancements:
- PluginConfigModal for visual userConfig configuration
- Configure button in PluginDetail when plugin has userConfig
- GET/POST /api/plugins/options API endpoints
- Sensitive fields use password input + secure storage

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 12:56:34 +08:00