@civitai/app-sdk 0.1.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -1
- package/dist/blocks/defineBlock.d.ts +32 -0
- package/dist/blocks/defineBlock.d.ts.map +1 -0
- package/dist/blocks/defineBlock.js +270 -0
- package/dist/blocks/defineBlock.js.map +1 -0
- package/dist/blocks/index.d.ts +16 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +12 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/messages.d.ts +277 -0
- package/dist/blocks/messages.d.ts.map +1 -0
- package/dist/blocks/messages.js +31 -0
- package/dist/blocks/messages.js.map +1 -0
- package/dist/blocks/scopes.d.ts +35 -0
- package/dist/blocks/scopes.d.ts.map +1 -0
- package/dist/blocks/scopes.js +33 -0
- package/dist/blocks/scopes.js.map +1 -0
- package/dist/blocks/types.d.ts +371 -0
- package/dist/blocks/types.d.ts.map +1 -0
- package/dist/blocks/types.js +8 -0
- package/dist/blocks/types.js.map +1 -0
- package/dist/orchestrator/index.d.ts +224 -0
- package/dist/orchestrator/index.d.ts.map +1 -1
- package/dist/orchestrator/index.js +207 -0
- package/dist/orchestrator/index.js.map +1 -1
- package/package.json +10 -4
- package/schemas/app-block/v1.json +184 -0
- package/dist/client/index.d.ts +0 -23
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -19
- package/dist/client/index.js.map +0 -1
- package/dist/workflows/index.d.ts +0 -52
- package/dist/workflows/index.d.ts.map +0 -1
- package/dist/workflows/index.js +0 -77
- package/dist/workflows/index.js.map +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type surface for the `@civitai/app-sdk/blocks` subpath.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic. Hooks and transport classes that consume these types
|
|
5
|
+
* live in a separate package so this module stays usable from any runtime.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Per-instance context the host page passes to the block at mount time.
|
|
9
|
+
*
|
|
10
|
+
* `slotId` is the only field guaranteed to be present; every other field
|
|
11
|
+
* depends on which slot the block is rendered into. Authors who target a
|
|
12
|
+
* specific slot should narrow to a slot-specific context type
|
|
13
|
+
* (e.g. {@link ModelSlotContext}) rather than reaching into the index
|
|
14
|
+
* signature.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors `SlotContext` in civitai/civitai's `src/components/AppBlocks/types.ts`.
|
|
17
|
+
*/
|
|
18
|
+
export interface BlockContext {
|
|
19
|
+
slotId: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Snapshot of the effective Checkpoint the block will generate against —
|
|
24
|
+
* already merged from publisher default + viewer override on the host.
|
|
25
|
+
* For Checkpoint-bound installs this is the model itself; for LoRA installs
|
|
26
|
+
* it's whichever Checkpoint the resolver picked.
|
|
27
|
+
*
|
|
28
|
+
* `null` (via `ModelSlotContext.checkpoint`) means no checkpoint is
|
|
29
|
+
* configured; blocks should render a "missing checkpoint" CTA pointing the
|
|
30
|
+
* user at the model owner.
|
|
31
|
+
*
|
|
32
|
+
* Mirrors `BlockCheckpointInfo` in civitai/civitai's
|
|
33
|
+
* `src/components/AppBlocks/types.ts`.
|
|
34
|
+
*/
|
|
35
|
+
export interface BlockCheckpointInfo {
|
|
36
|
+
versionId: number;
|
|
37
|
+
modelId: number;
|
|
38
|
+
modelName: string;
|
|
39
|
+
versionName: string;
|
|
40
|
+
baseModel: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One of the model version's curated preview images, with the standard
|
|
44
|
+
* gen params extracted from its source meta. Block UIs use these to let
|
|
45
|
+
* the user "remix" a known-good prompt without typing it.
|
|
46
|
+
*
|
|
47
|
+
* `null` on a gen-param field means the source image's meta didn't have
|
|
48
|
+
* that value (or it was malformed). The block should treat null as "keep
|
|
49
|
+
* the current value" rather than clearing the field — that way a partial
|
|
50
|
+
* meta doesn't trash a prompt the user already typed.
|
|
51
|
+
*
|
|
52
|
+
* Mirrors `ShowcaseImage` in civitai/civitai's
|
|
53
|
+
* `src/components/AppBlocks/types.ts`. Keep in lockstep.
|
|
54
|
+
*/
|
|
55
|
+
export interface ShowcaseImage {
|
|
56
|
+
id: number;
|
|
57
|
+
url: string;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
prompt: string | null;
|
|
61
|
+
negativePrompt: string | null;
|
|
62
|
+
cfgScale: number | null;
|
|
63
|
+
steps: number | null;
|
|
64
|
+
seed: number | null;
|
|
65
|
+
sampler: string | null;
|
|
66
|
+
/** Per-resource CLIP layer skip count (SD1/SDXL). Flux ignores it. */
|
|
67
|
+
clipSkip: number | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The shape the host delivers for the three model-page slots
|
|
71
|
+
* (`model.sidebar_top`, `model.below_images`, `model.actions_extra`).
|
|
72
|
+
*
|
|
73
|
+
* Optional fields are present when the host has them: `viewerUserId` is
|
|
74
|
+
* `null` for anonymous viewers, and `viewerUsername`/`viewerStatus`/`theme`
|
|
75
|
+
* are only filled when a viewer is signed in or the host's theme is
|
|
76
|
+
* resolved.
|
|
77
|
+
*
|
|
78
|
+
* Block authors using these slots should narrow:
|
|
79
|
+
*
|
|
80
|
+
* const ctx = useBlockContext().context as ModelSlotContext;
|
|
81
|
+
*
|
|
82
|
+
* Mirrors `ModelSlotContext` in civitai/civitai. Keep in lockstep — adding
|
|
83
|
+
* a field on either side without the other will silently degrade.
|
|
84
|
+
*/
|
|
85
|
+
export interface ModelSlotContext extends BlockContext {
|
|
86
|
+
slotId: 'model.sidebar_top' | 'model.below_images' | 'model.actions_extra';
|
|
87
|
+
modelId: number;
|
|
88
|
+
modelVersionId: number;
|
|
89
|
+
modelName: string;
|
|
90
|
+
modelType: string;
|
|
91
|
+
modelNsfwLevel: number;
|
|
92
|
+
creatorUserId: number;
|
|
93
|
+
viewerUserId: number | null;
|
|
94
|
+
viewerNsfwEnabled: boolean;
|
|
95
|
+
viewerUsername?: string | null;
|
|
96
|
+
/** Coarse status surface; authoritative re-check is `/api/v1/blocks/me`. */
|
|
97
|
+
viewerStatus?: 'active' | 'banned' | 'muted';
|
|
98
|
+
/** Host-page color scheme; lets the iframe match without a flicker. */
|
|
99
|
+
theme?: 'light' | 'dark';
|
|
100
|
+
/**
|
|
101
|
+
* Effective Checkpoint after publisher-default ∪ viewer-override merge.
|
|
102
|
+
* `null` when no checkpoint is configured (publisher hasn't set one AND
|
|
103
|
+
* the bound model isn't a Checkpoint itself) — block should render a
|
|
104
|
+
* "missing checkpoint" state and prompt the user to ask the model owner.
|
|
105
|
+
*/
|
|
106
|
+
checkpoint?: BlockCheckpointInfo | null;
|
|
107
|
+
/**
|
|
108
|
+
* Top showcase images for the bound model version, ordered by all-time
|
|
109
|
+
* reactions. Capped at 6 by the host. Empty array means the version
|
|
110
|
+
* has no preview images yet. The block uses these to render a "click
|
|
111
|
+
* to remix" carousel that populates the form from the selected image's
|
|
112
|
+
* gen meta.
|
|
113
|
+
*/
|
|
114
|
+
showcaseImages?: ShowcaseImage[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Short-lived, block-scoped JWT minted by civitai.com for a single block
|
|
118
|
+
* instance. Carries the scopes the user consented to plus an optional
|
|
119
|
+
* Buzz spend budget the parent enforces on orchestrator calls.
|
|
120
|
+
*/
|
|
121
|
+
export interface BlockToken {
|
|
122
|
+
raw: string;
|
|
123
|
+
scopes: string[];
|
|
124
|
+
expiresAt: Date;
|
|
125
|
+
buzzBudget?: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Settings the block sees: publisher-controlled (from manifest defaults +
|
|
129
|
+
* any per-deployment overrides) and user-controlled (per-instance prefs).
|
|
130
|
+
*/
|
|
131
|
+
export interface BlockSettings {
|
|
132
|
+
publisherSettings: Record<string, unknown>;
|
|
133
|
+
userSettings: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The signed-in viewer. `null` in `BlockInitPayload.viewer` means anonymous.
|
|
137
|
+
*
|
|
138
|
+
* `status` is a coarse surface for the iframe — `/api/v1/blocks/me` is the
|
|
139
|
+
* authoritative re-check if the block needs to gate on it.
|
|
140
|
+
*
|
|
141
|
+
* Mirrors the inline viewer shape in `BlockInitPayload` on the platform
|
|
142
|
+
* side (civitai/civitai `src/components/AppBlocks/types.ts`).
|
|
143
|
+
*/
|
|
144
|
+
export interface ViewerInfo {
|
|
145
|
+
id: number;
|
|
146
|
+
username: string | null;
|
|
147
|
+
status: 'active' | 'banned' | 'muted';
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Host-page color scheme. v2 will add a sibling `themeCssVars` field on
|
|
151
|
+
* `BlockInitPayload` for design-token sharing; v1 ships the string only.
|
|
152
|
+
*/
|
|
153
|
+
export type Theme = 'light' | 'dark';
|
|
154
|
+
export type WorkflowStatus = 'idle' | 'estimating' | 'confirming' | 'submitting' | 'polling' | 'done' | 'error';
|
|
155
|
+
/**
|
|
156
|
+
* Generation parameters a block can override. All optional — the host fills
|
|
157
|
+
* sensible defaults (sampler='Euler', steps=25, dimensions from the
|
|
158
|
+
* base-model family) when omitted, so the simplest block can submit
|
|
159
|
+
* `{ kind: 'textToImage', modelId, modelVersionId, params: { prompt } }`.
|
|
160
|
+
*
|
|
161
|
+
* Bounds mirror civitai/civitai's `blockWorkflowBodySchema` zod gate; over-
|
|
162
|
+
* limit values are rejected server-side before reaching the orchestrator.
|
|
163
|
+
*/
|
|
164
|
+
export interface BlockTextToImageParams {
|
|
165
|
+
prompt: string;
|
|
166
|
+
negativePrompt?: string;
|
|
167
|
+
/** Range 1–30. */
|
|
168
|
+
cfgScale?: number;
|
|
169
|
+
/** Sampler name (e.g. 'Euler', 'DPM++ 2M Karras'). Defaults to 'Euler'. */
|
|
170
|
+
sampler?: string;
|
|
171
|
+
/** Range 1–50. */
|
|
172
|
+
steps?: number;
|
|
173
|
+
/** `null` lets the orchestrator pick. */
|
|
174
|
+
seed?: number | null;
|
|
175
|
+
/** Range 64–2048. Defaults to 1024 for SDXL/Flux, 512 for SD1/SD2. */
|
|
176
|
+
width?: number;
|
|
177
|
+
/** Range 64–2048. Same defaults as width. */
|
|
178
|
+
height?: number;
|
|
179
|
+
/** Per-resource CLIP layer skip count (SD1/SDXL). Range 0–12. Flux ignores it. */
|
|
180
|
+
clipSkip?: number;
|
|
181
|
+
/** Range 1–4. Defaults to 1. */
|
|
182
|
+
quantity?: number;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Body the block sends to `useBuzzWorkflow().{submit,estimate}`. A
|
|
186
|
+
* discriminated union keyed by `kind` — v1 ships text-to-image only;
|
|
187
|
+
* new kinds (e.g. img2img, video) extend this union as the host gains
|
|
188
|
+
* support for them.
|
|
189
|
+
*
|
|
190
|
+
* Both `modelId` and `modelVersionId` are required even though they're
|
|
191
|
+
* conceptually redundant — the host validates that `modelId` matches the
|
|
192
|
+
* JWT's `ctx.modelId` (context binding) AND that the version belongs to
|
|
193
|
+
* that model (DB lookup). The block always has both values from
|
|
194
|
+
* `useBlockContext().context as ModelSlotContext`.
|
|
195
|
+
*/
|
|
196
|
+
export type WorkflowBody = {
|
|
197
|
+
kind: 'textToImage';
|
|
198
|
+
modelId: number;
|
|
199
|
+
modelVersionId: number;
|
|
200
|
+
params: BlockTextToImageParams;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The host-mediated view of an orchestrator workflow that an iframe block
|
|
204
|
+
* receives over `postMessage`.
|
|
205
|
+
*
|
|
206
|
+
* This is intentionally a flattened **subset** of `WorkflowSnapshot` from
|
|
207
|
+
* `../orchestrator/` — the host (civitai.com) maps the full orchestrator
|
|
208
|
+
* payload down to this shape before forwarding. Notable differences:
|
|
209
|
+
* - `workflowId` here = orchestrator's `id`
|
|
210
|
+
* - `imageUrls` here = flattened from `steps[].output.images[].url`
|
|
211
|
+
* - `cost.total` is the host-attested total (not the raw orchestrator field)
|
|
212
|
+
* - the status union omits orchestrator-internal states like `unassigned`
|
|
213
|
+
*
|
|
214
|
+
* If the orchestrator gains a status the host doesn't recognize, the host
|
|
215
|
+
* is responsible for mapping it to one of the values here (typically
|
|
216
|
+
* `processing` or `failed`).
|
|
217
|
+
*/
|
|
218
|
+
export interface BlockWorkflowSnapshot {
|
|
219
|
+
workflowId: string;
|
|
220
|
+
status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'expired' | 'canceled';
|
|
221
|
+
cost?: {
|
|
222
|
+
total: number;
|
|
223
|
+
};
|
|
224
|
+
imageUrls?: string[];
|
|
225
|
+
error?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Set when the host opportunistically claimed a Buzz reward on the user's
|
|
228
|
+
* behalf during submit. Currently the host only fires this for the daily
|
|
229
|
+
* boost (25 blue Buzz, one per UTC day) when the user's balance would
|
|
230
|
+
* otherwise have been short by less than the boost amount.
|
|
231
|
+
*
|
|
232
|
+
* Informational only — the block has no obligation to reconcile state
|
|
233
|
+
* (the claim already settled in the orchestrator). A typical block UX
|
|
234
|
+
* surfaces a small "+25 daily boost claimed" notice next to the
|
|
235
|
+
* succeeded result.
|
|
236
|
+
*/
|
|
237
|
+
autoClaim?: {
|
|
238
|
+
type: 'dailyBoost';
|
|
239
|
+
amount: number;
|
|
240
|
+
accountType: 'yellow' | 'blue' | 'red' | 'green';
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Which side of the settings split a field lives on.
|
|
245
|
+
* - `publisher`: stored on `model_block_installs.settings` (or a publisher
|
|
246
|
+
* subscription row). The model owner / app installer controls it.
|
|
247
|
+
* - `viewer`: stored on `block_user_settings.settings` (or a viewer
|
|
248
|
+
* subscription row). Each signed-in user controls their own value.
|
|
249
|
+
*/
|
|
250
|
+
export type SettingScope = 'publisher' | 'viewer';
|
|
251
|
+
/**
|
|
252
|
+
* Widget hints the platform's generic SettingsForm renderer consumes.
|
|
253
|
+
* `resource_picker` is the v0 escape hatch for the checkpoint case —
|
|
254
|
+
* delegates to `useCheckpointPicker` (or a future generic picker hook)
|
|
255
|
+
* via the host bridge.
|
|
256
|
+
*/
|
|
257
|
+
export type SettingWidget = 'number' | 'slider' | 'resource_picker' | 'text' | 'textarea' | 'select' | 'toggle';
|
|
258
|
+
interface ManifestSettingFieldBase {
|
|
259
|
+
scope: SettingScope;
|
|
260
|
+
label: string;
|
|
261
|
+
description: string;
|
|
262
|
+
/**
|
|
263
|
+
* Hide the field when this scope isn't in the app's declared scopes.
|
|
264
|
+
* Lets a manifest carry a "Max Buzz per generation" field that only
|
|
265
|
+
* renders for apps that requested `ai:write:budgeted`.
|
|
266
|
+
*/
|
|
267
|
+
requires_scope?: string;
|
|
268
|
+
}
|
|
269
|
+
export interface ManifestNumberField extends ManifestSettingFieldBase {
|
|
270
|
+
type: 'number';
|
|
271
|
+
widget?: 'number' | 'slider' | 'resource_picker';
|
|
272
|
+
default?: number | null;
|
|
273
|
+
min?: number;
|
|
274
|
+
max?: number;
|
|
275
|
+
step?: number;
|
|
276
|
+
/**
|
|
277
|
+
* Widget-specific config. For `resource_picker`:
|
|
278
|
+
* `{ resource_type: 'Checkpoint' | 'LORA' | ..., filter_by_ecosystem?: boolean }`.
|
|
279
|
+
*/
|
|
280
|
+
widget_options?: Record<string, unknown>;
|
|
281
|
+
}
|
|
282
|
+
export interface ManifestStringField extends ManifestSettingFieldBase {
|
|
283
|
+
type: 'string';
|
|
284
|
+
widget?: 'text' | 'textarea' | 'select';
|
|
285
|
+
default?: string | null;
|
|
286
|
+
max_length?: number;
|
|
287
|
+
/** RegExp source. Compiled at validate-time. */
|
|
288
|
+
pattern?: string;
|
|
289
|
+
/** Required when `widget === 'select'`. */
|
|
290
|
+
enum?: string[];
|
|
291
|
+
}
|
|
292
|
+
export interface ManifestBooleanField extends ManifestSettingFieldBase {
|
|
293
|
+
type: 'boolean';
|
|
294
|
+
widget?: 'toggle';
|
|
295
|
+
default?: boolean;
|
|
296
|
+
}
|
|
297
|
+
export type ManifestSettingField = ManifestNumberField | ManifestStringField | ManifestBooleanField;
|
|
298
|
+
/**
|
|
299
|
+
* W3 v0 manifest settings declaration. Keyed by snake_case field name.
|
|
300
|
+
* Mirrors `manifestSettingsSchema` in civitai/civitai's
|
|
301
|
+
* `src/server/schema/blocks/manifest-settings.meta.schema.ts`. Keep in
|
|
302
|
+
* lockstep — adding a field type or widget on one side without the other
|
|
303
|
+
* will silently degrade the form renderer or the platform validator.
|
|
304
|
+
*/
|
|
305
|
+
export type ManifestSettings = Record<string, ManifestSettingField>;
|
|
306
|
+
export type ContentRating = 'g' | 'pg' | 'pg13' | 'r' | 'x';
|
|
307
|
+
export interface ManifestTarget {
|
|
308
|
+
slotId: string;
|
|
309
|
+
priority: number;
|
|
310
|
+
requiredContext?: string[];
|
|
311
|
+
}
|
|
312
|
+
export interface ManifestIframe {
|
|
313
|
+
src: string;
|
|
314
|
+
minHeight: number;
|
|
315
|
+
/** Optional. Omit or set to `null` for no cap. */
|
|
316
|
+
maxHeight?: number | null;
|
|
317
|
+
resizable: boolean;
|
|
318
|
+
sandbox: string;
|
|
319
|
+
}
|
|
320
|
+
export interface ManifestAsset {
|
|
321
|
+
url: string;
|
|
322
|
+
integrity: string;
|
|
323
|
+
}
|
|
324
|
+
export interface ManifestPreview {
|
|
325
|
+
thumbnail: string;
|
|
326
|
+
description: string;
|
|
327
|
+
screenshots?: string[];
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* v1 manifest shape. Mirrors `schemas/app-block/v1.json` — keep them in sync.
|
|
331
|
+
*
|
|
332
|
+
* The trailing `renderMode` / `assetBundle` / `trustTier` fields are
|
|
333
|
+
* forward-compat hooks for v2 inline mode; they are accepted but unused
|
|
334
|
+
* by the v1 iframe runtime.
|
|
335
|
+
*/
|
|
336
|
+
export interface BlockManifestV1 {
|
|
337
|
+
$schema: 'https://civitai.com/schemas/app-block/v1.json';
|
|
338
|
+
appId: string;
|
|
339
|
+
blockId: string;
|
|
340
|
+
version: string;
|
|
341
|
+
name: string;
|
|
342
|
+
type: 'block' | 'embed';
|
|
343
|
+
targets: ManifestTarget[];
|
|
344
|
+
scopes: string[];
|
|
345
|
+
iframe: ManifestIframe;
|
|
346
|
+
assets?: ManifestAsset[];
|
|
347
|
+
/**
|
|
348
|
+
* Per-field settings declaration the platform validates user input
|
|
349
|
+
* against AND renders the publisher/viewer settings UI from. v0 shape;
|
|
350
|
+
* see {@link ManifestSettings}.
|
|
351
|
+
*/
|
|
352
|
+
settings?: ManifestSettings;
|
|
353
|
+
contentRating: ContentRating;
|
|
354
|
+
preview?: ManifestPreview;
|
|
355
|
+
promotionEligible?: boolean;
|
|
356
|
+
minApiVersion: string;
|
|
357
|
+
/**
|
|
358
|
+
* Author-declared mode preference. `hybrid` is a manifest-only hint that
|
|
359
|
+
* the host resolves to a concrete `iframe` | `inline` value before sending
|
|
360
|
+
* `BLOCK_INIT` — that's why `BlockInitPayload.renderMode` is narrower.
|
|
361
|
+
*/
|
|
362
|
+
renderMode?: 'iframe' | 'inline' | 'hybrid';
|
|
363
|
+
assetBundle?: {
|
|
364
|
+
url: string | null;
|
|
365
|
+
sha256: string | null;
|
|
366
|
+
};
|
|
367
|
+
trustTier?: 'unverified' | 'verified' | 'internal';
|
|
368
|
+
}
|
|
369
|
+
export type BlockManifest = BlockManifestV1;
|
|
370
|
+
export {};
|
|
371
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/blocks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE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;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type surface for the `@civitai/app-sdk/blocks` subpath.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic. Hooks and transport classes that consume these types
|
|
5
|
+
* live in a separate package so this module stays usable from any runtime.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/blocks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
* starter's BFF. Client + server safe: no Node-only imports, no `process.env`
|
|
4
4
|
* access. All configuration flows through the `OrchestratorClient` value that
|
|
5
5
|
* the caller builds.
|
|
6
|
+
*
|
|
7
|
+
* The orchestrator is a workflow API: you POST a `{ steps: [...] }` body with
|
|
8
|
+
* one or more typed steps (`textToImage`, `imageGen`, `videoGen`, `comfy`, ...)
|
|
9
|
+
* and get back a workflow snapshot. {@link WORKFLOW_STEP_TYPES} is the catalog
|
|
10
|
+
* of available step types — start there to find the one you need, then either
|
|
11
|
+
* use the matching `build*Body` helper or hand-craft a body and pass it to
|
|
12
|
+
* {@link submitWorkflow} / {@link callOrchestrator}.
|
|
13
|
+
*
|
|
14
|
+
* Full OpenAPI spec: https://orchestration.civitai.com/openapi/v2-consumers.json
|
|
6
15
|
*/
|
|
7
16
|
export declare const DEFAULT_ORCHESTRATOR_BASE_URL = "https://orchestration.civitai.com";
|
|
8
17
|
/** Default SDXL base model. Replace per starter / per call as needed. */
|
|
@@ -12,6 +21,121 @@ export declare const DEFAULT_MODEL_AIR = "urn:air:sdxl:checkpoint:civitai:101055
|
|
|
12
21
|
*/
|
|
13
22
|
export declare const TERMINAL_STATUSES: readonly ["succeeded", "failed", "expired", "canceled"];
|
|
14
23
|
export type TerminalStatus = (typeof TERMINAL_STATUSES)[number];
|
|
24
|
+
/**
|
|
25
|
+
* Every workflow step type the orchestrator accepts, with a one-line
|
|
26
|
+
* description. Use this as a map: find the step `$type` you want, then look
|
|
27
|
+
* at the matching `build*Body` helper (if one exists) or fall back to
|
|
28
|
+
* {@link callOrchestrator} with a hand-crafted body.
|
|
29
|
+
*
|
|
30
|
+
* Source of truth is `https://orchestration.civitai.com/openapi/v2-consumers.json`.
|
|
31
|
+
* If a step type is missing here, the catalog is stale — open a PR.
|
|
32
|
+
*/
|
|
33
|
+
export declare const WORKFLOW_STEP_TYPES: {
|
|
34
|
+
/** Diffusion image gen (SDXL / Flux.1 / Pony / Illustrious / SD1.5 / etc.). Use {@link buildTextToImageBody}. */
|
|
35
|
+
readonly textToImage: "Text-to-image via diffusion checkpoints (AIR URN models)";
|
|
36
|
+
/**
|
|
37
|
+
* Closed-source image-gen APIs (Nano Banana, Gemini, Flux.1 Kontext, Flux.2,
|
|
38
|
+
* GPT-Image, Seedream, Grok, fal, …). Each engine has its own input shape;
|
|
39
|
+
* see {@link IMAGE_GEN_ENGINES}. Use {@link buildImageGenBody}.
|
|
40
|
+
*/
|
|
41
|
+
readonly imageGen: "Closed-source image gen (Nano Banana, Gemini, GPT-Image, Flux Kontext, Seedream, Grok, fal, …)";
|
|
42
|
+
/** Arbitrary ComfyUI workflow graphs. Pass a `prompt` object (node graph). */
|
|
43
|
+
readonly comfy: "Custom ComfyUI node-graph workflows";
|
|
44
|
+
/** Upscale an existing image. Input is a source image URL + scale factor. */
|
|
45
|
+
readonly imageUpscaler: "Image upscaling";
|
|
46
|
+
/** LoRA / DoRA / embedding training. Long-running. */
|
|
47
|
+
readonly imageResourceTraining: "Train a LoRA / DoRA / embedding from a dataset";
|
|
48
|
+
/** Pre-process an image (resize, ControlNet preprocessor, etc.). */
|
|
49
|
+
readonly preprocessImage: "Image preprocessing (resize, ControlNet preprocessors, …)";
|
|
50
|
+
/** Format conversion between png/jpeg/webp/avif. */
|
|
51
|
+
readonly convertImage: "Image format conversion";
|
|
52
|
+
/** Upload arbitrary blob bytes for use as a reference in a later step. */
|
|
53
|
+
readonly imageUpload: "Upload an image blob to use as input in a later step";
|
|
54
|
+
/** Video gen across all engines (VEO 3, Kling, Wan, Vidu, Sora, LTX, …). */
|
|
55
|
+
readonly videoGen: "Video generation across all engines (VEO 3, Kling, Wan, Vidu, Sora, LTX, …)";
|
|
56
|
+
/** Upscale an existing video. */
|
|
57
|
+
readonly videoUpscaler: "Video upscaling";
|
|
58
|
+
/** Frame interpolation / smoothing. */
|
|
59
|
+
readonly videoInterpolation: "Video frame interpolation";
|
|
60
|
+
/** Per-frame transformations (denoise, color correct, etc.). */
|
|
61
|
+
readonly videoEnhancement: "Per-frame video enhancement";
|
|
62
|
+
/** Extract individual frames from a video. */
|
|
63
|
+
readonly videoFrameExtraction: "Extract frames from a video";
|
|
64
|
+
/** Read video metadata (duration, codec, dimensions). */
|
|
65
|
+
readonly videoMetadata: "Read video file metadata";
|
|
66
|
+
/** Transcode video format / codec. */
|
|
67
|
+
readonly transcode: "Audio/video transcoding";
|
|
68
|
+
/** Text-to-speech (multi-voice, multi-language). */
|
|
69
|
+
readonly textToSpeech: "Text-to-speech synthesis";
|
|
70
|
+
/** Music generation via ACE Step 1.5 (lyrics + style → song). */
|
|
71
|
+
readonly aceStepAudio: "Music generation (ACE Step 1.5)";
|
|
72
|
+
/** Speech-to-text transcription. */
|
|
73
|
+
readonly transcription: "Speech-to-text transcription";
|
|
74
|
+
/** Mix multiple audio tracks. */
|
|
75
|
+
readonly audioMix: "Audio track mixing";
|
|
76
|
+
/** Generate captions from audio. */
|
|
77
|
+
readonly audioCaptioning: "Caption generation from audio";
|
|
78
|
+
/** Hash an image / video / model for dedup or lookup. */
|
|
79
|
+
readonly mediaHash: "Media content hashing";
|
|
80
|
+
/** Hash a model file. */
|
|
81
|
+
readonly modelHash: "Model file hashing";
|
|
82
|
+
/** Rate media on aesthetic / quality axes. */
|
|
83
|
+
readonly mediaRating: "Media aesthetic / quality rating";
|
|
84
|
+
/** Caption an image with a vision model. */
|
|
85
|
+
readonly mediaCaptioning: "Image captioning via vision models";
|
|
86
|
+
/** WD-14 tagger (anime / booru tags). */
|
|
87
|
+
readonly wdTagging: "WD-14 anime tagging";
|
|
88
|
+
/** Estimate an age range for faces in an image. */
|
|
89
|
+
readonly ageClassification: "Age range classification";
|
|
90
|
+
/** xGuard NSFW / safety moderation. */
|
|
91
|
+
readonly xGuardModeration: "NSFW / safety moderation";
|
|
92
|
+
/** ClamAV scan a model file for malware. */
|
|
93
|
+
readonly modelClamScan: "Antivirus scan a model file";
|
|
94
|
+
/** Pickle-scan a model file for unsafe pickles. */
|
|
95
|
+
readonly modelPickleScan: "Pickle-safety scan for model files";
|
|
96
|
+
/** Parse model file metadata (SafeTensors / GGUF headers). */
|
|
97
|
+
readonly modelParseMetadata: "Parse model file metadata";
|
|
98
|
+
/** Chat completion (OpenAI / Anthropic / Gemini / local OSS). */
|
|
99
|
+
readonly chatCompletion: "LLM chat completion";
|
|
100
|
+
/** Generate a richer prompt from a short seed prompt. */
|
|
101
|
+
readonly promptEnhancement: "Prompt expansion via LLM";
|
|
102
|
+
/** Echo the input back. Useful for testing the round-trip. */
|
|
103
|
+
readonly echo: "Echo step — round-trip the input for testing";
|
|
104
|
+
/** Package multiple blobs into a zip archive. */
|
|
105
|
+
readonly blobArchive: "Zip multiple blobs into an archive";
|
|
106
|
+
};
|
|
107
|
+
export type WorkflowStepType = keyof typeof WORKFLOW_STEP_TYPES;
|
|
108
|
+
/**
|
|
109
|
+
* Engines that the `imageGen` step accepts. Each one has its own input shape;
|
|
110
|
+
* the body's `engine` field selects which shape applies.
|
|
111
|
+
*
|
|
112
|
+
* Pair with {@link buildImageGenBody} or hand-craft via {@link callOrchestrator}.
|
|
113
|
+
*/
|
|
114
|
+
export declare const IMAGE_GEN_ENGINES: {
|
|
115
|
+
/** Nano Banana 2 / Nano Banana Pro / Imagen 4. */
|
|
116
|
+
readonly google: "Google (Nano Banana, Imagen)";
|
|
117
|
+
/** Gemini 2.5 Flash image gen + editing. */
|
|
118
|
+
readonly gemini: "Gemini";
|
|
119
|
+
/** GPT-Image-1 / GPT-Image-1.5 / DALL-E-3. */
|
|
120
|
+
readonly openai: "OpenAI (GPT-Image, DALL-E)";
|
|
121
|
+
/** Flux.1 Kontext (pro/max/dev) — image editing with ref images. */
|
|
122
|
+
readonly 'flux1-kontext': "Flux.1 Kontext (image editing)";
|
|
123
|
+
/** Flux.2 family (pro/max/dev/flex/klein). */
|
|
124
|
+
readonly flux2: "Flux.2";
|
|
125
|
+
/** Seedream (ByteDance) — 2K/4K image gen. */
|
|
126
|
+
readonly seedream: "Seedream";
|
|
127
|
+
/** Grok image generation. */
|
|
128
|
+
readonly grok: "Grok";
|
|
129
|
+
/** Wan image generation. */
|
|
130
|
+
readonly wan: "Wan";
|
|
131
|
+
/** Self-hosted SDCpp (stable-diffusion.cpp) gen. */
|
|
132
|
+
readonly sdcpp: "SDCpp (self-hosted diffusion)";
|
|
133
|
+
/** fal.ai routed gen. */
|
|
134
|
+
readonly fal: "fal.ai";
|
|
135
|
+
/** Comfy graph as an imageGen step (vs. the top-level `comfy` step). */
|
|
136
|
+
readonly comfy: "Comfy (engine-style)";
|
|
137
|
+
};
|
|
138
|
+
export type ImageGenEngine = keyof typeof IMAGE_GEN_ENGINES;
|
|
15
139
|
/**
|
|
16
140
|
* Orchestrator workflow status. Lowercase — matches what the orchestrator
|
|
17
141
|
* actually returns. Forward-compat: open-ended string union so unknown
|
|
@@ -90,6 +214,106 @@ export interface BuildTextToImageBodyOptions {
|
|
|
90
214
|
* the shape every starter's existing `buildWorkflowBody` produced.
|
|
91
215
|
*/
|
|
92
216
|
export declare function buildTextToImageBody(input: GenerateInput, opts?: BuildTextToImageBodyOptions): unknown;
|
|
217
|
+
/**
|
|
218
|
+
* Input for an `imageGen` step. The engine + model pair picks which
|
|
219
|
+
* sub-schema applies. Every closed-source image-gen API plugs in here:
|
|
220
|
+
*
|
|
221
|
+
* - `{ engine: 'google', model: 'nano-banana-2' | 'nano-banana-pro' | 'imagen4', images?: string[] }`
|
|
222
|
+
* - `{ engine: 'gemini', model: '2.5-flash', operation: 'createImage' | 'editImage', images?: string[] }`
|
|
223
|
+
* - `{ engine: 'flux1-kontext', model: 'pro' | 'max' | 'dev', images?: string[] }`
|
|
224
|
+
* - `{ engine: 'flux2', model: 'pro' | 'max' | 'dev' | 'flex' | 'klein' }`
|
|
225
|
+
* - `{ engine: 'openai', model: 'gpt-image-1' | 'gpt-image-1.5' | 'dall-e-3' | 'dall-e-2' }`
|
|
226
|
+
* - `{ engine: 'seedream', model: '4b' | '20b' | 'v1.0' }`
|
|
227
|
+
* - `{ engine: 'grok', model: 'createImage' | 'editImage' }`
|
|
228
|
+
* - `{ engine: 'fal' | 'wan' | 'sdcpp' | 'comfy', model: ..., ... }`
|
|
229
|
+
*
|
|
230
|
+
* Reference images go in `images: [...]` (URL, data URL, or base64 string).
|
|
231
|
+
* For aspect ratio / dimensions / seed / etc., pass the engine-specific
|
|
232
|
+
* input fields directly — this builder is intentionally pass-through.
|
|
233
|
+
*
|
|
234
|
+
* See `https://orchestration.civitai.com/openapi/v2-consumers.json` for the
|
|
235
|
+
* complete per-engine schema. The shape is forward-compat: any field the
|
|
236
|
+
* engine accepts can be added to `input` without changing this SDK.
|
|
237
|
+
*/
|
|
238
|
+
export interface ImageGenInput {
|
|
239
|
+
engine: ImageGenEngine | (string & {});
|
|
240
|
+
model: string;
|
|
241
|
+
prompt?: string;
|
|
242
|
+
/** Reference images. Each item is a URL, data URL, or raw base64 string. */
|
|
243
|
+
images?: string[];
|
|
244
|
+
/** Catch-all for engine-specific fields. */
|
|
245
|
+
[field: string]: unknown;
|
|
246
|
+
}
|
|
247
|
+
export interface BuildImageGenBodyOptions {
|
|
248
|
+
tags?: string[];
|
|
249
|
+
/** Step name. Defaults to `step_0`. */
|
|
250
|
+
name?: string;
|
|
251
|
+
/** Step timeout. Defaults to `'00:10:00'`. */
|
|
252
|
+
timeout?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Build an `imageGen` workflow body. Pass-through for engine-specific input
|
|
256
|
+
* fields — see {@link ImageGenInput} for examples per engine.
|
|
257
|
+
*
|
|
258
|
+
* @example Nano Banana 2 with a reference image
|
|
259
|
+
* ```ts
|
|
260
|
+
* const body = buildImageGenBody({
|
|
261
|
+
* engine: 'google',
|
|
262
|
+
* model: 'nano-banana-2',
|
|
263
|
+
* prompt: 'turn this into a cartoon sticker',
|
|
264
|
+
* images: ['data:image/png;base64,...'],
|
|
265
|
+
* aspectRatio: '1:1',
|
|
266
|
+
* numImages: 1,
|
|
267
|
+
* resolution: '1K',
|
|
268
|
+
* }, { tags: ['my-app'] });
|
|
269
|
+
*
|
|
270
|
+
* const estimate = await estimateWorkflow(client, body);
|
|
271
|
+
* const submitted = await submitWorkflow(client, body);
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @example Flux.1 Kontext for image editing
|
|
275
|
+
* ```ts
|
|
276
|
+
* const body = buildImageGenBody({
|
|
277
|
+
* engine: 'flux1-kontext',
|
|
278
|
+
* model: 'pro',
|
|
279
|
+
* prompt: 'add sunglasses',
|
|
280
|
+
* images: ['https://example.com/portrait.jpg'],
|
|
281
|
+
* aspectRatio: '1:1',
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
export declare function buildImageGenBody(input: ImageGenInput, opts?: BuildImageGenBodyOptions): unknown;
|
|
286
|
+
export interface BuildWorkflowBodyStep {
|
|
287
|
+
$type: WorkflowStepType | (string & {});
|
|
288
|
+
/** Step name. Defaults to `step_0`. */
|
|
289
|
+
name?: string;
|
|
290
|
+
/** Step timeout. Defaults to `'00:10:00'`. */
|
|
291
|
+
timeout?: string;
|
|
292
|
+
/** The step's input — shape is per-step-type. See {@link WORKFLOW_STEP_TYPES}. */
|
|
293
|
+
input: unknown;
|
|
294
|
+
/** Optional metadata attached to the step. */
|
|
295
|
+
metadata?: Record<string, unknown>;
|
|
296
|
+
}
|
|
297
|
+
export interface BuildWorkflowBodyOptions {
|
|
298
|
+
tags?: string[];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Lowest-level body builder — drops a single step into the `{ steps: [...] }`
|
|
302
|
+
* envelope and fills in `name` / `timeout` defaults. Use this when no dedicated
|
|
303
|
+
* `build*Body` exists for your step type.
|
|
304
|
+
*
|
|
305
|
+
* For multi-step workflows, hand-build `{ tags?, steps: [step1, step2, ...] }`
|
|
306
|
+
* yourself — there's no special envelope work beyond a JSON array.
|
|
307
|
+
*
|
|
308
|
+
* @example videoGen via VEO 3
|
|
309
|
+
* ```ts
|
|
310
|
+
* const body = buildWorkflowBody({
|
|
311
|
+
* $type: 'videoGen',
|
|
312
|
+
* input: { engine: 'veo3', prompt: 'a fox jumping', duration: 8 },
|
|
313
|
+
* }, { tags: ['my-app'] });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export declare function buildWorkflowBody(step: BuildWorkflowBodyStep, opts?: BuildWorkflowBodyOptions): unknown;
|
|
93
317
|
/**
|
|
94
318
|
* Cost preview ("what if") — runs the workflow validation/pricing pipeline
|
|
95
319
|
* without committing any Buzz.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestrator/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestrator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,6BAA6B,sCAAsC,CAAC;AAEjF,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,iBAAiB,yDAA0D,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIhE;;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