@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.
- package/LICENSE +21 -0
- package/README.md +315 -2
- package/dist/app-media-contracts.d.ts +499 -0
- package/dist/app-media-contracts.js +96 -0
- package/dist/browser-failure.d.ts +40 -0
- package/dist/browser-failure.js +39 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +1 -0
- package/dist/cloudflare/provider.d.ts +13 -0
- package/dist/cloudflare/provider.js +140 -0
- package/dist/cloudflare/reference-images.d.ts +42 -0
- package/dist/cloudflare/reference-images.js +102 -0
- package/dist/cloudflare.d.ts +6 -0
- package/dist/cloudflare.js +4 -0
- package/dist/cost-estimate.d.ts +22 -0
- package/dist/cost-estimate.js +76 -0
- package/dist/effect.d.ts +2 -0
- package/dist/effect.js +2 -0
- package/dist/execution-error.d.ts +54 -0
- package/dist/execution-error.js +62 -0
- package/dist/failure.d.ts +2 -0
- package/dist/failure.js +8 -0
- package/dist/gateway-models.d.ts +23 -0
- package/dist/gateway-models.js +77 -0
- package/dist/gateway-wire.d.ts +16 -0
- package/dist/gateway-wire.js +22 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +607 -0
- package/dist/media-binding.d.ts +291 -0
- package/dist/media-binding.js +149 -0
- package/dist/media-generation.d.ts +10 -0
- package/dist/media-generation.js +110 -0
- package/dist/media-operation-contract.d.ts +104 -0
- package/dist/media-operation-contract.js +29 -0
- package/dist/media-operation-do.d.ts +55 -0
- package/dist/media-operation-do.js +105 -0
- package/dist/media-operation-owner.d.ts +301 -0
- package/dist/media-operation-owner.js +903 -0
- package/dist/media-operation-storage.d.ts +81 -0
- package/dist/media-operation-storage.js +1 -0
- package/dist/media-operation.d.ts +33 -0
- package/dist/media-operation.js +230 -0
- package/dist/model-catalog.d.ts +456 -0
- package/dist/model-catalog.js +565 -0
- package/dist/neurons.d.ts +4 -0
- package/dist/neurons.js +4 -0
- package/dist/provenance-bytes.d.ts +3 -0
- package/dist/provenance-bytes.js +15 -0
- package/dist/provenance-export.d.ts +23 -0
- package/dist/provenance-export.js +103 -0
- package/dist/provenance-jpeg.d.ts +3 -0
- package/dist/provenance-jpeg.js +76 -0
- package/dist/provenance-png.d.ts +1 -0
- package/dist/provenance-png.js +21 -0
- package/dist/provenance-xmp.d.ts +2 -0
- package/dist/provenance-xmp.js +54 -0
- package/dist/provenance.d.ts +20 -0
- package/dist/provenance.js +58 -0
- package/dist/server.d.ts +158 -0
- package/dist/server.js +207 -0
- package/dist/video-providers/index.d.ts +14 -0
- package/dist/video-providers/index.js +14 -0
- package/dist/video-providers/minimax.d.ts +25 -0
- package/dist/video-providers/minimax.js +63 -0
- package/dist/video-providers/reference-encoding.d.ts +4 -0
- package/dist/video-providers/reference-encoding.js +11 -0
- package/dist/video-providers/types.d.ts +28 -0
- package/dist/video-providers/types.js +1 -0
- package/dist/video-providers/unified.d.ts +18 -0
- package/dist/video-providers/unified.js +52 -0
- package/docs/api/README.md +16 -0
- package/docs/api/app-media-contracts.md +507 -0
- package/docs/api/browser.md +126 -0
- package/docs/api/cloudflare.md +678 -0
- package/docs/api/effect.md +39 -0
- package/docs/api/index.md +1775 -0
- package/docs/api/modules.md +19 -0
- package/docs/api/provenance-export.md +114 -0
- package/docs/api/server.md +1672 -0
- package/package.json +110 -3
|
@@ -0,0 +1,1672 @@
|
|
|
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) / server
|
|
8
|
+
|
|
9
|
+
# server
|
|
10
|
+
|
|
11
|
+
## Classes
|
|
12
|
+
|
|
13
|
+
### MediaExecutionError
|
|
14
|
+
|
|
15
|
+
A bounded stage marker for failures that cross the Media HTTP boundary.
|
|
16
|
+
|
|
17
|
+
#### Extends
|
|
18
|
+
|
|
19
|
+
- `Error`
|
|
20
|
+
|
|
21
|
+
#### Constructors
|
|
22
|
+
|
|
23
|
+
##### Constructor
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
new MediaExecutionError(stage, options?): MediaExecutionError;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
###### Parameters
|
|
30
|
+
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| ---------- | ----------------------------------------- | ------------------------------------------- |
|
|
33
|
+
| `stage` | [`MediaFailureStage`](#mediafailurestage) | Execution stage where the failure occurred. |
|
|
34
|
+
| `options?` | `ErrorOptions` | - |
|
|
35
|
+
|
|
36
|
+
###### Returns
|
|
37
|
+
|
|
38
|
+
[`MediaExecutionError`](#mediaexecutionerror)
|
|
39
|
+
|
|
40
|
+
###### Overrides
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
Error.constructor;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Properties
|
|
47
|
+
|
|
48
|
+
##### stage
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
readonly stage: MediaFailureStage;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Execution stage where the failure occurred.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### MediaBillingRefusal
|
|
59
|
+
|
|
60
|
+
A definitive billing refusal before dispatch; nothing was generated or charged.
|
|
61
|
+
|
|
62
|
+
#### Extends
|
|
63
|
+
|
|
64
|
+
- `Error`
|
|
65
|
+
|
|
66
|
+
#### Constructors
|
|
67
|
+
|
|
68
|
+
##### Constructor
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
new MediaBillingRefusal(code): MediaBillingRefusal;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
###### Parameters
|
|
75
|
+
|
|
76
|
+
| Parameter | Type | Description |
|
|
77
|
+
| --------- | ----------------------------------------------------- | ---------------------------------- |
|
|
78
|
+
| `code` | [`MediaBillingRefusalCode`](#mediabillingrefusalcode) | Bounded refusal or failure reason. |
|
|
79
|
+
|
|
80
|
+
###### Returns
|
|
81
|
+
|
|
82
|
+
[`MediaBillingRefusal`](#mediabillingrefusal)
|
|
83
|
+
|
|
84
|
+
###### Overrides
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
Error.constructor;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Properties
|
|
91
|
+
|
|
92
|
+
##### code
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
readonly code: MediaBillingRefusalCode;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Bounded refusal or failure reason.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### MediaOperationOwner
|
|
103
|
+
|
|
104
|
+
Own exact replay, dispatch leases, retained output and save recovery in SQL and
|
|
105
|
+
object storage.
|
|
106
|
+
|
|
107
|
+
#### Constructors
|
|
108
|
+
|
|
109
|
+
##### Constructor
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
new MediaOperationOwner(
|
|
113
|
+
ctx,
|
|
114
|
+
env,
|
|
115
|
+
provider?,
|
|
116
|
+
hooks?
|
|
117
|
+
): MediaOperationOwner;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
###### Parameters
|
|
121
|
+
|
|
122
|
+
| Parameter | Type |
|
|
123
|
+
| ----------- | -------------------------------------------------------------- |
|
|
124
|
+
| `ctx` | [`MediaOperationContext`](#mediaoperationcontext) |
|
|
125
|
+
| `env` | [`MediaOperationEnvironment`](#mediaoperationenvironment) |
|
|
126
|
+
| `provider?` | () => [`MediaProvider`](index.md#mediaprovider) \| `undefined` |
|
|
127
|
+
| `hooks?` | [`MediaOperationHooks`](#mediaoperationhooks) |
|
|
128
|
+
|
|
129
|
+
###### Returns
|
|
130
|
+
|
|
131
|
+
[`MediaOperationOwner`](#mediaoperationowner)
|
|
132
|
+
|
|
133
|
+
#### Methods
|
|
134
|
+
|
|
135
|
+
##### read()
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
read():
|
|
139
|
+
| Readonly<{
|
|
140
|
+
operationId: string;
|
|
141
|
+
requestId: string;
|
|
142
|
+
namespace: string;
|
|
143
|
+
owner: string;
|
|
144
|
+
state: | "admitted"
|
|
145
|
+
| "estimating"
|
|
146
|
+
| "generating"
|
|
147
|
+
| "writing"
|
|
148
|
+
| "charging"
|
|
149
|
+
| "written"
|
|
150
|
+
| "succeeded"
|
|
151
|
+
| "interrupted";
|
|
152
|
+
spentFailure: "output_format_mismatch" | null;
|
|
153
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
154
|
+
estimatedCostMilliunits: number | null;
|
|
155
|
+
image: | {
|
|
156
|
+
bytes: number;
|
|
157
|
+
format: string;
|
|
158
|
+
}
|
|
159
|
+
| null;
|
|
160
|
+
result: | {
|
|
161
|
+
generationId: string;
|
|
162
|
+
bytes: number;
|
|
163
|
+
format: string;
|
|
164
|
+
costMilliunits: number;
|
|
165
|
+
}
|
|
166
|
+
| null;
|
|
167
|
+
createdAt: number;
|
|
168
|
+
updatedAt: number;
|
|
169
|
+
}>
|
|
170
|
+
| null;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Read the safe persisted operation projection, or null before admission or after
|
|
174
|
+
erasure.
|
|
175
|
+
|
|
176
|
+
###### Returns
|
|
177
|
+
|
|
178
|
+
\| `Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
|
|
179
|
+
`string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
|
|
180
|
+
`"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
|
|
181
|
+
`"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
|
|
182
|
+
`providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
183
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
184
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
185
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
186
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\> \| `null`
|
|
187
|
+
|
|
188
|
+
##### preflightErasure()
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
preflightErasure(namespace, requestId): MediaErasurePreflight;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Check host namespace, request identity and inactivity before erasure.
|
|
195
|
+
|
|
196
|
+
###### Parameters
|
|
197
|
+
|
|
198
|
+
| Parameter | Type |
|
|
199
|
+
| ----------- | -------- |
|
|
200
|
+
| `namespace` | `string` |
|
|
201
|
+
| `requestId` | `string` |
|
|
202
|
+
|
|
203
|
+
###### Returns
|
|
204
|
+
|
|
205
|
+
[`MediaErasurePreflight`](#mediaerasurepreflight)
|
|
206
|
+
|
|
207
|
+
##### erase()
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
erase(namespace, requestId): Promise<Readonly<{
|
|
211
|
+
clear: boolean;
|
|
212
|
+
}>>;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Erase inactive output and local storage, then retain the durable erasure marker.
|
|
216
|
+
|
|
217
|
+
###### Parameters
|
|
218
|
+
|
|
219
|
+
| Parameter | Type |
|
|
220
|
+
| ----------- | -------- |
|
|
221
|
+
| `namespace` | `string` |
|
|
222
|
+
| `requestId` | `string` |
|
|
223
|
+
|
|
224
|
+
###### Returns
|
|
225
|
+
|
|
226
|
+
`Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
|
|
227
|
+
|
|
228
|
+
##### readErasure()
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
readErasure(): Promise<Readonly<{
|
|
232
|
+
clear: boolean;
|
|
233
|
+
}>>;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Read back empty SQL, alarm and retained output with the durable erasure marker.
|
|
237
|
+
|
|
238
|
+
###### Returns
|
|
239
|
+
|
|
240
|
+
`Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
|
|
241
|
+
|
|
242
|
+
##### admit()
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
admit(
|
|
246
|
+
actorUserId,
|
|
247
|
+
coordinatesInput,
|
|
248
|
+
requestId,
|
|
249
|
+
input
|
|
250
|
+
): MediaOperationDecision;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Capture immutable host identity and input, replaying exact requests and refusing
|
|
254
|
+
changed input.
|
|
255
|
+
|
|
256
|
+
###### Parameters
|
|
257
|
+
|
|
258
|
+
| Parameter | Type | Description |
|
|
259
|
+
| ---------------------------- | ------------------------------------------------- | -------------------------------- |
|
|
260
|
+
| `actorUserId` | `string` | - |
|
|
261
|
+
| `coordinatesInput` | \{ `namespace`: `string`; `owner`: `string`; \} | - |
|
|
262
|
+
| `coordinatesInput.namespace` | `string` | Host isolation namespace. |
|
|
263
|
+
| `coordinatesInput.owner` | `string` | Host owner within the namespace. |
|
|
264
|
+
| `requestId` | `string` | - |
|
|
265
|
+
| `input` | [`MediaOperationRequest`](#mediaoperationrequest) | - |
|
|
266
|
+
|
|
267
|
+
###### Returns
|
|
268
|
+
|
|
269
|
+
[`MediaOperationDecision`](#mediaoperationdecision)
|
|
270
|
+
|
|
271
|
+
##### claim()
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
claim(): Promise<Readonly<{
|
|
275
|
+
kind: | "admitted"
|
|
276
|
+
| "succeeded"
|
|
277
|
+
| "interrupted"
|
|
278
|
+
| "conflict"
|
|
279
|
+
| "replayed"
|
|
280
|
+
| "claimed"
|
|
281
|
+
| "pending";
|
|
282
|
+
operation: MediaOperationProjection;
|
|
283
|
+
leaseId?: string;
|
|
284
|
+
}>>;
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Claim a safe dispatch or save lease, recovering retained output without
|
|
288
|
+
redispatching inference.
|
|
289
|
+
|
|
290
|
+
###### Returns
|
|
291
|
+
|
|
292
|
+
`Promise`\<`Readonly`\<\{ `kind`: \| `"admitted"` \| `"succeeded"` \|
|
|
293
|
+
`"interrupted"` \| `"conflict"` \| `"replayed"` \| `"claimed"` \| `"pending"`;
|
|
294
|
+
`operation`: [`MediaOperationProjection`](#mediaoperationprojection);
|
|
295
|
+
`leaseId?`: `string`; \}\>\>
|
|
296
|
+
|
|
297
|
+
##### recordEstimate()
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
recordEstimate(leaseId, costMilliunits): Readonly<{
|
|
301
|
+
operationId: string;
|
|
302
|
+
requestId: string;
|
|
303
|
+
namespace: string;
|
|
304
|
+
owner: string;
|
|
305
|
+
state: | "admitted"
|
|
306
|
+
| "estimating"
|
|
307
|
+
| "generating"
|
|
308
|
+
| "writing"
|
|
309
|
+
| "charging"
|
|
310
|
+
| "written"
|
|
311
|
+
| "succeeded"
|
|
312
|
+
| "interrupted";
|
|
313
|
+
spentFailure: "output_format_mismatch" | null;
|
|
314
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
315
|
+
estimatedCostMilliunits: number | null;
|
|
316
|
+
image: | {
|
|
317
|
+
bytes: number;
|
|
318
|
+
format: string;
|
|
319
|
+
}
|
|
320
|
+
| null;
|
|
321
|
+
result: | {
|
|
322
|
+
generationId: string;
|
|
323
|
+
bytes: number;
|
|
324
|
+
format: string;
|
|
325
|
+
costMilliunits: number;
|
|
326
|
+
}
|
|
327
|
+
| null;
|
|
328
|
+
createdAt: number;
|
|
329
|
+
updatedAt: number;
|
|
330
|
+
}>;
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Pin the admitted price and begin the generation lease.
|
|
334
|
+
|
|
335
|
+
###### Parameters
|
|
336
|
+
|
|
337
|
+
| Parameter | Type |
|
|
338
|
+
| ---------------- | -------- |
|
|
339
|
+
| `leaseId` | `string` |
|
|
340
|
+
| `costMilliunits` | `number` |
|
|
341
|
+
|
|
342
|
+
###### Returns
|
|
343
|
+
|
|
344
|
+
`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
|
|
345
|
+
`string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
|
|
346
|
+
`"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
|
|
347
|
+
`"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
|
|
348
|
+
`providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
349
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
350
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
351
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
352
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\>
|
|
353
|
+
|
|
354
|
+
##### dispatchInBackground()
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
dispatchInBackground(leaseId, references): Promise<Readonly<{
|
|
358
|
+
operationId: string;
|
|
359
|
+
requestId: string;
|
|
360
|
+
namespace: string;
|
|
361
|
+
owner: string;
|
|
362
|
+
state: | "admitted"
|
|
363
|
+
| "estimating"
|
|
364
|
+
| "generating"
|
|
365
|
+
| "writing"
|
|
366
|
+
| "charging"
|
|
367
|
+
| "written"
|
|
368
|
+
| "succeeded"
|
|
369
|
+
| "interrupted";
|
|
370
|
+
spentFailure: "output_format_mismatch" | null;
|
|
371
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
372
|
+
estimatedCostMilliunits: number | null;
|
|
373
|
+
image: | {
|
|
374
|
+
bytes: number;
|
|
375
|
+
format: string;
|
|
376
|
+
}
|
|
377
|
+
| null;
|
|
378
|
+
result: | {
|
|
379
|
+
generationId: string;
|
|
380
|
+
bytes: number;
|
|
381
|
+
format: string;
|
|
382
|
+
costMilliunits: number;
|
|
383
|
+
}
|
|
384
|
+
| null;
|
|
385
|
+
createdAt: number;
|
|
386
|
+
updatedAt: number;
|
|
387
|
+
}>>;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Hand a long (video) generation to this owner's alarm. The caller's request
|
|
391
|
+
returns at once; the alarm dispatches the provider exactly once, retains the
|
|
392
|
+
output, and releases the lease so a later retry saves and charges it.
|
|
393
|
+
|
|
394
|
+
###### Parameters
|
|
395
|
+
|
|
396
|
+
| Parameter | Type |
|
|
397
|
+
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
398
|
+
| `leaseId` | `string` |
|
|
399
|
+
| `references` | readonly `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: [`ImageFormat`](index.md#imageformat); `width`: `number`; `height`: `number`; `filename?`: `string`; \}\>[] |
|
|
400
|
+
|
|
401
|
+
###### Returns
|
|
402
|
+
|
|
403
|
+
`Promise`\<`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`;
|
|
404
|
+
`namespace`: `string`; `owner`: `string`; `state`: \| `"admitted"` \|
|
|
405
|
+
`"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
|
|
406
|
+
\| `"succeeded"` \| `"interrupted"`; `spentFailure`: `"output_format_mismatch"`
|
|
407
|
+
\| `null`; `providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
408
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
409
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
410
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
411
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\>\>
|
|
412
|
+
|
|
413
|
+
##### alarm()
|
|
414
|
+
|
|
415
|
+
```ts
|
|
416
|
+
alarm(): Promise<void>;
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Run a background generation once; a retried alarm never redispatches.
|
|
420
|
+
|
|
421
|
+
###### Returns
|
|
422
|
+
|
|
423
|
+
`Promise`\<`void`\>
|
|
424
|
+
|
|
425
|
+
##### interruptGeneration()
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
interruptGeneration(leaseId, refusalInput?): MediaOperationProjection;
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
An aborted in-flight provider call is terminal for this request ID.
|
|
432
|
+
|
|
433
|
+
###### Parameters
|
|
434
|
+
|
|
435
|
+
| Parameter | Type |
|
|
436
|
+
| --------------- | ------------------------- |
|
|
437
|
+
| `leaseId` | `string` |
|
|
438
|
+
| `refusalInput?` | `"safety_filter_refused"` |
|
|
439
|
+
|
|
440
|
+
###### Returns
|
|
441
|
+
|
|
442
|
+
[`MediaOperationProjection`](#mediaoperationprojection)
|
|
443
|
+
|
|
444
|
+
##### recordGenerated()
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
recordGenerated(
|
|
448
|
+
leaseId,
|
|
449
|
+
bytes,
|
|
450
|
+
formatInput
|
|
451
|
+
): Promise<MediaRetentionResult>;
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Retain immutable provider output before making the save state visible.
|
|
455
|
+
|
|
456
|
+
###### Parameters
|
|
457
|
+
|
|
458
|
+
| Parameter | Type |
|
|
459
|
+
| ------------- | ------------ |
|
|
460
|
+
| `leaseId` | `string` |
|
|
461
|
+
| `bytes` | `Uint8Array` |
|
|
462
|
+
| `formatInput` | `string` |
|
|
463
|
+
|
|
464
|
+
###### Returns
|
|
465
|
+
|
|
466
|
+
`Promise`\<[`MediaRetentionResult`](#mediaretentionresult)\>
|
|
467
|
+
|
|
468
|
+
##### readGenerated()
|
|
469
|
+
|
|
470
|
+
```ts
|
|
471
|
+
readGenerated(leaseId): Promise<Uint8Array<ArrayBufferLike>>;
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
Read exact retained bytes under the current save lease.
|
|
475
|
+
|
|
476
|
+
###### Parameters
|
|
477
|
+
|
|
478
|
+
| Parameter | Type |
|
|
479
|
+
| --------- | -------- |
|
|
480
|
+
| `leaseId` | `string` |
|
|
481
|
+
|
|
482
|
+
###### Returns
|
|
483
|
+
|
|
484
|
+
`Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
|
|
485
|
+
|
|
486
|
+
##### releaseWrite()
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
releaseWrite(leaseId): MediaOperationProjection;
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
A fixed-path exact-byte save is safe to retry without repeating generation.
|
|
493
|
+
|
|
494
|
+
###### Parameters
|
|
495
|
+
|
|
496
|
+
| Parameter | Type |
|
|
497
|
+
| --------- | -------- |
|
|
498
|
+
| `leaseId` | `string` |
|
|
499
|
+
|
|
500
|
+
###### Returns
|
|
501
|
+
|
|
502
|
+
[`MediaOperationProjection`](#mediaoperationprojection)
|
|
503
|
+
|
|
504
|
+
##### recordWritten()
|
|
505
|
+
|
|
506
|
+
```ts
|
|
507
|
+
recordWritten(
|
|
508
|
+
leaseId,
|
|
509
|
+
receipt,
|
|
510
|
+
written
|
|
511
|
+
): Readonly<{
|
|
512
|
+
operationId: string;
|
|
513
|
+
requestId: string;
|
|
514
|
+
namespace: string;
|
|
515
|
+
owner: string;
|
|
516
|
+
state: | "admitted"
|
|
517
|
+
| "estimating"
|
|
518
|
+
| "generating"
|
|
519
|
+
| "writing"
|
|
520
|
+
| "charging"
|
|
521
|
+
| "written"
|
|
522
|
+
| "succeeded"
|
|
523
|
+
| "interrupted";
|
|
524
|
+
spentFailure: "output_format_mismatch" | null;
|
|
525
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
526
|
+
estimatedCostMilliunits: number | null;
|
|
527
|
+
image: | {
|
|
528
|
+
bytes: number;
|
|
529
|
+
format: string;
|
|
530
|
+
}
|
|
531
|
+
| null;
|
|
532
|
+
result: | {
|
|
533
|
+
generationId: string;
|
|
534
|
+
bytes: number;
|
|
535
|
+
format: string;
|
|
536
|
+
costMilliunits: number;
|
|
537
|
+
}
|
|
538
|
+
| null;
|
|
539
|
+
createdAt: number;
|
|
540
|
+
updatedAt: number;
|
|
541
|
+
}>;
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Record a destination write and move to idempotent settlement.
|
|
545
|
+
|
|
546
|
+
###### Parameters
|
|
547
|
+
|
|
548
|
+
| Parameter | Type | Description |
|
|
549
|
+
| ---------------- | -------------------------------------------- | ----------------------- |
|
|
550
|
+
| `leaseId` | `string` | - |
|
|
551
|
+
| `receipt` | `string` | - |
|
|
552
|
+
| `written` | \{ `bytes`: `number`; `format`: `string`; \} | - |
|
|
553
|
+
| `written.bytes` | `number` | Output byte length. |
|
|
554
|
+
| `written.format` | `string` | Actual output encoding. |
|
|
555
|
+
|
|
556
|
+
###### Returns
|
|
557
|
+
|
|
558
|
+
`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
|
|
559
|
+
`string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
|
|
560
|
+
`"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
|
|
561
|
+
`"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
|
|
562
|
+
`providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
563
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
564
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
565
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
566
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\>
|
|
567
|
+
|
|
568
|
+
##### recordWrittenWithoutSettlement()
|
|
569
|
+
|
|
570
|
+
```ts
|
|
571
|
+
recordWrittenWithoutSettlement(
|
|
572
|
+
leaseId,
|
|
573
|
+
receipt,
|
|
574
|
+
written
|
|
575
|
+
): Readonly<{
|
|
576
|
+
operationId: string;
|
|
577
|
+
requestId: string;
|
|
578
|
+
namespace: string;
|
|
579
|
+
owner: string;
|
|
580
|
+
state: | "admitted"
|
|
581
|
+
| "estimating"
|
|
582
|
+
| "generating"
|
|
583
|
+
| "writing"
|
|
584
|
+
| "charging"
|
|
585
|
+
| "written"
|
|
586
|
+
| "succeeded"
|
|
587
|
+
| "interrupted";
|
|
588
|
+
spentFailure: "output_format_mismatch" | null;
|
|
589
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
590
|
+
estimatedCostMilliunits: number | null;
|
|
591
|
+
image: | {
|
|
592
|
+
bytes: number;
|
|
593
|
+
format: string;
|
|
594
|
+
}
|
|
595
|
+
| null;
|
|
596
|
+
result: | {
|
|
597
|
+
generationId: string;
|
|
598
|
+
bytes: number;
|
|
599
|
+
format: string;
|
|
600
|
+
costMilliunits: number;
|
|
601
|
+
}
|
|
602
|
+
| null;
|
|
603
|
+
createdAt: number;
|
|
604
|
+
updatedAt: number;
|
|
605
|
+
}>;
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
Persist a completed Computer write without claiming billing success. A lost
|
|
609
|
+
receipt may replay the exact retained bytes to the captured path; it never
|
|
610
|
+
repeats provider generation.
|
|
611
|
+
|
|
612
|
+
###### Parameters
|
|
613
|
+
|
|
614
|
+
| Parameter | Type | Description |
|
|
615
|
+
| ---------------- | -------------------------------------------- | ----------------------- |
|
|
616
|
+
| `leaseId` | `string` | - |
|
|
617
|
+
| `receipt` | `string` | - |
|
|
618
|
+
| `written` | \{ `bytes`: `number`; `format`: `string`; \} | - |
|
|
619
|
+
| `written.bytes` | `number` | Output byte length. |
|
|
620
|
+
| `written.format` | `string` | Actual output encoding. |
|
|
621
|
+
|
|
622
|
+
###### Returns
|
|
623
|
+
|
|
624
|
+
`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
|
|
625
|
+
`string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
|
|
626
|
+
`"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
|
|
627
|
+
`"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
|
|
628
|
+
`providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
629
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
630
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
631
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
632
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\>
|
|
633
|
+
|
|
634
|
+
##### recordSucceeded()
|
|
635
|
+
|
|
636
|
+
```ts
|
|
637
|
+
recordSucceeded(leaseId, resultInput): Readonly<{
|
|
638
|
+
operationId: string;
|
|
639
|
+
requestId: string;
|
|
640
|
+
namespace: string;
|
|
641
|
+
owner: string;
|
|
642
|
+
state: | "admitted"
|
|
643
|
+
| "estimating"
|
|
644
|
+
| "generating"
|
|
645
|
+
| "writing"
|
|
646
|
+
| "charging"
|
|
647
|
+
| "written"
|
|
648
|
+
| "succeeded"
|
|
649
|
+
| "interrupted";
|
|
650
|
+
spentFailure: "output_format_mismatch" | null;
|
|
651
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
652
|
+
estimatedCostMilliunits: number | null;
|
|
653
|
+
image: | {
|
|
654
|
+
bytes: number;
|
|
655
|
+
format: string;
|
|
656
|
+
}
|
|
657
|
+
| null;
|
|
658
|
+
result: | {
|
|
659
|
+
generationId: string;
|
|
660
|
+
bytes: number;
|
|
661
|
+
format: string;
|
|
662
|
+
costMilliunits: number;
|
|
663
|
+
}
|
|
664
|
+
| null;
|
|
665
|
+
createdAt: number;
|
|
666
|
+
updatedAt: number;
|
|
667
|
+
}>;
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
Commit the settled receipt after verifying the saved output and admitted price.
|
|
671
|
+
|
|
672
|
+
###### Parameters
|
|
673
|
+
|
|
674
|
+
| Parameter | Type | Description |
|
|
675
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
676
|
+
| `leaseId` | `string` | - |
|
|
677
|
+
| `resultInput` | \{ `generationId`: `string`; `bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} | - |
|
|
678
|
+
| `resultInput.generationId` | `string` | Durable operation identifier. |
|
|
679
|
+
| `resultInput.bytes` | `number` | Output byte length. |
|
|
680
|
+
| `resultInput.format` | `string` | Actual output encoding. |
|
|
681
|
+
| `resultInput.costMilliunits` | `number` | Admitted price in milliunits, where 1 cent is 1,000 milliunits. |
|
|
682
|
+
|
|
683
|
+
###### Returns
|
|
684
|
+
|
|
685
|
+
`Readonly`\<\{ `operationId`: `string`; `requestId`: `string`; `namespace`:
|
|
686
|
+
`string`; `owner`: `string`; `state`: \| `"admitted"` \| `"estimating"` \|
|
|
687
|
+
`"generating"` \| `"writing"` \| `"charging"` \| `"written"` \| `"succeeded"` \|
|
|
688
|
+
`"interrupted"`; `spentFailure`: `"output_format_mismatch"` \| `null`;
|
|
689
|
+
`providerRefusal`: `"safety_filter_refused"` \| `null`;
|
|
690
|
+
`estimatedCostMilliunits`: `number` \| `null`; `image`: \| \{ `bytes`: `number`;
|
|
691
|
+
`format`: `string`; \} \| `null`; `result`: \| \{ `generationId`: `string`;
|
|
692
|
+
`bytes`: `number`; `format`: `string`; `costMilliunits`: `number`; \} \| `null`;
|
|
693
|
+
`createdAt`: `number`; `updatedAt`: `number`; \}\>
|
|
694
|
+
|
|
695
|
+
##### releaseEstimate()
|
|
696
|
+
|
|
697
|
+
```ts
|
|
698
|
+
releaseEstimate(leaseId): MediaOperationProjection;
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
Release preparation or refused admission so the same request can retry.
|
|
702
|
+
|
|
703
|
+
###### Parameters
|
|
704
|
+
|
|
705
|
+
| Parameter | Type |
|
|
706
|
+
| --------- | -------- |
|
|
707
|
+
| `leaseId` | `string` |
|
|
708
|
+
|
|
709
|
+
###### Returns
|
|
710
|
+
|
|
711
|
+
[`MediaOperationProjection`](#mediaoperationprojection)
|
|
712
|
+
|
|
713
|
+
## Type Aliases
|
|
714
|
+
|
|
715
|
+
### MediaFailureStage
|
|
716
|
+
|
|
717
|
+
```ts
|
|
718
|
+
type MediaFailureStage = Exclude<
|
|
719
|
+
z.output<typeof mediaFailureStageSchema>,
|
|
720
|
+
"admission" | "settings"
|
|
721
|
+
>;
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
Execution stage at which a generation failed.
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
### MediaBillingRefusalCode
|
|
729
|
+
|
|
730
|
+
```ts
|
|
731
|
+
type MediaBillingRefusalCode =
|
|
732
|
+
"insufficient_credits" | "daily_limit_reached" | "denied";
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Why the host's billing owner refused to admit a new generation.
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
### MediaUnits
|
|
740
|
+
|
|
741
|
+
```ts
|
|
742
|
+
type MediaUnits = Readonly<{
|
|
743
|
+
unit: "image" | "video_second";
|
|
744
|
+
units: number;
|
|
745
|
+
}>;
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
What one generation bills: whole images, or seconds of video.
|
|
749
|
+
|
|
750
|
+
---
|
|
751
|
+
|
|
752
|
+
### MediaMetering
|
|
753
|
+
|
|
754
|
+
```ts
|
|
755
|
+
type MediaMetering = Readonly<{
|
|
756
|
+
admit: (input) => Promise<
|
|
757
|
+
Readonly<{
|
|
758
|
+
priceMilliunits: number;
|
|
759
|
+
}>
|
|
760
|
+
>;
|
|
761
|
+
settle: (input) => Promise<void>;
|
|
762
|
+
}>;
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
The host's billing owner for Media. Every call is keyed by the durable operation
|
|
766
|
+
id and must be idempotent: a lost acknowledgement is retried with the same id
|
|
767
|
+
and must never admit, hold, or charge twice.
|
|
768
|
+
|
|
769
|
+
---
|
|
770
|
+
|
|
771
|
+
### MediaOperation
|
|
772
|
+
|
|
773
|
+
```ts
|
|
774
|
+
type MediaOperation = {
|
|
775
|
+
[
|
|
776
|
+
Method in
|
|
777
|
+
| "admit"
|
|
778
|
+
| "claim"
|
|
779
|
+
| "dispatchInBackground"
|
|
780
|
+
| "interruptGeneration"
|
|
781
|
+
| "readGenerated"
|
|
782
|
+
| "recordEstimate"
|
|
783
|
+
| "recordGenerated"
|
|
784
|
+
| "recordSucceeded"
|
|
785
|
+
| "recordWritten"
|
|
786
|
+
| "recordWrittenWithoutSettlement"
|
|
787
|
+
| "releaseEstimate"
|
|
788
|
+
| "releaseWrite"
|
|
789
|
+
]: (
|
|
790
|
+
input: Parameters<MediaOperationOwner[Method]>,
|
|
791
|
+
) =>
|
|
792
|
+
| ReturnType<MediaOperationOwner[Method]>
|
|
793
|
+
| Promise<Awaited<ReturnType<MediaOperationOwner[Method]>>>;
|
|
794
|
+
};
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
Local or RPC methods consumed by a replay-safe generation.
|
|
798
|
+
|
|
799
|
+
---
|
|
800
|
+
|
|
801
|
+
### MediaOperationRequest
|
|
802
|
+
|
|
803
|
+
```ts
|
|
804
|
+
type MediaOperationRequest = MediaGenerationSettings &
|
|
805
|
+
z.output<typeof mediaOperationDestinationSchema>;
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
Normalized generation and its fixed destination, captured for exact replay.
|
|
809
|
+
|
|
810
|
+
---
|
|
811
|
+
|
|
812
|
+
### MediaOperationCoordinates
|
|
813
|
+
|
|
814
|
+
```ts
|
|
815
|
+
type MediaOperationCoordinates = z.output<
|
|
816
|
+
typeof mediaOperationCoordinatesSchema
|
|
817
|
+
>;
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
Host-owned namespace and owner identity for one durable operation.
|
|
821
|
+
|
|
822
|
+
---
|
|
823
|
+
|
|
824
|
+
### MediaOperationState
|
|
825
|
+
|
|
826
|
+
```ts
|
|
827
|
+
type MediaOperationState = z.output<typeof mediaOperationStateSchema>;
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
Durable generation, save and settlement states.
|
|
831
|
+
|
|
832
|
+
---
|
|
833
|
+
|
|
834
|
+
### MediaImage
|
|
835
|
+
|
|
836
|
+
```ts
|
|
837
|
+
type MediaImage = z.output<typeof mediaImageSchema>;
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
Byte length and encoding of generated or saved output.
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
### MediaOperationResult
|
|
845
|
+
|
|
846
|
+
```ts
|
|
847
|
+
type MediaOperationResult = z.output<typeof mediaOperationResultSchema>;
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
Settled generation receipt with the host-admitted customer price.
|
|
851
|
+
|
|
852
|
+
---
|
|
853
|
+
|
|
854
|
+
### MediaOperationProjection
|
|
855
|
+
|
|
856
|
+
```ts
|
|
857
|
+
type MediaOperationProjection = Readonly<{
|
|
858
|
+
operationId: string;
|
|
859
|
+
requestId: string;
|
|
860
|
+
namespace: string;
|
|
861
|
+
owner: string;
|
|
862
|
+
state: MediaOperationState;
|
|
863
|
+
spentFailure: "output_format_mismatch" | null;
|
|
864
|
+
providerRefusal: "safety_filter_refused" | null;
|
|
865
|
+
estimatedCostMilliunits: number | null;
|
|
866
|
+
image: MediaImage | null;
|
|
867
|
+
result: MediaOperationResult | null;
|
|
868
|
+
createdAt: number;
|
|
869
|
+
updatedAt: number;
|
|
870
|
+
}>;
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
The only operation shape safe to return outside the owner.
|
|
874
|
+
|
|
875
|
+
---
|
|
876
|
+
|
|
877
|
+
### MediaOperationDecision
|
|
878
|
+
|
|
879
|
+
```ts
|
|
880
|
+
type MediaOperationDecision = Readonly<{
|
|
881
|
+
kind:
|
|
882
|
+
| "admitted"
|
|
883
|
+
| "conflict"
|
|
884
|
+
| "replayed"
|
|
885
|
+
| "claimed"
|
|
886
|
+
| "pending"
|
|
887
|
+
| "succeeded"
|
|
888
|
+
| "interrupted";
|
|
889
|
+
operation: MediaOperationProjection;
|
|
890
|
+
leaseId?: string;
|
|
891
|
+
}>;
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
An admission or claim decision with a safe operation projection.
|
|
895
|
+
|
|
896
|
+
---
|
|
897
|
+
|
|
898
|
+
### MediaErasurePreflight
|
|
899
|
+
|
|
900
|
+
```ts
|
|
901
|
+
type MediaErasurePreflight = Readonly<{
|
|
902
|
+
namespace: string;
|
|
903
|
+
requestId: string;
|
|
904
|
+
erased: boolean;
|
|
905
|
+
}>;
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
Scoped inactivity observation made before destructive erasure.
|
|
909
|
+
|
|
910
|
+
---
|
|
911
|
+
|
|
912
|
+
### MediaErasureReadback
|
|
913
|
+
|
|
914
|
+
```ts
|
|
915
|
+
type MediaErasureReadback = Readonly<{
|
|
916
|
+
clear: boolean;
|
|
917
|
+
}>;
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
Evidence that retained output, SQL and alarms were erased.
|
|
921
|
+
|
|
922
|
+
---
|
|
923
|
+
|
|
924
|
+
### MediaRetentionResult
|
|
925
|
+
|
|
926
|
+
```ts
|
|
927
|
+
type MediaRetentionResult =
|
|
928
|
+
| MediaOperationProjection
|
|
929
|
+
| Readonly<{
|
|
930
|
+
kind: "refused";
|
|
931
|
+
code: "output_format_mismatch";
|
|
932
|
+
}>;
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
Retained output projection, or a terminal spent format refusal.
|
|
936
|
+
|
|
937
|
+
---
|
|
938
|
+
|
|
939
|
+
### MediaOperationHooks
|
|
940
|
+
|
|
941
|
+
```ts
|
|
942
|
+
type MediaOperationHooks = Readonly<{
|
|
943
|
+
namespace?: () => string | null;
|
|
944
|
+
}>;
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
Optional host facts that pin a namespace before operation admission.
|
|
948
|
+
|
|
949
|
+
---
|
|
950
|
+
|
|
951
|
+
### MediaOperationEnvironment
|
|
952
|
+
|
|
953
|
+
```ts
|
|
954
|
+
type MediaOperationEnvironment = Readonly<{
|
|
955
|
+
APP_ARTIFACTS: MediaOperationBucket;
|
|
956
|
+
}>;
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
Retained-output storage supplied by the host.
|
|
960
|
+
|
|
961
|
+
---
|
|
962
|
+
|
|
963
|
+
### MediaOperationStorage
|
|
964
|
+
|
|
965
|
+
```ts
|
|
966
|
+
type MediaOperationStorage = object;
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
SQL rows stay untrusted until the owner decodes their stored representation.
|
|
970
|
+
|
|
971
|
+
#### Properties
|
|
972
|
+
|
|
973
|
+
##### sql
|
|
974
|
+
|
|
975
|
+
```ts
|
|
976
|
+
sql: object;
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
Native synchronous SQL interface.
|
|
980
|
+
|
|
981
|
+
###### exec()
|
|
982
|
+
|
|
983
|
+
```ts
|
|
984
|
+
exec(query, ...bindings): object;
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
Execute a native SQL statement with positional bindings.
|
|
988
|
+
|
|
989
|
+
###### Parameters
|
|
990
|
+
|
|
991
|
+
| Parameter | Type |
|
|
992
|
+
| ------------- | ---------------------------------- |
|
|
993
|
+
| `query` | `string` |
|
|
994
|
+
| ...`bindings` | (`string` \| `number` \| `null`)[] |
|
|
995
|
+
|
|
996
|
+
###### Returns
|
|
997
|
+
|
|
998
|
+
| Name | Type | Description |
|
|
999
|
+
| ----------- | ------------------------- | ---------------------------------------------------------- |
|
|
1000
|
+
| `toArray()` | () => readonly `object`[] | Read the native SQL rows as objects for boundary decoding. |
|
|
1001
|
+
|
|
1002
|
+
#### Methods
|
|
1003
|
+
|
|
1004
|
+
##### transactionSync()
|
|
1005
|
+
|
|
1006
|
+
```ts
|
|
1007
|
+
transactionSync<T>(body): T;
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
Run one atomic synchronous local mutation.
|
|
1011
|
+
|
|
1012
|
+
###### Type Parameters
|
|
1013
|
+
|
|
1014
|
+
| Type Parameter |
|
|
1015
|
+
| -------------- |
|
|
1016
|
+
| `T` |
|
|
1017
|
+
|
|
1018
|
+
###### Parameters
|
|
1019
|
+
|
|
1020
|
+
| Parameter | Type |
|
|
1021
|
+
| --------- | --------- |
|
|
1022
|
+
| `body` | () => `T` |
|
|
1023
|
+
|
|
1024
|
+
###### Returns
|
|
1025
|
+
|
|
1026
|
+
`T`
|
|
1027
|
+
|
|
1028
|
+
##### isErased()
|
|
1029
|
+
|
|
1030
|
+
```ts
|
|
1031
|
+
isErased(): Promise<boolean>;
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
Read the durable erasure marker.
|
|
1035
|
+
|
|
1036
|
+
###### Returns
|
|
1037
|
+
|
|
1038
|
+
`Promise`\<`boolean`\>
|
|
1039
|
+
|
|
1040
|
+
##### markErased()
|
|
1041
|
+
|
|
1042
|
+
```ts
|
|
1043
|
+
markErased(): Promise<void>;
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
Persist the durable erasure marker.
|
|
1047
|
+
|
|
1048
|
+
###### Returns
|
|
1049
|
+
|
|
1050
|
+
`Promise`\<`void`\>
|
|
1051
|
+
|
|
1052
|
+
##### listKeys()
|
|
1053
|
+
|
|
1054
|
+
```ts
|
|
1055
|
+
listKeys(): Promise<readonly string[]>;
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
List local key-value storage keys for erasure readback.
|
|
1059
|
+
|
|
1060
|
+
###### Returns
|
|
1061
|
+
|
|
1062
|
+
`Promise`\<readonly `string`[]\>
|
|
1063
|
+
|
|
1064
|
+
##### deleteAlarm()
|
|
1065
|
+
|
|
1066
|
+
```ts
|
|
1067
|
+
deleteAlarm(): Promise<void>;
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
Remove any scheduled background alarm.
|
|
1071
|
+
|
|
1072
|
+
###### Returns
|
|
1073
|
+
|
|
1074
|
+
`Promise`\<`void`\>
|
|
1075
|
+
|
|
1076
|
+
##### deleteAll()
|
|
1077
|
+
|
|
1078
|
+
```ts
|
|
1079
|
+
deleteAll(): Promise<void>;
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
Remove local SQL and key-value storage.
|
|
1083
|
+
|
|
1084
|
+
###### Returns
|
|
1085
|
+
|
|
1086
|
+
`Promise`\<`void`\>
|
|
1087
|
+
|
|
1088
|
+
##### getAlarm()
|
|
1089
|
+
|
|
1090
|
+
```ts
|
|
1091
|
+
getAlarm(): Promise<number | null>;
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
Read the current background alarm, or null.
|
|
1095
|
+
|
|
1096
|
+
###### Returns
|
|
1097
|
+
|
|
1098
|
+
`Promise`\<`number` \| `null`\>
|
|
1099
|
+
|
|
1100
|
+
##### setAlarm()
|
|
1101
|
+
|
|
1102
|
+
```ts
|
|
1103
|
+
setAlarm(timestamp): Promise<void>;
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
Schedule background generation at the given timestamp.
|
|
1107
|
+
|
|
1108
|
+
###### Parameters
|
|
1109
|
+
|
|
1110
|
+
| Parameter | Type |
|
|
1111
|
+
| ----------- | -------- |
|
|
1112
|
+
| `timestamp` | `number` |
|
|
1113
|
+
|
|
1114
|
+
###### Returns
|
|
1115
|
+
|
|
1116
|
+
`Promise`\<`void`\>
|
|
1117
|
+
|
|
1118
|
+
---
|
|
1119
|
+
|
|
1120
|
+
### MediaOperationContext
|
|
1121
|
+
|
|
1122
|
+
```ts
|
|
1123
|
+
type MediaOperationContext = object;
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
The identity, serialization and storage owned by one media operation.
|
|
1127
|
+
|
|
1128
|
+
#### Properties
|
|
1129
|
+
|
|
1130
|
+
##### id
|
|
1131
|
+
|
|
1132
|
+
```ts
|
|
1133
|
+
id: object;
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
Durable operation identity selected by the host.
|
|
1137
|
+
|
|
1138
|
+
###### name
|
|
1139
|
+
|
|
1140
|
+
```ts
|
|
1141
|
+
name: string | undefined;
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
Stable error name or durable object name.
|
|
1145
|
+
|
|
1146
|
+
##### storage
|
|
1147
|
+
|
|
1148
|
+
```ts
|
|
1149
|
+
storage: MediaOperationStorage;
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
Host-owned SQL, key-value storage and alarms.
|
|
1153
|
+
|
|
1154
|
+
#### Methods
|
|
1155
|
+
|
|
1156
|
+
##### blockConcurrencyWhile()
|
|
1157
|
+
|
|
1158
|
+
```ts
|
|
1159
|
+
blockConcurrencyWhile<T>(body): Promise<T>;
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
Serialize asynchronous owner initialization with requests.
|
|
1163
|
+
|
|
1164
|
+
###### Type Parameters
|
|
1165
|
+
|
|
1166
|
+
| Type Parameter |
|
|
1167
|
+
| -------------- |
|
|
1168
|
+
| `T` |
|
|
1169
|
+
|
|
1170
|
+
###### Parameters
|
|
1171
|
+
|
|
1172
|
+
| Parameter | Type |
|
|
1173
|
+
| --------- | ---------------------- |
|
|
1174
|
+
| `body` | () => `Promise`\<`T`\> |
|
|
1175
|
+
|
|
1176
|
+
###### Returns
|
|
1177
|
+
|
|
1178
|
+
`Promise`\<`T`\>
|
|
1179
|
+
|
|
1180
|
+
---
|
|
1181
|
+
|
|
1182
|
+
### MediaOperationObject
|
|
1183
|
+
|
|
1184
|
+
```ts
|
|
1185
|
+
type MediaOperationObject = Readonly<{
|
|
1186
|
+
key: string;
|
|
1187
|
+
version: string;
|
|
1188
|
+
size: number;
|
|
1189
|
+
httpMetadata?: Readonly<{
|
|
1190
|
+
contentType?: string;
|
|
1191
|
+
}>;
|
|
1192
|
+
}>;
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
Object metadata consumed by retention and recovery; mirrors the native R2 fields
|
|
1196
|
+
used here.
|
|
1197
|
+
|
|
1198
|
+
---
|
|
1199
|
+
|
|
1200
|
+
### MediaOperationBucket
|
|
1201
|
+
|
|
1202
|
+
```ts
|
|
1203
|
+
type MediaOperationBucket = object;
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
Exact object operations needed for immutable media outputs and references.
|
|
1207
|
+
|
|
1208
|
+
#### Methods
|
|
1209
|
+
|
|
1210
|
+
##### put()
|
|
1211
|
+
|
|
1212
|
+
```ts
|
|
1213
|
+
put(
|
|
1214
|
+
key,
|
|
1215
|
+
bytes,
|
|
1216
|
+
options?
|
|
1217
|
+
): Promise<
|
|
1218
|
+
| Readonly<{
|
|
1219
|
+
version: string;
|
|
1220
|
+
}>
|
|
1221
|
+
| null>;
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
Conditionally retain immutable provider bytes or background reference bytes.
|
|
1225
|
+
|
|
1226
|
+
###### Parameters
|
|
1227
|
+
|
|
1228
|
+
| Parameter | Type |
|
|
1229
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1230
|
+
| `key` | `string` |
|
|
1231
|
+
| `bytes` | `Uint8Array` |
|
|
1232
|
+
| `options?` | `Readonly`\<\{ `onlyIf?`: `Readonly`\<\{ `etagDoesNotMatch`: `string`; \}\>; `httpMetadata?`: `Readonly`\<\{ `contentType`: `string`; \}\>; `customMetadata?`: `Readonly`\<`Record`\<`string`, `string`\>\>; \}\> |
|
|
1233
|
+
|
|
1234
|
+
###### Returns
|
|
1235
|
+
|
|
1236
|
+
`Promise`\< \| `Readonly`\<\{ `version`: `string`; \}\> \| `null`\>
|
|
1237
|
+
|
|
1238
|
+
##### head()
|
|
1239
|
+
|
|
1240
|
+
```ts
|
|
1241
|
+
head(key): Promise<
|
|
1242
|
+
| Readonly<{
|
|
1243
|
+
key: string;
|
|
1244
|
+
version: string;
|
|
1245
|
+
size: number;
|
|
1246
|
+
httpMetadata?: Readonly<{
|
|
1247
|
+
contentType?: string;
|
|
1248
|
+
}>;
|
|
1249
|
+
}>
|
|
1250
|
+
| null>;
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
Read immutable object metadata without loading bytes.
|
|
1254
|
+
|
|
1255
|
+
###### Parameters
|
|
1256
|
+
|
|
1257
|
+
| Parameter | Type |
|
|
1258
|
+
| --------- | -------- |
|
|
1259
|
+
| `key` | `string` |
|
|
1260
|
+
|
|
1261
|
+
###### Returns
|
|
1262
|
+
|
|
1263
|
+
`Promise`\< \| `Readonly`\<\{ `key`: `string`; `version`: `string`; `size`:
|
|
1264
|
+
`number`; `httpMetadata?`: `Readonly`\<\{ `contentType?`: `string`; \}\>; \}\>
|
|
1265
|
+
\| `null`\>
|
|
1266
|
+
|
|
1267
|
+
##### get()
|
|
1268
|
+
|
|
1269
|
+
```ts
|
|
1270
|
+
get(key): Promise<
|
|
1271
|
+
| Omit<Readonly<{
|
|
1272
|
+
key: string;
|
|
1273
|
+
version: string;
|
|
1274
|
+
size: number;
|
|
1275
|
+
httpMetadata?: Readonly<{
|
|
1276
|
+
contentType?: string;
|
|
1277
|
+
}>;
|
|
1278
|
+
}>, "httpMetadata"> & Readonly<{
|
|
1279
|
+
customMetadata?: Readonly<Record<string, string>>;
|
|
1280
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
1281
|
+
}>
|
|
1282
|
+
| null>;
|
|
1283
|
+
```
|
|
1284
|
+
|
|
1285
|
+
Read retained object bytes and metadata.
|
|
1286
|
+
|
|
1287
|
+
###### Parameters
|
|
1288
|
+
|
|
1289
|
+
| Parameter | Type |
|
|
1290
|
+
| --------- | -------- |
|
|
1291
|
+
| `key` | `string` |
|
|
1292
|
+
|
|
1293
|
+
###### Returns
|
|
1294
|
+
|
|
1295
|
+
`Promise`\< \| `Omit`\<`Readonly`\<\{ `key`: `string`; `version`: `string`;
|
|
1296
|
+
`size`: `number`; `httpMetadata?`: `Readonly`\<\{ `contentType?`: `string`;
|
|
1297
|
+
\}\>; \}\>, `"httpMetadata"`\> & `Readonly`\<\{ `customMetadata?`:
|
|
1298
|
+
`Readonly`\<`Record`\<`string`, `string`\>\>; `arrayBuffer`: () =>
|
|
1299
|
+
`Promise`\<`ArrayBuffer`\>; \}\> \| `null`\>
|
|
1300
|
+
|
|
1301
|
+
##### delete()
|
|
1302
|
+
|
|
1303
|
+
```ts
|
|
1304
|
+
delete(key): Promise<void>;
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
Delete the owner-selected object key.
|
|
1308
|
+
|
|
1309
|
+
###### Parameters
|
|
1310
|
+
|
|
1311
|
+
| Parameter | Type |
|
|
1312
|
+
| --------- | -------- |
|
|
1313
|
+
| `key` | `string` |
|
|
1314
|
+
|
|
1315
|
+
###### Returns
|
|
1316
|
+
|
|
1317
|
+
`Promise`\<`void`\>
|
|
1318
|
+
|
|
1319
|
+
---
|
|
1320
|
+
|
|
1321
|
+
### MediaScope
|
|
1322
|
+
|
|
1323
|
+
```ts
|
|
1324
|
+
type MediaScope = Readonly<{
|
|
1325
|
+
actorId: string;
|
|
1326
|
+
namespace: string;
|
|
1327
|
+
owner: string;
|
|
1328
|
+
destinationId: string;
|
|
1329
|
+
}>;
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
Identity supplied by the admitting host, never selected by a request body.
|
|
1333
|
+
|
|
1334
|
+
---
|
|
1335
|
+
|
|
1336
|
+
### MediaRefusalMessages
|
|
1337
|
+
|
|
1338
|
+
```ts
|
|
1339
|
+
type MediaRefusalMessages = Readonly<Record<MediaBillingRefusalCode, string>>;
|
|
1340
|
+
```
|
|
1341
|
+
|
|
1342
|
+
Customer-visible refusal text owned by a metered host.
|
|
1343
|
+
|
|
1344
|
+
---
|
|
1345
|
+
|
|
1346
|
+
### MediaServiceHost
|
|
1347
|
+
|
|
1348
|
+
```ts
|
|
1349
|
+
type MediaServiceHost = Readonly<{
|
|
1350
|
+
scope: MediaScope;
|
|
1351
|
+
operations: {
|
|
1352
|
+
getByName: MediaOperation;
|
|
1353
|
+
};
|
|
1354
|
+
provider: MediaProvider;
|
|
1355
|
+
beforeAdmit?: (requestId) => Promise<void>;
|
|
1356
|
+
authorizeGeneration?: () => Promise<void>;
|
|
1357
|
+
destination: Readonly<{
|
|
1358
|
+
authorize: (path) => Promise<void>;
|
|
1359
|
+
write: (path, bytes) => Promise<void>;
|
|
1360
|
+
readReference?: (reference) => Promise<MediaReferenceBytes>;
|
|
1361
|
+
}>;
|
|
1362
|
+
onFailure?: (error) => Response | undefined;
|
|
1363
|
+
}> &
|
|
1364
|
+
| Readonly<{
|
|
1365
|
+
metering: "unmetered";
|
|
1366
|
+
refusalMessages?: never;
|
|
1367
|
+
}>
|
|
1368
|
+
| Readonly<{
|
|
1369
|
+
metering: MediaMetering;
|
|
1370
|
+
refusalMessages: MediaRefusalMessages;
|
|
1371
|
+
}>;
|
|
1372
|
+
```
|
|
1373
|
+
|
|
1374
|
+
Host authority, durable operations, provider, metering and destination access.
|
|
1375
|
+
|
|
1376
|
+
---
|
|
1377
|
+
|
|
1378
|
+
### MediaGenerationRequest
|
|
1379
|
+
|
|
1380
|
+
```ts
|
|
1381
|
+
type MediaGenerationRequest = Readonly<{
|
|
1382
|
+
requestId: string;
|
|
1383
|
+
path: string;
|
|
1384
|
+
settings: Parameters<typeof validateMediaGenerationSettings>[0];
|
|
1385
|
+
outputFormat?: z.output<typeof mediaRequestSchema>["outputFormat"];
|
|
1386
|
+
}>;
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
One Media generation request, already carrying its idempotency key.
|
|
1390
|
+
|
|
1391
|
+
---
|
|
1392
|
+
|
|
1393
|
+
### MediaGenerationOutcome
|
|
1394
|
+
|
|
1395
|
+
```ts
|
|
1396
|
+
type MediaGenerationOutcome =
|
|
1397
|
+
| Readonly<{
|
|
1398
|
+
kind: "succeeded";
|
|
1399
|
+
path: string;
|
|
1400
|
+
bytes: number;
|
|
1401
|
+
costMilliunits: number;
|
|
1402
|
+
format: "png" | "jpeg" | "gif" | "webp" | "mp4";
|
|
1403
|
+
height: number;
|
|
1404
|
+
model: string;
|
|
1405
|
+
width: number;
|
|
1406
|
+
}>
|
|
1407
|
+
| Readonly<{
|
|
1408
|
+
kind: "pending";
|
|
1409
|
+
background: boolean;
|
|
1410
|
+
retryAfterSeconds: number;
|
|
1411
|
+
}>
|
|
1412
|
+
| Readonly<{
|
|
1413
|
+
kind: "conflict";
|
|
1414
|
+
}>
|
|
1415
|
+
| Readonly<{
|
|
1416
|
+
kind: "interrupted";
|
|
1417
|
+
}>
|
|
1418
|
+
| Readonly<{
|
|
1419
|
+
kind: "unavailable";
|
|
1420
|
+
}>;
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
The typed result of one generation, shared by the Hono route and the Agent path.
|
|
1424
|
+
|
|
1425
|
+
## Variables
|
|
1426
|
+
|
|
1427
|
+
### mediaResultSchema
|
|
1428
|
+
|
|
1429
|
+
```ts
|
|
1430
|
+
const mediaResultSchema: ZodObject<
|
|
1431
|
+
{
|
|
1432
|
+
bytes: ZodNumber;
|
|
1433
|
+
costMilliunits: ZodNumber;
|
|
1434
|
+
path: ZodString;
|
|
1435
|
+
format: ZodEnum<{
|
|
1436
|
+
png: "png";
|
|
1437
|
+
jpeg: "jpeg";
|
|
1438
|
+
gif: "gif";
|
|
1439
|
+
webp: "webp";
|
|
1440
|
+
mp4: "mp4";
|
|
1441
|
+
}>;
|
|
1442
|
+
height: ZodNumber;
|
|
1443
|
+
model: ZodString;
|
|
1444
|
+
width: ZodNumber;
|
|
1445
|
+
},
|
|
1446
|
+
$strict
|
|
1447
|
+
>;
|
|
1448
|
+
```
|
|
1449
|
+
|
|
1450
|
+
Decode a completed generation, destination path and estimated or settled price.
|
|
1451
|
+
|
|
1452
|
+
---
|
|
1453
|
+
|
|
1454
|
+
### mediaOperationDestinationSchema
|
|
1455
|
+
|
|
1456
|
+
```ts
|
|
1457
|
+
const mediaOperationDestinationSchema: ZodObject<
|
|
1458
|
+
{
|
|
1459
|
+
computerId: ZodString;
|
|
1460
|
+
path: ZodString;
|
|
1461
|
+
outputFormat: ZodOptional<
|
|
1462
|
+
ZodEnum<{
|
|
1463
|
+
png: "png";
|
|
1464
|
+
jpeg: "jpeg";
|
|
1465
|
+
webp: "webp";
|
|
1466
|
+
}>
|
|
1467
|
+
>;
|
|
1468
|
+
},
|
|
1469
|
+
$strict
|
|
1470
|
+
>;
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
Fixed generation destination captured before provider dispatch.
|
|
1474
|
+
|
|
1475
|
+
---
|
|
1476
|
+
|
|
1477
|
+
### mediaOperationCoordinatesSchema
|
|
1478
|
+
|
|
1479
|
+
```ts
|
|
1480
|
+
const mediaOperationCoordinatesSchema: ZodObject<
|
|
1481
|
+
{
|
|
1482
|
+
namespace: ZodString;
|
|
1483
|
+
owner: ZodString;
|
|
1484
|
+
},
|
|
1485
|
+
$strict
|
|
1486
|
+
>;
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
Decode host namespace and owner identity.
|
|
1490
|
+
|
|
1491
|
+
---
|
|
1492
|
+
|
|
1493
|
+
### mediaOperationStateSchema
|
|
1494
|
+
|
|
1495
|
+
```ts
|
|
1496
|
+
const mediaOperationStateSchema: ZodEnum<{
|
|
1497
|
+
admitted: "admitted";
|
|
1498
|
+
estimating: "estimating";
|
|
1499
|
+
generating: "generating";
|
|
1500
|
+
writing: "writing";
|
|
1501
|
+
charging: "charging";
|
|
1502
|
+
written: "written";
|
|
1503
|
+
succeeded: "succeeded";
|
|
1504
|
+
interrupted: "interrupted";
|
|
1505
|
+
}>;
|
|
1506
|
+
```
|
|
1507
|
+
|
|
1508
|
+
Decode durable generation, save and settlement states.
|
|
1509
|
+
|
|
1510
|
+
---
|
|
1511
|
+
|
|
1512
|
+
### mediaImageSchema
|
|
1513
|
+
|
|
1514
|
+
```ts
|
|
1515
|
+
const mediaImageSchema: ZodObject<
|
|
1516
|
+
{
|
|
1517
|
+
bytes: ZodNumber;
|
|
1518
|
+
format: ZodString;
|
|
1519
|
+
},
|
|
1520
|
+
$strict
|
|
1521
|
+
>;
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
Decode retained or saved output size and encoding.
|
|
1525
|
+
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
### mediaOperationResultSchema
|
|
1529
|
+
|
|
1530
|
+
```ts
|
|
1531
|
+
const mediaOperationResultSchema: ZodObject<
|
|
1532
|
+
{
|
|
1533
|
+
generationId: ZodString;
|
|
1534
|
+
bytes: ZodNumber;
|
|
1535
|
+
format: ZodString;
|
|
1536
|
+
costMilliunits: ZodNumber;
|
|
1537
|
+
},
|
|
1538
|
+
$strict
|
|
1539
|
+
>;
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
Decode the settled receipt, including the host-admitted customer price.
|
|
1543
|
+
|
|
1544
|
+
---
|
|
1545
|
+
|
|
1546
|
+
### mediaRequestSchema
|
|
1547
|
+
|
|
1548
|
+
```ts
|
|
1549
|
+
const mediaRequestSchema: ZodObject<{
|
|
1550
|
+
path: ZodString;
|
|
1551
|
+
settings: ZodObject<{
|
|
1552
|
+
model: ZodString;
|
|
1553
|
+
prompt: ZodString;
|
|
1554
|
+
width: ZodNumber;
|
|
1555
|
+
height: ZodNumber;
|
|
1556
|
+
steps: ZodOptional<ZodNumber>;
|
|
1557
|
+
durationSeconds: ZodOptional<ZodNumber>;
|
|
1558
|
+
resolution: ZodOptional<ZodEnum<{
|
|
1559
|
+
p480: "480p";
|
|
1560
|
+
p720: "720p";
|
|
1561
|
+
p1080: "1080p";
|
|
1562
|
+
p4k: "4k";
|
|
1563
|
+
}>>;
|
|
1564
|
+
aspectRatio: ZodOptional<ZodEnum<{
|
|
1565
|
+
wide: "16:9";
|
|
1566
|
+
landscape: "4:3";
|
|
1567
|
+
square: "1:1";
|
|
1568
|
+
portrait: "3:4";
|
|
1569
|
+
tall: "9:16";
|
|
1570
|
+
ultrawide: "21:9";
|
|
1571
|
+
ultratall: "9:21";
|
|
1572
|
+
}>>;
|
|
1573
|
+
generateAudio: ZodOptional<ZodBoolean>;
|
|
1574
|
+
references: ZodOptional<ZodArray<ZodObject<{
|
|
1575
|
+
computerId: ZodString;
|
|
1576
|
+
path: ZodString;
|
|
1577
|
+
role: ZodOptional<ZodEnum<{
|
|
1578
|
+
first: ...;
|
|
1579
|
+
last: ...;
|
|
1580
|
+
reference: ...;
|
|
1581
|
+
}>>;
|
|
1582
|
+
}, $strict>>>;
|
|
1583
|
+
}, $strict>;
|
|
1584
|
+
outputFormat: ZodOptional<ZodEnum<{
|
|
1585
|
+
png: "png";
|
|
1586
|
+
jpeg: "jpeg";
|
|
1587
|
+
webp: "webp";
|
|
1588
|
+
}>>;
|
|
1589
|
+
}, $strict>;
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
Decode relative service generation input. Identity comes from the host.
|
|
1593
|
+
|
|
1594
|
+
---
|
|
1595
|
+
|
|
1596
|
+
### mediaPendingSchema
|
|
1597
|
+
|
|
1598
|
+
```ts
|
|
1599
|
+
const mediaPendingSchema: ZodObject<
|
|
1600
|
+
{
|
|
1601
|
+
status: ZodLiteral<"pending">;
|
|
1602
|
+
retryAfterSeconds: ZodNumber;
|
|
1603
|
+
},
|
|
1604
|
+
$strict
|
|
1605
|
+
>;
|
|
1606
|
+
```
|
|
1607
|
+
|
|
1608
|
+
A background (video) generation in progress; retry the same request id.
|
|
1609
|
+
|
|
1610
|
+
## Functions
|
|
1611
|
+
|
|
1612
|
+
### mediaUnits()
|
|
1613
|
+
|
|
1614
|
+
```ts
|
|
1615
|
+
function mediaUnits(settings): MediaUnits;
|
|
1616
|
+
```
|
|
1617
|
+
|
|
1618
|
+
Billing units for validated settings; video bills its requested length.
|
|
1619
|
+
|
|
1620
|
+
#### Parameters
|
|
1621
|
+
|
|
1622
|
+
| Parameter | Type |
|
|
1623
|
+
| ---------- | ------------------------------------------------------------- |
|
|
1624
|
+
| `settings` | [`MediaGenerationSettings`](index.md#mediagenerationsettings) |
|
|
1625
|
+
|
|
1626
|
+
#### Returns
|
|
1627
|
+
|
|
1628
|
+
[`MediaUnits`](#mediaunits)
|
|
1629
|
+
|
|
1630
|
+
---
|
|
1631
|
+
|
|
1632
|
+
### generateMedia()
|
|
1633
|
+
|
|
1634
|
+
```ts
|
|
1635
|
+
function generateMedia(host, request, signal?): Promise<MediaGenerationOutcome>;
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
Generate through the Effect core with a Promise boundary preserving typed domain
|
|
1639
|
+
failures.
|
|
1640
|
+
|
|
1641
|
+
#### Parameters
|
|
1642
|
+
|
|
1643
|
+
| Parameter | Type |
|
|
1644
|
+
| --------- | --------------------------------------------------- |
|
|
1645
|
+
| `host` | [`MediaServiceHost`](#mediaservicehost) |
|
|
1646
|
+
| `request` | [`MediaGenerationRequest`](#mediagenerationrequest) |
|
|
1647
|
+
| `signal?` | `AbortSignal` |
|
|
1648
|
+
|
|
1649
|
+
#### Returns
|
|
1650
|
+
|
|
1651
|
+
`Promise`\<[`MediaGenerationOutcome`](#mediagenerationoutcome)\>
|
|
1652
|
+
|
|
1653
|
+
---
|
|
1654
|
+
|
|
1655
|
+
### createMediaService()
|
|
1656
|
+
|
|
1657
|
+
```ts
|
|
1658
|
+
function createMediaService(host): Hono<BlankEnv, BlankSchema, "/">;
|
|
1659
|
+
```
|
|
1660
|
+
|
|
1661
|
+
Relative HTTP routes; the caller admits identity and supplies destination
|
|
1662
|
+
access.
|
|
1663
|
+
|
|
1664
|
+
#### Parameters
|
|
1665
|
+
|
|
1666
|
+
| Parameter | Type |
|
|
1667
|
+
| --------- | --------------------------------------- |
|
|
1668
|
+
| `host` | [`MediaServiceHost`](#mediaservicehost) |
|
|
1669
|
+
|
|
1670
|
+
#### Returns
|
|
1671
|
+
|
|
1672
|
+
`Hono`\<`BlankEnv`, `BlankSchema`, `"/"`\>
|