@civitai/app-sdk 0.52.0 → 0.54.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 CHANGED
@@ -87,7 +87,7 @@ over `window.postMessage({ type, payload }, targetOrigin)`, discriminated by
87
87
  - **parent → block**: `BLOCK_INIT`, `TOKEN_REFRESH`, `TOKEN_REFRESH_RESPONSE`,
88
88
  `ESTIMATE_RESULT`, `WORKFLOW_SUBMITTED`, `WORKFLOW_STATUS`,
89
89
  `BUZZ_PURCHASE_RESULT`, `CHECKPOINT_PICKER_RESULT`, `USER_CHECKPOINT_SET`,
90
- `APP_STORAGE_*_RESULT`, `SUSPEND`, `RESUME`, `THEME_CHANGE`,
90
+ `APP_STORAGE_*_RESULT`, `SUSPEND`, `RESUME`, `THEME_CHANGE`, `ROUTE_CHANGED`,
91
91
  `CONSENT_UNAVAILABLE` (`ParentToBlockMessage`).
92
92
  - **block → parent**: `BLOCK_READY`, `BLOCK_ERROR`, `REQUEST_TOKEN`,
93
93
  `RESIZE_IFRAME`, `SUBMIT_WORKFLOW`, `ESTIMATE_WORKFLOW`, `POLL_WORKFLOW`,
@@ -446,7 +446,7 @@ The starters in `civitai/civitai-app-starters` wire this into framework-specific
446
446
 
447
447
  ## Choosing a workflow step type
448
448
 
449
- The orchestrator is a workflow API: each request submits a list of typed steps. `WORKFLOW_STEP_TYPES` is the in-code catalog of every step `$type` it accepts, with a one-line description for each — `textToImage`, `imageGen`, `videoGen`, `comfy`, `customComfy`, `textToSpeech`, `aceStepAudio`, `transcription`, `imageUpscaler` among them (50 in total).
449
+ The orchestrator is a workflow API: each request submits a list of typed steps. `WORKFLOW_STEP_TYPES` is the in-code catalog of every step `$type` it accepts, with a one-line description for each — `textToImage`, `imageGen`, `videoGen`, `comfy`, `customComfy`, `textToSpeech`, `aceStepAudio`, `transcription`, `imageUpscaler` among them (51 in total).
450
450
 
451
451
  The catalog is pinned to the orchestrator's published OpenAPI spec two ways — an offline unit test against a transcribed copy of the spec's `WorkflowStepTemplate` discriminator mapping, and a CI job (`pnpm check:catalogs`) that re-fetches the live spec and diffs it. If a `$type` is listed here, the orchestrator accepts it.
452
452
 
@@ -521,15 +521,15 @@ What it exports:
521
521
 
522
522
  | Export | What |
523
523
  |---|---|
524
- | `WorkflowStepTemplates` | `$type` → template type, for 47 of the catalog's 50 step types. Keyed by the WIRE name, which the generated type names don't always match (`model3DPreview` → `Model3dPreviewStepTemplate`). |
524
+ | `WorkflowStepTemplates` | `$type` → template type, for 47 of the catalog's 51 step types. Keyed by the WIRE name, which the generated type names don't always match (`model3DPreview` → `Model3dPreviewStepTemplate`). |
525
525
  | `WorkflowStepTemplateFor<'videoGen'>` | One step's template. |
526
526
  | `WorkflowStepInputFor<'videoGen'>` | One step's `input` shape, without needing the generated `*Input` name. |
527
527
  | `AnyWorkflowStepTemplate` | Discriminated union of all 47 mapped templates — `Extract<…, { $type: 'comfy' }>` and exhaustive `switch` work. `@civitai/client`'s base `WorkflowStepTemplate` has `$type` as a bare `string`, so it narrows nothing. |
528
528
  | `TypedWorkflowTemplate` | The submit envelope with `steps` narrowed to that union. Pass it straight to `submitWorkflow` / `estimateWorkflow`. |
529
529
 
530
- > 🔴 **The map is not total over the catalog, and that is the expected state.** `WORKFLOW_STEP_TYPES` documents 50 `$type`s; this map covers 47. The 3 with no generated template in the pinned `@civitai/client` are `imageScanning`, `preprocessVideo`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile error for each of them.
530
+ > 🔴 **The map is not total over the catalog, and that is the expected state.** `WORKFLOW_STEP_TYPES` documents 51 `$type`s; this map covers 47. The 4 with no generated template in the pinned `@civitai/client` are `imageScanning`, `preprocessVideo`, `soniloAudioGen`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile error for each of them.
531
531
  >
532
- > The two surfaces move independently on purpose: the catalog tracks the **live** orchestrator spec (a daily job syncs it), while these types track whatever `@civitai/client` was last published from. So the catalog runs ahead and the client catches up. The gap is never silent — `test/orchestrator/step-templates.test-d.ts` carries it as a `never` ledger plus one `@ts-expect-error` per gap `$type`, and `test/orchestrator/step-count-prose.test.ts` derives all four numbers (50, 47, 3, and the names) from `WORKFLOW_STEP_TYPES` and the map's own AST, then fails if this paragraph or its twin in `src/orchestrator/steps.ts` disagrees by one character.
532
+ > The two surfaces move independently on purpose: the catalog tracks the **live** orchestrator spec (a daily job syncs it), while these types track whatever `@civitai/client` was last published from. So the catalog runs ahead and the client catches up. The gap is never silent — `test/orchestrator/step-templates.test-d.ts` carries it as a `never` ledger plus one `@ts-expect-error` per gap `$type`, and `test/orchestrator/step-count-prose.test.ts` derives all four numbers (51, 47, 4, and the names) from `WORKFLOW_STEP_TYPES` and the map's own AST, then fails if this paragraph or its twin in `src/orchestrator/steps.ts` disagrees by one character.
533
533
 
534
534
  The generated `*StepTemplate` and `*Input` types are **not** re-exported individually. Using this subpath already requires `@civitai/client` installed, so if you want one by name, import it straight from there — `import type { TextToImageStepTemplate } from '@civitai/client'`.
535
535
 
@@ -566,7 +566,7 @@ A `$type` having a type here says nothing about whether you may submit it.
566
566
 
567
567
  Several of the 47 exist to serve Civitai's own pipelines rather than third-party apps — `modelPickleScan`, `xGuardModeration`, `training`, `comfyNodepackSnapshot`, `qwenImageBench`, the `model*`/`media*` hashing and classification steps. They're in the consumer spec, so they're typed here. They are not an invitation.
568
568
 
569
- Note that `WORKFLOW_STEP_TYPES` does **not** mark most of them: of its 50 entries exactly two — `comfyNodepackSnapshot` and `qwenImageBench` — sit under its "Platform internals" heading, and the rest are ordinary documented entries (`webScrape` even carries usage notes). The reason the platform steps are typed anyway is not that the catalog flags them as internal; it's that the catalog *documents* them, so skipping them would make `WorkflowStepTemplateFor<'training'>` a compile error for a step type the SDK documents — which is exactly what is live today for the 3 `$type`s the pinned client cannot type, and is why that gap is spelled out above rather than left to be discovered.
569
+ Note that `WORKFLOW_STEP_TYPES` does **not** mark most of them: of its 51 entries exactly two — `comfyNodepackSnapshot` and `qwenImageBench` — sit under its "Platform internals" heading, and the rest are ordinary documented entries (`webScrape` even carries usage notes). The reason the platform steps are typed anyway is not that the catalog flags them as internal; it's that the catalog *documents* them, so skipping them would make `WorkflowStepTemplateFor<'training'>` a compile error for a step type the SDK documents — which is exactly what is live today for the 3 `$type`s the pinned client cannot type, and is why that gap is spelled out above rather than left to be discovered.
570
570
 
571
571
  ## Public vs. confidential clients
572
572
 
@@ -77,5 +77,5 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
77
77
  * in `types.ts` for which of the two it uses and why.
78
78
  */
79
79
  export { isSignedIn } from './types.js';
80
- export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockTextToImageParams, BlockWorkflowSnapshot, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, } from './types.js';
80
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, } from './types.js';
81
81
  //# sourceMappingURL=index.d.ts.map
@@ -8,7 +8,7 @@
8
8
  * Wire format: `window.postMessage({ type, payload }, targetOrigin)`.
9
9
  */
10
10
  import type { ColorDomain } from './browsingLevel.js';
11
- import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult } from './types.js';
11
+ import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult } from './types.js';
12
12
  /**
13
13
  * Filter params for `GET_BUZZ_TRANSACTIONS`. All optional; the host validates
14
14
  * them server-side (they are NEVER trusted for auth — the account is self-bound
@@ -345,6 +345,11 @@ export type ParentToBlockMessage = {
345
345
  payload: {
346
346
  theme: Theme;
347
347
  };
348
+ } | {
349
+ type: 'ROUTE_CHANGED';
350
+ payload: {
351
+ subPath: string;
352
+ };
348
353
  } | {
349
354
  type: 'CONSENT_UNAVAILABLE';
350
355
  payload: ConsentUnavailablePayload;
@@ -785,7 +790,8 @@ export type BlockToParentMessage = {
785
790
  type: 'OPEN_CHECKPOINT_PICKER';
786
791
  payload: {
787
792
  requestId: string;
788
- baseModelGroup: string;
793
+ /** Optional ecosystem-family filter. Absent ⇒ unconstrained. Never ''. */
794
+ baseModelGroup?: string;
789
795
  /** Currently-selected versionId so the picker can pre-highlight it. */
790
796
  currentVersionId?: number;
791
797
  };
@@ -814,6 +820,7 @@ export type BlockToParentMessage = {
814
820
  type: 'NAVIGATE';
815
821
  payload: {
816
822
  path: string;
823
+ scope?: BlockNavigateScope;
817
824
  target: 'current' | 'new_tab';
818
825
  };
819
826
  } | {
@@ -258,6 +258,28 @@ export type BlockImageScanResult = {
258
258
  * `imageId`/`nsfwLevel`/`contentRating` crosses back into the block.
259
259
  */
260
260
  export type BlockUploadPurpose = 'display' | 'generationSource';
261
+ /**
262
+ * Which SPACE a `NAVIGATE` path is resolved in. Mirrors the host's
263
+ * `NavigateScope` in civitai/civitai's `pageBlockHostLogic.ts`. Keep in lockstep.
264
+ *
265
+ * - `'app'` (DEFAULT): the path is resolved under the block's OWN route
266
+ * (`<base>/<slug>/<path>`) and pushed shallowly, so the page stays mounted.
267
+ * - `'site'`: the path is resolved at the SITE root, non-shallow, and the viewer
268
+ * leaves the app. Granted per-surface — the host refuses it outright on a
269
+ * surface that does not hold the capability — and `/api/*` is refused in this
270
+ * scope regardless.
271
+ *
272
+ * 🔴 ABSENT IS `'app'`, and the host compares against the literal `'site'` rather
273
+ * than validating against this union, so an UNKNOWN value fails CLOSED onto
274
+ * `'app'` too. That is what makes the field additive: a block built against an
275
+ * SDK that predates `scope` sends nothing and keeps the behaviour it always had.
276
+ *
277
+ * 🔴 A LEADING SLASH CARRIES NO MEANING. `scope` selects the space and `path` is a
278
+ * path WITHIN it, so the host normalises leading slashes away:
279
+ * `{ scope: 'app', path: '/settings' }` and `{ scope: 'app', path: 'settings' }`
280
+ * are one request. Do not reintroduce punctuation semantics.
281
+ */
282
+ export type BlockNavigateScope = 'app' | 'site';
261
283
  /**
262
284
  * The source-image result the host returns from `OPEN_IMAGE_UPLOAD` when the
263
285
  * block requested `purpose: 'generationSource'` (`IMAGE_UPLOAD_RESULT.selected`)
@@ -90,8 +90,9 @@ export const SCHEMA_DIVERGENCES = {
90
90
  'REVIEW IN THE OTHER DIRECTION: `allow-popups`, `allow-modals`, `allow-downloads` and any ' +
91
91
  'other token outside {allow-scripts, allow-forms} PASS HERE and may be refused at review. ' +
92
92
  'They are not rejected because the tier is assigned server-side during review and is ' +
93
- 'unknowable locally — `starters/civitai-block-starter` itself ships ' +
94
- '"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox". See ' +
93
+ 'unknowable locally. Every shipped starter and example now declares exactly ' +
94
+ '"allow-scripts allow-forms", so none of them illustrates this gap any more — the looser ' +
95
+ 'arm is pinned by the synthetic cases in test/manifest/divergences.test.ts instead. See ' +
95
96
  'KNOWN_GAPS["tier-dependent-sandbox-allowlist"].',
96
97
  },
97
98
  scopeJustifications: {
@@ -130,6 +130,8 @@ export declare const WORKFLOW_STEP_TYPES: {
130
130
  * `maxDuration` is an upper bound; generation can stop earlier.
131
131
  */
132
132
  readonly yuE2: "Generate a song from style and lyrics with YuE2";
133
+ /** Music or a standalone sound effect from a text prompt. */
134
+ readonly soniloAudioGen: "Music or a sound effect from a text prompt (Sonilo)";
133
135
  /** Speech-to-text transcription. */
134
136
  readonly transcription: "Speech-to-text transcription";
135
137
  /** Generate captions from audio. */
@@ -134,6 +134,8 @@ export const WORKFLOW_STEP_TYPES = {
134
134
  * `maxDuration` is an upper bound; generation can stop earlier.
135
135
  */
136
136
  yuE2: 'Generate a song from style and lyrics with YuE2',
137
+ /** Music or a standalone sound effect from a text prompt. */
138
+ soniloAudioGen: 'Music or a sound effect from a text prompt (Sonilo)',
137
139
  /** Speech-to-text transcription. */
138
140
  transcription: 'Speech-to-text transcription',
139
141
  /** Generate captions from audio. */
@@ -3,7 +3,7 @@
3
3
  * own generated client (`@civitai/client`).
4
4
  *
5
5
  * The sibling `@civitai/app-sdk/orchestrator` module gives you the *catalog*
6
- * (`WORKFLOW_STEP_TYPES` — 50 `$type` names and what each one does) and the
6
+ * (`WORKFLOW_STEP_TYPES` — 51 `$type` names and what each one does) and the
7
7
  * fetch helpers (`submitWorkflow`, `estimateWorkflow`, …), but its body
8
8
  * builders take `input: unknown`. This module is the missing half: the actual
9
9
  * per-step input shapes, tracked against the orchestrator's OpenAPI spec by
@@ -70,7 +70,7 @@
70
70
  * consumer spec, so they are typed here. They are not an invitation.
71
71
  *
72
72
  * ⚠️ `WORKFLOW_STEP_TYPES` does NOT mark most of them. Counted at this commit:
73
- * of its 50 entries, exactly TWO sit under its "Platform internals" heading —
73
+ * of its 51 entries, exactly TWO sit under its "Platform internals" heading —
74
74
  * `comfyNodepackSnapshot` and `qwenImageBench`. `training`, `webScrape`,
75
75
  * `xGuardModeration`, `modelPickleScan` and the `model*` / `media*` steps are
76
76
  * ordinary documented entries under ordinary headings, and `webScrape` carries
@@ -89,9 +89,9 @@
89
89
  * (#315) without anything going red. The measured state, derived rather than
90
90
  * typed:
91
91
  *
92
- * `WORKFLOW_STEP_TYPES` documents 50 `$type`s; this map covers 47. The 3 with
92
+ * `WORKFLOW_STEP_TYPES` documents 51 `$type`s; this map covers 47. The 4 with
93
93
  * no generated template in the pinned `@civitai/client` are `imageScanning`,
94
- * `preprocessVideo`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile
94
+ * `preprocessVideo`, `soniloAudioGen`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile
95
95
  * error for each of them.
96
96
  *
97
97
  * That gap is EXPECTED and is not a defect in either surface. The catalog
@@ -300,7 +300,7 @@ interface StepTemplateMap {
300
300
  xGuardModeration: XGuardModerationStepTemplate;
301
301
  }
302
302
  /**
303
- * `$type` → its step-template type, for 47 of the catalog's 50 step types.
303
+ * `$type` → its step-template type, for 47 of the catalog's 51 step types.
304
304
  *
305
305
  * Keyed by the WIRE name rather than the generated type name, because the wire
306
306
  * name is what you actually have in hand and the generator does not always
@@ -3,7 +3,7 @@
3
3
  * own generated client (`@civitai/client`).
4
4
  *
5
5
  * The sibling `@civitai/app-sdk/orchestrator` module gives you the *catalog*
6
- * (`WORKFLOW_STEP_TYPES` — 50 `$type` names and what each one does) and the
6
+ * (`WORKFLOW_STEP_TYPES` — 51 `$type` names and what each one does) and the
7
7
  * fetch helpers (`submitWorkflow`, `estimateWorkflow`, …), but its body
8
8
  * builders take `input: unknown`. This module is the missing half: the actual
9
9
  * per-step input shapes, tracked against the orchestrator's OpenAPI spec by
@@ -70,7 +70,7 @@
70
70
  * consumer spec, so they are typed here. They are not an invitation.
71
71
  *
72
72
  * ⚠️ `WORKFLOW_STEP_TYPES` does NOT mark most of them. Counted at this commit:
73
- * of its 50 entries, exactly TWO sit under its "Platform internals" heading —
73
+ * of its 51 entries, exactly TWO sit under its "Platform internals" heading —
74
74
  * `comfyNodepackSnapshot` and `qwenImageBench`. `training`, `webScrape`,
75
75
  * `xGuardModeration`, `modelPickleScan` and the `model*` / `media*` steps are
76
76
  * ordinary documented entries under ordinary headings, and `webScrape` carries
@@ -89,9 +89,9 @@
89
89
  * (#315) without anything going red. The measured state, derived rather than
90
90
  * typed:
91
91
  *
92
- * `WORKFLOW_STEP_TYPES` documents 50 `$type`s; this map covers 47. The 3 with
92
+ * `WORKFLOW_STEP_TYPES` documents 51 `$type`s; this map covers 47. The 4 with
93
93
  * no generated template in the pinned `@civitai/client` are `imageScanning`,
94
- * `preprocessVideo`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile
94
+ * `preprocessVideo`, `soniloAudioGen`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile
95
95
  * error for each of them.
96
96
  *
97
97
  * That gap is EXPECTED and is not a defect in either surface. The catalog
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.52.0",
3
+ "version": "0.54.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",