@civitai/app-sdk 0.78.0 → 0.79.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/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/messages.d.ts +16 -2
- package/dist/blocks/messages.js +1 -0
- package/dist/blocks/types.d.ts +72 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/blocks/index.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export { isModelSlotContext, isPageSlotContext } from './types.js';
|
|
|
116
116
|
* in `types.ts` for which of the two it uses and why.
|
|
117
117
|
*/
|
|
118
118
|
export { isSignedIn } from './types.js';
|
|
119
|
-
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageDeclaration, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, 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, WorkflowStatus, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, 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';
|
|
119
|
+
export type { BlockContext, KnownSlotId, ModelSlotId, PageSlotContext, PageSlotId, UnknownSlotContext, BlockAnalyticsDeclaration, BlockAnalyticsEventDeclaration, BlockAnalyticsPropertyDeclaration, BlockManifest, BlockManifestGood, BlockManifestV1, BlockSettings, BlockStorageCollectionDeclaration, BlockStorageDeclaration, BlockStorageIndexes, BlockStorageIndexType, BlockStoragePrivateCollectionDeclaration, BlockStorageSharedCollectionDeclaration, BlockToken, ContentRating, ManifestBooleanField, ManifestIframe, ManifestNumberField, ManifestPage, ManifestPreview, ManifestSettingField, ManifestSettings, ManifestStringField, ManifestTarget, ModelSlotContext, SettingScope, SettingWidget, Theme, ViewerInfo, BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockSourceImage, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, 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, 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';
|
|
120
120
|
/** Host bound for the App Blocks `kind: 'workflow'` body — see `WorkflowBodyWorkflow`. */
|
|
121
121
|
export { BLOCK_WORKFLOW_MAX_STEPS, BLOCK_WORKFLOW_REPEAT_MAX_ITERATIONS } from './types.js';
|
|
122
122
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Wire format: `window.postMessage({ type, payload }, targetOrigin)`.
|
|
9
9
|
*/
|
|
10
10
|
import type { ColorDomain } from './browsingLevel.js';
|
|
11
|
-
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDataUploadResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep } from './types.js';
|
|
11
|
+
import type { BlockCheckpointInfo, BlockResourceInfo, BlockResourcePickerType, BlockUploadedImageInfo, BlockGenerationSourceImageInfo, BlockImagePickerSource, BlockPickedImageInfo, BlockMediaKind, BlockMediaUploadInfo, BlockPendingImageInfo, BlockImageScanResult, BlockUploadPurpose, BlockNavigateScope, BlockContext, BlockSettings, Theme, ViewerInfo, WorkflowBody, BlockWorkflowSnapshot, BlockEstimateBatchAggregate, BlockBuzzTransaction, BlockBuzzAccount, BlockDailyCompensationResource, BlockViewer, BlockWildcardPack, BlockWildcardPackErrorCode, BlockResourceFile, BlockResourceFileErrorCode, AppWorkflow, BlockGatedImage, BlockCollectionFollowErrorCode, BlockCollectionFollowResult, BlockPostSource, BlockCreatePostResult, BlockTrainingDataUploadResult, WorkflowBodyTraining, WorkflowBodyPassThroughStep } from './types.js';
|
|
12
12
|
import type { BlockAppReaction, BlockEntityReactionErrorCode, BlockEntityReactionResult, BlockEntityReactionsResult, BlockReactionEntityType } from './reactions.js';
|
|
13
13
|
/**
|
|
14
14
|
* Filter params for `GET_BUZZ_TRANSACTIONS`. All optional; the host validates
|
|
@@ -484,6 +484,13 @@ export type ParentToBlockMessage = {
|
|
|
484
484
|
pack?: BlockWildcardPack;
|
|
485
485
|
error?: BlockWildcardPackErrorCode;
|
|
486
486
|
};
|
|
487
|
+
} | {
|
|
488
|
+
type: 'RESOURCE_FILE_RESULT';
|
|
489
|
+
payload: {
|
|
490
|
+
requestId: string;
|
|
491
|
+
file?: BlockResourceFile;
|
|
492
|
+
error?: BlockResourceFileErrorCode;
|
|
493
|
+
};
|
|
487
494
|
} | {
|
|
488
495
|
type: 'APP_WORKFLOWS_RESULT';
|
|
489
496
|
payload: {
|
|
@@ -854,6 +861,13 @@ export type BlockToParentMessage = {
|
|
|
854
861
|
requestId: string;
|
|
855
862
|
modelVersionId: number;
|
|
856
863
|
};
|
|
864
|
+
} | {
|
|
865
|
+
type: 'GET_RESOURCE_FILE';
|
|
866
|
+
payload: {
|
|
867
|
+
requestId: string;
|
|
868
|
+
modelVersionId: number;
|
|
869
|
+
fileId?: number;
|
|
870
|
+
};
|
|
857
871
|
} | {
|
|
858
872
|
type: 'QUERY_APP_WORKFLOWS';
|
|
859
873
|
payload: {
|
|
@@ -1216,7 +1230,7 @@ export type BlockToParentMessageType = BlockToParentMessage['type'];
|
|
|
1216
1230
|
* it is a measurement, not an invariant, and civitai's own compile-time gate
|
|
1217
1231
|
* (published SDK union ⊆ `keyof INVENTORY`) is what holds one direction of it.
|
|
1218
1232
|
*/
|
|
1219
|
-
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "APP_STORAGE_GET", "APP_STORAGE_SET", "APP_STORAGE_DELETE", "APP_STORAGE_LIST", "APP_STORAGE_QUOTA", "SHARED_LIST", "SHARED_GET_COUNT", "SHARED_GET_COUNTS", "SHARED_APPEND", "SHARED_VOTE", "SHARED_UNVOTE", "SHARED_WITHDRAW", "SHARED_UPDATE", "SHARED_GET", "SHARED_REPORT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
1233
|
+
export declare const BLOCK_TO_PARENT_MESSAGE_TYPES: readonly ["BLOCK_HELLO", "BLOCK_READY", "BLOCK_ERROR", "BLOCK_MESSAGE_REJECTED", "REQUEST_TOKEN", "RESIZE_IFRAME", "SUBMIT_WORKFLOW", "ESTIMATE_WORKFLOW", "ESTIMATE_WORKFLOW_BATCH", "POLL_WORKFLOW", "CANCEL_WORKFLOW", "OPEN_BUZZ_PURCHASE", "GET_BUZZ_BALANCE", "GET_VIEWER", "GET_BUZZ_TRANSACTIONS", "GET_BUZZ_ACCOUNTS", "GET_DAILY_COMPENSATION", "GET_WILDCARD_PACK", "GET_RESOURCE_FILE", "QUERY_APP_WORKFLOWS", "PUBLISH_GENERATION_OUTPUTS", "CREATE_POST_FROM_APP", "RUN_TRAINING", "RUN_CONFIRMED_STEP", "GET_IMAGES_BY_IDS", "CANCEL_APP_WORKFLOW", "OPEN_CHECKPOINT_PICKER", "OPEN_RESOURCE_PICKER", "OPEN_IMAGE_UPLOAD", "OPEN_IMAGE_PICKER", "OPEN_MEDIA_UPLOAD", "SET_USER_CHECKPOINT", "NAVIGATE", "REQUEST_SIGN_IN", "REQUEST_CONSENT", "TRACK_EVENT", "APP_STORAGE_GET", "APP_STORAGE_SET", "APP_STORAGE_DELETE", "APP_STORAGE_LIST", "APP_STORAGE_QUOTA", "SHARED_LIST", "SHARED_GET_COUNT", "SHARED_GET_COUNTS", "SHARED_APPEND", "SHARED_VOTE", "SHARED_UNVOTE", "SHARED_WITHDRAW", "SHARED_UPDATE", "SHARED_GET", "SHARED_REPORT", "SAVE_IMAGE", "SET_COLLECTION_FOLLOW", "SET_ENTITY_REACTION", "GET_ENTITY_REACTIONS"];
|
|
1220
1234
|
/**
|
|
1221
1235
|
* The bucket a message type falls into when the protocol does not declare it.
|
|
1222
1236
|
*
|
package/dist/blocks/messages.js
CHANGED
package/dist/blocks/types.d.ts
CHANGED
|
@@ -3214,6 +3214,78 @@ export interface BlockWildcardPack {
|
|
|
3214
3214
|
sfwOnly: boolean;
|
|
3215
3215
|
};
|
|
3216
3216
|
}
|
|
3217
|
+
/**
|
|
3218
|
+
* The CLOSED error set a `RESOURCE_FILE_RESULT` carries on failure
|
|
3219
|
+
* (civitai/civitai-app-starters#664). Like {@link BlockWildcardPackErrorCode} it
|
|
3220
|
+
* is a discriminated code, never free text. What each code covers is the host's
|
|
3221
|
+
* behaviour in civitai/civitai#6818 (`resource-file.service.ts`,
|
|
3222
|
+
* `resourceFileParse.ts`, `resourceFileHost.ts`):
|
|
3223
|
+
*
|
|
3224
|
+
* - `not-found` — every refusal of the resolve step except maturity: no such
|
|
3225
|
+
* version; not a `Workflows`/`ComfyWorkflows` version; no such file, or (for a
|
|
3226
|
+
* non-owner) the file is not `Public`; the site's download gate, evaluated
|
|
3227
|
+
* WITHOUT moderator rights, refuses it; an unpublished draft (the owner's own
|
|
3228
|
+
* included); an early-access or paid version for anyone but its owner (buyers
|
|
3229
|
+
* included); downloads disabled for anyone but the owner; and, for anyone but
|
|
3230
|
+
* the owner (moderators included), a POI model or a model or version whose
|
|
3231
|
+
* availability is not open (`Public` or `Unsearchable`), e.g. `Private`.
|
|
3232
|
+
* - `forbidden` — the version passes every gate above but is above the viewer's
|
|
3233
|
+
* maturity ceiling on this site (checked AFTER the download gate, so a version
|
|
3234
|
+
* the viewer cannot download never reveals its rating); or the app is running
|
|
3235
|
+
* in review preview, which refuses before resolving anything.
|
|
3236
|
+
* - `unauthorized` — the viewer is signed out.
|
|
3237
|
+
* - `too-large` — the file's advertised size, its `Content-Length` or the body
|
|
3238
|
+
* as it streams is over 32 MB; or no entry could be returned and at least one
|
|
3239
|
+
* was dropped by a size cap (4 MB per entry, 16 MB inflated in total) — so a
|
|
3240
|
+
* single `.json` over 4 MB is `too-large`.
|
|
3241
|
+
* - `parse-failed` — not a `.json` or `.zip`, a corrupt zip, or no JSON entry
|
|
3242
|
+
* that could be read and parsed. ALSO the host's catch-all: a network error, a
|
|
3243
|
+
* non-OK fetch, no answer within the host's 110 s deadline, a transient storage
|
|
3244
|
+
* failure in the resolve step, or any other server error. So it can be
|
|
3245
|
+
* transient, and one retry is reasonable. It is also the `dev:live` reply,
|
|
3246
|
+
* which cannot serve this bridge.
|
|
3247
|
+
* - `busy` — the tab already has 3 resource-file requests in flight; retry.
|
|
3248
|
+
* - `rate-limited` — the viewer's 30-a-minute budget is spent; retry later.
|
|
3249
|
+
*/
|
|
3250
|
+
export type BlockResourceFileErrorCode = 'not-found' | 'forbidden' | 'unauthorized' | 'too-large' | 'parse-failed' | 'busy' | 'rate-limited';
|
|
3251
|
+
/**
|
|
3252
|
+
* How the host classified one parsed JSON entry: `api` when every top-level
|
|
3253
|
+
* value has `class_type` and `inputs` (the ComfyUI API format), `ui` when it has
|
|
3254
|
+
* a `nodes` array (the ComfyUI UI/editor format), otherwise `unknown`.
|
|
3255
|
+
*/
|
|
3256
|
+
export type BlockResourceFileEntryFormat = 'ui' | 'api' | 'unknown';
|
|
3257
|
+
/** Which file the host served, and what it belongs to. */
|
|
3258
|
+
export interface BlockResourceFileMeta {
|
|
3259
|
+
modelId: number;
|
|
3260
|
+
modelVersionId: number;
|
|
3261
|
+
/** The file the host picked (or the `fileId` the request named). */
|
|
3262
|
+
fileId: number;
|
|
3263
|
+
fileName: string;
|
|
3264
|
+
modelName: string;
|
|
3265
|
+
versionName: string;
|
|
3266
|
+
creatorUsername: string | null;
|
|
3267
|
+
}
|
|
3268
|
+
/** One parsed JSON document out of the file. */
|
|
3269
|
+
export interface BlockResourceFileEntry {
|
|
3270
|
+
/** The entry's path inside the archive, or the file name for a plain `.json`. */
|
|
3271
|
+
path: string;
|
|
3272
|
+
format: BlockResourceFileEntryFormat;
|
|
3273
|
+
/** The parsed JSON, as-is. Check `format` before reading it as a graph. */
|
|
3274
|
+
graph: unknown;
|
|
3275
|
+
}
|
|
3276
|
+
/**
|
|
3277
|
+
* A resource file the host resolved, fetched, unzipped and parsed AS THE VIEWER
|
|
3278
|
+
* and returned on `RESOURCE_FILE_RESULT`. A plain `.json` file gives one entry;
|
|
3279
|
+
* a `.zip` gives one per `.json` entry (other entries, `__MACOSX/` and dot-files
|
|
3280
|
+
* are skipped and do not count), at most 20. `truncated` is true when a JSON
|
|
3281
|
+
* entry was dropped: past the 20, over the 4 MB per-entry or 16 MB total inflate
|
|
3282
|
+
* cap, unreadable, or not valid JSON.
|
|
3283
|
+
*/
|
|
3284
|
+
export interface BlockResourceFile {
|
|
3285
|
+
meta: BlockResourceFileMeta;
|
|
3286
|
+
entries: BlockResourceFileEntry[];
|
|
3287
|
+
truncated: boolean;
|
|
3288
|
+
}
|
|
3217
3289
|
/**
|
|
3218
3290
|
* One result image on an {@link AppWorkflow}. Mirrors civitai/civitai's
|
|
3219
3291
|
* `AppWorkflowImage` projection (`src/server/services/blocks/workflow.service.ts`,
|
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
|
+
* 202 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 202 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
|
+
* 202 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 202 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