@clipwright/core 0.75.2 → 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/endpoint-notes.js +7 -7
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -2
- package/dist/prices.js +7 -3
- package/dist/reference-analysis.d.ts +27 -2
- package/dist/reference-analysis.js +50 -19
- package/package.json +1 -1
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.",
|
|
@@ -64,12 +64,12 @@ export const ENDPOINT_NOTES = {
|
|
|
64
64
|
"GET /v1/assets/{id}": "One live asset with a link signed for an hour. Free.",
|
|
65
65
|
"POST /v1/assets/{id}": "Renames an asset or changes its role. Free.",
|
|
66
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.",
|
|
67
|
-
"POST /v1/reference-analyses/quote": `Prices an analysis of this asset or link: ${
|
|
68
|
-
|
|
69
|
-
"POST /v1/reference-analyses": `Starts reading an MP4 asset, up to ${REFERENCE_ANALYSIS_MAX_SECONDS.full} s, into a reference profile (or, with mode data,
|
|
70
|
-
|
|
71
|
-
"answers at once; the same asset in the same mode answers the same analysis for free.
|
|
72
|
-
`${
|
|
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. ` +
|
|
73
73
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per hour.`,
|
|
74
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.",
|
|
75
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/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;
|
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
|
},
|
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(),
|
|
@@ -211,8 +213,10 @@ function buildPriceList(offer, diy) {
|
|
|
211
213
|
"with no call, interview, presenter_gaze or talking shot and no presenter part longer than about 36 s; any other video renders " +
|
|
212
214
|
"on HeyGen Avatar IV. Presenter seconds are the seconds a presenter take fills, counted once over the video and rounded up; " +
|
|
213
215
|
"production seconds are every second of the finished video." })] : []),
|
|
214
|
-
paid({ tool: "analyze_reference", route: "POST /v1/reference-analyses",
|
|
215
|
-
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. " +
|
|
216
220
|
"Starting it again on the same asset answers the same analysis for free." }),
|
|
217
221
|
paid({ tool: "analyze_reference", route: "POST /v1/reference-analyses", variant: "data mode", unit: "call", credits: REFERENCE_DATA_CREDITS,
|
|
218
222
|
quote_tool: "quote_analysis", notes: "mode: \"data\": duration, size, timed transcript, hook and a frame sheet, without the vision pass. " +
|
|
@@ -7,11 +7,29 @@ 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 REFERENCE_ANALYSIS_MODE_CREDITS: Readonly<Record<ReferenceAnalysisMode, number>>;
|
|
15
33
|
export declare const REFERENCE_ANALYSIS_MAX_SECONDS: Readonly<Record<ReferenceAnalysisMode, number>>;
|
|
16
34
|
export declare function referenceTooLongMessage(mode: ReferenceAnalysisMode, seconds: number, subject?: string): string | null;
|
|
17
35
|
export declare const isReferenceTooLongMessage: (line: string) => boolean;
|
|
@@ -23,6 +41,8 @@ export declare const REFERENCE_DATA_SHEET_MAX_WIDTH = 1080;
|
|
|
23
41
|
export declare const REFERENCE_ANALYSIS_WINDOW_SECONDS = 3600;
|
|
24
42
|
export declare const REFERENCE_ANALYSIS_WORK_SECONDS = 420;
|
|
25
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;
|
|
26
46
|
export declare const REFERENCE_ANALYSIS_DEADLINE_SECONDS = 900;
|
|
27
47
|
export declare const REFERENCE_ANALYSIS_STATES: readonly ["queued", "analyzing", "succeeded", "failed"];
|
|
28
48
|
export declare const REFERENCE_ANALYSIS_ERRORS: readonly ["timed_out", "analysis_failed", "asset_gone", "enqueue_failed"];
|
|
@@ -1474,6 +1494,11 @@ export type ReferenceAnalysis = z.infer<typeof referenceAnalysis>;
|
|
|
1474
1494
|
export declare const analysisQuoteResponse: z.ZodObject<{
|
|
1475
1495
|
asset_id: z.ZodNullable<z.ZodString>;
|
|
1476
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>;
|
|
1477
1502
|
replays_analysis_id: z.ZodNullable<z.ZodString>;
|
|
1478
1503
|
repeat_note: z.ZodString;
|
|
1479
1504
|
warnings: z.ZodArray<z.ZodString>;
|
|
@@ -12,24 +12,48 @@ 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 REFERENCE_ANALYSIS_MODE_CREDITS = {
|
|
19
|
-
full: REFERENCE_ANALYSIS_CREDITS, data: REFERENCE_DATA_CREDITS,
|
|
20
|
-
};
|
|
21
47
|
export const REFERENCE_ANALYSIS_MAX_SECONDS = {
|
|
22
|
-
full:
|
|
48
|
+
full: ANALYSIS_VIDEO_MAX_SECONDS, data: ANALYSIS_VIDEO_MAX_SECONDS,
|
|
23
49
|
};
|
|
24
50
|
const REFERENCE_TOO_LONG_LEAD = "the reel lasts ";
|
|
25
51
|
export function referenceTooLongMessage(mode, seconds, subject = "the reel") {
|
|
26
52
|
const most = REFERENCE_ANALYSIS_MAX_SECONDS[mode];
|
|
27
53
|
if (seconds <= most)
|
|
28
54
|
return null;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
? `${lead}; start it with mode: "data", which reads reels up to ${REFERENCE_ANALYSIS_MAX_SECONDS.data} s, for ${REFERENCE_DATA_CREDITS} credits`
|
|
32
|
-
: `${lead}; use a shorter clip`;
|
|
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";
|
|
33
57
|
}
|
|
34
58
|
export const isReferenceTooLongMessage = (line) => line.startsWith(REFERENCE_TOO_LONG_LEAD) && / analysis reads at most \d+ s/.test(line);
|
|
35
59
|
export const REFERENCE_ANALYSIS_PER_HOUR = 10;
|
|
@@ -40,6 +64,8 @@ export const REFERENCE_DATA_SHEET_MAX_WIDTH = 1080;
|
|
|
40
64
|
export const REFERENCE_ANALYSIS_WINDOW_SECONDS = 3600;
|
|
41
65
|
export const REFERENCE_ANALYSIS_WORK_SECONDS = 420;
|
|
42
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;
|
|
43
69
|
export const REFERENCE_ANALYSIS_DEADLINE_SECONDS = 900;
|
|
44
70
|
export const REFERENCE_ANALYSIS_STATES = ["queued", "analyzing", "succeeded", "failed"];
|
|
45
71
|
export const REFERENCE_ANALYSIS_ERRORS = ["timed_out", "analysis_failed", "asset_gone", "enqueue_failed"];
|
|
@@ -84,11 +110,11 @@ export function classifyReferenceUrl(raw) {
|
|
|
84
110
|
}
|
|
85
111
|
export const analyzeReferenceRequest = z.strictObject({
|
|
86
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, ` +
|
|
87
|
-
`or ${ANALYSIS_VIDEO_MAX_SECONDS} s for an analysis_only asset
|
|
113
|
+
`or ${ANALYSIS_VIDEO_MAX_SECONDS} s for an analysis_only asset`),
|
|
88
114
|
source_url: z.string().url().startsWith("https://").max(2048).optional()
|
|
89
115
|
.describe(`instead of asset_id: ${REFERENCE_URL_ACCEPTED}; YouTube is refused`),
|
|
90
|
-
mode: z.enum(REFERENCE_ANALYSIS_MODES).optional().describe(`full (default, ${
|
|
91
|
-
`${
|
|
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): ` +
|
|
92
118
|
"duration, size, timed transcript, scenes between measured cuts, hook and a 3×3 frame sheet, without beats or graphics"),
|
|
93
119
|
max_credits: maxCreditsField,
|
|
94
120
|
}).refine((request) => (request.asset_id === undefined) !== (request.source_url === undefined), {
|
|
@@ -206,7 +232,7 @@ export const referenceFramesPage = z.strictObject({
|
|
|
206
232
|
.describe(`End second, exclusive; at most ${REFERENCE_FRAMES_PAGE_MAX} frames a page.`),
|
|
207
233
|
});
|
|
208
234
|
export const REFERENCE_WAIT_MAX_SECONDS = 50;
|
|
209
|
-
export const REFERENCE_EXPECTED_SECONDS = { full:
|
|
235
|
+
export const REFERENCE_EXPECTED_SECONDS = { full: 210, data: 45 };
|
|
210
236
|
export const referenceAnalysisQuery = referenceFramesPage.extend({
|
|
211
237
|
wait_seconds: z.coerce.number().int().min(0).max(REFERENCE_WAIT_MAX_SECONDS).optional()
|
|
212
238
|
.describe(`Wait up to this many seconds (at most ${REFERENCE_WAIT_MAX_SECONDS}) for the analysis to finish before answering.`),
|
|
@@ -253,6 +279,8 @@ export const referenceAnalysis = z.strictObject({
|
|
|
253
279
|
export const analysisQuoteResponse = z.strictObject({
|
|
254
280
|
asset_id: assetId.nullable(),
|
|
255
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(),
|
|
256
284
|
replays_analysis_id: referenceAnalysisId.nullable(),
|
|
257
285
|
repeat_note: z.string(),
|
|
258
286
|
warnings: z.array(z.string()),
|
|
@@ -289,8 +317,8 @@ export const ANALYZE_REFERENCE_DESCRIPTION = "Break down any reel or ad into a r
|
|
|
289
317
|
"graphic's label_hint. speakers names who talks, on or off screen, with their caption look; each beat names its speaker, gaze " +
|
|
290
318
|
"and gestures, each claim citing frames_s. " +
|
|
291
319
|
"What we cannot draw is in unmapped with a substitute and in warnings. Pass asset_id of an MP4 asset (create_asset " +
|
|
292
|
-
`with kind: "video"), at most 100 MiB, or source_url: ${REFERENCE_URL_ACCEPTED}.
|
|
293
|
-
`${REFERENCE_ANALYSIS_MAX_SECONDS.full} s
|
|
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 ` +
|
|
294
322
|
"is refused at no charge, before its video is downloaded when the platform gives its length, and the error message names the limit. " +
|
|
295
323
|
"A link becomes an analysis-only asset (asset_id in the answer), and source carries the post's caption, author, engagement, " +
|
|
296
324
|
"the author's followers and median views with the ratio (x), the top 50 comments and their code words; a number, caption or " +
|
|
@@ -299,11 +327,12 @@ export const ANALYZE_REFERENCE_DESCRIPTION = "Break down any reel or ad into a r
|
|
|
299
327
|
`mode: "data" skips beats and graphics and answers data: duration, size and fps, the timed ` +
|
|
300
328
|
"transcript and segments, scenes between measured cuts with their segments, the hook with the post's caption line and its frame, " +
|
|
301
329
|
"and a 3×3 frame sheet, plus source for a link; no speech gives an empty transcript and a " +
|
|
302
|
-
`warning.
|
|
303
|
-
|
|
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. " +
|
|
304
333
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per hour per account. ` +
|
|
305
334
|
`Answers at once with state queued; call get_reference_analysis with wait_seconds: ${REFERENCE_WAIT_MAX_SECONDS} until succeeded or failed ` +
|
|
306
|
-
"(full about 2–
|
|
335
|
+
"(full about 2–4 minutes, data under one). " +
|
|
307
336
|
"The same asset, or reel by its full link, in the same mode returns the same analysis, free, unless it " +
|
|
308
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 " +
|
|
309
338
|
"once (replaces_analysis_id names the old one, still readable). The asset is not changed. " +
|
|
@@ -324,7 +353,9 @@ export const GET_REFERENCE_ANALYSIS_DESCRIPTION = "Read an analysis started by a
|
|
|
324
353
|
"0 once failed; repeat_note says " +
|
|
325
354
|
"what asking again costs. Free.";
|
|
326
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 " +
|
|
327
|
-
`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 " +
|
|
328
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 " +
|
|
329
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 " +
|
|
330
361
|
"unknown link is refused here too. Free; starts nothing.";
|