@clipwright/core 0.69.0 → 0.71.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.
@@ -147,6 +147,7 @@ export interface AgentFailureReport {
147
147
  }
148
148
  export declare const TAKE_UNCHECKED_NEXT_ACTION: string;
149
149
  export declare const UPLOAD_NOT_FINISHED_NEXT_ACTION: string;
150
+ export declare const ASSET_NOT_READY_NEXT_ACTION: string;
150
151
  export declare const UNAUTHORIZED_NEXT_ACTION: string;
151
152
  export declare function refusalNextAction(next: DiyNext): string;
152
153
  export declare function agentFailureReport(failure: ApiFailure): AgentFailureReport;
@@ -264,6 +264,8 @@ export const TAKE_UNCHECKED_NEXT_ACTION = "Do not render yet: each clip the mess
264
264
  export const UPLOAD_NOT_FINISHED_NEXT_ACTION = "Finish the upload first: PUT the file to the put_url from create_upload with the given put_headers, confirm it " +
265
265
  "with get_upload, then repeat this call. If the message says the upload is finishing, the file is already there: " +
266
266
  "wait a few seconds and repeat. Nothing was charged and no run was created.";
267
+ export const ASSET_NOT_READY_NEXT_ACTION = "Wait for the asset the message names: call get_asset with its id until its state is ready, then repeat this same call unchanged. " +
268
+ "If get_asset says it failed, create the asset again. Nothing was charged and no run was created.";
267
269
  export const UNAUTHORIZED_NEXT_ACTION = "STOP. Clipwright did not accept this connection's key or sign-in: it is missing, mistyped or revoked. Nothing was " +
268
270
  `charged. With a key, the human creates a new one at ${PUBLIC_APP_BASE_URL}/api-keys (a new account at ` +
269
271
  `${PUBLIC_APP_BASE_URL}/auth/sign-up comes with trial credits), puts it in the MCP server's environment as ` +
@@ -433,6 +435,15 @@ export function agentFailureReport(failure) {
433
435
  : "STOP. Read the plan and address every issue before purchase. Save the corrected document, obtain approval of its exact revision, then quote it. Approval and a paid launch are separate explicit actions; do not perform them automatically.",
434
436
  };
435
437
  case "client_error":
438
+ if (failure.status === 409 && (failure.code === "film_asset_not_ready" || failure.code === "asset_not_ready"))
439
+ return {
440
+ ...base,
441
+ status: "RETRY_LATER",
442
+ code: failure.code,
443
+ retryable: true,
444
+ ...(failure.next && { next: failure.next }),
445
+ next_action: ASSET_NOT_READY_NEXT_ACTION,
446
+ };
436
447
  return {
437
448
  ...base,
438
449
  status: "FAILED",
package/dist/errors.d.ts CHANGED
@@ -271,7 +271,7 @@ export type EditCeilingReachedError = z.infer<typeof editCeilingReachedError>;
271
271
  export declare function editCeilingReachedBody(args: Omit<EditCeilingReachedError["error"], "code" | "message">, counting?: "revision" | "candidate"): EditCeilingReachedError;
272
272
  export declare function unusableSourceMessage(errorClass: string, detail: string): string;
273
273
  export declare const MALFORMED_BODY_MESSAGE: string;
274
- declare const BARE_ERROR_CODES: readonly ["analysis_enqueue_failed", "aspect_conflict", "actor_unavailable", "actor_format_unavailable", "actor_storage_unavailable", "actor_generation_disabled", "actor_in_use", "ad_limited", "ad_not_found", "ad_slot_in_use", "ad_slot_unchecked", "asset_cap_exceeded", "asset_ingest_cap_exceeded", "asset_not_found", "asset_not_ready", "assets_disabled", "creator_profile_limited", "creator_profile_not_found", "creator_url_unsupported", "cut_limited", "cut_not_found", "cut_preview_limited", "cut_slot_in_use", "deletion_held", "editing_window_not_set", "explainer_busy", "feedback_limited", "film_draft_limited", "film_draft_not_found", "film_draft_stale", "film_hero_limited", "film_run_not_found", "film_voice_not_ready", "generations_disabled", "generations_marking_pending", "idempotency_key_required", "idempotency_key_reused", "ingest_enqueue_failed", "insufficient_scope", "internal_error", "invalid_image", "invalid_request", "malformed_body", "no_changes", "not_found", "own_agent_disabled", "own_agent_marking_pending", "paid_render_disabled", "payload_too_large", "reference_analysis_disabled", "reference_analysis_limited", "reference_analysis_not_found", "reference_not_analyzable", "reference_not_usable", "reference_url_unsupported", "revision_needs_generated_unit", "rights_not_confirmed", "run_media_in_use", "run_not_finished", "run_not_found", "source_aspect_mismatch", "source_not_usable", "take_check_limited", "take_frames_limited", "trend_page_unavailable", "trend_search_limited", "trend_search_not_found", "trends_unavailable", "unauthorized", "unsupported_combination", "unsupported_media_type", "unusable_source", "upload_cap_exceeded", "upload_digest_mismatch", "upload_expired", "upload_in_use", "upload_not_finished", "upload_size_mismatch", "upstream_error", "url_fetch_busy", "url_fetch_failed", "url_fetch_rate_limited", "url_fetch_refused", "url_import_disabled"];
274
+ declare const BARE_ERROR_CODES: readonly ["analysis_enqueue_failed", "aspect_conflict", "actor_unavailable", "actor_format_unavailable", "actor_storage_unavailable", "actor_generation_disabled", "actor_in_use", "ad_limited", "ad_not_found", "ad_slot_in_use", "ad_slot_unchecked", "asset_cap_exceeded", "asset_ingest_cap_exceeded", "asset_not_found", "asset_not_ready", "assets_disabled", "creator_profile_limited", "creator_profile_not_found", "creator_url_unsupported", "cut_limited", "cut_not_found", "cut_preview_limited", "cut_slot_in_use", "deletion_held", "editing_window_not_set", "explainer_busy", "feedback_limited", "film_asset_not_ready", "film_draft_limited", "film_draft_not_found", "film_draft_stale", "film_hero_limited", "film_run_not_found", "film_voice_not_ready", "generations_disabled", "generations_marking_pending", "idempotency_key_required", "idempotency_key_reused", "ingest_enqueue_failed", "insufficient_scope", "internal_error", "invalid_image", "invalid_request", "malformed_body", "no_changes", "not_found", "own_agent_disabled", "own_agent_marking_pending", "paid_render_disabled", "payload_too_large", "reference_analysis_disabled", "reference_analysis_limited", "reference_analysis_not_found", "reference_not_analyzable", "reference_not_usable", "reference_url_unsupported", "revision_needs_generated_unit", "rights_not_confirmed", "run_media_in_use", "run_not_finished", "run_not_found", "source_aspect_mismatch", "source_not_usable", "take_check_limited", "take_frames_limited", "trend_page_unavailable", "trend_search_limited", "trend_search_not_found", "trends_unavailable", "unauthorized", "unsupported_combination", "unsupported_media_type", "unusable_source", "upload_cap_exceeded", "upload_digest_mismatch", "upload_expired", "upload_in_use", "upload_not_finished", "upload_size_mismatch", "upstream_error", "url_fetch_busy", "url_fetch_failed", "url_fetch_rate_limited", "url_fetch_refused", "url_import_disabled"];
275
275
  export type BareApiErrorCode = (typeof BARE_ERROR_CODES)[number];
276
276
  export declare const API_ERROR_CODES: readonly string[];
277
277
  export declare function apiErrorBody(args: {
package/dist/errors.js CHANGED
@@ -322,6 +322,7 @@ const BARE_ERROR_CODES = [
322
322
  "editing_window_not_set",
323
323
  "explainer_busy",
324
324
  "feedback_limited",
325
+ "film_asset_not_ready",
325
326
  "film_draft_limited",
326
327
  "film_draft_not_found",
327
328
  "film_draft_stale",
@@ -91,6 +91,7 @@ export declare const FILM_EDIT_CAPTION_POSITIONS: readonly ["top", "middle", "bo
91
91
  export declare const FILM_EDIT_CAPTION_STYLES: readonly ["outline", "banner", "badge"];
92
92
  export declare const FILM_EDIT_CAPTION_ALIGNS: readonly ["center", "left"];
93
93
  export declare const EDIT_CLIP_MIN_VOLUME_DB = -24, EDIT_CLIP_MAX_VOLUME_DB = 3;
94
+ export declare const EDIT_AMBIENCE_MIN_VOLUME_DB = -40, EDIT_AMBIENCE_MAX_VOLUME_DB = -18, EDIT_AMBIENCE_DEFAULT_VOLUME_DB = -20, EDIT_AMBIENCE_MIN_SPAN_SEC = 1;
94
95
  export declare const filmEditInput: z.ZodObject<{
95
96
  clips: z.ZodArray<z.ZodObject<{
96
97
  run_id: z.ZodOptional<z.ZodString>;
@@ -196,6 +197,13 @@ export declare const filmEditInput: z.ZodObject<{
196
197
  fade_out: z.ZodDefault<z.ZodNumber>;
197
198
  duck: z.ZodOptional<z.ZodBoolean>;
198
199
  }, z.core.$strict>>;
200
+ ambience: z.ZodOptional<z.ZodObject<{
201
+ run_id: z.ZodOptional<z.ZodString>;
202
+ asset_id: z.ZodOptional<z.ZodString>;
203
+ from: z.ZodNumber;
204
+ to: z.ZodNumber;
205
+ volume: z.ZodDefault<z.ZodNumber>;
206
+ }, z.core.$strict>>;
199
207
  ad_id: z.ZodOptional<z.ZodString>;
200
208
  max_credits: z.ZodOptional<z.ZodNumber>;
201
209
  }, z.core.$strict>;
@@ -212,8 +220,8 @@ export declare const TAKE_MOTION_TARGETS: Record<TakeMotionFormat, {
212
220
  }>;
213
221
  export declare const TAKE_SHAKE_LIMIT = 4;
214
222
  export declare const takeFramesInput: z.ZodObject<{
215
- run_id: z.ZodOptional<z.ZodString>;
216
223
  asset_id: z.ZodOptional<z.ZodString>;
224
+ run_id: z.ZodOptional<z.ZodString>;
217
225
  fps: z.ZodDefault<z.ZodNumber>;
218
226
  from: z.ZodOptional<z.ZodNumber>;
219
227
  to: z.ZodOptional<z.ZodNumber>;
@@ -270,7 +278,12 @@ export declare const takeCheckInput: z.ZodObject<{
270
278
  rights_confirmed: z.ZodOptional<z.ZodBoolean>;
271
279
  asset_id: z.ZodOptional<z.ZodString>;
272
280
  }, z.core.$strict>>;
273
- product_image: z.ZodOptional<z.ZodString>;
281
+ product_image: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
282
+ run_id: z.ZodOptional<z.ZodString>;
283
+ upload_id: z.ZodOptional<z.ZodString>;
284
+ rights_confirmed: z.ZodOptional<z.ZodBoolean>;
285
+ asset_id: z.ZodOptional<z.ZodString>;
286
+ }, z.core.$strict>]>>;
274
287
  moves: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
275
288
  ad_id: z.ZodOptional<z.ZodString>;
276
289
  cut_id: z.ZodOptional<z.ZodString>;
@@ -88,6 +88,18 @@ const editClip = z.strictObject({
88
88
  .refine(clip => clip.sound !== true || clip.run_id !== undefined, { path: ["sound"], message: "a clip's own sound is kept only from a generate_video run made with audio: true" })
89
89
  .refine(clip => clip.sound !== true || clip.speed === 1, { path: ["sound"], message: "a clip's own sound plays at speed 1 only" })
90
90
  .refine(clip => clip.sound === true || (clip.speech === undefined && clip.volume === undefined), { path: ["sound"], message: "speech and volume describe a clip's own sound: they need sound: true" });
91
+ export const EDIT_AMBIENCE_MIN_VOLUME_DB = -40, EDIT_AMBIENCE_MAX_VOLUME_DB = -18, EDIT_AMBIENCE_DEFAULT_VOLUME_DB = -20, EDIT_AMBIENCE_MIN_SPAN_SEC = 1;
92
+ const editAmbience = z.strictObject({
93
+ run_id: runId.optional().describe("A delivered generate_video run of this account made with audio: true, whose own sound is the place's"),
94
+ asset_id: assetId.optional().describe("Instead of run_id: a video asset of this account with its own sound"),
95
+ from: editSecond.describe("The second of the clip the room sound starts at"),
96
+ to: editSecond.describe(`The second of the clip it ends at, at least ${EDIT_AMBIENCE_MIN_SPAN_SEC} s after from: a stretch with no one speaking ` +
97
+ "and no sharp sound in it"),
98
+ volume: z.number().min(EDIT_AMBIENCE_MIN_VOLUME_DB).max(EDIT_AMBIENCE_MAX_VOLUME_DB).default(EDIT_AMBIENCE_DEFAULT_VOLUME_DB)
99
+ .describe(`dB from the level of speech: ${EDIT_AMBIENCE_DEFAULT_VOLUME_DB} (the default) is a quiet room under the voice, ` +
100
+ `${EDIT_AMBIENCE_MAX_VOLUME_DB} the loudest`),
101
+ }).refine(a => (a.run_id === undefined) !== (a.asset_id === undefined), "name the room sound by run_id or by asset_id, one of them")
102
+ .refine(a => a.to - a.from >= EDIT_AMBIENCE_MIN_SPAN_SEC - 1e-9, { path: ["to"], message: `the room sound is taken from at least ${EDIT_AMBIENCE_MIN_SPAN_SEC} s: to must be that far after from` });
91
103
  const voicePiece = z.strictObject({
92
104
  from: editSecond.describe("The second of the take the piece starts at (make_voice words give each word's start and end)"),
93
105
  to: editSecond.describe("The second of the take the piece ends at, after from"),
@@ -126,6 +138,9 @@ export const filmEditInput = z.strictObject({
126
138
  .describe("Seconds the last frame is held at the end, for the packshot"),
127
139
  music: editMusic.optional().describe("Music from at to the end: a library track (free) or one made for the cut (paid on delivery); " +
128
140
  "under a voice it plays lower"),
141
+ ambience: editAmbience.optional().describe("Free: the place's quiet room sound, a stretch of one of your clips' own sound repeated " +
142
+ "smoothly under the whole cut whatever its windows and their speed, so every window can play silent and sped up. It never lowers the " +
143
+ "music and the voice stays on top of it; it goes with a voice, music or a clip's own sound"),
129
144
  ad_id: adId.optional().describe("The ad record this cut belongs to: every clip then names its slot, and a clip made with generate_video " +
130
145
  "that has not passed check_take in its slot is refused before any credits, unless the slot is people_only; your own footage needs no check"),
131
146
  max_credits: maxCreditsField,
@@ -148,6 +163,8 @@ const oneTake = (take) => (take.run_id === undefined) !== (take.asset_id === und
148
163
  const ONE_TAKE = "name the take by run_id or by asset_id, one of them";
149
164
  export const takeFramesInput = z.strictObject({
150
165
  ...takeSource,
166
+ run_id: runId.optional().describe("The take: a delivered generate_video run of this account, or a delivered render_edit run to read the " +
167
+ "finished edit"),
151
168
  fps: z.number().int().min(TAKE_FRAMES_MIN_FPS).max(TAKE_FRAMES_MAX_FPS).default(TAKE_FRAMES_DEFAULT_FPS)
152
169
  .describe("Frames a second: 8 to read the whole take, 12 to 24 on a contact"),
153
170
  from: takeSecond.optional().describe("The second of the take the frames start at; omitted, its start"),
@@ -183,8 +200,9 @@ export const takeCheckInput = z.strictObject({
183
200
  .describe("With against picture: the look a colour outside it is named against"),
184
201
  picture: filmCutPicture.optional().describe("With against picture: the picture the take is checked against; needed only when the take " +
185
202
  "was not made from a first frame, and it must be that first frame when it was"),
186
- product_image: qualifiedImageUrl.optional()
187
- .describe("https picture of the product as it really is (your upload or a saved asset): the take's product is compared with it"),
203
+ product_image: z.union([qualifiedImageUrl, filmCutPicture]).optional()
204
+ .describe("The product as it really is, the take's product compared with it: an https link to your upload or a saved asset, or the " +
205
+ "picture by run_id (a delivered generate_image run of this account, such as a product sheet), upload_id or asset_id"),
188
206
  moves: z.array(takeSecond).max(TAKE_CHECK_MAX_MOVES).optional()
189
207
  .describe("Seconds of the take where a hand meets the product (a grip, a lid, a set-down): looked at first"),
190
208
  ad_id: adId.optional().describe("With slot: the ad record the verdict joins, as a take of that slot"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipwright/core",
3
- "version": "0.69.0",
3
+ "version": "0.71.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",