@fungi.computer/darkroom 0.11.34 → 0.11.36
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/dist/app-media-contracts.js +27 -22
- package/dist/index.js +53 -43
- package/dist/media-binding.js +23 -21
- package/dist/model-catalog.js +77 -64
- package/package.json +2 -2
- package/src/app-media-contracts.ts +35 -30
- package/src/index.ts +48 -43
- package/src/media-binding.ts +37 -33
- package/src/model-catalog.ts +89 -68
package/src/index.ts
CHANGED
|
@@ -181,7 +181,7 @@ export const MIN_VIEW_DIMENSION = 256;
|
|
|
181
181
|
/** Maximum long-edge size accepted by an image viewer, in pixels. */
|
|
182
182
|
export const MAX_VIEW_DIMENSION = 512;
|
|
183
183
|
/** Decode a viewer long-edge size within the supported pixel bounds. */
|
|
184
|
-
export const viewDimensionSchema = z.lazy(() =>
|
|
184
|
+
export const viewDimensionSchema = /* @__PURE__ */ z.lazy(() =>
|
|
185
185
|
z.number().int().min(MIN_VIEW_DIMENSION).max(MAX_VIEW_DIMENSION),
|
|
186
186
|
);
|
|
187
187
|
/**
|
|
@@ -243,57 +243,57 @@ const normalizeReference = (value: {
|
|
|
243
243
|
export const MAX_AUDIO_REFERENCE_COUNT = 10;
|
|
244
244
|
|
|
245
245
|
/** Structural wire grammar for one Media generation request. */
|
|
246
|
-
export const mediaGenerationSettingsSchema = z
|
|
246
|
+
export const mediaGenerationSettingsSchema = /* @__PURE__ */ z
|
|
247
247
|
.object({
|
|
248
248
|
/** Provider catalog model identifier. */
|
|
249
|
-
model: z.string().min(1).max(256),
|
|
249
|
+
model: /* @__PURE__ */ z.string().min(1).max(256),
|
|
250
250
|
/** Generation prompt; each model's `maxPromptLength` is enforced on top of this ceiling. */
|
|
251
|
-
prompt: z.string().min(1).max(MAX_MEDIA_PROMPT_LENGTH),
|
|
251
|
+
prompt: /* @__PURE__ */ z.string().min(1).max(MAX_MEDIA_PROMPT_LENGTH),
|
|
252
252
|
/** Requested image width or nominal video selector; absent for audio. */
|
|
253
|
-
width: z.number().int().min(1).max(5_040).optional(),
|
|
253
|
+
width: /* @__PURE__ */ z.number().int().min(1).max(5_040).optional(),
|
|
254
254
|
/** Requested image height or nominal video selector; absent for audio. */
|
|
255
|
-
height: z.number().int().min(1).max(5_040).optional(),
|
|
255
|
+
height: /* @__PURE__ */ z.number().int().min(1).max(5_040).optional(),
|
|
256
256
|
/** Model-specific inference step count. */
|
|
257
|
-
steps: z.number().int().optional(),
|
|
257
|
+
steps: /* @__PURE__ */ z.number().int().optional(),
|
|
258
258
|
/** Prompt guidance; models without a catalog guidance range refuse it. */
|
|
259
|
-
guidance: z.number().optional(),
|
|
259
|
+
guidance: /* @__PURE__ */ z.number().optional(),
|
|
260
260
|
/** Requested video or music length in whole seconds. */
|
|
261
|
-
durationSeconds: z.number().int().optional(),
|
|
261
|
+
durationSeconds: /* @__PURE__ */ z.number().int().optional(),
|
|
262
262
|
/** Upscale only: the output size in megapixels, one of the model's offered sizes. */
|
|
263
|
-
targetMegapixels: z.number().int().optional(),
|
|
263
|
+
targetMegapixels: /* @__PURE__ */ z.number().int().optional(),
|
|
264
264
|
/** Speech models only: a premade voice from the catalog; the default when omitted. */
|
|
265
|
-
voiceId: z.string().min(1).max(64).optional(),
|
|
265
|
+
voiceId: /* @__PURE__ */ z.string().min(1).max(64).optional(),
|
|
266
266
|
/** Video resolution; must match the nominal width/height selector. */
|
|
267
|
-
resolution: mediaVideoResolutionSchema.optional(),
|
|
267
|
+
resolution: /* @__PURE__ */ mediaVideoResolutionSchema.optional(),
|
|
268
268
|
/** Video aspect; must match the nominal width/height selector. */
|
|
269
|
-
aspectRatio: mediaVideoAspectRatioSchema.optional(),
|
|
269
|
+
aspectRatio: /* @__PURE__ */ mediaVideoAspectRatioSchema.optional(),
|
|
270
270
|
/** Video audio selection. */
|
|
271
|
-
generateAudio: z.boolean().optional(),
|
|
271
|
+
generateAudio: /* @__PURE__ */ z.boolean().optional(),
|
|
272
272
|
/** Host-authorized reference images. */
|
|
273
|
-
references: z
|
|
273
|
+
references: /* @__PURE__ */ z
|
|
274
274
|
.array(
|
|
275
|
-
z
|
|
275
|
+
/* @__PURE__ */ z
|
|
276
276
|
.object({
|
|
277
277
|
/** Host-admitted destination or reference identity. */
|
|
278
|
-
computerId: z.string().min(1).max(256),
|
|
278
|
+
computerId: /* @__PURE__ */ z.string().min(1).max(256),
|
|
279
279
|
/** Fixed destination or reference file path. */
|
|
280
|
-
path: z.string().min(1).max(4_096),
|
|
280
|
+
path: /* @__PURE__ */ z.string().min(1).max(4_096),
|
|
281
281
|
/** Video-only reference role. */
|
|
282
|
-
role: mediaVideoReferenceRoleSchema.optional(),
|
|
282
|
+
role: /* @__PURE__ */ mediaVideoReferenceRoleSchema.optional(),
|
|
283
283
|
})
|
|
284
284
|
.strict(),
|
|
285
285
|
)
|
|
286
286
|
.max(MAX_REFERENCE_COUNT)
|
|
287
287
|
.optional(),
|
|
288
288
|
/** Host-authorized reference audio clips; only a model declaring `audioReferences` takes them. */
|
|
289
|
-
audioReferences: z
|
|
289
|
+
audioReferences: /* @__PURE__ */ z
|
|
290
290
|
.array(
|
|
291
|
-
z
|
|
291
|
+
/* @__PURE__ */ z
|
|
292
292
|
.object({
|
|
293
293
|
/** Host-admitted destination or reference identity. */
|
|
294
|
-
computerId: z.string().min(1).max(256),
|
|
294
|
+
computerId: /* @__PURE__ */ z.string().min(1).max(256),
|
|
295
295
|
/** Fixed reference file path. */
|
|
296
|
-
path: z.string().min(1).max(4_096),
|
|
296
|
+
path: /* @__PURE__ */ z.string().min(1).max(4_096),
|
|
297
297
|
})
|
|
298
298
|
.strict(),
|
|
299
299
|
)
|
|
@@ -307,32 +307,32 @@ export type MediaGenerationSettingsInput = z.input<
|
|
|
307
307
|
>;
|
|
308
308
|
/** A reference may select another Computer; identity never grants access. */
|
|
309
309
|
export const mediaGenerationSelectionSchema =
|
|
310
|
-
mediaGenerationSettingsSchema.extend({
|
|
310
|
+
/* @__PURE__ */ mediaGenerationSettingsSchema.extend({
|
|
311
311
|
/** Host-authorized reference images. */
|
|
312
|
-
references: z
|
|
312
|
+
references: /* @__PURE__ */ z
|
|
313
313
|
.array(
|
|
314
|
-
z
|
|
314
|
+
/* @__PURE__ */ z
|
|
315
315
|
.object({
|
|
316
316
|
/** Omit for the selected Computer; the host authorizes every named Computer. */
|
|
317
|
-
computerId: z.string().min(1).max(256).optional(),
|
|
317
|
+
computerId: /* @__PURE__ */ z.string().min(1).max(256).optional(),
|
|
318
318
|
/** Fixed destination or reference file path. */
|
|
319
|
-
path: z.string().min(1).max(4_096),
|
|
319
|
+
path: /* @__PURE__ */ z.string().min(1).max(4_096),
|
|
320
320
|
/** Video-only reference role. */
|
|
321
|
-
role: mediaVideoReferenceRoleSchema.optional(),
|
|
321
|
+
role: /* @__PURE__ */ mediaVideoReferenceRoleSchema.optional(),
|
|
322
322
|
})
|
|
323
323
|
.strict(),
|
|
324
324
|
)
|
|
325
325
|
.max(MAX_REFERENCE_COUNT)
|
|
326
326
|
.optional(),
|
|
327
327
|
/** Host-authorized reference audio clips. */
|
|
328
|
-
audioReferences: z
|
|
328
|
+
audioReferences: /* @__PURE__ */ z
|
|
329
329
|
.array(
|
|
330
|
-
z
|
|
330
|
+
/* @__PURE__ */ z
|
|
331
331
|
.object({
|
|
332
332
|
/** Omit for the selected Computer; the host authorizes every named Computer. */
|
|
333
|
-
computerId: z.string().min(1).max(256).optional(),
|
|
333
|
+
computerId: /* @__PURE__ */ z.string().min(1).max(256).optional(),
|
|
334
334
|
/** Fixed reference file path. */
|
|
335
|
-
path: z.string().min(1).max(4_096),
|
|
335
|
+
path: /* @__PURE__ */ z.string().min(1).max(4_096),
|
|
336
336
|
})
|
|
337
337
|
.strict(),
|
|
338
338
|
)
|
|
@@ -715,7 +715,7 @@ function normalizeAudioSettings<Reference>(
|
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
/** Path-only video reference; the host supplies authority and reads its bytes. */
|
|
718
|
-
export const mediaVideoReferenceSchema = z.lazy(() =>
|
|
718
|
+
export const mediaVideoReferenceSchema = /* @__PURE__ */ z.lazy(() =>
|
|
719
719
|
z.strictObject({
|
|
720
720
|
/** Selected image path, trimmed and nonblank after validation. */
|
|
721
721
|
path: z.string().min(1).max(4_096),
|
|
@@ -726,7 +726,7 @@ export const mediaVideoReferenceSchema = z.lazy(() =>
|
|
|
726
726
|
/** One path-only video reference. */
|
|
727
727
|
export type MediaVideoReference = z.output<typeof mediaVideoReferenceSchema>;
|
|
728
728
|
/** Path-only audio reference; the host supplies authority and reads its bytes. */
|
|
729
|
-
export const mediaAudioReferenceSelectionSchema = z.lazy(() =>
|
|
729
|
+
export const mediaAudioReferenceSelectionSchema = /* @__PURE__ */ z.lazy(() =>
|
|
730
730
|
z.strictObject({
|
|
731
731
|
/** Selected audio file path, trimmed and nonblank after validation. */
|
|
732
732
|
path: z.string().min(1).max(4_096),
|
|
@@ -737,7 +737,7 @@ export type MediaAudioReferenceSelection = z.output<
|
|
|
737
737
|
typeof mediaAudioReferenceSelectionSchema
|
|
738
738
|
>;
|
|
739
739
|
/** Neutral video selection; model-specific combinations are checked by validateMediaVideoSelection. */
|
|
740
|
-
export const mediaVideoSelectionSchema = z.lazy(() =>
|
|
740
|
+
export const mediaVideoSelectionSchema = /* @__PURE__ */ z.lazy(() =>
|
|
741
741
|
z.strictObject({
|
|
742
742
|
/** Verified catalog model identifier. */
|
|
743
743
|
model: mediaVideoModelIdSchema,
|
|
@@ -768,9 +768,9 @@ export const mediaVideoSelectionSchema = z.lazy(() =>
|
|
|
768
768
|
* The same selection for a host's own catalogue: the model is any id that
|
|
769
769
|
* catalogue lists, checked by `validateMediaVideoSelection`.
|
|
770
770
|
*/
|
|
771
|
-
const catalogueVideoSelectionSchema = mediaVideoSelectionSchema
|
|
771
|
+
const catalogueVideoSelectionSchema = /* @__PURE__ */ mediaVideoSelectionSchema
|
|
772
772
|
.unwrap()
|
|
773
|
-
.extend({ model: z.string().min(1).max(256) });
|
|
773
|
+
.extend({ model: /* @__PURE__ */ z.string().min(1).max(256) });
|
|
774
774
|
/** Caller video selection before defaults and model-specific refinements. */
|
|
775
775
|
export type MediaVideoSelectionInput = z.input<
|
|
776
776
|
typeof mediaVideoSelectionSchema
|
|
@@ -916,7 +916,7 @@ function normalizeTransformSettings<
|
|
|
916
916
|
}
|
|
917
917
|
|
|
918
918
|
/** Neutral audio selection: speech takes a voice, music a length; model-specific limits are checked by validateMediaGenerationSettings. */
|
|
919
|
-
export const mediaAudioSelectionSchema = z.lazy(() =>
|
|
919
|
+
export const mediaAudioSelectionSchema = /* @__PURE__ */ z.lazy(() =>
|
|
920
920
|
z.strictObject({
|
|
921
921
|
/** Verified catalog audio model identifier. */
|
|
922
922
|
model: mediaAudioModelIdSchema,
|
|
@@ -941,7 +941,12 @@ export type MediaReferenceReader = Readonly<{
|
|
|
941
941
|
model: string,
|
|
942
942
|
) => Promise<MediaReferenceBytes>;
|
|
943
943
|
}>;
|
|
944
|
-
const imageFormats = new Set<ImageFormat>([
|
|
944
|
+
const imageFormats = /* @__PURE__ */ new Set<ImageFormat>([
|
|
945
|
+
"png",
|
|
946
|
+
"jpeg",
|
|
947
|
+
"gif",
|
|
948
|
+
"webp",
|
|
949
|
+
]);
|
|
945
950
|
|
|
946
951
|
/**
|
|
947
952
|
* Refuse a source image the operation cannot take, with plain copy, before any
|
|
@@ -1157,7 +1162,7 @@ export type MediaProviderOutput =
|
|
|
1157
1162
|
/** Provider output image entries. */
|
|
1158
1163
|
entries: readonly MediaProviderImageEntry[];
|
|
1159
1164
|
}>;
|
|
1160
|
-
const providerEntrySchema = z.lazy(() =>
|
|
1165
|
+
const providerEntrySchema = /* @__PURE__ */ z.lazy(() =>
|
|
1161
1166
|
z
|
|
1162
1167
|
.object({
|
|
1163
1168
|
/** Base64-encoded image data. */
|
|
@@ -1175,7 +1180,7 @@ const providerEntrySchema = z.lazy(() =>
|
|
|
1175
1180
|
})
|
|
1176
1181
|
.strict(),
|
|
1177
1182
|
);
|
|
1178
|
-
const providerEnvelopeSchema = z.lazy(() =>
|
|
1183
|
+
const providerEnvelopeSchema = /* @__PURE__ */ z.lazy(() =>
|
|
1179
1184
|
z.union([
|
|
1180
1185
|
z.object({
|
|
1181
1186
|
/** Encoded provider image. */
|
|
@@ -1193,7 +1198,7 @@ const providerEnvelopeSchema = z.lazy(() =>
|
|
|
1193
1198
|
);
|
|
1194
1199
|
|
|
1195
1200
|
/** Decode the Workers AI binding's raw output at the provider boundary. */
|
|
1196
|
-
export const mediaProviderWireSchema = z.lazy(() =>
|
|
1201
|
+
export const mediaProviderWireSchema = /* @__PURE__ */ z.lazy(() =>
|
|
1197
1202
|
z.union([
|
|
1198
1203
|
providerEnvelopeSchema,
|
|
1199
1204
|
z.instanceof(Uint8Array),
|
package/src/media-binding.ts
CHANGED
|
@@ -25,30 +25,30 @@ import {
|
|
|
25
25
|
} from "./app-media-contracts.js";
|
|
26
26
|
|
|
27
27
|
/** The App owns its folder; the host owns Computer identity and the output filename. */
|
|
28
|
-
const mediaBindingLibraryPathSchema = z
|
|
28
|
+
const mediaBindingLibraryPathSchema = /* @__PURE__ */ z
|
|
29
29
|
.string()
|
|
30
30
|
.refine(
|
|
31
|
-
Schema.is(mediaLibraryPathSchema),
|
|
31
|
+
/* @__PURE__ */ Schema.is(mediaLibraryPathSchema),
|
|
32
32
|
"Select an absolute library folder",
|
|
33
33
|
);
|
|
34
34
|
/** Image settings and path references crossing a scoped MEDIA binding. */
|
|
35
|
-
export const mediaImageBindingInputSchema = z.strictObject({
|
|
35
|
+
export const mediaImageBindingInputSchema = /* @__PURE__ */ z.strictObject({
|
|
36
36
|
/** Select image generation rather than video. */
|
|
37
|
-
kind: z.literal("image"),
|
|
37
|
+
kind: /* @__PURE__ */ z.literal("image"),
|
|
38
38
|
/** Attempt identity retained through polling and replay. */
|
|
39
39
|
requestId: mediaRequestIdSchema,
|
|
40
40
|
/** App-owned absolute folder; the host supplies Computer authority. */
|
|
41
41
|
libraryPath: mediaBindingLibraryPathSchema,
|
|
42
42
|
/** Image model selection, references and inference settings. */
|
|
43
|
-
settings: mediaGenerationSelectionSchema
|
|
43
|
+
settings: /* @__PURE__ */ mediaGenerationSelectionSchema
|
|
44
44
|
.omit({ durationSeconds: true, voiceId: true, audioReferences: true })
|
|
45
45
|
.extend({
|
|
46
46
|
/** Output width in pixels; an image always names its size. */
|
|
47
|
-
width: z.number().int().min(1).max(5_040),
|
|
47
|
+
width: /* @__PURE__ */ z.number().int().min(1).max(5_040),
|
|
48
48
|
/** Output height in pixels; an image always names its size. */
|
|
49
|
-
height: z.number().int().min(1).max(5_040),
|
|
49
|
+
height: /* @__PURE__ */ z.number().int().min(1).max(5_040),
|
|
50
50
|
/** Optional inference-step count for models that support it. */
|
|
51
|
-
steps: z
|
|
51
|
+
steps: /* @__PURE__ */ z
|
|
52
52
|
.number()
|
|
53
53
|
.int()
|
|
54
54
|
.nonnegative()
|
|
@@ -60,12 +60,12 @@ export const mediaImageBindingInputSchema = z.strictObject({
|
|
|
60
60
|
"Select an image model from listModels",
|
|
61
61
|
),
|
|
62
62
|
/** Requested image encoding, validated against the selected model. */
|
|
63
|
-
outputFormat: mediaRequestedImageFormatSchema.optional(),
|
|
63
|
+
outputFormat: /* @__PURE__ */ mediaRequestedImageFormatSchema.optional(),
|
|
64
64
|
});
|
|
65
65
|
/** Video settings and path references crossing the same scoped binding. */
|
|
66
|
-
export const mediaVideoBindingInputSchema = z.strictObject({
|
|
66
|
+
export const mediaVideoBindingInputSchema = /* @__PURE__ */ z.strictObject({
|
|
67
67
|
/** Select video generation rather than an image. */
|
|
68
|
-
kind: z.literal("video"),
|
|
68
|
+
kind: /* @__PURE__ */ z.literal("video"),
|
|
69
69
|
/** Attempt identity retained through polling and replay. */
|
|
70
70
|
requestId: mediaRequestIdSchema,
|
|
71
71
|
/** App-owned absolute folder; the host supplies Computer authority. */
|
|
@@ -74,9 +74,9 @@ export const mediaVideoBindingInputSchema = z.strictObject({
|
|
|
74
74
|
settings: mediaVideoSelectionSchema,
|
|
75
75
|
});
|
|
76
76
|
/** Speech or music settings crossing the same scoped binding; audio takes no references. */
|
|
77
|
-
export const mediaAudioBindingInputSchema = z.strictObject({
|
|
77
|
+
export const mediaAudioBindingInputSchema = /* @__PURE__ */ z.strictObject({
|
|
78
78
|
/** Select speech or music generation. */
|
|
79
|
-
kind: z.literal("audio"),
|
|
79
|
+
kind: /* @__PURE__ */ z.literal("audio"),
|
|
80
80
|
/** Attempt identity retained through polling and replay. */
|
|
81
81
|
requestId: mediaRequestIdSchema,
|
|
82
82
|
/** App-owned absolute folder; the host supplies Computer authority. */
|
|
@@ -85,34 +85,38 @@ export const mediaAudioBindingInputSchema = z.strictObject({
|
|
|
85
85
|
settings: mediaAudioSelectionSchema,
|
|
86
86
|
});
|
|
87
87
|
/** One generation identity, including the App-owned folder captured for replay. */
|
|
88
|
-
export const mediaBindingGenerationSchema =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
export const mediaBindingGenerationSchema =
|
|
89
|
+
/* @__PURE__ */ z.discriminatedUnion("kind", [
|
|
90
|
+
mediaImageBindingInputSchema,
|
|
91
|
+
mediaVideoBindingInputSchema,
|
|
92
|
+
mediaAudioBindingInputSchema,
|
|
93
|
+
]);
|
|
93
94
|
/** Parsed generation command consumed by either host. */
|
|
94
95
|
export type MediaBindingGeneration = z.output<
|
|
95
96
|
typeof mediaBindingGenerationSchema
|
|
96
97
|
>;
|
|
97
98
|
/** Maintained MEDIA grammar; reference selectors carry no Computer authority. */
|
|
98
|
-
export const mediaBindingCallSchema = z.discriminatedUnion(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
export const mediaBindingCallSchema = /* @__PURE__ */ z.discriminatedUnion(
|
|
100
|
+
"operation",
|
|
101
|
+
[
|
|
102
|
+
/* @__PURE__ */ z.strictObject({
|
|
103
|
+
/** Read the model catalog without dispatching generation. */
|
|
104
|
+
operation: /* @__PURE__ */ z.literal("models"),
|
|
105
|
+
/** Catalog reads carry no guest authority or generation settings. */
|
|
106
|
+
input: /* @__PURE__ */ z.strictObject({}),
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ z.strictObject({
|
|
109
|
+
/** Execute or poll one admitted generation identity. */
|
|
110
|
+
operation: /* @__PURE__ */ z.literal("generate"),
|
|
111
|
+
/** The App's captured generation selection and library folder. */
|
|
112
|
+
input: mediaBindingGenerationSchema,
|
|
113
|
+
}),
|
|
114
|
+
],
|
|
115
|
+
);
|
|
112
116
|
/** Parsed call consumed by host admission and transport. */
|
|
113
117
|
export type MediaBindingCall = z.output<typeof mediaBindingCallSchema>;
|
|
114
118
|
/** Background-generation reply emitted by the durable service. */
|
|
115
|
-
export const mediaPendingSchema = z.lazy(() =>
|
|
119
|
+
export const mediaPendingSchema = /* @__PURE__ */ z.lazy(() =>
|
|
116
120
|
z.strictObject({
|
|
117
121
|
/** Background work has been accepted but is not yet delivered. */
|
|
118
122
|
status: z.literal("pending"),
|