@fungi.computer/darkroom 0.0.0-stage → 0.1.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +315 -2
  3. package/dist/app-media-contracts.d.ts +499 -0
  4. package/dist/app-media-contracts.js +96 -0
  5. package/dist/browser-failure.d.ts +40 -0
  6. package/dist/browser-failure.js +39 -0
  7. package/dist/browser.d.ts +2 -0
  8. package/dist/browser.js +1 -0
  9. package/dist/cloudflare/provider.d.ts +13 -0
  10. package/dist/cloudflare/provider.js +140 -0
  11. package/dist/cloudflare/reference-images.d.ts +42 -0
  12. package/dist/cloudflare/reference-images.js +102 -0
  13. package/dist/cloudflare.d.ts +6 -0
  14. package/dist/cloudflare.js +4 -0
  15. package/dist/cost-estimate.d.ts +22 -0
  16. package/dist/cost-estimate.js +76 -0
  17. package/dist/effect.d.ts +2 -0
  18. package/dist/effect.js +2 -0
  19. package/dist/execution-error.d.ts +54 -0
  20. package/dist/execution-error.js +62 -0
  21. package/dist/failure.d.ts +2 -0
  22. package/dist/failure.js +8 -0
  23. package/dist/gateway-models.d.ts +23 -0
  24. package/dist/gateway-models.js +77 -0
  25. package/dist/gateway-wire.d.ts +16 -0
  26. package/dist/gateway-wire.js +22 -0
  27. package/dist/index.d.ts +361 -0
  28. package/dist/index.js +607 -0
  29. package/dist/media-binding.d.ts +291 -0
  30. package/dist/media-binding.js +149 -0
  31. package/dist/media-generation.d.ts +10 -0
  32. package/dist/media-generation.js +110 -0
  33. package/dist/media-operation-contract.d.ts +104 -0
  34. package/dist/media-operation-contract.js +29 -0
  35. package/dist/media-operation-do.d.ts +55 -0
  36. package/dist/media-operation-do.js +105 -0
  37. package/dist/media-operation-owner.d.ts +301 -0
  38. package/dist/media-operation-owner.js +903 -0
  39. package/dist/media-operation-storage.d.ts +81 -0
  40. package/dist/media-operation-storage.js +1 -0
  41. package/dist/media-operation.d.ts +33 -0
  42. package/dist/media-operation.js +230 -0
  43. package/dist/model-catalog.d.ts +456 -0
  44. package/dist/model-catalog.js +565 -0
  45. package/dist/neurons.d.ts +4 -0
  46. package/dist/neurons.js +4 -0
  47. package/dist/provenance-bytes.d.ts +3 -0
  48. package/dist/provenance-bytes.js +15 -0
  49. package/dist/provenance-export.d.ts +23 -0
  50. package/dist/provenance-export.js +103 -0
  51. package/dist/provenance-jpeg.d.ts +3 -0
  52. package/dist/provenance-jpeg.js +76 -0
  53. package/dist/provenance-png.d.ts +1 -0
  54. package/dist/provenance-png.js +21 -0
  55. package/dist/provenance-xmp.d.ts +2 -0
  56. package/dist/provenance-xmp.js +54 -0
  57. package/dist/provenance.d.ts +20 -0
  58. package/dist/provenance.js +58 -0
  59. package/dist/server.d.ts +158 -0
  60. package/dist/server.js +207 -0
  61. package/dist/video-providers/index.d.ts +14 -0
  62. package/dist/video-providers/index.js +14 -0
  63. package/dist/video-providers/minimax.d.ts +25 -0
  64. package/dist/video-providers/minimax.js +63 -0
  65. package/dist/video-providers/reference-encoding.d.ts +4 -0
  66. package/dist/video-providers/reference-encoding.js +11 -0
  67. package/dist/video-providers/types.d.ts +28 -0
  68. package/dist/video-providers/types.js +1 -0
  69. package/dist/video-providers/unified.d.ts +18 -0
  70. package/dist/video-providers/unified.js +52 -0
  71. package/docs/api/README.md +16 -0
  72. package/docs/api/app-media-contracts.md +507 -0
  73. package/docs/api/browser.md +126 -0
  74. package/docs/api/cloudflare.md +678 -0
  75. package/docs/api/effect.md +39 -0
  76. package/docs/api/index.md +1775 -0
  77. package/docs/api/modules.md +19 -0
  78. package/docs/api/provenance-export.md +114 -0
  79. package/docs/api/server.md +1672 -0
  80. package/package.json +110 -3
@@ -0,0 +1,678 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/darkroom**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/darkroom](modules.md) / cloudflare
8
+
9
+ # cloudflare
10
+
11
+ ## Classes
12
+
13
+ ### MediaOperationDO
14
+
15
+ Cloudflare lifecycle and RPC surface around the durable media owner.
16
+
17
+ #### Extends
18
+
19
+ - `DurableObject`\<[`MediaOperationCloudflareEnvironment`](#mediaoperationcloudflareenvironment)\>
20
+
21
+ #### Constructors
22
+
23
+ ##### Constructor
24
+
25
+ ```ts
26
+ new MediaOperationDO(ctx, env): MediaOperationDO;
27
+ ```
28
+
29
+ ###### Parameters
30
+
31
+ | Parameter | Type |
32
+ | --------- | ----------------------------------------------------------------------------- |
33
+ | `ctx` | `DurableObjectState` |
34
+ | `env` | [`MediaOperationCloudflareEnvironment`](#mediaoperationcloudflareenvironment) |
35
+
36
+ ###### Returns
37
+
38
+ [`MediaOperationDO`](#mediaoperationdo)
39
+
40
+ ###### Overrides
41
+
42
+ ```ts
43
+ DurableObject<MediaOperationCloudflareEnvironment>.constructor
44
+ ```
45
+
46
+ #### Methods
47
+
48
+ ##### read()
49
+
50
+ ```ts
51
+ read(...input):
52
+ | Readonly<{
53
+ operationId: string;
54
+ requestId: string;
55
+ namespace: string;
56
+ owner: string;
57
+ state: | "admitted"
58
+ | "estimating"
59
+ | "generating"
60
+ | "writing"
61
+ | "charging"
62
+ | "written"
63
+ | "succeeded"
64
+ | "interrupted";
65
+ spentFailure: "output_format_mismatch" | null;
66
+ providerRefusal: "safety_filter_refused" | null;
67
+ estimatedCostMilliunits: number | null;
68
+ image: | {
69
+ bytes: number;
70
+ format: string;
71
+ }
72
+ | null;
73
+ result: | {
74
+ generationId: string;
75
+ bytes: number;
76
+ format: string;
77
+ costMilliunits: number;
78
+ }
79
+ | null;
80
+ createdAt: number;
81
+ updatedAt: number;
82
+ }>
83
+ | null;
84
+ ```
85
+
86
+ Read the safe persisted operation projection, or null before admission or after
87
+ erasure.
88
+
89
+ ###### Parameters
90
+
91
+ | Parameter | Type |
92
+ | ---------- | ---- |
93
+ | ...`input` | \[\] |
94
+
95
+ ###### Returns
96
+
97
+ \| `Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
98
+ `string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
99
+ `"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
100
+ `"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
101
+ `providerRefusal`: `"safety_filter_refused"` \| `null`;
102
+ `estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
103
+ `format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
104
+ `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
105
+ `createdAt`: `number`; `updatedAt`: `number`; \}\> \| `null`
106
+
107
+ ##### preflightErasure()
108
+
109
+ ```ts
110
+ preflightErasure(...input): ReturnType<MediaOperationOwner["preflightErasure"]>;
111
+ ```
112
+
113
+ Check host namespace, request identity and inactivity before erasure.
114
+
115
+ ###### Parameters
116
+
117
+ | Parameter | Type | Description |
118
+ | ---------- | ---------------------- | ----------- |
119
+ | ...`input` | \[`string`, `string`\] | - |
120
+
121
+ ###### Returns
122
+
123
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"preflightErasure"`\]\>
124
+
125
+ ##### erase()
126
+
127
+ ```ts
128
+ erase(...input): Promise<Readonly<{
129
+ clear: boolean;
130
+ }>>;
131
+ ```
132
+
133
+ Erase inactive output and local storage, then retain the durable erasure marker.
134
+
135
+ ###### Parameters
136
+
137
+ | Parameter | Type | Description |
138
+ | ---------- | ---------------------- | ----------- |
139
+ | ...`input` | \[`string`, `string`\] | - |
140
+
141
+ ###### Returns
142
+
143
+ `Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
144
+
145
+ ##### readErasure()
146
+
147
+ ```ts
148
+ readErasure(...input): Promise<Readonly<{
149
+ clear: boolean;
150
+ }>>;
151
+ ```
152
+
153
+ Read back empty SQL, alarm and retained output with the durable erasure marker.
154
+
155
+ ###### Parameters
156
+
157
+ | Parameter | Type |
158
+ | ---------- | ---- |
159
+ | ...`input` | \[\] |
160
+
161
+ ###### Returns
162
+
163
+ `Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
164
+
165
+ ##### admit()
166
+
167
+ ```ts
168
+ admit(...input): ReturnType<MediaOperationOwner["admit"]>;
169
+ ```
170
+
171
+ Capture immutable host identity and input, replaying exact requests and refusing
172
+ changed input.
173
+
174
+ ###### Parameters
175
+
176
+ | Parameter | Type | Description |
177
+ | ---------- | -------------------------------------------------------------------------------------------- | ----------- |
178
+ | ...`input` | \[`string`, `object`, `string`, [`MediaOperationRequest`](server.md#mediaoperationrequest)\] | - |
179
+
180
+ ###### Returns
181
+
182
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"admit"`\]\>
183
+
184
+ ##### claim()
185
+
186
+ ```ts
187
+ claim(...input): Promise<Readonly<{
188
+ kind: | "admitted"
189
+ | "succeeded"
190
+ | "interrupted"
191
+ | "conflict"
192
+ | "replayed"
193
+ | "claimed"
194
+ | "pending";
195
+ operation: MediaOperationProjection;
196
+ leaseId?: string;
197
+ }>>;
198
+ ```
199
+
200
+ Claim a safe dispatch or save lease, recovering retained output without
201
+ redispatching inference.
202
+
203
+ ###### Parameters
204
+
205
+ | Parameter | Type |
206
+ | ---------- | ---- |
207
+ | ...`input` | \[\] |
208
+
209
+ ###### Returns
210
+
211
+ `Promise`\<`Readonly`\<\{ `kind`: \| `"admitted"` \| `"succeeded"` \|
212
+ `"interrupted"` \| `"conflict"` \| `"replayed"` \| `"claimed"` \| `"pending"`;
213
+ `operation`: [`MediaOperationProjection`](server.md#mediaoperationprojection);
214
+ `leaseId?`: `string`; \}\>\>
215
+
216
+ ##### recordEstimate()
217
+
218
+ ```ts
219
+ recordEstimate(...input): ReturnType<MediaOperationOwner["recordEstimate"]>;
220
+ ```
221
+
222
+ Pin the admitted price and begin the generation lease.
223
+
224
+ ###### Parameters
225
+
226
+ | Parameter | Type | Description |
227
+ | ---------- | ---------------------- | ----------- |
228
+ | ...`input` | \[`string`, `number`\] | - |
229
+
230
+ ###### Returns
231
+
232
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"recordEstimate"`\]\>
233
+
234
+ ##### dispatchInBackground()
235
+
236
+ ```ts
237
+ dispatchInBackground(...input): Promise<Readonly<{
238
+ operationId: string;
239
+ requestId: string;
240
+ namespace: string;
241
+ owner: string;
242
+ state: | "admitted"
243
+ | "estimating"
244
+ | "generating"
245
+ | "writing"
246
+ | "charging"
247
+ | "written"
248
+ | "succeeded"
249
+ | "interrupted";
250
+ spentFailure: "output_format_mismatch" | null;
251
+ providerRefusal: "safety_filter_refused" | null;
252
+ estimatedCostMilliunits: number | null;
253
+ image: | {
254
+ bytes: number;
255
+ format: string;
256
+ }
257
+ | null;
258
+ result: | {
259
+ generationId: string;
260
+ bytes: number;
261
+ format: string;
262
+ costMilliunits: number;
263
+ }
264
+ | null;
265
+ createdAt: number;
266
+ updatedAt: number;
267
+ }>>;
268
+ ```
269
+
270
+ Hand a long (video) generation to this owner's alarm. The caller's request
271
+ returns at once; the alarm dispatches the provider exactly once, retains the
272
+ output, and releases the lease so a later retry saves and charges it.
273
+
274
+ ###### Parameters
275
+
276
+ | Parameter | Type | Description |
277
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
278
+ | ...`input` | \[`string`, readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: [`ImageFormat`](index.md#imageformat); `width`: `number`; `height`: `number`; `filename?`: `string`; \}\>[]\] | - |
279
+
280
+ ###### Returns
281
+
282
+ `Promise`\<`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`;
283
+ `namespace`: `string`; `owner`: `string`; `state`: \| `"admitted"` \|
284
+ `"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
285
+ \| `"succeeded"` \| `"interrupted"`; `spentFailure`: `"output_format_mismatch"`
286
+ \| `null`; `providerRefusal`: `"safety_filter_refused"` \| `null`;
287
+ `estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
288
+ `format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
289
+ `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
290
+ `createdAt`: `number`; `updatedAt`: `number`; \}\>\>
291
+
292
+ ##### alarm()
293
+
294
+ ```ts
295
+ alarm(...input): Promise<void>;
296
+ ```
297
+
298
+ Run a background generation once; a retried alarm never redispatches.
299
+
300
+ ###### Parameters
301
+
302
+ | Parameter | Type |
303
+ | ---------- | ---- |
304
+ | ...`input` | \[\] |
305
+
306
+ ###### Returns
307
+
308
+ `Promise`\<`void`\>
309
+
310
+ ###### Overrides
311
+
312
+ ```ts
313
+ DurableObject.alarm;
314
+ ```
315
+
316
+ ##### interruptGeneration()
317
+
318
+ ```ts
319
+ interruptGeneration(...input): ReturnType<MediaOperationOwner["interruptGeneration"]>;
320
+ ```
321
+
322
+ An aborted in-flight provider call is terminal for this request ID.
323
+
324
+ ###### Parameters
325
+
326
+ | Parameter | Type | Description |
327
+ | ---------- | --------------------------------------- | ----------- |
328
+ | ...`input` | \[`string`, `"safety_filter_refused"`\] | - |
329
+
330
+ ###### Returns
331
+
332
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"interruptGeneration"`\]\>
333
+
334
+ ##### recordGenerated()
335
+
336
+ ```ts
337
+ recordGenerated(...input): Promise<MediaRetentionResult>;
338
+ ```
339
+
340
+ Retain immutable provider output before making the save state visible.
341
+
342
+ ###### Parameters
343
+
344
+ | Parameter | Type | Description |
345
+ | ---------- | --------------------------------------------------------- | ----------- |
346
+ | ...`input` | \[`string`, `Uint8Array`\<`ArrayBufferLike`\>, `string`\] | - |
347
+
348
+ ###### Returns
349
+
350
+ `Promise`\<[`MediaRetentionResult`](server.md#mediaretentionresult)\>
351
+
352
+ ##### readGenerated()
353
+
354
+ ```ts
355
+ readGenerated(...input): Promise<Uint8Array<ArrayBufferLike>>;
356
+ ```
357
+
358
+ Read exact retained bytes under the current save lease.
359
+
360
+ ###### Parameters
361
+
362
+ | Parameter | Type | Description |
363
+ | ---------- | ------------ | ----------- |
364
+ | ...`input` | \[`string`\] | - |
365
+
366
+ ###### Returns
367
+
368
+ `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
369
+
370
+ ##### releaseWrite()
371
+
372
+ ```ts
373
+ releaseWrite(...input): ReturnType<MediaOperationOwner["releaseWrite"]>;
374
+ ```
375
+
376
+ A fixed-path exact-byte save is safe to retry without repeating generation.
377
+
378
+ ###### Parameters
379
+
380
+ | Parameter | Type | Description |
381
+ | ---------- | ------------ | ----------- |
382
+ | ...`input` | \[`string`\] | - |
383
+
384
+ ###### Returns
385
+
386
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"releaseWrite"`\]\>
387
+
388
+ ##### recordWritten()
389
+
390
+ ```ts
391
+ recordWritten(...input): ReturnType<MediaOperationOwner["recordWritten"]>;
392
+ ```
393
+
394
+ Record a destination write and move to idempotent settlement.
395
+
396
+ ###### Parameters
397
+
398
+ | Parameter | Type | Description |
399
+ | ---------- | -------------------------------- | ----------- |
400
+ | ...`input` | \[`string`, `string`, `object`\] | - |
401
+
402
+ ###### Returns
403
+
404
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"recordWritten"`\]\>
405
+
406
+ ##### recordWrittenWithoutSettlement()
407
+
408
+ ```ts
409
+ recordWrittenWithoutSettlement(...input): ReturnType<MediaOperationOwner["recordWrittenWithoutSettlement"]>;
410
+ ```
411
+
412
+ Persist a completed Computer write without claiming billing success. A lost
413
+ receipt may replay the exact retained bytes to the captured path; it never
414
+ repeats provider generation.
415
+
416
+ ###### Parameters
417
+
418
+ | Parameter | Type | Description |
419
+ | ---------- | -------------------------------- | ----------- |
420
+ | ...`input` | \[`string`, `string`, `object`\] | - |
421
+
422
+ ###### Returns
423
+
424
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"recordWrittenWithoutSettlement"`\]\>
425
+
426
+ ##### recordSucceeded()
427
+
428
+ ```ts
429
+ recordSucceeded(...input): ReturnType<MediaOperationOwner["recordSucceeded"]>;
430
+ ```
431
+
432
+ Commit the settled receipt after verifying the saved output and admitted price.
433
+
434
+ ###### Parameters
435
+
436
+ | Parameter | Type | Description |
437
+ | ---------- | ---------------------- | ----------- |
438
+ | ...`input` | \[`string`, `object`\] | - |
439
+
440
+ ###### Returns
441
+
442
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"recordSucceeded"`\]\>
443
+
444
+ ##### releaseEstimate()
445
+
446
+ ```ts
447
+ releaseEstimate(...input): ReturnType<MediaOperationOwner["releaseEstimate"]>;
448
+ ```
449
+
450
+ Release preparation or refused admission so the same request can retry.
451
+
452
+ ###### Parameters
453
+
454
+ | Parameter | Type | Description |
455
+ | ---------- | ------------ | ----------- |
456
+ | ...`input` | \[`string`\] | - |
457
+
458
+ ###### Returns
459
+
460
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"releaseEstimate"`\]\>
461
+
462
+ ## Type Aliases
463
+
464
+ ### MediaAiResult
465
+
466
+ ```ts
467
+ type MediaAiResult = Awaited<ReturnType<Ai["run"]>> | MediaProviderWire;
468
+ ```
469
+
470
+ Native Workers AI output or an already decoded provider representation.
471
+
472
+ ---
473
+
474
+ ### MediaAiPort
475
+
476
+ ```ts
477
+ type MediaAiPort = object;
478
+ ```
479
+
480
+ Workers AI results vary by model; the provider decodes them at this boundary.
481
+
482
+ #### Methods
483
+
484
+ ##### run()
485
+
486
+ ```ts
487
+ run(
488
+ model,
489
+ input,
490
+ options?
491
+ ): Promise<MediaAiResult>;
492
+ ```
493
+
494
+ Dispatch to the native Workers AI binding.
495
+
496
+ ###### Parameters
497
+
498
+ | Parameter | Type |
499
+ | ---------- | ------------------------------- |
500
+ | `model` | `string` |
501
+ | `input` | `Record`\<`string`, `unknown`\> |
502
+ | `options?` | `AiOptions` |
503
+
504
+ ###### Returns
505
+
506
+ `Promise`\<[`MediaAiResult`](#mediaairesult)\>
507
+
508
+ ---
509
+
510
+ ### MediaImagePort
511
+
512
+ ```ts
513
+ type MediaImagePort = object;
514
+ ```
515
+
516
+ Only image metadata and the bounded resize chain are consumed by Media.
517
+
518
+ #### Methods
519
+
520
+ ##### info()
521
+
522
+ ```ts
523
+ info(input): Promise<ImageInfoResponse>;
524
+ ```
525
+
526
+ Read decoded image metadata through the Images binding.
527
+
528
+ ###### Parameters
529
+
530
+ | Parameter | Type |
531
+ | --------- | ----------------------------------------------------- |
532
+ | `input` | `ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`\>\> |
533
+
534
+ ###### Returns
535
+
536
+ `Promise`\<`ImageInfoResponse`\>
537
+
538
+ ##### input()
539
+
540
+ ```ts
541
+ input(input): object;
542
+ ```
543
+
544
+ Start the native resize and encode chain.
545
+
546
+ ###### Parameters
547
+
548
+ | Parameter | Type |
549
+ | --------- | ----------------------------------------------------- |
550
+ | `input` | `ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`\>\> |
551
+
552
+ ###### Returns
553
+
554
+ | Name | Type | Description |
555
+ | ------------- | ----------------------- | -------------------------------------- |
556
+ | `transform()` | (`options`) => `object` | Apply the native scale-down transform. |
557
+
558
+ ---
559
+
560
+ ### MediaOperationCloudflareEnvironment
561
+
562
+ ```ts
563
+ type MediaOperationCloudflareEnvironment = MediaOperationEnvironment &
564
+ Readonly<{
565
+ AI?: MediaAiPort;
566
+ AI_GATEWAY_ID?: string;
567
+ }>;
568
+ ```
569
+
570
+ Retention storage and native background provider bindings for the operation DO.
571
+
572
+ ## Functions
573
+
574
+ ### createWorkersAiMediaProvider()
575
+
576
+ ```ts
577
+ function createWorkersAiMediaProvider(ai, options?): MediaProvider;
578
+ ```
579
+
580
+ Media's provider port on the Workers AI binding, with fixed options such as the
581
+ AI Gateway route.
582
+
583
+ #### Parameters
584
+
585
+ | Parameter | Type |
586
+ | ---------- | ----------------------------- |
587
+ | `ai` | [`MediaAiPort`](#mediaaiport) |
588
+ | `options?` | `AiOptions` |
589
+
590
+ #### Returns
591
+
592
+ [`MediaProvider`](index.md#mediaprovider)
593
+
594
+ ---
595
+
596
+ ### createImagesReferenceFitter()
597
+
598
+ ```ts
599
+ function createImagesReferenceFitter(images): ReferenceImageFitter;
600
+ ```
601
+
602
+ Media's reference preparation on the Images binding: decode the real bytes,
603
+ scale an oversized image down to MAX_REFERENCE_DIMENSION as PNG, then decode the
604
+ output so its metadata describes the bytes actually sent.
605
+
606
+ #### Parameters
607
+
608
+ | Parameter | Type |
609
+ | --------- | ----------------------------------- |
610
+ | `images` | [`MediaImagePort`](#mediaimageport) |
611
+
612
+ #### Returns
613
+
614
+ [`ReferenceImageFitter`](index.md#referenceimagefitter)
615
+
616
+ ---
617
+
618
+ ### createImagesViewFitter()
619
+
620
+ ```ts
621
+ function createImagesViewFitter(images): ImageViewFitter;
622
+ ```
623
+
624
+ Fit one image for a model to look at on the Images binding: always re-encode it
625
+ as JPEG (quality 80), scaled down within `maxDimension`, and decode the output
626
+ so its metadata describes the bytes actually returned.
627
+
628
+ #### Parameters
629
+
630
+ | Parameter | Type |
631
+ | --------- | ----------------------------------- |
632
+ | `images` | [`MediaImagePort`](#mediaimageport) |
633
+
634
+ #### Returns
635
+
636
+ [`ImageViewFitter`](index.md#imageviewfitter)
637
+
638
+ ## References
639
+
640
+ ### MediaOperationCoordinates
641
+
642
+ Re-exports [MediaOperationCoordinates](server.md#mediaoperationcoordinates)
643
+
644
+ ---
645
+
646
+ ### MediaOperationRequest
647
+
648
+ Re-exports [MediaOperationRequest](server.md#mediaoperationrequest)
649
+
650
+ ---
651
+
652
+ ### MediaOperationOwner
653
+
654
+ Re-exports [MediaOperationOwner](server.md#mediaoperationowner)
655
+
656
+ ---
657
+
658
+ ### MediaOperationContext
659
+
660
+ Re-exports [MediaOperationContext](server.md#mediaoperationcontext)
661
+
662
+ ---
663
+
664
+ ### MediaOperationStorage
665
+
666
+ Re-exports [MediaOperationStorage](server.md#mediaoperationstorage)
667
+
668
+ ---
669
+
670
+ ### MediaOperationBucket
671
+
672
+ Re-exports [MediaOperationBucket](server.md#mediaoperationbucket)
673
+
674
+ ---
675
+
676
+ ### MediaOperationObject
677
+
678
+ Re-exports [MediaOperationObject](server.md#mediaoperationobject)
@@ -0,0 +1,39 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/darkroom**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/darkroom](modules.md) / effect
8
+
9
+ # effect
10
+
11
+ ## Functions
12
+
13
+ ### runMediaGeneration()
14
+
15
+ ```ts
16
+ function runMediaGeneration(
17
+ host,
18
+ request,
19
+ signal?,
20
+ ): Effect<MediaGenerationOutcome, MediaSettingsError | MediaExecutionError>;
21
+ ```
22
+
23
+ Validate, admit, dispatch and save one generation against `host`. Shared by the
24
+ `/generate` Hono route and the Agent image tool so both run the exact same
25
+ admission, billing and destination-write sequence.
26
+
27
+ #### Parameters
28
+
29
+ | Parameter | Type |
30
+ | --------- | ------------------------------------------------------------ |
31
+ | `host` | [`MediaServiceHost`](server.md#mediaservicehost) |
32
+ | `request` | [`MediaGenerationRequest`](server.md#mediagenerationrequest) |
33
+ | `signal?` | `AbortSignal` |
34
+
35
+ #### Returns
36
+
37
+ `Effect`\<[`MediaGenerationOutcome`](server.md#mediagenerationoutcome), \|
38
+ [`MediaSettingsError`](index.md#mediasettingserror) \|
39
+ [`MediaExecutionError`](server.md#mediaexecutionerror)\>