@clipwright/core 0.75.1 → 0.76.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/api-failure.js +2 -1
- package/dist/assets.d.ts +2 -0
- package/dist/assets.js +3 -1
- package/dist/endpoint-notes.js +9 -6
- package/dist/endpoints.js +2 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +4 -2
- package/dist/openapi.js +5 -1
- package/dist/prices.js +8 -3
- package/dist/reference-analysis.d.ts +58 -3
- package/dist/reference-analysis.js +80 -19
- package/dist/reference-display.d.ts +3 -2
- package/dist/reference-display.js +13 -2
- package/dist/reference-profile.js +11 -9
- package/dist/reference-staging.d.ts +1 -0
- package/dist/reference-staging.js +6 -5
- package/dist/skills.js +4 -1
- package/dist/trend-search.d.ts +1 -0
- package/dist/trend-search.js +6 -1
- package/dist/uploads.d.ts +26 -0
- package/dist/uploads.js +28 -4
- package/package.json +1 -1
package/dist/api-failure.js
CHANGED
|
@@ -255,7 +255,8 @@ function messageFromStatus(status, bodyText) {
|
|
|
255
255
|
}
|
|
256
256
|
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 " +
|
|
257
257
|
"with get_upload, then repeat this call. If the message says the upload is finishing, the file is already there: " +
|
|
258
|
-
"wait a few seconds and repeat.
|
|
258
|
+
"wait a few seconds and repeat. If the upload came from an upload page link, the photo has not been dropped yet; " +
|
|
259
|
+
"get_upload returns it once the user has dropped it. Nothing was charged and no run was created.";
|
|
259
260
|
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. " +
|
|
260
261
|
"If get_asset says it failed, create the asset again. Nothing was charged and no run was created.";
|
|
261
262
|
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 " +
|
package/dist/assets.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare const ASSET_TOOL_PAGE = 8;
|
|
|
18
18
|
export declare const ASSET_TOOL_ANSWER_CHARS = 12000;
|
|
19
19
|
export declare const ASSET_VIDEO_MAX_BYTES: number;
|
|
20
20
|
export declare const ASSET_VIDEO_MAX_SECONDS = 120;
|
|
21
|
+
export declare const ANALYSIS_VIDEO_MAX_SECONDS = 180;
|
|
22
|
+
export declare const assetVideoMaxSeconds: (analysisOnly: boolean) => number;
|
|
21
23
|
export declare const ASSET_VIDEO_CODECS: readonly ["h264", "hevc"];
|
|
22
24
|
export declare const ASSET_BYTES_ROUTE_VIDEO_MAX_BYTES: number;
|
|
23
25
|
export declare const ASSET_PROCESSING_SECONDS = 600;
|
package/dist/assets.js
CHANGED
|
@@ -21,6 +21,8 @@ export const ASSET_TOOL_PAGE = 8;
|
|
|
21
21
|
export const ASSET_TOOL_ANSWER_CHARS = 12_000;
|
|
22
22
|
export const ASSET_VIDEO_MAX_BYTES = 100 * 1024 * 1024;
|
|
23
23
|
export const ASSET_VIDEO_MAX_SECONDS = 120;
|
|
24
|
+
export const ANALYSIS_VIDEO_MAX_SECONDS = 180;
|
|
25
|
+
export const assetVideoMaxSeconds = (analysisOnly) => (analysisOnly ? ANALYSIS_VIDEO_MAX_SECONDS : ASSET_VIDEO_MAX_SECONDS);
|
|
24
26
|
export const ASSET_VIDEO_CODECS = ["h264", "hevc"];
|
|
25
27
|
export const ASSET_BYTES_ROUTE_VIDEO_MAX_BYTES = 32 * 1024 * 1024;
|
|
26
28
|
export const ASSET_PROCESSING_SECONDS = 600;
|
|
@@ -207,7 +209,7 @@ export const CREATE_ASSET_DESCRIPTION = "Save a picture or a clip as an asset of
|
|
|
207
209
|
"(state \"processing\" or \"awaiting_upload\"; get_asset says ready or failed within minutes). For your own material " +
|
|
208
210
|
"pass rights_confirmed: true, stating once that you may use the people and works in it. A reference only to analyse, " +
|
|
209
211
|
"such as someone else's ad for analyze_reference, takes analysis_only: true instead: no rights claim, and no render " +
|
|
210
|
-
|
|
212
|
+
`or generation ever takes it; such a clip may run up to ${ANALYSIS_VIDEO_MAX_SECONDS} seconds. A picture's {asset_id} is a generation reference or frame (quote_image says how); a clip ` +
|
|
211
213
|
"is not one yet. " + ASSET_TOOL_TERMS;
|
|
212
214
|
export const LIST_ASSETS_DESCRIPTION = "List the assets of this account, newest first, each with a freshly signed url, its role, name, size and " +
|
|
213
215
|
`content_digest; ${ASSET_TOOL_PAGE} a page unless you pass limit (up to ${ASSET_LIST_MAX_LIMIT}), and fewer when the page would not fit ` +
|
package/dist/endpoint-notes.js
CHANGED
|
@@ -4,7 +4,7 @@ import { REVISION_CHARGE_TEXT } from "./edit-revision.js";
|
|
|
4
4
|
import { CREATOR_PROFILE_CREDITS, CREATOR_PROFILE_PER_HOUR, CREATOR_PROFILE_VIDEOS } from "./creator-profile.js";
|
|
5
5
|
import { TREND_FREE_PAGES_PER_DAY, TREND_FREE_SEARCHES_PER_MONTH, TREND_PAGE_PAID_CREDITS, TREND_PAGE_WINDOW_SECONDS, TREND_SEARCH_CREDITS, TREND_SEARCH_MAX_PAGES, TREND_SEARCH_PER_HOUR, TREND_SEARCH_REELS, } from "./trend-search.js";
|
|
6
6
|
import { FEEDBACK_PER_HOUR } from "./feedback.js";
|
|
7
|
-
import {
|
|
7
|
+
import { REFERENCE_ANALYSIS_MAX_SECONDS, REFERENCE_ANALYSIS_PER_HOUR, REFERENCE_DATA_CREDITS, REFERENCE_DATA_PER_HOUR, referenceAnalysisPriceRange } from "./reference-analysis.js";
|
|
8
8
|
export const ENDPOINT_NOTES = {
|
|
9
9
|
"GET /v1/public/workflows": "Lists public workflow methods and whether each is available now, without account plans or an account admission claim.",
|
|
10
10
|
"GET /v1/public/workflows/{id}": "Reads a method's guidance, limitations and what it can do right now.",
|
|
@@ -54,6 +54,8 @@ export const ENDPOINT_NOTES = {
|
|
|
54
54
|
"GET /v1/uploads": "Your uploads a revision still takes, newest first and one per picture, each with upload_id, the original content_digest, a freshly signed url and the moment it stops being usable. Free.",
|
|
55
55
|
"POST /v1/uploads/import": "Downloads a public https PNG or JPEG (up to 10 MB, 20 seconds, 3 redirects) and returns the same upload shape. Private addresses are refused; 30 downloads per hour per account. Free.",
|
|
56
56
|
"POST /v1/uploads/intents": "Returns a presigned PUT url for a local PNG or JPEG of the declared type, size and sha256. The upload_id is usable once the PUT lands; before that generations answer upload_not_finished. Free.",
|
|
57
|
+
"POST /v1/uploads/pages": "Returns an upload_id and a page_url for a person to open in a browser and drop one photo (PNG or JPEG; other phone photos are converted). Use it when the photo is with the user and you cannot send it. The link takes one photo and expires after 30 minutes; read the upload with GET /v1/uploads/{id}. Free; counts toward 200 uploads per day.",
|
|
58
|
+
"POST /v1/public/upload-pages/{token}": "The upload page sends the person's photo here under its link, with no API key. Agents do not call it: they read the upload with GET /v1/uploads/{id}. Free.",
|
|
57
59
|
"GET /v1/uploads/{id}": "One upload with a freshly signed url and its usable_until. After a presigned PUT it confirms the file: upload_not_finished until it is there, upload_expired after 24 hours. Free.",
|
|
58
60
|
"DELETE /v1/uploads/{id}": `Deletes an upload: no call takes it from now on, and its file is erased from storage after ${ASSET_DELETE_GRACE_DAYS} days unless another upload of the same picture is kept. Refused with upload_in_use while an unfinished run uses it. Free.`,
|
|
59
61
|
"POST /v1/assets": "Saves a picture as an account asset, kept until you delete it: from a run_id, an upload_id, a public https url or base64. Your own material needs rights_confirmed: true, or analysis_only: true for a reference kept for analyze_reference alone, which no render or generation takes. 2000 assets and 1 GB per account, 20 GB once it has bought credits as a pack or a plan, 100 new ones per day. Free.",
|
|
@@ -62,11 +64,12 @@ export const ENDPOINT_NOTES = {
|
|
|
62
64
|
"GET /v1/assets/{id}": "One live asset with a link signed for an hour. Free.",
|
|
63
65
|
"POST /v1/assets/{id}": "Renames an asset or changes its role. Free.",
|
|
64
66
|
"DELETE /v1/assets/{id}": "Deletes an asset: it leaves the list and generations at once, and a daily cleanup removes its file once 7 days have passed. Free.",
|
|
65
|
-
"POST /v1/reference-analyses/quote": `Prices an analysis of this asset or link: ${
|
|
66
|
-
|
|
67
|
-
"POST /v1/reference-analyses":
|
|
68
|
-
"
|
|
69
|
-
|
|
67
|
+
"POST /v1/reference-analyses/quote": `Prices an analysis of this asset or link: ${referenceAnalysisPriceRange()} (the most for a link of unknown length), ` +
|
|
68
|
+
`${REFERENCE_DATA_CREDITS} with mode data, or 0 when its live analysis in that mode would answer. Charges nothing.`,
|
|
69
|
+
"POST /v1/reference-analyses": `Starts reading an MP4 asset or a reel, up to ${REFERENCE_ANALYSIS_MAX_SECONDS.full} s, into a reference profile (or, with mode data, ` +
|
|
70
|
+
"its transcript, hook, scenes and frames) and " +
|
|
71
|
+
"answers at once; the same asset in the same mode answers the same analysis for free. Price: " +
|
|
72
|
+
`${referenceAnalysisPriceRange()} (${REFERENCE_DATA_CREDITS} for data), held at the start and charged once it succeeds, the most for a link of unknown length; a failed one costs nothing. ` +
|
|
70
73
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per hour.`,
|
|
71
74
|
"GET /v1/reference-analyses/{id}": "One reference analysis: queued, analyzing, succeeded with reference_profile or data and warnings, or failed with its error. Free.",
|
|
72
75
|
"POST /v1/creator-profiles/quote": `Prices a creator profile for this link: ${CREATOR_PROFILE_CREDITS} credits, or 0 when a profile of the same creator from the last hour ` +
|
package/dist/endpoints.js
CHANGED
|
@@ -72,6 +72,8 @@ export const API_ENDPOINTS = [
|
|
|
72
72
|
{ method: "GET", path: "/v1/uploads", billed: false, onQuickstart: false, jsonBody: false, cabinet: true, mcp: false },
|
|
73
73
|
{ method: "POST", path: "/v1/uploads/import", billed: false, onQuickstart: false, jsonBody: true, cabinet: false, mcp: true },
|
|
74
74
|
{ method: "POST", path: "/v1/uploads/intents", billed: false, onQuickstart: false, jsonBody: true, cabinet: false, mcp: true },
|
|
75
|
+
{ method: "POST", path: "/v1/uploads/pages", billed: false, onQuickstart: false, jsonBody: true, cabinet: false, mcp: true },
|
|
76
|
+
{ method: "POST", path: "/v1/public/upload-pages/:token", billed: false, onQuickstart: false, jsonBody: false, cabinet: false, mcp: false },
|
|
75
77
|
{ method: "GET", path: "/v1/uploads/:id", billed: false, onQuickstart: false, jsonBody: false, cabinet: true, mcp: true },
|
|
76
78
|
{ method: "DELETE", path: "/v1/uploads/:id", billed: false, onQuickstart: false, jsonBody: false, cabinet: false, mcp: true },
|
|
77
79
|
{ method: "POST", path: ASSETS_PATH, billed: false, onQuickstart: false, jsonBody: true, cabinet: true, mcp: true },
|
package/dist/errors.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export type MaxCreditsExceededError = z.infer<typeof maxCreditsExceededError>;
|
|
|
52
52
|
export declare function maxCreditsExceededBody(args: {
|
|
53
53
|
holdCredits: number;
|
|
54
54
|
maxCredits: number;
|
|
55
|
+
note?: string | undefined;
|
|
55
56
|
}): MaxCreditsExceededError;
|
|
56
57
|
export declare const debtOutstandingError: z.ZodObject<{
|
|
57
58
|
error: z.ZodObject<{
|
|
@@ -71,6 +72,7 @@ export type AccountNotAdmittedError = z.infer<typeof accountNotAdmittedError>;
|
|
|
71
72
|
export declare function insufficientCreditsBody(args: {
|
|
72
73
|
balanceCredits: number;
|
|
73
74
|
requiredCredits: number;
|
|
75
|
+
note?: string | undefined;
|
|
74
76
|
}): InsufficientCreditsError;
|
|
75
77
|
export declare function creditsNeededSentence(args: {
|
|
76
78
|
balanceCredits: number;
|
|
@@ -244,7 +246,7 @@ export type EditCeilingReachedError = z.infer<typeof editCeilingReachedError>;
|
|
|
244
246
|
export declare function editCeilingReachedBody(args: Omit<EditCeilingReachedError["error"], "code" | "message">, counting?: "revision" | "candidate"): EditCeilingReachedError;
|
|
245
247
|
export declare function unusableSourceMessage(errorClass: string, detail: string): string;
|
|
246
248
|
export declare const MALFORMED_BODY_MESSAGE: string;
|
|
247
|
-
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_busy", "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"];
|
|
249
|
+
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_busy", "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_page_rate_limited", "upload_page_used", "upload_size_mismatch", "upstream_error", "url_fetch_busy", "url_fetch_failed", "url_fetch_rate_limited", "url_fetch_refused", "url_import_disabled"];
|
|
248
250
|
export type BareApiErrorCode = (typeof BARE_ERROR_CODES)[number];
|
|
249
251
|
export declare const API_ERROR_CODES: readonly string[];
|
|
250
252
|
export declare function apiErrorBody(args: {
|
package/dist/errors.js
CHANGED
|
@@ -35,7 +35,7 @@ export function maxCreditsExceededBody(args) {
|
|
|
35
35
|
code: "max_credits_exceeded",
|
|
36
36
|
message: `This call reserves ${args.holdCredits} credits, above its max_credits of ${args.maxCredits}. ` +
|
|
37
37
|
"Nothing was charged and no run was created. Ask the person to approve the higher amount and retry with max_credits " +
|
|
38
|
-
`of at least ${args.holdCredits}, or change the request to cost less
|
|
38
|
+
`of at least ${args.holdCredits}, or change the request to cost less.` + (args.note === undefined ? "" : ` ${args.note}`),
|
|
39
39
|
hold_credits: args.holdCredits,
|
|
40
40
|
max_credits: args.maxCredits,
|
|
41
41
|
},
|
|
@@ -59,7 +59,7 @@ export function insufficientCreditsBody(args) {
|
|
|
59
59
|
error: {
|
|
60
60
|
code: "insufficient_credits",
|
|
61
61
|
message: `${creditsNeededSentence(args)} ` +
|
|
62
|
-
"Top up the balance and retry; nothing was charged and no run was created.",
|
|
62
|
+
"Top up the balance and retry; nothing was charged and no run was created." + (args.note === undefined ? "" : ` ${args.note}`),
|
|
63
63
|
balance_credits: args.balanceCredits,
|
|
64
64
|
required_credits: args.requiredCredits,
|
|
65
65
|
},
|
|
@@ -363,6 +363,8 @@ const BARE_ERROR_CODES = [
|
|
|
363
363
|
"upload_expired",
|
|
364
364
|
"upload_in_use",
|
|
365
365
|
"upload_not_finished",
|
|
366
|
+
"upload_page_rate_limited",
|
|
367
|
+
"upload_page_used",
|
|
366
368
|
"upload_size_mismatch",
|
|
367
369
|
"upstream_error",
|
|
368
370
|
"url_fetch_busy",
|
package/dist/openapi.js
CHANGED
|
@@ -37,7 +37,7 @@ import { runId, runQuery } from "./runs.js";
|
|
|
37
37
|
import { quoteResponse } from "./skills.js";
|
|
38
38
|
import { templateSoundsList } from "./templates/sounds.js";
|
|
39
39
|
import { motionMovesList, motionMovesQuery } from "./moves.js";
|
|
40
|
-
import { UPLOAD_MEDIA_TYPES, uploadId, uploadImportRequest, uploadIntentRequest, uploadIntentResponse, uploadItemResponse, uploadList, uploadResponse, } from "./uploads.js";
|
|
40
|
+
import { UPLOAD_MEDIA_TYPES, uploadId, uploadImportRequest, uploadIntentRequest, uploadIntentResponse, uploadItemResponse, uploadList, uploadPageRequest, uploadPageResponse, uploadResponse, } from "./uploads.js";
|
|
41
41
|
import { serverFacelessInput } from "./voice-admission.js";
|
|
42
42
|
import { serverVoicesQuery } from "./voice-listing.js";
|
|
43
43
|
import { voicesResponse } from "./voices.js";
|
|
@@ -144,6 +144,10 @@ export const OPENAPI_ROUTES = {
|
|
|
144
144
|
"POST /v1/uploads/intents": { exposure: "public", operationId: "createUploadIntent", tag: "Uploads", optionalIdempotencyKey: true,
|
|
145
145
|
body: named("UploadIntentRequest", uploadIntentRequest),
|
|
146
146
|
responses: { 201: named("UploadIntent", uploadIntentResponse), 200: named("UploadIntent", uploadIntentResponse) } },
|
|
147
|
+
"POST /v1/uploads/pages": { exposure: "public", operationId: "createUploadPage", tag: "Uploads",
|
|
148
|
+
body: named("UploadPageRequest", uploadPageRequest), responses: { 201: named("UploadPage", uploadPageResponse) } },
|
|
149
|
+
"POST /v1/public/upload-pages/{token}": { exposure: "excluded",
|
|
150
|
+
reason: "The upload page's own call: the person's browser sends the photo under the link's token, not an API key." },
|
|
147
151
|
"GET /v1/uploads/{id}": { exposure: "public", operationId: "getUpload", tag: "Uploads", params: { id: uploadId },
|
|
148
152
|
responses: { 200: named("UploadItem", uploadItemResponse) } },
|
|
149
153
|
"DELETE /v1/uploads/{id}": { exposure: "public", operationId: "deleteUpload", tag: "Uploads", params: { id: uploadId }, responses: { 204: null } },
|
package/dist/prices.js
CHANGED
|
@@ -8,13 +8,15 @@ import { PRESENTER_ENGINES, SHOT_ENGINES } from "./face-billing.js";
|
|
|
8
8
|
import { listGenerationModels } from "./generations.js";
|
|
9
9
|
import { PARTS_DURATION_TARIFF, PARTS_FACE_TARIFF, PRESENTER_CREDITS_PER_SECOND, PRESENTER_ENGINE_LABELS, SCENE_CREDITS, SHOT_CREDITS_PER_SECOND, SHOT_ENGINE_LABELS } from "./parts-pricing.js";
|
|
10
10
|
import { UPSCALE_CAPABILITIES, UPSCALE_QUOTE_PATH, UPSCALE_RUN_PATH } from "./upscale.js";
|
|
11
|
-
import {
|
|
11
|
+
import { REFERENCE_ANALYSIS_TARIFFS, REFERENCE_DATA_CREDITS, referenceAnalysisPriceRange, referenceAnalysisPriceTable, referenceAnalysisSince } from "./reference-analysis.js";
|
|
12
12
|
import { CREATOR_PROFILE_CREDITS, CREATOR_PROFILE_VIDEOS } from "./creator-profile.js";
|
|
13
13
|
import { TREND_FREE_PAGES_PER_DAY, TREND_FREE_SEARCHES_PER_MONTH, TREND_PAGE_PAID_CREDITS, TREND_PAGE_WINDOW_SECONDS, TREND_SEARCH_CREDITS, TREND_SEARCH_MAX_PAGES, TREND_SEARCH_REELS, } from "./trend-search.js";
|
|
14
14
|
import { FILM_MUSIC_BED_CREDITS, MUSIC_BED_CREDITS } from "./music.js";
|
|
15
15
|
import { HERO_RUNS_PER_HOUR, OWN_FILM_EXTRA_SECOND_CREDITS, OWN_FILM_INCLUDED_SECONDS, OWN_FILM_RENDER_CREDITS, OWN_HERO_POSE_CREDITS, OWN_HERO_POSES, OWN_HERO_FREE_POSES_PER_DAY, OWN_HERO_FREE_POSES_WINDOW_HOURS, OWN_FREE_STILLS, OWN_FREE_STILLS_WINDOW_HOURS, OWN_STILL_CREDITS, OWN_STILLS_MAX_PER_CALL, OWN_VOICE_CREDITS_PER_SECOND, OWN_EDIT_CREDITS, OWN_EDIT_MAX_SECONDS, OWN_TAKE_CHECK_CREDITS, OWN_CUT_BED_CREDITS, OWN_CUT_CREDITS, OWN_CUT_EXTRA_SECOND_CREDITS, OWN_CUT_INCLUDED_SECONDS, OWN_CUT_MAX_NEW_SOUNDS, OWN_CUT_MAX_SECONDS, OWN_CUT_MIN_SECONDS, OWN_CUT_TAKE_SOUND_CREDITS_PER_SECOND, OWN_TAKE_CHECK_PICTURE_CREDITS, OWN_TAKE_CHECK_PICTURE_LONG_CREDITS, OWN_TAKE_FRAMES_MAX, TAKE_PICTURE_SHORT_TIER_SECONDS, OWN_HERO_HEAD_CREDITS, OWN_HERO_MAX_SPRITES, OWN_HERO_SPRITE_CREDITS, OWN_HERO_TALKING_POSES, ownAgentTermsNow, ownHeroCredits } from "./own-agent-price.js";
|
|
16
16
|
import { CUT_PREVIEW_MAX_STILLS } from "./film-cut.js";
|
|
17
17
|
export const PRICES_PATH = "/v1/public/prices";
|
|
18
|
+
const referenceAnalysisTableText = (tariff, index) => `${index === 0 ? "By the reel's length, " : `${referenceAnalysisSince(tariff)}, `}` +
|
|
19
|
+
referenceAnalysisPriceTable(tariff).map((row, at) => `${row.credits}${at === 0 ? " credits" : ""} up to ${row.up_to_s} s`).join(", ");
|
|
18
20
|
export const PRICE_UNITS = ["call", "second", "face_second", "image", "clip", "clip_second", "still", "scene", "track"];
|
|
19
21
|
export const priceEntryLine = z.strictObject({
|
|
20
22
|
label: z.string().min(1).nullable(),
|
|
@@ -89,6 +91,7 @@ const FREE_TOOLS = {
|
|
|
89
91
|
get_creator_profile: "GET /v1/creator-profiles/{id}",
|
|
90
92
|
delete_creator_profile: "DELETE /v1/creator-profiles/{id}",
|
|
91
93
|
quote_trends: "POST /v1/trend-searches/quote",
|
|
94
|
+
get_trend_search: "GET /v1/trend-searches/{id}",
|
|
92
95
|
trend_niches: "POST /v1/trend-niches",
|
|
93
96
|
list_workflows: "GET /v1/public/workflows",
|
|
94
97
|
get_workflow: "GET /v1/public/workflows/{id}",
|
|
@@ -210,8 +213,10 @@ function buildPriceList(offer, diy) {
|
|
|
210
213
|
"with no call, interview, presenter_gaze or talking shot and no presenter part longer than about 36 s; any other video renders " +
|
|
211
214
|
"on HeyGen Avatar IV. Presenter seconds are the seconds a presenter take fills, counted once over the video and rounded up; " +
|
|
212
215
|
"production seconds are every second of the finished video." })] : []),
|
|
213
|
-
paid({ tool: "analyze_reference", route: "POST /v1/reference-analyses",
|
|
214
|
-
quote_tool: "quote_analysis", notes: "
|
|
216
|
+
paid({ tool: "analyze_reference", route: "POST /v1/reference-analyses", formula: referenceAnalysisPriceRange(),
|
|
217
|
+
quote_tool: "quote_analysis", notes: `${REFERENCE_ANALYSIS_TARIFFS.map(referenceAnalysisTableText).join("; ")}. ` +
|
|
218
|
+
"A link of unknown length holds the most and is charged by the length. " +
|
|
219
|
+
"Held at the start and charged once the analysis succeeds; a failed one costs nothing. " +
|
|
215
220
|
"Starting it again on the same asset answers the same analysis for free." }),
|
|
216
221
|
paid({ tool: "analyze_reference", route: "POST /v1/reference-analyses", variant: "data mode", unit: "call", credits: REFERENCE_DATA_CREDITS,
|
|
217
222
|
quote_tool: "quote_analysis", notes: "mode: \"data\": duration, size, timed transcript, hook and a frame sheet, without the vision pass. " +
|
|
@@ -7,11 +7,32 @@ export declare const ANALYZE_REFERENCE_TASK = "analyze-reference";
|
|
|
7
7
|
export declare const ANALYZE_REFERENCE_SKILL = "analyze_reference";
|
|
8
8
|
export declare const referenceAnalysisId: z.ZodString;
|
|
9
9
|
export declare const REFERENCE_ANALYSIS_VERSION = 2;
|
|
10
|
-
export declare const REFERENCE_ANALYSIS_CREDITS = 70;
|
|
11
10
|
export declare const REFERENCE_DATA_CREDITS = 10;
|
|
11
|
+
export interface ReferenceAnalysisTariff {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly from: string;
|
|
14
|
+
readonly stepSeconds: number;
|
|
15
|
+
readonly credits: readonly number[];
|
|
16
|
+
}
|
|
17
|
+
export declare const REFERENCE_ANALYSIS_TARIFFS: readonly ReferenceAnalysisTariff[];
|
|
18
|
+
export declare const referenceAnalysisTariff: (name: string) => ReferenceAnalysisTariff | null;
|
|
19
|
+
export declare function referenceAnalysisTariffAt(at: Date): ReferenceAnalysisTariff;
|
|
20
|
+
export declare const referenceAnalysisCeiling: (tariff: ReferenceAnalysisTariff) => number;
|
|
21
|
+
export declare const REFERENCE_ANALYSIS_MIN_PRICED_FPS = 10;
|
|
22
|
+
export declare function referenceAnalysisPrice(tariff: ReferenceAnalysisTariff, durationFrames: number, fps: number): number | null;
|
|
23
|
+
export declare const referenceAnalysisLikelyPrice: (tariff: ReferenceAnalysisTariff, seconds: number) => number | null;
|
|
24
|
+
export declare const referenceAnalysisPriceTable: (tariff: ReferenceAnalysisTariff) => {
|
|
25
|
+
up_to_s: number;
|
|
26
|
+
credits: number;
|
|
27
|
+
}[];
|
|
28
|
+
export declare const referenceAnalysisPriceRange: () => string;
|
|
29
|
+
export declare const referenceAnalysisSince: (tariff: ReferenceAnalysisTariff) => string;
|
|
30
|
+
export declare const referenceLengthUnknownNote: (ceiling: number, refusal: "max_credits" | "balance") => string;
|
|
12
31
|
export declare const REFERENCE_ANALYSIS_MODES: readonly ["full", "data"];
|
|
13
32
|
export type ReferenceAnalysisMode = (typeof REFERENCE_ANALYSIS_MODES)[number];
|
|
14
|
-
export declare const
|
|
33
|
+
export declare const REFERENCE_ANALYSIS_MAX_SECONDS: Readonly<Record<ReferenceAnalysisMode, number>>;
|
|
34
|
+
export declare function referenceTooLongMessage(mode: ReferenceAnalysisMode, seconds: number, subject?: string): string | null;
|
|
35
|
+
export declare const isReferenceTooLongMessage: (line: string) => boolean;
|
|
15
36
|
export declare const REFERENCE_ANALYSIS_PER_HOUR = 10;
|
|
16
37
|
export declare const REFERENCE_DATA_PER_HOUR = 60;
|
|
17
38
|
export declare const REFERENCE_DATA_SHEET_COLUMNS = 3;
|
|
@@ -20,6 +41,8 @@ export declare const REFERENCE_DATA_SHEET_MAX_WIDTH = 1080;
|
|
|
20
41
|
export declare const REFERENCE_ANALYSIS_WINDOW_SECONDS = 3600;
|
|
21
42
|
export declare const REFERENCE_ANALYSIS_WORK_SECONDS = 420;
|
|
22
43
|
export declare const REFERENCE_ANALYSIS_TASK_MAX_DURATION_SECONDS = 600;
|
|
44
|
+
export declare const REFERENCE_LINK_INGEST_SECONDS: number;
|
|
45
|
+
export declare const REFERENCE_VIDEO_CALL_TIMEOUT_SECONDS = 270;
|
|
23
46
|
export declare const REFERENCE_ANALYSIS_DEADLINE_SECONDS = 900;
|
|
24
47
|
export declare const REFERENCE_ANALYSIS_STATES: readonly ["queued", "analyzing", "succeeded", "failed"];
|
|
25
48
|
export declare const REFERENCE_ANALYSIS_ERRORS: readonly ["timed_out", "analysis_failed", "asset_gone", "enqueue_failed"];
|
|
@@ -119,6 +142,7 @@ export declare const referenceSource: z.ZodObject<{
|
|
|
119
142
|
}, z.core.$strict>>;
|
|
120
143
|
}, z.core.$strict>;
|
|
121
144
|
export type ReferenceSource = z.infer<typeof referenceSource>;
|
|
145
|
+
export declare const MAX_REFERENCE_SCENES = 60;
|
|
122
146
|
export declare const referenceData: z.ZodObject<{
|
|
123
147
|
transcript: z.ZodArray<z.ZodObject<{
|
|
124
148
|
text: z.ZodString;
|
|
@@ -131,6 +155,8 @@ export declare const referenceData: z.ZodObject<{
|
|
|
131
155
|
text: z.ZodString;
|
|
132
156
|
end_s: z.ZodNumber;
|
|
133
157
|
caption: z.ZodOptional<z.ZodString>;
|
|
158
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
159
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
134
160
|
}, z.core.$strict>>;
|
|
135
161
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
162
|
start_s: z.ZodNumber;
|
|
@@ -156,6 +182,12 @@ export declare const referenceData: z.ZodObject<{
|
|
|
156
182
|
width: z.ZodNumber;
|
|
157
183
|
height: z.ZodNumber;
|
|
158
184
|
fps: z.ZodNumber;
|
|
185
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
186
|
+
start_s: z.ZodNumber;
|
|
187
|
+
end_s: z.ZodNumber;
|
|
188
|
+
key_frame_s: z.ZodNumber;
|
|
189
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
190
|
+
}, z.core.$strict>>>;
|
|
159
191
|
frame_sheet: z.ZodObject<{
|
|
160
192
|
columns: z.ZodNumber;
|
|
161
193
|
rows: z.ZodNumber;
|
|
@@ -182,6 +214,8 @@ export declare const referenceDataParts: {
|
|
|
182
214
|
text: z.ZodString;
|
|
183
215
|
end_s: z.ZodNumber;
|
|
184
216
|
caption: z.ZodOptional<z.ZodString>;
|
|
217
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
218
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
185
219
|
}, z.core.$strict>>;
|
|
186
220
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
187
221
|
start_s: z.ZodNumber;
|
|
@@ -210,6 +244,14 @@ export declare const referenceDataParts: {
|
|
|
210
244
|
height: z.ZodNumber;
|
|
211
245
|
fps: z.ZodNumber;
|
|
212
246
|
};
|
|
247
|
+
scenes: {
|
|
248
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
249
|
+
start_s: z.ZodNumber;
|
|
250
|
+
end_s: z.ZodNumber;
|
|
251
|
+
key_frame_s: z.ZodNumber;
|
|
252
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
253
|
+
}, z.core.$strict>>>;
|
|
254
|
+
};
|
|
213
255
|
};
|
|
214
256
|
export declare const REFERENCE_FRAMES_FPS = 1;
|
|
215
257
|
export declare const REFERENCE_FRAME_MAX_WIDTH = 540;
|
|
@@ -218,7 +260,6 @@ export declare const REFERENCE_SHEET_ROWS = 3;
|
|
|
218
260
|
export declare const REFERENCE_SHEET_WIDTH = 1080;
|
|
219
261
|
export declare const REFERENCE_FRAMES_PAGE_MAX = 60;
|
|
220
262
|
export declare const REFERENCE_FRAME_LINK_TTL_SECONDS = 86400;
|
|
221
|
-
export declare const MAX_REFERENCE_SCENES = 60;
|
|
222
263
|
export declare const REFERENCE_FRAMES_VERSION = "reference-frames-v1";
|
|
223
264
|
export declare const referenceFrameName: (t: number) => string;
|
|
224
265
|
export declare const referenceSheetName: (index: number) => string;
|
|
@@ -1216,6 +1257,8 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1216
1257
|
text: z.ZodString;
|
|
1217
1258
|
end_s: z.ZodNumber;
|
|
1218
1259
|
caption: z.ZodOptional<z.ZodString>;
|
|
1260
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
1261
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
1219
1262
|
}, z.core.$strict>>;
|
|
1220
1263
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1221
1264
|
start_s: z.ZodNumber;
|
|
@@ -1241,6 +1284,12 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1241
1284
|
width: z.ZodNumber;
|
|
1242
1285
|
height: z.ZodNumber;
|
|
1243
1286
|
fps: z.ZodNumber;
|
|
1287
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1288
|
+
start_s: z.ZodNumber;
|
|
1289
|
+
end_s: z.ZodNumber;
|
|
1290
|
+
key_frame_s: z.ZodNumber;
|
|
1291
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
1292
|
+
}, z.core.$strict>>>;
|
|
1244
1293
|
frame_sheet: z.ZodObject<{
|
|
1245
1294
|
columns: z.ZodNumber;
|
|
1246
1295
|
rows: z.ZodNumber;
|
|
@@ -1377,6 +1426,7 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1377
1426
|
untrusted_content: z.ZodObject<{
|
|
1378
1427
|
note: z.ZodLiteral<string>;
|
|
1379
1428
|
fields: z.ZodArray<z.ZodEnum<{
|
|
1429
|
+
"data.hook.post_caption": "data.hook.post_caption";
|
|
1380
1430
|
"data.hook.text": "data.hook.text";
|
|
1381
1431
|
"data.segments[].text": "data.segments[].text";
|
|
1382
1432
|
"data.transcript[].text": "data.transcript[].text";
|
|
@@ -1444,6 +1494,11 @@ export type ReferenceAnalysis = z.infer<typeof referenceAnalysis>;
|
|
|
1444
1494
|
export declare const analysisQuoteResponse: z.ZodObject<{
|
|
1445
1495
|
asset_id: z.ZodNullable<z.ZodString>;
|
|
1446
1496
|
credits_estimate: z.ZodNumber;
|
|
1497
|
+
credits_by_length: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1498
|
+
up_to_s: z.ZodNumber;
|
|
1499
|
+
credits: z.ZodNumber;
|
|
1500
|
+
}, z.core.$strict>>>;
|
|
1501
|
+
length_known: z.ZodOptional<z.ZodBoolean>;
|
|
1447
1502
|
replays_analysis_id: z.ZodNullable<z.ZodString>;
|
|
1448
1503
|
repeat_note: z.ZodString;
|
|
1449
1504
|
warnings: z.ZodArray<z.ZodString>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { assetId } from "./asset-identity.js";
|
|
3
|
-
import { ASSET_VIDEO_MAX_SECONDS } from "./assets.js";
|
|
3
|
+
import { ANALYSIS_VIDEO_MAX_SECONDS, ASSET_VIDEO_MAX_SECONDS } from "./assets.js";
|
|
4
4
|
import { maxCreditsField } from "./max-credits.js";
|
|
5
5
|
import { referenceUntrusted } from "./reference-display.js";
|
|
6
6
|
import { filmKitMap, referenceFilmNext } from "./reference-film-kit.js";
|
|
7
|
-
import { MAX_REFERENCE_SEGMENTS, MAX_REFERENCE_TRANSCRIPT_WORDS, referenceHook, referenceLanguage, referenceProfileAnswer, referenceSegment, referenceWord } from "./reference-profile.js";
|
|
7
|
+
import { MAX_REFERENCE_LABEL_CHARS, MAX_REFERENCE_SEGMENTS, MAX_REFERENCE_TRANSCRIPT_WORDS, referenceHook, referenceLanguage, referenceProfileAnswer, referenceSegment, referenceWord } from "./reference-profile.js";
|
|
8
8
|
export const REFERENCE_ANALYSES_PATH = "/v1/reference-analyses";
|
|
9
9
|
export const REFERENCE_ANALYSIS_PATH = "/v1/reference-analyses/:id";
|
|
10
10
|
export const REFERENCE_ANALYSIS_QUOTE_PATH = "/v1/reference-analyses/quote";
|
|
@@ -12,12 +12,50 @@ export const ANALYZE_REFERENCE_TASK = "analyze-reference";
|
|
|
12
12
|
export const ANALYZE_REFERENCE_SKILL = "analyze_reference";
|
|
13
13
|
export const referenceAnalysisId = z.string().regex(/^ref_[a-f0-9]{32}$/);
|
|
14
14
|
export const REFERENCE_ANALYSIS_VERSION = 2;
|
|
15
|
-
export const REFERENCE_ANALYSIS_CREDITS = 70;
|
|
16
15
|
export const REFERENCE_DATA_CREDITS = 10;
|
|
16
|
+
export const REFERENCE_ANALYSIS_TARIFFS = [
|
|
17
|
+
{ name: "analysis-length-v1", from: "2026-11-22T00:00:00.000Z", stepSeconds: 30, credits: [37, 44, 51, 58, 65, 72] },
|
|
18
|
+
{ name: "analysis-length-v2", from: "2026-12-01T00:00:00.000Z", stepSeconds: 30, credits: [66, 80, 93, 107, 120, 134] },
|
|
19
|
+
];
|
|
20
|
+
export const referenceAnalysisTariff = (name) => REFERENCE_ANALYSIS_TARIFFS.find((tariff) => tariff.name === name) ?? null;
|
|
21
|
+
export function referenceAnalysisTariffAt(at) {
|
|
22
|
+
const started = REFERENCE_ANALYSIS_TARIFFS.filter((tariff) => Date.parse(tariff.from) <= at.getTime());
|
|
23
|
+
return started.at(-1) ?? REFERENCE_ANALYSIS_TARIFFS[0];
|
|
24
|
+
}
|
|
25
|
+
export const referenceAnalysisCeiling = (tariff) => tariff.credits.at(-1);
|
|
26
|
+
export const REFERENCE_ANALYSIS_MIN_PRICED_FPS = 10;
|
|
27
|
+
export function referenceAnalysisPrice(tariff, durationFrames, fps) {
|
|
28
|
+
if (!(durationFrames > 0) || !(fps > 0))
|
|
29
|
+
throw new Error(`a reel of ${durationFrames} frames at ${fps} fps has no price`);
|
|
30
|
+
if (fps < REFERENCE_ANALYSIS_MIN_PRICED_FPS)
|
|
31
|
+
return referenceAnalysisCeiling(tariff);
|
|
32
|
+
if (durationFrames / fps > REFERENCE_ANALYSIS_MAX_SECONDS.full)
|
|
33
|
+
return null;
|
|
34
|
+
const step = Math.max(1, Math.ceil((durationFrames - Math.floor(fps / 2)) / (tariff.stepSeconds * fps)));
|
|
35
|
+
return tariff.credits[Math.min(step, tariff.credits.length) - 1];
|
|
36
|
+
}
|
|
37
|
+
export const referenceAnalysisLikelyPrice = (tariff, seconds) => seconds > 0 ? referenceAnalysisPrice(tariff, Math.round(seconds * 1000), 1000) : null;
|
|
38
|
+
export const referenceAnalysisPriceTable = (tariff) => tariff.credits.map((credits, index) => ({ up_to_s: (index + 1) * tariff.stepSeconds, credits }));
|
|
39
|
+
export const referenceAnalysisPriceRange = () => REFERENCE_ANALYSIS_TARIFFS.map((tariff, index) => `${tariff.credits[0]} to ${referenceAnalysisCeiling(tariff)}${index === 0 ? " credits by the reel's length" : ` ${referenceAnalysisSince(tariff)}`}`).join(", ");
|
|
40
|
+
export const referenceAnalysisSince = (tariff) => "from " + tariff.from.slice(0, 10);
|
|
41
|
+
export const referenceLengthUnknownNote = (ceiling, refusal) => refusal === "max_credits"
|
|
42
|
+
? `The reel's length is unknown until it is read, so the start holds ${ceiling}; the charge follows the length and never exceeds it. ` +
|
|
43
|
+
"An uploaded clip is quoted at its exact price."
|
|
44
|
+
: `The reel's length is unknown until it is read, so the start holds ${ceiling}, the most a full analysis costs; the charge ` +
|
|
45
|
+
"follows the length. An uploaded clip is held at its exact price.";
|
|
17
46
|
export const REFERENCE_ANALYSIS_MODES = ["full", "data"];
|
|
18
|
-
export const
|
|
19
|
-
full:
|
|
47
|
+
export const REFERENCE_ANALYSIS_MAX_SECONDS = {
|
|
48
|
+
full: ANALYSIS_VIDEO_MAX_SECONDS, data: ANALYSIS_VIDEO_MAX_SECONDS,
|
|
20
49
|
};
|
|
50
|
+
const REFERENCE_TOO_LONG_LEAD = "the reel lasts ";
|
|
51
|
+
export function referenceTooLongMessage(mode, seconds, subject = "the reel") {
|
|
52
|
+
const most = REFERENCE_ANALYSIS_MAX_SECONDS[mode];
|
|
53
|
+
if (seconds <= most)
|
|
54
|
+
return null;
|
|
55
|
+
return `${subject === "the reel" ? REFERENCE_TOO_LONG_LEAD : `${subject} lasts `}${seconds.toFixed(1)} s; a ${mode} analysis reads at most ${most} s; ` +
|
|
56
|
+
"use a shorter clip";
|
|
57
|
+
}
|
|
58
|
+
export const isReferenceTooLongMessage = (line) => line.startsWith(REFERENCE_TOO_LONG_LEAD) && / analysis reads at most \d+ s/.test(line);
|
|
21
59
|
export const REFERENCE_ANALYSIS_PER_HOUR = 10;
|
|
22
60
|
export const REFERENCE_DATA_PER_HOUR = 60;
|
|
23
61
|
export const REFERENCE_DATA_SHEET_COLUMNS = 3;
|
|
@@ -26,6 +64,8 @@ export const REFERENCE_DATA_SHEET_MAX_WIDTH = 1080;
|
|
|
26
64
|
export const REFERENCE_ANALYSIS_WINDOW_SECONDS = 3600;
|
|
27
65
|
export const REFERENCE_ANALYSIS_WORK_SECONDS = 420;
|
|
28
66
|
export const REFERENCE_ANALYSIS_TASK_MAX_DURATION_SECONDS = 600;
|
|
67
|
+
export const REFERENCE_LINK_INGEST_SECONDS = REFERENCE_ANALYSIS_TASK_MAX_DURATION_SECONDS - REFERENCE_ANALYSIS_WORK_SECONDS - 60;
|
|
68
|
+
export const REFERENCE_VIDEO_CALL_TIMEOUT_SECONDS = 270;
|
|
29
69
|
export const REFERENCE_ANALYSIS_DEADLINE_SECONDS = 900;
|
|
30
70
|
export const REFERENCE_ANALYSIS_STATES = ["queued", "analyzing", "succeeded", "failed"];
|
|
31
71
|
export const REFERENCE_ANALYSIS_ERRORS = ["timed_out", "analysis_failed", "asset_gone", "enqueue_failed"];
|
|
@@ -69,11 +109,13 @@ export function classifyReferenceUrl(raw) {
|
|
|
69
109
|
return { ok: false, message: `${host} ${url.pathname} is not a link we read; pass ${REFERENCE_URL_ACCEPTED}` };
|
|
70
110
|
}
|
|
71
111
|
export const analyzeReferenceRequest = z.strictObject({
|
|
72
|
-
asset_id: assetId.optional().describe(`asset_id of an MP4 asset of this account, at most ${ASSET_VIDEO_MAX_SECONDS} s
|
|
112
|
+
asset_id: assetId.optional().describe(`asset_id of an MP4 asset of this account, at most 100 MiB and ${ASSET_VIDEO_MAX_SECONDS} s, ` +
|
|
113
|
+
`or ${ANALYSIS_VIDEO_MAX_SECONDS} s for an analysis_only asset`),
|
|
73
114
|
source_url: z.string().url().startsWith("https://").max(2048).optional()
|
|
74
115
|
.describe(`instead of asset_id: ${REFERENCE_URL_ACCEPTED}; YouTube is refused`),
|
|
75
|
-
mode: z.enum(REFERENCE_ANALYSIS_MODES).optional().describe(`full (default, ${
|
|
76
|
-
|
|
116
|
+
mode: z.enum(REFERENCE_ANALYSIS_MODES).optional().describe(`full (default, ${referenceAnalysisPriceRange()}, reels up to ` +
|
|
117
|
+
`${REFERENCE_ANALYSIS_MAX_SECONDS.full} s): the reference_profile. data (${REFERENCE_DATA_CREDITS} credits, reels up to ${REFERENCE_ANALYSIS_MAX_SECONDS.data} s): ` +
|
|
118
|
+
"duration, size, timed transcript, scenes between measured cuts, hook and a 3×3 frame sheet, without beats or graphics"),
|
|
77
119
|
max_credits: maxCreditsField,
|
|
78
120
|
}).refine((request) => (request.asset_id === undefined) !== (request.source_url === undefined), {
|
|
79
121
|
message: "pass exactly one of asset_id or source_url",
|
|
@@ -117,18 +159,30 @@ const frameSheet = z.strictObject({
|
|
|
117
159
|
rows: z.number().int().positive(),
|
|
118
160
|
times_s: z.array(z.number().nonnegative()).min(1),
|
|
119
161
|
});
|
|
162
|
+
const dataHook = referenceHook.extend({
|
|
163
|
+
post_caption: z.string().min(1).max(MAX_REFERENCE_LABEL_CHARS).optional()
|
|
164
|
+
.describe("The first line of the post's caption, the author's text under a linked post; absent for an asset or a post without one."),
|
|
165
|
+
frame_s: z.number().int().nonnegative().optional()
|
|
166
|
+
.describe("The second of the hook's frame, where its first word starts: the frames.key_frames entry of kind hook."),
|
|
167
|
+
});
|
|
120
168
|
const dataWords = { transcript: z.array(referenceWord).max(MAX_REFERENCE_TRANSCRIPT_WORDS),
|
|
121
169
|
transcript_language: referenceLanguage.optional(),
|
|
122
|
-
hook:
|
|
170
|
+
hook: dataHook.nullable(),
|
|
123
171
|
segments: z.array(referenceSegment).max(MAX_REFERENCE_SEGMENTS).optional() };
|
|
124
172
|
const dataProbe = { duration_s: z.number().positive(), width: z.number().int().positive(), height: z.number().int().positive(),
|
|
125
173
|
fps: z.number().positive() };
|
|
174
|
+
export const MAX_REFERENCE_SCENES = 60;
|
|
175
|
+
const dataScenes = { scenes: z.array(z.strictObject({ start_s: z.number().nonnegative(), end_s: z.number().positive(),
|
|
176
|
+
key_frame_s: z.number().int().nonnegative().describe("The second whose frame shows the scene; frames.scenes signs it."),
|
|
177
|
+
segments: z.array(z.number().int().nonnegative()).describe("Indexes into segments of those that start in this scene.") }))
|
|
178
|
+
.max(MAX_REFERENCE_SCENES).optional().describe("Shots between measured cuts; absent when the frames could not be kept, or on data from before them.") };
|
|
126
179
|
export const referenceData = z.strictObject({
|
|
127
180
|
...dataProbe,
|
|
128
181
|
...dataWords,
|
|
182
|
+
...dataScenes,
|
|
129
183
|
frame_sheet: frameSheet.extend({ url: z.string().url().nullable() }),
|
|
130
184
|
});
|
|
131
|
-
export const referenceDataParts = { frameSheet, words: dataWords, probe: dataProbe };
|
|
185
|
+
export const referenceDataParts = { frameSheet, words: dataWords, probe: dataProbe, scenes: dataScenes };
|
|
132
186
|
export const REFERENCE_FRAMES_FPS = 1;
|
|
133
187
|
export const REFERENCE_FRAME_MAX_WIDTH = 540;
|
|
134
188
|
export const REFERENCE_SHEET_COLUMNS = 4;
|
|
@@ -136,9 +190,8 @@ export const REFERENCE_SHEET_ROWS = 3;
|
|
|
136
190
|
export const REFERENCE_SHEET_WIDTH = 1080;
|
|
137
191
|
export const REFERENCE_FRAMES_PAGE_MAX = 60;
|
|
138
192
|
export const REFERENCE_FRAME_LINK_TTL_SECONDS = 86_400;
|
|
139
|
-
export const MAX_REFERENCE_SCENES = 60;
|
|
140
193
|
export const REFERENCE_FRAMES_VERSION = "reference-frames-v1";
|
|
141
|
-
const maxFrames = Math.ceil(
|
|
194
|
+
const maxFrames = Math.ceil(ANALYSIS_VIDEO_MAX_SECONDS) + 1;
|
|
142
195
|
export const referenceFrameName = (t) => `f-${Number.isInteger(t) ? String(t).padStart(3, "0") : t.toFixed(1).padStart(5, "0")}.jpg`;
|
|
143
196
|
export const referenceSheetName = (index) => `sheet-${index}.jpg`;
|
|
144
197
|
const second = z.number().int().nonnegative();
|
|
@@ -179,7 +232,7 @@ export const referenceFramesPage = z.strictObject({
|
|
|
179
232
|
.describe(`End second, exclusive; at most ${REFERENCE_FRAMES_PAGE_MAX} frames a page.`),
|
|
180
233
|
});
|
|
181
234
|
export const REFERENCE_WAIT_MAX_SECONDS = 50;
|
|
182
|
-
export const REFERENCE_EXPECTED_SECONDS = { full:
|
|
235
|
+
export const REFERENCE_EXPECTED_SECONDS = { full: 210, data: 45 };
|
|
183
236
|
export const referenceAnalysisQuery = referenceFramesPage.extend({
|
|
184
237
|
wait_seconds: z.coerce.number().int().min(0).max(REFERENCE_WAIT_MAX_SECONDS).optional()
|
|
185
238
|
.describe(`Wait up to this many seconds (at most ${REFERENCE_WAIT_MAX_SECONDS}) for the analysis to finish before answering.`),
|
|
@@ -226,6 +279,8 @@ export const referenceAnalysis = z.strictObject({
|
|
|
226
279
|
export const analysisQuoteResponse = z.strictObject({
|
|
227
280
|
asset_id: assetId.nullable(),
|
|
228
281
|
credits_estimate: z.number().int().nonnegative(),
|
|
282
|
+
credits_by_length: z.array(z.strictObject({ up_to_s: z.number().int().positive(), credits: z.number().int().positive() })).optional(),
|
|
283
|
+
length_known: z.boolean().optional(),
|
|
229
284
|
replays_analysis_id: referenceAnalysisId.nullable(),
|
|
230
285
|
repeat_note: z.string(),
|
|
231
286
|
warnings: z.array(z.string()),
|
|
@@ -262,18 +317,22 @@ export const ANALYZE_REFERENCE_DESCRIPTION = "Break down any reel or ad into a r
|
|
|
262
317
|
"graphic's label_hint. speakers names who talks, on or off screen, with their caption look; each beat names its speaker, gaze " +
|
|
263
318
|
"and gestures, each claim citing frames_s. " +
|
|
264
319
|
"What we cannot draw is in unmapped with a substitute and in warnings. Pass asset_id of an MP4 asset (create_asset " +
|
|
265
|
-
`with kind: "video"), at most
|
|
320
|
+
`with kind: "video"), at most 100 MiB, or source_url: ${REFERENCE_URL_ACCEPTED}. Both modes read reels up to ` +
|
|
321
|
+
`${REFERENCE_ANALYSIS_MAX_SECONDS.full} s (a link or an analysis_only asset; any other asset is at most ${ASSET_VIDEO_MAX_SECONDS} s); a longer reel ` +
|
|
322
|
+
"is refused at no charge, before its video is downloaded when the platform gives its length, and the error message names the limit. " +
|
|
266
323
|
"A link becomes an analysis-only asset (asset_id in the answer), and source carries the post's caption, author, engagement, " +
|
|
267
324
|
"the author's followers and median views with the ratio (x), the top 50 comments and their code words; a number, caption or " +
|
|
268
325
|
"author the platform did not give is null and named in warnings. A YouTube link is refused: upload its MP4 with create_asset. " +
|
|
269
326
|
"Once succeeded both modes answer frames and video, the reel as an MP4 (get_reference_analysis lists them). " +
|
|
270
327
|
`mode: "data" skips beats and graphics and answers data: duration, size and fps, the timed ` +
|
|
271
|
-
"transcript and segments,
|
|
272
|
-
|
|
273
|
-
|
|
328
|
+
"transcript and segments, scenes between measured cuts with their segments, the hook with the post's caption line and its frame, " +
|
|
329
|
+
"and a 3×3 frame sheet, plus source for a link; no speech gives an empty transcript and a " +
|
|
330
|
+
`warning. Full costs ${referenceAnalysisPriceRange()}; quote_analysis gives the exact price. A link of unknown length ` +
|
|
331
|
+
`holds the most and is charged by the length. Data costs ${REFERENCE_DATA_CREDITS}. ` +
|
|
332
|
+
"The price is held at the start and charged once it succeeds; a failed analysis costs nothing. " +
|
|
274
333
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per hour per account. ` +
|
|
275
334
|
`Answers at once with state queued; call get_reference_analysis with wait_seconds: ${REFERENCE_WAIT_MAX_SECONDS} until succeeded or failed ` +
|
|
276
|
-
"(full about 2–
|
|
335
|
+
"(full about 2–4 minutes, data under one). " +
|
|
277
336
|
"The same asset, or reel by its full link, in the same mode returns the same analysis, free, unless it " +
|
|
278
337
|
"failed, and a short vt.tiktok.com or vm.tiktok.com link counts as the full link of its video. An analysis made before frames and speakers existed is redone free " +
|
|
279
338
|
"once (replaces_analysis_id names the old one, still readable). The asset is not changed. " +
|
|
@@ -294,7 +353,9 @@ export const GET_REFERENCE_ANALYSIS_DESCRIPTION = "Read an analysis started by a
|
|
|
294
353
|
"0 once failed; repeat_note says " +
|
|
295
354
|
"what asking again costs. Free.";
|
|
296
355
|
export const QUOTE_ANALYSIS_DESCRIPTION = "Price analyze_reference for an asset_id or a source_url and a mode before starting it: credits_estimate is what a start " +
|
|
297
|
-
`holds and
|
|
356
|
+
`holds and, once it succeeds, at most charges: full ${referenceAnalysisPriceRange()}, data ${REFERENCE_DATA_CREDITS}. ` +
|
|
357
|
+
"credits_by_length lists today's full prices; length_known: false means the length is not known yet: the estimate is the most " +
|
|
358
|
+
"and the charge follows the reel's length. It is 0 when the " +
|
|
298
359
|
"asset or the reel already has an analysis in that mode that a start would answer (replays_analysis_id), and 0 when a start " +
|
|
299
360
|
"would redo an analysis made before frames and speakers were added. repeat_note says, in a sentence for the user, what asking again costs. A YouTube or " +
|
|
300
361
|
"unknown link is refused here too. Free; starts nothing.";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ReferenceAnalysis } from "./reference-analysis.js";
|
|
3
3
|
export declare const REFERENCE_UNTRUSTED_NOTE: string;
|
|
4
|
-
export declare const REFERENCE_UNTRUSTED_FIELDS: readonly ["reference_profile.transcript[].text", "reference_profile.segments[].text", "reference_profile.hook.text", "reference_profile.hook.caption", "reference_profile.beats[].spoken_summary", "reference_profile.beats[].graphics[].label_hint", "reference_profile.spellings[].heard", "reference_profile.spellings[].shown", "data.transcript[].text", "data.segments[].text", "data.hook.text", "source.caption.text", "source.author.name", "source.author.handle", "source.top_comments[].text", "source.code_words[].word", "source.code_word_guess", "source.funnel.word", "display_markdown"];
|
|
4
|
+
export declare const REFERENCE_UNTRUSTED_FIELDS: readonly ["reference_profile.transcript[].text", "reference_profile.segments[].text", "reference_profile.hook.text", "reference_profile.hook.caption", "reference_profile.beats[].spoken_summary", "reference_profile.beats[].graphics[].label_hint", "reference_profile.spellings[].heard", "reference_profile.spellings[].shown", "data.transcript[].text", "data.segments[].text", "data.hook.text", "data.hook.post_caption", "source.caption.text", "source.author.name", "source.author.handle", "source.top_comments[].text", "source.code_words[].word", "source.code_word_guess", "source.funnel.word", "display_markdown"];
|
|
5
5
|
export declare const referenceUntrusted: z.ZodObject<{
|
|
6
6
|
note: z.ZodLiteral<string>;
|
|
7
7
|
fields: z.ZodArray<z.ZodEnum<{
|
|
8
|
+
"data.hook.post_caption": "data.hook.post_caption";
|
|
8
9
|
"data.hook.text": "data.hook.text";
|
|
9
10
|
"data.segments[].text": "data.segments[].text";
|
|
10
11
|
"data.transcript[].text": "data.transcript[].text";
|
|
@@ -28,7 +29,7 @@ export declare const referenceUntrusted: z.ZodObject<{
|
|
|
28
29
|
}, z.core.$strict>;
|
|
29
30
|
export declare const REFERENCE_UNTRUSTED: {
|
|
30
31
|
note: string;
|
|
31
|
-
fields: ("data.hook.text" | "data.segments[].text" | "data.transcript[].text" | "display_markdown" | "reference_profile.beats[].graphics[].label_hint" | "reference_profile.beats[].spoken_summary" | "reference_profile.hook.caption" | "reference_profile.hook.text" | "reference_profile.segments[].text" | "reference_profile.spellings[].heard" | "reference_profile.spellings[].shown" | "reference_profile.transcript[].text" | "source.author.handle" | "source.author.name" | "source.caption.text" | "source.code_word_guess" | "source.code_words[].word" | "source.funnel.word" | "source.top_comments[].text")[];
|
|
32
|
+
fields: ("data.hook.post_caption" | "data.hook.text" | "data.segments[].text" | "data.transcript[].text" | "display_markdown" | "reference_profile.beats[].graphics[].label_hint" | "reference_profile.beats[].spoken_summary" | "reference_profile.hook.caption" | "reference_profile.hook.text" | "reference_profile.segments[].text" | "reference_profile.spellings[].heard" | "reference_profile.spellings[].shown" | "reference_profile.transcript[].text" | "source.author.handle" | "source.author.name" | "source.caption.text" | "source.code_word_guess" | "source.code_words[].word" | "source.funnel.word" | "source.top_comments[].text")[];
|
|
32
33
|
};
|
|
33
34
|
export declare const REFERENCE_DISPLAY_HINT: string;
|
|
34
35
|
export declare function referenceAnalysisMarkdown(analysis: ReferenceAnalysis): string;
|
|
@@ -5,7 +5,7 @@ export const REFERENCE_UNTRUSTED_NOTE = "Third-party text from the reel and its
|
|
|
5
5
|
export const REFERENCE_UNTRUSTED_FIELDS = [
|
|
6
6
|
"reference_profile.transcript[].text", "reference_profile.segments[].text", "reference_profile.hook.text", "reference_profile.hook.caption",
|
|
7
7
|
"reference_profile.beats[].spoken_summary", "reference_profile.beats[].graphics[].label_hint", "reference_profile.spellings[].heard",
|
|
8
|
-
"reference_profile.spellings[].shown", "data.transcript[].text", "data.segments[].text", "data.hook.text", "source.caption.text",
|
|
8
|
+
"reference_profile.spellings[].shown", "data.transcript[].text", "data.segments[].text", "data.hook.text", "data.hook.post_caption", "source.caption.text",
|
|
9
9
|
"source.author.name", "source.author.handle", "source.top_comments[].text", "source.code_words[].word", "source.code_word_guess", "source.funnel.word",
|
|
10
10
|
"display_markdown",
|
|
11
11
|
];
|
|
@@ -65,8 +65,10 @@ export function referenceAnalysisMarkdown(analysis) {
|
|
|
65
65
|
}
|
|
66
66
|
const language = profile?.transcript_language ?? data?.transcript_language;
|
|
67
67
|
const hook = profile?.hook ?? data?.hook;
|
|
68
|
+
const postCaption = data?.hook?.post_caption;
|
|
68
69
|
if (hook)
|
|
69
|
-
lines.push(`- Hook (0–${seconds(hook.end_s)} s): ${quote(hook.text, 160)}${hook.caption ? ` · on screen ${quote(hook.caption, 80)}` : ""}`
|
|
70
|
+
lines.push(`- Hook (0–${seconds(hook.end_s)} s): ${quote(hook.text, 160)}${hook.caption ? ` · on screen ${quote(hook.caption, 80)}` : ""}` +
|
|
71
|
+
`${postCaption ? ` · caption ${quote(postCaption, 80)}` : ""}`);
|
|
70
72
|
if (language)
|
|
71
73
|
lines.push(`- Spoken language: ${language}`);
|
|
72
74
|
if (profile) {
|
|
@@ -98,6 +100,15 @@ export function referenceAnalysisMarkdown(analysis) {
|
|
|
98
100
|
}
|
|
99
101
|
else if (data) {
|
|
100
102
|
lines.push("", `- Transcript: ${data.transcript.length} words${data.frame_sheet.url ? ` · [frame sheet](${data.frame_sheet.url})` : ""}`);
|
|
103
|
+
if (data.scenes?.length) {
|
|
104
|
+
const frameOf = new Map((analysis.frames?.scenes ?? []).map(scene => [scene.start_s, scene.url]));
|
|
105
|
+
lines.push(`- Scenes: ${data.scenes.length}, one every ${seconds(data.duration_s / data.scenes.length)} s (measured cuts)`, "", "| Scene | Time | Said | Frame |", "|---:|---|---|---|");
|
|
106
|
+
data.scenes.forEach((scene, index) => {
|
|
107
|
+
const said = scene.segments.map(at => data.segments?.[at]?.text ?? "").join(" ").trim(), frame = frameOf.get(scene.start_s);
|
|
108
|
+
lines.push(`| ${index} | ${seconds(scene.start_s)}–${seconds(scene.end_s)} s | ${said ? quote(said, 70) : "—"} | ` +
|
|
109
|
+
`${frame ? `[${scene.key_frame_s} s](${frame})` : scene.key_frame_s} |`);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
101
112
|
}
|
|
102
113
|
if (source?.top_comments.length) {
|
|
103
114
|
lines.push("", `Top comments (${Math.min(TOP_COMMENTS_SHOWN, source.top_comments.length)} of ${source.comments_read ?? source.top_comments.length} read):`, ...source.top_comments.slice(0, TOP_COMMENTS_SHOWN).map((comment, index) => `${index + 1}. ${quote(comment.text, 120)} (${number(comment.likes)} likes)`));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { REFERENCE_BRING_KINDS, referenceBringItem } from "./reference-bring.js";
|
|
3
3
|
import { REFERENCE_GRAPHIC_KINDS, REFERENCE_SOURCE_KINDS } from "./reference-kinds.js";
|
|
4
|
-
import { referenceStaging, stagingIssues, stagingRect } from "./reference-staging.js";
|
|
4
|
+
import { pastTheSource, referenceStaging, stagingIssues, stagingRect } from "./reference-staging.js";
|
|
5
5
|
import { referenceVoice } from "./reference-voice.js";
|
|
6
6
|
import { CAPTION_EMPHASIS_LOOKS } from "./skills.js";
|
|
7
7
|
import { TEMPLATE_KIND_IDS, TEMPLATE_SOUND_BEATS } from "./templates/index.js";
|
|
@@ -191,12 +191,12 @@ function checkProfile(profile, ctx) {
|
|
|
191
191
|
if (word.end_s < word.start_s)
|
|
192
192
|
issue(["transcript", index, "end_s"], "ends before the word starts");
|
|
193
193
|
else if (word.end_s > duration)
|
|
194
|
-
issue(["transcript", index, "end_s"],
|
|
194
|
+
issue(["transcript", index, "end_s"], pastTheSource(word.end_s, duration));
|
|
195
195
|
if (index && word.start_s < profile.transcript[index - 1].start_s)
|
|
196
196
|
issue(["transcript", index, "start_s"], "starts before the word before it: words are in order");
|
|
197
197
|
});
|
|
198
198
|
if (profile.hook && profile.hook.end_s > duration)
|
|
199
|
-
issue(["hook", "end_s"],
|
|
199
|
+
issue(["hook", "end_s"], pastTheSource(profile.hook.end_s, duration));
|
|
200
200
|
const ids = new Set(profile.speakers?.map(speaker => speaker.id) ?? []);
|
|
201
201
|
profile.speakers?.forEach((speaker, index) => {
|
|
202
202
|
if (profile.speakers.findIndex(other => other.id === speaker.id) < index)
|
|
@@ -205,8 +205,10 @@ function checkProfile(profile, ctx) {
|
|
|
205
205
|
issue(["speakers", index, "frames_s"], `cites a second past the ${duration} s source`);
|
|
206
206
|
});
|
|
207
207
|
profile.segments?.forEach((segment, index) => {
|
|
208
|
-
if (segment.end_s < segment.start_s
|
|
209
|
-
issue(["segments", index, "end_s"], "ends before it starts
|
|
208
|
+
if (segment.end_s < segment.start_s)
|
|
209
|
+
issue(["segments", index, "end_s"], "ends before it starts");
|
|
210
|
+
else if (segment.end_s > duration)
|
|
211
|
+
issue(["segments", index, "end_s"], pastTheSource(segment.end_s, duration));
|
|
210
212
|
if (profile.speakers && !ids.has(segment.speaker))
|
|
211
213
|
issue(["segments", index, "speaker"], `${segment.speaker} is not in speakers`);
|
|
212
214
|
if (segment.frames_s.some(t => t >= duration))
|
|
@@ -221,8 +223,8 @@ function checkProfile(profile, ctx) {
|
|
|
221
223
|
issue(["beats", index, "end_frac"], "ends where or before the beat starts");
|
|
222
224
|
else if (beat.end_s <= beat.start_s)
|
|
223
225
|
issue(["beats", index, "end_s"], "ends where or before the beat starts");
|
|
224
|
-
if (beat.end_s >
|
|
225
|
-
issue(["beats", index, "end_s"],
|
|
226
|
+
if (beat.end_s > duration)
|
|
227
|
+
issue(["beats", index, "end_s"], pastTheSource(beat.end_s, duration));
|
|
226
228
|
for (const t of [...beat.key_frame_s === undefined ? [] : [beat.key_frame_s], ...beat.frames_s ?? [], ...beat.gaze?.frames_s ?? [],
|
|
227
229
|
...(beat.gestures ?? []).flatMap(gesture => gesture.frames_s)]) {
|
|
228
230
|
if (t >= duration)
|
|
@@ -250,7 +252,7 @@ function checkProfile(profile, ctx) {
|
|
|
250
252
|
if (shot.end_s <= shot.start_s)
|
|
251
253
|
issue(["shots", index, "end_s"], "ends where or before the shot starts");
|
|
252
254
|
if (shot.end_s > duration)
|
|
253
|
-
issue(["shots", index, "end_s"],
|
|
255
|
+
issue(["shots", index, "end_s"], pastTheSource(shot.end_s, duration));
|
|
254
256
|
else if (index === profile.shots.length - 1 && shot.end_s < duration - 1e-6)
|
|
255
257
|
issue(["shots", index, "end_s"], "the last shot ends with the reel");
|
|
256
258
|
if (before ? Math.abs(shot.start_s - before.end_s) > 1e-6 : shot.start_s !== 0)
|
|
@@ -266,7 +268,7 @@ function checkProfile(profile, ctx) {
|
|
|
266
268
|
});
|
|
267
269
|
profile.sound_events?.forEach((event, index) => {
|
|
268
270
|
if (event.t_s > duration)
|
|
269
|
-
issue(["sound_events", index, "t_s"],
|
|
271
|
+
issue(["sound_events", index, "t_s"], pastTheSource(event.t_s, duration));
|
|
270
272
|
if (index && event.t_s < profile.sound_events[index - 1].t_s)
|
|
271
273
|
issue(["sound_events", index, "t_s"], "comes before the event before it: events are in order");
|
|
272
274
|
});
|
|
@@ -623,6 +623,7 @@ export declare const referenceStaging: z.ZodObject<{
|
|
|
623
623
|
}, z.core.$strict>>>;
|
|
624
624
|
}, z.core.$strict>;
|
|
625
625
|
export type ReferenceStaging = z.infer<typeof referenceStaging>;
|
|
626
|
+
export declare const pastTheSource: (t: number, duration: number) => string;
|
|
626
627
|
export declare function stagingIssues(staging: ReferenceStaging, beats: readonly {
|
|
627
628
|
graphics: readonly unknown[];
|
|
628
629
|
}[], duration: number): {
|
|
@@ -84,6 +84,7 @@ export const referenceStaging = z.strictObject({
|
|
|
84
84
|
freezes: z.array(stagingFreeze).max(8),
|
|
85
85
|
flashes: z.array(stagingFlash).max(80).optional().describe("Each flash anchor's light: when it starts, how long and how bright it is, and its colour."),
|
|
86
86
|
});
|
|
87
|
+
export const pastTheSource = (t, duration) => `${Math.round(t * 1e4) / 1e4} s lies past the ${Math.round(duration * 1e4) / 1e4} s source`;
|
|
87
88
|
export function stagingIssues(staging, beats, duration) {
|
|
88
89
|
const out = [];
|
|
89
90
|
const ids = new Set();
|
|
@@ -92,7 +93,7 @@ export function stagingIssues(staging, beats, duration) {
|
|
|
92
93
|
out.push({ path: ["anchors", index, "id"], message: `${anchor.id} is named twice` });
|
|
93
94
|
ids.add(anchor.id);
|
|
94
95
|
if (anchor.t_s > duration)
|
|
95
|
-
out.push({ path: ["anchors", index, "t_s"], message:
|
|
96
|
+
out.push({ path: ["anchors", index, "t_s"], message: pastTheSource(anchor.t_s, duration) });
|
|
96
97
|
});
|
|
97
98
|
const refs = (path, list) => list?.forEach((ref, index) => {
|
|
98
99
|
if (!ids.has(ref.id))
|
|
@@ -102,7 +103,7 @@ export function stagingIssues(staging, beats, duration) {
|
|
|
102
103
|
const known = times.filter((entry) => entry[1] !== undefined);
|
|
103
104
|
known.forEach(([field, t], index) => {
|
|
104
105
|
if (t > duration)
|
|
105
|
-
out.push({ path: [...path, field], message:
|
|
106
|
+
out.push({ path: [...path, field], message: pastTheSource(t, duration) });
|
|
106
107
|
const before = known[index - 1];
|
|
107
108
|
if (before && t < before[1])
|
|
108
109
|
out.push({ path: [...path, field], message: `comes before ${before[0]}` });
|
|
@@ -121,7 +122,7 @@ export function stagingIssues(staging, beats, duration) {
|
|
|
121
122
|
ordered(path, [["entry.first_visible_s", element.entry?.first_visible_s], ["entry.settled_s", element.entry?.settled_s],
|
|
122
123
|
["exit.last_visible_s", element.exit?.last_visible_s]]);
|
|
123
124
|
element.rects?.forEach((sample, at) => { if (sample.t_s > duration)
|
|
124
|
-
out.push({ path: [...path, "rects", at, "t_s"], message:
|
|
125
|
+
out.push({ path: [...path, "rects", at, "t_s"], message: pastTheSource(sample.t_s, duration) }); });
|
|
125
126
|
});
|
|
126
127
|
staging.flashes?.forEach((flash, index) => {
|
|
127
128
|
if (!ids.has(flash.id))
|
|
@@ -129,14 +130,14 @@ export function stagingIssues(staging, beats, duration) {
|
|
|
129
130
|
if (staging.flashes.findIndex(other => other.id === flash.id) < index)
|
|
130
131
|
out.push({ path: ["flashes", index, "id"], message: `${flash.id} is measured twice` });
|
|
131
132
|
if (flash.t_s + flash.length_s > duration + 0.05)
|
|
132
|
-
out.push({ path: ["flashes", index, "length_s"], message:
|
|
133
|
+
out.push({ path: ["flashes", index, "length_s"], message: pastTheSource(flash.t_s + flash.length_s, duration) });
|
|
133
134
|
});
|
|
134
135
|
staging.freezes.forEach((freeze, index) => {
|
|
135
136
|
refs(["freezes", index, "anchors"], freeze.anchors);
|
|
136
137
|
if (freeze.end_s <= freeze.start_s)
|
|
137
138
|
out.push({ path: ["freezes", index, "end_s"], message: "ends where or before the freeze starts" });
|
|
138
139
|
if (freeze.end_s > duration)
|
|
139
|
-
out.push({ path: ["freezes", index, "end_s"], message:
|
|
140
|
+
out.push({ path: ["freezes", index, "end_s"], message: pastTheSource(freeze.end_s, duration) });
|
|
140
141
|
});
|
|
141
142
|
return out;
|
|
142
143
|
}
|
package/dist/skills.js
CHANGED
|
@@ -250,7 +250,10 @@ const serverInstructions = (offer, adGuide, facelessDiy = false) => "Clipwright
|
|
|
250
250
|
"the user asks. Offer to save the confirmed design with brand_kit so a series keeps one look.\n\n" +
|
|
251
251
|
"To study another creator, analyze_creator(link) reads an Instagram or TikTok creator's latest 12 videos with each " +
|
|
252
252
|
"video's x to their median, and analyze_reference breaks one video down into a style profile. Show a creator " +
|
|
253
|
-
"profile's or a trend search's display_markdown table first, as it came
|
|
253
|
+
"profile's or a trend search's display_markdown table first, as it came.\n\n" +
|
|
254
|
+
"A photo attached in chat does not reach Clipwright. create_upload with no arguments returns a page_url where the user " +
|
|
255
|
+
"drops the photo, and get_upload then returns it. The person's own photo is what a video of them is made from, so a " +
|
|
256
|
+
"drawn stand-in does not replace it.";
|
|
254
257
|
export const MCP_SERVER_INSTRUCTIONS = mcpServerInstructions({ ownAgent: false });
|
|
255
258
|
export const MAKE_FACELESS_DESCRIPTION = "Start a paid finished faceless video from a script or brief. You select 30–90 seconds; " +
|
|
256
259
|
"the video ends with its narration, runs at least 25 seconds (an explainer, as long as its narration) and at most a quarter past the selection, never beyond 90. " +
|
package/dist/trend-search.d.ts
CHANGED
|
@@ -538,5 +538,6 @@ export declare const TREND_DISPLAY_HINT: string;
|
|
|
538
538
|
export declare const TREND_PLATFORM_NAMES: Readonly<Record<TrendPlatform, string>>;
|
|
539
539
|
export declare function trendSearchMarkdown(answer: TrendSearchAnswer): string;
|
|
540
540
|
export declare const FIND_TRENDS_DESCRIPTION: string;
|
|
541
|
+
export declare const GET_TREND_SEARCH_DESCRIPTION: string;
|
|
541
542
|
export declare const QUOTE_TRENDS_DESCRIPTION: string;
|
|
542
543
|
export {};
|
package/dist/trend-search.js
CHANGED
|
@@ -542,13 +542,18 @@ function nextPageLine(answer) {
|
|
|
542
542
|
}
|
|
543
543
|
export const FIND_TRENDS_DESCRIPTION = `Reels that took off on a topic: up to ${TREND_SEARCH_REELS} per platform, one per creator, TikTok and Instagram in one ranking by ` +
|
|
544
544
|
"x_median (views over the creator's median). Charged only on success, a mix that reached one platform too; " +
|
|
545
|
-
`${TREND_SEARCH_PER_HOUR} per hour. poll
|
|
545
|
+
`${TREND_SEARCH_PER_HOUR} per hour. An unfinished answer's poll names get_trend_search, free. Each reel says why it is here, and a reel measured before carries its speed now; ` +
|
|
546
546
|
"the same call with another sort reorders the same search for free within the hour. A weak result (under two reels that took off) " +
|
|
547
547
|
"lists suggested_wordings: search again with one. With no keywords it searches the primary saved niche (trend_niches). " +
|
|
548
548
|
`A finished search has gallery_url, a page with covers to share for ${TREND_GALLERY_DAYS} days. ` +
|
|
549
549
|
`next_page: up to ${TREND_SEARCH_REELS} more places per platform (search_id and page, nothing else), up to ` +
|
|
550
550
|
`${TREND_SEARCH_MAX_PAGES} pages, free for ${TREND_PAGE_WINDOW_SECONDS / 3600} hours after the search, up to ` +
|
|
551
551
|
`${TREND_FREE_PAGES_PER_DAY} pages a day per account; past that ${TREND_PAGE_PAID_CREDITS} credits a page.`;
|
|
552
|
+
export const GET_TREND_SEARCH_DESCRIPTION = "Read a search or a next page started by find_trends: state queued or searching, succeeded with result and warnings, or failed " +
|
|
553
|
+
"with error.code and error.message. " +
|
|
554
|
+
`wait_seconds (at most ${REFERENCE_WAIT_MAX_SECONDS}) holds the answer until the search finishes or the wait ends; an unfinished ` +
|
|
555
|
+
"answer carries retry_after_seconds and poll. sort reorders the reels. display_markdown is a ready table; display_hint says " +
|
|
556
|
+
"how to show it. untrusted_content lists the third-party text fields. credits_charged is the price once succeeded. Free.";
|
|
552
557
|
export const QUOTE_TRENDS_DESCRIPTION = `Price find_trends: 0 when the same query from the last hour would answer or a free search applies ` +
|
|
553
558
|
`(${TREND_FREE_SEARCHES_PER_MONTH} a month; free_searches_left). With search_id and page: a next page, free for ` +
|
|
554
559
|
`${TREND_PAGE_WINDOW_SECONDS / 3600} hours after the search, up to ${TREND_FREE_PAGES_PER_DAY} pages a day per account, ` +
|
package/dist/uploads.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ export declare const UPLOADS_PATH = "/v1/uploads";
|
|
|
10
10
|
export declare const UPLOAD_IMPORT_PATH = "/v1/uploads/import";
|
|
11
11
|
export declare const UPLOAD_INTENTS_PATH = "/v1/uploads/intents";
|
|
12
12
|
export declare const UPLOAD_ITEM_PATH = "/v1/uploads/:id";
|
|
13
|
+
export declare const UPLOAD_PAGES_PATH = "/v1/uploads/pages";
|
|
14
|
+
export declare const UPLOAD_PAGE_DROP_PATH = "/v1/public/upload-pages/:token";
|
|
15
|
+
export declare const UPLOAD_PAGE_WEB_PATH = "/upload";
|
|
16
|
+
export declare const UPLOAD_PAGE_TTL_SECONDS = 1800;
|
|
17
|
+
export declare const UPLOAD_PAGE_DROPS_PER_HOUR = 20;
|
|
18
|
+
export declare const UPLOAD_PAGE_DROP_WINDOW_SECONDS = 3600;
|
|
19
|
+
export declare const uploadPageToken: z.ZodString;
|
|
20
|
+
export declare const redactUploadPageToken: (path: string) => string;
|
|
13
21
|
export declare const UPLOAD_PUT_URL_TTL_SECONDS = 900;
|
|
14
22
|
export declare const UPLOAD_INTENT_FINISH_SECONDS = 86400;
|
|
15
23
|
export declare const UPLOAD_FINISH_LEASE_SECONDS = 60;
|
|
@@ -22,6 +30,24 @@ export declare const URL_IMPORT_IMAGE_DEADLINE_MS = 20000;
|
|
|
22
30
|
export declare const URL_IMPORT_MAX_REDIRECTS = 3;
|
|
23
31
|
export declare const UPLOAD_MAX_SIDE = 8192;
|
|
24
32
|
export declare const uploadId: z.ZodString;
|
|
33
|
+
export declare const uploadPageRequest: z.ZodObject<{}, z.core.$strict>;
|
|
34
|
+
export declare const uploadPageResponse: z.ZodObject<{
|
|
35
|
+
upload_id: z.ZodString;
|
|
36
|
+
page_url: z.ZodString;
|
|
37
|
+
expires_at: z.ZodString;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export type UploadPageResponse = z.infer<typeof uploadPageResponse>;
|
|
40
|
+
export declare const uploadPageRead: z.ZodObject<{
|
|
41
|
+
upload_id: z.ZodString;
|
|
42
|
+
page_url: z.ZodString;
|
|
43
|
+
expires_at: z.ZodString;
|
|
44
|
+
}, z.core.$loose>;
|
|
45
|
+
export type UploadPageRead = z.infer<typeof uploadPageRead>;
|
|
46
|
+
export declare const uploadPageDropResponse: z.ZodObject<{
|
|
47
|
+
upload_id: z.ZodString;
|
|
48
|
+
width: z.ZodNumber;
|
|
49
|
+
height: z.ZodNumber;
|
|
50
|
+
}, z.core.$strict>;
|
|
25
51
|
export declare const uploadImportRequest: z.ZodObject<{
|
|
26
52
|
url: z.ZodString;
|
|
27
53
|
}, z.core.$strict>;
|
package/dist/uploads.js
CHANGED
|
@@ -9,6 +9,14 @@ export const UPLOADS_PATH = "/v1/uploads";
|
|
|
9
9
|
export const UPLOAD_IMPORT_PATH = "/v1/uploads/import";
|
|
10
10
|
export const UPLOAD_INTENTS_PATH = "/v1/uploads/intents";
|
|
11
11
|
export const UPLOAD_ITEM_PATH = "/v1/uploads/:id";
|
|
12
|
+
export const UPLOAD_PAGES_PATH = "/v1/uploads/pages";
|
|
13
|
+
export const UPLOAD_PAGE_DROP_PATH = "/v1/public/upload-pages/:token";
|
|
14
|
+
export const UPLOAD_PAGE_WEB_PATH = "/upload";
|
|
15
|
+
export const UPLOAD_PAGE_TTL_SECONDS = 1800;
|
|
16
|
+
export const UPLOAD_PAGE_DROPS_PER_HOUR = 20;
|
|
17
|
+
export const UPLOAD_PAGE_DROP_WINDOW_SECONDS = 3600;
|
|
18
|
+
export const uploadPageToken = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
19
|
+
export const redactUploadPageToken = (path) => path.replace(/(\/(?:upload-pages|upload)\/)[^/]+/, "$1<token>");
|
|
12
20
|
export const UPLOAD_PUT_URL_TTL_SECONDS = 900;
|
|
13
21
|
export const UPLOAD_INTENT_FINISH_SECONDS = 86_400;
|
|
14
22
|
export const UPLOAD_FINISH_LEASE_SECONDS = 60;
|
|
@@ -22,6 +30,18 @@ export const URL_IMPORT_MAX_REDIRECTS = 3;
|
|
|
22
30
|
export const UPLOAD_MAX_SIDE = 8192;
|
|
23
31
|
export const uploadId = z.string().regex(/^upl_[a-f0-9]{32}$/);
|
|
24
32
|
const sha256Hex = z.string().regex(/^[a-f0-9]{64}$/);
|
|
33
|
+
export const uploadPageRequest = z.strictObject({});
|
|
34
|
+
export const uploadPageResponse = z.strictObject({
|
|
35
|
+
upload_id: uploadId,
|
|
36
|
+
page_url: z.string().url(),
|
|
37
|
+
expires_at: z.string().datetime(),
|
|
38
|
+
});
|
|
39
|
+
export const uploadPageRead = uploadPageResponse.loose();
|
|
40
|
+
export const uploadPageDropResponse = z.strictObject({
|
|
41
|
+
upload_id: uploadId,
|
|
42
|
+
width: z.number().int().positive(),
|
|
43
|
+
height: z.number().int().positive(),
|
|
44
|
+
});
|
|
25
45
|
export const uploadImportRequest = z.strictObject({
|
|
26
46
|
url: z.string().url().startsWith("https://").max(2048),
|
|
27
47
|
});
|
|
@@ -87,8 +107,12 @@ export const UPLOAD_IMAGE_DESCRIPTION = "Get an upload_id and a signed https url
|
|
|
87
107
|
`${UPLOAD_OBJECT_RETENTION_DAYS} days. For ` +
|
|
88
108
|
"workflow assets the upload_id is both asset_id and content_digest: the SHA-256 of the original " +
|
|
89
109
|
"bytes. Set `aspect_ratio` to match the picture. For a file on your disk while this server is remote, " +
|
|
90
|
-
"use create_upload. Free; 200 uploads per day per account, at most 30 url downloads per hour.";
|
|
91
|
-
export const CREATE_UPLOAD_DESCRIPTION = "
|
|
110
|
+
"use create_upload; for a photo attached in chat, create_upload with no arguments gives a page link to drop it on. Free; 200 uploads per day per account, at most 30 url downloads per hour.";
|
|
111
|
+
export const CREATE_UPLOAD_DESCRIPTION = "With no arguments it returns an upload_id and a page_url, a page where a person drops one photo in a browser (PNG or " +
|
|
112
|
+
"JPEG; other phone photos are converted). It suits a photo you cannot send yourself, such as one attached in chat: " +
|
|
113
|
+
"the user opens the page_url, and get_upload with the upload_id answers upload_not_finished until the photo is " +
|
|
114
|
+
"dropped. The link takes one photo and works for 30 minutes. " +
|
|
115
|
+
"With media_type, bytes and sha256 it uploads a LOCAL PNG or JPEG (up to 10 MB) through a one-time presigned PUT; use it when this server is remote and " +
|
|
92
116
|
"you have a shell. Pass media_type, the exact size in bytes and the file's sha256 (`sha256sum <file>` or " +
|
|
93
117
|
"`shasum -a 256 <file>`). Within 15 minutes run: `curl -X PUT -H 'content-type: <media_type>' --data-binary " +
|
|
94
118
|
"@<file> '<put_url>'` (curl sends the content-length itself; both headers must match what you declared). Once the " +
|
|
@@ -97,5 +121,5 @@ export const CREATE_UPLOAD_DESCRIPTION = "Upload a LOCAL PNG or JPEG (up to 10 M
|
|
|
97
121
|
"read content_digest, width and height; other tools that take an upload_id need that call first. Use the " +
|
|
98
122
|
"upload_id within 24 hours. Free; counts toward 200 uploads per day.";
|
|
99
123
|
export const GET_UPLOAD_DESCRIPTION = "Read one upload by upload_id: a freshly signed https url, content_digest, media_type, bytes, width, height and " +
|
|
100
|
-
"usable_until. After create_upload it also confirms the PUT: it answers upload_not_finished until
|
|
101
|
-
"there and upload_expired
|
|
124
|
+
"usable_until. After create_upload it also confirms the PUT or the page drop: it answers upload_not_finished until " +
|
|
125
|
+
"the file is there and upload_expired once the PUT window (24 hours) or the page link (30 minutes) has passed. Free.";
|