@clipwright/core 0.76.0 → 0.78.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/actors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ACTOR_FULL_PORTRAIT_FACE_HEIGHT, ACTOR_WIDE_PORTRAIT_FACE_HEIGHT, actorIdScope } from "./account-actors.js";
3
- import { expectedVendorFrame } from "./aspect.js";
3
+ import { outputFrame } from "./aspect.js";
4
4
  import { sharpCropOf } from "./scene-place.js";
5
5
  import { ACTOR_FOR_GENDER, actorId, ASPECT_RATIOS, LEGACY_RUN_RESOLUTION, RESOLUTIONS } from "./skills.js";
6
6
  import { defaultVoiceOf, DEFAULT_VOICE_PRESET, speaksOwnVoices, VOICE_PRESETS } from "./voices.js";
@@ -101,7 +101,7 @@ function presenterPlaceSoftness(input, pin) {
101
101
  const aspect = ASPECT_RATIOS.find(ratio => ratio === asset?.aspect_ratio), resolution = RESOLUTIONS.find(entry => entry === input.resolution) ?? LEGACY_RUN_RESOLUTION;
102
102
  if (!place || largest === undefined || !asset?.width || !aspect)
103
103
  return undefined;
104
- const sharp = sharpCropOf(asset.width, expectedVendorFrame(resolution, aspect).width);
104
+ const sharp = sharpCropOf(asset.width, outputFrame(resolution, aspect).width);
105
105
  if (place.face_height / largest <= sharp)
106
106
  return undefined;
107
107
  return `presenter_place face height ${place.face_height.toFixed(2)}: the actor's ${view} portrait shows the face under ${largest} of its height, so a ` +
package/dist/aspect.d.ts CHANGED
@@ -20,7 +20,6 @@ export interface ResolveAspectInput {
20
20
  }
21
21
  export declare function resolveAspectRatio(input: ResolveAspectInput): AspectResolution;
22
22
  export declare function exactAspectLabel(width: number, height: number): string;
23
- export declare function vendorAspectFor(source: AspectSource, supported: readonly AspectRatio[]): AspectRatio;
24
23
  export interface DeliveredClip {
25
24
  width: number;
26
25
  height: number;
@@ -37,7 +36,7 @@ export declare function deliveredResolutionWarning(requested: Resolution, delive
37
36
  width: number;
38
37
  height: number;
39
38
  }): string | null;
40
- export declare function expectedVendorFrame(resolution: Resolution, aspectRatio: AspectRatio): {
39
+ export declare function outputFrame(resolution: Resolution, aspectRatio: AspectRatio): {
41
40
  width: number;
42
41
  height: number;
43
42
  };
package/dist/aspect.js CHANGED
@@ -67,22 +67,6 @@ export function exactAspectLabel(width, height) {
67
67
  const divisor = gcd(w, h);
68
68
  return `${w / divisor}:${h / divisor}`;
69
69
  }
70
- export function vendorAspectFor(source, supported) {
71
- if (supported.length === 0) {
72
- throw new Error("vendorAspectFor: backend declares no supported aspect ratios");
73
- }
74
- const sourceRatio = source.width / source.height;
75
- let best = supported[0];
76
- let bestDistance = aspectDistance(ASPECT_RATIO_VALUES[best], sourceRatio);
77
- for (const candidate of supported) {
78
- const distance = aspectDistance(ASPECT_RATIO_VALUES[candidate], sourceRatio);
79
- if (distance < bestDistance) {
80
- best = candidate;
81
- bestDistance = distance;
82
- }
83
- }
84
- return best;
85
- }
86
70
  export function deliveryWarnings(args) {
87
71
  const { predicted, actual } = args;
88
72
  const tolerance = args.durationToleranceSec ?? 0.05;
@@ -102,7 +86,7 @@ export function deliveryWarnings(args) {
102
86
  export function upscaleWarning(source, resolution, aspectRatio) {
103
87
  if (source === null || source.origin !== "probed")
104
88
  return null;
105
- const frame = expectedVendorFrame(resolution, aspectRatio);
89
+ const frame = outputFrame(resolution, aspectRatio);
106
90
  const sourceShort = Math.min(source.width, source.height);
107
91
  const frameShort = Math.min(frame.width, frame.height);
108
92
  if (sourceShort >= frameShort)
@@ -122,7 +106,7 @@ export function deliveredResolutionWarning(requested, delivered) {
122
106
  return `resolution ${requested} was requested, but the video is delivered at ` +
123
107
  `${delivered.width}×${delivered.height}; resolution does not change the price`;
124
108
  }
125
- export function expectedVendorFrame(resolution, aspectRatio) {
109
+ export function outputFrame(resolution, aspectRatio) {
126
110
  const short = SHORT_SIDE_BY_RESOLUTION[resolution];
127
111
  const ratio = ASPECT_RATIO_VALUES[aspectRatio];
128
112
  const even = (value) => {
@@ -141,7 +141,7 @@ export const creatorProfile = z.strictObject({
141
141
  median_comment_rate: z.number().nonnegative().nullable().describe("The median comment_rate of the videos with both counts, four decimals; null " +
142
142
  `under ${CREATOR_COMMENT_NORM_MIN_VIDEOS} such videos.`),
143
143
  cadence: cadenceShape,
144
- voice_proposal: scriptVoice.optional().describe("A script voice proposed from the author's own captions (#1203): their topics and a closing " +
144
+ voice_proposal: scriptVoice.optional().describe("A script voice proposed from the author's own captions: their topics and a closing " +
145
145
  "line they repeat. Third-party text, not saved until passed to brand_kit; it suits only this author's own brand kit."),
146
146
  });
147
147
  const measuredProfile = z.object({
package/dist/design.js CHANGED
@@ -149,7 +149,7 @@ export const extractBrandResponse = z.object({
149
149
  url: z.string(),
150
150
  design: design,
151
151
  resolved: resolvedDesign,
152
- voice: scriptVoice.optional().describe("A proposed script voice read from the page's own words (#1203): third-party text, not " +
152
+ voice: scriptVoice.optional().describe("A proposed script voice read from the page's own words: third-party text, not " +
153
153
  "saved until passed to brand_kit."),
154
154
  brand_name: brandName.optional().describe("A proposed brand name read from the page: third-party text, not saved until passed to " +
155
155
  "brand_kit."),
@@ -85,7 +85,6 @@ export declare const FACELESS_MIN_BASE_CREDITS = 50;
85
85
  export declare const FACELESS_SHOT_CREDITS_PER_SECOND = 30;
86
86
  export declare const FACELESS_MAX_SHOTS = 10;
87
87
  export declare const FACELESS_SHOT_MAX_SEC = 5;
88
- export declare const FACELESS_MAX_CAP_USD_MICROS = 10000000;
89
88
  export declare const facelessShotSecondsCeiling: (shots: number) => number;
90
89
  export declare function facelessPartsBase(images: number, outputFrames: number): number;
91
90
  export declare const FACELESS_EXPLAINER_POSE_PICTURES = 9;
@@ -56,7 +56,6 @@ export const FACELESS_MIN_BASE_CREDITS = DELIVERED_VIDEO_MINIMUM_CREDITS;
56
56
  export const FACELESS_SHOT_CREDITS_PER_SECOND = 30;
57
57
  export const FACELESS_MAX_SHOTS = 10;
58
58
  export const FACELESS_SHOT_MAX_SEC = 5;
59
- export const FACELESS_MAX_CAP_USD_MICROS = 10_000_000;
60
59
  export const facelessShotSecondsCeiling = (shots) => shots * FACELESS_SHOT_MAX_SEC;
61
60
  export function facelessPartsBase(images, outputFrames) {
62
61
  return images * FACELESS_IMAGE_CREDITS + Math.ceil(FACELESS_CREDITS_PER_1500_FRAMES * outputFrames / 1500);
package/dist/index.d.ts CHANGED
@@ -60,7 +60,6 @@ export * from "./pacing.js";
60
60
  export * from "./render-backend.js";
61
61
  export * from "./tts-backend.js";
62
62
  export * from "./speech-words.js";
63
- export * from "./vendor-response.js";
64
63
  export * from "./public-endpoints.js";
65
64
  export * from "./endpoints.js";
66
65
  export * from "./endpoint-notes.js";
package/dist/index.js CHANGED
@@ -60,7 +60,6 @@ export * from "./pacing.js";
60
60
  export * from "./render-backend.js";
61
61
  export * from "./tts-backend.js";
62
62
  export * from "./speech-words.js";
63
- export * from "./vendor-response.js";
64
63
  export * from "./public-endpoints.js";
65
64
  export * from "./endpoints.js";
66
65
  export * from "./endpoint-notes.js";
@@ -22,7 +22,6 @@ export declare function calculateFaceCharge(intervals: readonly FaceBillingInter
22
22
  credits: number;
23
23
  minimumApplied: boolean;
24
24
  };
25
- export declare const FACE_RESERVE_SHAPE_MARGIN = 1.15;
26
25
  export declare const longFormQuoteSchema: z.ZodReadonly<z.ZodObject<{
27
26
  pricingVersion: z.ZodString;
28
27
  rateCreditsPerFaceSecond: z.ZodNumber;
@@ -46,7 +46,6 @@ export function calculateFaceCharge(intervals, fps, tariff) {
46
46
  return { faceFrames: Number(frames), billableFaceSeconds: Number(seconds), credits: Number(credits),
47
47
  minimumApplied: usageCredits < minimum };
48
48
  }
49
- export const FACE_RESERVE_SHAPE_MARGIN = 1.15;
50
49
  const credits = z.number().int().nonnegative().max(2_147_483_647);
51
50
  const pricing = {
52
51
  pricingVersion: z.string().min(1).max(200),
package/dist/openapi.js CHANGED
@@ -161,25 +161,25 @@ export const OPENAPI_ROUTES = {
161
161
  "POST /v1/assets/{id}": { exposure: "public", operationId: "updateAsset", tag: "Assets", params: ASSET,
162
162
  body: named("UpdateAssetRequest", updateAssetRequest), responses: { 200: named("Asset", asset) } },
163
163
  "DELETE /v1/assets/{id}": { exposure: "public", operationId: "deleteAsset", tag: "Assets", params: ASSET, responses: { 204: null } },
164
- "POST /v1/film-drafts": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches (#1291 F2)." },
165
- "POST /v1/film-drafts/{id}/files": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches (#1291 F2)." },
166
- "GET /v1/film-drafts/{id}": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches (#1291 F2)." },
167
- "POST /v1/film-drafts/{id}/check": { exposure: "excluded", reason: "Not offered yet: the film check joins the contract with the drafts it reads (#1356)." },
168
- "POST /v1/film-stills/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
169
- "POST /v1/film-stills": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
170
- "POST /v1/film-voices/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
171
- "POST /v1/film-voices": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
172
- "POST /v1/film-renders/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
173
- "POST /v1/film-renders": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
174
- "POST /v1/film-heroes/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1356)." },
175
- "POST /v1/film-heroes": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1356)." },
176
- "POST /v1/film-edits/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
177
- "POST /v1/film-edits": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
178
- "POST /v1/take-frames/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
179
- "POST /v1/take-frames": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
180
- "POST /v1/take-checks/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
181
- "POST /v1/take-checks": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
182
- "GET /v1/film-runs/{id}": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches (#1337)." },
164
+ "POST /v1/film-drafts": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches." },
165
+ "POST /v1/film-drafts/{id}/files": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches." },
166
+ "GET /v1/film-drafts/{id}": { exposure: "excluded", reason: "Not offered yet: film drafts join the contract when their mode launches." },
167
+ "POST /v1/film-drafts/{id}/check": { exposure: "excluded", reason: "Not offered yet: the film check joins the contract with the drafts it reads." },
168
+ "POST /v1/film-stills/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
169
+ "POST /v1/film-stills": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
170
+ "POST /v1/film-voices/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
171
+ "POST /v1/film-voices": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
172
+ "POST /v1/film-renders/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
173
+ "POST /v1/film-renders": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
174
+ "POST /v1/film-heroes/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
175
+ "POST /v1/film-heroes": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
176
+ "POST /v1/film-edits/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
177
+ "POST /v1/film-edits": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
178
+ "POST /v1/take-frames/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
179
+ "POST /v1/take-frames": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
180
+ "POST /v1/take-checks/quote": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
181
+ "POST /v1/take-checks": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
182
+ "GET /v1/film-runs/{id}": { exposure: "excluded", reason: "Not offered yet: film runs join the contract when their mode launches." },
183
183
  "POST /v1/film-cuts/check": { exposure: "excluded", reason: "Offered through MCP (check_cut)." },
184
184
  "POST /v1/film-cuts/quote": { exposure: "excluded", reason: "Offered through MCP (quote_cut, render_cut)." },
185
185
  "POST /v1/film-cuts": { exposure: "excluded", reason: "Offered through MCP (quote_cut, render_cut)." },
@@ -188,12 +188,12 @@ export const OPENAPI_ROUTES = {
188
188
  "POST /v1/cuts": { exposure: "excluded", reason: "Offered through MCP (create_cut, get_cut, update_cut)." },
189
189
  "POST /v1/cuts/{id}": { exposure: "excluded", reason: "Offered through MCP (create_cut, get_cut, update_cut)." },
190
190
  "GET /v1/cuts/{id}": { exposure: "excluded", reason: "Offered through MCP (create_cut, get_cut, update_cut)." },
191
- "GET /v1/film-guide": { exposure: "excluded", reason: "Not offered yet: the film guide joins the contract when its mode launches (#1356)." },
192
- "GET /v1/film-kit": { exposure: "excluded", reason: "Not offered yet: the film kit joins the contract when its mode launches (#1356)." },
193
- "GET /v1/ad-guide": { exposure: "excluded", reason: "Not offered yet: the ad guide joins the contract when it opens to every account (#1539)." },
194
- "POST /v1/ads": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account (#1539)." },
195
- "POST /v1/ads/{id}": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account (#1539)." },
196
- "GET /v1/ads/{id}": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account (#1539)." },
191
+ "GET /v1/film-guide": { exposure: "excluded", reason: "Not offered yet: the film guide joins the contract when its mode launches." },
192
+ "GET /v1/film-kit": { exposure: "excluded", reason: "Not offered yet: the film kit joins the contract when its mode launches." },
193
+ "GET /v1/ad-guide": { exposure: "excluded", reason: "Not offered yet: the ad guide joins the contract when it opens to every account." },
194
+ "POST /v1/ads": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account." },
195
+ "POST /v1/ads/{id}": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account." },
196
+ "GET /v1/ads/{id}": { exposure: "excluded", reason: "Not offered yet: ad records join the contract with the ad guide, when it opens to every account." },
197
197
  "GET /internal/portfolio-metrics": { exposure: "excluded",
198
198
  reason: "Internal funnel aggregates behind their own secret, outside the client contract (docs/03-api.md section 12)." },
199
199
  "GET /v1/public/workflows": { exposure: "public", operationId: "listWorkflows", tag: "Workflows", anonymous: true,
@@ -1,5 +1,4 @@
1
1
  import type { AspectRatio, Resolution } from "./skills.js";
2
- import type { VendorRefusalClass } from "./vendor-response.js";
3
2
  export type AudioSource = {
4
3
  kind: "url";
5
4
  url: string;
@@ -43,9 +42,8 @@ export interface RenderBackend {
43
42
  pollAvatarJob(handle: AvatarJobHandle, options?: {
44
43
  deadlineMs: number;
45
44
  }): Promise<AvatarClipResult>;
46
- classifyRefusal(error: unknown): VendorRefusalClass;
45
+ classifyRefusal(error: unknown): "account_standing" | "vendor" | "unknown";
47
46
  }
48
- export declare function isRetryableVendorError(error: unknown): boolean;
49
47
  export declare function negotiateCapabilities(req: Pick<AvatarClipRequest, "resolution" | "aspectRatio">, caps: BackendCapabilities, backendName: string): {
50
48
  resolution: Resolution;
51
49
  aspectRatio: AspectRatio;
@@ -1,8 +1,3 @@
1
- export function isRetryableVendorError(error) {
2
- return (typeof error === "object" &&
3
- error !== null &&
4
- error.retryable === true);
5
- }
6
1
  export function negotiateCapabilities(req, caps, backendName) {
7
2
  const warnings = [];
8
3
  let resolution = req.resolution;
@@ -1,4 +1,3 @@
1
- import type { VendorRefusalClass } from "./vendor-response.js";
2
1
  export interface WordTiming {
3
2
  word: string;
4
3
  startSec: number;
@@ -27,7 +26,7 @@ export interface TtsBackend {
27
26
  readonly name: string;
28
27
  readonly capabilities: TtsCapabilities;
29
28
  synthesize(req: SpeechRequest): Promise<SpeechResult>;
30
- classifyRefusal(error: unknown): VendorRefusalClass;
29
+ classifyRefusal(error: unknown): "account_standing" | "vendor" | "unknown";
31
30
  }
32
31
  export declare function charTimingsToWords(characters: readonly string[], startTimes: readonly number[], endTimes: readonly number[]): WordTiming[];
33
32
  export declare const ALIGNMENT_TAIL_TOLERANCE_SEC = 0.1;
@@ -5,7 +5,7 @@ import { isFacelessVoiceName } from "./faceless-voices.js";
5
5
  import { filmVoiceInput } from "./own-agent-runs.js";
6
6
  import { normalizeVoiceLabel } from "./voice-catalog.js";
7
7
  import { VOICE_CATALOG } from "./voice-catalog-data.js";
8
- import { vendorVerifiedModels } from "./voice-listing.js";
8
+ import { verifiedVoiceModels } from "./voice-verified-models.js";
9
9
  import { isModelVoiceName, isVoicePresetName, MODEL_VOICES, resolveTtsModel, voicePresetOf, withPublishedPresetsOnly, } from "./voices.js";
10
10
  export function catalogVoiceRefusal(voice, voices = VOICE_CATALOG.voices, options = {}) {
11
11
  if (isVoicePresetName(voice) || isModelVoiceName(voice))
@@ -75,7 +75,7 @@ export function buildVoiceVerificationWarnings(input, gender, voices = VOICE_CAT
75
75
  if (entry === undefined)
76
76
  return [];
77
77
  const model = resolveTtsModel(input, gender);
78
- if (!vendorVerifiedModels(voices).includes(model))
78
+ if (!verifiedVoiceModels(voices).includes(model))
79
79
  return [];
80
80
  if (entry.verified_models.includes(model))
81
81
  return [];
@@ -1,9 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { type CatalogFileVoice, type TtsModelLanguagesFile, type VoiceCatalogFile, type VoicesQuery } from "./voice-catalog.js";
3
- import { TTS_MODELS, type VoiceCatalogEntry, type VoicePreset } from "./voices.js";
3
+ import { type VoiceCatalogEntry, type VoicePreset } from "./voices.js";
4
4
  export { TTS_MODEL_LANGUAGES, VOICE_CATALOG } from "./voice-catalog-data.js";
5
5
  export declare const MEASURED_MODEL_LANGUAGES: Readonly<Record<string, readonly string[]>>;
6
- export declare function vendorVerifiedModels(voices?: readonly CatalogFileVoice[]): readonly (typeof TTS_MODELS)[number][];
7
6
  export declare function serverVoicesQueryFor(voices?: readonly CatalogFileVoice[]): z.ZodObject<{
8
7
  language: z.ZodOptional<z.ZodEnum<{
9
8
  bg: "bg";
@@ -3,15 +3,13 @@ import { CATALOG_LANGUAGES, normalizeVoiceLabel, VOICES_QUERY_FIELDS, voicesQuer
3
3
  import { TTS_MODEL_LANGUAGES, VOICE_CATALOG } from "./voice-catalog-data.js";
4
4
  import { FACELESS_SPEECH_MODEL, FACELESS_VOICE_NAMES, FACELESS_VOICES } from "./faceless-voices.js";
5
5
  import { measuredPaceOf, VOICE_PACE } from "./voice-pace.js";
6
+ import { verifiedVoiceModels } from "./voice-verified-models.js";
6
7
  import { ELEVENLABS_TTS_MODELS, GOOGLE_TTS_MODEL, MODEL_VOICE_NAMES, MODEL_VOICES, resolveTtsModel, TTS_MODEL_CHAR_CAP, TTS_MODELS, VOICE_PRESETS, } from "./voices.js";
7
8
  export { TTS_MODEL_LANGUAGES, VOICE_CATALOG } from "./voice-catalog-data.js";
8
9
  const isLive = (voice) => voice.retired_at === undefined;
9
10
  export const MEASURED_MODEL_LANGUAGES = {
10
11
  [GOOGLE_TTS_MODEL]: ["en", "ru"],
11
12
  };
12
- export function vendorVerifiedModels(voices = VOICE_CATALOG.voices) {
13
- return TTS_MODELS.filter((model) => voices.some((voice) => isLive(voice) && voice.verified_models.includes(model)));
14
- }
15
13
  function labelValues(voices, raw) {
16
14
  const values = voices.filter(isLive).map((voice) => normalizeVoiceLabel(raw(voice)));
17
15
  return [...new Set(values.filter((value) => value !== undefined))].sort();
@@ -87,7 +85,7 @@ export function listVoices(query, catalog = VOICE_CATALOG, modelLanguages = TTS_
87
85
  id,
88
86
  char_limit: TTS_MODEL_CHAR_CAP[id],
89
87
  languages: languagesOf(id),
90
- vendor_verifies_voices: vendorVerifiedModels(catalog.voices).includes(id),
88
+ vendor_verifies_voices: verifiedVoiceModels(catalog.voices).includes(id),
91
89
  })),
92
90
  };
93
91
  }
@@ -0,0 +1,3 @@
1
+ import type { CatalogFileVoice } from "./voice-catalog.js";
2
+ import { TTS_MODELS } from "./voices.js";
3
+ export declare function verifiedVoiceModels(voices?: readonly CatalogFileVoice[]): readonly (typeof TTS_MODELS)[number][];
@@ -0,0 +1,5 @@
1
+ import { VOICE_CATALOG } from "./voice-catalog-data.js";
2
+ import { TTS_MODELS } from "./voices.js";
3
+ export function verifiedVoiceModels(voices = VOICE_CATALOG.voices) {
4
+ return TTS_MODELS.filter((model) => voices.some((voice) => voice.retired_at === undefined && voice.verified_models.includes(model)));
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipwright/core",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Zod schemas and the shared request/response contract of the Clipwright UGC video API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,97 +0,0 @@
1
- import { z } from "zod";
2
- declare const plan: z.ZodObject<{
3
- version: z.ZodLiteral<"faceless_image_v1">;
4
- script: z.ZodString;
5
- aspectRatio: z.ZodLiteral<"9:16">;
6
- resolution: z.ZodLiteral<"1080p">;
7
- brollPolicy: z.ZodEnum<{
8
- anyone: "anyone";
9
- no_actor: "no_actor";
10
- no_people: "no_people";
11
- }>;
12
- assets: z.ZodArray<z.ZodObject<{
13
- id: z.ZodString;
14
- role: z.ZodEnum<{
15
- character: "character";
16
- scene: "scene";
17
- style: "style";
18
- }>;
19
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
- kind: z.ZodLiteral<"supplied">;
21
- url: z.ZodURL;
22
- }, z.core.$strict>, z.ZodObject<{
23
- kind: z.ZodLiteral<"generated">;
24
- prompt: z.ZodString;
25
- styleId: z.ZodOptional<z.ZodString>;
26
- characterIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
- }, z.core.$strict>], "kind">;
28
- }, z.core.$strict>>;
29
- scenes: z.ZodArray<z.ZodObject<{
30
- id: z.ZodString;
31
- assetId: z.ZodString;
32
- durationFrames: z.ZodNumber;
33
- motion: z.ZodOptional<z.ZodObject<{
34
- direction: z.ZodEnum<{
35
- in: "in";
36
- out: "out";
37
- }>;
38
- amount: z.ZodNumber;
39
- }, z.core.$strict>>;
40
- }, z.core.$strict>>;
41
- }, z.core.$strict>;
42
- export type FacelessImagePlan = z.infer<typeof plan>;
43
- export declare function parseFacelessImagePlan(input: unknown): FacelessImagePlan;
44
- export declare function quoteFacelessImage(input: unknown): {
45
- pricingVersion: "faceless-image-v1-shadow";
46
- aspectRatio: "9:16";
47
- resolution: "1080p";
48
- outputFrames: number;
49
- outputSeconds: number;
50
- credits: number;
51
- customerCreditCeiling: number;
52
- baseGeneratedImages: number;
53
- maxGeneratedImages: number;
54
- retryHeadroom: number;
55
- costBreakdown: {
56
- generatedImages: {
57
- status: "unmeasured";
58
- usd: null;
59
- exposureBasis: "hypothetical_two_attempts_per_generated_asset_within_shared_allowance";
60
- maxPaidAttemptsPerAsset: number;
61
- maxPaidImageCalls: number;
62
- };
63
- tts: {
64
- status: "unmeasured";
65
- usd: null;
66
- };
67
- rendering: {
68
- status: "unmeasured";
69
- usd: null;
70
- };
71
- storage: {
72
- status: "unmeasured";
73
- usd: null;
74
- };
75
- paymentFees: {
76
- status: "unmeasured";
77
- usd: null;
78
- };
79
- paidFailures: {
80
- status: "unmeasured";
81
- usd: null;
82
- };
83
- };
84
- totalCostUsd: null;
85
- contributionMargin: null;
86
- costQualified: boolean;
87
- marginQualified: boolean;
88
- sceneCount: number;
89
- sceneSources: {
90
- sceneId: string;
91
- assetId: string;
92
- sourceKind: "generated" | "supplied";
93
- }[];
94
- maxPaidAttempts: 0;
95
- maxUsdSpend: 0;
96
- };
97
- export {};
@@ -1,143 +0,0 @@
1
- import { z } from "zod";
2
- import { brollPolicy } from "./broll-policy.js";
3
- import { CANVAS_FPS } from "./media-timebase.js";
4
- import { MAX_URL_LENGTH } from "./skills.js";
5
- import { DEFAULT_TTS_MODEL, speechTextFor, TTS_MODEL_CHAR_CAP } from "./voices.js";
6
- const id = z.string().min(1);
7
- const suppliedSource = z.strictObject({
8
- kind: z.literal("supplied"),
9
- url: z.url().max(MAX_URL_LENGTH).refine(url => {
10
- const source = new URL(url);
11
- return source.protocol === "https:" && /\.(png|jpe?g)$/i.test(source.pathname);
12
- }, "supplied image URL must use HTTPS with a PNG or JPEG path suffix"),
13
- });
14
- const generatedSource = z.strictObject({
15
- kind: z.literal("generated"),
16
- prompt: z.string().trim().min(1),
17
- styleId: id.optional(),
18
- characterIds: z.array(id).optional(),
19
- });
20
- const asset = z.strictObject({
21
- id,
22
- role: z.enum(["scene", "style", "character"]),
23
- source: z.discriminatedUnion("kind", [suppliedSource, generatedSource]),
24
- });
25
- const scene = z.strictObject({
26
- id,
27
- assetId: id,
28
- durationFrames: z.number().int().positive().refine(Number.isSafeInteger, "durationFrames must be a safe integer"),
29
- motion: z.strictObject({ direction: z.enum(["in", "out"]), amount: z.number().min(0).lt(1) }).optional(),
30
- });
31
- const plan = z.strictObject({
32
- version: z.literal("faceless_image_v1"),
33
- script: z.string().trim().min(1).refine(text => speechTextFor(text, DEFAULT_TTS_MODEL).length <= TTS_MODEL_CHAR_CAP[DEFAULT_TTS_MODEL], `script exceeds ${DEFAULT_TTS_MODEL} limit of ${TTS_MODEL_CHAR_CAP[DEFAULT_TTS_MODEL]} characters after stress normalization`),
34
- aspectRatio: z.literal("9:16"),
35
- resolution: z.literal("1080p"),
36
- brollPolicy,
37
- assets: z.array(asset).min(1),
38
- scenes: z.array(scene).min(1).max(100),
39
- });
40
- export function parseFacelessImagePlan(input) {
41
- const parsed = plan.parse(input);
42
- const assets = new Map();
43
- for (const entry of parsed.assets) {
44
- if (assets.has(entry.id))
45
- throw new Error(`duplicate faceless IMAGE asset ID: ${entry.id}`);
46
- if (entry.role !== "scene" && entry.source.kind === "generated" &&
47
- (entry.source.styleId !== undefined || entry.source.characterIds !== undefined)) {
48
- throw new Error(`faceless IMAGE references belong on scene assets: ${entry.id}`);
49
- }
50
- assets.set(entry.id, entry);
51
- }
52
- const used = new Set();
53
- const sceneIds = new Set();
54
- let sharedStyleId;
55
- for (const entry of parsed.scenes) {
56
- if (sceneIds.has(entry.id))
57
- throw new Error(`duplicate faceless IMAGE scene ID: ${entry.id}`);
58
- sceneIds.add(entry.id);
59
- const image = assets.get(entry.assetId);
60
- if (image?.role !== "scene")
61
- throw new Error(`faceless IMAGE scene asset missing or wrong role: ${entry.assetId}`);
62
- used.add(image.id);
63
- if (image.source.kind === "generated") {
64
- const style = image.source.styleId === undefined ? undefined : assets.get(image.source.styleId);
65
- if (style?.role !== "style")
66
- throw new Error(`faceless IMAGE style asset missing or wrong role: ${image.id}`);
67
- if (sharedStyleId !== undefined && sharedStyleId !== style.id)
68
- throw new Error("faceless IMAGE scenes require one shared style anchor");
69
- sharedStyleId = style.id;
70
- used.add(style.id);
71
- const characters = image.source.characterIds ?? [];
72
- if (parsed.brollPolicy !== "anyone" && characters.length > 0)
73
- throw new Error("character references require the anyone policy");
74
- if (new Set(characters).size !== characters.length)
75
- throw new Error(`duplicate character reference: ${image.id}`);
76
- for (const characterId of characters) {
77
- const character = assets.get(characterId);
78
- if (character?.role !== "character")
79
- throw new Error(`faceless IMAGE character asset missing or wrong role: ${characterId}`);
80
- used.add(characterId);
81
- }
82
- }
83
- }
84
- for (const entry of parsed.assets) {
85
- if (!used.has(entry.id))
86
- throw new Error(`unreferenced faceless IMAGE asset: ${entry.id}`);
87
- }
88
- const outputFrames = parsed.scenes.reduce((sum, entry) => sum + entry.durationFrames, 0);
89
- if (!Number.isSafeInteger(outputFrames) || outputFrames > 300 * CANVAS_FPS)
90
- throw new Error("faceless IMAGE exceeds 300 seconds");
91
- const maxGeneratedImages = Math.floor((24 * outputFrames) / (60 * CANVAS_FPS));
92
- const baseGeneratedImages = parsed.assets.filter(entry => entry.source.kind === "generated").length;
93
- if (baseGeneratedImages > maxGeneratedImages)
94
- throw new Error("faceless IMAGE exceeds generated image allowance");
95
- return parsed;
96
- }
97
- export function quoteFacelessImage(input) {
98
- const parsed = parseFacelessImagePlan(input);
99
- const outputFrames = parsed.scenes.reduce((sum, entry) => sum + entry.durationFrames, 0);
100
- const maxGeneratedImages = Math.floor((24 * outputFrames) / (60 * CANVAS_FPS));
101
- const baseGeneratedImages = parsed.assets.filter(entry => entry.source.kind === "generated").length;
102
- const raw = (180n * BigInt(outputFrames) + BigInt(60 * CANVAS_FPS - 1)) / BigInt(60 * CANVAS_FPS);
103
- const credits = Number(raw > 200n ? raw : 200n);
104
- const assetById = new Map(parsed.assets.map(entry => [entry.id, entry]));
105
- return {
106
- pricingVersion: "faceless-image-v1-shadow",
107
- aspectRatio: parsed.aspectRatio,
108
- resolution: parsed.resolution,
109
- outputFrames,
110
- outputSeconds: outputFrames / CANVAS_FPS,
111
- credits,
112
- customerCreditCeiling: credits,
113
- baseGeneratedImages,
114
- maxGeneratedImages,
115
- retryHeadroom: maxGeneratedImages - baseGeneratedImages,
116
- costBreakdown: {
117
- generatedImages: {
118
- status: "unmeasured",
119
- usd: null,
120
- exposureBasis: "hypothetical_two_attempts_per_generated_asset_within_shared_allowance",
121
- maxPaidAttemptsPerAsset: 2,
122
- maxPaidImageCalls: Math.min(maxGeneratedImages, 2 * baseGeneratedImages),
123
- },
124
- tts: { status: "unmeasured", usd: null },
125
- rendering: { status: "unmeasured", usd: null },
126
- storage: { status: "unmeasured", usd: null },
127
- paymentFees: { status: "unmeasured", usd: null },
128
- paidFailures: { status: "unmeasured", usd: null },
129
- },
130
- totalCostUsd: null,
131
- contributionMargin: null,
132
- costQualified: false,
133
- marginQualified: false,
134
- sceneCount: parsed.scenes.length,
135
- sceneSources: parsed.scenes.map(entry => ({
136
- sceneId: entry.id,
137
- assetId: entry.assetId,
138
- sourceKind: assetById.get(entry.assetId).source.kind,
139
- })),
140
- maxPaidAttempts: 0,
141
- maxUsdSpend: 0,
142
- };
143
- }
@@ -1,20 +0,0 @@
1
- export type VendorDispatchFact = {
2
- readonly kind: "unsent";
3
- } | {
4
- readonly kind: "responded";
5
- readonly status: number;
6
- };
7
- export declare function markVendorUnsent<E>(error: E): E;
8
- export declare function markVendorResponse<E>(error: E, status: number): E;
9
- export declare function vendorDispatchFact(error: unknown): VendorDispatchFact | undefined;
10
- export type VendorJobVerdict = "succeeded" | "failed";
11
- export declare function markVendorJobVerdict<E>(error: E, verdict: VendorJobVerdict): E;
12
- export declare function vendorJobVerdict(error: unknown): VendorJobVerdict | undefined;
13
- export declare function markVendorJobUnbilled<E>(error: E): E;
14
- export declare function vendorJobUnbilled(error: unknown): boolean;
15
- export type VendorRefusalClass = "account_standing" | "vendor" | "unknown";
16
- export declare function markVendorRefusal<E>(error: E, refusal: VendorRefusalClass): E;
17
- export declare function vendorRefusalClass(error: unknown): VendorRefusalClass;
18
- export declare function withRefusalClass<T>(backend: {
19
- classifyRefusal(error: unknown): VendorRefusalClass;
20
- }, call: () => Promise<T>): Promise<T>;
@@ -1,94 +0,0 @@
1
- const VENDOR_DISPATCH_FACT = "clipwrightVendorDispatchFact";
2
- function mark(error, fact) {
3
- if (typeof error !== "object" || error === null) {
4
- return error;
5
- }
6
- Object.defineProperty(error, VENDOR_DISPATCH_FACT, {
7
- value: fact,
8
- enumerable: false,
9
- writable: false,
10
- configurable: true,
11
- });
12
- return error;
13
- }
14
- export function markVendorUnsent(error) {
15
- return mark(error, { kind: "unsent" });
16
- }
17
- export function markVendorResponse(error, status) {
18
- return mark(error, { kind: "responded", status });
19
- }
20
- export function vendorDispatchFact(error) {
21
- if (typeof error !== "object" || error === null) {
22
- return undefined;
23
- }
24
- const value = error[VENDOR_DISPATCH_FACT];
25
- if (typeof value !== "object" || value === null) {
26
- return undefined;
27
- }
28
- const fact = value;
29
- if (fact.kind === "unsent") {
30
- return { kind: "unsent" };
31
- }
32
- if (fact.kind === "responded" && typeof fact.status === "number") {
33
- return { kind: "responded", status: fact.status };
34
- }
35
- return undefined;
36
- }
37
- const VENDOR_JOB_VERDICT = "clipwrightVendorJobVerdict";
38
- export function markVendorJobVerdict(error, verdict) {
39
- if (typeof error !== "object" || error === null) {
40
- return error;
41
- }
42
- Object.defineProperty(error, VENDOR_JOB_VERDICT, {
43
- value: verdict,
44
- enumerable: false,
45
- writable: false,
46
- configurable: true,
47
- });
48
- return error;
49
- }
50
- export function vendorJobVerdict(error) {
51
- if (typeof error !== "object" || error === null) {
52
- return undefined;
53
- }
54
- const value = error[VENDOR_JOB_VERDICT];
55
- return value === "succeeded" || value === "failed" ? value : undefined;
56
- }
57
- const VENDOR_JOB_UNBILLED = "clipwrightVendorJobUnbilled";
58
- export function markVendorJobUnbilled(error) {
59
- if (typeof error !== "object" || error === null)
60
- return error;
61
- Object.defineProperty(error, VENDOR_JOB_UNBILLED, { value: true, enumerable: false, writable: false, configurable: true });
62
- return error;
63
- }
64
- export function vendorJobUnbilled(error) {
65
- return typeof error === "object" && error !== null && error[VENDOR_JOB_UNBILLED] === true;
66
- }
67
- const VENDOR_REFUSAL_CLASS = "clipwrightVendorRefusalClass";
68
- export function markVendorRefusal(error, refusal) {
69
- if (typeof error !== "object" || error === null) {
70
- return error;
71
- }
72
- Object.defineProperty(error, VENDOR_REFUSAL_CLASS, {
73
- value: refusal,
74
- enumerable: false,
75
- writable: false,
76
- configurable: true,
77
- });
78
- return error;
79
- }
80
- export function vendorRefusalClass(error) {
81
- if (typeof error !== "object" || error === null) {
82
- return "unknown";
83
- }
84
- const value = error[VENDOR_REFUSAL_CLASS];
85
- return value === "account_standing" || value === "vendor" ? value : "unknown";
86
- }
87
- export async function withRefusalClass(backend, call) {
88
- try {
89
- return await call();
90
- }
91
- catch (error) {
92
- throw markVendorRefusal(error, backend.classifyRefusal(error));
93
- }
94
- }