@clipwright/core 0.75.0 → 0.75.2
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 +5 -2
- package/dist/endpoints.js +2 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +2 -0
- package/dist/openapi.js +5 -1
- package/dist/prices.js +23 -9
- package/dist/reference-analysis.d.ts +31 -1
- package/dist/reference-analysis.js +41 -11
- 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 { REFERENCE_ANALYSIS_CREDITS, REFERENCE_ANALYSIS_PER_HOUR, REFERENCE_DATA_CREDITS, REFERENCE_DATA_PER_HOUR } from "./reference-analysis.js";
|
|
7
|
+
import { REFERENCE_ANALYSIS_CREDITS, REFERENCE_ANALYSIS_MAX_SECONDS, REFERENCE_ANALYSIS_PER_HOUR, REFERENCE_DATA_CREDITS, REFERENCE_DATA_PER_HOUR } 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.",
|
|
@@ -64,7 +66,8 @@ export const ENDPOINT_NOTES = {
|
|
|
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
67
|
"POST /v1/reference-analyses/quote": `Prices an analysis of this asset or link: ${REFERENCE_ANALYSIS_CREDITS} credits, ${REFERENCE_DATA_CREDITS} with mode data, or 0 when ` +
|
|
66
68
|
"its live analysis in that mode would answer. Charges nothing.",
|
|
67
|
-
"POST /v1/reference-analyses":
|
|
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, up to ` +
|
|
70
|
+
`${REFERENCE_ANALYSIS_MAX_SECONDS.data} s, its transcript, hook, scenes and frames) and ` +
|
|
68
71
|
"answers at once; the same asset in the same mode answers the same analysis for free. Holds " +
|
|
69
72
|
`${REFERENCE_ANALYSIS_CREDITS} credits (${REFERENCE_DATA_CREDITS} for data), charged once it succeeds; a failed one costs nothing. ` +
|
|
70
73
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per 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
|
@@ -244,7 +244,7 @@ export type EditCeilingReachedError = z.infer<typeof editCeilingReachedError>;
|
|
|
244
244
|
export declare function editCeilingReachedBody(args: Omit<EditCeilingReachedError["error"], "code" | "message">, counting?: "revision" | "candidate"): EditCeilingReachedError;
|
|
245
245
|
export declare function unusableSourceMessage(errorClass: string, detail: string): string;
|
|
246
246
|
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"];
|
|
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_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
248
|
export type BareApiErrorCode = (typeof BARE_ERROR_CODES)[number];
|
|
249
249
|
export declare const API_ERROR_CODES: readonly string[];
|
|
250
250
|
export declare function apiErrorBody(args: {
|
package/dist/errors.js
CHANGED
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
|
@@ -89,6 +89,7 @@ const FREE_TOOLS = {
|
|
|
89
89
|
get_creator_profile: "GET /v1/creator-profiles/{id}",
|
|
90
90
|
delete_creator_profile: "DELETE /v1/creator-profiles/{id}",
|
|
91
91
|
quote_trends: "POST /v1/trend-searches/quote",
|
|
92
|
+
get_trend_search: "GET /v1/trend-searches/{id}",
|
|
92
93
|
trend_niches: "POST /v1/trend-niches",
|
|
93
94
|
list_workflows: "GET /v1/public/workflows",
|
|
94
95
|
get_workflow: "GET /v1/public/workflows/{id}",
|
|
@@ -181,16 +182,18 @@ function buildPriceList(offer, diy) {
|
|
|
181
182
|
const unit = EDIT_UNIT_PRICES;
|
|
182
183
|
const parts = PARTS_FACE_TARIFF;
|
|
183
184
|
const shotRates = parts.shotCreditsPerSecond ?? SHOT_CREDITS_PER_SECOND;
|
|
185
|
+
const shotLines = liveShots ? SHOT_ENGINES.flatMap((shot) => shotRates[shot] === undefined ? []
|
|
186
|
+
: [{ label: SHOT_ENGINE_LABELS[shot], unit: "face_second", credits: shotRates[shot] }]) : [];
|
|
187
|
+
const sceneLines = scenes ? [{ label: "scene made for the video", unit: "scene", credits: SCENE_CREDITS }] : [];
|
|
188
|
+
const musicLine = { label: "music under the voice", unit: "track", credits: MUSIC_BED_CREDITS };
|
|
184
189
|
return [
|
|
185
190
|
...PRESENTER_ENGINES.map((engine) => paid({ tool: "make_ugc", route: "POST /v1/skills/make_ugc/run",
|
|
186
191
|
variant: engine === "heygen" ? "HeyGen presenter" : "OmniHuman presenter", quote_tool: "quote_ugc", minimum_credits: parts.minimumCredits,
|
|
187
192
|
lines: [{ label: PRESENTER_ENGINE_LABELS[engine], unit: "face_second", credits: parts.presenterCreditsPerSecond[engine] },
|
|
188
|
-
...
|
|
189
|
-
: [{ label: SHOT_ENGINE_LABELS[shot], unit: "face_second", credits: shotRates[shot] }]) : []),
|
|
193
|
+
...shotLines,
|
|
190
194
|
{ label: "production (voice and render)", unit: "second", credits: parts.productionCreditsPerSecond },
|
|
191
195
|
{ label: "live avatar on a call", unit: "still", credits: parts.liveAvatarStillCredits },
|
|
192
|
-
...
|
|
193
|
-
{ label: "music under the voice", unit: "track", credits: MUSIC_BED_CREDITS }],
|
|
196
|
+
...sceneLines, musicLine],
|
|
194
197
|
notes: "Short and long videos alike. Presenter seconds are the seconds a presenter take fills, covered by an insert, overlay, " +
|
|
195
198
|
"window or template or not, counted once over the video and rounded up; the engine that renders each take sets its rate " +
|
|
196
199
|
(engine === "heygen" ? "(today every take renders on HeyGen). " : "(no take renders on OmniHuman today). ") +
|
|
@@ -201,7 +204,9 @@ function buildPriceList(offer, diy) {
|
|
|
201
204
|
...(avatar6 ? [paid({ tool: "make_ugc", route: "POST /v1/skills/make_ugc/run", variant: "HeyGen Avatar 6 Turbo presenter",
|
|
202
205
|
quote_tool: "quote_ugc", minimum_credits: PARTS_DURATION_TARIFF.minimumCredits,
|
|
203
206
|
lines: [{ label: PRESENTER_ENGINE_LABELS.heygen_avatar6_turbo, unit: "face_second", credits: PRESENTER_CREDITS_PER_SECOND.heygen_avatar6_turbo },
|
|
204
|
-
|
|
207
|
+
...shotLines,
|
|
208
|
+
{ label: "production (voice and render)", unit: "second", credits: PARTS_DURATION_TARIFF.productionCreditsPerSecond },
|
|
209
|
+
...sceneLines, musicLine],
|
|
205
210
|
notes: "presenter_engine avatar6_turbo, the default of a 9:16 video, short or long, whose presenter picture is within 2% of 9:16, " +
|
|
206
211
|
"with no call, interview, presenter_gaze or talking shot and no presenter part longer than about 36 s; any other video renders " +
|
|
207
212
|
"on HeyGen Avatar IV. Presenter seconds are the seconds a presenter take fills, counted once over the video and rounded up; " +
|
|
@@ -315,6 +320,7 @@ const UNIT_TEXT = {
|
|
|
315
320
|
};
|
|
316
321
|
const LISTED_PRICES = 4;
|
|
317
322
|
const RANGE_BASIS = { create_actor: "by quality and image kind" };
|
|
323
|
+
const ENGINE_PRICED = new Set(["make_ugc"]);
|
|
318
324
|
export const priceText = (entry) => entry.lines.length === 0 ? entry.formula ?? "" :
|
|
319
325
|
entry.lines.map(lineText).join(" plus ") + (entry.minimum_credits === null ? "" : `, at least ${entry.minimum_credits}`);
|
|
320
326
|
const lineText = (line) => `${line.label === null ? "" : `${line.label} `}${line.credits} credits per ${UNIT_TEXT[line.unit]}`;
|
|
@@ -328,12 +334,20 @@ export function priceLine(tool, list) {
|
|
|
328
334
|
? [entry.lines[0].credits] : []));
|
|
329
335
|
const rest = (entry) => JSON.stringify([entry.lines.slice(1), entry.minimum_credits]);
|
|
330
336
|
const shared = entries.length > 1 && entries.every((entry) => entry.formula === null && entry.lines.length > 1 && rest(entry) === rest(first));
|
|
337
|
+
const production = (entry) => entry.lines.find((line) => line.unit === "second");
|
|
338
|
+
const base = (entry) => JSON.stringify([entry.lines[0]?.unit, production(entry), entry.minimum_credits]);
|
|
339
|
+
const engines = ENGINE_PRICED.has(tool) && entries.length > 1 &&
|
|
340
|
+
entries.every((entry) => entry.formula === null && production(entry) !== undefined && base(entry) === base(first));
|
|
331
341
|
const text = unit !== undefined && single.length === entries.length && single.length > LISTED_PRICES
|
|
332
342
|
? `${Math.min(...single)} to ${Math.max(...single)} credits per ${UNIT_TEXT[unit]}, ${RANGE_BASIS[tool] ?? "by model and size"}`
|
|
333
|
-
:
|
|
334
|
-
?
|
|
335
|
-
`${
|
|
336
|
-
|
|
343
|
+
: engines
|
|
344
|
+
? `starting at ${Math.min(...entries.map((entry) => entry.lines[0].credits))} credits per ${UNIT_TEXT[unit]}, by presenter engine, plus ` +
|
|
345
|
+
`${lineText(production(first))}${first.minimum_credits === null ? "" : `, at least ${first.minimum_credits}`}; ` +
|
|
346
|
+
"list_prices names each engine and add-on"
|
|
347
|
+
: shared
|
|
348
|
+
? `${entries.map((entry) => `${entry.variant === null ? "" : `${entry.variant}: `}${lineText(entry.lines[0])}`).join("; ")}; each plus ` +
|
|
349
|
+
`${first.lines.slice(1).map(lineText).join(" plus ")}${first.minimum_credits === null ? "" : `, at least ${first.minimum_credits}`}`
|
|
350
|
+
: entries.map((entry) => `${entry.variant === null ? "" : `${entry.variant}: `}${priceText(entry)}`).join("; ");
|
|
337
351
|
return `Price: ${text}. Quote first with ${first.quote_tool}.`;
|
|
338
352
|
}
|
|
339
353
|
export const withPriceLine = (tool, description, list) => {
|
|
@@ -12,6 +12,9 @@ export declare const REFERENCE_DATA_CREDITS = 10;
|
|
|
12
12
|
export declare const REFERENCE_ANALYSIS_MODES: readonly ["full", "data"];
|
|
13
13
|
export type ReferenceAnalysisMode = (typeof REFERENCE_ANALYSIS_MODES)[number];
|
|
14
14
|
export declare const REFERENCE_ANALYSIS_MODE_CREDITS: Readonly<Record<ReferenceAnalysisMode, number>>;
|
|
15
|
+
export declare const REFERENCE_ANALYSIS_MAX_SECONDS: Readonly<Record<ReferenceAnalysisMode, number>>;
|
|
16
|
+
export declare function referenceTooLongMessage(mode: ReferenceAnalysisMode, seconds: number, subject?: string): string | null;
|
|
17
|
+
export declare const isReferenceTooLongMessage: (line: string) => boolean;
|
|
15
18
|
export declare const REFERENCE_ANALYSIS_PER_HOUR = 10;
|
|
16
19
|
export declare const REFERENCE_DATA_PER_HOUR = 60;
|
|
17
20
|
export declare const REFERENCE_DATA_SHEET_COLUMNS = 3;
|
|
@@ -119,6 +122,7 @@ export declare const referenceSource: z.ZodObject<{
|
|
|
119
122
|
}, z.core.$strict>>;
|
|
120
123
|
}, z.core.$strict>;
|
|
121
124
|
export type ReferenceSource = z.infer<typeof referenceSource>;
|
|
125
|
+
export declare const MAX_REFERENCE_SCENES = 60;
|
|
122
126
|
export declare const referenceData: z.ZodObject<{
|
|
123
127
|
transcript: z.ZodArray<z.ZodObject<{
|
|
124
128
|
text: z.ZodString;
|
|
@@ -131,6 +135,8 @@ export declare const referenceData: z.ZodObject<{
|
|
|
131
135
|
text: z.ZodString;
|
|
132
136
|
end_s: z.ZodNumber;
|
|
133
137
|
caption: z.ZodOptional<z.ZodString>;
|
|
138
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
139
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
134
140
|
}, z.core.$strict>>;
|
|
135
141
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
142
|
start_s: z.ZodNumber;
|
|
@@ -156,6 +162,12 @@ export declare const referenceData: z.ZodObject<{
|
|
|
156
162
|
width: z.ZodNumber;
|
|
157
163
|
height: z.ZodNumber;
|
|
158
164
|
fps: z.ZodNumber;
|
|
165
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
166
|
+
start_s: z.ZodNumber;
|
|
167
|
+
end_s: z.ZodNumber;
|
|
168
|
+
key_frame_s: z.ZodNumber;
|
|
169
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
170
|
+
}, z.core.$strict>>>;
|
|
159
171
|
frame_sheet: z.ZodObject<{
|
|
160
172
|
columns: z.ZodNumber;
|
|
161
173
|
rows: z.ZodNumber;
|
|
@@ -182,6 +194,8 @@ export declare const referenceDataParts: {
|
|
|
182
194
|
text: z.ZodString;
|
|
183
195
|
end_s: z.ZodNumber;
|
|
184
196
|
caption: z.ZodOptional<z.ZodString>;
|
|
197
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
198
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
185
199
|
}, z.core.$strict>>;
|
|
186
200
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
187
201
|
start_s: z.ZodNumber;
|
|
@@ -210,6 +224,14 @@ export declare const referenceDataParts: {
|
|
|
210
224
|
height: z.ZodNumber;
|
|
211
225
|
fps: z.ZodNumber;
|
|
212
226
|
};
|
|
227
|
+
scenes: {
|
|
228
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
229
|
+
start_s: z.ZodNumber;
|
|
230
|
+
end_s: z.ZodNumber;
|
|
231
|
+
key_frame_s: z.ZodNumber;
|
|
232
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
233
|
+
}, z.core.$strict>>>;
|
|
234
|
+
};
|
|
213
235
|
};
|
|
214
236
|
export declare const REFERENCE_FRAMES_FPS = 1;
|
|
215
237
|
export declare const REFERENCE_FRAME_MAX_WIDTH = 540;
|
|
@@ -218,7 +240,6 @@ export declare const REFERENCE_SHEET_ROWS = 3;
|
|
|
218
240
|
export declare const REFERENCE_SHEET_WIDTH = 1080;
|
|
219
241
|
export declare const REFERENCE_FRAMES_PAGE_MAX = 60;
|
|
220
242
|
export declare const REFERENCE_FRAME_LINK_TTL_SECONDS = 86400;
|
|
221
|
-
export declare const MAX_REFERENCE_SCENES = 60;
|
|
222
243
|
export declare const REFERENCE_FRAMES_VERSION = "reference-frames-v1";
|
|
223
244
|
export declare const referenceFrameName: (t: number) => string;
|
|
224
245
|
export declare const referenceSheetName: (index: number) => string;
|
|
@@ -1216,6 +1237,8 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1216
1237
|
text: z.ZodString;
|
|
1217
1238
|
end_s: z.ZodNumber;
|
|
1218
1239
|
caption: z.ZodOptional<z.ZodString>;
|
|
1240
|
+
post_caption: z.ZodOptional<z.ZodString>;
|
|
1241
|
+
frame_s: z.ZodOptional<z.ZodNumber>;
|
|
1219
1242
|
}, z.core.$strict>>;
|
|
1220
1243
|
segments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1221
1244
|
start_s: z.ZodNumber;
|
|
@@ -1241,6 +1264,12 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1241
1264
|
width: z.ZodNumber;
|
|
1242
1265
|
height: z.ZodNumber;
|
|
1243
1266
|
fps: z.ZodNumber;
|
|
1267
|
+
scenes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1268
|
+
start_s: z.ZodNumber;
|
|
1269
|
+
end_s: z.ZodNumber;
|
|
1270
|
+
key_frame_s: z.ZodNumber;
|
|
1271
|
+
segments: z.ZodArray<z.ZodNumber>;
|
|
1272
|
+
}, z.core.$strict>>>;
|
|
1244
1273
|
frame_sheet: z.ZodObject<{
|
|
1245
1274
|
columns: z.ZodNumber;
|
|
1246
1275
|
rows: z.ZodNumber;
|
|
@@ -1377,6 +1406,7 @@ export declare const referenceAnalysis: z.ZodObject<{
|
|
|
1377
1406
|
untrusted_content: z.ZodObject<{
|
|
1378
1407
|
note: z.ZodLiteral<string>;
|
|
1379
1408
|
fields: z.ZodArray<z.ZodEnum<{
|
|
1409
|
+
"data.hook.post_caption": "data.hook.post_caption";
|
|
1380
1410
|
"data.hook.text": "data.hook.text";
|
|
1381
1411
|
"data.segments[].text": "data.segments[].text";
|
|
1382
1412
|
"data.transcript[].text": "data.transcript[].text";
|
|
@@ -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";
|
|
@@ -18,6 +18,20 @@ export const REFERENCE_ANALYSIS_MODES = ["full", "data"];
|
|
|
18
18
|
export const REFERENCE_ANALYSIS_MODE_CREDITS = {
|
|
19
19
|
full: REFERENCE_ANALYSIS_CREDITS, data: REFERENCE_DATA_CREDITS,
|
|
20
20
|
};
|
|
21
|
+
export const REFERENCE_ANALYSIS_MAX_SECONDS = {
|
|
22
|
+
full: ASSET_VIDEO_MAX_SECONDS, data: ANALYSIS_VIDEO_MAX_SECONDS,
|
|
23
|
+
};
|
|
24
|
+
const REFERENCE_TOO_LONG_LEAD = "the reel lasts ";
|
|
25
|
+
export function referenceTooLongMessage(mode, seconds, subject = "the reel") {
|
|
26
|
+
const most = REFERENCE_ANALYSIS_MAX_SECONDS[mode];
|
|
27
|
+
if (seconds <= most)
|
|
28
|
+
return null;
|
|
29
|
+
const lead = `${subject === "the reel" ? REFERENCE_TOO_LONG_LEAD : `${subject} lasts `}${seconds.toFixed(1)} s; a ${mode} analysis reads at most ${most} s`;
|
|
30
|
+
return mode === "full" && seconds <= REFERENCE_ANALYSIS_MAX_SECONDS.data
|
|
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`;
|
|
33
|
+
}
|
|
34
|
+
export const isReferenceTooLongMessage = (line) => line.startsWith(REFERENCE_TOO_LONG_LEAD) && / analysis reads at most \d+ s/.test(line);
|
|
21
35
|
export const REFERENCE_ANALYSIS_PER_HOUR = 10;
|
|
22
36
|
export const REFERENCE_DATA_PER_HOUR = 60;
|
|
23
37
|
export const REFERENCE_DATA_SHEET_COLUMNS = 3;
|
|
@@ -69,11 +83,13 @@ export function classifyReferenceUrl(raw) {
|
|
|
69
83
|
return { ok: false, message: `${host} ${url.pathname} is not a link we read; pass ${REFERENCE_URL_ACCEPTED}` };
|
|
70
84
|
}
|
|
71
85
|
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
|
|
86
|
+
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 in mode data`),
|
|
73
88
|
source_url: z.string().url().startsWith("https://").max(2048).optional()
|
|
74
89
|
.describe(`instead of asset_id: ${REFERENCE_URL_ACCEPTED}; YouTube is refused`),
|
|
75
|
-
mode: z.enum(REFERENCE_ANALYSIS_MODES).optional().describe(`full (default, ${REFERENCE_ANALYSIS_CREDITS} credits
|
|
76
|
-
|
|
90
|
+
mode: z.enum(REFERENCE_ANALYSIS_MODES).optional().describe(`full (default, ${REFERENCE_ANALYSIS_CREDITS} credits, reels up to ` +
|
|
91
|
+
`${ASSET_VIDEO_MAX_SECONDS} s): the reference_profile. data (${REFERENCE_DATA_CREDITS} credits, reels up to ${ANALYSIS_VIDEO_MAX_SECONDS} s): ` +
|
|
92
|
+
"duration, size, timed transcript, scenes between measured cuts, hook and a 3×3 frame sheet, without beats or graphics"),
|
|
77
93
|
max_credits: maxCreditsField,
|
|
78
94
|
}).refine((request) => (request.asset_id === undefined) !== (request.source_url === undefined), {
|
|
79
95
|
message: "pass exactly one of asset_id or source_url",
|
|
@@ -117,18 +133,30 @@ const frameSheet = z.strictObject({
|
|
|
117
133
|
rows: z.number().int().positive(),
|
|
118
134
|
times_s: z.array(z.number().nonnegative()).min(1),
|
|
119
135
|
});
|
|
136
|
+
const dataHook = referenceHook.extend({
|
|
137
|
+
post_caption: z.string().min(1).max(MAX_REFERENCE_LABEL_CHARS).optional()
|
|
138
|
+
.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."),
|
|
139
|
+
frame_s: z.number().int().nonnegative().optional()
|
|
140
|
+
.describe("The second of the hook's frame, where its first word starts: the frames.key_frames entry of kind hook."),
|
|
141
|
+
});
|
|
120
142
|
const dataWords = { transcript: z.array(referenceWord).max(MAX_REFERENCE_TRANSCRIPT_WORDS),
|
|
121
143
|
transcript_language: referenceLanguage.optional(),
|
|
122
|
-
hook:
|
|
144
|
+
hook: dataHook.nullable(),
|
|
123
145
|
segments: z.array(referenceSegment).max(MAX_REFERENCE_SEGMENTS).optional() };
|
|
124
146
|
const dataProbe = { duration_s: z.number().positive(), width: z.number().int().positive(), height: z.number().int().positive(),
|
|
125
147
|
fps: z.number().positive() };
|
|
148
|
+
export const MAX_REFERENCE_SCENES = 60;
|
|
149
|
+
const dataScenes = { scenes: z.array(z.strictObject({ start_s: z.number().nonnegative(), end_s: z.number().positive(),
|
|
150
|
+
key_frame_s: z.number().int().nonnegative().describe("The second whose frame shows the scene; frames.scenes signs it."),
|
|
151
|
+
segments: z.array(z.number().int().nonnegative()).describe("Indexes into segments of those that start in this scene.") }))
|
|
152
|
+
.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
153
|
export const referenceData = z.strictObject({
|
|
127
154
|
...dataProbe,
|
|
128
155
|
...dataWords,
|
|
156
|
+
...dataScenes,
|
|
129
157
|
frame_sheet: frameSheet.extend({ url: z.string().url().nullable() }),
|
|
130
158
|
});
|
|
131
|
-
export const referenceDataParts = { frameSheet, words: dataWords, probe: dataProbe };
|
|
159
|
+
export const referenceDataParts = { frameSheet, words: dataWords, probe: dataProbe, scenes: dataScenes };
|
|
132
160
|
export const REFERENCE_FRAMES_FPS = 1;
|
|
133
161
|
export const REFERENCE_FRAME_MAX_WIDTH = 540;
|
|
134
162
|
export const REFERENCE_SHEET_COLUMNS = 4;
|
|
@@ -136,9 +164,8 @@ export const REFERENCE_SHEET_ROWS = 3;
|
|
|
136
164
|
export const REFERENCE_SHEET_WIDTH = 1080;
|
|
137
165
|
export const REFERENCE_FRAMES_PAGE_MAX = 60;
|
|
138
166
|
export const REFERENCE_FRAME_LINK_TTL_SECONDS = 86_400;
|
|
139
|
-
export const MAX_REFERENCE_SCENES = 60;
|
|
140
167
|
export const REFERENCE_FRAMES_VERSION = "reference-frames-v1";
|
|
141
|
-
const maxFrames = Math.ceil(
|
|
168
|
+
const maxFrames = Math.ceil(ANALYSIS_VIDEO_MAX_SECONDS) + 1;
|
|
142
169
|
export const referenceFrameName = (t) => `f-${Number.isInteger(t) ? String(t).padStart(3, "0") : t.toFixed(1).padStart(5, "0")}.jpg`;
|
|
143
170
|
export const referenceSheetName = (index) => `sheet-${index}.jpg`;
|
|
144
171
|
const second = z.number().int().nonnegative();
|
|
@@ -262,13 +289,16 @@ export const ANALYZE_REFERENCE_DESCRIPTION = "Break down any reel or ad into a r
|
|
|
262
289
|
"graphic's label_hint. speakers names who talks, on or off screen, with their caption look; each beat names its speaker, gaze " +
|
|
263
290
|
"and gestures, each claim citing frames_s. " +
|
|
264
291
|
"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
|
|
292
|
+
`with kind: "video"), at most 100 MiB, or source_url: ${REFERENCE_URL_ACCEPTED}. Full reads reels up to ` +
|
|
293
|
+
`${REFERENCE_ANALYSIS_MAX_SECONDS.full} s, data up to ${REFERENCE_ANALYSIS_MAX_SECONDS.data} s (a link or an analysis_only asset); a longer reel ` +
|
|
294
|
+
"is refused at no charge, before its video is downloaded when the platform gives its length, and the error message names the limit. " +
|
|
266
295
|
"A link becomes an analysis-only asset (asset_id in the answer), and source carries the post's caption, author, engagement, " +
|
|
267
296
|
"the author's followers and median views with the ratio (x), the top 50 comments and their code words; a number, caption or " +
|
|
268
297
|
"author the platform did not give is null and named in warnings. A YouTube link is refused: upload its MP4 with create_asset. " +
|
|
269
298
|
"Once succeeded both modes answer frames and video, the reel as an MP4 (get_reference_analysis lists them). " +
|
|
270
299
|
`mode: "data" skips beats and graphics and answers data: duration, size and fps, the timed ` +
|
|
271
|
-
"transcript and segments,
|
|
300
|
+
"transcript and segments, scenes between measured cuts with their segments, the hook with the post's caption line and its frame, " +
|
|
301
|
+
"and a 3×3 frame sheet, plus source for a link; no speech gives an empty transcript and a " +
|
|
272
302
|
`warning. ${REFERENCE_ANALYSIS_CREDITS} credits for full, ${REFERENCE_DATA_CREDITS} for data, held at the start and charged once it ` +
|
|
273
303
|
"succeeds; a failed analysis costs nothing. " +
|
|
274
304
|
`${REFERENCE_ANALYSIS_PER_HOUR} new full and ${REFERENCE_DATA_PER_HOUR} new data analyses per hour per account. ` +
|
|
@@ -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.";
|