@fungi.computer/darkroom 0.10.0 → 0.11.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.
- package/README.md +51 -3
- package/dist/app-media-contracts.d.ts +19 -0
- package/dist/cloudflare/provider.d.ts +1 -0
- package/dist/cloudflare/r2-destination.d.ts +2 -0
- package/dist/cloudflare/r2-destination.js +13 -0
- package/dist/cloudflare.d.ts +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +17 -0
- package/dist/media-binding.d.ts +3 -0
- package/dist/media-generation.js +2 -0
- package/dist/media-operation-contract.d.ts +13 -1
- package/dist/media-operation-do.d.ts +6 -0
- package/dist/media-operation-do.js +37 -2
- package/dist/media-operation-owner.d.ts +93 -5
- package/dist/media-operation-owner.js +249 -44
- package/dist/media-operation-storage.d.ts +18 -4
- package/dist/media-operation.js +30 -4
- package/dist/media-written.d.ts +22 -0
- package/dist/media-written.js +20 -0
- package/dist/model-catalog.d.ts +25 -0
- package/dist/model-catalog.js +34 -0
- package/dist/provenance.d.ts +5 -1
- package/dist/provenance.js +2 -1
- package/dist/server.d.ts +56 -2
- package/dist/server.js +44 -0
- package/docs/api/app-media-contracts.md +6 -0
- package/docs/api/cloudflare.md +145 -5
- package/docs/api/index.md +88 -40
- package/docs/api/server.md +431 -44
- package/package.json +2 -2
package/docs/api/server.md
CHANGED
|
@@ -334,23 +334,31 @@ Check host namespace, request identity and inactivity before erasure.
|
|
|
334
334
|
##### erase()
|
|
335
335
|
|
|
336
336
|
```ts
|
|
337
|
-
erase(
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
erase(
|
|
338
|
+
namespace,
|
|
339
|
+
requestId,
|
|
340
|
+
policy?
|
|
341
|
+
): Promise<MediaErasure>;
|
|
340
342
|
```
|
|
341
343
|
|
|
342
|
-
Erase
|
|
344
|
+
Erase the operation and everything it retained or could still write, even
|
|
345
|
+
mid-generation. Erasure is marked first, so an attempt still running, or a lease
|
|
346
|
+
recovered later, can neither transition nor leave output behind: a write that
|
|
347
|
+
lands after the mark is deleted. The marker is never removed, so a crash cannot
|
|
348
|
+
resurrect the operation. Safe to repeat until `clear`; a repeat after a partial
|
|
349
|
+
failure resumes the cleanup.
|
|
343
350
|
|
|
344
351
|
###### Parameters
|
|
345
352
|
|
|
346
|
-
| Parameter | Type
|
|
347
|
-
| ----------- |
|
|
348
|
-
| `namespace` | `string` |
|
|
349
|
-
| `requestId` | `string` |
|
|
353
|
+
| Parameter | Type | Default value |
|
|
354
|
+
| ----------- | --------------------------------------- | ---------------- |
|
|
355
|
+
| `namespace` | `string` | `undefined` |
|
|
356
|
+
| `requestId` | `string` | `undefined` |
|
|
357
|
+
| `policy` | [`MediaErasePolicy`](#mediaerasepolicy) | `"abort-active"` |
|
|
350
358
|
|
|
351
359
|
###### Returns
|
|
352
360
|
|
|
353
|
-
`Promise
|
|
361
|
+
`Promise`\<[`MediaErasure`](#mediaerasure)\>
|
|
354
362
|
|
|
355
363
|
##### readErasure()
|
|
356
364
|
|
|
@@ -366,6 +374,76 @@ Read back empty SQL, alarm and retained output with the durable erasure marker.
|
|
|
366
374
|
|
|
367
375
|
`Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
|
|
368
376
|
|
|
377
|
+
##### retained()
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
retained(namespace, requestId): Promise<
|
|
381
|
+
| Readonly<{
|
|
382
|
+
requestId: string;
|
|
383
|
+
state: | "admitted"
|
|
384
|
+
| "estimating"
|
|
385
|
+
| "generating"
|
|
386
|
+
| "writing"
|
|
387
|
+
| "charging"
|
|
388
|
+
| "written"
|
|
389
|
+
| "succeeded"
|
|
390
|
+
| "interrupted";
|
|
391
|
+
destinationPath: string;
|
|
392
|
+
output: | Readonly<{
|
|
393
|
+
bytes: number;
|
|
394
|
+
format: string;
|
|
395
|
+
contentType: string;
|
|
396
|
+
}>
|
|
397
|
+
| null;
|
|
398
|
+
}>
|
|
399
|
+
| null>;
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
List what this operation retains: its destination path and exact provider
|
|
403
|
+
output. Null once erased.
|
|
404
|
+
|
|
405
|
+
###### Parameters
|
|
406
|
+
|
|
407
|
+
| Parameter | Type |
|
|
408
|
+
| ----------- | -------- |
|
|
409
|
+
| `namespace` | `string` |
|
|
410
|
+
| `requestId` | `string` |
|
|
411
|
+
|
|
412
|
+
###### Returns
|
|
413
|
+
|
|
414
|
+
`Promise`\< \| `Readonly`\<\{ `requestId`: `string`; `state`: \| `"admitted"` \|
|
|
415
|
+
`"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
|
|
416
|
+
\| `"succeeded"` \| `"interrupted"`; `destinationPath`: `string`; `output`: \|
|
|
417
|
+
`Readonly`\<\{ `bytes`: `number`; `format`: `string`; `contentType`: `string`;
|
|
418
|
+
\}\> \| `null`; \}\> \| `null`\>
|
|
419
|
+
|
|
420
|
+
##### readRetained()
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
readRetained(namespace, requestId): Promise<
|
|
424
|
+
| Readonly<{
|
|
425
|
+
bytes: Uint8Array;
|
|
426
|
+
format: string;
|
|
427
|
+
}>
|
|
428
|
+
| null>;
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Read back the exact retained provider bytes, before any provenance, so a host
|
|
432
|
+
can re-save a result whose destination write was lost. Null when erased or
|
|
433
|
+
nothing was retained.
|
|
434
|
+
|
|
435
|
+
###### Parameters
|
|
436
|
+
|
|
437
|
+
| Parameter | Type |
|
|
438
|
+
| ----------- | -------- |
|
|
439
|
+
| `namespace` | `string` |
|
|
440
|
+
| `requestId` | `string` |
|
|
441
|
+
|
|
442
|
+
###### Returns
|
|
443
|
+
|
|
444
|
+
`Promise`\< \| `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: `string`; \}\> \|
|
|
445
|
+
`null`\>
|
|
446
|
+
|
|
369
447
|
##### admit()
|
|
370
448
|
|
|
371
449
|
```ts
|
|
@@ -646,6 +724,28 @@ A fixed-path exact-byte save is safe to retry without repeating generation.
|
|
|
646
724
|
|
|
647
725
|
[`MediaOperationProjection`](#mediaoperationprojection)
|
|
648
726
|
|
|
727
|
+
##### recordWriteIntent()
|
|
728
|
+
|
|
729
|
+
```ts
|
|
730
|
+
recordWriteIntent(leaseId, sha256): MediaOperationProjection;
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
Record the digest of the exact bytes about to be written to the destination,
|
|
734
|
+
before writing them. An erasure then knows which file this operation owns, even
|
|
735
|
+
if the process dies between the write and its record, and refuses the write once
|
|
736
|
+
erased.
|
|
737
|
+
|
|
738
|
+
###### Parameters
|
|
739
|
+
|
|
740
|
+
| Parameter | Type |
|
|
741
|
+
| --------- | -------- |
|
|
742
|
+
| `leaseId` | `string` |
|
|
743
|
+
| `sha256` | `string` |
|
|
744
|
+
|
|
745
|
+
###### Returns
|
|
746
|
+
|
|
747
|
+
[`MediaOperationProjection`](#mediaoperationprojection)
|
|
748
|
+
|
|
649
749
|
##### recordWritten()
|
|
650
750
|
|
|
651
751
|
```ts
|
|
@@ -1034,6 +1134,10 @@ type MediaOperation = {
|
|
|
1034
1134
|
| "recordWrittenWithoutSettlement"
|
|
1035
1135
|
| "releaseEstimate"
|
|
1036
1136
|
| "releaseWrite"
|
|
1137
|
+
| "recordWriteIntent"
|
|
1138
|
+
| "retained"
|
|
1139
|
+
| "readRetained"
|
|
1140
|
+
| "erase"
|
|
1037
1141
|
]: (
|
|
1038
1142
|
input: Parameters<MediaOperationOwner[Method]>,
|
|
1039
1143
|
) =>
|
|
@@ -1173,6 +1277,63 @@ Evidence that retained output, SQL and alarms were erased.
|
|
|
1173
1277
|
|
|
1174
1278
|
---
|
|
1175
1279
|
|
|
1280
|
+
### MediaErasePolicy
|
|
1281
|
+
|
|
1282
|
+
```ts
|
|
1283
|
+
type MediaErasePolicy = "abort-active" | "refuse-active";
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
How `erase` treats an operation that is still generating or saving.
|
|
1287
|
+
|
|
1288
|
+
---
|
|
1289
|
+
|
|
1290
|
+
### MediaErasure
|
|
1291
|
+
|
|
1292
|
+
```ts
|
|
1293
|
+
type MediaErasure = MediaErasureReadback &
|
|
1294
|
+
Readonly<{
|
|
1295
|
+
destinationPath: string | null;
|
|
1296
|
+
writtenSha256: string | null;
|
|
1297
|
+
abandonedGeneration: boolean;
|
|
1298
|
+
}>;
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
Result of erasing one operation: readback plus what the host may still own.
|
|
1302
|
+
|
|
1303
|
+
---
|
|
1304
|
+
|
|
1305
|
+
### MediaRetainedBytes
|
|
1306
|
+
|
|
1307
|
+
```ts
|
|
1308
|
+
type MediaRetainedBytes = Readonly<{
|
|
1309
|
+
bytes: Uint8Array;
|
|
1310
|
+
format: string;
|
|
1311
|
+
}>;
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
Exact provider bytes an operation retained, before any provenance.
|
|
1315
|
+
|
|
1316
|
+
---
|
|
1317
|
+
|
|
1318
|
+
### MediaRetained
|
|
1319
|
+
|
|
1320
|
+
```ts
|
|
1321
|
+
type MediaRetained = Readonly<{
|
|
1322
|
+
requestId: string;
|
|
1323
|
+
state: MediaOperationState;
|
|
1324
|
+
destinationPath: string;
|
|
1325
|
+
output: Readonly<{
|
|
1326
|
+
bytes: number;
|
|
1327
|
+
format: string;
|
|
1328
|
+
contentType: string;
|
|
1329
|
+
}> | null;
|
|
1330
|
+
}>;
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
What one operation still retains, readable by operation id.
|
|
1334
|
+
|
|
1335
|
+
---
|
|
1336
|
+
|
|
1176
1337
|
### MediaRetentionResult
|
|
1177
1338
|
|
|
1178
1339
|
```ts
|
|
@@ -1213,6 +1374,21 @@ Retained-output storage supplied by the host.
|
|
|
1213
1374
|
|
|
1214
1375
|
---
|
|
1215
1376
|
|
|
1377
|
+
### MediaErasureMarker
|
|
1378
|
+
|
|
1379
|
+
```ts
|
|
1380
|
+
type MediaErasureMarker = Readonly<{
|
|
1381
|
+
destinationPath: string | null;
|
|
1382
|
+
writtenSha256: string | null;
|
|
1383
|
+
abandonedGeneration: boolean;
|
|
1384
|
+
}>;
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
Facts an erased operation keeps: its destination file, and whether a billing
|
|
1388
|
+
hold may be open.
|
|
1389
|
+
|
|
1390
|
+
---
|
|
1391
|
+
|
|
1216
1392
|
### MediaOperationStorage
|
|
1217
1393
|
|
|
1218
1394
|
```ts
|
|
@@ -1293,15 +1469,42 @@ Read the durable erasure marker.
|
|
|
1293
1469
|
##### markErased()
|
|
1294
1470
|
|
|
1295
1471
|
```ts
|
|
1296
|
-
markErased(): Promise<void>;
|
|
1472
|
+
markErased(marker): Promise<void>;
|
|
1297
1473
|
```
|
|
1298
1474
|
|
|
1299
|
-
Persist the durable erasure marker.
|
|
1475
|
+
Persist the durable erasure marker with the facts the host needs after erasure.
|
|
1476
|
+
Never removed: nothing may delete it.
|
|
1477
|
+
|
|
1478
|
+
###### Parameters
|
|
1479
|
+
|
|
1480
|
+
| Parameter | Type |
|
|
1481
|
+
| --------- | ------------------------------------------- |
|
|
1482
|
+
| `marker` | [`MediaErasureMarker`](#mediaerasuremarker) |
|
|
1300
1483
|
|
|
1301
1484
|
###### Returns
|
|
1302
1485
|
|
|
1303
1486
|
`Promise`\<`void`\>
|
|
1304
1487
|
|
|
1488
|
+
##### readErasureMarker()
|
|
1489
|
+
|
|
1490
|
+
```ts
|
|
1491
|
+
readErasureMarker(): Promise<
|
|
1492
|
+
| Readonly<{
|
|
1493
|
+
destinationPath: string | null;
|
|
1494
|
+
writtenSha256: string | null;
|
|
1495
|
+
abandonedGeneration: boolean;
|
|
1496
|
+
}>
|
|
1497
|
+
| null>;
|
|
1498
|
+
```
|
|
1499
|
+
|
|
1500
|
+
Read the facts kept with the marker, or null for a marker without them.
|
|
1501
|
+
|
|
1502
|
+
###### Returns
|
|
1503
|
+
|
|
1504
|
+
`Promise`\< \| `Readonly`\<\{ `destinationPath`: `string` \| `null`;
|
|
1505
|
+
`writtenSha256`: `string` \| `null`; `abandonedGeneration`: `boolean`; \}\> \|
|
|
1506
|
+
`null`\>
|
|
1507
|
+
|
|
1305
1508
|
##### listKeys()
|
|
1306
1509
|
|
|
1307
1510
|
```ts
|
|
@@ -1326,13 +1529,19 @@ Remove any scheduled background alarm.
|
|
|
1326
1529
|
|
|
1327
1530
|
`Promise`\<`void`\>
|
|
1328
1531
|
|
|
1329
|
-
#####
|
|
1532
|
+
##### deleteKeys()
|
|
1330
1533
|
|
|
1331
1534
|
```ts
|
|
1332
|
-
|
|
1535
|
+
deleteKeys(keys): Promise<void>;
|
|
1333
1536
|
```
|
|
1334
1537
|
|
|
1335
|
-
Remove
|
|
1538
|
+
Remove the named key-value entries.
|
|
1539
|
+
|
|
1540
|
+
###### Parameters
|
|
1541
|
+
|
|
1542
|
+
| Parameter | Type |
|
|
1543
|
+
| --------- | ------------------- |
|
|
1544
|
+
| `keys` | readonly `string`[] |
|
|
1336
1545
|
|
|
1337
1546
|
###### Returns
|
|
1338
1547
|
|
|
@@ -1581,6 +1790,16 @@ The provider cost of one exact generation request, before any billing policy.
|
|
|
1581
1790
|
|
|
1582
1791
|
---
|
|
1583
1792
|
|
|
1793
|
+
### MediaRemoval
|
|
1794
|
+
|
|
1795
|
+
```ts
|
|
1796
|
+
type MediaRemoval = "removed" | "absent" | "not-ours" | "kept";
|
|
1797
|
+
```
|
|
1798
|
+
|
|
1799
|
+
What a destination did when asked to delete a file this operation wrote.
|
|
1800
|
+
|
|
1801
|
+
---
|
|
1802
|
+
|
|
1584
1803
|
### HostReferenceSource
|
|
1585
1804
|
|
|
1586
1805
|
```ts
|
|
@@ -1633,9 +1852,11 @@ type MediaServiceHost = Readonly<{
|
|
|
1633
1852
|
destination: Readonly<{
|
|
1634
1853
|
authorize: (path) => Promise<void>;
|
|
1635
1854
|
write: (path, bytes) => Promise<void>;
|
|
1855
|
+
remove: (path, written) => Promise<MediaRemoval>;
|
|
1636
1856
|
readReference?: (reference, model) => Promise<MediaReferenceBytes>;
|
|
1637
1857
|
readAudioReference?: (reference) => Promise<Uint8Array>;
|
|
1638
1858
|
}>;
|
|
1859
|
+
embedPrompt?: boolean;
|
|
1639
1860
|
onFailure?: (error) => Response | undefined;
|
|
1640
1861
|
}> &
|
|
1641
1862
|
| Readonly<{
|
|
@@ -1668,6 +1889,7 @@ type MediaGenerationRequest = Readonly<{
|
|
|
1668
1889
|
path: string;
|
|
1669
1890
|
settings: Parameters<typeof validateMediaGenerationSettings>[0];
|
|
1670
1891
|
outputFormat?: z.output<typeof mediaRequestSchema>["outputFormat"];
|
|
1892
|
+
embedPrompt?: boolean;
|
|
1671
1893
|
}>;
|
|
1672
1894
|
```
|
|
1673
1895
|
|
|
@@ -1707,6 +1929,19 @@ type MediaGenerationOutcome =
|
|
|
1707
1929
|
|
|
1708
1930
|
The typed result of one generation, shared by the Hono route and the Agent path.
|
|
1709
1931
|
|
|
1932
|
+
---
|
|
1933
|
+
|
|
1934
|
+
### MediaOperationErasure
|
|
1935
|
+
|
|
1936
|
+
```ts
|
|
1937
|
+
type MediaOperationErasure = MediaErasure &
|
|
1938
|
+
Readonly<{
|
|
1939
|
+
destinationFile: MediaRemoval | null;
|
|
1940
|
+
}>;
|
|
1941
|
+
```
|
|
1942
|
+
|
|
1943
|
+
Erasure of one generation, with what happened to its destination file.
|
|
1944
|
+
|
|
1710
1945
|
## Variables
|
|
1711
1946
|
|
|
1712
1947
|
### mediaImageBindingInputSchema
|
|
@@ -1719,6 +1954,7 @@ const mediaImageBindingInputSchema: ZodObject<{
|
|
|
1719
1954
|
settings: ZodObject<{
|
|
1720
1955
|
model: ZodString;
|
|
1721
1956
|
prompt: ZodString;
|
|
1957
|
+
guidance: ZodOptional<ZodNumber>;
|
|
1722
1958
|
targetMegapixels: ZodOptional<ZodNumber>;
|
|
1723
1959
|
resolution: ZodOptional<ZodEnum<{
|
|
1724
1960
|
p480: "480p";
|
|
@@ -1823,6 +2059,7 @@ const mediaBindingGenerationSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
1823
2059
|
settings: ZodObject<{
|
|
1824
2060
|
model: ZodString;
|
|
1825
2061
|
prompt: ZodString;
|
|
2062
|
+
guidance: ZodOptional<ZodNumber>;
|
|
1826
2063
|
targetMegapixels: ZodOptional<ZodNumber>;
|
|
1827
2064
|
resolution: ZodOptional<ZodEnum<{
|
|
1828
2065
|
p480: "480p";
|
|
@@ -1928,6 +2165,7 @@ const mediaBindingCallSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
1928
2165
|
settings: ZodObject<{
|
|
1929
2166
|
model: ZodString;
|
|
1930
2167
|
prompt: ZodString;
|
|
2168
|
+
guidance: ZodOptional<...>;
|
|
1931
2169
|
targetMegapixels: ZodOptional<...>;
|
|
1932
2170
|
resolution: ZodOptional<...>;
|
|
1933
2171
|
aspectRatio: ZodOptional<...>;
|
|
@@ -2129,6 +2367,7 @@ const mediaRequestSchema: ZodObject<{
|
|
|
2129
2367
|
width: ZodOptional<ZodNumber>;
|
|
2130
2368
|
height: ZodOptional<ZodNumber>;
|
|
2131
2369
|
steps: ZodOptional<ZodNumber>;
|
|
2370
|
+
guidance: ZodOptional<ZodNumber>;
|
|
2132
2371
|
durationSeconds: ZodOptional<ZodNumber>;
|
|
2133
2372
|
targetMegapixels: ZodOptional<ZodNumber>;
|
|
2134
2373
|
voiceId: ZodOptional<ZodString>;
|
|
@@ -2201,6 +2440,7 @@ Quote the catalog defaults through the exact estimator used before dispatch.
|
|
|
2201
2440
|
| `settings.width?` | `number` | Requested image width or nominal video resolution/aspect selector; absent for audio. |
|
|
2202
2441
|
| `settings.height?` | `number` | Requested image height or nominal video resolution/aspect selector; absent for audio. |
|
|
2203
2442
|
| `settings.steps?` | `number` | Model-specific inference steps. |
|
|
2443
|
+
| `settings.guidance?` | `number` | Prompt guidance for models that take it; the catalog default when omitted. |
|
|
2204
2444
|
| `settings.durationSeconds?` | `number` | Video and music models only: output length in whole seconds. |
|
|
2205
2445
|
| `settings.targetMegapixels?` | `number` | Upscale only: the output size in megapixels. |
|
|
2206
2446
|
| `settings.voiceId?` | `string` | Speech models only: the catalog voice that reads the prompt. |
|
|
@@ -2275,6 +2515,7 @@ function parseMediaBindingCall(raw):
|
|
|
2275
2515
|
settings: {
|
|
2276
2516
|
model: string;
|
|
2277
2517
|
prompt: string;
|
|
2518
|
+
guidance?: number;
|
|
2278
2519
|
targetMegapixels?: number;
|
|
2279
2520
|
resolution?: "480p" | "720p" | "768p" | "1080p" | "4k";
|
|
2280
2521
|
aspectRatio?:
|
|
@@ -2345,10 +2586,10 @@ Parsing and model refusal stay shared; authorization remains host-owned.
|
|
|
2345
2586
|
\| `Readonly`\<\{ `kind`: `"parsed"`; `call`: \| \{ `operation`: `"models"`;
|
|
2346
2587
|
`input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`;
|
|
2347
2588
|
`input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`:
|
|
2348
|
-
`string`; `settings`: \{ `model`: `string`; `prompt`: `string`;
|
|
2349
|
-
`targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \|
|
|
2350
|
-
\| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"`
|
|
2351
|
-
`"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`;
|
|
2589
|
+
`string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `guidance?`:
|
|
2590
|
+
`number`; `targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \|
|
|
2591
|
+
`"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"`
|
|
2592
|
+
\| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`;
|
|
2352
2593
|
`references?`: `object`[]; `width`: `number`; `height`: `number`; `steps?`:
|
|
2353
2594
|
`number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`:
|
|
2354
2595
|
`"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{
|
|
@@ -2377,10 +2618,10 @@ Choose the same fixed filename on both hosts without a recursive App lookup.
|
|
|
2377
2618
|
|
|
2378
2619
|
#### Parameters
|
|
2379
2620
|
|
|
2380
|
-
| Parameter | Type
|
|
2381
|
-
| ------------ |
|
|
2382
|
-
| `input` | \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \} |
|
|
2383
|
-
| `computerId` | `string`
|
|
2621
|
+
| Parameter | Type |
|
|
2622
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2623
|
+
| `input` | \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `guidance?`: `number`; `targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \} |
|
|
2624
|
+
| `computerId` | `string` |
|
|
2384
2625
|
|
|
2385
2626
|
#### Returns
|
|
2386
2627
|
|
|
@@ -2398,11 +2639,11 @@ Decode bounded service replies once for both MEDIA host bindings.
|
|
|
2398
2639
|
|
|
2399
2640
|
#### Parameters
|
|
2400
2641
|
|
|
2401
|
-
| Parameter | Type
|
|
2402
|
-
| ------------ |
|
|
2403
|
-
| `input` | \| \{ `operation`: `"models"`; `input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`; `input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \}; \} |
|
|
2404
|
-
| `computerId` | `string`
|
|
2405
|
-
| `response` | `Response`
|
|
2642
|
+
| Parameter | Type |
|
|
2643
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2644
|
+
| `input` | \| \{ `operation`: `"models"`; `input`: `Record`\<`string`, `never`\>; \} \| \{ `operation`: `"generate"`; `input`: \| \{ `kind`: `"image"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: `string`; `prompt`: `string`; `guidance?`: `number`; `targetMegapixels?`: `number`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `width`: `number`; `height`: `number`; `steps?`: `number`; \}; `outputFormat?`: `"png"` \| `"jpeg"` \| `"webp"`; \} \| \{ `kind`: `"video"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"bytedance/seedance-2.5"` \| `"bytedance/seedance-2.0"` \| `"bytedance/seedance-2.0-fast"` \| `"bytedance/seedance-2.0-mini"` \| `"google/veo-3.1"` \| `"google/veo-3.1-fast"` \| `"minimax/h3-max"`; `prompt`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `durationSeconds?`: `number`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \}; \} \| \{ `kind`: `"audio"`; `requestId`: `string`; `libraryPath`: `string`; `settings`: \{ `model`: \| `"elevenlabs/eleven-multilingual-v2"` \| `"elevenlabs/eleven-v3"` \| `"elevenlabs/music-v2"`; `prompt`: `string`; `voiceId?`: `string`; `durationSeconds?`: `number`; \}; \}; \} |
|
|
2645
|
+
| `computerId` | `string` |
|
|
2646
|
+
| `response` | `Response` |
|
|
2406
2647
|
|
|
2407
2648
|
#### Returns
|
|
2408
2649
|
|
|
@@ -2434,23 +2675,24 @@ way its metering does, so the number matches the charge.
|
|
|
2434
2675
|
|
|
2435
2676
|
#### Parameters
|
|
2436
2677
|
|
|
2437
|
-
| Parameter | Type
|
|
2438
|
-
| ----------------------- |
|
|
2439
|
-
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width?`: `number`; `height?`: `number`; `steps?`: `number`; `durationSeconds?`: `number`; `targetMegapixels?`: `number`; `voiceId?`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \} | - |
|
|
2440
|
-
| `raw.model` | `string`
|
|
2441
|
-
| `raw.prompt` | `string`
|
|
2442
|
-
| `raw.width?` | `number`
|
|
2443
|
-
| `raw.height?` | `number`
|
|
2444
|
-
| `raw.steps?` | `number`
|
|
2445
|
-
| `raw.
|
|
2446
|
-
| `raw.
|
|
2447
|
-
| `raw.
|
|
2448
|
-
| `raw.
|
|
2449
|
-
| `raw.
|
|
2450
|
-
| `raw.
|
|
2451
|
-
| `raw.
|
|
2452
|
-
| `raw.
|
|
2453
|
-
| `
|
|
2678
|
+
| Parameter | Type | Description |
|
|
2679
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
2680
|
+
| `raw` | \{ `model`: `string`; `prompt`: `string`; `width?`: `number`; `height?`: `number`; `steps?`: `number`; `guidance?`: `number`; `durationSeconds?`: `number`; `targetMegapixels?`: `number`; `voiceId?`: `string`; `resolution?`: `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"`; `aspectRatio?`: `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"`; `generateAudio?`: `boolean`; `references?`: `object`[]; `audioReferences?`: `object`[]; \} | - |
|
|
2681
|
+
| `raw.model` | `string` | Provider catalog model identifier. |
|
|
2682
|
+
| `raw.prompt` | `string` | Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. |
|
|
2683
|
+
| `raw.width?` | `number` | Requested image width or nominal video selector; absent for audio. |
|
|
2684
|
+
| `raw.height?` | `number` | Requested image height or nominal video selector; absent for audio. |
|
|
2685
|
+
| `raw.steps?` | `number` | Model-specific inference step count. |
|
|
2686
|
+
| `raw.guidance?` | `number` | Prompt guidance; models without a catalog guidance range refuse it. |
|
|
2687
|
+
| `raw.durationSeconds?` | `number` | Requested video or music length in whole seconds. |
|
|
2688
|
+
| `raw.targetMegapixels?` | `number` | Upscale only: the output size in megapixels, one of the model's offered sizes. |
|
|
2689
|
+
| `raw.voiceId?` | `string` | Speech models only: a premade voice from the catalog; the default when omitted. |
|
|
2690
|
+
| `raw.resolution?` | `"480p"` \| `"720p"` \| `"768p"` \| `"1080p"` \| `"4k"` | Video resolution; must match the nominal width/height selector. |
|
|
2691
|
+
| `raw.aspectRatio?` | `"16:9"` \| `"4:3"` \| `"1:1"` \| `"3:4"` \| `"9:16"` \| `"21:9"` \| `"9:21"` | Video aspect; must match the nominal width/height selector. |
|
|
2692
|
+
| `raw.generateAudio?` | `boolean` | Video audio selection. |
|
|
2693
|
+
| `raw.references?` | `object`[] | Host-authorized reference images. |
|
|
2694
|
+
| `raw.audioReferences?` | `object`[] | Host-authorized reference audio clips; only a model declaring `audioReferences` takes them. |
|
|
2695
|
+
| `references` | [`MediaReferenceReader`](index.md#mediareferencereader) | - |
|
|
2454
2696
|
|
|
2455
2697
|
#### Returns
|
|
2456
2698
|
|
|
@@ -2460,6 +2702,48 @@ way its metering does, so the number matches the charge.
|
|
|
2460
2702
|
|
|
2461
2703
|
---
|
|
2462
2704
|
|
|
2705
|
+
### mediaWrittenDigest()
|
|
2706
|
+
|
|
2707
|
+
```ts
|
|
2708
|
+
function mediaWrittenDigest(bytes): Promise<string>;
|
|
2709
|
+
```
|
|
2710
|
+
|
|
2711
|
+
Lowercase hex SHA-256 of the exact bytes written to a destination.
|
|
2712
|
+
|
|
2713
|
+
#### Parameters
|
|
2714
|
+
|
|
2715
|
+
| Parameter | Type |
|
|
2716
|
+
| --------- | ------------ |
|
|
2717
|
+
| `bytes` | `Uint8Array` |
|
|
2718
|
+
|
|
2719
|
+
#### Returns
|
|
2720
|
+
|
|
2721
|
+
`Promise`\<`string`\>
|
|
2722
|
+
|
|
2723
|
+
---
|
|
2724
|
+
|
|
2725
|
+
### removeMediaIfWritten()
|
|
2726
|
+
|
|
2727
|
+
```ts
|
|
2728
|
+
function removeMediaIfWritten(file, sha256): Promise<MediaRemoval>;
|
|
2729
|
+
```
|
|
2730
|
+
|
|
2731
|
+
Delete the file at a destination path only while it still holds the exact bytes
|
|
2732
|
+
the operation wrote, so a path reused for something else is never lost.
|
|
2733
|
+
|
|
2734
|
+
#### Parameters
|
|
2735
|
+
|
|
2736
|
+
| Parameter | Type |
|
|
2737
|
+
| --------- | ----------------------------------------------------------------------------------------------------------- |
|
|
2738
|
+
| `file` | `Readonly`\<\{ `read`: () => `Promise`\<`Uint8Array` \| `null`\>; `delete`: () => `Promise`\<`void`\>; \}\> |
|
|
2739
|
+
| `sha256` | `string` |
|
|
2740
|
+
|
|
2741
|
+
#### Returns
|
|
2742
|
+
|
|
2743
|
+
`Promise`\<[`MediaRemoval`](#mediaremoval)\>
|
|
2744
|
+
|
|
2745
|
+
---
|
|
2746
|
+
|
|
2463
2747
|
### readHostReference()
|
|
2464
2748
|
|
|
2465
2749
|
```ts
|
|
@@ -2526,6 +2810,109 @@ failures.
|
|
|
2526
2810
|
|
|
2527
2811
|
---
|
|
2528
2812
|
|
|
2813
|
+
### retainedMedia()
|
|
2814
|
+
|
|
2815
|
+
```ts
|
|
2816
|
+
function retainedMedia(
|
|
2817
|
+
host,
|
|
2818
|
+
requestId,
|
|
2819
|
+
): Promise<Readonly<{
|
|
2820
|
+
requestId: string;
|
|
2821
|
+
state:
|
|
2822
|
+
| "admitted"
|
|
2823
|
+
| "estimating"
|
|
2824
|
+
| "generating"
|
|
2825
|
+
| "writing"
|
|
2826
|
+
| "charging"
|
|
2827
|
+
| "written"
|
|
2828
|
+
| "succeeded"
|
|
2829
|
+
| "interrupted";
|
|
2830
|
+
destinationPath: string;
|
|
2831
|
+
output: Readonly<{
|
|
2832
|
+
bytes: number;
|
|
2833
|
+
format: string;
|
|
2834
|
+
contentType: string;
|
|
2835
|
+
}> | null;
|
|
2836
|
+
}> | null>;
|
|
2837
|
+
```
|
|
2838
|
+
|
|
2839
|
+
What one generation still retains, by its request id: where its file goes, and
|
|
2840
|
+
the exact provider bytes held for recovery, including bytes a crash left
|
|
2841
|
+
unrecorded. Null once erased. Refuses another namespace.
|
|
2842
|
+
|
|
2843
|
+
#### Parameters
|
|
2844
|
+
|
|
2845
|
+
| Parameter | Type |
|
|
2846
|
+
| ----------- | ------------------------------------------------------------------------------ |
|
|
2847
|
+
| `host` | `Pick`\<[`MediaServiceHost`](#mediaservicehost), `"operations"` \| `"scope"`\> |
|
|
2848
|
+
| `requestId` | `string` |
|
|
2849
|
+
|
|
2850
|
+
#### Returns
|
|
2851
|
+
|
|
2852
|
+
`Promise`\< \| `Readonly`\<\{ `requestId`: `string`; `state`: \| `"admitted"` \|
|
|
2853
|
+
`"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
|
|
2854
|
+
\| `"succeeded"` \| `"interrupted"`; `destinationPath`: `string`; `output`: \|
|
|
2855
|
+
`Readonly`\<\{ `bytes`: `number`; `format`: `string`; `contentType`: `string`;
|
|
2856
|
+
\}\> \| `null`; \}\> \| `null`\>
|
|
2857
|
+
|
|
2858
|
+
---
|
|
2859
|
+
|
|
2860
|
+
### readRetainedMedia()
|
|
2861
|
+
|
|
2862
|
+
```ts
|
|
2863
|
+
function readRetainedMedia(
|
|
2864
|
+
host,
|
|
2865
|
+
requestId,
|
|
2866
|
+
): Promise<Readonly<{
|
|
2867
|
+
bytes: Uint8Array;
|
|
2868
|
+
format: string;
|
|
2869
|
+
}> | null>;
|
|
2870
|
+
```
|
|
2871
|
+
|
|
2872
|
+
Read back the exact provider bytes a generation retained, before any provenance,
|
|
2873
|
+
so a host can re-save a result whose destination write was lost. Null when
|
|
2874
|
+
erased or nothing was retained. Refuses another namespace.
|
|
2875
|
+
|
|
2876
|
+
#### Parameters
|
|
2877
|
+
|
|
2878
|
+
| Parameter | Type |
|
|
2879
|
+
| ----------- | ------------------------------------------------------------------------------ |
|
|
2880
|
+
| `host` | `Pick`\<[`MediaServiceHost`](#mediaservicehost), `"operations"` \| `"scope"`\> |
|
|
2881
|
+
| `requestId` | `string` |
|
|
2882
|
+
|
|
2883
|
+
#### Returns
|
|
2884
|
+
|
|
2885
|
+
`Promise`\< \| `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: `string`; \}\> \|
|
|
2886
|
+
`null`\>
|
|
2887
|
+
|
|
2888
|
+
---
|
|
2889
|
+
|
|
2890
|
+
### eraseMediaOperation()
|
|
2891
|
+
|
|
2892
|
+
```ts
|
|
2893
|
+
function eraseMediaOperation(host, requestId): Promise<MediaOperationErasure>;
|
|
2894
|
+
```
|
|
2895
|
+
|
|
2896
|
+
Erase everything a generation retained or could still write: its retained
|
|
2897
|
+
output, reference copies, storage and the destination file (only while it still
|
|
2898
|
+
holds what this operation wrote). Works mid generation: the operation refuses
|
|
2899
|
+
later writes, deletes anything that lands, and its open billing hold is settled
|
|
2900
|
+
at zero units. Call again until `clear` is true; the destination facts are kept
|
|
2901
|
+
for that retry.
|
|
2902
|
+
|
|
2903
|
+
#### Parameters
|
|
2904
|
+
|
|
2905
|
+
| Parameter | Type |
|
|
2906
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
2907
|
+
| `host` | `Pick`\<[`MediaServiceHost`](#mediaservicehost), `"operations"` \| `"scope"` \| `"destination"` \| `"metering"`\> |
|
|
2908
|
+
| `requestId` | `string` |
|
|
2909
|
+
|
|
2910
|
+
#### Returns
|
|
2911
|
+
|
|
2912
|
+
`Promise`\<[`MediaOperationErasure`](#mediaoperationerasure)\>
|
|
2913
|
+
|
|
2914
|
+
---
|
|
2915
|
+
|
|
2529
2916
|
### createMediaService()
|
|
2530
2917
|
|
|
2531
2918
|
```ts
|