@omnichar/contracts 0.0.0-6cf9984

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 (109) hide show
  1. package/dist/errors.d.ts +39 -0
  2. package/dist/errors.d.ts.map +1 -0
  3. package/dist/errors.js +42 -0
  4. package/dist/errors.js.map +1 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +5 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/manifest/index.d.ts +18 -0
  10. package/dist/manifest/index.d.ts.map +1 -0
  11. package/dist/manifest/index.js +13 -0
  12. package/dist/manifest/index.js.map +1 -0
  13. package/dist/result.d.ts +12 -0
  14. package/dist/result.d.ts.map +1 -0
  15. package/dist/result.js +7 -0
  16. package/dist/result.js.map +1 -0
  17. package/dist/v1/accessRequests.d.ts +11 -0
  18. package/dist/v1/accessRequests.d.ts.map +1 -0
  19. package/dist/v1/accessRequests.js +12 -0
  20. package/dist/v1/accessRequests.js.map +1 -0
  21. package/dist/v1/apiKeys.d.ts +38 -0
  22. package/dist/v1/apiKeys.d.ts.map +1 -0
  23. package/dist/v1/apiKeys.js +28 -0
  24. package/dist/v1/apiKeys.js.map +1 -0
  25. package/dist/v1/assets.d.ts +47 -0
  26. package/dist/v1/assets.d.ts.map +1 -0
  27. package/dist/v1/assets.js +24 -0
  28. package/dist/v1/assets.js.map +1 -0
  29. package/dist/v1/capacity.d.ts +48 -0
  30. package/dist/v1/capacity.d.ts.map +1 -0
  31. package/dist/v1/capacity.js +18 -0
  32. package/dist/v1/capacity.js.map +1 -0
  33. package/dist/v1/characterListings.d.ts +75 -0
  34. package/dist/v1/characterListings.d.ts.map +1 -0
  35. package/dist/v1/characterListings.js +68 -0
  36. package/dist/v1/characterListings.js.map +1 -0
  37. package/dist/v1/characters.d.ts +89 -0
  38. package/dist/v1/characters.d.ts.map +1 -0
  39. package/dist/v1/characters.js +64 -0
  40. package/dist/v1/characters.js.map +1 -0
  41. package/dist/v1/common.d.ts +13 -0
  42. package/dist/v1/common.d.ts.map +1 -0
  43. package/dist/v1/common.js +12 -0
  44. package/dist/v1/common.js.map +1 -0
  45. package/dist/v1/credits.d.ts +124 -0
  46. package/dist/v1/credits.d.ts.map +1 -0
  47. package/dist/v1/credits.js +82 -0
  48. package/dist/v1/credits.js.map +1 -0
  49. package/dist/v1/datasets.d.ts +153 -0
  50. package/dist/v1/datasets.d.ts.map +1 -0
  51. package/dist/v1/datasets.js +93 -0
  52. package/dist/v1/datasets.js.map +1 -0
  53. package/dist/v1/featureRequests.d.ts +29 -0
  54. package/dist/v1/featureRequests.d.ts.map +1 -0
  55. package/dist/v1/featureRequests.js +36 -0
  56. package/dist/v1/featureRequests.js.map +1 -0
  57. package/dist/v1/health.d.ts +13 -0
  58. package/dist/v1/health.d.ts.map +1 -0
  59. package/dist/v1/health.js +10 -0
  60. package/dist/v1/health.js.map +1 -0
  61. package/dist/v1/index.d.ts +23 -0
  62. package/dist/v1/index.d.ts.map +1 -0
  63. package/dist/v1/index.js +23 -0
  64. package/dist/v1/index.js.map +1 -0
  65. package/dist/v1/me.d.ts +30 -0
  66. package/dist/v1/me.d.ts.map +1 -0
  67. package/dist/v1/me.js +22 -0
  68. package/dist/v1/me.js.map +1 -0
  69. package/dist/v1/plans.d.ts +30 -0
  70. package/dist/v1/plans.d.ts.map +1 -0
  71. package/dist/v1/plans.js +19 -0
  72. package/dist/v1/plans.js.map +1 -0
  73. package/dist/v1/purchases.d.ts +40 -0
  74. package/dist/v1/purchases.d.ts.map +1 -0
  75. package/dist/v1/purchases.js +56 -0
  76. package/dist/v1/purchases.js.map +1 -0
  77. package/dist/v1/runs.d.ts +498 -0
  78. package/dist/v1/runs.d.ts.map +1 -0
  79. package/dist/v1/runs.js +203 -0
  80. package/dist/v1/runs.js.map +1 -0
  81. package/dist/v1/sessions.d.ts +349 -0
  82. package/dist/v1/sessions.d.ts.map +1 -0
  83. package/dist/v1/sessions.js +76 -0
  84. package/dist/v1/sessions.js.map +1 -0
  85. package/dist/v1/studio.d.ts +124 -0
  86. package/dist/v1/studio.d.ts.map +1 -0
  87. package/dist/v1/studio.js +120 -0
  88. package/dist/v1/studio.js.map +1 -0
  89. package/dist/v1/terms.d.ts +8 -0
  90. package/dist/v1/terms.d.ts.map +1 -0
  91. package/dist/v1/terms.js +15 -0
  92. package/dist/v1/terms.js.map +1 -0
  93. package/dist/v1/uploads.d.ts +56 -0
  94. package/dist/v1/uploads.d.ts.map +1 -0
  95. package/dist/v1/uploads.js +58 -0
  96. package/dist/v1/uploads.js.map +1 -0
  97. package/dist/v1/usernames.d.ts +35 -0
  98. package/dist/v1/usernames.d.ts.map +1 -0
  99. package/dist/v1/usernames.js +67 -0
  100. package/dist/v1/usernames.js.map +1 -0
  101. package/dist/v1/videoPricing.d.ts +70 -0
  102. package/dist/v1/videoPricing.d.ts.map +1 -0
  103. package/dist/v1/videoPricing.js +128 -0
  104. package/dist/v1/videoPricing.js.map +1 -0
  105. package/dist/v1/workflows.d.ts +198 -0
  106. package/dist/v1/workflows.d.ts.map +1 -0
  107. package/dist/v1/workflows.js +103 -0
  108. package/dist/v1/workflows.js.map +1 -0
  109. package/package.json +34 -0
@@ -0,0 +1,124 @@
1
+ import { z } from 'zod';
2
+ import { type VideoResolution } from './videoPricing.js';
3
+ export declare const STUDIO_MODES: readonly ["video", "image"];
4
+ export type StudioMode = (typeof STUDIO_MODES)[number];
5
+ export declare const STUDIO_RESOLUTIONS: readonly ["0.5k", "1k", "2k", "4k"];
6
+ export type StudioResolution = (typeof STUDIO_RESOLUTIONS)[number];
7
+ export declare const STUDIO_RATIOS: readonly ["1:1", "3:4", "4:5", "9:16", "16:9"];
8
+ export type StudioRatio = (typeof STUDIO_RATIOS)[number];
9
+ export declare const VIDEO_STUDIO_RATIOS: readonly StudioRatio[];
10
+ export declare const ratiosFor: (mode: StudioMode) => readonly StudioRatio[];
11
+ export declare const IMAGE_STUDIO_RESOLUTIONS: readonly StudioResolution[];
12
+ export declare const resolutionsFor: (mode: StudioMode) => readonly StudioResolution[];
13
+ export declare const IMAGE_MICRO_BY_RESOLUTION: Record<StudioResolution, number>;
14
+ export declare const CAST_IMAGE_MICRO_BY_RESOLUTION: Record<StudioResolution, number>;
15
+ /** The flat price of one image, in micro-credits. */
16
+ export declare function imageRunMicro(resolution: StudioResolution, hasCharacter: boolean): number;
17
+ export declare const IMAGE_LONG_EDGE: Record<StudioResolution, number>;
18
+ export declare const VIDEO_RESOLUTION_FOR: Record<StudioResolution, VideoResolution>;
19
+ /** Width and height for an image at this tier and shape. */
20
+ export declare function imageDimensions(resolution: StudioResolution, ratio: StudioRatio): {
21
+ width: number;
22
+ height: number;
23
+ };
24
+ export type StudioQuote = {
25
+ mode: StudioMode;
26
+ resolution: StudioResolution;
27
+ seconds?: number | undefined;
28
+ hasCharacter: boolean;
29
+ };
30
+ /** What one generate costs, in micro-credits. The same function the server charges by. */
31
+ export declare function studioRunMicro(quote: StudioQuote): number;
32
+ export declare const studioRunCredits: (quote: StudioQuote) => number;
33
+ export declare const castSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
34
+ kind: z.ZodLiteral<"own">;
35
+ characterId: z.ZodUUID;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ kind: z.ZodLiteral<"community">;
38
+ slug: z.ZodString;
39
+ }, z.core.$strip>], "kind">;
40
+ export declare const generateBodySchema: z.ZodObject<{
41
+ mode: z.ZodEnum<{
42
+ image: "image";
43
+ video: "video";
44
+ }>;
45
+ prompt: z.ZodString;
46
+ ratio: z.ZodEnum<{
47
+ "16:9": "16:9";
48
+ "1:1": "1:1";
49
+ "3:4": "3:4";
50
+ "9:16": "9:16";
51
+ "4:5": "4:5";
52
+ }>;
53
+ resolution: z.ZodEnum<{
54
+ "0.5k": "0.5k";
55
+ "1k": "1k";
56
+ "2k": "2k";
57
+ "4k": "4k";
58
+ }>;
59
+ seconds: z.ZodOptional<z.ZodNumber>;
60
+ cast: z.ZodDefault<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
61
+ kind: z.ZodLiteral<"own">;
62
+ characterId: z.ZodUUID;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ kind: z.ZodLiteral<"community">;
65
+ slug: z.ZodString;
66
+ }, z.core.$strip>], "kind">>>;
67
+ sessionId: z.ZodOptional<z.ZodUUID>;
68
+ }, z.core.$strip>;
69
+ export declare const generateResponseSchema: z.ZodObject<{
70
+ runId: z.ZodUUID;
71
+ sessionId: z.ZodNullable<z.ZodUUID>;
72
+ credits: z.ZodNumber;
73
+ }, z.core.$strip>;
74
+ export declare const studioSettingsSchema: z.ZodObject<{
75
+ mode: z.ZodEnum<{
76
+ image: "image";
77
+ video: "video";
78
+ }>;
79
+ prompt: z.ZodString;
80
+ ratio: z.ZodEnum<{
81
+ "16:9": "16:9";
82
+ "1:1": "1:1";
83
+ "3:4": "3:4";
84
+ "9:16": "9:16";
85
+ "4:5": "4:5";
86
+ }>;
87
+ resolution: z.ZodEnum<{
88
+ "0.5k": "0.5k";
89
+ "1k": "1k";
90
+ "2k": "2k";
91
+ "4k": "4k";
92
+ }>;
93
+ seconds: z.ZodNullable<z.ZodNumber>;
94
+ characterName: z.ZodNullable<z.ZodString>;
95
+ cast: z.ZodDefault<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
96
+ kind: z.ZodLiteral<"own">;
97
+ characterId: z.ZodUUID;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ kind: z.ZodLiteral<"community">;
100
+ slug: z.ZodString;
101
+ }, z.core.$strip>], "kind">>>;
102
+ }, z.core.$strip>;
103
+ export declare const communityCharacterSchema: z.ZodObject<{
104
+ slug: z.ZodString;
105
+ name: z.ZodString;
106
+ summary: z.ZodString;
107
+ archs: z.ZodArray<z.ZodString>;
108
+ coverUrl: z.ZodNullable<z.ZodURL>;
109
+ }, z.core.$strip>;
110
+ export declare const communityCharacterListSchema: z.ZodObject<{
111
+ items: z.ZodArray<z.ZodObject<{
112
+ slug: z.ZodString;
113
+ name: z.ZodString;
114
+ summary: z.ZodString;
115
+ archs: z.ZodArray<z.ZodString>;
116
+ coverUrl: z.ZodNullable<z.ZodURL>;
117
+ }, z.core.$strip>>;
118
+ }, z.core.$strip>;
119
+ export type GenerateBody = z.input<typeof generateBodySchema>;
120
+ export type GenerateResponse = z.infer<typeof generateResponseSchema>;
121
+ export type StudioSettings = z.infer<typeof studioSettingsSchema>;
122
+ export type Cast = z.infer<typeof castSchema>;
123
+ export type CommunityCharacter = z.infer<typeof communityCharacterSchema>;
124
+ //# sourceMappingURL=studio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../src/v1/studio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAA;AAK1B,eAAO,MAAM,YAAY,6BAA8B,CAAA;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD,eAAO,MAAM,kBAAkB,qCAAsC,CAAA;AACrE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE,eAAO,MAAM,aAAa,gDAAiD,CAAA;AAC3E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAGxD,eAAO,MAAM,mBAAmB,EAAE,SAAS,WAAW,EAAmC,CAAA;AAEzF,eAAO,MAAM,SAAS,GAAI,MAAM,UAAU,KAAG,SAAS,WAAW,EACT,CAAA;AAIxD,eAAO,MAAM,wBAAwB,EAAE,SAAS,gBAAgB,EAAuB,CAAA;AAEvF,eAAO,MAAM,cAAc,GAAI,MAAM,UAAU,KAAG,SAAS,gBAAgB,EACT,CAAA;AAMlE,eAAO,MAAM,yBAAyB,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AG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAC7C,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
@@ -0,0 +1,120 @@
1
+ import { z } from 'zod';
2
+ import { MICRO_PER_CREDIT } from './credits.js';
3
+ import { MAX_VIDEO_SECONDS, MIN_VIDEO_SECONDS, billedVideoReferences, videoRunMicro, } from './videoPricing.js';
4
+ // The studio's one-box generate: a prompt, a mode and three presets. The server maps each preset
5
+ // onto a workflow's own fields, so the browser never learns a node id or a width.
6
+ export const STUDIO_MODES = ['video', 'image'];
7
+ export const STUDIO_RESOLUTIONS = ['0.5k', '1k', '2k', '4k'];
8
+ export const STUDIO_RATIOS = ['1:1', '3:4', '4:5', '9:16', '16:9'];
9
+ // MiniMax H3 offers no 4:5, so video leaves it out rather than rounding it to a shape nobody chose.
10
+ export const VIDEO_STUDIO_RATIOS = ['1:1', '3:4', '9:16', '16:9'];
11
+ export const ratiosFor = (mode) => mode === 'video' ? VIDEO_STUDIO_RATIOS : STUDIO_RATIOS;
12
+ // An image under a megapixel is billed as a whole one, so 0.5K would cost what 1K costs for less
13
+ // picture. Video keeps it, where 480p really is cheaper.
14
+ export const IMAGE_STUDIO_RESOLUTIONS = ['1k', '2k', '4k'];
15
+ export const resolutionsFor = (mode) => mode === 'image' ? IMAGE_STUDIO_RESOLUTIONS : STUDIO_RESOLUTIONS;
16
+ // What an image costs a caller: twice the renderer's own rate, the same margin video carries. A
17
+ // cast character is sent as up to four reference images, each billed as a megapixel of input, so it
18
+ // is priced as its own column rather than a flat add-on. The server recomputes both columns from the
19
+ // supplier's rates in a test, so the card and the cost cannot drift.
20
+ export const IMAGE_MICRO_BY_RESOLUTION = {
21
+ '0.5k': 2_000_000,
22
+ '1k': 2_000_000,
23
+ '2k': 5_000_000,
24
+ '4k': 20_000_000,
25
+ };
26
+ export const CAST_IMAGE_MICRO_BY_RESOLUTION = {
27
+ '0.5k': 11_000_000,
28
+ '1k': 11_000_000,
29
+ '2k': 18_000_000,
30
+ '4k': 44_000_000,
31
+ };
32
+ /** The flat price of one image, in micro-credits. */
33
+ export function imageRunMicro(resolution, hasCharacter) {
34
+ return (hasCharacter ? CAST_IMAGE_MICRO_BY_RESOLUTION : IMAGE_MICRO_BY_RESOLUTION)[resolution];
35
+ }
36
+ // Pixels on the long edge. The short edge follows from the ratio.
37
+ export const IMAGE_LONG_EDGE = {
38
+ '0.5k': 512,
39
+ '1k': 1024,
40
+ '2k': 2048,
41
+ '4k': 4096,
42
+ };
43
+ export const VIDEO_RESOLUTION_FOR = {
44
+ '0.5k': '480p',
45
+ '1k': '768p',
46
+ '2k': '2K',
47
+ '4k': '4K',
48
+ };
49
+ // Latent models need both edges on a 16px grid; anything else is cropped or rejected downstream.
50
+ const onGrid = (px) => Math.max(16, Math.round(px / 16) * 16);
51
+ /** Width and height for an image at this tier and shape. */
52
+ export function imageDimensions(resolution, ratio) {
53
+ const [w, h] = ratio.split(':').map(Number);
54
+ const long = IMAGE_LONG_EDGE[resolution];
55
+ return w >= h
56
+ ? { width: onGrid(long), height: onGrid((long * h) / w) }
57
+ : { width: onGrid((long * w) / h), height: onGrid(long) };
58
+ }
59
+ /** What one generate costs, in micro-credits. The same function the server charges by. */
60
+ export function studioRunMicro(quote) {
61
+ if (quote.mode === 'image')
62
+ return imageRunMicro(quote.resolution, quote.hasCharacter);
63
+ return videoRunMicro({
64
+ resolution: VIDEO_RESOLUTION_FOR[quote.resolution],
65
+ seconds: quote.seconds ?? MIN_VIDEO_SECONDS,
66
+ referenceImages: billedVideoReferences({ uploads: 0, hasCharacter: quote.hasCharacter }),
67
+ });
68
+ }
69
+ export const studioRunCredits = (quote) => Math.ceil(studioRunMicro(quote) / MICRO_PER_CREDIT);
70
+ // A community character is named by its gallery slug; the server imports it on first use.
71
+ export const castSchema = z.discriminatedUnion('kind', [
72
+ z.object({ kind: z.literal('own'), characterId: z.uuid() }),
73
+ z.object({ kind: z.literal('community'), slug: z.string().min(1).max(120) }),
74
+ ]);
75
+ export const generateBodySchema = z
76
+ .object({
77
+ mode: z.enum(STUDIO_MODES),
78
+ prompt: z.string().trim().min(1).max(4000),
79
+ ratio: z.enum(STUDIO_RATIOS),
80
+ resolution: z.enum(STUDIO_RESOLUTIONS),
81
+ seconds: z.number().int().min(MIN_VIDEO_SECONDS).max(MAX_VIDEO_SECONDS).optional(),
82
+ cast: castSchema.nullable().default(null),
83
+ sessionId: z.uuid().optional(),
84
+ })
85
+ .refine((body) => ratiosFor(body.mode).includes(body.ratio), {
86
+ message: 'That shape is not available for video.',
87
+ path: ['ratio'],
88
+ })
89
+ .refine((body) => resolutionsFor(body.mode).includes(body.resolution), {
90
+ message: 'Images start at 1K.',
91
+ path: ['resolution'],
92
+ });
93
+ export const generateResponseSchema = z.object({
94
+ runId: z.uuid(),
95
+ sessionId: z.uuid().nullable(),
96
+ credits: z.number().int().nonnegative(),
97
+ });
98
+ // What the studio recorded about a run it started, read back by the run list.
99
+ export const studioSettingsSchema = z.object({
100
+ mode: z.enum(STUDIO_MODES),
101
+ prompt: z.string(),
102
+ ratio: z.enum(STUDIO_RATIOS),
103
+ resolution: z.enum(STUDIO_RESOLUTIONS),
104
+ seconds: z.number().int().nullable(),
105
+ characterName: z.string().nullable(),
106
+ // Which character was cast, so Run again and Edit prompt can cast the same one.
107
+ cast: castSchema.nullable().default(null),
108
+ });
109
+ // A published character anyone may cast. `coverUrl` is on the media gateway's public route.
110
+ export const communityCharacterSchema = z.object({
111
+ slug: z.string(),
112
+ name: z.string(),
113
+ summary: z.string(),
114
+ archs: z.array(z.string()),
115
+ coverUrl: z.url().nullable(),
116
+ });
117
+ export const communityCharacterListSchema = z.object({
118
+ items: z.array(communityCharacterSchema),
119
+ });
120
+ //# sourceMappingURL=studio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio.js","sourceRoot":"","sources":["../../src/v1/studio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GAEd,MAAM,mBAAmB,CAAA;AAE1B,iGAAiG;AACjG,kFAAkF;AAElF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAA;AAGvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AAGrE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AAG3E,oGAAoG;AACpG,MAAM,CAAC,MAAM,mBAAmB,GAA2B,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAEzF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAgB,EAA0B,EAAE,CACpE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,aAAa,CAAA;AAExD,iGAAiG;AACjG,yDAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAgC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEvF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAgB,EAA+B,EAAE,CAC9E,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC,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MAAM,CAAC;IACnD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC;CACzC,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export declare const termsAcceptanceSchema: z.ZodObject<{
3
+ version: z.ZodNullable<z.ZodString>;
4
+ acceptedAt: z.ZodNullable<z.ZodISODateTime>;
5
+ previousVersion: z.ZodNullable<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export type TermsAcceptance = z.infer<typeof termsAcceptanceSchema>;
8
+ //# sourceMappingURL=terms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../../src/v1/terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,eAAO,MAAM,qBAAqB;;;;iBAOhC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ // What this service has recorded about someone agreeing to the Terms of Service.
3
+ //
4
+ // Every field is written server-side from the verified session and the server's own TERMS_VERSION.
5
+ // Nothing here is ever read from a request body, so a client cannot backdate an acceptance or
6
+ // claim one that did not happen.
7
+ export const termsAcceptanceSchema = z.object({
8
+ // The Terms version on record, as an ISO date. Null before anyone has signed in through the UI.
9
+ version: z.string().nullable(),
10
+ acceptedAt: z.iso.datetime().nullable(),
11
+ // The version this call replaced, so the dashboard can say the Terms changed. Null on a first
12
+ // acceptance, and on every later call that changed nothing.
13
+ previousVersion: z.string().nullable(),
14
+ });
15
+ //# sourceMappingURL=terms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terms.js","sourceRoot":"","sources":["../../src/v1/terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,iFAAiF;AACjF,EAAE;AACF,mGAAmG;AACnG,8FAA8F;AAC9F,iCAAiC;AACjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,gGAAgG;IAChG,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,8FAA8F;IAC9F,4DAA4D;IAC5D,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ export declare const MAX_UPLOAD_BYTES: number;
3
+ export declare const MAX_THUMBNAIL_BYTES: number;
4
+ /**
5
+ * The long edge of every stored derivative, wherever it is made.
6
+ *
7
+ * Shared because three places make one - the control plane for a pod's takes, the worker for a
8
+ * serverless run's, and the browser for an upload - and a grid that gets a different size depending
9
+ * on which produced it is a grid that looks wrong for reasons nobody can see.
10
+ */
11
+ export declare const THUMBNAIL_EDGE = 512;
12
+ export declare const THUMBNAIL_CONTENT_TYPE = "image/webp";
13
+ export declare const THUMBNAIL_QUALITY = 82;
14
+ export declare const UPLOAD_KINDS: readonly ["image", "video", "character"];
15
+ export declare const uploadKindSchema: z.ZodEnum<{
16
+ image: "image";
17
+ video: "video";
18
+ character: "character";
19
+ }>;
20
+ export declare const UPLOAD_CONTENT_TYPES: {
21
+ readonly image: readonly ["image/png", "image/jpeg", "image/webp"];
22
+ readonly video: readonly ["video/mp4", "video/webm"];
23
+ readonly character: readonly ["application/octet-stream"];
24
+ };
25
+ export declare const createUploadBodySchema: z.ZodObject<{
26
+ kind: z.ZodEnum<{
27
+ image: "image";
28
+ video: "video";
29
+ character: "character";
30
+ }>;
31
+ contentType: z.ZodString;
32
+ bytes: z.ZodNumber;
33
+ name: z.ZodOptional<z.ZodString>;
34
+ thumbBytes: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$strip>;
36
+ export declare const uploadThumbnailSchema: z.ZodObject<{
37
+ r2Key: z.ZodString;
38
+ uploadUrl: z.ZodURL;
39
+ contentType: z.ZodLiteral<"image/webp">;
40
+ }, z.core.$strip>;
41
+ export declare const createUploadResponseSchema: z.ZodObject<{
42
+ r2Key: z.ZodString;
43
+ uploadUrl: z.ZodURL;
44
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
45
+ expiresAt: z.ZodISODateTime;
46
+ thumb: z.ZodNullable<z.ZodObject<{
47
+ r2Key: z.ZodString;
48
+ uploadUrl: z.ZodURL;
49
+ contentType: z.ZodLiteral<"image/webp">;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>;
52
+ export type UploadKind = z.infer<typeof uploadKindSchema>;
53
+ export type CreateUploadBody = z.infer<typeof createUploadBodySchema>;
54
+ export type CreateUploadResponse = z.infer<typeof createUploadResponseSchema>;
55
+ export type UploadThumbnail = z.infer<typeof uploadThumbnailSchema>;
56
+ //# sourceMappingURL=uploads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../src/v1/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,gBAAgB,QAAqB,CAAA;AAGlD,eAAO,MAAM,mBAAmB,QAAkB,CAAA;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,eAAO,MAAM,sBAAsB,eAAe,CAAA;AAElD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,eAAO,MAAM,YAAY,0CAA2C,CAAA;AACpE,eAAO,MAAM,gBAAgB;;;;EAAuB,CAAA;AAEpD,eAAO,MAAM,oBAAoB;;;;CAI4C,CAAA;AAE7E,eAAO,MAAM,sBAAsB;;;;;;;;;;iBAiBhC,CAAA;AAKH,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAA;AAGF,eAAO,MAAM,0BAA0B;;;;;;;;;;iBAMrC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAC7E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ // One gigabyte. A character carrying a trained LoRA is already 164 MB, so the old 64 MB refused
3
+ // files this platform had itself produced. The pod dispatcher still reads an input into memory on
4
+ // its way to the pod, but it stages them one at a time, so the peak is one file rather than all.
5
+ export const MAX_UPLOAD_BYTES = 1024 * 1024 * 1024;
6
+ // A 512px WebP is a few tens of KB. The cap only stops the second grant being useful for anything
7
+ // but the derivative it was asked for.
8
+ export const MAX_THUMBNAIL_BYTES = 2 * 1024 * 1024;
9
+ /**
10
+ * The long edge of every stored derivative, wherever it is made.
11
+ *
12
+ * Shared because three places make one - the control plane for a pod's takes, the worker for a
13
+ * serverless run's, and the browser for an upload - and a grid that gets a different size depending
14
+ * on which produced it is a grid that looks wrong for reasons nobody can see.
15
+ */
16
+ export const THUMBNAIL_EDGE = 512;
17
+ export const THUMBNAIL_CONTENT_TYPE = 'image/webp';
18
+ // Held here for the same reason as the edge: three encoders, one answer.
19
+ export const THUMBNAIL_QUALITY = 82;
20
+ export const UPLOAD_KINDS = ['image', 'video', 'character'];
21
+ export const uploadKindSchema = z.enum(UPLOAD_KINDS);
22
+ export const UPLOAD_CONTENT_TYPES = {
23
+ image: ['image/png', 'image/jpeg', 'image/webp'],
24
+ video: ['video/mp4', 'video/webm'],
25
+ character: ['application/octet-stream'],
26
+ };
27
+ export const createUploadBodySchema = z
28
+ .object({
29
+ kind: uploadKindSchema,
30
+ contentType: z.string().max(100),
31
+ bytes: z.number().int().positive().max(MAX_UPLOAD_BYTES),
32
+ // The file's own name, kept so the Imported list can show it. Cleaned before it reaches a key.
33
+ name: z.string().max(200).optional(),
34
+ // The exact size of the derivative the caller has already made. Sent up front because a signed
35
+ // PUT binds the length exactly, so the grant cannot be issued before the bytes exist.
36
+ thumbBytes: z.number().int().positive().max(MAX_THUMBNAIL_BYTES).optional(),
37
+ })
38
+ .refine((body) => UPLOAD_CONTENT_TYPES[body.kind].includes(body.contentType), {
39
+ message: 'That content type is not accepted for this kind of upload.',
40
+ path: ['contentType'],
41
+ });
42
+ // A second link for a small WebP of the same image, at a key derived from the first. Null for
43
+ // anything that is not an image. The browser has the file decoded already, so making the derivative
44
+ // there costs nothing per byte; the key is still ours, so a caller cannot choose where it lands.
45
+ export const uploadThumbnailSchema = z.object({
46
+ r2Key: z.string(),
47
+ uploadUrl: z.url(),
48
+ contentType: z.literal('image/webp'),
49
+ });
50
+ // The signed URL binds the key, content type and length, so the PUT must send exactly `headers`.
51
+ export const createUploadResponseSchema = z.object({
52
+ r2Key: z.string(),
53
+ uploadUrl: z.url(),
54
+ headers: z.record(z.string(), z.string()),
55
+ expiresAt: z.iso.datetime(),
56
+ thumb: uploadThumbnailSchema.nullable(),
57
+ });
58
+ //# sourceMappingURL=uploads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../src/v1/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,gGAAgG;AAChG,kGAAkG;AAClG,iGAAiG;AACjG,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAClD,kGAAkG;AAClG,uCAAuC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG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,aAAa,CAAC;CACtB,CACF,CAAA;AAEH,8FAA8F;AAC9F,oGAAoG;AACpG,iGAAiG;AACjG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE;IAClB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;CACrC,CAAC,CAAA;AAEF,iGAAiG;AACjG,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE;IAClB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC3B,KAAK,EAAE,qBAAqB,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ export declare const USERNAME_MIN = 3;
3
+ export declare const USERNAME_MAX = 30;
4
+ export declare const USERNAME_PATTERN: RegExp;
5
+ export declare const RESERVED_USERNAMES: readonly ["about", "admin", "api", "auth", "characters", "help", "login", "logout", "omnichar", "pricing", "privacy", "projects", "root", "settings", "signup", "staff", "support", "team", "terms", "welcome", "workflows"];
6
+ /** Lowercasing is the client's job before it sends, so the API can refuse what it did not mean. */
7
+ export declare function normaliseUsername(raw: string): string;
8
+ export declare function isReservedUsername(name: string): boolean;
9
+ export declare const usernameShapeSchema: z.ZodString;
10
+ export declare const usernameSchema: z.ZodString;
11
+ export declare const usernameAvailableQuerySchema: z.ZodObject<{
12
+ name: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export declare const usernameAvailableSchema: z.ZodObject<{
15
+ available: z.ZodBoolean;
16
+ reason: z.ZodNullable<z.ZodEnum<{
17
+ shape: "shape";
18
+ reserved: "reserved";
19
+ taken: "taken";
20
+ }>>;
21
+ }, z.core.$strip>;
22
+ export declare const claimUsernameBodySchema: z.ZodObject<{
23
+ username: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export declare const claimUsernameResponseSchema: z.ZodObject<{
26
+ username: z.ZodString;
27
+ }, z.core.$strip>;
28
+ export type UsernameAvailable = z.infer<typeof usernameAvailableSchema>;
29
+ export type ClaimUsernameBody = z.infer<typeof claimUsernameBodySchema>;
30
+ export type ClaimUsernameResponse = z.infer<typeof claimUsernameResponseSchema>;
31
+ export declare const myUsernameSchema: z.ZodObject<{
32
+ username: z.ZodNullable<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ export type MyUsername = z.infer<typeof myUsernameSchema>;
35
+ //# sourceMappingURL=usernames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usernames.d.ts","sourceRoot":"","sources":["../../src/v1/usernames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,YAAY,IAAI,CAAA;AAC7B,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,gBAAgB,QAAiB,CAAA;AAK9C,eAAO,MAAM,kBAAkB,8NAsBrB,CAAA;AAEV,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAID,eAAO,MAAM,mBAAmB,aAIN,CAAA;AAE1B,eAAO,MAAM,cAAc,aAEzB,CAAA;AAIF,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;iBAIlC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;iBAAyC,CAAA;AAE7E,eAAO,MAAM,2BAA2B;;iBAAyC,CAAA;AAEjF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAI/E,eAAO,MAAM,gBAAgB;;iBAE3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,67 @@
1
+ import { z } from 'zod';
2
+ // A handle is public, so the character set is deliberately narrow. Uppercase is refused rather than
3
+ // folded, which is what lets a plain unique index behave case-insensitively with no citext extension.
4
+ export const USERNAME_MIN = 3;
5
+ export const USERNAME_MAX = 30;
6
+ export const USERNAME_PATTERN = /^[a-z0-9_]+$/;
7
+ // Out of circulation so a handle can never read as though it belongs to us, or collide with a path
8
+ // if a profile route is ever added. Only words that could actually be claimed are listed: anything
9
+ // with a hyphen, or shorter than the minimum, is already unreachable.
10
+ export const RESERVED_USERNAMES = [
11
+ 'about',
12
+ 'admin',
13
+ 'api',
14
+ 'auth',
15
+ 'characters',
16
+ 'help',
17
+ 'login',
18
+ 'logout',
19
+ 'omnichar',
20
+ 'pricing',
21
+ 'privacy',
22
+ 'projects',
23
+ 'root',
24
+ 'settings',
25
+ 'signup',
26
+ 'staff',
27
+ 'support',
28
+ 'team',
29
+ 'terms',
30
+ 'welcome',
31
+ 'workflows',
32
+ ];
33
+ /** Lowercasing is the client's job before it sends, so the API can refuse what it did not mean. */
34
+ export function normaliseUsername(raw) {
35
+ return raw.trim().toLowerCase();
36
+ }
37
+ export function isReservedUsername(name) {
38
+ return RESERVED_USERNAMES.includes(name);
39
+ }
40
+ // Shape alone, with no opinion on whether the word is spoken for. Separate so a caller can be told
41
+ // which of the two it failed: "too short" and "already ours" are different answers.
42
+ export const usernameShapeSchema = z
43
+ .string()
44
+ .min(USERNAME_MIN)
45
+ .max(USERNAME_MAX)
46
+ .regex(USERNAME_PATTERN);
47
+ export const usernameSchema = usernameShapeSchema.refine((name) => !isReservedUsername(name), {
48
+ message: 'That one is reserved.',
49
+ });
50
+ // Loosely typed on purpose: a live checker wants to be told why a candidate is wrong, so the route
51
+ // answers rather than rejecting the request. The shape is judged in the response, not the schema.
52
+ export const usernameAvailableQuerySchema = z.object({
53
+ name: z.string().min(1).max(64),
54
+ });
55
+ export const usernameAvailableSchema = z.object({
56
+ available: z.boolean(),
57
+ // Why not, when it is not, so the form states a reason instead of guessing at one.
58
+ reason: z.enum(['shape', 'reserved', 'taken']).nullable(),
59
+ });
60
+ export const claimUsernameBodySchema = z.object({ username: usernameSchema });
61
+ export const claimUsernameResponseSchema = z.object({ username: usernameSchema });
62
+ // The caller's own username, or null when they have not set one. Its own response rather than a
63
+ // field on /v1/me, because that route is behind the alpha gate and this is not.
64
+ export const myUsernameSchema = z.object({
65
+ username: z.string().nullable(),
66
+ });
67
+ //# sourceMappingURL=usernames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usernames.js","sourceRoot":"","sources":["../../src/v1/usernames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,oGAAoG;AACpG,sGAAsG;AACtG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAA;AAC7B,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAE9C,mGAAmG;AACnG,mGAAmG;AACnG,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,YAAY;IACZ,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACN,UAA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E,cAAc,EAAE,CAAC,CAAA;AAE7E,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAA;AAMjF,gGAAgG;AAChG,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAA"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * What a reference-to-video run costs, in credits, before it is run.
3
+ *
4
+ * Unlike a GPU run there is nothing to meter: the price follows from the duration, the resolution
5
+ * and the number of references, all of which the caller picks. So the form shows the exact number,
6
+ * the charge equals the quote, and a run that cannot be afforded is refused with the settings that
7
+ * would fit rather than a bare "not enough credits".
8
+ *
9
+ * The rates below are what a caller pays. What the run costs us is server-side
10
+ * (`services/pricing/videoCost.ts`), and a test there recomputes this table so the two cannot drift.
11
+ */
12
+ export declare const VIDEO_RESOLUTIONS: readonly ["480p", "768p", "2K", "4K"];
13
+ export type VideoResolution = (typeof VIDEO_RESOLUTIONS)[number];
14
+ /** Whole seconds, as the model accepts them. */
15
+ export declare const MIN_VIDEO_SECONDS = 5;
16
+ export declare const MAX_VIDEO_SECONDS = 15;
17
+ export declare const VIDEO_MICRO_PER_SECOND: Record<VideoResolution, number>;
18
+ export declare const FREE_VIDEO_REFERENCES = 5;
19
+ export declare const VIDEO_MICRO_PER_EXTRA_REFERENCE = 16000000;
20
+ export declare const VIDEO_ASPECT_RATIOS: readonly ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
21
+ export type VideoAspectRatio = (typeof VIDEO_ASPECT_RATIOS)[number];
22
+ export declare const VIDEO_SHORT_EDGE: Record<VideoResolution, number>;
23
+ export type VideoQuoteInput = {
24
+ resolution: VideoResolution;
25
+ seconds: number;
26
+ aspectRatio?: VideoAspectRatio;
27
+ /** Every reference the run sends, a character's own included. */
28
+ referenceImages?: number;
29
+ };
30
+ export declare class VideoQuoteError extends Error {
31
+ }
32
+ /**
33
+ * The price of one run, in micro-credits.
34
+ *
35
+ * Throws on anything it cannot price. A quote that fell back to the cheapest tier for an unknown
36
+ * resolution would undercharge silently, which is the one failure nobody would report.
37
+ */
38
+ export declare function videoRunMicro(input: VideoQuoteInput): number;
39
+ /** The same price in whole credits, which is the only form a caller ever sees. */
40
+ export declare function videoRunCredits(input: VideoQuoteInput): number;
41
+ export type VideoAlternative = {
42
+ resolution: VideoResolution;
43
+ seconds: number;
44
+ credits: number;
45
+ };
46
+ /**
47
+ * Settings close to the ones asked for that this balance can afford, dearest first.
48
+ *
49
+ * Offered because the two things that move the price are the two things the caller chose, so a
50
+ * refusal can name a way forward instead of only a number. Same resolution at a shorter duration
51
+ * comes first, since length is usually easier to give up than sharpness.
52
+ */
53
+ export declare function affordableVideoOptions(balanceMicro: number, input: VideoQuoteInput, limit?: number): VideoAlternative[];
54
+ /** What the model accepts, and so the most a run can be billed for. */
55
+ export declare const MAX_VIDEO_REFERENCES = 9;
56
+ /**
57
+ * How many references a run is billed for.
58
+ *
59
+ * A character carries its own references inside the `.char`, so they never appear among the
60
+ * uploads - and the renderer charges for every one it is sent. Billing only the uploads would hand
61
+ * those over free, so a run with a character is billed at the model's cap: the most it can send.
62
+ *
63
+ * Shared rather than restated in a browser: the figure a form shows and the figure a run is charged
64
+ * have to be the same arithmetic, or the price moves between pressing Run and being billed.
65
+ */
66
+ export declare function billedVideoReferences(opts: {
67
+ uploads: number;
68
+ hasCharacter: boolean;
69
+ }): number;
70
+ //# sourceMappingURL=videoPricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"videoPricing.d.ts","sourceRoot":"","sources":["../../src/v1/videoPricing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,iBAAiB,uCAAwC,CAAA;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAi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