egaki 0.11.0 → 0.13.0

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 (39) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/cli/cli.d.ts.map +1 -1
  3. package/dist/cli/cli.js +171 -2
  4. package/dist/cli/clone-generate.d.ts +1 -0
  5. package/dist/cli/clone-generate.d.ts.map +1 -1
  6. package/dist/cli/clone-generate.js +1 -1
  7. package/dist/cli/generate.d.ts +4 -2
  8. package/dist/cli/generate.d.ts.map +1 -1
  9. package/dist/cli/generate.js +14 -6
  10. package/dist/cli/model-catalog.d.ts.map +1 -1
  11. package/dist/cli/model-catalog.js +158 -5
  12. package/dist/cli/upscale-generate.d.ts +97 -0
  13. package/dist/cli/upscale-generate.d.ts.map +1 -0
  14. package/dist/cli/upscale-generate.js +300 -0
  15. package/dist/cli/upscale-generate.test.d.ts +2 -0
  16. package/dist/cli/upscale-generate.test.d.ts.map +1 -0
  17. package/dist/cli/upscale-generate.test.js +92 -0
  18. package/dist/cli/voice-change-generate.d.ts +39 -0
  19. package/dist/cli/voice-change-generate.d.ts.map +1 -0
  20. package/dist/cli/voice-change-generate.js +123 -0
  21. package/dist/vite/angled-screen-shader.d.ts +4 -39
  22. package/dist/vite/angled-screen-shader.d.ts.map +1 -1
  23. package/dist/vite/angled-screen-shader.js +36 -440
  24. package/dist/vite/angled-screen.d.ts.map +1 -1
  25. package/dist/vite/angled-screen.js +9 -7
  26. package/dist/vite/shader-renderer.d.ts +0 -4
  27. package/dist/vite/shader-renderer.d.ts.map +1 -1
  28. package/dist/vite/shader-renderer.js +2 -66
  29. package/package.json +11 -6
  30. package/src/cli/cli.ts +231 -2
  31. package/src/cli/clone-generate.ts +1 -1
  32. package/src/cli/generate.ts +24 -11
  33. package/src/cli/model-catalog.ts +167 -5
  34. package/src/cli/upscale-generate.test.ts +96 -0
  35. package/src/cli/upscale-generate.ts +395 -0
  36. package/src/cli/voice-change-generate.ts +187 -0
  37. package/src/vite/angled-screen-shader.tsx +45 -498
  38. package/src/vite/angled-screen.tsx +9 -7
  39. package/src/vite/shader-renderer.tsx +7 -78
@@ -198,6 +198,18 @@ const openaiImage = {
198
198
  providerOptions: openaiImageProviderOptions,
199
199
  }
200
200
 
201
+ // GPT Image 2.5 models add `xhigh` and `max` quality levels.
202
+ // Docs: https://developers.openai.com/api/docs/models/gpt-image-2.5-sunburst
203
+ const openaiImage25ProviderOptions: ProviderOption[] = [
204
+ { flag: 'quality', providerKey: 'quality', description: 'Image quality', values: ['auto', 'low', 'medium', 'high', 'xhigh', 'max'], defaultValue: 'auto', type: 'string' },
205
+ { flag: 'output-format', providerKey: 'outputFormat', description: 'Output format', values: ['png', 'jpeg', 'webp'], defaultValue: 'png', type: 'string' },
206
+ ]
207
+
208
+ const openaiImage25 = {
209
+ ...openaiImage,
210
+ providerOptions: openaiImage25ProviderOptions,
211
+ }
212
+
201
213
  const replicateImage = {
202
214
  provider: 'replicate',
203
215
  strategy: 'image' as const,
@@ -240,6 +252,15 @@ const xaiImage = {
240
252
  providerOptions: xaiImageProviderOptions,
241
253
  }
242
254
 
255
+ // Docs: https://docs.x.ai/developers/model-capabilities/images/generation
256
+ // quality is only honored by grok-imagine-image-2.0. 'auto' is the server default
257
+ // (low for generation, medium for editing), so egaki omits the field for 'auto'.
258
+ const xaiImage2ProviderOptions: ProviderOption[] = [
259
+ { flag: 'quality', providerKey: 'quality', description: 'Image quality', values: ['auto', 'low', 'medium'], defaultValue: 'auto', type: 'string' },
260
+ { flag: 'resolution', providerKey: 'resolution', description: 'Output resolution', values: ['1k', '2k'], defaultValue: '1k', type: 'string' },
261
+ { flag: 'output-format', providerKey: 'output_format', description: 'Output format', values: ['png', 'jpeg'], defaultValue: 'png', type: 'string' },
262
+ ]
263
+
243
264
  // Source: node_modules/@ai-sdk/xai/dist/index.d.ts → XaiVideoModelOptions
244
265
  // Docs: https://docs.x.ai/docs/api-reference#create-video
245
266
  const xaiVideoProviderOptions: ProviderOption[] = [
@@ -251,6 +272,21 @@ const xaiVideoProviderOptions: ProviderOption[] = [
251
272
  { flag: 'reference-images', providerKey: 'referenceImageUrls', description: 'Reference images for R2V (1-7 files or URLs)', type: 'string', array: true },
252
273
  ]
253
274
 
275
+ // Docs: https://docs.x.ai/developers/model-capabilities/video/overview
276
+ // grok-imagine-video-1.5: T2V/I2V at native 1080p, R2V up to 720p with up to 14 references.
277
+ // No editing or extension. Preset voices (reference_audios), last_frame and keyframes exist
278
+ // on the REST API but are not exposed by @ai-sdk/xai yet.
279
+ const xaiVideo15ProviderOptions: ProviderOption[] = [
280
+ { flag: 'resolution', providerKey: 'resolution', description: 'Output resolution (R2V is capped at 720p)', values: ['480p', '720p', '1080p'], defaultValue: '720p', type: 'string' },
281
+ { flag: 'mode', providerKey: 'mode', description: 'Video operation mode', values: ['reference-to-video'], type: 'string' },
282
+ { flag: 'reference-images', providerKey: 'referenceImageUrls', description: 'Reference images for R2V (1-14 files or URLs)', type: 'string', array: true },
283
+ ]
284
+
285
+ // grok-imagine-video-1.5-lite: T2V/I2V only. 1080p is upscaled from 720p.
286
+ const xaiVideo15LiteProviderOptions: ProviderOption[] = [
287
+ { flag: 'resolution', providerKey: 'resolution', description: 'Output resolution (1080p is upscaled from 720p)', values: ['480p', '720p', '1080p'], defaultValue: '720p', type: 'string' },
288
+ ]
289
+
254
290
  // Source: node_modules/@ai-sdk/bytedance/dist/index.d.ts → ByteDanceVideoProviderOptions
255
291
  // Docs: https://sdk.vercel.ai/docs/providers/bytedance
256
292
  const bytedanceVideoProviderOptions: ProviderOption[] = [
@@ -747,6 +783,24 @@ export const CATALOG: ModelEntry[] = [
747
783
  multipleImages: true,
748
784
  },
749
785
  },
786
+ {
787
+ id: 'grok-imagine-image-2.0',
788
+ name: 'Grok Imagine Image 2.0',
789
+ released: '2026-08',
790
+ ...xaiImage,
791
+ providerOptions: xaiImage2ProviderOptions,
792
+ // $0.04 at low quality (what 'auto' serves for generation); medium is $0.06, 2k costs more.
793
+ cost: { type: 'per-image', perImage: 0.04 },
794
+ features: {
795
+ editing: true,
796
+ inpainting: false,
797
+ aspectRatios: ['1:1', '3:4', '4:3', '9:16', '16:9', '2:3', '3:2', '21:9', '5:2'],
798
+ seed: false,
799
+ multipleImages: true,
800
+ },
801
+ },
802
+ // xAI retires grok-imagine-image-quality on 2026-11-02. After that date, requests to
803
+ // this slug are served by grok-imagine-image-2.0 with quality 'low'.
750
804
  {
751
805
  id: 'grok-imagine-image-quality',
752
806
  name: 'Grok Imagine Image Quality',
@@ -857,6 +911,84 @@ export const CATALOG: ModelEntry[] = [
857
911
  multipleImages: true,
858
912
  },
859
913
  },
914
+ {
915
+ id: 'gpt-image-2.5-flare',
916
+ name: 'GPT Image 2.5 Flare',
917
+ description:
918
+ 'Fastest GPT Image 2.5 model for high-quality everyday generation and editing. ' +
919
+ 'Token rates match gpt-image-2; $0.053 is the medium-quality 1024×1024 estimate.',
920
+ released: '2026-09-08',
921
+ ...openaiImage25,
922
+ // Token-based pricing: $30/1M output image tokens, same rates as gpt-image-2.
923
+ cost: { type: 'per-image', perImage: 0.053 },
924
+ features: {
925
+ editing: true,
926
+ inpainting: true,
927
+ aspectRatios: [],
928
+ sizes: ['1024x1024', '1536x1024', '1024x1536'],
929
+ seed: false,
930
+ multipleImages: true,
931
+ },
932
+ },
933
+ {
934
+ id: 'gpt-image-2.5-sunburst',
935
+ name: 'GPT Image 2.5 Sunburst',
936
+ description:
937
+ 'Most capable GPT Image 2.5 model, for work where editing precision and reference ' +
938
+ 'fidelity matter most. Slower than Flare. Token rates match gpt-image-2; actual cost ' +
939
+ 'is usually higher because it spends more tokens per image.',
940
+ released: '2026-09-08',
941
+ ...openaiImage25,
942
+ // Token-based pricing: $30/1M output image tokens, same rates as gpt-image-2.
943
+ cost: { type: 'per-image', perImage: 0.053 },
944
+ features: {
945
+ editing: true,
946
+ inpainting: true,
947
+ aspectRatios: [],
948
+ sizes: ['1024x1024', '1536x1024', '1024x1536'],
949
+ seed: false,
950
+ multipleImages: true,
951
+ },
952
+ },
953
+ // GPT Image 2.6 (changelog: https://developers.openai.com/api/docs/changelog, 2026-11-04).
954
+ // Quality levels and pricing are assumed equal to 2.5 until OpenAI's model pages confirm them.
955
+ {
956
+ id: 'gpt-image-2.6-flare',
957
+ name: 'GPT Image 2.6 Flare',
958
+ description:
959
+ 'Fastest GPT Image 2.6 model for image generation and editing, with adjustable complexity. ' +
960
+ 'Pricing assumed equal to gpt-image-2.5-flare.',
961
+ released: '2026-11-04',
962
+ ...openaiImage25,
963
+ cost: { type: 'per-image', perImage: 0.053 },
964
+ features: {
965
+ editing: true,
966
+ inpainting: true,
967
+ aspectRatios: [],
968
+ sizes: ['1024x1024', '1536x1024', '1024x1536'],
969
+ seed: false,
970
+ multipleImages: true,
971
+ },
972
+ },
973
+ {
974
+ id: 'gpt-image-2.6-sunburst',
975
+ name: 'GPT Image 2.6 Sunburst',
976
+ description:
977
+ 'Most capable GPT Image 2.6 model, for work where editing precision and reference ' +
978
+ 'fidelity matter most. Slower than Flare. Pricing assumed equal to gpt-image-2.5-sunburst; ' +
979
+ 'actual cost is usually higher because it spends more tokens per image.',
980
+ released: '2026-11-04',
981
+ ...openaiImage25,
982
+ cost: { type: 'per-image', perImage: 0.053 },
983
+ features: {
984
+ editing: true,
985
+ inpainting: true,
986
+ aspectRatios: [],
987
+ sizes: ['1024x1024', '1536x1024', '1024x1536'],
988
+ seed: false,
989
+ multipleImages: true,
990
+ },
991
+ },
860
992
  {
861
993
  id: 'chatgpt-image-latest',
862
994
  name: 'ChatGPT Image',
@@ -1608,25 +1740,55 @@ export const VIDEO_CATALOG: VideoModelEntry[] = [
1608
1740
  provider: 'xai',
1609
1741
  strategy: 'video',
1610
1742
  released: '2026-05',
1743
+ // Source: https://ai-gateway.vercel.sh/v1/models (spacexai/grok-imagine-video-1.5)
1611
1744
  cost: {
1612
1745
  type: 'per-video-second',
1613
1746
  defaultDurationSec: 5,
1614
1747
  tiers: [
1615
1748
  { resolution: '480p', costPerSecond: 0.08 },
1616
1749
  { resolution: '720p', costPerSecond: 0.14 },
1750
+ { resolution: '1080p', costPerSecond: 0.25 },
1617
1751
  ],
1618
1752
  },
1619
1753
  features: {
1620
- textToVideo: false,
1754
+ textToVideo: true,
1621
1755
  imageToVideo: true,
1622
- capabilities: ['i2v'],
1623
- aspectRatios: ['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3'],
1624
- resolutions: ['480p', '720p'],
1756
+ capabilities: ['t2v', 'i2v', 'r2v'],
1757
+ aspectRatios: ['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3', '21:9', '5:2'],
1758
+ resolutions: ['480p', '720p', '1080p'],
1625
1759
  durationRangeSec: { min: 1, max: 15 },
1626
1760
  seed: false,
1627
1761
  multipleVideos: false,
1628
1762
  },
1629
- providerOptions: xaiVideoProviderOptions,
1763
+ providerOptions: xaiVideo15ProviderOptions,
1764
+ },
1765
+ {
1766
+ id: 'grok-imagine-video-1.5-lite',
1767
+ name: 'Grok Imagine Video 1.5 Lite',
1768
+ provider: 'xai',
1769
+ strategy: 'video',
1770
+ released: '2026-10-08',
1771
+ // Source: https://ai-gateway.vercel.sh/v1/models (spacexai/grok-imagine-video-1.5-lite)
1772
+ cost: {
1773
+ type: 'per-video-second',
1774
+ defaultDurationSec: 5,
1775
+ tiers: [
1776
+ { resolution: '480p', costPerSecond: 0.02 },
1777
+ { resolution: '720p', costPerSecond: 0.03 },
1778
+ { resolution: '1080p', costPerSecond: 0.14 },
1779
+ ],
1780
+ },
1781
+ features: {
1782
+ textToVideo: true,
1783
+ imageToVideo: true,
1784
+ capabilities: ['t2v', 'i2v'],
1785
+ aspectRatios: ['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3', '21:9', '5:2'],
1786
+ resolutions: ['480p', '720p', '1080p'],
1787
+ durationRangeSec: { min: 1, max: 15 },
1788
+ seed: false,
1789
+ multipleVideos: false,
1790
+ },
1791
+ providerOptions: xaiVideo15LiteProviderOptions,
1630
1792
  },
1631
1793
  // ── Kling (AI Gateway) ──────────────────────────────────────────────
1632
1794
  // Source: https://ai-gateway.vercel.sh/v1/models (klingai/* entries)
@@ -0,0 +1,96 @@
1
+ import { describe, expect, test } from 'vitest'
2
+ import { blendTiles, chooseGrid, gptUpscaleSize, planTiles } from './upscale-generate.js'
3
+
4
+ describe('gptUpscaleSize', () => {
5
+ test('picks a size inside every GPT Image limit, close to the requested scale', () => {
6
+ const cases = [
7
+ { width: 992, height: 570 },
8
+ { width: 992, height: 570, scale: 2 },
9
+ { width: 1024, height: 1024 },
10
+ { width: 1080, height: 1920 },
11
+ { width: 3000, height: 1000 },
12
+ { width: 400, height: 300, scale: 1.5 },
13
+ { width: 600, height: 200, scale: 2 },
14
+ { width: 4000, height: 3000, scale: 2 },
15
+ { width: 3100, height: 1000 },
16
+ { width: 800, height: 600, scale: 0.5 },
17
+ ]
18
+ const results = cases.map((input) => {
19
+ const label = `${input.width}x${input.height} x${input.scale ?? 'max'}`
20
+ const size = gptUpscaleSize(input)
21
+ if (size instanceof Error) return `${label}: ${size.message}`
22
+ const pixels = size.width * size.height
23
+ const valid =
24
+ size.width % 16 === 0 &&
25
+ size.height % 16 === 0 &&
26
+ Math.max(size.width, size.height) <= 3840 &&
27
+ pixels >= 655_360 &&
28
+ pixels <= 8_294_400 &&
29
+ Math.max(size.width / size.height, size.height / size.width) <= 3
30
+ const ratioDrift = Math.abs(size.width / size.height / (input.width / input.height) - 1)
31
+ return `${label} -> ${size.width}x${size.height} (${(pixels / 1e6).toFixed(2)} MP, ratio drift ${(ratioDrift * 100).toFixed(2)}%${valid ? '' : ', INVALID'})`
32
+ })
33
+ expect('\n' + results.join('\n')).toMatchInlineSnapshot(`
34
+ "
35
+ 992x570 xmax -> 3792x2176 (8.25 MP, ratio drift 0.13%)
36
+ 992x570 x2 -> 1984x1136 (2.25 MP, ratio drift 0.35%)
37
+ 1024x1024 xmax -> 2880x2880 (8.29 MP, ratio drift 0.00%)
38
+ 1080x1920 xmax -> 2160x3840 (8.29 MP, ratio drift 0.00%)
39
+ 3000x1000 xmax -> 3840x1280 (4.92 MP, ratio drift 0.00%)
40
+ 400x300 x1.5 -> 944x704 (0.66 MP, ratio drift 0.57%)
41
+ 600x200 x2 -> 1424x480 (0.68 MP, ratio drift 1.11%)
42
+ 4000x3000 x2: GPT Image cannot upscale a 4000x3000 image: its output is limited to 3840px per edge and 8.3 MP.
43
+ 3100x1000 xmax: GPT Image supports aspect ratios up to 3:1. The input is 3100x1000.
44
+ 800x600 x0.5: Scale must be greater than 1, got 0.5."
45
+ `)
46
+ })
47
+
48
+ test('ChatGPT login tiles the image until ~1.6 MP per tile reaches the target', () => {
49
+ const cases = [
50
+ { width: 992, height: 570, targetWidth: 3792 },
51
+ { width: 992, height: 570, targetWidth: 1984 },
52
+ { width: 1024, height: 1024, targetWidth: 2880 },
53
+ { width: 300, height: 200, targetWidth: 3456 },
54
+ ]
55
+ const lines = cases.map((c) => {
56
+ const grid = chooseGrid({ ...c, pixelsPerCall: 1536 * 1024 })
57
+ const tiles = planTiles({ width: c.width, height: c.height, grid })
58
+ const last = tiles[tiles.length - 1]!
59
+ const covers = last.x + last.width === c.width && last.y + last.height === c.height
60
+ return `${c.width}x${c.height} -> ${c.targetWidth}w: grid ${grid}, tile ${tiles[0]!.width}x${tiles[0]!.height}, covers ${covers}`
61
+ })
62
+ expect('\n' + lines.join('\n')).toMatchInlineSnapshot(`
63
+ "
64
+ 992x570 -> 3792w: grid 3, tile 382x219, covers true
65
+ 992x570 -> 1984w: grid 2, tile 551x317, covers true
66
+ 1024x1024 -> 2880w: grid 3, tile 394x394, covers true
67
+ 300x200 -> 3456w: grid 1, tile 300x200, covers true"
68
+ `)
69
+ })
70
+
71
+ test('blendTiles maps each tile to the reference colors and keeps overlaps seamless', () => {
72
+ const width = 8
73
+ const height = 4
74
+ const reference = new Uint8Array(width * height * 3).map((_, i) => 100 + (i % 3) * 20)
75
+ // two overlapping tiles with a different global color cast each
76
+ const tile = (x: number, cast: number) => ({
77
+ x,
78
+ y: 0,
79
+ width: 5,
80
+ height,
81
+ pixels: new Uint8Array(5 * height * 3).map((_, i) => 100 + (i % 3) * 20 + cast + (i % 7)),
82
+ })
83
+ const out = blendTiles({ width, height, reference, tiles: [tile(0, 40), tile(3, -30)] })
84
+ const maxDiff = Math.max(...out.map((v, i) => Math.abs(v - reference[i]!)))
85
+ expect(maxDiff).toBeLessThanOrEqual(4)
86
+
87
+ // near-white areas push matched values past 255; they must clamp, not wrap to dark pixels
88
+ const bright = blendTiles({
89
+ width: 4,
90
+ height: 1,
91
+ reference: new Uint8Array([250, 250, 250, 255, 255, 255, 240, 240, 240, 255, 255, 255]),
92
+ tiles: [{ x: 0, y: 0, width: 4, height: 1, pixels: new Uint8Array([10, 10, 10, 200, 200, 200, 0, 0, 0, 255, 255, 255]) }],
93
+ })
94
+ expect(Math.min(...bright)).toBeGreaterThan(200)
95
+ })
96
+ })