@civitai/app-sdk 0.87.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.
@@ -305,6 +305,41 @@ export type BlockNavigateScope = 'app' | 'site';
305
305
  * lockstep.
306
306
  */
307
307
  export type BlockGenerationSourceImageInfo = BlockSourceImage;
308
+ /**
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` — 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.
317
+ */
318
+ export interface BlockPersistGenerationSourceRequest {
319
+ workflowId: string;
320
+ imageIndex: number;
321
+ }
322
+ /**
323
+ * What the host returns from `PERSIST_GENERATION_SOURCE`
324
+ * (`GENERATION_SOURCE_PERSISTED.result`): the app's own output, saved as a
325
+ * PRIVATE, scanned generation source.
326
+ *
327
+ * `url` / `width` / `height` are a {@link BlockGenerationSourceImageInfo}, so
328
+ * the value (or that subset of it) goes straight into a `sourceImages` entry,
329
+ * or anywhere else a generation source is accepted.
330
+ *
331
+ * - The image is private to the viewer and is NOT on the app's shared grid.
332
+ * The host shows no confirm.
333
+ * - `imageId` is the persisted `Image` row id.
334
+ * - `ready` says whether the scan finished. The host waits up to about 30 s for
335
+ * it. `ready: false` means the scan is still running: a generation that uses
336
+ * the source is refused with the `source-scan-pending` error code until it
337
+ * finishes, so retry that generation later.
338
+ */
339
+ export interface BlockPersistedGenerationSource extends BlockGenerationSourceImageInfo {
340
+ imageId: number;
341
+ ready: boolean;
342
+ }
308
343
  /**
309
344
  * One image an `OPEN_IMAGE_UPLOAD { purpose: 'trainingData' }` uploaded — an
310
345
  * element of {@link BlockTrainingDataUploadResult.images}. Mirrors the host's
@@ -452,6 +487,28 @@ export interface BlockMediaUploadInfo {
452
487
  /** Duration in milliseconds, for `'video'` / `'audio'` when known. Never set for `'image'`. */
453
488
  durationMs?: number;
454
489
  }
490
+ /**
491
+ * One item's answer in a batch media upload (`MEDIA_UPLOAD_BATCH_RESULT.results`,
492
+ * via `useMediaUpload().uploadBatch`). The host answers EXACTLY ONE entry per
493
+ * item, in item order, and `index` is that item's position in the request.
494
+ *
495
+ * Exactly one of `selected` and `error` is set:
496
+ * - `selected`: the item was uploaded, the same {@link BlockMediaUploadInfo}
497
+ * `MEDIA_UPLOAD_RESULT.selected` carries;
498
+ * - `error`: the item was refused (the same per-file strings as a single
499
+ * bytes upload: too large, wrong type, `mimeType` mismatch, invalid) or its
500
+ * upload failed (`this image was refused by the upload service`,
501
+ * `media upload failed — please try again`, …). The other items are not
502
+ * affected.
503
+ */
504
+ export interface BlockMediaUploadBatchItemResult {
505
+ /** The item's position in the request's `items`. */
506
+ index: number;
507
+ /** The uploaded file. Never set beside `error`. */
508
+ selected?: BlockMediaUploadInfo;
509
+ /** Why this item was not uploaded. Never set beside `selected`. */
510
+ error?: string;
511
+ }
455
512
  /**
456
513
  * One of the model version's curated preview images, with the standard
457
514
  * gen params extracted from its source meta. Block UIs use these to let
@@ -920,9 +977,8 @@ export type WorkflowBodyTextToImage = {
920
977
  /**
921
978
  * Optional shared-storage key of the published content this generation runs on
922
979
  * behalf of. The server resolves it to the content's author for attribution
923
- * (see the G5 civitai PR). Opaque string — the block passes back the `key` it
924
- * got from `useSharedStorage()` for the content being generated against; omit
925
- * when not applicable.
980
+ * (see the G5 civitai PR). Opaque string — the block passes back the `key` of
981
+ * the shared entry the generation runs against; omit when not applicable.
926
982
  */
927
983
  sharedContentKey?: string;
928
984
  /**
@@ -1292,6 +1348,27 @@ export type WorkflowBodyStep = {
1292
1348
  * package would drift against it silently.
1293
1349
  */
1294
1350
  params: Record<string, unknown>;
1351
+ /**
1352
+ * Optional Buzz pool to try FIRST for this job. The host puts it at the front of
1353
+ * the pools this app may spend and keeps the others as fallback, so a job the
1354
+ * picked pool cannot cover alone still runs (an SFW app may spend `blue` and
1355
+ * `green`; a mature app `blue` and `yellow`). Omit it for the host's default
1356
+ * order, blue first.
1357
+ *
1358
+ * A pick outside the app's allowed pools is REFUSED, with an error naming the
1359
+ * pool, on the estimate and the submit alike, before anything is priced or
1360
+ * reserved. Estimate with the same pick you submit with: the estimate prices
1361
+ * that order.
1362
+ *
1363
+ * 🔴 It does NOT guarantee an unrestricted output. When the picked pool runs
1364
+ * out the fallback pays, and a fallback to `blue` can still leave a mature
1365
+ * output restricted.
1366
+ *
1367
+ * Top-level, NOT inside `params` — a pool is not a step parameter, and the
1368
+ * step's own `.strict()` param schema would refuse it there. A host predating
1369
+ * this field refuses it as an unknown key.
1370
+ */
1371
+ accountType?: BuzzAccountType;
1295
1372
  };
1296
1373
  /**
1297
1374
  * The PASS-THROUGH ARM of the `kind: 'step'` member — the block names an
@@ -1455,6 +1532,28 @@ export type WorkflowBodyPassThroughStep = {
1455
1532
  * (`quoteId` itself is excluded from that comparison).
1456
1533
  */
1457
1534
  quoteId?: string;
1535
+ /**
1536
+ * Optional Buzz pool to try FIRST for this job. The host puts it at the front of
1537
+ * the pools this app may spend and keeps the others as fallback, so a job the
1538
+ * picked pool cannot cover alone still runs (an SFW app may spend `blue` and
1539
+ * `green`; a mature app `blue` and `yellow`). Omit it for the host's default
1540
+ * order, blue first.
1541
+ *
1542
+ * A pick outside the app's allowed pools is REFUSED, with an error naming the
1543
+ * pool, on the estimate and the submit alike, before anything is priced or
1544
+ * reserved. Estimate with the same pick you submit with: the estimate prices
1545
+ * that order.
1546
+ *
1547
+ * 🔴 It does NOT guarantee an unrestricted output. When the picked pool runs
1548
+ * out the fallback pays, and a fallback to `blue` can still leave a mature
1549
+ * output restricted.
1550
+ *
1551
+ * Never forwarded into {@link input}. On a CONFIRMED run it is part of the
1552
+ * body the quote is bound to: submit with the pool you estimated with, or the
1553
+ * run is refused as a changed body. A host predating this field refuses it as
1554
+ * an unknown key.
1555
+ */
1556
+ accountType?: BuzzAccountType;
1458
1557
  };
1459
1558
  /**
1460
1559
  * Ceiling on what ONE viewer-confirmed pass-through job may cost, in Buzz. Host
@@ -1667,6 +1766,28 @@ export type WorkflowBodyWorkflow = {
1667
1766
  * place to put a prompt or a seed that several steps share.
1668
1767
  */
1669
1768
  arguments?: Record<string, unknown>;
1769
+ /**
1770
+ * Optional Buzz pool to try FIRST for this job. The host puts it at the front of
1771
+ * the pools this app may spend and keeps the others as fallback, so a job the
1772
+ * picked pool cannot cover alone still runs (an SFW app may spend `blue` and
1773
+ * `green`; a mature app `blue` and `yellow`). Omit it for the host's default
1774
+ * order, blue first.
1775
+ *
1776
+ * A pick outside the app's allowed pools is REFUSED, with an error naming the
1777
+ * pool, on the estimate and the submit alike, before anything is priced or
1778
+ * reserved. Estimate with the same pick you submit with: the estimate prices
1779
+ * that order.
1780
+ *
1781
+ * 🔴 It does NOT guarantee an unrestricted output. When the picked pool runs
1782
+ * out the fallback pays, and a fallback to `blue` can still leave a mature
1783
+ * output restricted.
1784
+ *
1785
+ * ONE pick for the whole workflow, not per step: the orchestrator takes a
1786
+ * single list of pools per workflow, so a step cannot name its own (a step
1787
+ * carrying `accountType` is refused). A host predating this field refuses it
1788
+ * as an unknown key.
1789
+ */
1790
+ accountType?: BuzzAccountType;
1670
1791
  };
1671
1792
  /** Ceiling on what ONE confirmed `kind: 'training'` run may cost, in Buzz. Host constant `BLOCK_TRAINING_MAX_BUZZ_PER_RUN`. */
1672
1793
  export declare const BLOCK_TRAINING_MAX_BUZZ_PER_RUN = 5000;
@@ -1933,7 +2054,67 @@ export interface BlockWorkflowSnapshot {
1933
2054
  */
1934
2055
  authorFee?: number;
1935
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
+ */
1936
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;
1937
2118
  error?: string;
1938
2119
  /**
1939
2120
  * A stable, machine-readable companion to {@link error}, for a block to
@@ -2032,9 +2213,10 @@ export interface BlockWorkflowSnapshot {
2032
2213
  * error, errorCode }` with NO `cost`. A host that predates these codes
2033
2214
  * resolves the estimate instead, priced at the step's declared estimate, so
2034
2215
  * there a registered-step estimate may not be a quote.
2035
- * - `'source-scan-pending'` — a `kind: 'step'` or `kind: 'workflow'` input,
2036
- * or an inline `customComfy` graph, names an image the viewer uploaded
2037
- * whose scan has not finished. `error` reads `that image is still being
2216
+ * - `'source-scan-pending'` — a `kind: 'textToImage'` source image, a
2217
+ * `kind: 'step'` or `kind: 'workflow'` input, or an inline `customComfy`
2218
+ * graph, names an image the viewer uploaded (or a source kept with
2219
+ * `PERSIST_GENERATION_SOURCE`) whose scan has not finished. `error` reads `that image is still being
2038
2220
  * scanned — wait for it to finish before using it`. Estimate and submit
2039
2221
  * alike, before anything is reserved. Retry the same body once the
2040
2222
  * upload's scan verdict is `'scanned'`.
@@ -2355,6 +2537,73 @@ export interface BlockWorkflowSnapshot {
2355
2537
  * an estimate (which creates no workflow) and on a host that predates it.
2356
2538
  */
2357
2539
  steps?: BlockWorkflowStepSnapshot[];
2540
+ /**
2541
+ * Where the run is right now: a summary of the ONE step that is queued or
2542
+ * running, for a progress bar or an "N ahead, starts ~HH:MM" line. The host
2543
+ * reads it off ALL of the workflow's orchestrator steps, so a single-step kind
2544
+ * (`textToImage`, `step`, `customComfy`, `training`) has one too, not only a
2545
+ * `kind: 'workflow'` run. It picks the first step with a queue position, else
2546
+ * the first `processing` step. See {@link BlockWorkflowEta} for each field.
2547
+ *
2548
+ * - **An object** while the workflow is not terminal and a step is queued or
2549
+ * running.
2550
+ * - **ABSENT OR `null` — READ THEM THE SAME.** The host OMITS the field when
2551
+ * it has nothing to report rather than sending `null`. That covers:
2552
+ * - a terminal workflow (`succeeded`, `failed`, `expired`, `canceled`);
2553
+ * - a workflow with no step queued or running;
2554
+ * - a host that predates the field;
2555
+ * - a rate-limited poll the host could not serve. That reply carries
2556
+ * {@link BlockWorkflowSnapshot.throttled}, and `watch` drops it rather
2557
+ * than passing it to `onUpdate`, so an app on `watch` never sees its
2558
+ * missing `eta`.
2559
+ *
2560
+ * 🔴 THE QUEUE POSITION DOES NOT MOVE ON ITS OWN BETWEEN STATUS CHANGES. A held
2561
+ * poll (`watch`) returns early when the workflow's status, a step's progress or
2562
+ * a job event changes, NOT when the queue ahead of a waiting step drains. So
2563
+ * while a step is queued, `queuedAhead` and its estimates refresh at most once
2564
+ * per held poll (about every 15 s). Once the step runs, `progress` moves
2565
+ * promptly.
2566
+ *
2567
+ * Every value in it is an ESTIMATE from the orchestrator's scheduler. Do not
2568
+ * gate on it; `status` is still the only thing that says the run is done.
2569
+ *
2570
+ * ```tsx
2571
+ * await watch(workflowId, {
2572
+ * onUpdate: (s) => {
2573
+ * const eta = s.eta;
2574
+ * if (!eta) return; // absent: keep the last line (watch resolves when terminal)
2575
+ * if (eta.progress !== null) return setBar(eta.progress); // running
2576
+ * const at = eta.startsAt ? new Date(eta.startsAt) : null;
2577
+ * setLine(
2578
+ * `${eta.queuedAhead ?? '?'} ahead` +
2579
+ * (at ? `, starts ~${at.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : ''),
2580
+ * );
2581
+ * },
2582
+ * });
2583
+ * ```
2584
+ *
2585
+ * 🔴 A MALFORMED VALUE IS DROPPED, NOT FATAL. `@civitai/blocks-react` removes
2586
+ * an `eta` that does not have this shape (and likewise a malformed `queue`,
2587
+ * `progress`, `startedAt` or `completedAt` on a step) and delivers the rest of
2588
+ * the snapshot, so a bad estimate never costs an app its status or outputs.
2589
+ */
2590
+ eta?: BlockWorkflowEta | null;
2591
+ /**
2592
+ * A poll the host could not serve; NOT A REAL UPDATE. The host answers a poll
2593
+ * it refused (rate-limited) with `{ workflowId, status: 'processing',
2594
+ * throttled: true }` without reading the workflow, so its `status` is a
2595
+ * placeholder and everything else is missing. A real snapshot never carries
2596
+ * the field.
2597
+ *
2598
+ * `useBuzzWorkflow().watch` already handles it: it does not pass such a reply
2599
+ * to `onUpdate`, keeps the previous real snapshot as its result, and polls
2600
+ * again. `poll()` returns it as is (so check the flag) but does not replace
2601
+ * the hook's `result` with it. On a cancel it means the cancel was NOT
2602
+ * issued: `cancel()` rejects with `WorkflowCancelNotIssuedError`, and the
2603
+ * caller retries. Absent on a host that predates the marker,
2604
+ * whose throttled reply is `{ workflowId, status: 'processing' }`.
2605
+ */
2606
+ throttled?: true;
2358
2607
  }
2359
2608
  /** One entry of {@link BlockWorkflowSnapshot.steps}. */
2360
2609
  export interface BlockWorkflowStepSnapshot {
@@ -2364,10 +2613,19 @@ export interface BlockWorkflowStepSnapshot {
2364
2613
  $type: string;
2365
2614
  status: 'pending' | 'processing' | 'succeeded' | 'failed' | 'expired' | 'canceled';
2366
2615
  /**
2367
- * This step's own image urls. Omitted when it has none, and always omitted
2368
- * 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`.
2369
2619
  */
2370
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;
2371
2629
  /**
2372
2630
  * The step's raw orchestrator output, minus its blobs — the same treatment
2373
2631
  * and the same caveats as {@link BlockWorkflowSnapshot.stepOutputs}: its shape
@@ -2376,6 +2634,101 @@ export interface BlockWorkflowStepSnapshot {
2376
2634
  output?: unknown;
2377
2635
  /** Why this step failed. Diagnostic text; do not render it verbatim. */
2378
2636
  error?: string;
2637
+ /**
2638
+ * The step's place in the orchestrator's queue. PRESENT ONLY WHILE THE STEP
2639
+ * IS QUEUED (waiting for a worker). Absent (read it as `null`) once the step
2640
+ * has started, once it or the workflow is terminal, and on a host that
2641
+ * predates the field. Its position refreshes at most once per held poll —
2642
+ * see {@link BlockWorkflowSnapshot.eta}. See {@link BlockWorkflowStepQueue}.
2643
+ */
2644
+ queue?: BlockWorkflowStepQueue | null;
2645
+ /**
2646
+ * How much of this step is done, as a FRACTION from `0` to `1` (not a
2647
+ * percentage). Absent or `null` (the same thing) when the orchestrator
2648
+ * reports none, once the step or the workflow is terminal, on a host that
2649
+ * predates the field, and for every step type whose orchestrator value is not
2650
+ * a fraction of the whole step. The host reports it only for image and video
2651
+ * generation (`textToImage`, `imageGen`, `videoGen`); multi-phase types such
2652
+ * as training restart at 0 in each phase, so they get none.
2653
+ */
2654
+ progress?: number | null;
2655
+ /**
2656
+ * When the step started running, as an ISO-8601 string. Absent or `null`
2657
+ * (the same thing) until it has started, and on a host that predates the
2658
+ * field.
2659
+ */
2660
+ startedAt?: string | null;
2661
+ /**
2662
+ * When the step finished, as an ISO-8601 string. Absent or `null` (the same
2663
+ * thing) until it is terminal, and on a host that predates the field.
2664
+ */
2665
+ completedAt?: string | null;
2666
+ }
2667
+ /**
2668
+ * The values the host sends today in {@link BlockWorkflowStepQueue.support}
2669
+ * and {@link BlockWorkflowEta.support}: whether the orchestrator can estimate
2670
+ * this step's queue at all.
2671
+ *
2672
+ * - `'available'` — there is capacity for the step and the estimates are the
2673
+ * scheduler's own.
2674
+ * - `'unavailable'` — NO CAPACITY RIGHT NOW: no worker that can run the step
2675
+ * is available, so the step waits until one is. The estimates, when given,
2676
+ * are least reliable here.
2677
+ * - `'unsupported'` — the orchestrator does not estimate queues for this kind
2678
+ * of step; the position and times are `null`.
2679
+ *
2680
+ * 🔴 AN UNKNOWN VALUE IS POSSIBLE: the field is typed as these plus any string,
2681
+ * and the SDK's inbound validator accepts any string. Treat an unrecognised
2682
+ * value like `'unsupported'`.
2683
+ */
2684
+ export type KnownBlockWorkflowQueueSupport = 'unsupported' | 'unavailable' | 'available';
2685
+ /**
2686
+ * One step's place in the orchestrator's queue — {@link
2687
+ * BlockWorkflowStepSnapshot.queue}, present only while the step is queued.
2688
+ *
2689
+ * Every time is an ISO-8601 string and an ESTIMATE, and any of them may be
2690
+ * `null` when the orchestrator has none.
2691
+ */
2692
+ export interface BlockWorkflowStepQueue {
2693
+ /** How many jobs are ahead of this step in the queue (a whole number ≥ 0), or `null` when unknown. */
2694
+ precedingJobs: number | null;
2695
+ /** When the step is expected to start running. An estimate. */
2696
+ estimatedStartAt: string | null;
2697
+ /** When the step is expected to finish. An estimate. */
2698
+ estimatedCompleteAt: string | null;
2699
+ /** Whether these estimates exist at all — see {@link KnownBlockWorkflowQueueSupport}. */
2700
+ support: KnownBlockWorkflowQueueSupport | (string & {});
2701
+ }
2702
+ /**
2703
+ * {@link BlockWorkflowSnapshot.eta}: a summary of the step that is queued or
2704
+ * running now (the first queued step, else the first running step).
2705
+ *
2706
+ * WHILE QUEUED, `queuedAhead`, `startsAt`, `completesAt` and `support` come
2707
+ * from the step's queue and `progress` is `null`. WHILE RUNNING, those four
2708
+ * are `null` and `progress` moves. Every time is an ISO-8601 string and an
2709
+ * ESTIMATE. All six keys are always present when the object is.
2710
+ */
2711
+ export interface BlockWorkflowEta {
2712
+ /** The {@link BlockWorkflowStepSnapshot.name} of the step this summarises. */
2713
+ stepName: string;
2714
+ /** How many jobs are ahead of that step in the queue (a whole number ≥ 0), or `null` when unknown. */
2715
+ queuedAhead: number | null;
2716
+ /** When the step is expected to start. An estimate; `null` once it is running or when unknown. */
2717
+ startsAt: string | null;
2718
+ /** When the step is expected to finish. An estimate; `null` once it is running or when unknown. */
2719
+ completesAt: string | null;
2720
+ /**
2721
+ * How much of the step is done, as a FRACTION from `0` to `1`. `null` while
2722
+ * it is queued, when the orchestrator reports none, and for step types other
2723
+ * than image and video generation (see
2724
+ * {@link BlockWorkflowStepSnapshot.progress}).
2725
+ */
2726
+ progress: number | null;
2727
+ /**
2728
+ * The step's {@link BlockWorkflowStepQueue.support}, or `null` when the host
2729
+ * has none. `'unavailable'` means no capacity right now.
2730
+ */
2731
+ support: KnownBlockWorkflowQueueSupport | (string & {}) | null;
2379
2732
  }
2380
2733
  /**
2381
2734
  * The run total a BATCH estimate reports beside its per-cell snapshots
@@ -2423,6 +2776,99 @@ export interface BlockStepQuote {
2423
2776
  /** ISO-8601. The quote cannot be run after this. */
2424
2777
  expiresAt: string;
2425
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;
2426
2872
  /**
2427
2873
  * One entry of {@link BlockWorkflowSnapshot.model3dOutputs} /
2428
2874
  * {@link AppWorkflow.model3dOutputs} — the label for one 3D model url.
@@ -3360,7 +3806,7 @@ export type BlockManifest = BlockManifestV1;
3360
3806
  * DATE WIRE CAVEAT: `date` is documented as ISO-8601 to match the SDK's
3361
3807
  * wire convention, BUT the host currently forwards the raw tRPC `result` over a
3362
3808
  * structured-clone `postMessage` (it does NOT `.toISOString()`-map it the way
3363
- * the `SHARED_LIST` bridge does), so at runtime `date` arrives as a `Date`
3809
+ * the removed `SHARED_LIST` bridge did), so at runtime `date` arrives as a `Date`
3364
3810
  * INSTANCE. The block-side guard + `useBuzzTransactions` hook tolerate BOTH a
3365
3811
  * `Date` and an ISO string (rehydrating to `Date`), so either representation
3366
3812
  * round-trips correctly. See `civitai-blocks-react`'s `isValidBuzzTransactionsResult`.
@@ -3600,7 +4046,9 @@ export interface AppWorkflowImage {
3600
4046
  *
3601
4047
  * status: the block-contract status — the orchestrator's
3602
4048
  * `unassigned`/`preparing`/`scheduled` all collapse to `pending`.
3603
- * 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`.
3604
4052
  * cost: the workflow's realized/estimated buzz total, or `null` when absent.
3605
4053
  * createdAt: ISO-8601 string.
3606
4054
  */
@@ -3640,6 +4088,17 @@ export interface AppWorkflow {
3640
4088
  * there are none (and on hosts that predate it).
3641
4089
  */
3642
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;
3643
4102
  }
3644
4103
  /**
3645
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
- * 228 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 228 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
- * 228 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 228 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.87.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",