ugcinc 5.3.2 → 5.5.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.
Files changed (34) hide show
  1. package/README.md +70 -58
  2. package/dist/content-skills.js +4 -4
  3. package/dist/index.d.ts +1 -1
  4. package/dist/media-analysis.d.ts +460 -180
  5. package/dist/media-analysis.js +16 -9
  6. package/dist/render/components/TextElement.js +1 -1
  7. package/dist/render/compositions/IMessageDmComposition/convertPropsToElements.d.ts +27 -0
  8. package/dist/render/compositions/IMessageDmComposition/convertPropsToElements.js +629 -0
  9. package/dist/render/compositions/IMessageDmComposition/index.d.ts +21 -0
  10. package/dist/render/compositions/IMessageDmComposition/index.js +504 -0
  11. package/dist/render/compositions/IMessageDmComposition/types.d.ts +767 -0
  12. package/dist/render/compositions/IMessageDmComposition/types.js +228 -0
  13. package/dist/render/compositions/ImageEditorComposition.js +15 -2
  14. package/dist/render/compositions/VideoEditorComposition.js +7 -0
  15. package/dist/render/hooks/index.d.ts +10 -0
  16. package/dist/render/hooks/index.js +50 -0
  17. package/dist/render/types/base.d.ts +2 -0
  18. package/dist/render/types/element.d.ts +5 -0
  19. package/dist/render/types/native-text.d.ts +106 -1
  20. package/dist/render/types/native-text.js +17 -2
  21. package/dist/render/utils/fonts.d.ts +45 -3
  22. package/dist/render/utils/fonts.js +84 -3
  23. package/dist/render/utils/index.d.ts +1 -1
  24. package/dist/render/utils/index.js +9 -1
  25. package/dist/render/utils/positionResolver.js +2 -1
  26. package/dist/render.d.ts +1 -1
  27. package/dist/render.js +1 -1
  28. package/dist/skills.js +2 -2
  29. package/dist/stats.d.ts +24 -0
  30. package/dist/stats.js +11 -0
  31. package/package.json +1 -1
  32. package/skills/content-automation/SKILL.md +4 -2
  33. package/skills/media/SKILL.md +32 -11
  34. package/skills/media/references/tools.md +25 -20
@@ -3,8 +3,14 @@
3
3
  * Font utilities for the rendering system
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FONT_URLS = exports.FONT_FAMILIES = exports.APPLE_EMOJI_FONT = void 0;
6
+ exports.FONT_URLS = exports.FONT_LIBRARY_BASE_URL = exports.FONT_FAMILIES = exports.APPLE_EMOJI_FONT = void 0;
7
7
  exports.getFontFamily = getFontFamily;
8
+ exports.libraryFontFace = libraryFontFace;
9
+ exports.libraryFontSlug = libraryFontSlug;
10
+ exports.numericFontWeight = numericFontWeight;
11
+ exports.nearestLibraryWeight = nearestLibraryWeight;
12
+ exports.fetchFontLibraryCatalogue = fetchFontLibraryCatalogue;
13
+ exports.loadLibraryFonts = loadLibraryFonts;
8
14
  exports.buildFontString = buildFontString;
9
15
  exports.preloadFonts = preloadFonts;
10
16
  exports.areFontsLoaded = areFontsLoaded;
@@ -24,11 +30,86 @@ exports.FONT_FAMILIES = {
24
30
  arial: `Arial, ${exports.APPLE_EMOJI_FONT}, sans-serif`,
25
31
  };
26
32
  /**
27
- * Get the CSS font family string for a font type
33
+ * Get the CSS font family string for a font type, or for a font-library family
34
+ * when `fontFamily` is set (it takes precedence over `fontType`).
28
35
  */
29
- function getFontFamily(fontType) {
36
+ function getFontFamily(fontType, fontFamily) {
37
+ if (fontFamily) {
38
+ return `"${libraryFontFace(fontFamily)}", ${exports.APPLE_EMOJI_FONT}, sans-serif`;
39
+ }
30
40
  return exports.FONT_FAMILIES[fontType] ?? exports.FONT_FAMILIES.arial;
31
41
  }
42
+ /**
43
+ * Font library: the Google Fonts catalogue mirrored by UGC (open licences).
44
+ * `catalogue.json` lists every family with its available upright weights;
45
+ * files live at `<base>/files/<slug>/<weight>.ttf` (Latin subset).
46
+ */
47
+ exports.FONT_LIBRARY_BASE_URL = 'https://media.ugc.inc/owned-uploads/render/fonts/google';
48
+ /** CSS family name a library font is registered under (namespaced so it never collides with bundled fonts). */
49
+ function libraryFontFace(family) {
50
+ return `UGC Library ${family}`;
51
+ }
52
+ /** URL-safe family slug used in library file paths. */
53
+ function libraryFontSlug(family) {
54
+ return family.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
55
+ }
56
+ /** Numeric CSS weight for a FontWeight value. */
57
+ function numericFontWeight(weight) {
58
+ if (weight === undefined || weight === 'normal')
59
+ return 400;
60
+ if (weight === 'bold')
61
+ return 700;
62
+ return weight;
63
+ }
64
+ /** Nearest available weight (ties go to the heavier weight, as CSS matching does above 500). */
65
+ function nearestLibraryWeight(available, wanted) {
66
+ return available.reduce((best, w) => {
67
+ const d = Math.abs(w - wanted);
68
+ const bd = Math.abs(best - wanted);
69
+ return d < bd || (d === bd && w > best) ? w : best;
70
+ }, available[0] ?? wanted);
71
+ }
72
+ let cataloguePromise = null;
73
+ /** Fetch (once per page) the font library catalogue. Resolves null when unreachable. */
74
+ function fetchFontLibraryCatalogue() {
75
+ cataloguePromise ?? (cataloguePromise = fetch(`${exports.FONT_LIBRARY_BASE_URL}/catalogue.json`)
76
+ .then((r) => (r.ok ? r.json() : null))
77
+ .catch(() => null));
78
+ return cataloguePromise;
79
+ }
80
+ const loadedLibraryFaces = new Map();
81
+ /**
82
+ * Load library font faces for the given (family, weight) pairs into
83
+ * `document.fonts`. Each requested weight is snapped to the nearest weight the
84
+ * library has for that family and registered under the requested weight too,
85
+ * so CSS matching picks the same file in every renderer. Resolves to the list
86
+ * of pairs that failed to load (empty on success).
87
+ */
88
+ async function loadLibraryFonts(requests) {
89
+ if (typeof document === 'undefined' || !document.fonts || requests.length === 0)
90
+ return [];
91
+ const catalogue = await fetchFontLibraryCatalogue();
92
+ const failed = [];
93
+ await Promise.all(requests.map(async ({ family, weight }) => {
94
+ const wanted = numericFontWeight(weight);
95
+ const entry = catalogue?.families[family];
96
+ const fileWeight = entry ? nearestLibraryWeight(entry.weights, wanted) : wanted;
97
+ const slug = entry?.slug ?? libraryFontSlug(family);
98
+ const key = `${family}|${wanted}`;
99
+ let pending = loadedLibraryFaces.get(key);
100
+ if (!pending) {
101
+ const face = new FontFace(libraryFontFace(family), `url(${exports.FONT_LIBRARY_BASE_URL}/files/${slug}/${fileWeight}.ttf)`, { weight: String(wanted), style: 'normal' });
102
+ pending = face.load().then((loaded) => {
103
+ document.fonts.add(loaded);
104
+ return true;
105
+ }, () => false);
106
+ loadedLibraryFaces.set(key, pending);
107
+ }
108
+ if (!(await pending))
109
+ failed.push({ family, weight: wanted });
110
+ }));
111
+ return failed;
112
+ }
32
113
  /**
33
114
  * Build a CSS font string
34
115
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Utility exports for ugcinc-render
3
3
  */
4
- export { FONT_FAMILIES, APPLE_EMOJI_FONT, getFontFamily, buildFontString, FONT_URLS, preloadFonts, areFontsLoaded, debugFontStatus, } from './fonts';
4
+ export { FONT_FAMILIES, APPLE_EMOJI_FONT, getFontFamily, buildFontString, FONT_URLS, preloadFonts, areFontsLoaded, debugFontStatus, FONT_LIBRARY_BASE_URL, libraryFontFace, libraryFontSlug, numericFontWeight, nearestLibraryWeight, fetchFontLibraryCatalogue, loadLibraryFonts, type FontLibraryCatalogue, } from './fonts';
5
5
  export { calculateFitDimensions, type FitDimensions } from './fit';
6
6
  export { TEXT_DEFAULTS, IMAGE_DEFAULTS, VIDEO_DEFAULTS, VISUAL_DEFAULTS, applyTextDefaults, applyImageDefaults, applyVideoDefaults, } from './defaults';
7
7
  export { wrapText, calculateLineWidth, getBorderRadii, parseHexColor, hexToRgba, getSFProLetterSpacing, } from './text';
@@ -3,7 +3,8 @@
3
3
  * Utility exports for ugcinc-render
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateScreenshotAnimationDuration = exports.SCREENSHOT_ANIMATION_DEFAULTS = exports.colorNameToHex = exports.isValidCaptionPreset = exports.getCaptionPresetNames = exports.resolveCaptionStyle = exports.DEFAULT_CAPTION_STYLE = exports.CAPTION_PRESETS = exports.generateOverlayId = exports.generateSegmentId = exports.parseTime = exports.formatTime = exports.calculateTimelineContentEnd = exports.calculateEstimatedDuration = exports.isSegmentVisibleAtTime = exports.getSegmentTimelinePosition = exports.getOverlays = exports.getBaseSegments = exports.defaultOffset = exports.isDynamicCropEnabled = exports.calculateCropBounds = exports.getReferenceElementY = exports.getReferenceElementX = exports.getDependentElements = exports.canSetAsReference = exports.calculateAutoWidthDimensions = exports.resolveElementPositions = exports.getSFProLetterSpacing = exports.hexToRgba = exports.parseHexColor = exports.getBorderRadii = exports.calculateLineWidth = exports.wrapText = exports.applyVideoDefaults = exports.applyImageDefaults = exports.applyTextDefaults = exports.VISUAL_DEFAULTS = exports.VIDEO_DEFAULTS = exports.IMAGE_DEFAULTS = exports.TEXT_DEFAULTS = exports.calculateFitDimensions = exports.debugFontStatus = exports.areFontsLoaded = exports.preloadFonts = exports.FONT_URLS = exports.buildFontString = exports.getFontFamily = exports.APPLE_EMOJI_FONT = exports.FONT_FAMILIES = void 0;
6
+ exports.DEFAULT_CAPTION_STYLE = exports.CAPTION_PRESETS = exports.generateOverlayId = exports.generateSegmentId = exports.parseTime = exports.formatTime = exports.calculateTimelineContentEnd = exports.calculateEstimatedDuration = exports.isSegmentVisibleAtTime = exports.getSegmentTimelinePosition = exports.getOverlays = exports.getBaseSegments = exports.defaultOffset = exports.isDynamicCropEnabled = exports.calculateCropBounds = exports.getReferenceElementY = exports.getReferenceElementX = exports.getDependentElements = exports.canSetAsReference = exports.calculateAutoWidthDimensions = exports.resolveElementPositions = exports.getSFProLetterSpacing = exports.hexToRgba = exports.parseHexColor = exports.getBorderRadii = exports.calculateLineWidth = exports.wrapText = exports.applyVideoDefaults = exports.applyImageDefaults = exports.applyTextDefaults = exports.VISUAL_DEFAULTS = exports.VIDEO_DEFAULTS = exports.IMAGE_DEFAULTS = exports.TEXT_DEFAULTS = exports.calculateFitDimensions = exports.loadLibraryFonts = exports.fetchFontLibraryCatalogue = exports.nearestLibraryWeight = exports.numericFontWeight = exports.libraryFontSlug = exports.libraryFontFace = exports.FONT_LIBRARY_BASE_URL = exports.debugFontStatus = exports.areFontsLoaded = exports.preloadFonts = exports.FONT_URLS = exports.buildFontString = exports.getFontFamily = exports.APPLE_EMOJI_FONT = exports.FONT_FAMILIES = void 0;
7
+ exports.calculateScreenshotAnimationDuration = exports.SCREENSHOT_ANIMATION_DEFAULTS = exports.colorNameToHex = exports.isValidCaptionPreset = exports.getCaptionPresetNames = exports.resolveCaptionStyle = void 0;
7
8
  // Font utilities
8
9
  var fonts_1 = require("./fonts");
9
10
  Object.defineProperty(exports, "FONT_FAMILIES", { enumerable: true, get: function () { return fonts_1.FONT_FAMILIES; } });
@@ -14,6 +15,13 @@ Object.defineProperty(exports, "FONT_URLS", { enumerable: true, get: function ()
14
15
  Object.defineProperty(exports, "preloadFonts", { enumerable: true, get: function () { return fonts_1.preloadFonts; } });
15
16
  Object.defineProperty(exports, "areFontsLoaded", { enumerable: true, get: function () { return fonts_1.areFontsLoaded; } });
16
17
  Object.defineProperty(exports, "debugFontStatus", { enumerable: true, get: function () { return fonts_1.debugFontStatus; } });
18
+ Object.defineProperty(exports, "FONT_LIBRARY_BASE_URL", { enumerable: true, get: function () { return fonts_1.FONT_LIBRARY_BASE_URL; } });
19
+ Object.defineProperty(exports, "libraryFontFace", { enumerable: true, get: function () { return fonts_1.libraryFontFace; } });
20
+ Object.defineProperty(exports, "libraryFontSlug", { enumerable: true, get: function () { return fonts_1.libraryFontSlug; } });
21
+ Object.defineProperty(exports, "numericFontWeight", { enumerable: true, get: function () { return fonts_1.numericFontWeight; } });
22
+ Object.defineProperty(exports, "nearestLibraryWeight", { enumerable: true, get: function () { return fonts_1.nearestLibraryWeight; } });
23
+ Object.defineProperty(exports, "fetchFontLibraryCatalogue", { enumerable: true, get: function () { return fonts_1.fetchFontLibraryCatalogue; } });
24
+ Object.defineProperty(exports, "loadLibraryFonts", { enumerable: true, get: function () { return fonts_1.loadLibraryFonts; } });
17
25
  // Fit utilities
18
26
  var fit_1 = require("./fit");
19
27
  Object.defineProperty(exports, "calculateFitDimensions", { enumerable: true, get: function () { return fit_1.calculateFitDimensions; } });
@@ -13,6 +13,7 @@ exports.canSetAsReference = canSetAsReference;
13
13
  exports.getDependentElements = getDependentElements;
14
14
  exports.getReferenceElementX = getReferenceElementX;
15
15
  exports.getReferenceElementY = getReferenceElementY;
16
+ const fonts_1 = require("./fonts");
16
17
  // Font family mapping for text measurement
17
18
  const FONT_FAMILIES = {
18
19
  tiktok: '"TikTok Sans", sans-serif',
@@ -56,7 +57,7 @@ function calculateAutoWidthDimensions(elem, textContent, ctx) {
56
57
  const boxAlign = elem.boxAlign ?? 'left';
57
58
  const autoWidth = elem.autoWidth ?? false;
58
59
  // Set font for measurement
59
- const fontFamily = FONT_FAMILIES[fontType] ?? FONT_FAMILIES.tiktok;
60
+ const fontFamily = elem.fontFamily ? `"${(0, fonts_1.libraryFontFace)(elem.fontFamily)}", sans-serif` : (FONT_FAMILIES[fontType] ?? FONT_FAMILIES.tiktok);
60
61
  measureCtx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
61
62
  // Calculate available width for text wrapping
62
63
  const availableWidth = maxWidth - paddingLeft - paddingRight;
package/dist/render.d.ts CHANGED
@@ -15,7 +15,7 @@ import type { CreateDmMessage } from './automations/nodes/create-dm';
15
15
  import { type RemotionCompositionInput } from './render/types/remotion-composition';
16
16
  import { type NativeTextStickerInput } from './render/types/native-text';
17
17
  export { nativeTextStickerSchema, type NativeTextStickerInput } from './render/types/native-text';
18
- /** Render a native text/emoji sticker directly to a transparent PNG. */
18
+ /** Render a native text/emoji PNG; Snapchat includes its translucent bar by default. */
19
19
  export declare function submitNativeTextStickerRenderJob(params: NativeTextStickerInput): Promise<{
20
20
  ok: boolean;
21
21
  code: number;
package/dist/render.js CHANGED
@@ -33,7 +33,7 @@ function renderBaseUrl() {
33
33
  return url.replace(/\/+$/, '');
34
34
  }
35
35
  const MAX_RETRIES = 3;
36
- /** Render a native text/emoji sticker directly to a transparent PNG. */
36
+ /** Render a native text/emoji PNG; Snapchat includes its translucent bar by default. */
37
37
  async function submitNativeTextStickerRenderJob(params) {
38
38
  const parsed = native_text_1.nativeTextStickerSchema.safeParse(params);
39
39
  if (!parsed.success)
package/dist/skills.js CHANGED
@@ -260,13 +260,13 @@ For detailed port schemas, config options, and guides, use \`list_node_types\` a
260
260
 
261
261
  ### Node Discovery
262
262
  \`\`\`bash
263
- ${run} list_node_types # All nodes with ports, guides, defaults
263
+ ${run} list_node_types '{}' # All nodes with ports, guides, defaults
264
264
  ${run} get_node_type '{"nodeType":"llm"}' # Detailed info for one node
265
265
  \`\`\`
266
266
 
267
267
  ### Template Management
268
268
  \`\`\`bash
269
- ${run} list_automations # List all templates
269
+ ${run} list_automations '{}' # List all templates
270
270
  ${run} get_automation '{"templateId":"id"}' # Get template with full workflow
271
271
  ${run} create_automation '{"name":"My Automation","workflowDefinition":{...}}'
272
272
  ${run} update_automation '{"templateId":"id","name":"Updated","workflowDefinition":{...}}'
package/dist/stats.d.ts CHANGED
@@ -30,6 +30,24 @@ export interface RefreshStatsProgressResponse {
30
30
  totalPosts: number;
31
31
  completedPosts: number;
32
32
  }
33
+ /**
34
+ * How fresh an organization's post stats are. Accounts that posted in the
35
+ * last 7 days get a full stats refresh on every scheduled sync (every 12 hours).
36
+ */
37
+ export interface StatsSyncStatus {
38
+ /** Every active account has had a full stats refresh since this time. Null when one never has. */
39
+ lastSyncedAt: string | null;
40
+ /** The next scheduled sync. Null when it cannot be determined. */
41
+ nextSyncAt: string | null;
42
+ /** The last scheduled sync that ran successfully. */
43
+ lastSweepAt: string | null;
44
+ /** Accounts that posted in the last 7 days. */
45
+ activeAccounts: number;
46
+ /** Active accounts refreshed within the last 14 hours. */
47
+ currentAccounts: number;
48
+ /** Active accounts with no full refresh in the last 26 hours. */
49
+ staleAccounts: number;
50
+ }
33
51
  export interface DailyAggregatedStat {
34
52
  date: Date | string;
35
53
  followers: number;
@@ -386,6 +404,12 @@ export declare class StatsClient extends BaseClient {
386
404
  batchId: string;
387
405
  org_group?: string;
388
406
  }): Promise<ApiResponse<RefreshStatsProgressResponse>>;
407
+ /**
408
+ * Get how fresh the organization's post stats are and when the next scheduled sync runs.
409
+ */
410
+ getSyncStatus(params?: {
411
+ org_group?: string;
412
+ }): Promise<ApiResponse<StatsSyncStatus>>;
389
413
  /**
390
414
  * Refresh stats with NDJSON streaming progress.
391
415
  * Returns the raw Response so the caller can read the stream.
package/dist/stats.js CHANGED
@@ -222,6 +222,17 @@ class StatsClient extends base_1.BaseClient {
222
222
  }
223
223
  return this.get(`/stats/refresh/progress?${searchParams.toString()}`);
224
224
  }
225
+ /**
226
+ * Get how fresh the organization's post stats are and when the next scheduled sync runs.
227
+ */
228
+ async getSyncStatus(params) {
229
+ const searchParams = new URLSearchParams();
230
+ if (params?.org_group) {
231
+ searchParams.set('org_group', params.org_group);
232
+ }
233
+ const query = searchParams.toString();
234
+ return this.get(`/stats/sync-status${query ? `?${query}` : ''}`);
235
+ }
225
236
  /**
226
237
  * Refresh stats with NDJSON streaming progress.
227
238
  * Returns the raw Response so the caller can read the stream.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "5.3.2",
3
+ "version": "5.5.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,8 +57,10 @@ or enabling recurring runs unless the user authorized those actions.
57
57
  size, not only on a large canvas. Keep important text away from platform UI;
58
58
  inspect the relevant target presentation rather than assuming universal margins.
59
59
  - Use sampled reference colors and real render previews. Judge font, stroke,
60
- kerning, line height and emoji spacing together. Treat text-style fitting as a
61
- measured candidate, not proof of an exact font or pixel-perfect output.
60
+ kerning, line height and emoji spacing together. To reuse a reference
61
+ caption's font, take `match_text_style`'s identified library font
62
+ (`fontFamily` in Image Composer text); when it reports `approximate`, the
63
+ reference font is not in the library and the result is the closest match.
62
64
  - Match the reference post's actual audio excerpt, mix, start and duration when
63
65
  requested. Preserve attribution separately. Empty transcription can mean music
64
66
  or unrecognized speech, not silence. Keep visual reveals and audio timing coherent.
@@ -26,6 +26,23 @@ and limits. The CLI lists names/descriptions; the reference explains parameters.
26
26
 
27
27
  ## Choose the input and tools
28
28
 
29
+ Start from the analysis action; use the shipped tool before looking for local model packages.
30
+
31
+ | Need | Tool |
32
+ | --- | --- |
33
+ | Spoken words and approximate timing | `transcribe_audio` |
34
+ | Loudness, silence and volume over time | `measure_audio_levels` |
35
+ | On-screen text and when it appears | `read_video_text` |
36
+ | Scene boundaries | `detect_scenes` |
37
+ | Review frames/contact sheet | `extract_frames` |
38
+ | Text, colours or supplied boxes in a still | `read_image_text`, `sample_colors`, `measure_layout` |
39
+
40
+ For local media, use the existing owned-upload path described below, then pass its URL.
41
+ Normal file probes and quick local inspection remain useful. Missing local Whisper is
42
+ not a reason to abandon transcription or install another speech stack when UGC provides it.
43
+ If a supported service is unavailable, retain its error/job and use the workspace's operator
44
+ handoff; do not quietly replace it or guess the missing result.
45
+
29
46
  - A profile URL: `list_profile_posts` discovers a bounded page; follow its cursor
30
47
  only as needed. Listing does not download media or guarantee complete history.
31
48
  - A post URL: `download_social_post` ingests its ordered assets into owned media.
@@ -54,20 +71,24 @@ coverage. A zero process exit code alone does not establish API success.
54
71
  cannot inspect an arbitrarily long clip in one request.
55
72
  - Speech timestamps are estimates; speaker labels/forced alignment are absent.
56
73
  A transcript does not establish music, emotion, delivery or sound effects.
74
+ Matching waveform envelopes or correlation supports timing similarity, not identical
75
+ words or correct voice quality. Compare transcripts for wording, and distinguish measured
76
+ loudness from subjective listening. If you cannot listen, say so and leave that verdict open.
77
+ The first word timestamp is not proof of silence before that word; use audio levels to
78
+ establish silence. Model confidence scores are not a guarantee that wording is correct.
57
79
  - Color sampling measures decoded sRGB pixels, not guaranteed design hex values.
58
80
  Layout measurement does not detect objects or recover original layer files.
59
- - For text over photographic backgrounds, call `match_text_style` with
60
- `renderer: "auto"` or `"tiktok-native"` and exact text/line breaks when known.
61
- Native results include Unicode/emoji and a clean transparent sticker using
62
- the supported native TikTok profile. Omitted renderer keeps the older
63
- ASCII/plain-background image-editor path. Inspect `surface`/version and use
64
- `nativeResult` or generic `candidates` accordingly.
81
+ - To copy a caption's font, call `match_text_style` with exact text and line
82
+ breaks (default renderer). It identifies the font from the UGC font library
83
+ (Google Fonts catalogue, refreshed daily) for outlined captions on photos and
84
+ plain text on uniform backgrounds, and returns an Image Composer element with
85
+ `fontFamily` and fitted styling. `fontIdentification.status: approximate`
86
+ means the original font is not in the library; the closest one is returned.
87
+ Use `renderer: "tiktok-native"` for emoji captions.
65
88
  - A completed matching job can return inner `status: "unavailable"`. Check
66
- `reasonCode`, `fitAttempted`, `renders` and `nextActions`. Zero renders means
67
- no font fit was attempted: do not spend repeated calls on similar rejected
68
- crops or download replacement fonts. Font identity stays unverified; compare
69
- text/outline residuals and the preview before calling any result accurate.
70
- Equal line widths or matching positions alone do not prove identical text.
89
+ `reasonCode`, `fitAttempted`, `renders` and `nextActions`; do not spend
90
+ repeated calls on similar rejected crops. Compare `maskIoU` and the preview
91
+ before calling a result exact.
71
92
  - SAM/object segmentation, automatic overlay detection, element/mask tracking,
72
93
  motion measurement, extraction, media comparison/alignment and semantic search
73
94
  are not available through this tool set. Do not invent those calls or install
@@ -45,7 +45,7 @@ These return `{ok, data:{jobId,status,operation,result?,error?}}`. Use the compl
45
45
  | `measure_audio_levels` / `media.measureAudioLevels` | `{url,range?:{startMs,endMs},windowMs?:100,silenceThresholdDbfs?:-50}` | Native-channel RMS/sample peaks, loudness timeline/LUFS, silence, possible clipping, `previewUrl`. Windows20–5000ms, threshold−100to−10dBFS, range at most120seconds. |
46
46
  | `sample_colors` / `media.sampleColors` | `{url,maxColors?:8,point?:{x,y},box?:{x,y,width,height},mask?}`; choose at most one selection | Observed RGBA point or palette/proportions, omitted mass, declared color policy, `previewUrl`. Palette1–32colors. |
47
47
  | `measure_layout` / `media.measureLayout` | `{url,elements:[{id,box:{x,y,width,height}}]}`; each element may instead have `mask` | Margins, centers, spacing/alignment deltas, intersections/IoU and `previewUrl`.1–32unique IDs. Boxes are supplied, not automatically detected. |
48
- | `match_text_style` / `media.matchTextStyle` | `{url,box:{x,y,width,height},text?,renderer?}`; integer crop 16–1536 wide, 16–512 high. `renderer: auto` allows native fallback; `tiktok-native` requests the native profile. Omitted renderer keeps legacy image-editor behavior. Supply exact text and line breaks when available. | `status`, `reasonCode`, `fitAttempted`, `nextActions`, comparison and warnings. Generic v1 returns `candidates` with image-editor `element`/`previewConfig`. Native v2 returns `nativeResult` with actual native `settings`, clean transparent `stickerUrl`, source-pixel `composition`, masked residuals and diagnostics; `candidates` is empty. Native/auto accept Unicode/emoji, up to 160 UTF-16 code units/four lines; generic remains ASCII/plain-background only. Original font identity is unverified. |
48
+ | `match_text_style` / `media.matchTextStyle` | `{url,box:{x,y,width,height},text?,renderer?}`; integer crop 16–1536 wide, 16–512 high. Omitted renderer (`image-editor`) identifies the font from the UGC font library and fits an Image Composer text element; `auto` adds the native TikTok sticker as fallback (and uses it for emoji text); `tiktok-native` requests only the native profile. Supply exact text and line breaks. | `status`, `reasonCode`, `fitAttempted`, `nextActions`, comparison and warnings. Image-editor v3 returns `fontIdentification` (`family`, `weight`, `score`, `margin`, `status: identified|approximate`, ranked `topCandidates`) and up to 3 `candidates` whose `element` uses `fontFamily` (a library family) with fitted size, weight, spacing, line height, outline and colours. Native v2 returns `nativeResult` with native `settings`, a transparent `stickerUrl`, source-pixel `composition` and diagnostics; `candidates` is empty. Image-editor text is printable ASCII; native/auto accept Unicode/emoji, up to 160 UTF-16 code units/four lines. |
49
49
  | `get_media_analysis` / `media.getMediaAnalysis` | `{jobId}` | Current status/result in the current organization; use when automatic waiting returned pending/processing. |
50
50
 
51
51
  Boxes are half-open source-pixel rectangles. For masks used by colors/layout:
@@ -55,28 +55,33 @@ convention. Supply only masks you actually have; automatic segmentation is off.
55
55
 
56
56
  ## Text matching decisions
57
57
 
58
- For photographed TikTok captions, use `renderer: "auto"` or `"tiktok-native"`
59
- and supply the exact caption, including emoji and intended line breaks. The
60
- native candidate uses the supported `tiktok-classic-ios-47` profile: white text,
61
- dark outline, original native shaping and emoji. This does not imply every
62
- TikTok caption uses that profile. Unsupported styles remain unavailable or
63
- explicit approximations; no new font download or hosted model is required.
58
+ To copy a caption's font, call `match_text_style` with the default renderer
59
+ and the exact text with its line breaks. The tool compares the caption's letter
60
+ shapes with every font in the UGC font library (the Google Fonts catalogue,
61
+ about 1,800 families; refreshed daily, so new families become available without
62
+ a release). It works for an outlined caption (light or coloured fill, dark
63
+ outline) on any background and for plain text on a uniform background.
64
+
65
+ Read `fontIdentification`: `status: identified` names the library family and
66
+ weight; `approximate` means the caption's font is probably not in any free
67
+ library (for example a paid font), so the closest library font is returned.
68
+ `topCandidates` ranks the next best families; `equivalentFamilies` lists
69
+ families whose Latin letters are identical. Use `candidates[0].element`
70
+ directly in an Image Composer: it carries `fontFamily`, `fontWeight`, size,
71
+ letter spacing, line height, outline width and colours fitted with the real
72
+ renderer. Check `maskIoU` and the preview before calling a fit exact.
73
+
74
+ For emoji captions use `renderer: "tiktok-native"` (native TikTok sticker).
64
75
 
65
76
  Check all three levels: outer response `ok`, analysis job `status`, and inner
66
77
  matching `result.status`. A completed analysis can legitimately return
67
- `unavailable`. If `fitAttempted` is false or `renders` is zero, no font candidate
68
- was tested. Read `reasonCode` and `nextActions`; do not keep resubmitting nearly
69
- the same crop after a background/segmentation rejection. Keep the source frame
70
- and failure for a tool repair rather than claiming a missing font.
71
-
72
- Use `surface` and result version to choose the output. Generic image-editor
73
- results retain `candidates[].element` and `previewConfig`. Native results use
74
- `nativeResult.settings` with the native sticker renderer, or directly reuse
75
- `nativeResult.stickerUrl`. Its `composition` positions the clean PNG in source
76
- pixels; native settings themselves use points and produce 3× pixels. Do not
77
- paste extracted source-caption pixels onto a changed background. Compare the
78
- returned fit/difference preview and residuals; matching a line width or locating
79
- its top-left corner does not establish correct glyphs, spacing or emoji.
78
+ `unavailable`. If `fitAttempted` is false or `renders` is zero, no fit was
79
+ rendered. Read `reasonCode` and `nextActions` (for example
80
+ `TEXT_EVIDENCE_CLIPPED`: include the whole caption with a margin;
81
+ `AMBIGUOUS_TEXT_EVIDENCE`: supply the exact line breaks); do not keep
82
+ resubmitting nearly the same crop.
83
+
84
+ Do not paste extracted source-caption pixels onto a changed background.
80
85
 
81
86
  ## Existing media library
82
87