@civitai/app-sdk 0.88.0 → 0.89.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
@@ -114,8 +114,8 @@ queue it produced. Mirrors civitai/civitai PR #3164; the `@civitai/blocks-react`
114
114
 
115
115
  `PERSIST_GENERATION_SOURCE` → `GENERATION_SOURCE_PERSISTED` saves ONE of those
116
116
  outputs as a **private, scanned generation source** for the next generation.
117
- The request is `{ requestId, workflowId, imageIndex }` (an index into the
118
- workflow's `images`; never a url) and the reply carries `result`, a
117
+ The request is `{ requestId, workflowId, imageIndex }` (the output's POSITION in
118
+ the workflow's `outputs`, not an index into `images`; never a url) and the reply carries `result`, a
119
119
  `BlockPersistedGenerationSource` (`{ url, width, height, imageId, ready }`), or a
120
120
  free-text `error`. The image is private to the viewer and not on the app's
121
121
  shared grid, and there is no confirm dialog. The host waits up to about thirty
@@ -183,7 +183,46 @@ interface BlockInitPayload {
183
183
  | `isModelSlotContext(ctx)` / `isPageSlotContext(ctx)` | Runtime narrowing for the `slotId`-discriminated `BlockContext` union. Real checks on a value that crossed a `postMessage` boundary — they verify every field they assert, not just `slotId`. |
184
184
  | `fetchNestedDocument(opts)` | Embed one of your OWN bundled documents as an iframe `srcdoc`, because a nested `<iframe src>` of your own content **cannot load** — see [Nested documents](#nested-documents) below. `NestedDocumentError` carries a `.code` of `'invalid-url' \| 'http-error' \| 'network-error'`. |
185
185
  | `isSignedIn(viewer)` | **The sign-in gate.** `isSignedIn(useBlockContext().viewer)` — do not open-code it as `viewer !== null` or `viewer?.signedIn === true`. Which of those is correct has already changed once with the host contract, and this is the one place it is decided. It reads neither `viewer.id` nor `viewer.username` (both `@deprecated`), so nothing written through it changes when those are removed. Need the identity rather than the presence? `useViewer()` — scope-gated and audited per call. |
186
- | types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot` (+ `BlockWorkflowEta`, `BlockWorkflowStepQueue` and `KnownBlockWorkflowQueueSupport` — queue position, ETA and progress, see below), `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
186
+ | types | `BlockManifestV1`, `ManifestSettings` (+ field types), `BlockContext`, `ModelSlotContext`, `BlockCheckpointInfo`, `ShowcaseImage`, `BlockToken`, `WrappedToken`, `BlockSettings`, `ViewerInfo`, `Theme`, `WorkflowBody`, `BlockTextToImageParams`, `WorkflowBodyCustomComfy` (+ its two arms `WorkflowBodyCustomComfyRecipe` / `WorkflowBodyCustomComfyInline`, and `InlineComfyNode`), `WorkflowBodyStep` / `WorkflowBodyPassThroughStep` (the two arms of `kind: 'step'`), `WorkflowBodyTraining` (+ `AiToolkitTrainingParams`, `BlockTrainingQuote`, `BlockTrainingDatasetItem`, `BlockTrainingDataImage`, `BlockTrainingDataUploadResult`, `BlockRunTrainingHostError` and the `BLOCK_TRAINING_*` bounds), `WorkflowBodyWorkflow` (+ `WorkflowBodyWorkflowStep`, `WorkflowStepRef`, `WithWorkflowStepRefs`, `BlockWorkflowStepSnapshot` and `BLOCK_WORKFLOW_MAX_STEPS`), `BlockStepQuote` / `BlockRunConfirmedStepHostError` (+ `BLOCK_CONFIRMED_STEP_MAX_BUZZ_PER_JOB`, `BLOCK_STEP_QUOTE_ID_REGEX`), `BlockModel3dOutput`, `BlockWorkflowSnapshot` (+ `BlockWorkflowEta`, `BlockWorkflowStepQueue` and `KnownBlockWorkflowQueueSupport` — queue position, ETA and progress, see below; + `BlockWorkflowOutput`, `BlockWorkflowAvailableOutput`, `BlockWorkflowRestrictedOutput`, `KnownBlockWorkflowOutputRating` and `KnownBlockWorkflowRestrictionReason` — restricted outputs, see below), `WorkflowStatus`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`. |
187
+
188
+ **Restricted outputs.** `outputs` on a workflow snapshot (and on each of its
189
+ `steps`, and on an `AppWorkflow` row) lists every available output in order, with
190
+ **restricted** outputs kept in position. An entry is either `{ url, nsfwLevel? }`
191
+ (load it; `nsfwLevel` is `'pg' | 'pg13' | 'r' | 'x' | 'xxx'`, absent while
192
+ unrated) or `{ restricted: true, reason }`. A restricted entry has **no url**:
193
+ show a locked state and do not try to fetch it. `reason: 'pool'` means the Buzz
194
+ that paid does not include mature content for this viewer and the output is above
195
+ PG-13. `'ceiling'` means it is above the viewer's own browsing level, capped by
196
+ your app's maturity ceiling, or above a cap the host put on the request. A
197
+ restricted output is not in `imageUrls` (nor `AppWorkflow.images`), so those
198
+ lists can be shorter than `outputs` and are
199
+ **not for indexing**: `imageIndexes` (publish, post) and `imageIndex` (persist)
200
+ are **positions in `outputs`**, which never move when a rating lands late, and
201
+ naming a restricted position is refused with `output N is restricted`. Two more
202
+ entry shapes carry no url and keep their slot: `{ pending: true }` (not rated yet;
203
+ the snapshot then carries `ratingPending: true`, so read it again) and
204
+ `{ blocked: true }` (blocked by moderation). With `@civitai/blocks-react`, a
205
+ malformed entry reaches you as `{ restricted: true, reason: 'ceiling' }` in its own
206
+ slot (`@civitai/sdk` does not validate replies). ⚠️ **Migration:** an app that built
207
+ `imageIndexes` from `images` positions (`images.map((_, i) => i)`) now names a
208
+ different output whenever an earlier one is restricted, pending or blocked — build
209
+ them from `outputs` positions, or omit `imageIndexes`. An older host sends no
210
+ `outputs`:
211
+
212
+ ```ts
213
+ import type { BlockWorkflowOutput, BlockWorkflowSnapshot } from '@civitai/app-sdk/blocks';
214
+
215
+ function tiles(snapshot: BlockWorkflowSnapshot): Array<{ src: string } | { locked: string }> {
216
+ const outputs: BlockWorkflowOutput[] =
217
+ snapshot.outputs ?? (snapshot.imageUrls ?? []).map((url) => ({ url }));
218
+ return outputs.map((out) => {
219
+ if (out.restricted === true) return { locked: out.reason };
220
+ if (out.pending === true) return { locked: 'still processing' };
221
+ if (out.blocked === true) return { locked: 'not available' };
222
+ return { src: out.url };
223
+ });
224
+ }
225
+ ```
187
226
 
188
227
  **Queue position, ETA and progress.** A non-terminal workflow snapshot from a
189
228
  poll can carry `eta`, a summary of the step that is queued or running now, for
@@ -88,7 +88,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
88
88
  * in `types.ts` for which of the two it uses and why.
89
89
  */
90
90
  export { isSignedIn } from './types.js';
91
- export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
91
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageCollectionHook, BlockStorageCollectionSchema, BlockStorageDeclaration, BlockStorageImport, BlockStorageIndexes, BlockStorageIndexType, BlockStorageMigrationKeyword, BlockStorageMigrationOp, BlockStoragePrivateCollectionDeclaration, BlockStorageSchemaType, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockTextToImageParams, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, BuzzAccountType, ShowcaseImage, WorkflowBody, WorkflowBodyTextToImage, WorkflowBodyCustomComfy, WorkflowBodyCustomComfyRecipe, WorkflowBodyCustomComfyInline, InlineComfyNode, WorkflowBodyStep, WorkflowBodyPassThroughStep, WorkflowBodyWorkflow, WorkflowBodyWorkflowStep, WorkflowStepRef, WithWorkflowStepRefs, BlockWorkflowStepSnapshot, BlockWorkflowStepQueue, BlockWorkflowEta, KnownBlockWorkflowQueueSupport, BlockWorkflowOutput, BlockWorkflowAvailableOutput, BlockWorkflowRestrictedOutput, BlockWorkflowPendingOutput, BlockWorkflowBlockedOutput, KnownBlockWorkflowOutputRating, KnownBlockWorkflowRestrictionReason, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileEntry, BlockResourceFileEntryFormat, BlockResourceFileErrorCode, BlockResourceFileMeta, AppWorkflow, AppWorkflowImage, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostRequest, BlockCreatePostResult, BlockCreatePostHostError, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDataImage, BlockTrainingDataUploadResult, BlockRunTrainingHostError, BlockStepQuote, BlockModel3dOutput, BlockRunConfirmedStepHostError, } from './types.js';
92
92
  /**
93
93
  * Host bounds for an inline `customComfy` graph, mirrored from civitai/civitai —
94
94
  * see `WorkflowBodyCustomComfyInline.workflow`.
@@ -307,10 +307,13 @@ export type BlockNavigateScope = 'app' | 'site';
307
307
  export type BlockGenerationSourceImageInfo = BlockSourceImage;
308
308
  /**
309
309
  * What a block sends in `PERSIST_GENERATION_SOURCE`: ONE output of one of the
310
- * calling app's OWN workflows, named by `workflowId` and `imageIndex` (an index
311
- * into that workflow's `images`, as seen via `QUERY_APP_WORKFLOWS` /
312
- * `useAppWorkflows()`). Never a url: the host resolves the output server-side
313
- * from the ownership-verified workflow.
310
+ * calling app's OWN workflows, named by `workflowId` and `imageIndex` — the
311
+ * output's POSITION in that workflow's `outputs` ({@link AppWorkflow.outputs} /
312
+ * {@link BlockWorkflowSnapshot.outputs}), which keeps restricted outputs in place,
313
+ * so an index never moves when a rating lands late. NOT an index into `images` /
314
+ * `imageUrls`. A restricted position is refused (`output N is restricted`). Never a
315
+ * url: the host resolves the output server-side from the ownership-verified
316
+ * workflow.
314
317
  */
315
318
  export interface BlockPersistGenerationSourceRequest {
316
319
  workflowId: string;
@@ -2051,7 +2054,67 @@ export interface BlockWorkflowSnapshot {
2051
2054
  */
2052
2055
  authorFee?: number;
2053
2056
  };
2057
+ /**
2058
+ * The urls of the outputs you may load, in production order. A RESTRICTED
2059
+ * output is NOT here (see {@link outputs}), so with a host that emits
2060
+ * `outputs` this list can be shorter than `outputs`.
2061
+ *
2062
+ * 🔴 NOT FOR INDEXING. `imageIndexes` / `imageIndex` are positions in
2063
+ * {@link outputs}; a position here can point at a different output.
2064
+ */
2054
2065
  imageUrls?: string[];
2066
+ /**
2067
+ * Every available output, in production order, with RESTRICTED, PENDING and
2068
+ * BLOCKED outputs kept IN POSITION — the list to render a result grid from. Each
2069
+ * entry is exactly one of:
2070
+ *
2071
+ * - `{ url, nsfwLevel? }` — load and show it. `nsfwLevel` is the rating
2072
+ * (`'pg'`, `'pg13'`, `'r'`, `'x'`, `'xxx'`); it is absent when there is no
2073
+ * rating to report and none could restrict the output.
2074
+ * - `{ restricted: true, reason }` — **show a locked state, and do not try to
2075
+ * fetch it**: the entry carries no url, and the host withholds it. `reason`:
2076
+ * - `'pool'` — the Buzz that paid for this generation does not include
2077
+ * mature content for this viewer, and the output is above PG-13;
2078
+ * - `'ceiling'` — the output is above the viewer's own browsing level, capped
2079
+ * by your app's maturity ceiling (an SFW app on an SFW host caps every
2080
+ * viewer at PG-13), above a cap the host put on the request, or blocked as
2081
+ * mature content;
2082
+ * - `'unrated'` — no rating will ever arrive for it (a training sample, a 3D
2083
+ * model on a finished step with no rating source) and one could restrict it.
2084
+ * Terminal: it never becomes available. (A video from an engine the
2085
+ * orchestrator does not rate is DELIVERED with its url while unrated, as on
2086
+ * Civitai — its provider moderates it.)
2087
+ * - `{ pending: true }` — not rated yet; no url and no `nsfwLevel`. See
2088
+ * {@link ratingPending}.
2089
+ * - `{ blocked: true }` — blocked by moderation; no url, keeps its slot, never
2090
+ * becomes available.
2091
+ *
2092
+ * See {@link BlockWorkflowOutput}. Not-yet-available outputs are not listed, as in
2093
+ * `imageUrls`.
2094
+ *
2095
+ * 🔴 INDEXES ARE POSITIONS IN THIS LIST. `imageIndexes`
2096
+ * (`publishGenerationOutputs`, `createPostFromApp`) and `imageIndex`
2097
+ * (`persistGenerationSource`) name an output by its position here. A restricted
2098
+ * output keeps its slot, so an index never moves when a rating lands late.
2099
+ * Naming a restricted position is refused with `output N is restricted` — the
2100
+ * host never picks another output. `imageUrls` / {@link AppWorkflow.images} drop
2101
+ * restricted outputs and are NOT index spaces.
2102
+ *
2103
+ * 🔴 REQUIRES A HOST VERSION THAT EMITS IT. Absent on older hosts, and when
2104
+ * the workflow has no available output. In `@civitai/blocks-react`, the inbound
2105
+ * validator REPLACES a malformed entry in place with
2106
+ * `{ restricted: true, reason: 'ceiling' }`, so the reply is kept and no position
2107
+ * moves (`@civitai/sdk` does not validate replies).
2108
+ */
2109
+ outputs?: BlockWorkflowOutput[];
2110
+ /**
2111
+ * `true` while any entry of {@link outputs} is `{ pending: true }`. The workflow
2112
+ * can be in a final status and still gain a rating, so read it again until this is
2113
+ * absent. `watch` in `@civitai/blocks-react` and `@civitai/sdk` keeps polling for up
2114
+ * to two minutes after the final status while it is set, then resolves with the last
2115
+ * snapshot, outputs still pending. 🔴 REQUIRES A HOST VERSION THAT EMITS IT.
2116
+ */
2117
+ ratingPending?: true;
2055
2118
  error?: string;
2056
2119
  /**
2057
2120
  * A stable, machine-readable companion to {@link error}, for a block to
@@ -2550,10 +2613,19 @@ export interface BlockWorkflowStepSnapshot {
2550
2613
  $type: string;
2551
2614
  status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'expired' | 'canceled';
2552
2615
  /**
2553
- * This step's own image urls. Omitted when it has none, and always omitted
2554
- * for a step submitted with `suppressOutput: true`.
2616
+ * This step's own image urls, restricted outputs excluded — not for indexing.
2617
+ * Omitted when it has none, and always omitted for a step submitted with
2618
+ * `suppressOutput: true`.
2555
2619
  */
2556
2620
  imageUrls?: string[];
2621
+ /**
2622
+ * This step's own outputs, restricted ones in position — the same rules as
2623
+ * {@link BlockWorkflowSnapshot.outputs}. Omitted with `imageUrls`'s rule, and
2624
+ * present when every output of the step is restricted.
2625
+ */
2626
+ outputs?: BlockWorkflowOutput[];
2627
+ /** `true` while any of this step's `outputs` is pending — see {@link BlockWorkflowSnapshot.ratingPending}. */
2628
+ ratingPending?: true;
2557
2629
  /**
2558
2630
  * The step's raw orchestrator output, minus its blobs — the same treatment
2559
2631
  * and the same caveats as {@link BlockWorkflowSnapshot.stepOutputs}: its shape
@@ -2704,6 +2776,99 @@ export interface BlockStepQuote {
2704
2776
  /** ISO-8601. The quote cannot be run after this. */
2705
2777
  expiresAt: string;
2706
2778
  }
2779
+ /**
2780
+ * The rating of an output you may load ({@link BlockWorkflowOutput}). An unknown
2781
+ * value is possible (the field is typed as these plus any string, and the SDK's
2782
+ * inbound validator accepts any string); treat one as the most mature rating.
2783
+ */
2784
+ export type KnownBlockWorkflowOutputRating = 'pg' | 'pg13' | 'r' | 'x' | 'xxx';
2785
+ /**
2786
+ * Why an output is restricted ({@link BlockWorkflowRestrictedOutput}). An unknown
2787
+ * value is possible; treat it like `'ceiling'`.
2788
+ *
2789
+ * - `'pool'` — the Buzz that paid does not include mature content for this
2790
+ * viewer, and the output is above PG-13.
2791
+ * - `'ceiling'` — the output is above the viewer's own browsing level, capped by
2792
+ * the app's maturity ceiling, above a cap the host put on the request, or
2793
+ * blocked as mature content.
2794
+ * - `'unrated'` — no rating will ever arrive for the output and one could restrict
2795
+ * it, so the host fails closed. Terminal; does not set `ratingPending`.
2796
+ */
2797
+ export type KnownBlockWorkflowRestrictionReason = 'pool' | 'ceiling' | 'unrated';
2798
+ /** An output you may load: an entry of {@link BlockWorkflowSnapshot.outputs}. */
2799
+ export interface BlockWorkflowAvailableOutput {
2800
+ url: string;
2801
+ /**
2802
+ * Absent when the output has no rating to report: the host HOLDS an unrated output
2803
+ * whose rating could still restrict it ({@link BlockWorkflowPendingOutput}), so an
2804
+ * entry with a url and no rating is one nothing could restrict.
2805
+ */
2806
+ nsfwLevel?: KnownBlockWorkflowOutputRating | (string & {});
2807
+ restricted?: never;
2808
+ reason?: never;
2809
+ pending?: never;
2810
+ blocked?: never;
2811
+ }
2812
+ /**
2813
+ * An output NOT RATED YET whose rating could still restrict it (the viewer's level,
2814
+ * capped by your app's maturity ceiling, is below the top rating, the workflow refused
2815
+ * mature content, or the host capped it).
2816
+ * There is no url until the rating lands. The orchestrator can mark a workflow
2817
+ * succeeded seconds before it rates the last output, so the snapshot carries
2818
+ * {@link BlockWorkflowSnapshot.ratingPending}: poll again — `@civitai/blocks-react`'s
2819
+ * and `@civitai/sdk`'s `watch` do, for up to two minutes after the final status.
2820
+ * Show a "still processing" tile; publishing, posting or persisting this position is
2821
+ * refused with `output N is still being rated, try again shortly`.
2822
+ */
2823
+ export interface BlockWorkflowPendingOutput {
2824
+ pending: true;
2825
+ url?: never;
2826
+ nsfwLevel?: never;
2827
+ restricted?: never;
2828
+ reason?: never;
2829
+ blocked?: never;
2830
+ }
2831
+ /**
2832
+ * An output BLOCKED by moderation. It keeps its position (so no index moves when a
2833
+ * block lands late) and carries no url and no rating; it never becomes available.
2834
+ * Publishing, posting or persisting it is refused. A maturity block reads as a
2835
+ * {@link BlockWorkflowRestrictedOutput} with `reason: 'ceiling'` instead.
2836
+ */
2837
+ export interface BlockWorkflowBlockedOutput {
2838
+ blocked: true;
2839
+ url?: never;
2840
+ nsfwLevel?: never;
2841
+ restricted?: never;
2842
+ reason?: never;
2843
+ pending?: never;
2844
+ }
2845
+ /**
2846
+ * A RESTRICTED output: an entry of {@link BlockWorkflowSnapshot.outputs} that
2847
+ * carries NO url. Show a locked state in its place and do not try to fetch it.
2848
+ */
2849
+ export interface BlockWorkflowRestrictedOutput {
2850
+ restricted: true;
2851
+ reason: KnownBlockWorkflowRestrictionReason | (string & {});
2852
+ url?: never;
2853
+ nsfwLevel?: never;
2854
+ pending?: never;
2855
+ blocked?: never;
2856
+ }
2857
+ /**
2858
+ * One entry of {@link BlockWorkflowSnapshot.outputs} /
2859
+ * {@link BlockWorkflowStepSnapshot.outputs} / {@link AppWorkflow.outputs}.
2860
+ * Narrow on `restricted === true`:
2861
+ *
2862
+ * ```ts
2863
+ * for (const out of snapshot.outputs ?? []) {
2864
+ * if (out.restricted === true) renderLocked(out.reason);
2865
+ * else if (out.pending === true) renderProcessing();
2866
+ * else if (out.blocked === true) renderUnavailable();
2867
+ * else renderImage(out.url);
2868
+ * }
2869
+ * ```
2870
+ */
2871
+ export type BlockWorkflowOutput = BlockWorkflowAvailableOutput | BlockWorkflowRestrictedOutput | BlockWorkflowPendingOutput | BlockWorkflowBlockedOutput;
2707
2872
  /**
2708
2873
  * One entry of {@link BlockWorkflowSnapshot.model3dOutputs} /
2709
2874
  * {@link AppWorkflow.model3dOutputs} — the label for one 3D model url.
@@ -3881,7 +4046,9 @@ export interface AppWorkflowImage {
3881
4046
  *
3882
4047
  * status: the block-contract status — the orchestrator's
3883
4048
  * `unassigned`/`preparing`/`scheduled` all collapse to `pending`.
3884
- * images: only `available` blobs with a non-null url (see {@link AppWorkflowImage}).
4049
+ * images: only `available` blobs with a non-null url (see {@link AppWorkflowImage}),
4050
+ * RESTRICTED outputs excluded. A convenience view, NOT for indexing:
4051
+ * `imageIndexes` / `imageIndex` are positions in `outputs`.
3885
4052
  * cost: the workflow's realized/estimated buzz total, or `null` when absent.
3886
4053
  * createdAt: ISO-8601 string.
3887
4054
  */
@@ -3921,6 +4088,17 @@ export interface AppWorkflow {
3921
4088
  * there are none (and on hosts that predate it).
3922
4089
  */
3923
4090
  model3dOutputs?: BlockModel3dOutput[];
4091
+ /**
4092
+ * Every available output, restricted ones IN POSITION — same value and rules
4093
+ * as {@link BlockWorkflowSnapshot.outputs}. THIS is the index space of
4094
+ * `imageIndexes` / `imageIndex`; a restricted output is not in
4095
+ * {@link AppWorkflow.images}, which is not.
4096
+ *
4097
+ * 🔴 REQUIRES A HOST VERSION THAT EMITS IT. Absent on older hosts.
4098
+ */
4099
+ outputs?: BlockWorkflowOutput[];
4100
+ /** Same value and rule as {@link BlockWorkflowSnapshot.ratingPending}. */
4101
+ ratingPending?: true;
3924
4102
  }
3925
4103
  /**
3926
4104
  * Per-viewer gated projection of ONE image returned by `GET_IMAGES_BY_IDS`
package/dist/index.d.ts CHANGED
@@ -25,11 +25,11 @@
25
25
  *
26
26
  * - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
27
27
  * (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
28
- * 229 symbols and that side effect into the root would make every OAuth app
28
+ * 236 symbols and that side effect into the root would make every OAuth app
29
29
  * that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
30
30
  * Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
31
31
  * audiences; see this package's README.
32
- * 🔴 That 229 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 236 is ASSERTED, not merely quoted — by
33
33
  * `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
34
34
  * `surface.get('./blocks').size`. It said 119 here against a real 125 until
35
35
  * 2026-10-04, because the existing checks pin the root as an exact union and
package/dist/index.js CHANGED
@@ -25,11 +25,11 @@
25
25
  *
26
26
  * - **`./blocks`** — importing it RUNS `./safe-storage` for its side effect
27
27
  * (repairing `localStorage`/`sessionStorage` at an opaque origin). Folding
28
- * 229 symbols and that side effect into the root would make every OAuth app
28
+ * 236 symbols and that side effect into the root would make every OAuth app
29
29
  * that writes `import { exchangeCode } from '@civitai/app-sdk'` pay for the
30
30
  * Civitai-Apps contract it does not use. Blocks and OAuth apps are disjoint
31
31
  * audiences; see this package's README.
32
- * 🔴 That 229 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 236 is ASSERTED, not merely quoted — by
33
33
  * `packages/civitai-app-sdk/test/export-surface.test.ts`, which pins
34
34
  * `surface.get('./blocks').size`. It said 119 here against a real 125 until
35
35
  * 2026-10-04, because the existing checks pin the root as an exact union and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civitai/app-sdk",
3
- "version": "0.88.0",
3
+ "version": "0.89.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",