omp-fabric 1.26.14 → 1.26.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/chunks/{chunk-HCUDF34P.js → chunk-EZWJ5GBW.js} +14 -3
- package/dist/chunks/{chunk-HCUDF34P.js.map → chunk-EZWJ5GBW.js.map} +2 -2
- package/dist/fabric-runtime-state.js +123 -17
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/providers/image-provider.d.ts +1 -0
- package/dist/providers/image-provider.d.ts.map +1 -1
- package/dist/runtime/core-override-guest-types.js +1 -1
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/docs/image.md +24 -3
- package/package.json +1 -1
|
@@ -8504,6 +8504,43 @@ import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
|
8504
8504
|
import os from "node:os";
|
|
8505
8505
|
import path10 from "node:path";
|
|
8506
8506
|
var IMAGE_MODEL_API = /image|imagen|dall-e|flux|stable-diffusion|sdxl|seedream|kolors|wanx|cogview|recraft|ideogram|midjourney|horde|banana/i;
|
|
8507
|
+
var MUSE_IMAGE = /(^|\/)muse-image/i;
|
|
8508
|
+
var MUSE_MAX_COUNT = 10;
|
|
8509
|
+
var DEFAULT_MAX_COUNT = 4;
|
|
8510
|
+
var MUSE_OUTPUT_FORMATS = ["png", "jpeg", "webp"];
|
|
8511
|
+
var MUSE_REASONING_STRENGTHS = ["low", "high"];
|
|
8512
|
+
var MUSE_TOOL_SWITCHES = {
|
|
8513
|
+
imageSearch: "enable_image_search",
|
|
8514
|
+
webSearch: "enable_web_search",
|
|
8515
|
+
shell: "enable_shell"
|
|
8516
|
+
};
|
|
8517
|
+
var sizeProperty = {
|
|
8518
|
+
type: "string",
|
|
8519
|
+
pattern: "^[1-9][0-9]*x[1-9][0-9]*$",
|
|
8520
|
+
description: "Pixel size WxH for gateways that accept an images-API size field. gpt-image takes 1024x1024, 1536x1024 or 1024x1536; Muse (muse-image-*) keeps only the ratio and renders at its own resolution."
|
|
8521
|
+
};
|
|
8522
|
+
var museProperties = {
|
|
8523
|
+
outputFormat: {
|
|
8524
|
+
type: "string",
|
|
8525
|
+
enum: [...MUSE_OUTPUT_FORMATS],
|
|
8526
|
+
description: "Muse only: encoding of the returned image. Muse defaults to webp."
|
|
8527
|
+
},
|
|
8528
|
+
reasoningStrength: {
|
|
8529
|
+
type: "string",
|
|
8530
|
+
enum: [...MUSE_REASONING_STRENGTHS],
|
|
8531
|
+
description: "Muse only: low returns after one pass; high, the Muse default, refines over several passes."
|
|
8532
|
+
},
|
|
8533
|
+
toolEnablement: {
|
|
8534
|
+
type: "object",
|
|
8535
|
+
additionalProperties: false,
|
|
8536
|
+
properties: {
|
|
8537
|
+
imageSearch: { type: "boolean", description: "Muse image search for visual references." },
|
|
8538
|
+
webSearch: { type: "boolean", description: "Muse web search for current facts." },
|
|
8539
|
+
shell: { type: "boolean", description: "Muse code execution for charts and layouts." }
|
|
8540
|
+
},
|
|
8541
|
+
description: "Muse only: set a switch to false to turn that built-in tool off. Omitted switches stay on."
|
|
8542
|
+
}
|
|
8543
|
+
};
|
|
8507
8544
|
var generateSchema = {
|
|
8508
8545
|
type: "object",
|
|
8509
8546
|
additionalProperties: false,
|
|
@@ -8516,15 +8553,15 @@ var generateSchema = {
|
|
|
8516
8553
|
},
|
|
8517
8554
|
aspectRatio: {
|
|
8518
8555
|
type: "string",
|
|
8519
|
-
description: "Aspect ratio
|
|
8556
|
+
description: "Aspect ratio such as 1:1, 16:9, 9:16. Forwarded as aspect_ratio or imageConfig.aspectRatio; Muse receives it as a WxH size."
|
|
8520
8557
|
},
|
|
8521
|
-
size:
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
description: "
|
|
8558
|
+
size: sizeProperty,
|
|
8559
|
+
count: {
|
|
8560
|
+
type: "number",
|
|
8561
|
+
description: "Images to request from one model: up to 10 for Muse, up to 4 elsewhere. Only the images API honours more than one."
|
|
8525
8562
|
},
|
|
8526
|
-
|
|
8527
|
-
|
|
8563
|
+
saveTo: { type: "string", description: "Absolute or cwd-relative file path for a single image." },
|
|
8564
|
+
...museProperties
|
|
8528
8565
|
}
|
|
8529
8566
|
};
|
|
8530
8567
|
var editSchema = {
|
|
@@ -8540,13 +8577,13 @@ var editSchema = {
|
|
|
8540
8577
|
items: { type: "string" }
|
|
8541
8578
|
},
|
|
8542
8579
|
model: { type: "string", description: "Optional provider/id to try first." },
|
|
8543
|
-
aspectRatio: {
|
|
8544
|
-
size: {
|
|
8580
|
+
aspectRatio: {
|
|
8545
8581
|
type: "string",
|
|
8546
|
-
|
|
8547
|
-
description: "Pixel size for gateways that accept an images-API size field."
|
|
8582
|
+
description: "Aspect ratio forwarded to the backend; Muse receives it as a WxH size."
|
|
8548
8583
|
},
|
|
8549
|
-
|
|
8584
|
+
size: sizeProperty,
|
|
8585
|
+
saveTo: { type: "string", description: "Absolute or cwd-relative file path for a single image." },
|
|
8586
|
+
...museProperties
|
|
8550
8587
|
}
|
|
8551
8588
|
};
|
|
8552
8589
|
var modelsSchema = { type: "object", additionalProperties: false, properties: {} };
|
|
@@ -8559,7 +8596,7 @@ var descriptors2 = [
|
|
|
8559
8596
|
},
|
|
8560
8597
|
{
|
|
8561
8598
|
name: "edit",
|
|
8562
|
-
description: "Edit existing images with a prompt. Tries each configured model in priority order and returns the first success or { ok: false, reason, failures }. Source images travel in the shape each dialect expects: input_references or image/images for the images API, image_url parts for chat, input_image for responses, inlineData for gemini.",
|
|
8599
|
+
description: "Edit existing images with a prompt. Tries each configured model in priority order and returns the first success or { ok: false, reason, failures }. Source images travel in the shape each dialect expects: input_references or image/images for the images API, images[].image_url for Muse, image_url parts for chat, input_image for responses, inlineData for gemini.",
|
|
8563
8600
|
inputSchema: editSchema,
|
|
8564
8601
|
risk: "write"
|
|
8565
8602
|
},
|
|
@@ -8579,6 +8616,7 @@ var splitModelSelector = (selector) => {
|
|
|
8579
8616
|
var inferImageDialect = (api, modelId) => {
|
|
8580
8617
|
if (api === "openai-images" || api === "openrouter-images") return "images";
|
|
8581
8618
|
if (api === "google-generative-ai") return "gemini";
|
|
8619
|
+
if (MUSE_IMAGE.test(modelId)) return "images";
|
|
8582
8620
|
if (api === "openai-responses" || api === "openai-codex-responses") {
|
|
8583
8621
|
return IMAGE_MODEL_API.test(modelId) ? "images" : "responses";
|
|
8584
8622
|
}
|
|
@@ -8809,7 +8847,46 @@ var resolveImageSize = (aspectRatio, size) => {
|
|
|
8809
8847
|
return void 0;
|
|
8810
8848
|
}
|
|
8811
8849
|
};
|
|
8850
|
+
var MUSE_LONG_SIDE = 1024;
|
|
8851
|
+
var museSizeForRatio = (aspectRatio) => {
|
|
8852
|
+
const match = /^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(aspectRatio);
|
|
8853
|
+
if (!match) return void 0;
|
|
8854
|
+
const width = Number(match[1]);
|
|
8855
|
+
const height = Number(match[2]);
|
|
8856
|
+
if (!(width > 0 && height > 0)) return void 0;
|
|
8857
|
+
if (width >= height) return `${MUSE_LONG_SIDE}x${Math.max(1, Math.round(MUSE_LONG_SIDE * height / width))}`;
|
|
8858
|
+
return `${Math.max(1, Math.round(MUSE_LONG_SIDE * width / height))}x${MUSE_LONG_SIDE}`;
|
|
8859
|
+
};
|
|
8860
|
+
var resolveMuseSize = (aspectRatio, size) => {
|
|
8861
|
+
if (size !== void 0) return size;
|
|
8862
|
+
return aspectRatio === void 0 ? void 0 : museSizeForRatio(aspectRatio);
|
|
8863
|
+
};
|
|
8864
|
+
var SIZE_PATTERN = /^(\d+)x(\d+)$/;
|
|
8865
|
+
var ratioHonoured = (requested, width, height) => {
|
|
8866
|
+
const match = SIZE_PATTERN.exec(requested);
|
|
8867
|
+
if (!match || height === 0) return false;
|
|
8868
|
+
const wanted = Number(match[1]) / Number(match[2]);
|
|
8869
|
+
return Math.abs(width / height - wanted) <= wanted * 0.01;
|
|
8870
|
+
};
|
|
8871
|
+
var requestMuse = async (env, model, options) => {
|
|
8872
|
+
const body = {
|
|
8873
|
+
model: model.id,
|
|
8874
|
+
prompt: options.prompt,
|
|
8875
|
+
n: options.count,
|
|
8876
|
+
response_format: "b64_json"
|
|
8877
|
+
};
|
|
8878
|
+
const size = resolveMuseSize(options.aspectRatio, options.size);
|
|
8879
|
+
if (size !== void 0) body.size = size;
|
|
8880
|
+
if (options.outputFormat !== void 0) body.output_format = options.outputFormat;
|
|
8881
|
+
if (options.reasoningStrength !== void 0) body.reasoning_strength = options.reasoningStrength;
|
|
8882
|
+
if (options.toolEnablement !== void 0) body.tool_enablement = options.toolEnablement;
|
|
8883
|
+
const editing = options.inputImages.length > 0;
|
|
8884
|
+
if (editing) body.images = options.inputImages.map((image) => ({ image_url: dataUrl(image) }));
|
|
8885
|
+
const { payload } = await postJson(env, joinUrl(env.baseUrl, editing ? "/images/edits" : "/images/generations"), body);
|
|
8886
|
+
return parseImagesApiPayload(payload);
|
|
8887
|
+
};
|
|
8812
8888
|
var requestImages = async (env, model, options) => {
|
|
8889
|
+
if (model.muse) return requestMuse(env, model, options);
|
|
8813
8890
|
const openrouter = model.api === "openrouter-images";
|
|
8814
8891
|
const body = { model: model.id, prompt: options.prompt, n: options.count };
|
|
8815
8892
|
if (!model.gptImage) body.response_format = "b64_json";
|
|
@@ -8962,11 +9039,27 @@ var ignoredParams = (input) => {
|
|
|
8962
9039
|
if (input.size !== void 0) ignored.push("size");
|
|
8963
9040
|
} else if (input.dialect === "responses" && input.aspectRatio !== void 0 && resolveImageSize(input.aspectRatio, void 0) === void 0) {
|
|
8964
9041
|
ignored.push("aspectRatio");
|
|
9042
|
+
} else if (input.muse && input.size === void 0 && input.aspectRatio !== void 0 && museSizeForRatio(input.aspectRatio) === void 0) {
|
|
9043
|
+
ignored.push("aspectRatio");
|
|
8965
9044
|
}
|
|
8966
9045
|
if (input.dialect !== "images" && input.count > 1) ignored.push("count");
|
|
9046
|
+
if (!input.muse) {
|
|
9047
|
+
if (input.outputFormat !== void 0) ignored.push("outputFormat");
|
|
9048
|
+
if (input.reasoningStrength !== void 0) ignored.push("reasoningStrength");
|
|
9049
|
+
if (input.toolEnablement !== void 0) ignored.push("toolEnablement");
|
|
9050
|
+
}
|
|
8967
9051
|
if (input.saveTo !== void 0 && input.returned > 1) ignored.push("saveTo");
|
|
8968
9052
|
return ignored;
|
|
8969
9053
|
};
|
|
9054
|
+
var museToolEnablement = (value) => {
|
|
9055
|
+
if (!isRecord3(value)) return void 0;
|
|
9056
|
+
const switches = {};
|
|
9057
|
+
for (const [name, field] of Object.entries(MUSE_TOOL_SWITCHES)) {
|
|
9058
|
+
const setting = value[name];
|
|
9059
|
+
if (typeof setting === "boolean") switches[field] = setting;
|
|
9060
|
+
}
|
|
9061
|
+
return Object.keys(switches).length > 0 ? switches : void 0;
|
|
9062
|
+
};
|
|
8970
9063
|
var transient = (error) => {
|
|
8971
9064
|
const status = error?.status;
|
|
8972
9065
|
if (typeof status === "number") return status >= 500 || status === 408 || status === 409 || status === 429;
|
|
@@ -9029,7 +9122,8 @@ var ImageProvider = class {
|
|
|
9029
9122
|
baseUrl,
|
|
9030
9123
|
gptImage: GPT_IMAGE_FAMILY.test(parsed.id),
|
|
9031
9124
|
codex: api === "openai-codex-responses",
|
|
9032
|
-
xai: parsed.provider === "xai" || parsed.provider === "xai-oauth" || parsed.provider.startsWith("xai-")
|
|
9125
|
+
xai: parsed.provider === "xai" || parsed.provider === "xai-oauth" || parsed.provider.startsWith("xai-"),
|
|
9126
|
+
muse: MUSE_IMAGE.test(parsed.id)
|
|
9033
9127
|
};
|
|
9034
9128
|
}
|
|
9035
9129
|
dialectFor(model) {
|
|
@@ -9094,9 +9188,12 @@ var ImageProvider = class {
|
|
|
9094
9188
|
if (selectors.length === 0) {
|
|
9095
9189
|
return { ok: false, reason: "no image models configured (image.models is empty)" };
|
|
9096
9190
|
}
|
|
9097
|
-
const
|
|
9191
|
+
const requestedCount = typeof args.count === "number" && Number.isFinite(args.count) && args.count >= 1 ? Math.floor(args.count) : 1;
|
|
9098
9192
|
const aspectRatio = typeof args.aspectRatio === "string" ? args.aspectRatio : void 0;
|
|
9099
9193
|
const size = typeof args.size === "string" ? args.size : void 0;
|
|
9194
|
+
const outputFormat = MUSE_OUTPUT_FORMATS.includes(args.outputFormat) ? args.outputFormat : void 0;
|
|
9195
|
+
const reasoningStrength = MUSE_REASONING_STRENGTHS.includes(args.reasoningStrength) ? args.reasoningStrength : void 0;
|
|
9196
|
+
const toolEnablement = museToolEnablement(args.toolEnablement);
|
|
9100
9197
|
const saveTo = typeof args.saveTo === "string" && args.saveTo.trim().length > 0 ? args.saveTo.trim() : void 0;
|
|
9101
9198
|
const sources = action === "edit" ? Array.isArray(args.images) ? args.images.filter((entry) => typeof entry === "string") : [] : [];
|
|
9102
9199
|
if (action === "edit" && sources.length === 0) {
|
|
@@ -9122,6 +9219,8 @@ var ImageProvider = class {
|
|
|
9122
9219
|
continue;
|
|
9123
9220
|
}
|
|
9124
9221
|
const dialect = this.dialectFor(model);
|
|
9222
|
+
const muse = model.muse && dialect === "images";
|
|
9223
|
+
const count = Math.min(requestedCount, muse ? MUSE_MAX_COUNT : DEFAULT_MAX_COUNT);
|
|
9125
9224
|
let apiKey;
|
|
9126
9225
|
let extraHeaders = {};
|
|
9127
9226
|
try {
|
|
@@ -9152,6 +9251,9 @@ var ImageProvider = class {
|
|
|
9152
9251
|
prompt,
|
|
9153
9252
|
aspectRatio,
|
|
9154
9253
|
size,
|
|
9254
|
+
outputFormat,
|
|
9255
|
+
reasoningStrength,
|
|
9256
|
+
toolEnablement,
|
|
9155
9257
|
count,
|
|
9156
9258
|
inputImages,
|
|
9157
9259
|
signal: env.signal
|
|
@@ -9177,15 +9279,19 @@ ${written.map((entry) => ` ${entry.path} (${entry.bytes} bytes)`).join("\n")}`
|
|
|
9177
9279
|
);
|
|
9178
9280
|
const ignored = ignoredParams({
|
|
9179
9281
|
dialect,
|
|
9282
|
+
muse,
|
|
9180
9283
|
aspectRatio,
|
|
9181
9284
|
size,
|
|
9285
|
+
outputFormat,
|
|
9286
|
+
reasoningStrength,
|
|
9287
|
+
toolEnablement,
|
|
9182
9288
|
count,
|
|
9183
9289
|
saveTo,
|
|
9184
9290
|
returned: written.length
|
|
9185
9291
|
});
|
|
9186
|
-
const requestedSize = resolveImageSize(aspectRatio, size);
|
|
9292
|
+
const requestedSize = muse ? resolveMuseSize(aspectRatio, size) : resolveImageSize(aspectRatio, size);
|
|
9187
9293
|
const first = written[0];
|
|
9188
|
-
const mismatch = requestedSize !== void 0 && first?.width !== void 0 && first.height !== void 0 && requestedSize !== `${first.width}x${first.height}
|
|
9294
|
+
const mismatch = requestedSize !== void 0 && first?.width !== void 0 && first.height !== void 0 && (muse ? !ratioHonoured(requestedSize, first.width, first.height) : requestedSize !== `${first.width}x${first.height}`);
|
|
9189
9295
|
return {
|
|
9190
9296
|
ok: true,
|
|
9191
9297
|
model: `${model.provider}/${model.id}`,
|