@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.
@@ -65,6 +65,24 @@ export const mediaModelInputSchema = z.lazy(() => z
65
65
  maxSteps: z.number().int().positive().nullable(),
66
66
  /** Default inference step count. */
67
67
  defaultSteps: z.number().int().nonnegative().nullable(),
68
+ /**
69
+ * Prompt-guidance (`guidance`) bounds and default sent to the provider, or
70
+ * null when the model takes no guidance field. A host's own catalogue may
71
+ * omit the key; absent means null.
72
+ */
73
+ guidance: z
74
+ .strictObject({
75
+ /** Lowest value the provider accepts. */
76
+ min: z.number().nonnegative(),
77
+ /** Highest value the provider accepts. */
78
+ max: z.number().positive(),
79
+ /** Value sent when the caller names none. */
80
+ default: z.number().nonnegative(),
81
+ })
82
+ .readonly()
83
+ .refine((g) => g.min <= g.default && g.default <= g.max, "guidance default must lie within its bounds")
84
+ .nullable()
85
+ .default(null),
68
86
  /** Provider multipart reference-field prefix, or null when unsupported. */
69
87
  referenceField: z.string().min(1).max(256).nullable(),
70
88
  /** Maximum references accepted by this model. */
@@ -635,6 +653,7 @@ function videoModel(id, label, tier, provider, rates, bounds) {
635
653
  steps: "fixed",
636
654
  maxSteps: null,
637
655
  defaultSteps: null,
656
+ guidance: null,
638
657
  referenceField: seedance ? "image" : "image_input",
639
658
  maxReferences: seedance ? maxReferenceImages : 1,
640
659
  referenceDimension: null,
@@ -736,6 +755,7 @@ function minimaxVideoModel() {
736
755
  steps: "fixed",
737
756
  maxSteps: null,
738
757
  defaultSteps: null,
758
+ guidance: null,
739
759
  // Inert for this gateway model (media-generation.ts builds its body
740
760
  // directly); recorded for the same documentation parity as Seedance/Veo.
741
761
  referenceField: "image_url",
@@ -809,6 +829,7 @@ function audioModel(id, label, tier, maxPromptLength, audio) {
809
829
  steps: "fixed",
810
830
  maxSteps: null,
811
831
  defaultSteps: null,
832
+ guidance: null,
812
833
  referenceField: null,
813
834
  maxReferences: 0,
814
835
  referenceDimension: null,
@@ -859,6 +880,7 @@ function transformModel(input) {
859
880
  steps: "fixed",
860
881
  maxSteps: null,
861
882
  defaultSteps: null,
883
+ guidance: null,
862
884
  referenceField: "image",
863
885
  maxReferences: 1,
864
886
  // The hosts' reference fitter only shrinks; this keeps any source within
@@ -886,6 +908,7 @@ const models = Object.freeze([
886
908
  steps: "steps",
887
909
  maxSteps: 8,
888
910
  defaultSteps: 4,
911
+ guidance: null,
889
912
  referenceField: null,
890
913
  maxReferences: 0,
891
914
  // No documented reference size for this model; the retained 512 px fit.
@@ -909,6 +932,7 @@ const models = Object.freeze([
909
932
  steps: "fixed",
910
933
  maxSteps: null,
911
934
  defaultSteps: 4,
935
+ guidance: null,
912
936
  referenceField: "input_image_",
913
937
  maxReferences: 4,
914
938
  // No documented reference size for this model; the retained 512 px fit.
@@ -932,6 +956,7 @@ const models = Object.freeze([
932
956
  steps: "fixed",
933
957
  maxSteps: null,
934
958
  defaultSteps: 4,
959
+ guidance: null,
935
960
  referenceField: "input_image_",
936
961
  maxReferences: 4,
937
962
  // No documented reference size for this model; the retained 512 px fit.
@@ -955,6 +980,7 @@ const models = Object.freeze([
955
980
  steps: "steps",
956
981
  maxSteps: null,
957
982
  defaultSteps: 20,
983
+ guidance: null,
958
984
  referenceField: "input_image_",
959
985
  maxReferences: 4,
960
986
  // No documented reference size for this model; the retained 512 px fit.
@@ -979,6 +1005,9 @@ const models = Object.freeze([
979
1005
  steps: "num_steps",
980
1006
  maxSteps: 40,
981
1007
  defaultSteps: null,
1008
+ // https://developers.cloudflare.com/workers-ai/models/lucid-origin/ (guidance range); the
1009
+ // default is the value Loftwah's studio tuned for this model.
1010
+ guidance: { min: 0, max: 10, default: 5 },
982
1011
  referenceField: null,
983
1012
  maxReferences: 0,
984
1013
  // No documented reference size for this model; the retained 512 px fit.
@@ -1003,6 +1032,9 @@ const models = Object.freeze([
1003
1032
  steps: "num_steps",
1004
1033
  maxSteps: 50,
1005
1034
  defaultSteps: 25,
1035
+ // https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/ (guidance range); the
1036
+ // default is the value Loftwah's studio tuned for this model.
1037
+ guidance: { min: 2, max: 10, default: 3 },
1006
1038
  referenceField: null,
1007
1039
  maxReferences: 0,
1008
1040
  // No documented reference size for this model; the retained 512 px fit.
@@ -1030,6 +1062,7 @@ const models = Object.freeze([
1030
1062
  steps: "fixed",
1031
1063
  maxSteps: null,
1032
1064
  defaultSteps: null,
1065
+ guidance: null,
1033
1066
  // Cloudflare documents `images[]` (base64 strings or data URIs, 1-16
1034
1067
  // entries, routed to OpenAI's /v1/images/edits) for this exact model:
1035
1068
  // https://developers.cloudflare.com/ai/models/openai/gpt-image-2/
@@ -1068,6 +1101,7 @@ const models = Object.freeze([
1068
1101
  steps: "fixed",
1069
1102
  maxSteps: null,
1070
1103
  defaultSteps: null,
1104
+ guidance: null,
1071
1105
  // The page says the model takes up to 10 reference images (`image`, a
1072
1106
  // string or 1-10 strings) but shows only URL inputs and states no
1073
1107
  // base64 or data-URI form, so Prints sends none until it does.
@@ -3,7 +3,11 @@ import type { ImageFormat } from "./index.js";
3
3
  export type ProvenanceFacts = Readonly<{
4
4
  printId: string;
5
5
  model: string;
6
- prompt: string;
6
+ /**
7
+ * The prompt to publish in the file's XMP, or null to leave it out. The host
8
+ * decides per generation; a prompt is private unless the host opts in.
9
+ */
10
+ prompt: string | null;
7
11
  createdAt: number;
8
12
  }>;
9
13
  export type ProvenanceEmbedResult = Readonly<{
@@ -24,7 +24,8 @@ async function packet(facts) {
24
24
  .txt("http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia");
25
25
  description.ele("fungi:printId").txt(facts.printId);
26
26
  description.ele("fungi:model").txt(facts.model);
27
- description.ele("fungi:prompt").txt(facts.prompt);
27
+ if (facts.prompt !== null)
28
+ description.ele("fungi:prompt").txt(facts.prompt);
28
29
  return document.end({ headless: true });
29
30
  }
30
31
  async function embedWebp(bytes, xmp) {
package/dist/server.d.ts CHANGED
@@ -2,6 +2,10 @@ export { estimateMediaModel } from "./cloudflare/provider.js";
2
2
  export { mediaPendingSchema, mediaBindingCallSchema, mediaBindingGenerationSchema, mediaImageBindingInputSchema, mediaVideoBindingInputSchema, parseMediaBindingCall, mediaBindingRequest, readMediaBindingReply, type MediaBindingCall, type MediaBindingGeneration, type MediaBindingRequest, } from "./media-binding.js";
3
3
  import { Hono } from "hono";
4
4
  import { z } from "zod";
5
+ import type { MediaErasure, MediaRetained, MediaRetainedBytes } from "./media-operation-owner.js";
6
+ export type { MediaErasure, MediaRetained, MediaRetainedBytes };
7
+ export { mediaWrittenDigest, removeMediaIfWritten, type MediaRemoval, } from "./media-written.js";
8
+ import type { MediaRemoval } from "./media-written.js";
5
9
  import { validateMediaGenerationSettings, type MediaCatalogue, type MediaProvider, type MediaReference, type MediaReferenceBytes } from "./index.js";
6
10
  import { type MediaExecution, type MediaMetering } from "./media-operation-contract.js";
7
11
  import { MediaExecutionError, type MediaBillingRefusalCode } from "./execution-error.js";
@@ -12,8 +16,8 @@ export { mediaUnits, type MediaUnits } from "./gateway-models.js";
12
16
  export { quoteMediaGeneration, type MediaQuote } from "./media-quote.js";
13
17
  export type { MediaMetering, MediaOperation, } from "./media-operation-contract.js";
14
18
  export { MediaOperationOwner, mediaOperationDestinationSchema, mediaOperationCoordinatesSchema, mediaOperationStateSchema, mediaImageSchema, mediaOperationResultSchema, } from "./media-operation-owner.js";
15
- export type { MediaOperationCoordinates, MediaOperationRequest, MediaOperationProjection, MediaOperationDecision, MediaOperationState, MediaOperationResult, MediaOperationEnvironment, MediaOperationHooks, MediaImage, MediaErasurePreflight, MediaErasureReadback, MediaRetentionResult, } from "./media-operation-owner.js";
16
- export type { MediaOperationContext, MediaOperationStorage, MediaOperationBucket, MediaOperationObject, } from "./media-operation-storage.js";
19
+ export type { MediaOperationCoordinates, MediaOperationRequest, MediaOperationProjection, MediaOperationDecision, MediaOperationState, MediaOperationResult, MediaOperationEnvironment, MediaOperationHooks, MediaImage, MediaErasurePreflight, MediaErasureReadback, MediaErasePolicy, MediaRetentionResult, } from "./media-operation-owner.js";
20
+ export type { MediaOperationContext, MediaOperationStorage, MediaErasureMarker, MediaOperationBucket, MediaOperationObject, } from "./media-operation-storage.js";
17
21
  /** Decode relative service generation input. Identity comes from the host. */
18
22
  export declare const mediaRequestSchema: z.ZodObject<{
19
23
  path: z.ZodString;
@@ -23,6 +27,7 @@ export declare const mediaRequestSchema: z.ZodObject<{
23
27
  width: z.ZodOptional<z.ZodNumber>;
24
28
  height: z.ZodOptional<z.ZodNumber>;
25
29
  steps: z.ZodOptional<z.ZodNumber>;
30
+ guidance: z.ZodOptional<z.ZodNumber>;
26
31
  durationSeconds: z.ZodOptional<z.ZodNumber>;
27
32
  targetMegapixels: z.ZodOptional<z.ZodNumber>;
28
33
  voiceId: z.ZodOptional<z.ZodString>;
@@ -100,11 +105,25 @@ export type MediaServiceHost = Readonly<{
100
105
  authorize: (path: string) => Promise<void>;
101
106
  /** Save exact generated bytes to the admitted destination. */
102
107
  write: (path: string, bytes: Uint8Array) => Promise<void>;
108
+ /**
109
+ * Delete the file written at `path`, only while it still holds the bytes
110
+ * with this SHA-256, so a path reused for something else is never lost.
111
+ * Use `removeMediaIfWritten` to do the compare. Report what happened;
112
+ * "kept" means this destination cannot delete files.
113
+ */
114
+ remove: (path: string, written: Readonly<{
115
+ /** SHA-256 of the bytes written. */ sha256: string;
116
+ }>) => Promise<MediaRemoval>;
103
117
  /** Authorize and fit one selected reference image for the catalog model. */
104
118
  readReference?: (reference: MediaReference, model: string) => Promise<MediaReferenceBytes>;
105
119
  /** Authorize and read the raw bytes of one reference audio clip. */
106
120
  readAudioReference?: (reference: MediaReference) => Promise<Uint8Array>;
107
121
  }>;
122
+ /**
123
+ * Opt every `/generate` request into embedding its prompt in the saved
124
+ * image's XMP metadata. Omitted keeps the prompt private.
125
+ */
126
+ embedPrompt?: boolean | undefined;
108
127
  /** Translate host authority failures; undefined uses the shared Media failure. */
109
128
  onFailure?: (error: MediaExecutionError) => Response | undefined;
110
129
  }> & (Readonly<{
@@ -142,6 +161,11 @@ export type MediaGenerationRequest = Readonly<{
142
161
  settings: Parameters<typeof validateMediaGenerationSettings>[0];
143
162
  /** Optional verified image format pin. */
144
163
  outputFormat?: z.output<typeof mediaRequestSchema>["outputFormat"];
164
+ /**
165
+ * Publish the prompt in the saved image's XMP metadata (`fungi:prompt`).
166
+ * Omitted or false keeps it out: a host must opt in for each generation.
167
+ */
168
+ embedPrompt?: boolean | undefined;
145
169
  }>;
146
170
  /** The typed result of one generation, shared by the Hono route and the Agent path. */
147
171
  export type MediaGenerationOutcome = Readonly<{
@@ -180,5 +204,35 @@ export type MediaGenerationOutcome = Readonly<{
180
204
  }>;
181
205
  /** Generate through the Effect core with a Promise boundary preserving typed domain failures. */
182
206
  export declare function generateMedia(host: MediaServiceHost, request: MediaGenerationRequest, signal?: AbortSignal): Promise<MediaGenerationOutcome>;
207
+ /**
208
+ * What one generation still retains, by its request id: where its file goes,
209
+ * and the exact provider bytes held for recovery, including bytes a crash left
210
+ * unrecorded. Null once erased. Refuses another namespace.
211
+ */
212
+ export declare function retainedMedia(host: Pick<MediaServiceHost, "operations" | "scope">, requestId: string): Promise<MediaRetained | null>;
213
+ /**
214
+ * Read back the exact provider bytes a generation retained, before any
215
+ * provenance, so a host can re-save a result whose destination write was lost.
216
+ * Null when erased or nothing was retained. Refuses another namespace.
217
+ */
218
+ export declare function readRetainedMedia(host: Pick<MediaServiceHost, "operations" | "scope">, requestId: string): Promise<MediaRetainedBytes | null>;
219
+ /** Erasure of one generation, with what happened to its destination file. */
220
+ export type MediaOperationErasure = MediaErasure & Readonly<{
221
+ /**
222
+ * What the destination did with the file this operation wrote: null when
223
+ * none was ever begun. "not-ours" means the path now holds other bytes and
224
+ * was left alone.
225
+ */
226
+ destinationFile: MediaRemoval | null;
227
+ }>;
228
+ /**
229
+ * Erase everything a generation retained or could still write: its retained
230
+ * output, reference copies, storage and the destination file (only while it
231
+ * still holds what this operation wrote). Works mid generation: the operation
232
+ * refuses later writes, deletes anything that lands, and its open billing hold
233
+ * is settled at zero units. Call again until `clear` is true; the destination
234
+ * facts are kept for that retry.
235
+ */
236
+ export declare function eraseMediaOperation(host: Pick<MediaServiceHost, "operations" | "scope" | "destination" | "metering">, requestId: string): Promise<MediaOperationErasure>;
183
237
  /** Relative HTTP routes; the caller admits identity and supplies destination access. */
184
238
  export declare function createMediaService(host: MediaServiceHost): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
package/dist/server.js CHANGED
@@ -8,6 +8,7 @@ import { AppError, describeAppError } from "@fungi.computer/agar/errors";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Result from "effect/Result";
10
10
  import { mediaPathSchema } from "./media-path.js";
11
+ export { mediaWrittenDigest, removeMediaIfWritten, } from "./media-written.js";
11
12
  import { runMediaGeneration } from "./media-generation.js";
12
13
  import { quoteMediaGeneration } from "./media-quote.js";
13
14
  import { validateMediaGenerationSettings, listMediaModels, mediaGenerationSettingsSchema, mediaRequestedImageFormatSchema, MediaSettingsError, } from "./index.js";
@@ -145,6 +146,48 @@ export async function generateMedia(host, request, signal) {
145
146
  const result = await Effect.runPromise(Effect.result(runMediaGeneration(host, request, signal)));
146
147
  return Result.getOrThrowWith(result, (error) => error);
147
148
  }
149
+ /**
150
+ * What one generation still retains, by its request id: where its file goes,
151
+ * and the exact provider bytes held for recovery, including bytes a crash left
152
+ * unrecorded. Null once erased. Refuses another namespace.
153
+ */
154
+ export function retainedMedia(host, requestId) {
155
+ return Promise.resolve(host.operations
156
+ .getByName(`media:${requestId}`)
157
+ .retained(host.scope.namespace, requestId));
158
+ }
159
+ /**
160
+ * Read back the exact provider bytes a generation retained, before any
161
+ * provenance, so a host can re-save a result whose destination write was lost.
162
+ * Null when erased or nothing was retained. Refuses another namespace.
163
+ */
164
+ export function readRetainedMedia(host, requestId) {
165
+ return Promise.resolve(host.operations
166
+ .getByName(`media:${requestId}`)
167
+ .readRetained(host.scope.namespace, requestId));
168
+ }
169
+ /**
170
+ * Erase everything a generation retained or could still write: its retained
171
+ * output, reference copies, storage and the destination file (only while it
172
+ * still holds what this operation wrote). Works mid generation: the operation
173
+ * refuses later writes, deletes anything that lands, and its open billing hold
174
+ * is settled at zero units. Call again until `clear` is true; the destination
175
+ * facts are kept for that retry.
176
+ */
177
+ export async function eraseMediaOperation(host, requestId) {
178
+ const operationId = `media:${requestId}`;
179
+ const erased = await host.operations
180
+ .getByName(operationId)
181
+ .erase(host.scope.namespace, requestId);
182
+ if (erased.abandonedGeneration && host.metering !== "unmetered")
183
+ await host.metering.settle({ operationId, units: 0 });
184
+ const destinationFile = erased.destinationPath === null || erased.writtenSha256 === null
185
+ ? null
186
+ : await host.destination.remove(erased.destinationPath, {
187
+ sha256: erased.writtenSha256,
188
+ });
189
+ return { ...erased, destinationFile };
190
+ }
148
191
  function outcomeResponse(outcome) {
149
192
  if (outcome.kind === "conflict")
150
193
  return Response.json({
@@ -232,6 +275,7 @@ export function createMediaService(host) {
232
275
  path: input.data.path,
233
276
  settings: input.data.settings,
234
277
  outputFormat: input.data.outputFormat,
278
+ embedPrompt: host.embedPrompt,
235
279
  }, context.req.raw.signal).pipe(Effect.match({
236
280
  onSuccess: outcomeResponse,
237
281
  onFailure: (error) => (error instanceof MediaExecutionError
@@ -26,6 +26,7 @@ const mediaModelPriceEstimateSchema: ZodObject<{
26
26
  width: ZodOptional<ZodNumber>;
27
27
  height: ZodOptional<ZodNumber>;
28
28
  steps: ZodOptional<ZodNumber>;
29
+ guidance: ZodOptional<ZodNumber>;
29
30
  durationSeconds: ZodOptional<ZodNumber>;
30
31
  targetMegapixels: ZodOptional<ZodNumber>;
31
32
  voiceId: ZodOptional<ZodString>;
@@ -84,6 +85,7 @@ const mediaCatalogModelSchema: ZodReadonly<ZodObject<{
84
85
  width: ZodOptional<ZodNumber>;
85
86
  height: ZodOptional<ZodNumber>;
86
87
  steps: ZodOptional<ZodNumber>;
88
+ guidance: ZodOptional<ZodNumber>;
87
89
  durationSeconds: ZodOptional<ZodNumber>;
88
90
  targetMegapixels: ZodOptional<ZodNumber>;
89
91
  voiceId: ZodOptional<ZodString>;
@@ -147,6 +149,7 @@ const mediaCatalogModelSchema: ZodReadonly<ZodObject<{
147
149
  }>;
148
150
  maxSteps: ZodNullable<ZodNumber>;
149
151
  defaultSteps: ZodNullable<ZodNumber>;
152
+ guidance: ZodDefault<ZodNullable<ZodReadonly<ZodObject<..., ...>>>>;
150
153
  referenceField: ZodNullable<ZodString>;
151
154
  maxReferences: ZodNumber;
152
155
  referenceDimension: ZodNullable<ZodNumber>;
@@ -246,6 +249,7 @@ const mediaModelsSchema: ZodLazy<ZodArray<ZodReadonly<ZodObject<{
246
249
  width: ZodOptional<...>;
247
250
  height: ZodOptional<...>;
248
251
  steps: ZodOptional<...>;
252
+ guidance: ZodOptional<...>;
249
253
  durationSeconds: ZodOptional<...>;
250
254
  targetMegapixels: ZodOptional<...>;
251
255
  voiceId: ZodOptional<...>;
@@ -295,6 +299,7 @@ const mediaModelsSchema: ZodLazy<ZodArray<ZodReadonly<ZodObject<{
295
299
  }>;
296
300
  maxSteps: ZodNullable<ZodNumber>;
297
301
  defaultSteps: ZodNullable<ZodNumber>;
302
+ guidance: ZodDefault<ZodNullable<...>>;
298
303
  referenceField: ZodNullable<ZodString>;
299
304
  maxReferences: ZodNumber;
300
305
  referenceDimension: ZodNullable<ZodNumber>;
@@ -643,6 +648,7 @@ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodLazy<ZodArray<ZodReadon
643
648
  steps: ...;
644
649
  maxSteps: ...;
645
650
  defaultSteps: ...;
651
+ guidance: ...;
646
652
  referenceField: ...;
647
653
  maxReferences: ...;
648
654
  referenceDimension: ...;
@@ -218,15 +218,77 @@ Check host namespace, request identity and inactivity before erasure.
218
218
 
219
219
  `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"preflightErasure"`\]\>
220
220
 
221
+ ##### recordWriteIntent()
222
+
223
+ ```ts
224
+ recordWriteIntent(...input): ReturnType<MediaOperationOwner["recordWriteIntent"]>;
225
+ ```
226
+
227
+ Record the digest of the exact bytes about to be written to the destination,
228
+ before writing them. An erasure then knows which file this operation owns, even
229
+ if the process dies between the write and its record, and refuses the write once
230
+ erased.
231
+
232
+ ###### Parameters
233
+
234
+ | Parameter | Type | Description |
235
+ | ---------- | ---------------------- | ----------- |
236
+ | ...`input` | \[`string`, `string`\] | - |
237
+
238
+ ###### Returns
239
+
240
+ `ReturnType`\<[`MediaOperationOwner`](server.md#mediaoperationowner)\[`"recordWriteIntent"`\]\>
241
+
221
242
  ##### erase()
222
243
 
223
244
  ```ts
224
- erase(...input): Promise<Readonly<{
225
- clear: boolean;
226
- }>>;
245
+ erase(...input): Promise<MediaErasure>;
227
246
  ```
228
247
 
229
- Erase inactive output and local storage, then retain the durable erasure marker.
248
+ Erase the operation and everything it retained or could still write, even
249
+ mid-generation. Erasure is marked first, so an attempt still running, or a lease
250
+ recovered later, can neither transition nor leave output behind: a write that
251
+ lands after the mark is deleted. The marker is never removed, so a crash cannot
252
+ resurrect the operation. Safe to repeat until `clear`; a repeat after a partial
253
+ failure resumes the cleanup.
254
+
255
+ ###### Parameters
256
+
257
+ | Parameter | Type | Description |
258
+ | ---------- | ------------------------------------------------------------------------ | ----------- |
259
+ | ...`input` | \[`string`, `string`, [`MediaErasePolicy`](server.md#mediaerasepolicy)\] | - |
260
+
261
+ ###### Returns
262
+
263
+ `Promise`\<[`MediaErasure`](server.md#mediaerasure)\>
264
+
265
+ ##### retained()
266
+
267
+ ```ts
268
+ retained(...input): Promise<
269
+ | Readonly<{
270
+ requestId: string;
271
+ state: | "admitted"
272
+ | "estimating"
273
+ | "generating"
274
+ | "writing"
275
+ | "charging"
276
+ | "written"
277
+ | "succeeded"
278
+ | "interrupted";
279
+ destinationPath: string;
280
+ output: | Readonly<{
281
+ bytes: number;
282
+ format: string;
283
+ contentType: string;
284
+ }>
285
+ | null;
286
+ }>
287
+ | null>;
288
+ ```
289
+
290
+ List what this operation retains: its destination path and exact provider
291
+ output. Null once erased.
230
292
 
231
293
  ###### Parameters
232
294
 
@@ -236,7 +298,37 @@ Erase inactive output and local storage, then retain the durable erasure marker.
236
298
 
237
299
  ###### Returns
238
300
 
239
- `Promise`\<`Readonly`\<\{ `clear`: `boolean`; \}\>\>
301
+ `Promise`\< \| `Readonly`\<\{ `requestId`: `string`; `state`: \| `"admitted"` \|
302
+ `"estimating"` \| `"generating"` \| `"writing"` \| `"charging"` \| `"written"`
303
+ \| `"succeeded"` \| `"interrupted"`; `destinationPath`: `string`; `output`: \|
304
+ `Readonly`\<\{ `bytes`: `number`; `format`: `string`; `contentType`: `string`;
305
+ \}\> \| `null`; \}\> \| `null`\>
306
+
307
+ ##### readRetained()
308
+
309
+ ```ts
310
+ readRetained(...input): Promise<
311
+ | Readonly<{
312
+ bytes: Uint8Array;
313
+ format: string;
314
+ }>
315
+ | null>;
316
+ ```
317
+
318
+ Read back the exact retained provider bytes, before any provenance, so a host
319
+ can re-save a result whose destination write was lost. Null when erased or
320
+ nothing was retained.
321
+
322
+ ###### Parameters
323
+
324
+ | Parameter | Type | Description |
325
+ | ---------- | ---------------------- | ----------- |
326
+ | ...`input` | \[`string`, `string`\] | - |
327
+
328
+ ###### Returns
329
+
330
+ `Promise`\< \| `Readonly`\<\{ `bytes`: `Uint8Array`; `format`: `string`; \}\> \|
331
+ `null`\>
240
332
 
241
333
  ##### readErasure()
242
334
 
@@ -657,6 +749,24 @@ Store exact bytes with their MIME type.
657
749
 
658
750
  `Promise`\<`object` \| `null`\>
659
751
 
752
+ ##### delete()
753
+
754
+ ```ts
755
+ delete(key): Promise<void>;
756
+ ```
757
+
758
+ Delete one object; absent keys are not an error.
759
+
760
+ ###### Parameters
761
+
762
+ | Parameter | Type |
763
+ | --------- | -------- |
764
+ | `key` | `string` |
765
+
766
+ ###### Returns
767
+
768
+ `Promise`\<`void`\>
769
+
660
770
  ---
661
771
 
662
772
  ### R2MediaDestinationOptions
@@ -885,6 +995,30 @@ Re-exports [MediaOperationOwner](server.md#mediaoperationowner)
885
995
 
886
996
  ---
887
997
 
998
+ ### MediaErasure
999
+
1000
+ Re-exports [MediaErasure](server.md#mediaerasure)
1001
+
1002
+ ---
1003
+
1004
+ ### MediaRetained
1005
+
1006
+ Re-exports [MediaRetained](server.md#mediaretained)
1007
+
1008
+ ---
1009
+
1010
+ ### MediaRetainedBytes
1011
+
1012
+ Re-exports [MediaRetainedBytes](server.md#mediaretainedbytes)
1013
+
1014
+ ---
1015
+
1016
+ ### MediaErasePolicy
1017
+
1018
+ Re-exports [MediaErasePolicy](server.md#mediaerasepolicy)
1019
+
1020
+ ---
1021
+
888
1022
  ### MediaOperationContext
889
1023
 
890
1024
  Re-exports [MediaOperationContext](server.md#mediaoperationcontext)
@@ -897,6 +1031,12 @@ Re-exports [MediaOperationStorage](server.md#mediaoperationstorage)
897
1031
 
898
1032
  ---
899
1033
 
1034
+ ### MediaErasureMarker
1035
+
1036
+ Re-exports [MediaErasureMarker](server.md#mediaerasuremarker)
1037
+
1038
+ ---
1039
+
900
1040
  ### MediaOperationBucket
901
1041
 
902
1042
  Re-exports [MediaOperationBucket](server.md#mediaoperationbucket)