minimax 0.2.4: generate_image takes the catalog's area, n, output_format and reference_images (#955)

hokaii6990-boop (Windows 11, magpie 0.1.3654, plugin 0.2.3, CN site):
`magpie tool minimax_generate_image --requests '{"prompt":"...","area":"2K"}'`
answered "bad arguments: arguments.requests[0].area is not an accepted
argument", while the account's catalog schema has area, and
minimax_call_tool with the same arguments generated the image.

Our first reply said execute checks against the catalog's
input_schema_json. It does, but createConnectorTools wraps every tool's
execute in checked(t.args, args) first, and a named Matrix tool's args
are the bundled matrix-tools.json copy (2026-11-03: resolution,
input_urls, a six-value aspect_ratio). So that check refused the call
before the catalog was ever read.

- A named Matrix tool's call is now checked up front only for its two
  routing fields (site, account). Its own arguments are checked once, in
  execute, against the catalog entry's input_schema_json, and against the
  bundled copy only when the catalog gives none. A parameter MiniMax adds
  later passes without a plugin release. A priced call still never goes
  out with bad arguments; the catalog read now comes first.
  list_tools, tool_schema and call_tool keep their up-front check.
- The refusal names whose schema it was: "(checked against the account's
  catalog schema for connector__matrix__generate_image)", or the bundled
  one when the catalog gave none.
- matrix-tools.json's generate_image input_schema is the reporter's
  pasted `minimax_tool_schema --json` output, byte for byte after JSON
  parsing (kept as testdata/generate-image-schema-955.json). It is what
  agents are shown. Its description says reference_images, not
  input_urls. The other 15 tools' copies are unchanged; no fresher
  bytes for them.
- README says calls are checked against the live catalog.

Run:
- wsl-run (magpie-desktop, Bun 1.4.2), HOME=$(mktemp -d):
  bun test packages/minimax 148 pass 0 fail; bun scripts/check.mjs exit 0.
- win-run (xiaomi-gpu Windows 11, Bun 1.4.2), HOME and USERPROFILE a
  fresh temp dir: bun test packages/minimax 148 pass 0 fail;
  bun scripts/check.mjs exit 0.
- Broken by hand (wsl-run, connector-tools.test.mjs):
  - 0.2.3's code and bundle: 5 red, among them the area/n/output_format/
    reference_images call.
  - New code with 0.2.3's bundle: only the bundled-copy test red; the
    area call passes, held to the catalog.
  - New bundle with the old up-front check: 3 red (the catalog's
    refusal message, the no-schema fallback message, and a refusal that
    now reads the catalog first).

Not tried: no MiniMax Code account here, so no real generation; the
schema is the reporter's, from one CN-site account. The global site's
catalog was not seen. Codex desktop refusing area from the advertised
schema (the reporter's second path) was not reproduced; the refreshed
copy covers it for these fields. The get_asset_url /visible/ watermark
note is split out to #974.

Reported-by: hokaii6990-boop
Refs #955
This commit is contained in:
yetone
2026-11-11 14:21:17 +08:00
parent 9204c079ae
commit bf302fab7d
6 changed files with 147 additions and 14 deletions
+5
View File
@@ -85,6 +85,11 @@ On the combined MCP server these are named `minimax_generate_image`,
`minimax_submit_video_generation`, and so on. In the Library's routed server,
the separator is `minimax__generate_image`.
Each named tool shows a schema bundled with the plugin, so loading it asks
no network. A call is checked against the schema in the account's live
catalog, read on each call, so a parameter MiniMax added since the bundled
copy still goes through. `tool_schema` prints the live schema.
Webpage reading is available through Magpie's search MCP server, whose
`web_fetch` protects loopback and private network addresses.
+27 -8
View File
@@ -7,9 +7,12 @@
//
// The bundled matrix-tools.json is a copy of the catalog's real schemas,
// taken from mcode-tools (connector tool <name>) on 2026-11-03, so loading
// this plugin never asks the network. The live catalog still routes every
// call (provider/provider_tool_name/runtime_tool_name), and is re-read on
// each operation: another signed-in account may connect different tools.
// this plugin never asks the network. It is what agents are shown, never
// what a call is held to: the live catalog, re-read on each operation,
// routes every call (provider/provider_tool_name/runtime_tool_name) and its
// input_schema_json checks the arguments. The copy goes stale as MiniMax
// adds parameters (#955: area, n, output_format, reference_images), and
// another signed-in account may connect different tools.
import { readFileSync } from "node:fs"
const LIST_PATH = "/minimax-cloud/api/v1/connectors/connected-tools/list"
@@ -106,11 +109,13 @@ const same = (a, b) => a === b || (obj(a) && obj(b) && JSON.stringify(a) === JSO
// checked(schema, args) validates a tool call's own arguments (site and
// account already stripped) against its input_schema; a failure means the
// call never left, which for a priced generation is the point.
function checked(schema, args) {
// against, when given, names the schema in the error, so a refusal says
// whose rule it was.
function checked(schema, args, against) {
if (!obj(args)) throw new Error("tool arguments must be an object")
const errs = []
check(schema, args, "arguments", errs)
if (errs.length) throw new Error("bad arguments: " + errs.join("; "))
if (errs.length) throw new Error("bad arguments: " + errs.join("; ") + (against ? " (checked against " + against + ")" : ""))
return args
}
@@ -213,9 +218,15 @@ function routing(args, callCtx) {
return { site, account: a.account, args: rest, signal: callCtx?.abort }
}
// routingOnly is what a direct tool's call is checked against before its
// catalog is read: the two routing fields, and nothing about the tool's
// own arguments, which the catalog's schema judges in execute.
const routingOnly = { type: "object", properties: { site: siteArg, account: accountArg } }
const DIRECT = new WeakSet()
function directTool(request, name, def) {
const inner = def.input_schema ?? { type: "object", properties: {} }
return {
const t = {
description: def.description,
args: {
...inner,
@@ -228,10 +239,14 @@ function directTool(request, name, def) {
const r = routing(args, callCtx)
const cat = await catalog(request, r.site, r.signal, r.account)
const entry = find(cat, MATRIX + name)
const checkedArgs = checked(entry.input_schema_json ? parseSchema(entry.input_schema_json) : inner, r.args)
const checkedArgs = entry.input_schema_json
? checked(parseSchema(entry.input_schema_json), r.args, "the account's catalog schema for " + entry.runtime_tool_name)
: checked(inner, r.args, "the bundled schema for " + entry.runtime_tool_name + " (the catalog gave none)")
return invoke(request, r.site, entry, checkedArgs, r.signal, LONG.has(name) ? GEN_MS : CALL_MS, r.account)
},
}
DIRECT.add(t)
return t
}
function parseSchema(json) {
try {
@@ -329,10 +344,14 @@ export function createConnectorTools(request) {
},
}
// A direct tool's advertised args are the bundled copy, which can be
// behind the catalog; holding a call to them refused area on a catalog
// that accepts it (#955). Its own arguments are checked in execute.
for (const t of Object.values(tool)) {
const execute = t.execute
const pre = DIRECT.has(t) ? routingOnly : t.args
t.execute = async (args, ctx) => {
checked(t.args, args)
checked(pre, args)
ctx?.abort?.throwIfAborted()
return execute(args, ctx)
}
+48 -2
View File
@@ -5,6 +5,7 @@
// they could be sent, abort propagation, and the matrix-only call guard.
import "./nonet.mjs"
import { expect, test } from "bun:test"
import { readFileSync } from "node:fs"
import { createConnectorTools } from "./connector-tools.mjs"
const LIST = "/minimax-cloud/api/v1/connectors/connected-tools/list"
@@ -159,7 +160,7 @@ test("a broken result_json is an error, not a silent null", async () => {
).rejects.toThrow(/result_json is not valid JSON/)
})
test("bad arguments are refused before any request leaves", async () => {
test("bad arguments are refused before the call leaves", async () => {
const t = transport({
[LIST]: catalog([entry("generate_image", {
input_schema_json: JSON.stringify({ type: "object", properties: { requests: { type: "array" } }, required: ["requests"], additionalProperties: false }),
@@ -168,7 +169,52 @@ test("bad arguments are refused before any request leaves", async () => {
const { tool } = createConnectorTools(t.request)
// 'requests' is required by the catalog schema
await expect(tool.generate_image.execute({ prompt: "x" }, {})).rejects.toThrow(/bad arguments/)
expect(t.sent).toHaveLength(0) // bundled schema catches it before reading the catalog
// the catalog is read to judge them; the priced call never goes out
expect(t.sent.map((r) => r.path)).toEqual([LIST])
})
// #955: the catalog's generate_image schema as hokaii6990-boop's
// `magpie tool minimax_tool_schema --tool_name connector__matrix__generate_image --json`
// printed it on a CN-site account on 2026-11-11.
const liveImage = readFileSync(new URL("./testdata/generate-image-schema-955.json", import.meta.url), "utf8")
test("generate_image takes the catalog's area, n, output_format and reference_images (#955)", async () => {
const t = transport({
[LIST]: catalog([entry("generate_image", { input_schema_json: liveImage })]),
[CALL]: { result_json: JSON.stringify({ success_items: [{ node_id: "n1", file_name: "image_1.png" }] }) },
})
const { tool } = createConnectorTools(t.request)
const request = { prompt: "a fox, as 图1", aspect_ratio: "21:9", area: "2K", n: 2, output_format: "png", reference_images: [{ url: "https://upload.example/a.png", mime_type: "image/png" }] }
await tool.generate_image.execute({ requests: [request] }, {})
const calls = t.sent.filter((r) => r.path === CALL)
expect(calls).toHaveLength(1)
expect(JSON.parse(calls[0].body.arguments_json)).toEqual({ requests: [request] })
})
test("generate_image is refused by the catalog's schema, and says so (#955)", async () => {
const t = transport({ [LIST]: catalog([entry("generate_image", { input_schema_json: liveImage })]) })
const { tool } = createConnectorTools(t.request)
// resolution is the old name; the catalog took it away
await expect(tool.generate_image.execute({ requests: [{ prompt: "x", resolution: "2K" }] }, {}))
.rejects.toThrow("arguments.requests[0].resolution is not an accepted argument (checked against the account's catalog schema for connector__matrix__generate_image)")
expect(t.sent.filter((r) => r.path === CALL)).toHaveLength(0)
})
test("a tool the catalog gives no schema is held to the bundled copy, and says so", async () => {
const t = transport({ [LIST]: catalog([entry("generate_image", { input_schema_json: "" })]) })
const { tool } = createConnectorTools(t.request)
await expect(tool.generate_image.execute({ requests: [{ prompt: "x", model: "image-01" }] }, {}))
.rejects.toThrow("(checked against the bundled schema for connector__matrix__generate_image (the catalog gave none))")
expect(t.sent.filter((r) => r.path === CALL)).toHaveLength(0)
})
test("the bundled generate_image schema is the catalog's of 2026-11-11 (#955)", () => {
const { tool } = createConnectorTools(async () => ({}))
const shown = tool.generate_image.args
expect(shown.properties.requests).toEqual(JSON.parse(liveImage).properties.requests)
expect(Object.keys(shown.properties.requests.items.properties)).not.toContain("resolution")
expect(Object.keys(shown.properties.requests.items.properties)).not.toContain("input_urls")
expect(tool.generate_image.description).not.toContain("input_urls")
})
test("video validation follows the per-model allOf rules", async () => {
+3 -3
View File
@@ -1,9 +1,9 @@
{
"_verified": "verified against mcode-tools connector tool <name> (mcode CLI, minimax-cloud /connectors) on 2026-11-03; runtime_tool_name = connector__matrix__<key>. get_asset_url is CLI-hidden in 'connector tools' output but callable through the same tools/call gateway.",
"_verified": "verified against mcode-tools connector tool <name> (mcode CLI, minimax-cloud /connectors) on 2026-11-03 (generate_image refreshed on 2026-11-11 from a CN-site account's tool_schema output, plugins#955); runtime_tool_name = connector__matrix__<key>. get_asset_url is CLI-hidden in 'connector tools' output but callable through the same tools/call gateway.",
"tools": {
"generate_image": {
"description": "Text-to-image (or image-to-image via input_urls). Wrap each request in a 'requests' array, NOT as a flat prompt. Successful items return success_items[].node_id and success_items[].file_name; file_name is the final base filename including its actual extension. To use the generated image, call get_asset_url with this node_id to obtain a short-lived file URL. Optional requests[].output_file sets the downloaded base filename; directory components are ignored. Do not construct an OSS/CDN URL from node_id. Do NOT pass input_files/output_path.",
"input_schema": {"additionalProperties":false,"properties":{"requests":{"items":{"additionalProperties":false,"properties":{"aspect_ratio":{"enum":["1:1","16:9","9:16","4:3","3:4","21:9"],"type":"string"},"input_urls":{"items":{"type":"string"},"type":"array"},"output_file":{"description":"Optional downloaded base filename. Directory components are ignored.","minLength":1,"type":"string"},"prompt":{"type":"string"},"resolution":{"enum":["1K","2K","4K"],"type":"string"}},"required":["prompt"],"type":"object"},"minItems":1,"type":"array"}},"required":["requests"],"type":"object"},
"description": "Text-to-image, or editing and combining images via reference_images. Wrap each request in a 'requests' array, NOT as a flat prompt. Successful items return success_items[].node_id and success_items[].file_name; file_name is the final base filename including its actual extension. To use the generated image, call get_asset_url with this node_id to obtain a short-lived file URL. Optional requests[].output_file sets the downloaded base filename; directory components are ignored. Do not construct an OSS/CDN URL from node_id. Do NOT pass input_files/output_path.",
"input_schema": {"additionalProperties":false,"properties":{"requests":{"items":{"additionalProperties":false,"properties":{"area":{"description":"Output size tier used with aspect_ratio; defaults to 4K.","enum":["1K","2K","4K"],"type":"string"},"aspect_ratio":{"description":"\"auto\" or \"X:Y\" with integers 1-300 between 1:3 and 3:1, for example 16:9. Use with optional area.","type":"string"},"n":{"description":"Number of images for this request; defaults to 1. Each delivered image is charged once.","maximum":10,"minimum":1,"type":"integer"},"output_file":{"description":"Optional downloaded base filename. Directory components are ignored.","minLength":1,"type":"string"},"output_format":{"description":"Defaults to jpeg. jpg is the same as jpeg.","enum":["png","jpeg","jpg"],"type":"string"},"prompt":{"description":"Image description. With reference_images, refer to them as 图1, 图2, ... in the order given.","minLength":1,"type":"string"},"reference_images":{"description":"Optional 1-16 reference images to edit or combine. JPG, JPEG, PNG, WEBP, HEIC or HEIF; each at most 64 MB, 128-8192 px per side, aspect ratio at most 4:1.","items":{"additionalProperties":false,"properties":{"mime_type":{"enum":["image/jpeg","image/png","image/webp","image/heic","image/heif"],"type":"string"},"url":{"description":"temp_url from a completed upload_temp_url upload (upload local files first), or an existing upload URL from this environment.","type":"string"}},"required":["url"],"type":"object"},"maxItems":16,"type":"array"}},"required":["prompt"],"type":"object"},"maxItems":10,"minItems":1,"type":"array"}},"required":["requests"],"type":"object"},
"output_schema": null
},
"submit_video_generation": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-minimax-auth",
"version": "0.2.3",
"version": "0.2.4",
"description": "OpenCode provider plugins for MiniMax Code accounts: their credits and M Plan, China (minimax-code) and international (minimax-code-global), with MiniMax Code's own device sign-in",
"type": "module",
"main": "./opencode.mjs",
@@ -0,0 +1,63 @@
{
"additionalProperties": false,
"properties": {
"requests": {
"items": {
"additionalProperties": false,
"properties": {
"area": {
"description": "Output size tier used with aspect_ratio; defaults to 4K.",
"enum": ["1K", "2K", "4K"],
"type": "string"
},
"aspect_ratio": {
"description": "\"auto\" or \"X:Y\" with integers 1-300 between 1:3 and 3:1, for example 16:9. Use with optional area.",
"type": "string"
},
"n": {
"description": "Number of images for this request; defaults to 1. Each delivered image is charged once.",
"maximum": 10,
"minimum": 1,
"type": "integer"
},
"output_file": {
"description": "Optional downloaded base filename. Directory components are ignored.",
"minLength": 1,
"type": "string"
},
"output_format": {
"description": "Defaults to jpeg. jpg is the same as jpeg.",
"enum": ["png", "jpeg", "jpg"],
"type": "string"
},
"prompt": {
"description": "Image description. With reference_images, refer to them as 图1, 图2, ... in the order given.",
"minLength": 1,
"type": "string"
},
"reference_images": {
"description": "Optional 1-16 reference images to edit or combine. JPG, JPEG, PNG, WEBP, HEIC or HEIF; each at most 64 MB, 128-8192 px per side, aspect ratio at most 4:1.",
"items": {
"additionalProperties": false,
"properties": {
"mime_type": { "enum": ["image/jpeg", "image/png", "image/webp", "image/heic", "image/heif"], "type": "string" },
"url": { "description": "temp_url from a completed upload_temp_url upload (upload local files first), or an existing upload URL from this environment.", "type": "string" }
},
"required": ["url"],
"type": "object"
},
"maxItems": 16,
"type": "array"
}
},
"required": ["prompt"],
"type": "object"
},
"maxItems": 10,
"minItems": 1,
"type": "array"
}
},
"required": ["requests"],
"type": "object"
}