comfy-ts 2.14.0 → 2.16.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 (75) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-CUeo843w.js → LogsSt-Ct7Le0S_.js} +2 -2
  3. package/dist/{LogsSt-CUeo843w.js.map → LogsSt-Ct7Le0S_.js.map} +1 -1
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +268 -55
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +176 -26
  8. package/dist/index.d.ts +176 -26
  9. package/dist/index.js +262 -56
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-DUqcn0h3.js → run-serve-C78hD7t9.js} +119 -40
  12. package/dist/run-serve-C78hD7t9.js.map +1 -0
  13. package/dist/{run-tui-D-LaSqgB.js → run-tui-nPETFRmk.js} +15 -9
  14. package/dist/run-tui-nPETFRmk.js.map +1 -0
  15. package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-wb5XkrHV.js} +218 -27
  16. package/dist/schemaDrift-wb5XkrHV.js.map +1 -0
  17. package/dist/serve-web.js +64 -50
  18. package/dist/{state-BytbdZ8s.js → state-BMW57_M0.js} +45 -35
  19. package/dist/state-BMW57_M0.js.map +1 -0
  20. package/dist/web.d.ts +173 -26
  21. package/dist/web.js +251 -53
  22. package/dist/web.js.map +1 -1
  23. package/examples/README.md +1 -0
  24. package/examples/media/README.md +9 -0
  25. package/examples/media/sine_440hz_3s.flac +0 -0
  26. package/examples/media/testsrc_256x256_3s.mp4 +0 -0
  27. package/examples/media/voice_en_6s.flac +0 -0
  28. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +9 -1
  29. package/examples/rvion/10-anima-t2i.cflow.ts +8 -1
  30. package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
  31. package/examples/rvion/15-tts-voice-clone.cflow.ts +111 -0
  32. package/guide-for-agents.md +3 -1
  33. package/package.json +2 -2
  34. package/src/cli/serve/ServeApp.ts +115 -32
  35. package/src/cli/serve/applyVarPayload.ts +5 -3
  36. package/src/cli/serve/describeVar.ts +5 -3
  37. package/src/cli/serve/resultHistory.ts +22 -6
  38. package/src/cli/serve/run-serve.ts +4 -1
  39. package/src/cli/serve/web/api.ts +4 -0
  40. package/src/cli/serve/web/components/DraftTabs.tsx +2 -1
  41. package/src/cli/serve/web/components/Gallery.tsx +86 -5
  42. package/src/cli/serve/web/components/HistoryPicker.tsx +5 -3
  43. package/src/cli/serve/web/components/MenuButton.tsx +2 -4
  44. package/src/cli/serve/web/components/Omnibox.tsx +2 -1
  45. package/src/cli/serve/web/components/PromptEnhancer.tsx +4 -3
  46. package/src/cli/serve/web/components/ShortcutsModal.tsx +2 -1
  47. package/src/cli/serve/web/components/SideMenu.tsx +2 -1
  48. package/src/cli/serve/web/components/VarsForm.tsx +5 -3
  49. package/src/cli/serve/web/components/controls/LorasControl.tsx +4 -3
  50. package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
  51. package/src/cli/serve/web/components/controls/PresetPicker.tsx +2 -1
  52. package/src/cli/serve/web/components/controls/PromptControl.tsx +2 -1
  53. package/src/cli/serve/web/components/controls/SizeControl.tsx +2 -1
  54. package/src/cli/serve/web/state/FormSt.ts +70 -2
  55. package/src/cli/serve/web/state/escape.ts +16 -0
  56. package/src/cli/serve/web/state/host.ts +2 -0
  57. package/src/cli/serve/web/state/mediaDrop.ts +76 -0
  58. package/src/cli/serve/web/styles.ts +16 -2
  59. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +4 -1
  60. package/src/cli/tui/imagePicker/ImagePickerSt.ts +15 -6
  61. package/src/cli/tui/state/TuiSt.ts +1 -1
  62. package/src/coreExports.ts +20 -1
  63. package/src/exampleAssets.ts +13 -3
  64. package/src/host/ComfyUploader.ts +34 -27
  65. package/src/index.ts +1 -1
  66. package/src/runner/ComfyExecution.ts +38 -20
  67. package/src/runner/ComfyWsApi.ts +3 -0
  68. package/src/runner/mediaKinds.ts +51 -0
  69. package/src/vars/ComfyVars.ts +178 -34
  70. package/src/vars/DefinedWorkflow.ts +35 -2
  71. package/dist/run-serve-DUqcn0h3.js.map +0 -1
  72. package/dist/run-tui-D-LaSqgB.js.map +0 -1
  73. package/dist/schemaDrift-E95iTF7E.js.map +0 -1
  74. package/dist/state-BytbdZ8s.js.map +0 -1
  75. package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
@@ -1,5 +1,5 @@
1
- import { $ as stripAnsi, A as refreshLoraInfoCacheIfChanged, B as lmFilePath, C as getLoraTriggerWords, D as lorasMissingFromMirror, E as loraMirrorEntries, F as fetchLoraExampleImages, G as lmSha256, H as lmFolder, I as fetchLoraList, K as lmTags, L as fetchLoraPreviewBytes, M as writeLoraMirror, N as fetchLoraCivitai, P as fetchLoraDescription, Q as colorsAvailable, R as lmBaseModel, S as getLoraPreviewUrl, V as lmFileSize, W as lmNotes, X as loraPreviewMapFrom, Y as loraKey, Z as ansi, b as getLoraDisplayName, d as isPromptInput, dt as sha1HexOfString, et as extractErrorMessage, f as isLoraStrength, i as summarizeDrift, j as reloadLoraInfoCache, k as recordCivitaiMiss, l as isLoraLanes, lt as statelessRegex, m as getLoraKeyword, nt as bang, o as DEFAULT_IMAGE_EXTENSIONS, r as driftChanged, u as isLorasInput, v as buildLoraMirror, w as getLoraTriggers, x as getLoraInfo, y as getLoraAddedAt, z as lmCivitai } from "./schemaDrift-E95iTF7E.js";
2
- import { a as draftsDirForFile, c as isDraftMetaKey, f as findDefinedWorkflow, i as draftKeyForFile, m as scanCflowFiles, n as assembleLogChunks, o as listDraftsForFile, s as ENHANCE_KEY } from "./LogsSt-CUeo843w.js";
1
+ import { $ as DEFAULT_MEDIA_EXTENSIONS, A as reloadLoraInfoCache, B as lmFileSize, C as getLoraTriggers, E as lorasMissingFromMirror, F as fetchLoraList, G as lmTags, I as fetchLoraPreviewBytes, J as loraKey, L as lmBaseModel, M as fetchLoraCivitai, N as fetchLoraDescription, O as recordCivitaiMiss, P as fetchLoraExampleImages, Q as stripAnsi, R as lmCivitai, S as getLoraTriggerWords, T as loraMirrorEntries, U as lmNotes, V as lmFolder, W as lmSha256, X as ansi, Y as loraPreviewMapFrom, Z as colorsAvailable, _ as buildLoraMirror, at as extractErrorMessage, b as getLoraInfo, c as isLoraLanes, d as isLoraStrength, et as MEDIA_KINDS, ht as sha1HexOfString, i as summarizeDrift, j as writeLoraMirror, k as refreshLoraInfoCacheIfChanged, l as isLorasInput, mt as statelessRegex, p as getLoraKeyword, r as driftChanged, st as bang, u as isPromptInput, v as getLoraAddedAt, x as getLoraPreviewUrl, y as getLoraDisplayName, z as lmFilePath } from "./schemaDrift-wb5XkrHV.js";
2
+ import { a as draftsDirForFile, c as isDraftMetaKey, f as findDefinedWorkflow, i as draftKeyForFile, m as scanCflowFiles, n as assembleLogChunks, o as listDraftsForFile, s as ENHANCE_KEY } from "./LogsSt-Ct7Le0S_.js";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, extname, isAbsolute, join, resolve } from "pathe";
@@ -107,7 +107,9 @@ function describeVar(varDef) {
107
107
  starredPresets: [...v.starred]
108
108
  };
109
109
  }
110
- case "image": {
110
+ case "image":
111
+ case "audio":
112
+ case "video": {
111
113
  const v = varDef;
112
114
  return {
113
115
  ...base,
@@ -255,6 +257,8 @@ function applyVarPayload(varDef, raw, opts = {}) {
255
257
  return `var '${name}' expects {"width":W,"height":H}, "WxH", or a preset label`;
256
258
  }
257
259
  case "image":
260
+ case "audio":
261
+ case "video":
258
262
  if (typeof raw !== "string") return `var '${name}' expects a file path or http(s) url string`;
259
263
  varDef.set(raw);
260
264
  return null;
@@ -690,11 +694,13 @@ var ResultHistory = class {
690
694
  });
691
695
  this.used += b.bytes.byteLength;
692
696
  }
693
- this.runs = [{
697
+ const kept = {
694
698
  record: p.record,
695
699
  imageKeys: p.imageKeys,
696
- audioKeys: p.audioKeys
697
- }, ...this.runs];
700
+ audioKeys: p.audioKeys,
701
+ videoKeys: p.videoKeys ?? []
702
+ };
703
+ this.runs = [kept, ...this.runs];
698
704
  for (const dropped of this.runs.slice(50)) this.freeRun(dropped);
699
705
  this.runs = this.runs.slice(0, 50);
700
706
  this.evict();
@@ -707,7 +713,8 @@ var ResultHistory = class {
707
713
  return this.runs.map((k) => ({
708
714
  ...k.record,
709
715
  images: k.record.images.map((img, ix) => this.withLiveUrl(img, k.imageKeys[ix])),
710
- audios: k.record.audios.map((a, ix) => this.withLiveUrl(a, k.audioKeys[ix]))
716
+ audios: k.record.audios.map((a, ix) => this.withLiveUrl(a, k.audioKeys[ix])),
717
+ videos: (k.record.videos ?? []).map((a, ix) => this.withLiveUrl(a, k.videoKeys[ix]))
711
718
  }));
712
719
  }
713
720
  remove(promptId) {
@@ -741,7 +748,11 @@ var ResultHistory = class {
741
748
  };
742
749
  }
743
750
  freeRun(k) {
744
- for (const key of [...k.imageKeys, ...k.audioKeys]) {
751
+ for (const key of [
752
+ ...k.imageKeys,
753
+ ...k.audioKeys,
754
+ ...k.videoKeys
755
+ ]) {
745
756
  if (key == null) continue;
746
757
  const b = this.blobs.get(key);
747
758
  if (b == null) continue;
@@ -761,8 +772,8 @@ var ResultHistory = class {
761
772
  this.runs = this.runs.filter((k) => {
762
773
  const live = (keys) => keys.some((key) => key == null || this.blobs.has(key));
763
774
  const hasText = k.record.texts.length > 0;
764
- const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0;
765
- return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys);
775
+ const hasNothing = k.record.images.length === 0 && k.record.audios.length === 0 && (k.record.videos ?? []).length === 0;
776
+ return hasText || hasNothing || live(k.imageKeys) || live(k.audioKeys) || live(k.videoKeys);
766
777
  });
767
778
  }
768
779
  };
@@ -887,27 +898,31 @@ function readTabs(raw, modules) {
887
898
  }
888
899
  //#endregion
889
900
  //#region src/cli/serve/ServeApp.ts
890
- /** what serve will read off the disk and upload. Wider than the picker default: ComfyUI's
891
- * LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
892
- const SERVE_IMAGE_FLOOR = /* @__PURE__ */ new Set([
893
- ...DEFAULT_IMAGE_EXTENSIONS.map((e) => e.toLowerCase()),
894
- "bmp",
895
- "tif",
896
- "tiff",
897
- "avif"
898
- ]);
901
+ /** what serve will read off the disk and upload, per medium. Wider than the picker defaults:
902
+ * ComfyUI's LoadImage takes bmp and tiff too, and a var declaring one of those must not be refused */
903
+ const SERVE_MEDIA_FLOOR = {
904
+ image: /* @__PURE__ */ new Set([
905
+ ...DEFAULT_MEDIA_EXTENSIONS.image,
906
+ "bmp",
907
+ "tif",
908
+ "tiff",
909
+ "avif"
910
+ ]),
911
+ audio: /* @__PURE__ */ new Set([...DEFAULT_MEDIA_EXTENSIONS.audio, "aac"]),
912
+ video: /* @__PURE__ */ new Set([...DEFAULT_MEDIA_EXTENSIONS.video, "avi"])
913
+ };
899
914
  /** the first bytes say what a file IS; the name only says what it claims. Cheap, and it stops
900
915
  * a .png that holds a key or a script from being read and uploaded to the host.
901
916
  * HONEST LIMIT: this is checked before the run, and the file is read again when the graph
902
917
  * builds, so a local writer who can swap the path in between still wins. Closing that needs
903
918
  * the upload to hold an fd, which is a bigger change than this gate. */
904
- function looksLikeImage(path) {
919
+ function looksLikeMedia(kind, path) {
905
920
  let fd = null;
906
921
  try {
907
922
  fd = openSync(path, "r");
908
923
  const head = /* @__PURE__ */ new Uint8Array(16);
909
924
  const n = readSync(fd, head, 0, 16, 0);
910
- return isImageMagic(head.subarray(0, n));
925
+ return isMediaMagic(kind, head.subarray(0, n));
911
926
  } catch {
912
927
  return false;
913
928
  } finally {
@@ -919,10 +934,11 @@ function looksLikeImage(path) {
919
934
  * the gate: a workflow author narrowing (or emptying) it for listing reasons must not be able
920
935
  * to widen what an unauthenticated request can make the server read. The var may narrow this
921
936
  * floor, never leave it. */
922
- function serveAcceptsImageExt(declared, ext) {
937
+ function serveAcceptsMediaExt(kind, declared, ext) {
938
+ const floor = SERVE_MEDIA_FLOOR[kind];
923
939
  if (ext === "") return false;
924
- if (!SERVE_IMAGE_FLOOR.has(ext)) return false;
925
- const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, "")).filter((e) => SERVE_IMAGE_FLOOR.has(e));
940
+ if (!floor.has(ext)) return false;
941
+ const narrowed = declared.map((e) => e.toLowerCase().replace(/^\./, "")).filter((e) => floor.has(e));
926
942
  return narrowed.length === 0 || narrowed.includes(ext);
927
943
  }
928
944
  /** an image var pointing at a url downloads it: capped, because the inbound BODY cap does not
@@ -993,6 +1009,11 @@ const CONTENT_TYPES = {
993
1009
  ".gif": "image/gif",
994
1010
  ".mp4": "video/mp4",
995
1011
  ".webm": "video/webm",
1012
+ ".m4v": "video/mp4",
1013
+ ".mov": "video/quicktime",
1014
+ ".mkv": "video/x-matroska",
1015
+ ".avi": "video/x-msvideo",
1016
+ ".aac": "audio/aac",
996
1017
  ".flac": "audio/flac",
997
1018
  ".mp3": "audio/mpeg",
998
1019
  ".opus": "audio/ogg",
@@ -1023,6 +1044,31 @@ function isImageMagic(b) {
1023
1044
  if (at(4, 102, 116, 121, 112)) return true;
1024
1045
  return false;
1025
1046
  }
1047
+ /** the same full-signature sniff for every medium: a var of one kind never reads a file of
1048
+ * another. mp4, mov and m4a share the isobmff `ftyp` box, the extension floor tells them apart */
1049
+ function isMediaMagic(kind, b) {
1050
+ const at = (i, ...want) => want.every((w, k) => b[i + k] === w);
1051
+ const isobmff = at(4, 102, 116, 121, 112);
1052
+ if (kind === "image") return isImageMagic(b);
1053
+ if (kind === "audio") {
1054
+ if (at(0, 82, 73, 70, 70) && at(8, 87, 65, 86, 69)) return true;
1055
+ if (at(0, 102, 76, 97, 67)) return true;
1056
+ if (at(0, 79, 103, 103, 83)) return true;
1057
+ if (at(0, 73, 68, 51)) return true;
1058
+ const b0 = b[0];
1059
+ const b1 = b[1];
1060
+ const b2 = b[2];
1061
+ if (b0 === 255 && b1 != null && b1 !== 254 && b2 != null && (b1 & 224) === 224 && (b1 & 24) !== 8 && (b1 & 6) !== 0 && b2 >> 4 !== 15 && (b2 >> 2 & 3) !== 3) return true;
1062
+ if (b0 === 255 && b1 != null && (b1 & 246) === 240) return true;
1063
+ return isobmff;
1064
+ }
1065
+ if (at(0, 26, 69, 223, 163)) return true;
1066
+ if (at(0, 82, 73, 70, 70) && at(8, 65, 86, 73, 32)) return true;
1067
+ return isobmff;
1068
+ }
1069
+ function isMediaKind(kind) {
1070
+ return MEDIA_KINDS.includes(kind);
1071
+ }
1026
1072
  function json(status, payload) {
1027
1073
  return {
1028
1074
  status,
@@ -1040,7 +1086,8 @@ const USAGE = [
1040
1086
  "PUT /drafts/<module>/<draft> with { ...vars } — save (or duplicate to a new name) a draft",
1041
1087
  "DELETE /drafts/<module>/<draft> — delete that draft file",
1042
1088
  "GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes",
1043
- "POST /upload with {\"name\",\"dataBase64\"} — store a browser file for an image var",
1089
+ "POST /upload with {\"name\",\"dataBase64\"} — store a browser file for an image, audio or video var",
1090
+ "GET /images|audio|video/<promptId>/<ix> — an output kept in memory (saving off)",
1044
1091
  "GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)",
1045
1092
  "GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)",
1046
1093
  "GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)",
@@ -1166,6 +1213,7 @@ var ServeApp = class {
1166
1213
  if (segs[0] === "hosts" && segs.length === 3 && segs[1] != null && segs[2] === "drift") return await this.replyHostDrift(segs[1], req.url.includes("full=1"));
1167
1214
  if (segs[0] === "images" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`${segs[1]}/${segs[2]}`);
1168
1215
  if (segs[0] === "audio" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`audio/${segs[1]}/${segs[2]}`);
1216
+ if (segs[0] === "video" && segs.length === 3 && segs[1] != null && segs[2] != null) return this.replyMemoryImage(`video/${segs[1]}/${segs[2]}`);
1169
1217
  if (segs[0] === "results" && segs.length === 1) return json(200, {
1170
1218
  runs: this.kept.list(),
1171
1219
  memory: this.kept.usage()
@@ -1451,7 +1499,7 @@ var ServeApp = class {
1451
1499
  headers: NO_STORE
1452
1500
  };
1453
1501
  }
1454
- /** browser file → local file an image var can point at (downloadInput family) */
1502
+ /** browser file → local file a media var can point at (downloadInput family) */
1455
1503
  replyUpload(req) {
1456
1504
  let parsed;
1457
1505
  try {
@@ -1582,13 +1630,13 @@ var ServeApp = class {
1582
1630
  const rebound = await this.rebindHostVars(hostId, host);
1583
1631
  const nodes = host.schema.nodes.length;
1584
1632
  const loras = host.schema.getLoras().length;
1585
- const dropped = rebound.stale.length === 0 ? "" : `. dropped ${rebound.stale.length} selection(s) this host no longer lists`;
1633
+ const dropped = rebound.stale.length === 0 ? "" : `. ${rebound.stale.length} selection(s) this host no longer lists (a lora is dropped, a model stays picked)`;
1586
1634
  return json(200, {
1587
1635
  ok: true,
1588
1636
  host: hostId,
1589
1637
  action,
1590
1638
  stale: rebound.stale,
1591
- note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora var(s) changed${dropped}${lorasNote}`
1639
+ note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora or model var(s) changed${dropped}${lorasNote}`
1592
1640
  });
1593
1641
  }
1594
1642
  if (action === "restart") {
@@ -1624,6 +1672,15 @@ var ServeApp = class {
1624
1672
  if (mod.dw.host.data.id !== hostId) continue;
1625
1673
  await this.exclusive(mod.key, () => {
1626
1674
  for (const [name, varDef] of mod.dw.entries()) {
1675
+ if (varDef.kind === "choice") {
1676
+ const choice = varDef;
1677
+ if (choice.hostSlot == null) continue;
1678
+ const before = choice.choices.length;
1679
+ choice.bindHost(host);
1680
+ if (choice.choices.length !== before) widened++;
1681
+ if (choice.value != null && !choice.choices.includes(choice.value)) stale.push(`${mod.key}/${name}: ${choice.value}`);
1682
+ continue;
1683
+ }
1627
1684
  if (varDef.kind !== "loras") continue;
1628
1685
  const lorasVar = varDef;
1629
1686
  if (lorasVar.optionsFilter == null) continue;
@@ -2239,6 +2296,8 @@ var ServeApp = class {
2239
2296
  const produced = [`${execution.images.length} image(s)`];
2240
2297
  const audios = execution.audios ?? [];
2241
2298
  if (audios.length > 0) produced.push(`${audios.length} audio(s)`);
2299
+ const videos = execution.videos ?? [];
2300
+ if (videos.length > 0) produced.push(`${videos.length} video(s)`);
2242
2301
  if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`);
2243
2302
  console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1e3).toFixed(1)}s · ${produced.join(" · ")}`);
2244
2303
  const blobs = [];
@@ -2254,7 +2313,13 @@ var ServeApp = class {
2254
2313
  blobs.push(this.memoryBlob(key, a.bytes, a.filename));
2255
2314
  return key;
2256
2315
  });
2257
- const memoryUrl = (route, key) => `/${route}/${key.split("/").slice(route === "audio" ? 1 : 0).map((seg) => encodeURIComponent(seg)).join("/")}`;
2316
+ const videoKeys = videos.map((a, ix) => {
2317
+ if (a.absPath != null) return null;
2318
+ const key = `video/${execution.data.id}/${ix}`;
2319
+ blobs.push(this.memoryBlob(key, a.bytes, a.filename));
2320
+ return key;
2321
+ });
2322
+ const memoryUrl = (route, key) => `/${route}/${key.split("/").slice(route === "images" ? 0 : 1).map((seg) => encodeURIComponent(seg)).join("/")}`;
2258
2323
  const record = {
2259
2324
  ok: true,
2260
2325
  module: mod.key,
@@ -2284,12 +2349,22 @@ var ServeApp = class {
2284
2349
  url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl("audio", key) : null,
2285
2350
  absPath: a.absPath
2286
2351
  };
2352
+ }),
2353
+ videos: videos.map((a, ix) => {
2354
+ const key = videoKeys[ix];
2355
+ return {
2356
+ filename: a.filename,
2357
+ mime: a.mime,
2358
+ url: a.absPath != null ? this.outputUrl(a.absPath) : key != null ? memoryUrl("video", key) : null,
2359
+ absPath: a.absPath
2360
+ };
2287
2361
  })
2288
2362
  };
2289
2363
  this.kept.add({
2290
2364
  record,
2291
2365
  imageKeys,
2292
2366
  audioKeys,
2367
+ videoKeys,
2293
2368
  blobs
2294
2369
  });
2295
2370
  const first = execution.images[0];
@@ -2335,7 +2410,7 @@ var ServeApp = class {
2335
2410
  error: `unknown var '${k}' — vars: ${[...varMap.keys()].join(", ")}`
2336
2411
  };
2337
2412
  let value = rawValue;
2338
- if (varDef.kind === "image" && typeof rawValue === "string" && /^https?:\/\//.test(rawValue)) try {
2413
+ if (isMediaKind(varDef.kind) && typeof rawValue === "string" && /^https?:\/\//.test(rawValue)) try {
2339
2414
  value = await this.downloadInput(rawValue);
2340
2415
  } catch (e) {
2341
2416
  return {
@@ -2354,13 +2429,14 @@ var ServeApp = class {
2354
2429
  };
2355
2430
  }
2356
2431
  for (const [k, varDef] of varMap) {
2357
- if (varDef.kind !== "image") continue;
2358
- const img = varDef;
2359
- if (!img.isSet()) continue;
2360
- const abs = img.absPath();
2432
+ const kind = varDef.kind;
2433
+ if (!isMediaKind(kind)) continue;
2434
+ const media = varDef;
2435
+ if (!media.isSet()) continue;
2436
+ const abs = media.absPath();
2361
2437
  const refuse = {
2362
2438
  status: 400,
2363
- error: `image var '${k}': not a usable image file`
2439
+ error: `${kind} var '${k}': not a usable ${kind} file`
2364
2440
  };
2365
2441
  if (!existsSync(abs)) return refuse;
2366
2442
  let real;
@@ -2374,8 +2450,8 @@ var ServeApp = class {
2374
2450
  } catch {
2375
2451
  return refuse;
2376
2452
  }
2377
- if (!serveAcceptsImageExt(img.extensions, extname(real).toLowerCase().replace(/^\./, ""))) return refuse;
2378
- if (!looksLikeImage(real)) return refuse;
2453
+ if (!serveAcceptsMediaExt(kind, media.extensions, extname(real).toLowerCase().replace(/^\./, ""))) return refuse;
2454
+ if (!looksLikeMedia(kind, real)) return refuse;
2379
2455
  }
2380
2456
  for (const [k, varDef] of varMap) {
2381
2457
  if (varDef.kind !== "seed") continue;
@@ -2410,7 +2486,7 @@ var ServeApp = class {
2410
2486
  host: runHost ?? void 0
2411
2487
  }) };
2412
2488
  } catch (e) {
2413
- if (e instanceof Error && e.name === "ImageVarEmptyError") return {
2489
+ if (e instanceof Error && (e.name === "MediaVarEmptyError" || e.name === "ImageVarEmptyError")) return {
2414
2490
  status: 400,
2415
2491
  error: e.message
2416
2492
  };
@@ -2687,6 +2763,8 @@ async function loadOrBuildWebJs() {
2687
2763
  //#region src/cli/serve/run-serve.ts
2688
2764
  const DEFAULT_PORT = 8288;
2689
2765
  const BODY_CAP = 1e7;
2766
+ /** a video dropped on a media var rides POST /upload as base64 json: ~200 MB of file */
2767
+ const UPLOAD_BODY_CAP = 28e7;
2690
2768
  function parseArgs(args) {
2691
2769
  let target;
2692
2770
  let port = DEFAULT_PORT;
@@ -2726,6 +2804,7 @@ function makeRequestListener(app) {
2726
2804
  "access-control-allow-headers": "content-type, accept"
2727
2805
  };
2728
2806
  return (req, res) => {
2807
+ const cap = req.method === "POST" && (req.url ?? "").split("?")[0] === "/upload" ? UPLOAD_BODY_CAP : BODY_CAP;
2729
2808
  const chunks = [];
2730
2809
  let size = 0;
2731
2810
  let overflow = false;
@@ -2733,7 +2812,7 @@ function makeRequestListener(app) {
2733
2812
  req.on("data", (c) => {
2734
2813
  if (overflow) return;
2735
2814
  size += c.length;
2736
- if (size > BODY_CAP) {
2815
+ if (size > cap) {
2737
2816
  overflow = true;
2738
2817
  res.writeHead(413, {
2739
2818
  "content-type": "application/json",
@@ -2865,4 +2944,4 @@ function printStartup(app, bind, port) {
2865
2944
  //#endregion
2866
2945
  export { runServe };
2867
2946
 
2868
- //# sourceMappingURL=run-serve-DUqcn0h3.js.map
2947
+ //# sourceMappingURL=run-serve-C78hD7t9.js.map