@civitai/app-sdk 0.90.1 → 0.92.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 +17 -5
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messages.d.ts +21 -0
- package/dist/blocks/types.d.ts +26 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/orchestrator/index.d.ts +15 -3
- package/dist/orchestrator/index.js +23 -6
- package/dist/orchestrator/steps.d.ts +20 -9
- package/dist/orchestrator/steps.js +15 -5
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ pnpm add @civitai/app-sdk
|
|
|
28
28
|
| `oauth/*` — `generatePkce`, `buildAuthorizeUrl`, `exchangeCode`, `refreshToken`, `revokeToken`, `fetchMe` | The Civitai OAuth flow (Authorization Code + PKCE S256), as a set of stateless functions you call from your server-side handlers. |
|
|
29
29
|
| `scopes/*` — `TokenScope`, `TokenScopePresets`, `bitmaskFromScopes`, `scopesFromBitmask`, `hasScope`, `getScopeLabel` | Civitai scopes are stored as bitmasks. These helpers let you compose scope sets from named flags rather than magic numbers. |
|
|
30
30
|
| `cookies/*` — `sealCookie`, `unsealCookie`, `buildSetCookieHeader`, `readCookie` | AES-256-GCM authenticated cookie crypto. Use to seal a session blob (refresh token, expiry, scope) into an `httpOnly` cookie with zero external session store. |
|
|
31
|
-
| `orchestrator/*` — `createOrchestratorClient`, `estimateWorkflow`, `submitWorkflow`, `getWorkflow`, `pollWorkflow`, `buildTextToImageBody`, `buildImageGenBody`, `buildWorkflowBody`, `WORKFLOW_STEP_TYPES`, `IMAGE_GEN_ENGINES`, `isTerminal`, `extractImageUrls`, `OrchestratorError`, `WorkflowSnapshot`, `GenerateInput`, `ImageGenInput`, `WorkflowStepType`, `ImageGenEngine`, `DEFAULT_MODEL_AIR` | Orchestrator workflow glue — types, body builders, raw HTTP, and long-poll helper. Client + server safe (fetch-only). `estimateWorkflow` calls `?whatif=true` to preview Buzz cost without spending. `pollWorkflow` long-polls to terminal status. `WORKFLOW_STEP_TYPES` is the catalog of every step `$type` the orchestrator accepts. |
|
|
32
|
-
| `orchestrator/steps` — `WorkflowStepTemplates`, `WorkflowStepTemplateFor`, `WorkflowStepInputFor`, `AnyWorkflowStepTemplate`, `TypedWorkflowTemplate` | **Type-only** subpath (0 runtime bytes) keying the orchestrator's generated workflow-step shapes from `@civitai/client` by wire `$type`, so apps compose real step bodies against types
|
|
31
|
+
| `orchestrator/*` — `createOrchestratorClient`, `estimateWorkflow`, `submitWorkflow`, `getWorkflow`, `pollWorkflow`, `buildTextToImageBody`, `buildImageGenBody`, `buildWorkflowBody`, `WORKFLOW_STEP_TYPES`, `IMAGE_GEN_ENGINES`, `isTerminal`, `extractImageUrls`, `OrchestratorError`, `OrchestratorLogger`, `WorkflowSnapshot`, `GenerateInput`, `ImageGenInput`, `WorkflowStepType`, `ImageGenEngine`, `DEFAULT_MODEL_AIR` | Orchestrator workflow glue — types, body builders, raw HTTP, and long-poll helper. Client + server safe (fetch-only). `estimateWorkflow` calls `?whatif=true` to preview Buzz cost without spending. `pollWorkflow` long-polls to terminal status. `WORKFLOW_STEP_TYPES` is the catalog of every step `$type` the orchestrator accepts. |
|
|
32
|
+
| `orchestrator/steps` — `WorkflowStepTemplates`, `WorkflowStepTemplateFor`, `WorkflowStepInputFor`, `AnyWorkflowStepTemplate`, `TypedWorkflowTemplate` | **Type-only** subpath (0 runtime bytes) keying the orchestrator's generated workflow-step shapes from `@civitai/client` by wire `$type`, so apps compose real step bodies against generated types instead of hand-maintained copies. Requires the optional peer `@civitai/client@beta`, which is frozen (renamed upstream; see "Installing the peer"). Type surface only — it grants no submit permission; see "Typed step shapes" below. |
|
|
33
33
|
| `blocks/*` — `BlockManifestError`, `BLOCK_SCOPES`, `BLOCK_SCOPE_PATTERN`, `isMessage`, types (`BlockManifestV1`, `BlockContext`, `BlockToken`, `BlockSettings`, `ViewerInfo`, `ThemeInfo`, `BlockWorkflowSnapshot`, `BlockInitPayload`, `ParentToBlockMessage`, `BlockToParentMessage`, …) | Framework-agnostic contract for [Civitai Apps](https://github.com/civitai/civitai-app-starters/blob/main/docs/build-your-first-app-block.md). Ships a byte-identical copy of the server-published canonical JSON Schema (draft 2020-12, https://civitai.com/schemas/app-block/v1.json) at the `./schemas/app-block/v1.json` subpath for offline validation; a CI drift-check keeps it in sync. Runtime-agnostic and **zero runtime dependencies** — no React, no DOM types, nothing in your install graph. Hooks and the iframe transport live in a separate package. |
|
|
34
34
|
| `manifest/*` — `defineBlock`, `SCHEMA_DIVERGENCES`, `KNOWN_GAPS` (**Node only**) | Build-time manifest validation. `defineBlock(config)` compiles the vendored canonical schema with [Ajv](https://ajv.js.org) and validates a `BlockManifestV1` against it, so authoring mistakes surface in `pnpm dev` instead of at `civitai app validate`/submit. It is **derived from the schema, not a hand-written mirror of it** — that mirror is what produced [#330](https://github.com/civitai/civitai-app-starters/issues/330). Needs `node:fs` and the optional peer `ajv`, which is why it is not on the browser-facing `./blocks` surface. |
|
|
35
35
|
| `vite/*` — `blockManifestPlugin` (**Node only**) | A Vite plugin wrapping `defineBlock`, firing from `configResolved` — the one hook Vite calls on both the dev-server and the build path. Every block scaffold registers it, so `pnpm dev`, `pnpm dev:harness` and `pnpm build` all fail on a bad manifest with the offending field path. On the dev server only, it also exposes the manifest's `scopes` + `storage` to `@civitai/sdk` for a dev-tunnel local preview. Optional peers: `ajv` (runtime) and `vite` (types only). |
|
|
@@ -68,7 +68,7 @@ import { defineBlock } from '@civitai/app-sdk/manifest';
|
|
|
68
68
|
// The same gate as a Vite plugin (NODE ONLY — optional peers `ajv` + `vite`):
|
|
69
69
|
import { blockManifestPlugin } from '@civitai/app-sdk/vite';
|
|
70
70
|
// Type-only: the orchestrator's generated per-step shapes. Needs the optional
|
|
71
|
-
// peer `@civitai/client@beta` — see "Typed step shapes" below:
|
|
71
|
+
// (frozen) peer `@civitai/client@beta` — see "Typed step shapes" below:
|
|
72
72
|
import type { TypedWorkflowTemplate } from '@civitai/app-sdk/orchestrator/steps';
|
|
73
73
|
// Opaque-origin storage shim — see "Web storage in a block" below:
|
|
74
74
|
import '@civitai/app-sdk/safe-storage';
|
|
@@ -887,6 +887,16 @@ console.log(`Hi ${me.username}`);
|
|
|
887
887
|
> explicit `baseUrl` to each call only when targeting a local / self-hosted
|
|
888
888
|
> instance (e.g. a dev auth hub vs a dev main app).
|
|
889
889
|
|
|
890
|
+
> **Failed orchestrator calls are logged, and you choose where.** Before it
|
|
891
|
+
> throws `OrchestratorError`, `callOrchestrator` (which `estimateWorkflow`,
|
|
892
|
+
> `submitWorkflow`, `getWorkflow` and `pollWorkflow` all use) logs one line
|
|
893
|
+
> with the method, path, status text and the first 500 characters of the raw response body.
|
|
894
|
+
> That body can echo what you submitted, such as the user's prompt. By default
|
|
895
|
+
> the line goes to `console.error`. Pass `logger: { error: (...args) => … }` to
|
|
896
|
+
> `createOrchestratorClient` to send it to your own logger, or `logger: null`
|
|
897
|
+
> to keep it out of your logs entirely. The thrown error still carries `status`
|
|
898
|
+
> and `body` either way.
|
|
899
|
+
|
|
890
900
|
> **`fallbackScope`, and what happens to a `scope` we cannot read.** Civitai's
|
|
891
901
|
> token endpoint returns `scope` as a decimal bitmask in a JSON *string*
|
|
892
902
|
> (`"scope": "114689"` — see the
|
|
@@ -982,7 +992,7 @@ Per-engine input shapes (`aspectRatio`, `resolution`, `numImages`, etc.) come fr
|
|
|
982
992
|
|
|
983
993
|
## Typed step shapes (`@civitai/app-sdk/orchestrator/steps`)
|
|
984
994
|
|
|
985
|
-
`WORKFLOW_STEP_TYPES` tells you which `$type`s exist; the body builders above take `input: unknown`. This subpath is the other half: the real per-step input shapes, keyed by wire `$type` over the orchestrator's own generated client (`@civitai/client`) so they
|
|
995
|
+
`WORKFLOW_STEP_TYPES` tells you which `$type`s exist; the body builders above take `input: unknown`. This subpath is the other half: the real per-step input shapes, keyed by wire `$type` over the orchestrator's own generated client (`@civitai/client`) so they come from codegen rather than by hand.
|
|
986
996
|
|
|
987
997
|
It is **type-only** — every export is a `type`, the built `dist/orchestrator/steps.js` is an empty module, and bundling it yields 0 bytes. Nothing is added to your runtime.
|
|
988
998
|
|
|
@@ -1027,7 +1037,7 @@ What it exports:
|
|
|
1027
1037
|
|
|
1028
1038
|
> 🔴 **The map is not total over the catalog, and that is the expected state.** `WORKFLOW_STEP_TYPES` documents 58 `$type`s; this map covers 47. The 11 with no generated template in the pinned `@civitai/client` are `archiveExtraction`, `audioModeration`, `imageScanning`, `liveTextToSpeech`, `liveTranscription`, `merge`, `multimodalEmbedding`, `preprocessVideo`, `promptModeration`, `soniloAudioGen`, `yuE2`, and `WorkflowStepTemplateFor<…>` is a compile error for each of them.
|
|
1029
1039
|
>
|
|
1030
|
-
> The two surfaces move independently
|
|
1040
|
+
> The two surfaces move independently: the catalog tracks the **live** orchestrator spec (a daily job syncs it), while these types come from `@civitai/client`, which is frozen at `0.2.0-beta.98` and will receive no further releases (see "Installing the peer"). So the gap will not close through a `@civitai/client` release; it changes only if this subpath's types source does. 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 (58, 47, 11, 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.
|
|
1031
1041
|
|
|
1032
1042
|
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'`.
|
|
1033
1043
|
|
|
@@ -1041,6 +1051,8 @@ In practice `WorkflowStepTemplateFor<T>` and `WorkflowStepInputFor<T>` are the b
|
|
|
1041
1051
|
pnpm add -D @civitai/client@beta
|
|
1042
1052
|
```
|
|
1043
1053
|
|
|
1054
|
+
> 🔴 **`@civitai/client` is frozen, and this subpath intentionally stays on it.** The package was renamed to `@civitai/orchestration-client`; npm marks `@civitai/client` deprecated ("Moved to @civitai/orchestration-client"), and `0.2.0-beta.98` under the `beta` tag is its last release. It remains installable and works as documented here. This subpath's types import the module name `@civitai/client`, so installing only `@civitai/orchestration-client` does **not** satisfy it: the guard below reports exactly as if the peer were missing. Keep `@civitai/client@beta` installed for these types. If you want step types generated from the renamed client, `@civitai/sdk` (a separate package in this repo) types its orchestration steps from `@civitai/orchestration-client`.
|
|
1055
|
+
|
|
1044
1056
|
> 🔴 **Use the `beta` tag, not `latest`.** `@civitai/client`'s npm `latest` dist-tag points at `0.1.1-beta.0`, roughly 97 betas behind the `beta` tag the orchestrator is actually generated against — and missing most of the step types above. A plain `pnpm add @civitai/client` installs the stale one with no error; the first symptom is `TextToImageStepTemplate` not existing.
|
|
1045
1057
|
|
|
1046
1058
|
> 🔴 **If the peer's types don't resolve, these types tell you — they used to just stop checking.** The unresolved `@civitai/client` import is in the SDK's shipped `steps.d.ts`, so `skipLibCheck: true` — the default for a TypeScript app, and set by every starter in this repo — suppresses the `TS2307` along with every other declaration-file diagnostic, and the types above degrade to an error type that behaves like `any`. Measured on a consumer with the peer uninstalled, against the subpath as it stood before the guard existed: **1 diagnostic** — a planted `const x: number = 's'` — on a project that also had a deliberately wrong `$type`. The wrong `$type` reported nothing.
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -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, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, 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, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, 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, BlockUploadedGenerationSource, BlockPersistGenerationSourceRequest, BlockPersistedGenerationSource, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockMediaUploadBatchItemResult, BlockPendingImageInfo, BlockSharedUploadImageInfo, BlockSharedPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockShareLinkMethod, BlockShareLinkRequest, BlockShareLinkResult, 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, KnownBlockOutputUnlockOutcome, BlockOutputUnlockResult, 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`.
|
|
@@ -546,6 +546,14 @@ export type ParentToBlockMessage = {
|
|
|
546
546
|
selected?: BlockUploadedImageInfo | BlockUploadedGenerationSource | BlockPendingImageInfo | BlockTrainingDataUploadResult;
|
|
547
547
|
/** A `bytes` upload's refusal or failure: a host string or a forwarded server message. */
|
|
548
548
|
error?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Whether sharing TOOK EFFECT, on a reply to an `OPEN_IMAGE_UPLOAD` that
|
|
551
|
+
* carried `share: true`: `true` only when the server recorded this upload
|
|
552
|
+
* as shared with the app's other viewers, `false` otherwise. Absent on
|
|
553
|
+
* replies to unshared uploads, and from a host that predates the field,
|
|
554
|
+
* which the SDK reads as `false`.
|
|
555
|
+
*/
|
|
556
|
+
shared?: boolean;
|
|
549
557
|
};
|
|
550
558
|
} | {
|
|
551
559
|
type: 'IMAGE_SCAN_RESOLVED';
|
|
@@ -819,6 +827,19 @@ export type BlockToParentMessage = {
|
|
|
819
827
|
bytes?: ArrayBuffer;
|
|
820
828
|
/** Optional name for a `bytes` upload (host-sanitised). */
|
|
821
829
|
filename?: string;
|
|
830
|
+
/**
|
|
831
|
+
* Ask that THIS viewer-picked `display` upload be SHARED with this app's
|
|
832
|
+
* other viewers once Civitai has scanned it. Only the exact value `true`
|
|
833
|
+
* opts in; omit it (the default) and the upload stays private to the
|
|
834
|
+
* uploader, as before. The host shows the viewer a line saying so in its
|
|
835
|
+
* upload dialog before they pick a file, and the server records the app
|
|
836
|
+
* from the verified block token, never from this message. A shared upload
|
|
837
|
+
* is then readable by this app's gated image read (`GET_IMAGES_BY_IDS`),
|
|
838
|
+
* scanned rows only. Ignored for `generationSource`, `trainingData` and
|
|
839
|
+
* `bytes`. 🔴 A host that predates the field ignores it, so the upload is
|
|
840
|
+
* NOT shared there.
|
|
841
|
+
*/
|
|
842
|
+
share?: boolean;
|
|
822
843
|
};
|
|
823
844
|
} | {
|
|
824
845
|
type: 'OPEN_IMAGE_PICKER';
|
package/dist/blocks/types.d.ts
CHANGED
|
@@ -181,6 +181,24 @@ export interface BlockUploadedImageInfo {
|
|
|
181
181
|
/** The Civitai-hosted image URL — usable directly as a {@link BlockSourceImage.url}. */
|
|
182
182
|
url: string;
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* A `useImageUpload({ share: true })` result: the moderated image, plus whether
|
|
186
|
+
* sharing TOOK EFFECT. `shared: true` only when the host reports that the
|
|
187
|
+
* server recorded the upload as shared with the app's other viewers; `false`
|
|
188
|
+
* on a host that predates sharing (or did not record it), in which case the
|
|
189
|
+
* upload is private to the uploader and the app must not say otherwise.
|
|
190
|
+
*
|
|
191
|
+
* A shared upload is shown to the app's other viewers through its gated image
|
|
192
|
+
* read only once Civitai has scanned it, only at PG / PG13 (shared uploads are
|
|
193
|
+
* held to SFW), and clamped to each viewer's own browsing level.
|
|
194
|
+
*/
|
|
195
|
+
export type BlockSharedUploadImageInfo = BlockUploadedImageInfo & {
|
|
196
|
+
shared: boolean;
|
|
197
|
+
};
|
|
198
|
+
/** The `asyncScan: true` + `share: true` early handle: {@link BlockPendingImageInfo} plus `shared`. */
|
|
199
|
+
export type BlockSharedPendingImageInfo = BlockPendingImageInfo & {
|
|
200
|
+
shared: boolean;
|
|
201
|
+
};
|
|
184
202
|
/**
|
|
185
203
|
* Early-resolve handle for an ASYNC-SCAN `'display'` upload (`asyncScan: true`
|
|
186
204
|
* on `OPEN_IMAGE_UPLOAD`). The image has been PERSISTED (its `imageId` is known)
|
|
@@ -925,7 +943,7 @@ export type WorkflowStatus = 'idle' | 'estimating' | 'confirming' | 'submitting'
|
|
|
925
943
|
export type BuzzAccountType = 'blue' | 'green' | 'yellow';
|
|
926
944
|
/**
|
|
927
945
|
* Generation parameters a block can override. All optional — the host fills
|
|
928
|
-
* sensible defaults (sampler
|
|
946
|
+
* sensible defaults (the family's default sampler, steps=25, dimensions from the
|
|
929
947
|
* base-model family) when omitted, so the simplest block can submit
|
|
930
948
|
* `{ kind: 'textToImage', modelId, modelVersionId, params: { prompt } }`.
|
|
931
949
|
*
|
|
@@ -937,7 +955,13 @@ export interface BlockTextToImageParams {
|
|
|
937
955
|
negativePrompt?: string;
|
|
938
956
|
/** Range 1–30. */
|
|
939
957
|
cfgScale?: number;
|
|
940
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* Sampler name. Valid names depend on the model family: read them with
|
|
960
|
+
* `fetchGenerationSamplers` from `@civitai/app-sdk/blocks`. A name the family
|
|
961
|
+
* does not offer is replaced by the family's default, with no error. Omitted,
|
|
962
|
+
* the host uses the family's default, and sends none for a family with no
|
|
963
|
+
* sampler control.
|
|
964
|
+
*/
|
|
941
965
|
sampler?: string;
|
|
942
966
|
/** Range 1–50. */
|
|
943
967
|
steps?: number;
|
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
|
-
*
|
|
28
|
+
* 244 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
|
|
32
|
+
* 🔴 That 244 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
|
-
*
|
|
28
|
+
* 244 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
|
|
32
|
+
* 🔴 That 244 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
|
|
@@ -370,6 +370,10 @@ export interface WorkflowSnapshot {
|
|
|
370
370
|
export interface OrchestratorClient {
|
|
371
371
|
baseUrl: string;
|
|
372
372
|
accessToken: string;
|
|
373
|
+
logger?: OrchestratorLogger | null;
|
|
374
|
+
}
|
|
375
|
+
export interface OrchestratorLogger {
|
|
376
|
+
error: (...args: unknown[]) => void;
|
|
373
377
|
}
|
|
374
378
|
export declare class OrchestratorError extends Error {
|
|
375
379
|
readonly status: number;
|
|
@@ -382,6 +386,14 @@ export interface CreateOrchestratorClientOptions {
|
|
|
382
386
|
accessToken: string;
|
|
383
387
|
/** Orchestrator base URL. Defaults to Civitai's prod orchestrator. */
|
|
384
388
|
baseUrl?: string;
|
|
389
|
+
/**
|
|
390
|
+
* Where {@link callOrchestrator} logs a failed response before it throws:
|
|
391
|
+
* method, path, status text and the first 500 characters of the raw response body, which
|
|
392
|
+
* can echo the submitted input (a prompt, for example). Omit it to keep
|
|
393
|
+
* `console.error`; pass `null` to log nothing. This covers the orchestrator
|
|
394
|
+
* client only, not the OAuth helpers.
|
|
395
|
+
*/
|
|
396
|
+
logger?: OrchestratorLogger | null;
|
|
385
397
|
}
|
|
386
398
|
/**
|
|
387
399
|
* Build an {@link OrchestratorClient} from a user's access token. Pass the
|
|
@@ -396,9 +408,9 @@ export interface CreateOrchestratorClientOptions {
|
|
|
396
408
|
*/
|
|
397
409
|
export declare function createOrchestratorClient(opts: CreateOrchestratorClientOptions): OrchestratorClient;
|
|
398
410
|
/**
|
|
399
|
-
* Internal raw-fetch helper. Logs the failing response to
|
|
400
|
-
* throws {@link OrchestratorError} on non-2xx. Exported so callers can
|
|
401
|
-
* their own orchestrator routes without duplicating this code.
|
|
411
|
+
* Internal raw-fetch helper. Logs the failing response to the configured logger
|
|
412
|
+
* and throws {@link OrchestratorError} on non-2xx. Exported so callers can
|
|
413
|
+
* build their own orchestrator routes without duplicating this code.
|
|
402
414
|
*/
|
|
403
415
|
export declare function callOrchestrator(client: OrchestratorClient, path: string, init?: RequestInit): Promise<unknown>;
|
|
404
416
|
export interface BuildTextToImageBodyOptions {
|
|
@@ -345,16 +345,19 @@ export class OrchestratorError extends Error {
|
|
|
345
345
|
* const estimate = await estimateWorkflow(client, body);
|
|
346
346
|
*/
|
|
347
347
|
export function createOrchestratorClient(opts) {
|
|
348
|
-
|
|
348
|
+
const client = {
|
|
349
349
|
baseUrl: opts.baseUrl ?? DEFAULT_ORCHESTRATOR_BASE_URL,
|
|
350
350
|
accessToken: opts.accessToken,
|
|
351
351
|
};
|
|
352
|
+
if (opts.logger !== undefined)
|
|
353
|
+
client.logger = opts.logger;
|
|
354
|
+
return client;
|
|
352
355
|
}
|
|
353
356
|
// ---------- Raw HTTP --------------------------------------------------------
|
|
354
357
|
/**
|
|
355
|
-
* Internal raw-fetch helper. Logs the failing response to
|
|
356
|
-
* throws {@link OrchestratorError} on non-2xx. Exported so callers can
|
|
357
|
-
* their own orchestrator routes without duplicating this code.
|
|
358
|
+
* Internal raw-fetch helper. Logs the failing response to the configured logger
|
|
359
|
+
* and throws {@link OrchestratorError} on non-2xx. Exported so callers can
|
|
360
|
+
* build their own orchestrator routes without duplicating this code.
|
|
358
361
|
*/
|
|
359
362
|
export async function callOrchestrator(client, path, init = {}) {
|
|
360
363
|
const { headers, ...rest } = init;
|
|
@@ -375,8 +378,22 @@ export async function callOrchestrator(client, path, init = {}) {
|
|
|
375
378
|
body = text;
|
|
376
379
|
}
|
|
377
380
|
if (!res.ok) {
|
|
378
|
-
|
|
379
|
-
|
|
381
|
+
const logger = client.logger === undefined ? console : client.logger;
|
|
382
|
+
// A caller-supplied logger must never change what this function throws:
|
|
383
|
+
// callers branch on `instanceof OrchestratorError` to pass the status on.
|
|
384
|
+
// So a logger that throws is swallowed, and one that returns a rejected
|
|
385
|
+
// promise (an async log sink that is down) is caught rather than left as
|
|
386
|
+
// an unhandled rejection that would crash a Node process.
|
|
387
|
+
try {
|
|
388
|
+
const logged = logger?.error(`[orchestrator] ${init.method ?? 'GET'} ${path} -> ${res.status} ${res.statusText}\n` +
|
|
389
|
+
` raw body: ${text.length ? text.slice(0, 500) : '(empty)'}`);
|
|
390
|
+
if (logged && typeof logged.then === 'function') {
|
|
391
|
+
Promise.resolve(logged).catch(() => { });
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
// Logging is best-effort; the OrchestratorError below is the contract.
|
|
396
|
+
}
|
|
380
397
|
throw new OrchestratorError(`HTTP ${res.status}`, res.status, body);
|
|
381
398
|
}
|
|
382
399
|
return body;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
* (`WORKFLOW_STEP_TYPES` — 58 `$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
|
-
* per-step input shapes,
|
|
10
|
-
* codegen instead of by hand.
|
|
9
|
+
* per-step input shapes, generated from the orchestrator's OpenAPI spec by
|
|
10
|
+
* codegen instead of written by hand. 🔴 `@civitai/client` is FROZEN: it was
|
|
11
|
+
* renamed `@civitai/orchestration-client`, npm marks it deprecated, and
|
|
12
|
+
* `0.2.0-beta.98` is its last release. This module still imports the name
|
|
13
|
+
* `@civitai/client` on purpose, so the renamed package alone does not satisfy
|
|
14
|
+
* it (see "Why this is a separate deep entry point" below).
|
|
11
15
|
*
|
|
12
16
|
* What this module adds on top of `@civitai/client` is the `$type` → template
|
|
13
17
|
* MAP (`WorkflowStepTemplates`) and the lookups derived from it. The generated
|
|
@@ -106,9 +110,10 @@
|
|
|
106
110
|
*
|
|
107
111
|
* That gap is EXPECTED and is not a defect in either surface. The catalog
|
|
108
112
|
* tracks the LIVE orchestrator spec (`pnpm check:catalogs` and the daily
|
|
109
|
-
* `sync-orchestrator-catalogs` automation keep it there); these types
|
|
110
|
-
*
|
|
111
|
-
*
|
|
113
|
+
* `sync-orchestrator-catalogs` automation keep it there); these types come
|
|
114
|
+
* from `@civitai/client`, which is frozen and will receive no further
|
|
115
|
+
* releases. So the gap does not close through a client release; it changes
|
|
116
|
+
* only if this module's types source does. What is NOT optional is that the gap stays
|
|
112
117
|
* stated: it is spelled as a `never` ledger in
|
|
113
118
|
* `test/orchestrator/step-templates.test-d.ts` (which also pins the compile
|
|
114
119
|
* error above, one `@ts-expect-error` per gap `$type`), and the sentence naming
|
|
@@ -133,6 +138,11 @@
|
|
|
133
138
|
* pnpm add -D @civitai/client@beta
|
|
134
139
|
* ```
|
|
135
140
|
*
|
|
141
|
+
* That is the frozen package's last release, and it stays this module's peer:
|
|
142
|
+
* installing only the renamed `@civitai/orchestration-client` leaves the
|
|
143
|
+
* `@civitai/client` import unresolved, which the guard below reports exactly as
|
|
144
|
+
* a missing peer.
|
|
145
|
+
*
|
|
136
146
|
* 🔴 **WITHOUT A GUARD, FORGETTING THE PEER IS SILENT UNDER
|
|
137
147
|
* `skipLibCheck: true`, WHICH IS THE DEFAULT.** The unresolved
|
|
138
148
|
* `@civitai/client` import lands in the emitted `steps.d.ts`, so `skipLibCheck`
|
|
@@ -336,10 +346,11 @@ interface StepTemplateMap {
|
|
|
336
346
|
* catalog nor the pinned client knows about. That is the catalog's own
|
|
337
347
|
* drift check's job (`pnpm check:catalogs`, which re-fetches the LIVE spec).
|
|
338
348
|
*
|
|
339
|
-
* The two can legitimately disagree
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
349
|
+
* The two can legitimately disagree: the catalog tracks the live spec, while
|
|
350
|
+
* these types come from the frozen `@civitai/client`. When the catalog syncs
|
|
351
|
+
* ahead, name the not-yet-typed step types in the test's ledger in the same
|
|
352
|
+
* PR. No client republish will clear them; only a change of this module's
|
|
353
|
+
* types source can.
|
|
343
354
|
*/
|
|
344
355
|
export type WorkflowStepTemplates = {
|
|
345
356
|
[K in keyof StepTemplateMap]: GuardPeer<StepTemplateMap[K]>;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
* (`WORKFLOW_STEP_TYPES` — 58 `$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
|
-
* per-step input shapes,
|
|
10
|
-
* codegen instead of by hand.
|
|
9
|
+
* per-step input shapes, generated from the orchestrator's OpenAPI spec by
|
|
10
|
+
* codegen instead of written by hand. 🔴 `@civitai/client` is FROZEN: it was
|
|
11
|
+
* renamed `@civitai/orchestration-client`, npm marks it deprecated, and
|
|
12
|
+
* `0.2.0-beta.98` is its last release. This module still imports the name
|
|
13
|
+
* `@civitai/client` on purpose, so the renamed package alone does not satisfy
|
|
14
|
+
* it (see "Why this is a separate deep entry point" below).
|
|
11
15
|
*
|
|
12
16
|
* What this module adds on top of `@civitai/client` is the `$type` → template
|
|
13
17
|
* MAP (`WorkflowStepTemplates`) and the lookups derived from it. The generated
|
|
@@ -106,9 +110,10 @@
|
|
|
106
110
|
*
|
|
107
111
|
* That gap is EXPECTED and is not a defect in either surface. The catalog
|
|
108
112
|
* tracks the LIVE orchestrator spec (`pnpm check:catalogs` and the daily
|
|
109
|
-
* `sync-orchestrator-catalogs` automation keep it there); these types
|
|
110
|
-
*
|
|
111
|
-
*
|
|
113
|
+
* `sync-orchestrator-catalogs` automation keep it there); these types come
|
|
114
|
+
* from `@civitai/client`, which is frozen and will receive no further
|
|
115
|
+
* releases. So the gap does not close through a client release; it changes
|
|
116
|
+
* only if this module's types source does. What is NOT optional is that the gap stays
|
|
112
117
|
* stated: it is spelled as a `never` ledger in
|
|
113
118
|
* `test/orchestrator/step-templates.test-d.ts` (which also pins the compile
|
|
114
119
|
* error above, one `@ts-expect-error` per gap `$type`), and the sentence naming
|
|
@@ -133,6 +138,11 @@
|
|
|
133
138
|
* pnpm add -D @civitai/client@beta
|
|
134
139
|
* ```
|
|
135
140
|
*
|
|
141
|
+
* That is the frozen package's last release, and it stays this module's peer:
|
|
142
|
+
* installing only the renamed `@civitai/orchestration-client` leaves the
|
|
143
|
+
* `@civitai/client` import unresolved, which the guard below reports exactly as
|
|
144
|
+
* a missing peer.
|
|
145
|
+
*
|
|
136
146
|
* 🔴 **WITHOUT A GUARD, FORGETTING THE PEER IS SILENT UNDER
|
|
137
147
|
* `skipLibCheck: true`, WHICH IS THE DEFAULT.** The unresolved
|
|
138
148
|
* `@civitai/client` import lands in the emitted `steps.d.ts`, so `skipLibCheck`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civitai/app-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.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",
|
|
@@ -86,7 +86,13 @@
|
|
|
86
86
|
"and MISSING MOST STEP TYPES, with no error. The range below deliberately",
|
|
87
87
|
"excludes 0.1.x: verify with",
|
|
88
88
|
"`semver.satisfies('0.1.1-beta.0', '^0.2.0-beta.98')` === false.",
|
|
89
|
-
"Install with the tag: `pnpm add -D @civitai/client@beta`."
|
|
89
|
+
"Install with the tag: `pnpm add -D @civitai/client@beta`.",
|
|
90
|
+
"",
|
|
91
|
+
"🔴 @civitai/client IS FROZEN. It was renamed @civitai/orchestration-client;",
|
|
92
|
+
"npm marks it deprecated and 0.2.0-beta.98 is its last release, so the",
|
|
93
|
+
"catalog/type gap will not close through a @civitai/client release. The",
|
|
94
|
+
"peer stays @civitai/client on purpose: the renamed package alone does not",
|
|
95
|
+
"satisfy `./orchestrator/steps` (the README's \"Installing the peer\")."
|
|
90
96
|
],
|
|
91
97
|
"comment-peerDependencies-ajv-vite": [
|
|
92
98
|
"ajv and vite are OPTIONAL peers of the NODE-ONLY subpaths added when #330",
|