From e333a808fe392dd091579f6fa8a98ddc58114f07 Mon Sep 17 00:00:00 2001 From: Linghong Date: Mon, 10 Aug 2026 08:08:24 +0000 Subject: [PATCH] =?UTF-8?q?=E6=BE=84=E6=B8=85External=E5=83=8F=E7=B4=A0?= =?UTF-8?q?=E8=A7=84=E6=95=B4=E5=B0=BA=E5=AF=B8=E5=A5=91=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 明确 pixelArt 成功产物使用逻辑分辨率及最终实际尺寸。 限定 dimension-restore-fallback 仅描述进入 pixelArt 前的交付尺寸归一结果。 同步 External API Skill、OpenAPI 与接入文档的尺寸说明。 --- .../genarrative-external-editor-api/SKILL.md | 1 + .../references/requests-and-outputs.md | 10 +++++--- .../genarrative-external-v1.openapi.json | 24 +++++++++++-------- ...构】外部OpenAPI与APIKey接入方案-2026-06-19.md | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.codex/skills/genarrative-external-editor-api/SKILL.md b/.codex/skills/genarrative-external-editor-api/SKILL.md index 350dca833..44eda9820 100644 --- a/.codex/skills/genarrative-external-editor-api/SKILL.md +++ b/.codex/skills/genarrative-external-editor-api/SKILL.md @@ -32,6 +32,7 @@ Prefer `scripts/genarrative_external_api.py` for runnable REST calls. It uses on - Use stable references such as `objectKey`, project resource ID, or asset ID in generation requests. Use `/assets/read-url` only for temporary preview/download access. - Preserve both warning channels after completion. A general `warning` can coexist with `sliceWarning`; do not discard either. - Do not invent missing derivatives. A source-preserved warning means the main source remains usable but requested post-processing failed. A slice warning means the complete transparent sheet is usable but individual slices are absent. +- For successful `style="pixelArt"`, treat completed-result and nested resource/asset dimensions as the final logical-grid PNG dimensions. They may differ from `size`, `imageSize`, the provider image, and `canvasCompletion.placeholder`; do not rescale or reject the artifact to match those inputs. - Keep generated artifacts in the canvas and asset library together. Character animation accepts `assetFolderId` and `assetLabel`; its completed result directly returns the final `assetKind="character-animation"` resource and asset with formal sequence fields. Do not create a duplicate first-frame record. ## Documentation Navigation diff --git a/.codex/skills/genarrative-external-editor-api/references/requests-and-outputs.md b/.codex/skills/genarrative-external-editor-api/references/requests-and-outputs.md index 03c69a94f..f855a94fa 100644 --- a/.codex/skills/genarrative-external-editor-api/references/requests-and-outputs.md +++ b/.codex/skills/genarrative-external-editor-api/references/requests-and-outputs.md @@ -96,7 +96,7 @@ A minimal `canvasCompletion` is: } ``` -`dialogId` is optional. Do not reconstruct canvas state from completion results. Reload the project and asset library when complete authoritative snapshots are needed. +`dialogId` is optional. The placeholder supplies canvas placement and completion coordinates; it is not a final media pixel-size constraint. For successful pixel-art snapping, the result layer uses the final logical-grid PNG dimensions even when they differ from the placeholder. Do not reconstruct canvas state from completion results. Reload the project and asset library when complete authoritative snapshots are needed. Character animation accepts `assetFolderId` and `assetLabel` and persists the final transparent sequence directly. Its completed compact result includes the authoritative `assetKind="character-animation"` resource and asset with `imageSequenceFrames` and `imageSequenceDurationMs`. Use those records directly and never synthesize a duplicate asset from the first frame. @@ -145,7 +145,7 @@ Carry the current art spec in `generationInputs.artSpec` and reflect important c The top-level `style` field is not the art spec's visual-style prose. It appends a short server-side clause to the prompt sent to the provider and enables deterministic post-processing: - Omitted, `null`, empty string, or `"none"`: no clause is appended and no post-processing runs, without warning. -- `"pixelArt"`: append one short pixel-art line to the end of the prompt sent to the provider, and enable pixel-art snapping, for ordinary image generation, `kind: "character"`, and icon spritesheet generation. The line is appended, not substituted — the rest of your prompt is unchanged. For the exact per-kind wording, read the `style` field description in the OpenAPI document; it is the contract, and this guide deliberately does not copy it. +- `"pixelArt"`: append one short pixel-art line to the end of the prompt sent to the provider, and enable pixel-art snapping, for ordinary image generation, `kind: "character"`, and icon spritesheet generation. On successful snapping, each detected grid cell becomes one output pixel and the logical-grid PNG is persisted directly; it is not resized back to `size`, `imageSize`, the provider image, or `canvasCompletion.placeholder`. The line is appended, not substituted — the rest of your prompt is unchanged. For the exact per-kind wording, read the `style` field description in the OpenAPI document; it is the contract, and this guide deliberately does not copy it. - Unknown strings, or `"pixelArt"` on unsupported kinds such as `spec`, `quick-edit`, `ui-design`, or `publication-material`: continue without style processing and return `warning.code: "unsupported-image-style"`. - Non-string JSON values: malformed request, HTTP `400`. @@ -196,7 +196,7 @@ Do not guess dimensions or pass a temporary signed read URL. See `authentication The completed `result` may contain stable artifact fields such as: -- `objectKey`, media type, dimensions, or task ID. +- `objectKey`, media type, dimensions, or task ID. For successful `pixelArt`, image `width`/`height`, icon `spritesheetWidth`/`spritesheetHeight`, and nested resource/asset dimensions are the actual final logical-grid PNG dimensions rather than requested, provider, or placeholder dimensions. - Sound-effect `durationSeconds` is the probed MP3 duration and `loop` is the frozen request boolean; neither is inferred from Prompt text. - `resource`, `resourceId`, or equivalent canvas reference. - `asset`, `assetId`, or equivalent library reference. @@ -209,6 +209,10 @@ It deliberately excludes a complete project/canvas/library snapshot, Data URL, B Interpret warnings only after the query reaches `status=completed`. The query-level `warning` is display-ready text. Compact `result.warning` and `result.sliceWarning` preserve structured artifact semantics. +### Delivery-size normalization result before pixel-art snapping + +`result.warning.code: "dimension-restore-fallback"` records only the delivery-size normalization result established before any subsequent `pixelArt` snapping: the provider image could not be safely normalized, so its dimensions were preserved at that processing boundary. It does not describe or constrain the dimensions after `pixelArt`; if snapping succeeds, use the completed result's actual logical-grid dimensions as authoritative. + ### Source-preserved post-processing failure When `result.warning.code` is `postprocess-failed-source-preserved`: diff --git a/docs/openapi/genarrative-external-v1.openapi.json b/docs/openapi/genarrative-external-v1.openapi.json index e1dad4a14..3481dc682 100644 --- a/docs/openapi/genarrative-external-v1.openapi.json +++ b/docs/openapi/genarrative-external-v1.openapi.json @@ -3273,7 +3273,7 @@ "none", "pixelArt" ], - "description": "可选生成风格,当前识别 none 与 pixelArt。省略、null、空字符串或 none 按无风格处理,提交给 provider 的提示词与未带该字段时逐字一致;pixelArt 仅支持普通图片(kind 省略)和 character,会在提示词末尾追加一行像素风约束(普通图片为「画面为像素风格」,character 为「角色主体为像素风格」)并在回图后执行像素规整。未知字符串或不支持该风格的 kind 按 none 继续生成并返回 unsupported-image-style 告警;非字符串值返回 400。" + "description": "可选生成风格,当前识别 none 与 pixelArt。省略、null、空字符串或 none 按无风格处理,提交给 provider 的提示词与未带该字段时逐字一致;pixelArt 仅支持普通图片(kind 省略)和 character,会在提示词末尾追加一行像素风约束(普通图片为「画面为像素风格」,character 为「角色主体为像素风格」)并在回图后执行像素规整。规整成功时直接持久化一格一像素的逻辑分辨率 PNG,不恢复到 size、imageSize、provider 回图或 canvasCompletion.placeholder 的尺寸;width/height 及关联 resource/asset 尺寸均为最终 PNG 的实际值。未知字符串或不支持该风格的 kind 按 none 继续生成并返回 unsupported-image-style 告警;非字符串值返回 400。" }, "size": { "type": "string", @@ -3385,7 +3385,7 @@ "type": "null" } ], - "description": "带项目上下文生成时,服务端据此直接写入画布完成态并返回最新项目快照。" + "description": "带项目上下文生成时,服务端据此直接写入画布完成态并返回最新项目快照。placeholder 只参与占位与完成落点,不约束最终媒体像素尺寸;pixelArt 规整成功时结果图层使用最终逻辑分辨率 PNG 的实际尺寸。" } }, "additionalProperties": false @@ -3578,11 +3578,13 @@ }, "width": { "type": "integer", - "minimum": 1 + "minimum": 1, + "description": "最终持久化 PNG 的实际像素宽度;pixelArt 规整成功时为逻辑网格宽度,不保证等于 size、imageSize、provider 回图或画布 placeholder 宽度。" }, "height": { "type": "integer", - "minimum": 1 + "minimum": 1, + "description": "最终持久化 PNG 的实际像素高度;pixelArt 规整成功时为逻辑网格高度,不保证等于 size、imageSize、provider 回图或画布 placeholder 高度。" }, "sourceType": { "type": "string", @@ -3698,7 +3700,7 @@ "none", "pixelArt" ], - "description": "可选生成风格,当前识别 none 与 pixelArt。省略、null、空字符串或 none 按无风格处理,提交给 provider 的提示词与未带该字段时逐字一致;pixelArt 会在提示词末尾追加一行「每个图标素材均为像素风格」并启用图标图集像素规整。未知字符串按 none 继续生成并返回 unsupported-image-style 告警;非字符串值返回 400。" + "description": "可选生成风格,当前识别 none 与 pixelArt。省略、null、空字符串或 none 按无风格处理,提交给 provider 的提示词与未带该字段时逐字一致;pixelArt 会在提示词末尾追加一行「每个图标素材均为像素风格」并启用图标图集像素规整。规整成功时直接持久化一格一像素的逻辑分辨率透明 PNG,不恢复到 imageSize、provider 回图或 canvasCompletion.placeholder 的尺寸;spritesheetWidth/spritesheetHeight 及关联 resource/asset 尺寸均为最终 PNG 的实际值。未知字符串按 none 继续生成并返回 unsupported-image-style 告警;非字符串值返回 400。" }, "model": { "type": "string", @@ -3756,7 +3758,7 @@ "type": "null" } ], - "description": "带项目上下文生成时,服务端据此直接写入画布完成态并返回最新项目快照。" + "description": "带项目上下文生成时,服务端据此直接写入画布完成态并返回最新项目快照。placeholder 只参与占位与完成落点,不约束最终媒体像素尺寸;pixelArt 规整成功时结果图层使用最终逻辑分辨率 PNG 的实际尺寸。" } }, "additionalProperties": false @@ -3919,7 +3921,7 @@ "unsupported-image-style", "multiple-generation-warnings" ], - "description": "生成成功但后处理发生非阻断降级时的稳定原因码。" + "description": "生成成功但后处理发生非阻断降级时的稳定原因码。dimension-restore-fallback 只描述进入可选 pixelArt 处理前的交付尺寸归一结果:无法安全归一时,在该处理边界保留 provider 回图尺寸;它不描述或约束 pixelArt 成功后的最终尺寸,最终产物尺寸仍以逻辑分辨率 PNG 为准。" }, "reason": { "type": "string", @@ -3945,11 +3947,13 @@ }, "spritesheetWidth": { "type": "integer", - "minimum": 1 + "minimum": 1, + "description": "最终持久化 spritesheet PNG 的实际像素宽度;pixelArt 规整成功时为逻辑网格宽度,不保证等于 imageSize、provider 回图或画布 placeholder 宽度。" }, "spritesheetHeight": { "type": "integer", - "minimum": 1 + "minimum": 1, + "description": "最终持久化 spritesheet PNG 的实际像素高度;pixelArt 规整成功时为逻辑网格高度,不保证等于 imageSize、provider 回图或画布 placeholder 高度。" }, "iconImageSrcs": { "type": "array", @@ -4948,7 +4952,7 @@ } }, "additionalProperties": true, - "description": "其它生成类型或历史结果的兼容 compact result。背景音乐(audioKind=background-music)与不带 audioKind 的图片、视频、图标序列帧、角色动作和 UI 拆解结果都落在这里。该 fallback 明确排除 audioKind=sound-effect,避免吞掉 SFX 专用分支。" + "description": "其它生成类型或历史结果的兼容 compact result。背景音乐(audioKind=background-music)与不带 audioKind 的图片、视频、图标序列帧、角色动作和 UI 拆解结果都落在这里。pixelArt 图片的 width/height、图标结果的 spritesheetWidth/spritesheetHeight 及关联 resource/asset 尺寸均表示最终逻辑分辨率 PNG 的实际值,不保证等于请求档位、provider 回图或画布 placeholder。该 fallback 明确排除 audioKind=sound-effect,避免吞掉 SFX 专用分支。" }, "ExternalEditorGenerationCompletedResult": { "oneOf": [ diff --git a/docs/【后端架构】外部OpenAPI与APIKey接入方案-2026-06-19.md b/docs/【后端架构】外部OpenAPI与APIKey接入方案-2026-06-19.md index 0fc594ecc..a1a1ac538 100644 --- a/docs/【后端架构】外部OpenAPI与APIKey接入方案-2026-06-19.md +++ b/docs/【后端架构】外部OpenAPI与APIKey接入方案-2026-06-19.md @@ -52,7 +52,7 @@ v1 只开放以下能力: 图片生成、图标 spritesheet 和 UI 素材提取的 completed compact `result` 可携带可选结构化 `warning { code, reason }`;任务查询顶层 `warning` 是可直接展示的有界摘要。外部 OpenAPI 当前公开四个稳定 `code`: - `postprocess-failed-source-preserved`:生成成功,但透明处理、像素规整等后处理未完成,接口保留仍可使用的原图或进入该步骤前的结果。 -- `dimension-restore-fallback`:provider 回图无法安全收口到目标交付尺寸,接口保留实际回图尺寸。 +- `dimension-restore-fallback`:该告警只描述进入可选 `pixelArt` 处理前的交付尺寸归一结果;无法安全归一时,在该处理边界保留 provider 回图尺寸。它不描述或约束 `pixelArt` 成功后的最终尺寸;若随后像素规整成功,最终产物仍是逻辑分辨率 PNG,不能据此推断最终宽高等于 provider 回图。 - `unsupported-image-style`:请求的图片后处理风格未知或不适用于当前生成类型,接口按无风格继续生成。 - `multiple-generation-warnings`:同一成功响应合并了不同 `code` 的多条非阻断告警,具体原因按顺序拼接在 `reason`。