@cartanova/qgrid-cli 2.9.5 → 2.9.6

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.
Files changed (32) hide show
  1. package/bundle/dist/application/qgrid/qgrid-response-format.js +7 -7
  2. package/bundle/dist/application/qgrid/qgrid.types.js +14 -1
  3. package/bundle/dist/application/qgrid/tool-emulation.js +2 -1
  4. package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +22 -3
  5. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +7 -2
  6. package/bundle/dist/utils/providers/openai/openai-image-generation.js +4 -3
  7. package/bundle/src/application/qgrid/qgrid-response-format.test.ts +6 -1
  8. package/bundle/src/application/qgrid/qgrid-response-format.ts +8 -6
  9. package/bundle/src/application/qgrid/qgrid.types.ts +16 -6
  10. package/bundle/src/application/qgrid/tool-emulation.test.ts +7 -0
  11. package/bundle/src/application/qgrid/tool-emulation.ts +3 -1
  12. package/bundle/src/utils/providers/common/provider-dispatcher.ts +3 -1
  13. package/bundle/src/utils/providers/openai/openai-backend-protocol.test.ts +23 -0
  14. package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +19 -2
  15. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +19 -0
  16. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +10 -1
  17. package/bundle/src/utils/providers/openai/openai-image-generation.test.ts +17 -0
  18. package/bundle/src/utils/providers/openai/openai-image-generation.ts +7 -1
  19. package/bundle/web-dist/client/assets/{index-BcCytvFf.js → index-BtVmANcA.js} +3 -3
  20. package/bundle/web-dist/client/assets/{logs-BkOilk5x.js → logs-BCuaLfPL.js} +1 -1
  21. package/bundle/web-dist/client/assets/{monit-8oCSLCdL.js → monit-BkGkzl6m.js} +1 -1
  22. package/bundle/web-dist/client/assets/{routes-DFIF4IoW.js → routes-DqY8SXcB.js} +1 -1
  23. package/bundle/web-dist/client/assets/{settings-nUI-DR3U.js → settings-DbkDAJfh.js} +1 -1
  24. package/bundle/web-dist/client/assets/{show-Bzx6Xkoc.js → show-Dx5JFzwy.js} +1 -1
  25. package/bundle/web-dist/client/assets/{tokens-DFWCL7Ts.js → tokens-DHahzDQJ.js} +1 -1
  26. package/bundle/web-dist/client/assets/{use-oauth-login-flow-B5MAjpVc.js → use-oauth-login-flow-Cjdnj_8D.js} +1 -1
  27. package/bundle/web-dist/client/index.html +1 -1
  28. package/bundle/web-dist/server/entry-server.generated.js +1 -1
  29. package/package.json +1 -1
  30. package/skills/qgrid/SKILL.md +7 -0
  31. package/skills/qgrid/references/ai-sdk-provider-contract.md +3 -1
  32. package/skills/qgrid/references/openai-codex-runtime.md +1 -1
@@ -112,6 +112,7 @@ function asReasoning(req: GenerateRequest): OpenAIResponsesOptions["reasoning"]
112
112
  }
113
113
 
114
114
  function requestOptions(req: GenerateRequest): OpenAIResponsesOptions {
115
+ const { outputFormat, ...imageControls } = req.imageGenerationOptions ?? {};
115
116
  return {
116
117
  model: req.model ?? "",
117
118
  ...(req.systemPrompt ? { instructions: req.systemPrompt } : {}),
@@ -124,7 +125,14 @@ function requestOptions(req: GenerateRequest): OpenAIResponsesOptions {
124
125
  ...(req.promptCacheKey ? { promptCacheKey: req.promptCacheKey } : {}),
125
126
  ...(req.outputSchema ? { outputSchema: { schema: req.outputSchema as JsonValue } } : {}),
126
127
  ...(req.imageGeneration
127
- ? { imageGeneration: req.imageGenerationOptions ? { ...req.imageGenerationOptions } : true }
128
+ ? {
129
+ imageGeneration: req.imageGenerationOptions
130
+ ? {
131
+ ...imageControls,
132
+ ...(outputFormat ? { output_format: outputFormat } : {}),
133
+ }
134
+ : true,
135
+ }
128
136
  : {}),
129
137
  };
130
138
  }
@@ -320,6 +328,7 @@ export class OpenAIDispatcher implements ProviderDispatcher {
320
328
  imageAttempted = true;
321
329
  images.push({
322
330
  data: event.base64,
331
+ mediaType: event.mimeType,
323
332
  revisedPrompt: event.revisedPrompt ?? null,
324
333
  ...(event.generation ? { generation: event.generation } : {}),
325
334
  });
@@ -31,6 +31,23 @@ async function run(fetchImpl: typeof fetch, overrides = {}) {
31
31
  }
32
32
 
33
33
  describe("standalone transparent images", () => {
34
+ it("rejects non-PNG formats before a network request", async () => {
35
+ const fetchMock = vi.fn<typeof fetch>();
36
+ await expect(run(fetchMock, { imageGeneration: { background: "transparent", output_format: "webp" } })).rejects.toThrow("only supports PNG");
37
+ expect(fetchMock).not.toHaveBeenCalled();
38
+ });
39
+
40
+ it("preserves a previous JPEG image MIME when switching to transparent editing", async () => {
41
+ const fetchMock = vi.fn<typeof fetch>(async () => Response.json(result()));
42
+ await run(fetchMock, { history: [
43
+ { type: "image_generation_call", result: "/9j/", output_format: "jpeg" },
44
+ { role: "user", content: "Remove the background" },
45
+ ] });
46
+ const [url, init] = fetchMock.mock.calls[0]!;
47
+ expect(url).toContain("/images/edits");
48
+ expect(JSON.parse(String(init?.body)).images).toEqual([{ image_url: "data:image/jpeg;base64,/9j/" }]);
49
+ });
50
+
34
51
  it("uses the Images endpoint and preserves actual metadata without charging a driver", async () => {
35
52
  const fetchMock = vi.fn<typeof fetch>(async () => Response.json(result()));
36
53
  const events = await run(fetchMock);
@@ -4,6 +4,7 @@ import { z } from "zod";
4
4
  import { ImageGenerationMetadata } from "../../../application/qgrid/qgrid.types";
5
5
  import {
6
6
  CHATGPT_CODEX_RESPONSES_URL,
7
+ imageMimeType,
7
8
  OpenAIProtocolError,
8
9
  type OpenAINormalizedEvent,
9
10
  type OpenAIResponsesOptions,
@@ -26,13 +27,18 @@ export function buildStandaloneImageRequest(options: OpenAIResponsesOptions) {
26
27
  "Standalone images require an explicit transparent background request",
27
28
  );
28
29
  }
30
+ if (controls.output_format && controls.output_format !== "png") {
31
+ throw new OpenAIProtocolError("Transparent image generation only supports PNG output");
32
+ }
29
33
  const text: string[] = [];
30
34
  const images: Array<{ image_url: string }> = [];
31
35
  if (options.instructions) text.push(`System instructions:\n${options.instructions}`);
32
36
  for (const item of options.history) {
33
37
  if (item.type === "reasoning") continue;
34
38
  if (item.type === "image_generation_call" && typeof item.result === "string") {
35
- images.push({ image_url: `data:image/png;base64,${item.result}` });
39
+ images.push({
40
+ image_url: `data:${imageMimeType(item.result, item.output_format)};base64,${item.result}`,
41
+ });
36
42
  continue;
37
43
  }
38
44
  if (item.type !== "message" && typeof item.role !== "string") {