@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.
@@ -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
  // ---------- Constants -------------------------------------------------------
8
17
  export const DEFAULT_ORCHESTRATOR_BASE_URL = 'https://orchestration.civitai.com';
@@ -12,6 +21,126 @@ export const DEFAULT_MODEL_AIR = 'urn:air:sdxl:checkpoint:civitai:101055@128078'
12
21
  * Terminal orchestrator statuses (lowercase — matches what the API returns).
13
22
  */
14
23
  export const TERMINAL_STATUSES = ['succeeded', 'failed', 'expired', 'canceled'];
24
+ // ---------- Step type catalog ----------------------------------------------
25
+ /**
26
+ * Every workflow step type the orchestrator accepts, with a one-line
27
+ * description. Use this as a map: find the step `$type` you want, then look
28
+ * at the matching `build*Body` helper (if one exists) or fall back to
29
+ * {@link callOrchestrator} with a hand-crafted body.
30
+ *
31
+ * Source of truth is `https://orchestration.civitai.com/openapi/v2-consumers.json`.
32
+ * If a step type is missing here, the catalog is stale — open a PR.
33
+ */
34
+ export const WORKFLOW_STEP_TYPES = {
35
+ // ----- Image gen ---------------------------------------------------------
36
+ /** Diffusion image gen (SDXL / Flux.1 / Pony / Illustrious / SD1.5 / etc.). Use {@link buildTextToImageBody}. */
37
+ textToImage: 'Text-to-image via diffusion checkpoints (AIR URN models)',
38
+ /**
39
+ * Closed-source image-gen APIs (Nano Banana, Gemini, Flux.1 Kontext, Flux.2,
40
+ * GPT-Image, Seedream, Grok, fal, …). Each engine has its own input shape;
41
+ * see {@link IMAGE_GEN_ENGINES}. Use {@link buildImageGenBody}.
42
+ */
43
+ imageGen: 'Closed-source image gen (Nano Banana, Gemini, GPT-Image, Flux Kontext, Seedream, Grok, fal, …)',
44
+ /** Arbitrary ComfyUI workflow graphs. Pass a `prompt` object (node graph). */
45
+ comfy: 'Custom ComfyUI node-graph workflows',
46
+ /** Upscale an existing image. Input is a source image URL + scale factor. */
47
+ imageUpscaler: 'Image upscaling',
48
+ /** LoRA / DoRA / embedding training. Long-running. */
49
+ imageResourceTraining: 'Train a LoRA / DoRA / embedding from a dataset',
50
+ /** Pre-process an image (resize, ControlNet preprocessor, etc.). */
51
+ preprocessImage: 'Image preprocessing (resize, ControlNet preprocessors, …)',
52
+ /** Format conversion between png/jpeg/webp/avif. */
53
+ convertImage: 'Image format conversion',
54
+ /** Upload arbitrary blob bytes for use as a reference in a later step. */
55
+ imageUpload: 'Upload an image blob to use as input in a later step',
56
+ // ----- Video gen ---------------------------------------------------------
57
+ /** Video gen across all engines (VEO 3, Kling, Wan, Vidu, Sora, LTX, …). */
58
+ videoGen: 'Video generation across all engines (VEO 3, Kling, Wan, Vidu, Sora, LTX, …)',
59
+ /** Upscale an existing video. */
60
+ videoUpscaler: 'Video upscaling',
61
+ /** Frame interpolation / smoothing. */
62
+ videoInterpolation: 'Video frame interpolation',
63
+ /** Per-frame transformations (denoise, color correct, etc.). */
64
+ videoEnhancement: 'Per-frame video enhancement',
65
+ /** Extract individual frames from a video. */
66
+ videoFrameExtraction: 'Extract frames from a video',
67
+ /** Read video metadata (duration, codec, dimensions). */
68
+ videoMetadata: 'Read video file metadata',
69
+ /** Transcode video format / codec. */
70
+ transcode: 'Audio/video transcoding',
71
+ // ----- Audio -------------------------------------------------------------
72
+ /** Text-to-speech (multi-voice, multi-language). */
73
+ textToSpeech: 'Text-to-speech synthesis',
74
+ /** Music generation via ACE Step 1.5 (lyrics + style → song). */
75
+ aceStepAudio: 'Music generation (ACE Step 1.5)',
76
+ /** Speech-to-text transcription. */
77
+ transcription: 'Speech-to-text transcription',
78
+ /** Mix multiple audio tracks. */
79
+ audioMix: 'Audio track mixing',
80
+ /** Generate captions from audio. */
81
+ audioCaptioning: 'Caption generation from audio',
82
+ // ----- Classification / tagging / moderation ----------------------------
83
+ /** Hash an image / video / model for dedup or lookup. */
84
+ mediaHash: 'Media content hashing',
85
+ /** Hash a model file. */
86
+ modelHash: 'Model file hashing',
87
+ /** Rate media on aesthetic / quality axes. */
88
+ mediaRating: 'Media aesthetic / quality rating',
89
+ /** Caption an image with a vision model. */
90
+ mediaCaptioning: 'Image captioning via vision models',
91
+ /** WD-14 tagger (anime / booru tags). */
92
+ wdTagging: 'WD-14 anime tagging',
93
+ /** Estimate an age range for faces in an image. */
94
+ ageClassification: 'Age range classification',
95
+ /** xGuard NSFW / safety moderation. */
96
+ xGuardModeration: 'NSFW / safety moderation',
97
+ /** ClamAV scan a model file for malware. */
98
+ modelClamScan: 'Antivirus scan a model file',
99
+ /** Pickle-scan a model file for unsafe pickles. */
100
+ modelPickleScan: 'Pickle-safety scan for model files',
101
+ /** Parse model file metadata (SafeTensors / GGUF headers). */
102
+ modelParseMetadata: 'Parse model file metadata',
103
+ // ----- LLM ---------------------------------------------------------------
104
+ /** Chat completion (OpenAI / Anthropic / Gemini / local OSS). */
105
+ chatCompletion: 'LLM chat completion',
106
+ /** Generate a richer prompt from a short seed prompt. */
107
+ promptEnhancement: 'Prompt expansion via LLM',
108
+ // ----- Utility -----------------------------------------------------------
109
+ /** Echo the input back. Useful for testing the round-trip. */
110
+ echo: 'Echo step — round-trip the input for testing',
111
+ /** Package multiple blobs into a zip archive. */
112
+ blobArchive: 'Zip multiple blobs into an archive',
113
+ };
114
+ /**
115
+ * Engines that the `imageGen` step accepts. Each one has its own input shape;
116
+ * the body's `engine` field selects which shape applies.
117
+ *
118
+ * Pair with {@link buildImageGenBody} or hand-craft via {@link callOrchestrator}.
119
+ */
120
+ export const IMAGE_GEN_ENGINES = {
121
+ /** Nano Banana 2 / Nano Banana Pro / Imagen 4. */
122
+ google: 'Google (Nano Banana, Imagen)',
123
+ /** Gemini 2.5 Flash image gen + editing. */
124
+ gemini: 'Gemini',
125
+ /** GPT-Image-1 / GPT-Image-1.5 / DALL-E-3. */
126
+ openai: 'OpenAI (GPT-Image, DALL-E)',
127
+ /** Flux.1 Kontext (pro/max/dev) — image editing with ref images. */
128
+ 'flux1-kontext': 'Flux.1 Kontext (image editing)',
129
+ /** Flux.2 family (pro/max/dev/flex/klein). */
130
+ flux2: 'Flux.2',
131
+ /** Seedream (ByteDance) — 2K/4K image gen. */
132
+ seedream: 'Seedream',
133
+ /** Grok image generation. */
134
+ grok: 'Grok',
135
+ /** Wan image generation. */
136
+ wan: 'Wan',
137
+ /** Self-hosted SDCpp (stable-diffusion.cpp) gen. */
138
+ sdcpp: 'SDCpp (self-hosted diffusion)',
139
+ /** fal.ai routed gen. */
140
+ fal: 'fal.ai',
141
+ /** Comfy graph as an imageGen step (vs. the top-level `comfy` step). */
142
+ comfy: 'Comfy (engine-style)',
143
+ };
15
144
  export class OrchestratorError extends Error {
16
145
  status;
17
146
  body;
@@ -88,6 +217,84 @@ export function buildTextToImageBody(input, opts = {}) {
88
217
  body.tags = opts.tags;
89
218
  return body;
90
219
  }
220
+ /**
221
+ * Build an `imageGen` workflow body. Pass-through for engine-specific input
222
+ * fields — see {@link ImageGenInput} for examples per engine.
223
+ *
224
+ * @example Nano Banana 2 with a reference image
225
+ * ```ts
226
+ * const body = buildImageGenBody({
227
+ * engine: 'google',
228
+ * model: 'nano-banana-2',
229
+ * prompt: 'turn this into a cartoon sticker',
230
+ * images: ['data:image/png;base64,...'],
231
+ * aspectRatio: '1:1',
232
+ * numImages: 1,
233
+ * resolution: '1K',
234
+ * }, { tags: ['my-app'] });
235
+ *
236
+ * const estimate = await estimateWorkflow(client, body);
237
+ * const submitted = await submitWorkflow(client, body);
238
+ * ```
239
+ *
240
+ * @example Flux.1 Kontext for image editing
241
+ * ```ts
242
+ * const body = buildImageGenBody({
243
+ * engine: 'flux1-kontext',
244
+ * model: 'pro',
245
+ * prompt: 'add sunglasses',
246
+ * images: ['https://example.com/portrait.jpg'],
247
+ * aspectRatio: '1:1',
248
+ * });
249
+ * ```
250
+ */
251
+ export function buildImageGenBody(input, opts = {}) {
252
+ const body = {
253
+ steps: [
254
+ {
255
+ $type: 'imageGen',
256
+ name: opts.name ?? 'step_0',
257
+ timeout: opts.timeout ?? '00:10:00',
258
+ input,
259
+ },
260
+ ],
261
+ };
262
+ if (opts.tags && opts.tags.length > 0)
263
+ body.tags = opts.tags;
264
+ return body;
265
+ }
266
+ /**
267
+ * Lowest-level body builder — drops a single step into the `{ steps: [...] }`
268
+ * envelope and fills in `name` / `timeout` defaults. Use this when no dedicated
269
+ * `build*Body` exists for your step type.
270
+ *
271
+ * For multi-step workflows, hand-build `{ tags?, steps: [step1, step2, ...] }`
272
+ * yourself — there's no special envelope work beyond a JSON array.
273
+ *
274
+ * @example videoGen via VEO 3
275
+ * ```ts
276
+ * const body = buildWorkflowBody({
277
+ * $type: 'videoGen',
278
+ * input: { engine: 'veo3', prompt: 'a fox jumping', duration: 8 },
279
+ * }, { tags: ['my-app'] });
280
+ * ```
281
+ */
282
+ export function buildWorkflowBody(step, opts = {}) {
283
+ const body = {
284
+ steps: [
285
+ {
286
+ $type: step.$type,
287
+ name: step.name ?? 'step_0',
288
+ timeout: step.timeout ?? '00:10:00',
289
+ input: step.input,
290
+ ...(step.metadata ? { metadata: step.metadata } : {}),
291
+ },
292
+ ],
293
+ };
294
+ if (opts.tags && opts.tags.length > 0)
295
+ body.tags = opts.tags;
296
+ return body;
297
+ }
91
298
  // ---------- Workflow endpoints ---------------------------------------------
92
299
  /**
93
300
  * Cost preview ("what if") — runs the workflow validation/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,GAAG,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.6.0",
4
4
  "description": "OAuth + PKCE, encrypted-cookie sessions, scopes, and orchestrator helpers for building third-party Civitai apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,10 +26,16 @@
26
26
  "./orchestrator": {
27
27
  "types": "./dist/orchestrator/index.d.ts",
28
28
  "import": "./dist/orchestrator/index.js"
29
- }
29
+ },
30
+ "./blocks": {
31
+ "types": "./dist/blocks/index.d.ts",
32
+ "import": "./dist/blocks/index.js"
33
+ },
34
+ "./schemas/app-block/v1.json": "./schemas/app-block/v1.json"
30
35
  },
31
36
  "files": [
32
37
  "dist",
38
+ "schemas",
33
39
  "README.md"
34
40
  ],
35
41
  "scripts": {
@@ -43,7 +49,7 @@
43
49
  },
44
50
  "dependencies": {},
45
51
  "devDependencies": {
46
- "@types/node": "^20.19.9",
52
+ "@types/node": "^25.9.1",
47
53
  "typescript": "^5.9.2",
48
54
  "vitest": "^4.0.18"
49
55
  },
@@ -65,7 +71,7 @@
65
71
  "bugs": "https://github.com/civitai/civitai-app-starters/issues",
66
72
  "repository": {
67
73
  "type": "git",
68
- "url": "https://github.com/civitai/civitai-app-starters.git",
74
+ "url": "git+https://github.com/civitai/civitai-app-starters.git",
69
75
  "directory": "packages/civitai-app-sdk"
70
76
  }
71
77
  }
@@ -0,0 +1,184 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://civitai.com/schemas/app-block/v1.json",
4
+ "title": "Civitai App Block Manifest v1",
5
+ "description": "Manifest shape for a Civitai App Block. Mirrors the runtime check performed by defineBlock() in @civitai/app-sdk/blocks.",
6
+ "type": "object",
7
+ "required": [
8
+ "$schema",
9
+ "appId",
10
+ "blockId",
11
+ "version",
12
+ "name",
13
+ "type",
14
+ "targets",
15
+ "scopes",
16
+ "iframe",
17
+ "contentRating",
18
+ "minApiVersion"
19
+ ],
20
+ "additionalProperties": true,
21
+ "properties": {
22
+ "$schema": {
23
+ "type": "string",
24
+ "const": "https://civitai.com/schemas/app-block/v1.json"
25
+ },
26
+ "appId": {
27
+ "type": "string",
28
+ "minLength": 1
29
+ },
30
+ "blockId": {
31
+ "type": "string",
32
+ "pattern": "^[a-z0-9-]{3,64}$",
33
+ "description": "Immutable block identifier. Lowercase letters, digits, and hyphens; 3-64 characters."
34
+ },
35
+ "version": {
36
+ "type": "string",
37
+ "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$",
38
+ "description": "Semver."
39
+ },
40
+ "name": {
41
+ "type": "string",
42
+ "minLength": 1,
43
+ "maxLength": 80
44
+ },
45
+ "type": {
46
+ "type": "string",
47
+ "enum": ["block", "embed"]
48
+ },
49
+ "targets": {
50
+ "type": "array",
51
+ "minItems": 1,
52
+ "items": {
53
+ "type": "object",
54
+ "required": ["slotId", "priority"],
55
+ "properties": {
56
+ "slotId": { "type": "string", "minLength": 1 },
57
+ "priority": { "type": "integer" },
58
+ "requiredContext": {
59
+ "type": "array",
60
+ "items": { "type": "string" }
61
+ }
62
+ }
63
+ }
64
+ },
65
+ "scopes": {
66
+ "type": "array",
67
+ "minItems": 1,
68
+ "items": {
69
+ "type": "string",
70
+ "pattern": "^[a-z]+:[a-z]+:[a-z]+$",
71
+ "description": "Colon-separated lowercase, e.g. models:read:self. PascalCase is rejected."
72
+ }
73
+ },
74
+ "iframe": {
75
+ "type": "object",
76
+ "required": ["src", "minHeight", "resizable", "sandbox"],
77
+ "properties": {
78
+ "src": {
79
+ "type": "string",
80
+ "description": "HTTPS URL of the block app. http://localhost or http://127.0.0.1 also accepted for local dev."
81
+ },
82
+ "minHeight": { "type": "integer", "exclusiveMinimum": 0 },
83
+ "maxHeight": { "type": ["integer", "null"] },
84
+ "resizable": { "type": "boolean" },
85
+ "sandbox": {
86
+ "type": "string",
87
+ "allOf": [
88
+ {
89
+ "not": { "pattern": "(^|\\s)allow-same-origin(\\s|$)" },
90
+ "description": "Must not contain allow-same-origin — combined with allow-scripts it defeats the sandbox."
91
+ },
92
+ {
93
+ "not": { "pattern": "(^|\\s)allow-top-navigation(\\s|$)" },
94
+ "description": "Must not contain allow-top-navigation — use the NAVIGATE postMessage instead."
95
+ },
96
+ {
97
+ "not": { "pattern": "(^|\\s)allow-top-navigation-by-user-activation(\\s|$)" },
98
+ "description": "Must not contain allow-top-navigation-by-user-activation — same threat as allow-top-navigation, gated on a user gesture."
99
+ },
100
+ {
101
+ "not": { "pattern": "(^|\\s)allow-top-navigation-to-custom-protocols(\\s|$)" },
102
+ "description": "Must not contain allow-top-navigation-to-custom-protocols — same threat as allow-top-navigation, restricted to non-fetch schemes."
103
+ }
104
+ ]
105
+ }
106
+ }
107
+ },
108
+ "assets": {
109
+ "type": "array",
110
+ "items": {
111
+ "type": "object",
112
+ "required": ["url", "integrity"],
113
+ "properties": {
114
+ "url": { "type": "string" },
115
+ "integrity": {
116
+ "type": "string",
117
+ "pattern": "^sha(256|384|512)-[A-Za-z0-9+/=]+$"
118
+ }
119
+ }
120
+ }
121
+ },
122
+ "settings": {
123
+ "type": "array",
124
+ "items": {
125
+ "type": "object",
126
+ "required": ["id", "type", "label"],
127
+ "properties": {
128
+ "id": { "type": "string", "minLength": 1 },
129
+ "type": { "type": "string", "enum": ["string", "number", "boolean", "select"] },
130
+ "label": { "type": "string", "minLength": 1 },
131
+ "default": {},
132
+ "options": {
133
+ "type": "array",
134
+ "items": {
135
+ "type": "object",
136
+ "required": ["value", "label"],
137
+ "properties": {
138
+ "value": { "type": "string" },
139
+ "label": { "type": "string" }
140
+ }
141
+ }
142
+ },
143
+ "min": { "type": "number" },
144
+ "max": { "type": "number" },
145
+ "required": { "type": "boolean" }
146
+ }
147
+ }
148
+ },
149
+ "contentRating": {
150
+ "type": "string",
151
+ "enum": ["g", "pg", "pg13", "r", "x"]
152
+ },
153
+ "preview": {
154
+ "type": "object",
155
+ "required": ["thumbnail", "description"],
156
+ "properties": {
157
+ "thumbnail": { "type": "string" },
158
+ "description": { "type": "string" },
159
+ "screenshots": {
160
+ "type": "array",
161
+ "items": { "type": "string" }
162
+ }
163
+ }
164
+ },
165
+ "promotionEligible": { "type": "boolean" },
166
+ "minApiVersion": { "type": "string" },
167
+ "renderMode": {
168
+ "type": "string",
169
+ "enum": ["iframe", "inline", "hybrid"],
170
+ "description": "Optional. Defaults to iframe. v1 manifests may omit."
171
+ },
172
+ "assetBundle": {
173
+ "type": "object",
174
+ "properties": {
175
+ "url": { "type": ["string", "null"] },
176
+ "sha256": { "type": ["string", "null"] }
177
+ }
178
+ },
179
+ "trustTier": {
180
+ "type": "string",
181
+ "enum": ["unverified", "verified", "internal"]
182
+ }
183
+ }
184
+ }
@@ -1,23 +0,0 @@
1
- import { createCivitaiClient } from '@civitai/client';
2
- /** The orchestrator client returned by `createCivitaiClient`. */
3
- export type CivitaiClient = ReturnType<typeof createCivitaiClient>;
4
- export interface CreateAppClientOptions {
5
- /** OAuth access token or personal API key. Used as Bearer credential. */
6
- token: string;
7
- /** Orchestrator base URL. Defaults to Civitai's prod orchestrator. */
8
- baseUrl?: string;
9
- /** SDK env mode. Defaults to 'prod'. */
10
- env?: 'dev' | 'prod';
11
- }
12
- /**
13
- * Create a typed Civitai orchestrator client authenticated with the user's
14
- * OAuth access token (or a personal API key — same Bearer scheme).
15
- *
16
- * Wraps `@civitai/client`'s factory with sensible defaults. The returned
17
- * client is the same shape `@civitai/client` produces — pass it to the
18
- * SDK's standalone functions (`submitWorkflow({ client, body })`, etc.)
19
- * or to the wrappers in `@civitai/app-sdk/workflows`.
20
- */
21
- export declare function createAppClient(opts: CreateAppClientOptions): CivitaiClient;
22
- export type AppClient = CivitaiClient;
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEnE,MAAM,WAAW,sBAAsB;IACrC,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACtB;AAID;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,aAAa,CAM3E;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC"}
@@ -1,19 +0,0 @@
1
- import { createCivitaiClient } from '@civitai/client';
2
- const DEFAULT_ORCHESTRATOR_BASE_URL = 'https://orchestration-new.civitai.com';
3
- /**
4
- * Create a typed Civitai orchestrator client authenticated with the user's
5
- * OAuth access token (or a personal API key — same Bearer scheme).
6
- *
7
- * Wraps `@civitai/client`'s factory with sensible defaults. The returned
8
- * client is the same shape `@civitai/client` produces — pass it to the
9
- * SDK's standalone functions (`submitWorkflow({ client, body })`, etc.)
10
- * or to the wrappers in `@civitai/app-sdk/workflows`.
11
- */
12
- export function createAppClient(opts) {
13
- return createCivitaiClient({
14
- baseUrl: opts.baseUrl ?? DEFAULT_ORCHESTRATOR_BASE_URL,
15
- env: opts.env ?? 'prod',
16
- auth: opts.token,
17
- });
18
- }
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AActD,MAAM,6BAA6B,GAAG,uCAAuC,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAA4B;IAC1D,OAAO,mBAAmB,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,6BAA6B;QACtD,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,MAAM;QACvB,IAAI,EAAE,IAAI,CAAC,KAAK;KACjB,CAAC,CAAC;AACL,CAAC"}
@@ -1,52 +0,0 @@
1
- import { type SubmitWorkflowData, type Workflow } from '@civitai/client';
2
- import type { AppClient } from '../client/index.js';
3
- /**
4
- * Thin wrappers around the orchestrator's workflow endpoints with conventions
5
- * suited to third-party app starters. All calls use the user's OAuth token
6
- * (or API key) carried by the `AppClient` — the orchestrator debits Buzz
7
- * from whoever owns that token.
8
- */
9
- export type WorkflowBody = NonNullable<SubmitWorkflowData['body']>;
10
- export interface CostEstimate {
11
- /** Buzz cost. Pulled from the workflow's `cost.total` field. */
12
- total: number;
13
- /** Full workflow response (validation result, queue placement, etc.). */
14
- raw: Workflow;
15
- }
16
- declare class WorkflowError extends Error {
17
- readonly status: number | undefined;
18
- readonly detail: unknown;
19
- readonly name = "WorkflowError";
20
- constructor(message: string, status: number | undefined, detail: unknown);
21
- }
22
- /**
23
- * Cost preview ("what if") — runs the workflow validation/pricing pipeline
24
- * without committing any Buzz. Use this to show the user "this will cost X
25
- * Buzz" before they confirm submission.
26
- *
27
- * NOTE: per Civitai's docs, `whatif=true` validates and prices but does not
28
- * apply per-app spending caps to the response — a successful whatif can still
29
- * be denied at submit time if the user has set tight caps or insufficient
30
- * funds. Treat `whatif` as "this is the price" not "this is approved."
31
- */
32
- export declare function estimateCost(client: AppClient, body: WorkflowBody): Promise<CostEstimate>;
33
- /** Submit a workflow for real execution. Debits the token-owner's Buzz. */
34
- export declare function submitWorkflow(client: AppClient, body: WorkflowBody): Promise<Workflow>;
35
- export declare function getWorkflow(client: AppClient, workflowId: string): Promise<Workflow>;
36
- export interface PollWorkflowOptions {
37
- /** Polling interval in ms. Default 2000. */
38
- intervalMs?: number;
39
- /** Max total time to poll in ms. Default 5 minutes. */
40
- timeoutMs?: number;
41
- /** Optional progress callback fired on every poll tick. */
42
- onTick?: (snapshot: Workflow) => void;
43
- /** Optional abort signal. */
44
- signal?: AbortSignal;
45
- }
46
- /**
47
- * Poll a workflow until it reaches a terminal status (`Succeeded`, `Failed`,
48
- * `Canceled`) or the timeout elapses. Returns the final snapshot.
49
- */
50
- export declare function pollWorkflow(client: AppClient, workflowId: string, opts?: PollWorkflowOptions): Promise<Workflow>;
51
- export { WorkflowError };
52
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,cAAM,aAAc,SAAQ,KAAK;IAI7B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO;IAJ1B,SAAkB,IAAI,mBAAmB;gBAEvC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,OAAO;CAI3B;AAkBD;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ/F;AAED,2EAA2E;AAC3E,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,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