@omnichar/contracts 0.2.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 (73) 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/apiKeys.d.ts +38 -0
  18. package/dist/v1/apiKeys.d.ts.map +1 -0
  19. package/dist/v1/apiKeys.js +28 -0
  20. package/dist/v1/apiKeys.js.map +1 -0
  21. package/dist/v1/assets.d.ts +47 -0
  22. package/dist/v1/assets.d.ts.map +1 -0
  23. package/dist/v1/assets.js +24 -0
  24. package/dist/v1/assets.js.map +1 -0
  25. package/dist/v1/capacity.d.ts +48 -0
  26. package/dist/v1/capacity.d.ts.map +1 -0
  27. package/dist/v1/capacity.js +18 -0
  28. package/dist/v1/capacity.js.map +1 -0
  29. package/dist/v1/characters.d.ts +88 -0
  30. package/dist/v1/characters.d.ts.map +1 -0
  31. package/dist/v1/characters.js +59 -0
  32. package/dist/v1/characters.js.map +1 -0
  33. package/dist/v1/common.d.ts +13 -0
  34. package/dist/v1/common.d.ts.map +1 -0
  35. package/dist/v1/common.js +12 -0
  36. package/dist/v1/common.js.map +1 -0
  37. package/dist/v1/credits.d.ts +90 -0
  38. package/dist/v1/credits.d.ts.map +1 -0
  39. package/dist/v1/credits.js +68 -0
  40. package/dist/v1/credits.js.map +1 -0
  41. package/dist/v1/datasets.d.ts +153 -0
  42. package/dist/v1/datasets.d.ts.map +1 -0
  43. package/dist/v1/datasets.js +93 -0
  44. package/dist/v1/datasets.js.map +1 -0
  45. package/dist/v1/health.d.ts +13 -0
  46. package/dist/v1/health.d.ts.map +1 -0
  47. package/dist/v1/health.js +10 -0
  48. package/dist/v1/health.js.map +1 -0
  49. package/dist/v1/index.d.ts +14 -0
  50. package/dist/v1/index.d.ts.map +1 -0
  51. package/dist/v1/index.js +14 -0
  52. package/dist/v1/index.js.map +1 -0
  53. package/dist/v1/me.d.ts +23 -0
  54. package/dist/v1/me.d.ts.map +1 -0
  55. package/dist/v1/me.js +16 -0
  56. package/dist/v1/me.js.map +1 -0
  57. package/dist/v1/plans.d.ts +30 -0
  58. package/dist/v1/plans.d.ts.map +1 -0
  59. package/dist/v1/plans.js +19 -0
  60. package/dist/v1/plans.js.map +1 -0
  61. package/dist/v1/runs.d.ts +359 -0
  62. package/dist/v1/runs.d.ts.map +1 -0
  63. package/dist/v1/runs.js +173 -0
  64. package/dist/v1/runs.js.map +1 -0
  65. package/dist/v1/uploads.d.ts +56 -0
  66. package/dist/v1/uploads.d.ts.map +1 -0
  67. package/dist/v1/uploads.js +56 -0
  68. package/dist/v1/uploads.js.map +1 -0
  69. package/dist/v1/workflows.d.ts +198 -0
  70. package/dist/v1/workflows.d.ts.map +1 -0
  71. package/dist/v1/workflows.js +103 -0
  72. package/dist/v1/workflows.js.map +1 -0
  73. package/package.json +34 -0
@@ -0,0 +1,359 @@
1
+ import { z } from 'zod';
2
+ export declare const RUN_STATUSES: readonly ["queued", "dispatching", "running", "succeeded", "failed", "canceled"];
3
+ export declare const runStatusSchema: z.ZodEnum<{
4
+ queued: "queued";
5
+ dispatching: "dispatching";
6
+ running: "running";
7
+ succeeded: "succeeded";
8
+ failed: "failed";
9
+ canceled: "canceled";
10
+ }>;
11
+ export declare const TERMINAL_RUN_STATUSES: readonly ["succeeded", "failed", "canceled"];
12
+ export declare const runFileSchema: z.ZodObject<{
13
+ r2Key: z.ZodString;
14
+ kind: z.ZodEnum<{
15
+ image: "image";
16
+ video: "video";
17
+ }>;
18
+ contentType: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export declare const createRunBodySchema: z.ZodObject<{
21
+ slug: z.ZodString;
22
+ inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
23
+ files: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
24
+ r2Key: z.ZodString;
25
+ kind: z.ZodEnum<{
26
+ image: "image";
27
+ video: "video";
28
+ }>;
29
+ contentType: z.ZodString;
30
+ }, z.core.$strip>>>;
31
+ characters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
32
+ r2Key: z.ZodString;
33
+ }, z.core.$strip>>>;
34
+ }, z.core.$strip>;
35
+ export declare const createRunResponseSchema: z.ZodObject<{
36
+ runId: z.ZodUUID;
37
+ status: z.ZodEnum<{
38
+ queued: "queued";
39
+ dispatching: "dispatching";
40
+ running: "running";
41
+ succeeded: "succeeded";
42
+ failed: "failed";
43
+ canceled: "canceled";
44
+ }>;
45
+ }, z.core.$strip>;
46
+ export declare const cancelRunResponseSchema: z.ZodObject<{
47
+ runId: z.ZodUUID;
48
+ status: z.ZodEnum<{
49
+ queued: "queued";
50
+ dispatching: "dispatching";
51
+ running: "running";
52
+ succeeded: "succeeded";
53
+ failed: "failed";
54
+ canceled: "canceled";
55
+ }>;
56
+ }, z.core.$strip>;
57
+ export declare const RUN_PHASES: readonly ["queued", "preparing", "loading", "encode", "sample", "decode", "save"];
58
+ export declare const runPhaseSchema: z.ZodEnum<{
59
+ queued: "queued";
60
+ preparing: "preparing";
61
+ loading: "loading";
62
+ encode: "encode";
63
+ sample: "sample";
64
+ decode: "decode";
65
+ save: "save";
66
+ }>;
67
+ export declare const runProgressSchema: z.ZodObject<{
68
+ fraction: z.ZodNullable<z.ZodNumber>;
69
+ at: z.ZodISODateTime;
70
+ phase: z.ZodNullable<z.ZodEnum<{
71
+ queued: "queued";
72
+ preparing: "preparing";
73
+ loading: "loading";
74
+ encode: "encode";
75
+ sample: "sample";
76
+ decode: "decode";
77
+ save: "save";
78
+ }>>;
79
+ step: z.ZodNullable<z.ZodNumber>;
80
+ stepCount: z.ZodNullable<z.ZodNumber>;
81
+ detail: z.ZodNullable<z.ZodString>;
82
+ }, z.core.$strip>;
83
+ export declare const runArtifactSchema: z.ZodObject<{
84
+ id: z.ZodUUID;
85
+ mediaKind: z.ZodString;
86
+ bytes: z.ZodNumber;
87
+ url: z.ZodURL;
88
+ thumbUrl: z.ZodNullable<z.ZodURL>;
89
+ expiresAt: z.ZodISODateTime;
90
+ }, z.core.$strip>;
91
+ export declare const runPreviewSchema: z.ZodObject<{
92
+ url: z.ZodURL;
93
+ thumbUrl: z.ZodNullable<z.ZodURL>;
94
+ mediaKind: z.ZodString;
95
+ }, z.core.$strip>;
96
+ export declare const runSummarySchema: z.ZodObject<{
97
+ id: z.ZodUUID;
98
+ workflowSlug: z.ZodString;
99
+ workflowTitle: z.ZodString;
100
+ runtime: z.ZodEnum<{
101
+ serverless: "serverless";
102
+ pod: "pod";
103
+ }>;
104
+ status: z.ZodEnum<{
105
+ queued: "queued";
106
+ dispatching: "dispatching";
107
+ running: "running";
108
+ succeeded: "succeeded";
109
+ failed: "failed";
110
+ canceled: "canceled";
111
+ }>;
112
+ createdAt: z.ZodISODateTime;
113
+ startedAt: z.ZodNullable<z.ZodISODateTime>;
114
+ finishedAt: z.ZodNullable<z.ZodISODateTime>;
115
+ preview: z.ZodNullable<z.ZodObject<{
116
+ url: z.ZodURL;
117
+ thumbUrl: z.ZodNullable<z.ZodURL>;
118
+ mediaKind: z.ZodString;
119
+ }, z.core.$strip>>;
120
+ credits: z.ZodNullable<z.ZodNumber>;
121
+ estimateCredits: z.ZodNullable<z.ZodNumber>;
122
+ }, z.core.$strip>;
123
+ export declare const runSchema: z.ZodObject<{
124
+ id: z.ZodUUID;
125
+ workflowSlug: z.ZodString;
126
+ workflowTitle: z.ZodString;
127
+ runtime: z.ZodEnum<{
128
+ serverless: "serverless";
129
+ pod: "pod";
130
+ }>;
131
+ status: z.ZodEnum<{
132
+ queued: "queued";
133
+ dispatching: "dispatching";
134
+ running: "running";
135
+ succeeded: "succeeded";
136
+ failed: "failed";
137
+ canceled: "canceled";
138
+ }>;
139
+ createdAt: z.ZodISODateTime;
140
+ startedAt: z.ZodNullable<z.ZodISODateTime>;
141
+ finishedAt: z.ZodNullable<z.ZodISODateTime>;
142
+ preview: z.ZodNullable<z.ZodObject<{
143
+ url: z.ZodURL;
144
+ thumbUrl: z.ZodNullable<z.ZodURL>;
145
+ mediaKind: z.ZodString;
146
+ }, z.core.$strip>>;
147
+ credits: z.ZodNullable<z.ZodNumber>;
148
+ estimateCredits: z.ZodNullable<z.ZodNumber>;
149
+ inputs: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
150
+ error: z.ZodNullable<z.ZodObject<{
151
+ message: z.ZodString;
152
+ }, z.core.$strip>>;
153
+ progress: z.ZodNullable<z.ZodObject<{
154
+ fraction: z.ZodNullable<z.ZodNumber>;
155
+ at: z.ZodISODateTime;
156
+ phase: z.ZodNullable<z.ZodEnum<{
157
+ queued: "queued";
158
+ preparing: "preparing";
159
+ loading: "loading";
160
+ encode: "encode";
161
+ sample: "sample";
162
+ decode: "decode";
163
+ save: "save";
164
+ }>>;
165
+ step: z.ZodNullable<z.ZodNumber>;
166
+ stepCount: z.ZodNullable<z.ZodNumber>;
167
+ detail: z.ZodNullable<z.ZodString>;
168
+ }, z.core.$strip>>;
169
+ artifacts: z.ZodArray<z.ZodObject<{
170
+ id: z.ZodUUID;
171
+ mediaKind: z.ZodString;
172
+ bytes: z.ZodNumber;
173
+ url: z.ZodURL;
174
+ thumbUrl: z.ZodNullable<z.ZodURL>;
175
+ expiresAt: z.ZodISODateTime;
176
+ }, z.core.$strip>>;
177
+ }, z.core.$strip>;
178
+ export declare const runListSchema: z.ZodObject<{
179
+ items: z.ZodArray<z.ZodObject<{
180
+ id: z.ZodUUID;
181
+ workflowSlug: z.ZodString;
182
+ workflowTitle: z.ZodString;
183
+ runtime: z.ZodEnum<{
184
+ serverless: "serverless";
185
+ pod: "pod";
186
+ }>;
187
+ status: z.ZodEnum<{
188
+ queued: "queued";
189
+ dispatching: "dispatching";
190
+ running: "running";
191
+ succeeded: "succeeded";
192
+ failed: "failed";
193
+ canceled: "canceled";
194
+ }>;
195
+ createdAt: z.ZodISODateTime;
196
+ startedAt: z.ZodNullable<z.ZodISODateTime>;
197
+ finishedAt: z.ZodNullable<z.ZodISODateTime>;
198
+ preview: z.ZodNullable<z.ZodObject<{
199
+ url: z.ZodURL;
200
+ thumbUrl: z.ZodNullable<z.ZodURL>;
201
+ mediaKind: z.ZodString;
202
+ }, z.core.$strip>>;
203
+ credits: z.ZodNullable<z.ZodNumber>;
204
+ estimateCredits: z.ZodNullable<z.ZodNumber>;
205
+ }, z.core.$strip>>;
206
+ nextCursor: z.ZodNullable<z.ZodString>;
207
+ total: z.ZodOptional<z.ZodNumber>;
208
+ page: z.ZodOptional<z.ZodNumber>;
209
+ }, z.core.$strip>;
210
+ export declare const runStatusResponseSchema: z.ZodObject<{
211
+ runId: z.ZodUUID;
212
+ status: z.ZodEnum<{
213
+ queued: "queued";
214
+ dispatching: "dispatching";
215
+ running: "running";
216
+ succeeded: "succeeded";
217
+ failed: "failed";
218
+ canceled: "canceled";
219
+ }>;
220
+ finished: z.ZodBoolean;
221
+ progress: z.ZodNullable<z.ZodObject<{
222
+ fraction: z.ZodNullable<z.ZodNumber>;
223
+ at: z.ZodISODateTime;
224
+ phase: z.ZodNullable<z.ZodEnum<{
225
+ queued: "queued";
226
+ preparing: "preparing";
227
+ loading: "loading";
228
+ encode: "encode";
229
+ sample: "sample";
230
+ decode: "decode";
231
+ save: "save";
232
+ }>>;
233
+ step: z.ZodNullable<z.ZodNumber>;
234
+ stepCount: z.ZodNullable<z.ZodNumber>;
235
+ detail: z.ZodNullable<z.ZodString>;
236
+ }, z.core.$strip>>;
237
+ error: z.ZodNullable<z.ZodObject<{
238
+ message: z.ZodString;
239
+ }, z.core.$strip>>;
240
+ createdAt: z.ZodISODateTime;
241
+ startedAt: z.ZodNullable<z.ZodISODateTime>;
242
+ finishedAt: z.ZodNullable<z.ZodISODateTime>;
243
+ outputCount: z.ZodNumber;
244
+ credits: z.ZodNullable<z.ZodNumber>;
245
+ billableMs: z.ZodNullable<z.ZodNumber>;
246
+ }, z.core.$strip>;
247
+ export declare const runOutputsSchema: z.ZodObject<{
248
+ runId: z.ZodUUID;
249
+ status: z.ZodEnum<{
250
+ queued: "queued";
251
+ dispatching: "dispatching";
252
+ running: "running";
253
+ succeeded: "succeeded";
254
+ failed: "failed";
255
+ canceled: "canceled";
256
+ }>;
257
+ outputs: z.ZodArray<z.ZodObject<{
258
+ id: z.ZodUUID;
259
+ mediaKind: z.ZodString;
260
+ bytes: z.ZodNumber;
261
+ url: z.ZodURL;
262
+ thumbUrl: z.ZodNullable<z.ZodURL>;
263
+ expiresAt: z.ZodISODateTime;
264
+ }, z.core.$strip>>;
265
+ }, z.core.$strip>;
266
+ export declare const runsQuerySchema: z.ZodObject<{
267
+ cursor: z.ZodOptional<z.ZodString>;
268
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
269
+ status: z.ZodOptional<z.ZodEnum<{
270
+ queued: "queued";
271
+ dispatching: "dispatching";
272
+ running: "running";
273
+ succeeded: "succeeded";
274
+ failed: "failed";
275
+ canceled: "canceled";
276
+ }>>;
277
+ page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
278
+ }, z.core.$strip>;
279
+ export declare const storageUsageSchema: z.ZodObject<{
280
+ artifactBytes: z.ZodNumber;
281
+ importBytes: z.ZodNumber;
282
+ totalBytes: z.ZodNumber;
283
+ quotaBytes: z.ZodNumber;
284
+ }, z.core.$strip>;
285
+ export declare const runStatsSchema: z.ZodObject<{
286
+ inFlight: z.ZodNumber;
287
+ plan: z.ZodObject<{
288
+ id: z.ZodEnum<{
289
+ free: "free";
290
+ }>;
291
+ name: z.ZodString;
292
+ storageBytes: z.ZodNumber;
293
+ unlimitedCredits: z.ZodBoolean;
294
+ }, z.core.$strip>;
295
+ storage: z.ZodObject<{
296
+ artifactBytes: z.ZodNumber;
297
+ importBytes: z.ZodNumber;
298
+ totalBytes: z.ZodNumber;
299
+ quotaBytes: z.ZodNumber;
300
+ }, z.core.$strip>;
301
+ buckets: z.ZodArray<z.ZodObject<{
302
+ start: z.ZodISODateTime;
303
+ runs: z.ZodNumber;
304
+ failures: z.ZodNumber;
305
+ }, z.core.$strip>>;
306
+ }, z.core.$strip>;
307
+ export declare const artifactsQuerySchema: z.ZodObject<{
308
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
309
+ cursor: z.ZodOptional<z.ZodString>;
310
+ runId: z.ZodOptional<z.ZodUUID>;
311
+ }, z.core.$strip>;
312
+ export declare const artifactSchema: z.ZodObject<{
313
+ id: z.ZodUUID;
314
+ mediaKind: z.ZodString;
315
+ bytes: z.ZodNumber;
316
+ url: z.ZodURL;
317
+ thumbUrl: z.ZodNullable<z.ZodURL>;
318
+ expiresAt: z.ZodISODateTime;
319
+ runId: z.ZodUUID;
320
+ workflowSlug: z.ZodString;
321
+ workflowTitle: z.ZodString;
322
+ createdAt: z.ZodISODateTime;
323
+ }, z.core.$strip>;
324
+ export declare const artifactListSchema: z.ZodObject<{
325
+ items: z.ZodArray<z.ZodObject<{
326
+ id: z.ZodUUID;
327
+ mediaKind: z.ZodString;
328
+ bytes: z.ZodNumber;
329
+ url: z.ZodURL;
330
+ thumbUrl: z.ZodNullable<z.ZodURL>;
331
+ expiresAt: z.ZodISODateTime;
332
+ runId: z.ZodUUID;
333
+ workflowSlug: z.ZodString;
334
+ workflowTitle: z.ZodString;
335
+ createdAt: z.ZodISODateTime;
336
+ }, z.core.$strip>>;
337
+ nextCursor: z.ZodNullable<z.ZodString>;
338
+ }, z.core.$strip>;
339
+ export type RunStatus = z.infer<typeof runStatusSchema>;
340
+ export type RunFile = z.infer<typeof runFileSchema>;
341
+ export type CreateRunBody = z.input<typeof createRunBodySchema>;
342
+ export type CreateRunResponse = z.infer<typeof createRunResponseSchema>;
343
+ export type CancelRunResponse = z.infer<typeof cancelRunResponseSchema>;
344
+ export type RunProgress = z.infer<typeof runProgressSchema>;
345
+ export type RunPhase = z.infer<typeof runPhaseSchema>;
346
+ export type RunArtifact = z.infer<typeof runArtifactSchema>;
347
+ export type RunPreview = z.infer<typeof runPreviewSchema>;
348
+ export type RunSummary = z.infer<typeof runSummarySchema>;
349
+ export type Run = z.infer<typeof runSchema>;
350
+ export type RunList = z.infer<typeof runListSchema>;
351
+ export type RunStatusResponse = z.infer<typeof runStatusResponseSchema>;
352
+ export type RunOutputs = z.infer<typeof runOutputsSchema>;
353
+ export type RunsQuery = z.infer<typeof runsQuerySchema>;
354
+ export type RunStats = z.infer<typeof runStatsSchema>;
355
+ export type StorageUsage = z.infer<typeof storageUsageSchema>;
356
+ export type ArtifactsQuery = z.infer<typeof artifactsQuerySchema>;
357
+ export type Artifact = z.infer<typeof artifactSchema>;
358
+ export type ArtifactList = z.infer<typeof artifactListSchema>;
359
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/v1/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,YAAY,kFAOf,CAAA;AACV,eAAO,MAAM,eAAe;;;;;;;EAAuB,CAAA;AACnD,eAAO,MAAM,qBAAqB,8CAA+C,CAAA;AAEjF,eAAO,MAAM,aAAa;;;;;;;iBAIxB,CAAA;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;iBAO9B,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAGlC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAGlC,CAAA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A;AACrD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
@@ -0,0 +1,173 @@
1
+ import { z } from 'zod';
2
+ import { pageOf, pageQuerySchema } from './common.js';
3
+ import { planSchema } from './plans.js';
4
+ import { workflowRuntimeSchema, workflowSlugSchema } from './workflows.js';
5
+ // This service's vocabulary, not Core's: Core says done|error|cancelled and the dispatcher maps it.
6
+ export const RUN_STATUSES = [
7
+ 'queued',
8
+ 'dispatching',
9
+ 'running',
10
+ 'succeeded',
11
+ 'failed',
12
+ 'canceled',
13
+ ];
14
+ export const runStatusSchema = z.enum(RUN_STATUSES);
15
+ export const TERMINAL_RUN_STATUSES = ['succeeded', 'failed', 'canceled'];
16
+ export const runFileSchema = z.object({
17
+ r2Key: z.string().min(1).max(512),
18
+ kind: z.enum(['image', 'video']),
19
+ contentType: z.string().regex(/^(image|video)\/[\w.+-]+$/),
20
+ });
21
+ // Files and characters are keys from POST /v1/uploads, and only the caller's own are accepted.
22
+ export const createRunBodySchema = z.object({
23
+ slug: workflowSlugSchema,
24
+ // Keyed by the node's public name, then by the setting on it, the way a graph reads. The
25
+ // template lists both, so nothing here is a uuid a caller would have to copy out of a response.
26
+ inputs: z.record(z.string(), z.record(z.string(), z.unknown())).default({}),
27
+ files: z.record(z.string(), runFileSchema).default({}),
28
+ characters: z.record(z.string(), z.object({ r2Key: z.string().min(1).max(512) })).default({}),
29
+ });
30
+ export const createRunResponseSchema = z.object({
31
+ runId: z.uuid(),
32
+ status: runStatusSchema,
33
+ });
34
+ export const cancelRunResponseSchema = z.object({
35
+ runId: z.uuid(),
36
+ status: runStatusSchema,
37
+ });
38
+ // Core's own phase vocabulary (inline_core/runtime/progress.py). Reported rather than translated:
39
+ // naming the stage for a person is the dashboard's job, and a phase added upstream should reach it
40
+ // without a release here.
41
+ export const RUN_PHASES = [
42
+ 'queued',
43
+ 'preparing',
44
+ 'loading',
45
+ 'encode',
46
+ 'sample',
47
+ 'decode',
48
+ 'save',
49
+ ];
50
+ export const runPhaseSchema = z.enum(RUN_PHASES);
51
+ export const runProgressSchema = z.object({
52
+ fraction: z.number().min(0).max(1).nullable(),
53
+ at: z.iso.datetime(),
54
+ // What the run is doing now, from the node that is actually running.
55
+ phase: runPhaseSchema.nullable(),
56
+ // Sampling steps, when the node reports them: "12 of 50" is the only honest progress a diffusion
57
+ // model gives, and a fraction alone hides that a run is moving at all.
58
+ step: z.number().int().nonnegative().nullable(),
59
+ stepCount: z.number().int().positive().nullable(),
60
+ // Core's own line of text for the step, when it sets one.
61
+ detail: z.string().nullable(),
62
+ });
63
+ // A signed link on the media gateway; it expires, so a client refetches rather than keeping it.
64
+ export const runArtifactSchema = z.object({
65
+ id: z.uuid(),
66
+ mediaKind: z.string(),
67
+ bytes: z.number().int().nonnegative(),
68
+ url: z.url(),
69
+ // A small WebP of the same take, for grids. Null when there is none - a video, or an image no
70
+ // derivative could be made from - so a caller falls back to `url` rather than showing a gap.
71
+ thumbUrl: z.url().nullable(),
72
+ expiresAt: z.iso.datetime(),
73
+ });
74
+ // The first take, so a list shows what each run made without fetching every run.
75
+ export const runPreviewSchema = z.object({
76
+ url: z.url(),
77
+ thumbUrl: z.url().nullable(),
78
+ mediaKind: z.string(),
79
+ });
80
+ export const runSummarySchema = z.object({
81
+ id: z.uuid(),
82
+ workflowSlug: z.string(),
83
+ workflowTitle: z.string(),
84
+ runtime: workflowRuntimeSchema,
85
+ status: runStatusSchema,
86
+ createdAt: z.iso.datetime(),
87
+ startedAt: z.iso.datetime().nullable(),
88
+ finishedAt: z.iso.datetime().nullable(),
89
+ preview: runPreviewSchema.nullable(),
90
+ // What the run cost once it settled, or null while it is still going. Zero is a real answer: a run
91
+ // that produced nothing is released and not charged. Credits, never micro-credits.
92
+ credits: z.number().nullable(),
93
+ // What was held when it started, so a list can show a figure before the real one lands.
94
+ estimateCredits: z.number().nullable(),
95
+ });
96
+ export const runSchema = runSummarySchema.extend({
97
+ // What this run was given, in the same shape it would be sent in.
98
+ inputs: z.record(z.string(), z.record(z.string(), z.unknown())),
99
+ error: z.object({ message: z.string() }).nullable(),
100
+ progress: runProgressSchema.nullable(),
101
+ artifacts: z.array(runArtifactSchema),
102
+ });
103
+ export const runListSchema = pageOf(runSummarySchema).extend({
104
+ // Present only when a page number was asked for.
105
+ total: z.number().int().nonnegative().optional(),
106
+ page: z.number().int().min(1).optional(),
107
+ });
108
+ // Cheap to poll: the state of a run and nothing else. GET /runs/:id carries the same fields plus
109
+ // the outputs, which means signing a link for every take on every poll.
110
+ export const runStatusResponseSchema = z.object({
111
+ runId: z.uuid(),
112
+ status: runStatusSchema,
113
+ // True once the run has settled, so a poll loop needs no list of terminal statuses of its own.
114
+ finished: z.boolean(),
115
+ progress: runProgressSchema.nullable(),
116
+ error: z.object({ message: z.string() }).nullable(),
117
+ createdAt: z.iso.datetime(),
118
+ startedAt: z.iso.datetime().nullable(),
119
+ finishedAt: z.iso.datetime().nullable(),
120
+ outputCount: z.number().int().nonnegative(),
121
+ // Null until the run is metered, which happens as it settles. A poll sees the charge land.
122
+ credits: z.number().nullable(),
123
+ // What the run was billed on, so the figure under a result can say how long the GPU actually ran.
124
+ billableMs: z.number().int().nullable(),
125
+ });
126
+ // What the run produced. Links are signed and short-lived, so they are fetched when needed rather
127
+ // than stored; `expiresAt` says when this set stops working.
128
+ export const runOutputsSchema = z.object({
129
+ runId: z.uuid(),
130
+ status: runStatusSchema,
131
+ outputs: z.array(runArtifactSchema),
132
+ });
133
+ // Status is filtered in the query rather than in the client: a page of 25 filtered afterwards can
134
+ // come back empty while more matching runs sit on the next page.
135
+ export const runsQuerySchema = pageQuerySchema.extend({
136
+ status: runStatusSchema.optional(),
137
+ // 1-based. Given, the list answers for that page and says how many runs there are in total, which
138
+ // is what numbered pages need and a cursor cannot tell you. Absent, it pages by cursor as before.
139
+ page: z.coerce.number().int().min(1).max(10_000).optional(),
140
+ });
141
+ // Bytes the caller is keeping: their run outputs plus the files they uploaded.
142
+ export const storageUsageSchema = z.object({
143
+ artifactBytes: z.number().int().nonnegative(),
144
+ importBytes: z.number().int().nonnegative(),
145
+ totalBytes: z.number().int().nonnegative(),
146
+ // What the plan allows, so the dashboard shows a figure against a ceiling rather than alone.
147
+ quotaBytes: z.number().int().positive(),
148
+ });
149
+ // Per hour over the last day. Starts are instants, so a client lays them out on its own clock.
150
+ export const runStatsSchema = z.object({
151
+ inFlight: z.number().int().nonnegative(),
152
+ plan: planSchema,
153
+ storage: storageUsageSchema,
154
+ buckets: z.array(z.object({
155
+ start: z.iso.datetime(),
156
+ runs: z.number().int().nonnegative(),
157
+ failures: z.number().int().nonnegative(),
158
+ })),
159
+ });
160
+ // Every take the caller's runs produced, newest first. `runId` narrows it to one run.
161
+ export const artifactsQuerySchema = z.object({
162
+ limit: z.coerce.number().int().min(1).max(100).default(24),
163
+ cursor: z.string().max(64).optional(),
164
+ runId: z.uuid().optional(),
165
+ });
166
+ export const artifactSchema = runArtifactSchema.extend({
167
+ runId: z.uuid(),
168
+ workflowSlug: z.string(),
169
+ workflowTitle: z.string(),
170
+ createdAt: z.iso.datetime(),
171
+ });
172
+ export const artifactListSchema = pageOf(artifactSchema);
173
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/v1/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAE1E,oGAAoG;AACpG,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,aAAa;IACb,SAAS;IACT,WAAW;IACX,QAAQ;IACR,UAAU;CACF,CAAA;AACV,MAAM,CAAC,MAAM,eAAe,GAA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,EAAE;IACf,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,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;AAGvB,eAAO,MAAM,gBAAgB,QAAmB,CAAA;AAGhD,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,56 @@
1
+ import { z } from 'zod';
2
+ // Equal to the dispatcher's MAX_INPUT_BYTES, which reads every input into memory on its way to a pod.
3
+ export const MAX_UPLOAD_BYTES = 64 * 1024 * 1024;
4
+ // A 512px WebP is a few tens of KB. The cap only stops the second grant being useful for anything
5
+ // but the derivative it was asked for.
6
+ export const MAX_THUMBNAIL_BYTES = 2 * 1024 * 1024;
7
+ /**
8
+ * The long edge of every stored derivative, wherever it is made.
9
+ *
10
+ * Shared because three places make one - the control plane for a pod's takes, the worker for a
11
+ * serverless run's, and the browser for an upload - and a grid that gets a different size depending
12
+ * on which produced it is a grid that looks wrong for reasons nobody can see.
13
+ */
14
+ export const THUMBNAIL_EDGE = 512;
15
+ export const THUMBNAIL_CONTENT_TYPE = 'image/webp';
16
+ // Held here for the same reason as the edge: three encoders, one answer.
17
+ export const THUMBNAIL_QUALITY = 82;
18
+ export const UPLOAD_KINDS = ['image', 'video', 'character'];
19
+ export const uploadKindSchema = z.enum(UPLOAD_KINDS);
20
+ export const UPLOAD_CONTENT_TYPES = {
21
+ image: ['image/png', 'image/jpeg', 'image/webp'],
22
+ video: ['video/mp4', 'video/webm'],
23
+ character: ['application/octet-stream'],
24
+ };
25
+ export const createUploadBodySchema = z
26
+ .object({
27
+ kind: uploadKindSchema,
28
+ contentType: z.string().max(100),
29
+ bytes: z.number().int().positive().max(MAX_UPLOAD_BYTES),
30
+ // The file's own name, kept so the Imported list can show it. Cleaned before it reaches a key.
31
+ name: z.string().max(200).optional(),
32
+ // The exact size of the derivative the caller has already made. Sent up front because a signed
33
+ // PUT binds the length exactly, so the grant cannot be issued before the bytes exist.
34
+ thumbBytes: z.number().int().positive().max(MAX_THUMBNAIL_BYTES).optional(),
35
+ })
36
+ .refine((body) => UPLOAD_CONTENT_TYPES[body.kind].includes(body.contentType), {
37
+ message: 'That content type is not accepted for this kind of upload.',
38
+ path: ['contentType'],
39
+ });
40
+ // A second link for a small WebP of the same image, at a key derived from the first. Null for
41
+ // anything that is not an image. The browser has the file decoded already, so making the derivative
42
+ // there costs nothing per byte; the key is still ours, so a caller cannot choose where it lands.
43
+ export const uploadThumbnailSchema = z.object({
44
+ r2Key: z.string(),
45
+ uploadUrl: z.url(),
46
+ contentType: z.literal('image/webp'),
47
+ });
48
+ // The signed URL binds the key, content type and length, so the PUT must send exactly `headers`.
49
+ export const createUploadResponseSchema = z.object({
50
+ r2Key: z.string(),
51
+ uploadUrl: z.url(),
52
+ headers: z.record(z.string(), z.string()),
53
+ expiresAt: z.iso.datetime(),
54
+ thumb: uploadThumbnailSchema.nullable(),
55
+ });
56
+ //# 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,sGAAsG;AACtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAChD,kGAAkG;AAClG,uCAAuC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAA;AAClD,yEAAyE;AACzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAU,CAAA;AACpE,MAAM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