@mevdragon/vidfarm-devcli 0.12.0 → 0.14.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.
@@ -13,7 +13,7 @@ import ffprobeStatic from "ffprobe-static";
13
13
  import { parseHTML } from "linkedom";
14
14
  import { config } from "../config.js";
15
15
  import { devErrorFields, devLog } from "../lib/dev-log.js";
16
- import { CAPTION_ANIM_CSS, CAPTION_STYLE_MARKER, KEN_BURNS_CSS, KEN_BURNS_STYLE_MARKER, TRANSITION_ADJACENCY_EPSILON, TRANSITION_CSS, TRANSITION_PRESETS, TRANSITION_STYLE_MARKER, buildHyperframeCompositionHtml, clampTransitionDuration } from "../hyperframes/composition.js";
16
+ import { CAPTION_ANIM_CSS, CAPTION_STYLE_MARKER, KEN_BURNS_CSS, KEN_BURNS_STYLE_MARKER, LEGACY_TRANSITION_CSS_V1, TRANSITION_ADJACENCY_EPSILON, TRANSITION_CSS, TRANSITION_OUT_PRESETS, TRANSITION_PRESETS, TRANSITION_STYLE_MARKER, buildHyperframeCompositionHtml, clampTransitionDuration, transitionOutDelaySeconds } from "../hyperframes/composition.js";
17
17
  import { applyMarkupUsd } from "./billing-pricing.js";
18
18
  // The scene-annotation pass reuses the clip library's controlled vocabulary and
19
19
  // embedding-text recipe verbatim so a source scene's clip-match query is
@@ -2309,6 +2309,18 @@ function compositionHasCoverageGap(intervals, total, minGap = 0.2) {
2309
2309
  // neighbor back). Stored drafts stay butt-cut; only publish/render output
2310
2310
  // carries the overlap. The preview runtime applies the same window live.
2311
2311
  function materializeTransitionOverlaps(document) {
2312
+ const upsertStyleVar = (el, name, value) => {
2313
+ const styleValue = el.getAttribute("style") || "";
2314
+ const decl = `${name}:${value}`;
2315
+ const pattern = new RegExp(`(^|;)\\s*${name.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")}\\s*:[^;]*`, "i");
2316
+ const nextStyle = pattern.test(styleValue)
2317
+ ? styleValue.replace(pattern, (_match, lead) => `${lead}${decl}`)
2318
+ : styleValue.length === 0 || styleValue.endsWith(";")
2319
+ ? `${styleValue}${decl}`
2320
+ : `${styleValue};${decl}`;
2321
+ if (nextStyle !== styleValue)
2322
+ el.setAttribute("style", nextStyle);
2323
+ };
2312
2324
  const clips = [];
2313
2325
  for (const el of Array.from(document.querySelectorAll("[data-start]"))) {
2314
2326
  if (el.hasAttribute("data-composition-id"))
@@ -2331,6 +2343,23 @@ function materializeTransitionOverlaps(document) {
2331
2343
  return;
2332
2344
  for (const clip of clips) {
2333
2345
  const transitionEl = clip.el;
2346
+ const tagName = transitionEl.tagName?.toLowerCase?.() ?? "";
2347
+ // Exit transitions: validate/clamp here; the tail-positioning delay var is
2348
+ // re-derived in the final loop below once holds are known (the animation
2349
+ // must end at the clip's rendered end, nominal + hold).
2350
+ const outPreset = transitionEl.getAttribute("data-transition-out");
2351
+ if (outPreset) {
2352
+ if (!TRANSITION_OUT_PRESETS.includes(outPreset) || tagName === "audio") {
2353
+ transitionEl.removeAttribute("data-transition-out");
2354
+ transitionEl.removeAttribute("data-transition-out-duration");
2355
+ }
2356
+ else {
2357
+ const outDuration = Math.min(clampTransitionDuration(transitionEl.getAttribute("data-transition-out-duration")), clip.nominal);
2358
+ const outDurationValue = Number(outDuration.toFixed(3));
2359
+ transitionEl.setAttribute("data-transition-out-duration", String(outDurationValue));
2360
+ upsertStyleVar(transitionEl, "--vf-tr-out-dur", `${outDurationValue}s`);
2361
+ }
2362
+ }
2334
2363
  const preset = transitionEl.getAttribute("data-transition");
2335
2364
  if (!preset)
2336
2365
  continue;
@@ -2341,7 +2370,6 @@ function materializeTransitionOverlaps(document) {
2341
2370
  transitionEl.removeAttribute("data-transition-duration");
2342
2371
  continue;
2343
2372
  }
2344
- const tagName = transitionEl.tagName?.toLowerCase?.() ?? "";
2345
2373
  if (tagName === "audio") {
2346
2374
  transitionEl.removeAttribute("data-transition");
2347
2375
  transitionEl.removeAttribute("data-transition-duration");
@@ -2353,15 +2381,7 @@ function materializeTransitionOverlaps(document) {
2353
2381
  transitionEl.setAttribute("data-transition-duration", String(durationValue));
2354
2382
  // Keep the inline var (which drives animation-duration) in lockstep, same
2355
2383
  // as the --vf-kb-dur re-derivation above.
2356
- const styleValue = transitionEl.getAttribute("style") || "";
2357
- const durDecl = `--vf-tr-dur:${durationValue}s`;
2358
- const nextStyle = /(^|;)\s*--vf-tr-dur\s*:[^;]*/i.test(styleValue)
2359
- ? styleValue.replace(/(^|;)\s*--vf-tr-dur\s*:[^;]*/i, (_match, lead) => `${lead}${durDecl}`)
2360
- : styleValue.length === 0 || styleValue.endsWith(";")
2361
- ? `${styleValue}${durDecl}`
2362
- : `${styleValue};${durDecl}`;
2363
- if (nextStyle !== styleValue)
2364
- transitionEl.setAttribute("style", nextStyle);
2384
+ upsertStyleVar(transitionEl, "--vf-tr-dur", `${durationValue}s`);
2365
2385
  // Grant the hold to the clip this one cuts away from: same track, nominal
2366
2386
  // end at (within epsilon of) this clip's start.
2367
2387
  for (const candidate of clips) {
@@ -2390,6 +2410,13 @@ function materializeTransitionOverlaps(document) {
2390
2410
  else {
2391
2411
  clip.el.removeAttribute("data-transition-hold");
2392
2412
  }
2413
+ // Position the exit animation at the clip's rendered tail. Timeline edits
2414
+ // touch data-duration only, so this re-derivation (like --vf-kb-dur) is
2415
+ // what keeps stored delays honest after retimes.
2416
+ if (clip.el.getAttribute("data-transition-out")) {
2417
+ const outDuration = clampTransitionDuration(clip.el.getAttribute("data-transition-out-duration"));
2418
+ upsertStyleVar(clip.el, "--vf-tr-out-delay", `${transitionOutDelaySeconds(nextDuration, outDuration)}s`);
2419
+ }
2393
2420
  }
2394
2421
  }
2395
2422
  export function normalizePublishHtml(html) {
@@ -2519,10 +2546,28 @@ export function normalizePublishHtml(html) {
2519
2546
  (document.head ?? document.documentElement)?.appendChild(styleEl);
2520
2547
  }
2521
2548
  materializeTransitionOverlaps(document);
2522
- if (document.querySelector("[data-transition]") && !html.includes(TRANSITION_STYLE_MARKER)) {
2523
- const styleEl = document.createElement("style");
2524
- styleEl.textContent = TRANSITION_CSS;
2525
- (document.head ?? document.documentElement)?.appendChild(styleEl);
2549
+ if (document.querySelector("[data-transition], [data-transition-out]") && !html.includes(TRANSITION_STYLE_MARKER)) {
2550
+ // Compositions stored before V2 carry the V1 block inline: upgrade it in
2551
+ // place (exact string swap) instead of stacking a second stylesheet. If the
2552
+ // legacy block drifted, append after it — later source order wins the
2553
+ // equal-specificity animation-name battle, so V2 still takes effect.
2554
+ let upgradedLegacy = false;
2555
+ if (html.includes("__VF_TRANSITIONS_V1__")) {
2556
+ for (const styleEl of Array.from(document.querySelectorAll("style"))) {
2557
+ const text = styleEl.textContent || "";
2558
+ if (!text.includes("__VF_TRANSITIONS_V1__"))
2559
+ continue;
2560
+ styleEl.textContent = text.includes(LEGACY_TRANSITION_CSS_V1)
2561
+ ? text.split(LEGACY_TRANSITION_CSS_V1).join(TRANSITION_CSS)
2562
+ : `${text}\n${TRANSITION_CSS}`;
2563
+ upgradedLegacy = true;
2564
+ }
2565
+ }
2566
+ if (!upgradedLegacy) {
2567
+ const styleEl = document.createElement("style");
2568
+ styleEl.textContent = TRANSITION_CSS;
2569
+ (document.head ?? document.documentElement)?.appendChild(styleEl);
2570
+ }
2526
2571
  }
2527
2572
  // Editor sessions occasionally leave inline style attributes with double
2528
2573
  // quotes inside CSS values (font-family: "TikTok Sans"). When serialized into
@@ -1555,6 +1555,7 @@ export class ProviderService {
1555
1555
  prompt: input.prompt,
1556
1556
  language: input.language,
1557
1557
  diarize: input.diarize,
1558
+ wordTimestamps: input.wordTimestamps,
1558
1559
  apiKey: lease.secret
1559
1560
  })));
1560
1561
  await this.serverlessProviderKeys.recordProviderKeyUsage({
@@ -44,6 +44,7 @@ const METHOD_COLLECTIONS = {
44
44
  createTemplateRelease: "template_release",
45
45
  createTemplateSource: "template_source",
46
46
  createUserAttachment: "user_attachment",
47
+ updateUserAttachmentNotes: "user_attachment",
47
48
  createUserFileFolder: "user_file_folder",
48
49
  createUserTemporaryFile: "user_temporary_file",
49
50
  deleteEmailChannel: "email_channel",
@@ -151,6 +152,14 @@ class ServerlessRecordsServiceImpl {
151
152
  });
152
153
  }
153
154
  async getLatestApiKeyForCustomer(customerId) {
155
+ const keys = await this.listActiveApiKeysForCustomer(customerId, 1);
156
+ return keys[0] ?? null;
157
+ }
158
+ // Newest-first active API key records. Callers that hand a key to a client
159
+ // (boot configs, Settings) should pick one the CURRENT server can validate —
160
+ // after an API_KEY_SALT rotation the shared table holds keys hashed under
161
+ // different salts (deployed stage vs local dev boxes).
162
+ async listActiveApiKeysForCustomer(customerId, limit = 25) {
154
163
  const response = await dynamodb.send(new QueryCommand({
155
164
  TableName: requireMainTableName(),
156
165
  IndexName: "gsi1",
@@ -164,9 +173,9 @@ class ServerlessRecordsServiceImpl {
164
173
  ":status": "active"
165
174
  },
166
175
  ScanIndexForward: false,
167
- Limit: 1
176
+ Limit: limit
168
177
  }));
169
- return response.Items?.[0] ?? null;
178
+ return response.Items ?? [];
170
179
  }
171
180
  async hasCustomerCreditGrant(customerId, grantType) {
172
181
  return Boolean(await this.getById("credit_grant", `${customerId}:${grantType}`));
@@ -390,6 +399,7 @@ class ServerlessRecordsServiceImpl {
390
399
  templateId: null,
391
400
  trendTagline: input.trendTagline ?? null,
392
401
  visibility: input.visibility ?? "public",
402
+ origin: input.origin ?? "inspiration",
393
403
  notes: input.notes ?? null,
394
404
  errorMessage: null,
395
405
  createdAt: timestamp,
@@ -446,6 +456,7 @@ class ServerlessRecordsServiceImpl {
446
456
  viralDna: input.viralDna ?? null,
447
457
  defaultForkId: input.defaultForkId ?? null,
448
458
  visibility: input.visibility ?? "public",
459
+ origin: input.origin ?? "inspiration",
449
460
  notes: input.notes ?? null,
450
461
  createdAt: timestamp,
451
462
  updatedAt: timestamp
@@ -787,9 +798,15 @@ class ServerlessRecordsServiceImpl {
787
798
  storageKey: input.storageKey,
788
799
  folderPath: normalizeFolder(input.folderPath),
789
800
  publicUrl: input.publicUrl ?? null,
801
+ notes: input.notes ?? null,
802
+ notesEmbedding: input.notesEmbedding ?? null,
803
+ notesEmbeddingModel: input.notesEmbeddingModel ?? null,
790
804
  createdAt: input.createdAt ?? timestamp
791
805
  });
792
806
  }
807
+ async updateUserAttachmentNotes(customerId, attachmentId, patch) {
808
+ return this.mergeByIdForCustomer("user_attachment", customerId, attachmentId, patch);
809
+ }
793
810
  async listUserAttachments(customerId) {
794
811
  return this.listByCustomer("user_attachment", customerId);
795
812
  }
@@ -162,6 +162,18 @@ export class StorageService {
162
162
  async getReadUrl(key) {
163
163
  return this.createReadUrl(key);
164
164
  }
165
+ // Absolute on-disk path for a key — local driver only (null on S3), for
166
+ // callers that hand the file to a local process (ffmpeg) without copying.
167
+ getLocalPath(key) {
168
+ if (this.s3 && config.AWS_S3_BUCKET)
169
+ return null;
170
+ try {
171
+ return this.resolveLocalPath(key);
172
+ }
173
+ catch {
174
+ return null;
175
+ }
176
+ }
165
177
  async createWriteUrl(key, input) {
166
178
  if (!this.s3 || !config.AWS_S3_BUCKET) {
167
179
  throw new Error("Presigned uploads require S3 storage.");
@@ -307,6 +307,7 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
307
307
 
308
308
  .vf-editor-chat-mobile-fab,
309
309
  .vf-editor-chat-minimize,
310
+ .vf-editor-chat-expand,
310
311
  .vf-editor-chat-back-button--header {
311
312
  display: none;
312
313
  }
@@ -2634,18 +2635,25 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2634
2635
  pointer-events: none;
2635
2636
  }
2636
2637
 
2638
+ /* Chat opens as a floating popup card anchored above the FAB; the expand
2639
+ toggle promotes it to a full-screen sheet (data-mobile-expanded). */
2637
2640
  .vf-editor-chat-thread {
2638
2641
  position: fixed;
2639
- inset: 0;
2642
+ top: auto;
2643
+ left: auto;
2644
+ right: 12px;
2645
+ bottom: calc(12px + env(safe-area-inset-bottom));
2640
2646
  z-index: 1;
2641
2647
  display: none;
2642
- width: 100%;
2643
- height: 100svh;
2644
- border-radius: 0;
2648
+ width: min(430px, calc(100vw - 24px));
2649
+ height: min(72svh, 640px);
2650
+ border: 1px solid rgba(219, 193, 122, 0.46);
2651
+ border-radius: 24px;
2652
+ overflow: hidden;
2645
2653
  background:
2646
2654
  radial-gradient(circle at top right, rgba(219, 193, 122, 0.12), transparent 30%),
2647
2655
  linear-gradient(180deg, rgba(255, 252, 247, 0.99), rgba(252, 247, 238, 0.98));
2648
- box-shadow: none;
2656
+ box-shadow: 0 30px 72px rgba(37, 45, 61, 0.34);
2649
2657
  pointer-events: auto;
2650
2658
  }
2651
2659
 
@@ -2653,6 +2661,22 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2653
2661
  display: flex;
2654
2662
  }
2655
2663
 
2664
+ /* Outranks the desktop brainstorm thread rule (display:grid), which has
2665
+ higher specificity than the plain .vf-editor-chat-thread hide above. */
2666
+ .vf-editor-chat-shell:not([data-mobile-open="true"]) .vf-editor-chat-thread {
2667
+ display: none;
2668
+ }
2669
+
2670
+ .vf-editor-chat-shell[data-mobile-expanded="true"] .vf-editor-chat-thread {
2671
+ inset: 0;
2672
+ width: 100%;
2673
+ height: 100svh;
2674
+ border: 0;
2675
+ border-radius: 0;
2676
+ box-shadow: none;
2677
+ }
2678
+
2679
+ .vf-editor-chat-expand,
2656
2680
  .vf-editor-chat-minimize {
2657
2681
  all: unset;
2658
2682
  display: inline-flex;
@@ -2681,10 +2705,21 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2681
2705
  }
2682
2706
 
2683
2707
  .vf-editor-chat-new-thread,
2708
+ .vf-editor-chat-expand,
2684
2709
  .vf-editor-chat-minimize {
2685
2710
  flex: 0 0 auto;
2686
2711
  }
2687
2712
 
2713
+ .vf-editor-chat-expand svg {
2714
+ width: 16px;
2715
+ height: 16px;
2716
+ fill: none;
2717
+ stroke: currentColor;
2718
+ stroke-width: 1.9;
2719
+ stroke-linecap: round;
2720
+ stroke-linejoin: round;
2721
+ }
2722
+
2688
2723
  .vf-editor-chat-header,
2689
2724
  .vf-editor-chat-tracer-bar,
2690
2725
  .vf-editor-chat-footer {
@@ -2701,31 +2736,59 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2701
2736
  max-width: 72vw;
2702
2737
  }
2703
2738
 
2739
+ /* iOS auto-zooms the viewport when focusing sub-16px inputs; the chat
2740
+ composer is the page's primary interaction on phones. */
2741
+ .vf-editor-chat-input,
2742
+ .vf-editor-upload-folder-dialog input {
2743
+ font-size: 16px;
2744
+ }
2745
+
2746
+ .vf-editor-chat-shell[data-layout="brainstorm"] .editor-chat-panel,
2704
2747
  .vf-editor-chat-shell[data-layout="brainstorm"] {
2705
- pointer-events: auto;
2748
+ background: transparent;
2706
2749
  }
2707
2750
 
2708
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-mobile-fab {
2709
- display: none;
2751
+ .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-brainstorm-layout {
2752
+ grid-template-columns: minmax(0, 1fr);
2710
2753
  }
2711
2754
 
2712
- /* Minimize makes no sense when the chat IS the page (/chat); Discover
2713
- re-enables it (with the FAB dock pattern) via its own scoped styles. */
2714
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-minimize {
2755
+ /* On narrow screens the persistent history sidebar collapses; the
2756
+ overlay history toggle in the header takes over instead. */
2757
+ .vf-editor-chat-brainstorm-layout.has-sidebar > .vf-editor-chat-history-pane {
2715
2758
  display: none;
2716
2759
  }
2717
2760
 
2718
- /* iOS auto-zooms the viewport when focusing sub-16px inputs; the chat
2719
- composer is the page's primary interaction on phones. */
2720
- .vf-editor-chat-input,
2721
- .vf-editor-upload-folder-dialog input {
2722
- font-size: 16px;
2761
+ /* Brainstorm surfaces (Discover/Library/Clips) use the same FAB + popup
2762
+ dock as everything else; the thread just lays out as a grid. */
2763
+ .vf-editor-chat-shell[data-layout="brainstorm"][data-mobile-open="true"] .vf-editor-chat-thread {
2764
+ display: grid;
2765
+ grid-template-rows: auto minmax(0, 1fr) auto;
2723
2766
  }
2724
2767
 
2725
- /* On phones the /chat page has no topbar and the sidebar (with its
2726
- Discover link) is collapsed — surface the header back button there.
2727
- Discover hides it again via its own scoped styles. */
2728
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-back-button--header {
2768
+ .vf-editor-chat-history-close,
2769
+ .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-history-toggle {
2770
+ display: inline-flex;
2771
+ }
2772
+
2773
+ .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-viewport {
2774
+ padding-left: 12px;
2775
+ padding-right: 12px;
2776
+ }
2777
+
2778
+ /* /chat is the one surface where the chat IS the page: no FAB, no
2779
+ minimize/expand, thread pinned full-screen, with a back-to-Discover
2780
+ escape hatch in the header (the page has no topbar on phones). */
2781
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] {
2782
+ pointer-events: auto;
2783
+ }
2784
+
2785
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-mobile-fab,
2786
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-minimize,
2787
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-expand {
2788
+ display: none;
2789
+ }
2790
+
2791
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-back-button--header {
2729
2792
  display: inline-flex;
2730
2793
  align-items: center;
2731
2794
  justify-content: center;
@@ -2739,27 +2802,12 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2739
2802
  color: #617087;
2740
2803
  }
2741
2804
 
2742
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-back-button--header svg {
2805
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-back-button--header svg {
2743
2806
  width: 18px;
2744
2807
  height: 18px;
2745
2808
  }
2746
2809
 
2747
- .vf-editor-chat-shell[data-layout="brainstorm"] .editor-chat-panel,
2748
- .vf-editor-chat-shell[data-layout="brainstorm"] {
2749
- background: transparent;
2750
- }
2751
-
2752
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-brainstorm-layout {
2753
- grid-template-columns: minmax(0, 1fr);
2754
- }
2755
-
2756
- /* On narrow screens the persistent history sidebar collapses; the
2757
- overlay history toggle in the header takes over instead. */
2758
- .vf-editor-chat-brainstorm-layout.has-sidebar > .vf-editor-chat-history-pane {
2759
- display: none;
2760
- }
2761
-
2762
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-thread {
2810
+ .is-chat-page .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-thread {
2763
2811
  position: relative;
2764
2812
  inset: auto;
2765
2813
  display: grid;
@@ -2767,18 +2815,9 @@ export const TEMPLATE_EDITOR_SHELL_STYLES = `
2767
2815
  width: 100%;
2768
2816
  height: 100%;
2769
2817
  min-height: 0;
2818
+ border: 0;
2770
2819
  border-radius: 0;
2771
- }
2772
-
2773
-
2774
- .vf-editor-chat-history-close,
2775
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-history-toggle {
2776
- display: inline-flex;
2777
- }
2778
-
2779
- .vf-editor-chat-shell[data-layout="brainstorm"] .vf-editor-chat-viewport {
2780
- padding-left: 12px;
2781
- padding-right: 12px;
2820
+ box-shadow: none;
2782
2821
  }
2783
2822
  }
2784
2823
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mevdragon/vidfarm-devcli",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Local bridge for the Vidfarm Trackpad Editor. `vidfarm serve <template_id>` boots the FULL editor on localhost (disk-backed records/storage, free in-process render); edit composition.html on disk (Claude Code, Codex, etc.) and the browser live-morphs it.",
5
5
  "type": "module",
6
6
  "bin": {