@civitai/app-sdk 0.64.1 → 0.65.1

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.
@@ -109,7 +109,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
109
109
  * in `types.ts` for which of the two it uses and why.
110
110
  */
111
111
  export { isSignedIn } from './types.js';
112
- export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, 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, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, 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, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDatasetResult, BlockTrainingRejectionReason, BlockPrepareTrainingDatasetHostError, BlockRunTrainingHostError, } from './types.js';
112
+ export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, 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, BlockEstimateBatchAggregate, BlockModelSubstitution, ModelSubstitutionReason, KnownBlockWorkflowErrorCode, BlockStepToolCall, BlockTrainedEpoch, BlockPublishedModel, 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, WorkflowBodyTraining, AiToolkitTrainingParams, AiToolkitTrainingParamsBase, AiToolkitPlainEcosystem, AiToolkitLrScheduler, AiToolkitOptimizerType, BlockTrainingQuote, BlockTrainingDatasetItem, BlockTrainingDatasetResult, BlockTrainingRejectionReason, BlockPrepareTrainingDatasetHostError, BlockRunTrainingHostError, } from './types.js';
113
113
  /**
114
114
  * Host bounds for the App Blocks `kind: 'training'` flow, mirrored from
115
115
  * civitai/civitai's zod — see `WorkflowBodyTraining`.
@@ -1492,6 +1492,35 @@ export interface BlockWorkflowSnapshot {
1492
1492
  };
1493
1493
  imageUrls?: string[];
1494
1494
  error?: string;
1495
+ /**
1496
+ * A stable, machine-readable companion to {@link error}, for a block to
1497
+ * branch on instead of matching the prose. OPTIONAL: set only on the refusals
1498
+ * that define a code, absent everywhere else (and on every reply from a host
1499
+ * that predates the field).
1500
+ *
1501
+ * WHERE IT APPEARS today: the refusal for a pass-through `step` body
1502
+ * ({@link WorkflowBodyPassThroughStep}) whose `$type` is a training type
1503
+ * (`'training'` or `'imageResourceTraining'`) when the host could not get a
1504
+ * price quote for it. That refusal is `{ workflowId: 'failed', status:
1505
+ * 'failed', error, errorCode }` with no `cost`, and it is the reply to
1506
+ * `estimate()` (which rejects with `WorkflowEstimateError`), to `submit()`
1507
+ * (which rejects with `WorkflowSubmitError`, before anything is reserved or
1508
+ * charged), and to that body's cell in a batch estimate. Read it from the
1509
+ * error's `.snapshot.errorCode`. The `kind: 'training'` arm does NOT set it.
1510
+ *
1511
+ * The values the host sends today ({@link KnownBlockWorkflowErrorCode}):
1512
+ * - `'training-quote-rejected'` — the orchestrator refused the request
1513
+ * itself; resending the same body will not help. `error` then reads
1514
+ * `Training could not be priced: <reason>` when the reason is safe to show.
1515
+ * - `'training-quote-unavailable'` — no usable answer (an outage, a timeout,
1516
+ * a rate limit, insufficient funds, …). Retrying later may succeed.
1517
+ * - `'training-quote-unpriced'` — the orchestrator answered without a price.
1518
+ *
1519
+ * 🔴 AN UNKNOWN VALUE IS POSSIBLE: the host may add codes, and the SDK's
1520
+ * inbound validator accepts any string here. Handle an unrecognised code as a
1521
+ * generic failure and show `error`.
1522
+ */
1523
+ errorCode?: KnownBlockWorkflowErrorCode | (string & {});
1495
1524
  /**
1496
1525
  * The Buzz pool that was the PRIMARY FUNDER of this generation — i.e. the
1497
1526
  * account with the LARGEST debit, which the host stamps onto the workflow
@@ -1743,6 +1772,16 @@ export interface BlockTrainingQuote {
1743
1772
  * generic substitution rather than assuming the list is closed.
1744
1773
  */
1745
1774
  export type ModelSubstitutionReason = 'wrong-workflow' | 'unrecognized' | 'gated';
1775
+ /**
1776
+ * The {@link BlockWorkflowSnapshot.errorCode} values the host sends today — see
1777
+ * that field for what each means and which replies carry it.
1778
+ *
1779
+ * NOT a closed list: the field itself is typed `KnownBlockWorkflowErrorCode |
1780
+ * (string & {})` (the union is an autocomplete nudge), the host may add codes,
1781
+ * and the SDK's inbound validator accepts any string. Handle an unrecognised
1782
+ * code as a generic failure.
1783
+ */
1784
+ export type KnownBlockWorkflowErrorCode = 'training-quote-rejected' | 'training-quote-unavailable' | 'training-quote-unpriced';
1746
1785
  /** One entry of {@link BlockWorkflowSnapshot.modelSubstitutions}. */
1747
1786
  export interface BlockModelSubstitution {
1748
1787
  /** The checkpoint version id the block asked for. */
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
- * 159 symbols and that side effect into the root would make every OAuth app
28
+ * 160 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 159 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 160 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
- * 159 symbols and that side effect into the root would make every OAuth app
28
+ * 160 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 159 is ASSERTED, not merely quoted — by
32
+ * 🔴 That 160 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.64.1",
3
+ "version": "0.65.1",
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",