vidspotai-shared 1.0.131 → 1.0.133

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 (86) hide show
  1. package/lib/globals/aiModels/enums.d.ts +4 -0
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +9 -0
  4. package/lib/globals/aiModels/index.d.ts.map +1 -1
  5. package/lib/globals/aiModels/index.js +2 -0
  6. package/lib/globals/aiModels/providers/fal.d.ts +20 -0
  7. package/lib/globals/aiModels/providers/fal.d.ts.map +1 -0
  8. package/lib/globals/aiModels/providers/fal.js +100 -0
  9. package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
  10. package/lib/globals/aiModels/providers/google.js +229 -177
  11. package/lib/globals/aiModels/types.d.ts +3 -1
  12. package/lib/globals/aiModels/types.d.ts.map +1 -1
  13. package/lib/globals/creditUnit.d.ts +9 -0
  14. package/lib/globals/creditUnit.d.ts.map +1 -1
  15. package/lib/globals/creditUnit.js +10 -1
  16. package/lib/globals/index.d.ts +2 -0
  17. package/lib/globals/index.d.ts.map +1 -1
  18. package/lib/globals/index.js +2 -0
  19. package/lib/globals/posterExport.d.ts +34 -0
  20. package/lib/globals/posterExport.d.ts.map +1 -0
  21. package/lib/globals/posterExport.js +50 -0
  22. package/lib/globals/types.d.ts +9 -1
  23. package/lib/globals/types.d.ts.map +1 -1
  24. package/lib/globals/types.js +9 -0
  25. package/lib/globals/videoTools.d.ts +24 -0
  26. package/lib/globals/videoTools.d.ts.map +1 -0
  27. package/lib/globals/videoTools.js +31 -0
  28. package/lib/libs/storage/MediaStorage.d.ts.map +1 -1
  29. package/lib/libs/storage/MediaStorage.js +37 -10
  30. package/lib/libs/storage/cdnUrl.d.ts +7 -0
  31. package/lib/libs/storage/cdnUrl.d.ts.map +1 -1
  32. package/lib/libs/storage/cdnUrl.js +26 -0
  33. package/lib/models/index.d.ts +2 -0
  34. package/lib/models/index.d.ts.map +1 -1
  35. package/lib/models/index.js +2 -0
  36. package/lib/models/organization.model.d.ts +23 -0
  37. package/lib/models/organization.model.d.ts.map +1 -1
  38. package/lib/models/organization.model.js +17 -0
  39. package/lib/models/posterExport.model.d.ts +29 -0
  40. package/lib/models/posterExport.model.d.ts.map +1 -0
  41. package/lib/models/posterExport.model.js +2 -0
  42. package/lib/models/videoTool.model.d.ts +59 -0
  43. package/lib/models/videoTool.model.d.ts.map +1 -0
  44. package/lib/models/videoTool.model.js +2 -0
  45. package/lib/services/agent/planner/structuralRules.js +2 -2
  46. package/lib/services/agent/planner/validators.js +1 -1
  47. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  48. package/lib/services/agent/providerFallback/chains.js +13 -4
  49. package/lib/services/agent/tools/animateImage.tool.js +1 -1
  50. package/lib/services/agent/tools/generateVideo.tool.js +3 -3
  51. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  52. package/lib/services/aiGen/aiGenFactory.service.js +6 -0
  53. package/lib/services/aiGen/providers/fal/falImageTools.service.d.ts +37 -0
  54. package/lib/services/aiGen/providers/fal/falImageTools.service.d.ts.map +1 -0
  55. package/lib/services/aiGen/providers/fal/falImageTools.service.js +278 -0
  56. package/lib/services/aiGen/providers/fal/falUpscale.service.d.ts +8 -0
  57. package/lib/services/aiGen/providers/fal/falUpscale.service.d.ts.map +1 -1
  58. package/lib/services/aiGen/providers/fal/falUpscale.service.js +1 -0
  59. package/lib/services/aiGen/providers/fal/falVideoMatting.service.d.ts +36 -0
  60. package/lib/services/aiGen/providers/fal/falVideoMatting.service.d.ts.map +1 -0
  61. package/lib/services/aiGen/providers/fal/falVideoMatting.service.js +119 -0
  62. package/lib/services/aiGen/providers/fal/index.d.ts +2 -0
  63. package/lib/services/aiGen/providers/fal/index.d.ts.map +1 -1
  64. package/lib/services/aiGen/providers/fal/index.js +2 -0
  65. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  66. package/lib/services/aiGen/providers/google/google.service.js +9 -1
  67. package/lib/services/aiGen/textFallback.d.ts +19 -0
  68. package/lib/services/aiGen/textFallback.d.ts.map +1 -0
  69. package/lib/services/aiGen/textFallback.js +76 -0
  70. package/lib/services/brandKit.service.d.ts +22 -0
  71. package/lib/services/brandKit.service.d.ts.map +1 -0
  72. package/lib/services/brandKit.service.js +59 -0
  73. package/lib/services/firestore.service.d.ts +7 -1
  74. package/lib/services/firestore.service.d.ts.map +1 -1
  75. package/lib/services/firestore.service.js +10 -0
  76. package/lib/services/index.d.ts +1 -0
  77. package/lib/services/index.d.ts.map +1 -1
  78. package/lib/services/index.js +1 -0
  79. package/lib/services/translation/translation.service.d.ts.map +1 -1
  80. package/lib/services/translation/translation.service.js +13 -2
  81. package/lib/utils/errors.d.ts +4 -0
  82. package/lib/utils/errors.d.ts.map +1 -1
  83. package/lib/utils/errors.js +6 -0
  84. package/lib/utils/helpers.d.ts.map +1 -1
  85. package/lib/utils/helpers.js +7 -4
  86. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FalVideoMattingService = void 0;
4
+ const videoTools_1 = require("../../../../globals/videoTools");
5
+ const errors_1 = require("../../../../utils/errors");
6
+ const logger_1 = require("../../../../utils/logger");
7
+ const transientRetry_1 = require("../../transientRetry");
8
+ const falUpscale_service_1 = require("./falUpscale.service");
9
+ const QUEUE_BASE_URL = "https://queue.fal.run";
10
+ const OUTPUT_TYPE = {
11
+ // VP9 carries alpha (alpha_mode=1) — verified with ffprobe on a real output.
12
+ webm: "VP9 (.webm)",
13
+ mov: "PRORES4444 (.mov)",
14
+ };
15
+ /** BiRefNet video variant per quality — Light is ~12.7 compute-s per video-s. */
16
+ const MODEL_BY_QUALITY = {
17
+ standard: { model: "General Use (Light)", operating_resolution: "1024x1024" },
18
+ high: { model: "General Use (Heavy)", operating_resolution: "1024x1024" },
19
+ };
20
+ /**
21
+ * fal BiRefNet v2 VIDEO — alpha-matte background removal on a clip. Queue-only
22
+ * (minutes, not seconds), so this service exposes the three queue steps and
23
+ * leaves the poll loop to the VIDEO_TOOL_JOBS worker, which owns heartbeats,
24
+ * resumption (providerRequestId is persisted) and the ffmpeg composite.
25
+ */
26
+ class FalVideoMattingService {
27
+ constructor() {
28
+ if (!process.env.FAL_KEY) {
29
+ throw new Error("Missing FAL_KEY in environment variables");
30
+ }
31
+ this.apiKey = process.env.FAL_KEY;
32
+ }
33
+ headers(json) {
34
+ const h = { Authorization: `Key ${this.apiKey}` };
35
+ if (json)
36
+ h["Content-Type"] = "application/json";
37
+ return h;
38
+ }
39
+ /**
40
+ * Status/result routes for a request id. fal drops the nested sub-path of an
41
+ * app id (`fal-ai/birefnet/v2/video` → `fal-ai/birefnet`) on these routes —
42
+ * rebuilt here so a resumed job only needs the persisted request id.
43
+ */
44
+ routes(requestId) {
45
+ const [owner, app] = videoTools_1.VIDEO_BG_REMOVAL.appId.split("/");
46
+ const base = `${QUEUE_BASE_URL}/${owner}/${app}/requests/${requestId}`;
47
+ return { statusUrl: `${base}/status`, responseUrl: base };
48
+ }
49
+ async submit(params) {
50
+ const input = {
51
+ video_url: params.videoUrl,
52
+ ...MODEL_BY_QUALITY[params.quality],
53
+ video_output_type: OUTPUT_TYPE[params.container],
54
+ video_quality: "high",
55
+ video_write_mode: "balanced",
56
+ refine_foreground: true,
57
+ output_mask: false,
58
+ };
59
+ return (0, transientRetry_1.withTransientRetry)("fal:birefnet-video:submit", async () => {
60
+ const resp = await fetch(`${QUEUE_BASE_URL}/${videoTools_1.VIDEO_BG_REMOVAL.appId}`, {
61
+ method: "POST",
62
+ headers: this.headers(true),
63
+ body: JSON.stringify(input),
64
+ });
65
+ if (!resp.ok) {
66
+ const body = await resp.text();
67
+ if (resp.status === 422) {
68
+ throw new errors_1.UserFacingError("This video couldn't be processed. Try an MP4, MOV or WebM up to 60 seconds.", errors_1.USER_FACING_ERROR_CODES.INPUT_VIDEO_REJECTED);
69
+ }
70
+ throw (0, falUpscale_service_1.classifyFalHttpError)(resp.status, body, "birefnet-video:submit");
71
+ }
72
+ const data = (await resp.json());
73
+ if (!data.request_id)
74
+ throw new Error("fal birefnet video did not return a request_id");
75
+ return data.request_id;
76
+ }, {
77
+ onRetry: ({ attempt, maxAttempts, backoffMs, err }) => logger_1.logger.warn("fal video matting submit transient error — retrying", {
78
+ attempt,
79
+ maxAttempts,
80
+ backoffMs,
81
+ message: err.message,
82
+ }),
83
+ });
84
+ }
85
+ async status(requestId) {
86
+ const resp = await fetch(this.routes(requestId).statusUrl, { headers: this.headers(false) });
87
+ if (!resp.ok) {
88
+ throw (0, falUpscale_service_1.classifyFalHttpError)(resp.status, await resp.text(), "birefnet-video:status");
89
+ }
90
+ const data = (await resp.json());
91
+ if (data.error)
92
+ throw new Error(`fal birefnet video failed: ${data.error}`);
93
+ const status = (data.status ?? "").toUpperCase();
94
+ if (status === "COMPLETED" || status === "IN_PROGRESS")
95
+ return status;
96
+ return "IN_QUEUE";
97
+ }
98
+ async result(requestId) {
99
+ const resp = await fetch(this.routes(requestId).responseUrl, { headers: this.headers(false) });
100
+ if (!resp.ok) {
101
+ const body = await resp.text();
102
+ if (resp.status === 422) {
103
+ throw new errors_1.UserFacingError("This video couldn't be processed. Try an MP4, MOV or WebM up to 60 seconds.", errors_1.USER_FACING_ERROR_CODES.INPUT_VIDEO_REJECTED);
104
+ }
105
+ throw (0, falUpscale_service_1.classifyFalHttpError)(resp.status, body, "birefnet-video:result");
106
+ }
107
+ const data = (await resp.json());
108
+ if (!data.video?.url)
109
+ throw new Error("fal birefnet video returned no video");
110
+ return {
111
+ url: data.video.url,
112
+ contentType: data.video.content_type ?? "video/webm",
113
+ width: data.video.width,
114
+ height: data.video.height,
115
+ durationSec: data.video.duration,
116
+ };
117
+ }
118
+ }
119
+ exports.FalVideoMattingService = FalVideoMattingService;
@@ -1,3 +1,5 @@
1
1
  export * from "./falImage.service";
2
2
  export * from "./falUpscale.service";
3
+ export * from "./falImageTools.service";
4
+ export * from "./falVideoMatting.service";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/fal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/fal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC"}
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./falImage.service"), exports);
18
18
  __exportStar(require("./falUpscale.service"), exports);
19
+ __exportStar(require("./falImageTools.service"), exports);
20
+ __exportStar(require("./falVideoMatting.service"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAuIlB,qBAAa,aAAc,SAAQ,wBAAwB;IAKzD,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAK;;IAQ/C;;;;;;;;;OASG;IACG,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAoChC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAoCvB;;;;OAIG;YACW,kBAAkB;IAsC1B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiUjC;;;;;;;OAOG;YACW,iBAAiB;YAoGjB,eAAe;IA4EvB,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyEjD;;;;OAIG;YACW,oBAAoB;IAkH5B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAiBnB,cAAc;IAkP5B;;;;;;OAMG;IACH;;;;OAIG;IACG,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,UAAmB,EAAE,SAAiB,EAAE,SAAa,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAoCpJ"}
1
+ {"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAuIlB,qBAAa,aAAc,SAAQ,wBAAwB;IAKzD,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAK;;IAQ/C;;;;;;;;;OASG;IACG,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAoChC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAoCvB;;;;OAIG;YACW,kBAAkB;IAsC1B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiUjC;;;;;;;OAOG;YACW,iBAAiB;YAoGjB,eAAe;IAuFvB,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyEjD;;;;OAIG;YACW,oBAAoB;IAkH5B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAiBnB,cAAc;IAkP5B;;;;;;OAMG;IACH;;;;OAIG;IACG,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,UAAmB,EAAE,SAAiB,EAAE,SAAa,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAoCpJ"}
@@ -600,7 +600,15 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
600
600
  return { status: types_1.EVideoSceneStatus.PENDING };
601
601
  if (interaction.status !== "completed") {
602
602
  const apiErr = interaction.errors?.[0] ?? interaction.error;
603
- const classified = apiErr ? (0, googleErrors_1.classifyGoogleApiError)({ message: JSON.stringify({ error: apiErr }) }) : null;
603
+ let classified = apiErr ? (0, googleErrors_1.classifyGoogleApiError)({ message: JSON.stringify({ error: apiErr }) }) : null;
604
+ // Omni's opaque "There was a problem processing your request" failure
605
+ // (no status/code) is what it returns for silently-refused prompts or
606
+ // images (prod 2026-10-24: an explicit sexual prompt, and a
607
+ // two-characters image). Not operator-actionable — surface it as a
608
+ // rejected prompt so it doesn't page and the user gets a rephrase hint.
609
+ if (!classified && /problem processing your request/i.test(apiErr?.message ?? "")) {
610
+ classified = new errors_1.UserFacingError((0, errors_1.friendlyMessageForCode)(errors_1.USER_FACING_ERROR_CODES.PROMPT_INVALID), errors_1.USER_FACING_ERROR_CODES.PROMPT_INVALID);
611
+ }
604
612
  return {
605
613
  status: types_1.EVideoSceneStatus.FAILED,
606
614
  errorMessage: classified
@@ -0,0 +1,19 @@
1
+ import { ETextGenModels } from "../../globals/aiModels";
2
+ import type { TextGenerationParams, TextGenerationResult } from "./providers/types";
3
+ /**
4
+ * Cross-provider fallback for one-shot text generation.
5
+ *
6
+ * 2026-10-23: the OpenAI org ran out of credits ("429 You have no credits
7
+ * remaining") and every caller pinned to gpt-4o-mini — prompt generation,
8
+ * the translation LLM fallback — failed outright for a day. A second
9
+ * provider on a separate account (Gemini, separate billing + key) keeps
10
+ * those features up while the primary account is fixed.
11
+ */
12
+ export declare const TEXT_FALLBACK_MODEL = ETextGenModels.GOOGLE_GEMINI_3_5_FLASH;
13
+ /** Quota / billing / auth failures need a human (top up, rotate a key) — so
14
+ * they page; anything else (transient 5xx, timeouts) is recovered silently. */
15
+ export declare function isOperatorActionableLlmError(err: unknown): boolean;
16
+ /** Run `params` on its own provider; on failure, retry once on Gemini. If both
17
+ * fail, the PRIMARY error is rethrown (it's the one that explains the outage). */
18
+ export declare function generateTextWithFallback(params: TextGenerationParams, context: string): Promise<TextGenerationResult>;
19
+ //# sourceMappingURL=textFallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textFallback.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/textFallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEpF;;;;;;;;GAQG;AAGH,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAW1E;+EAC+E;AAC/E,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAUlE;AAkBD;kFACkF;AAClF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAuB/B"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEXT_FALLBACK_MODEL = void 0;
4
+ exports.isOperatorActionableLlmError = isOperatorActionableLlmError;
5
+ exports.generateTextWithFallback = generateTextWithFallback;
6
+ const aiModels_1 = require("../../globals/aiModels");
7
+ const logger_1 = require("../../utils/logger");
8
+ const aiGenFactory_service_1 = require("./aiGenFactory.service");
9
+ /**
10
+ * Cross-provider fallback for one-shot text generation.
11
+ *
12
+ * 2026-10-23: the OpenAI org ran out of credits ("429 You have no credits
13
+ * remaining") and every caller pinned to gpt-4o-mini — prompt generation,
14
+ * the translation LLM fallback — failed outright for a day. A second
15
+ * provider on a separate account (Gemini, separate billing + key) keeps
16
+ * those features up while the primary account is fixed.
17
+ */
18
+ // gemini-3.5-flash, not 2.5: newer Google projects (our pool key #1) get
19
+ // "gemini-2.5-flash is no longer available to new users" (checked 2026-10-23).
20
+ exports.TEXT_FALLBACK_MODEL = aiModels_1.ETextGenModels.GOOGLE_GEMINI_3_5_FLASH;
21
+ /** Quota / billing / auth failures need a human (top up, rotate a key) — so
22
+ * they page; anything else (transient 5xx, timeouts) is recovered silently. */
23
+ function isOperatorActionableLlmError(err) {
24
+ const e = (err ?? {});
25
+ const status = e.status ?? e.response?.status;
26
+ if (status === 401 || status === 403)
27
+ return true;
28
+ const code = `${e.code ?? ""} ${e.type ?? ""} ${e.error?.code ?? ""} ${e.error?.type ?? ""}`;
29
+ const msg = e.message ?? "";
30
+ return (/insufficient_quota|billing|authentication_error|invalid_api_key/i.test(code) ||
31
+ /no credits remaining|exceeded your current quota|invalid x-api-key|incorrect api key/i.test(msg));
32
+ }
33
+ /** Gemini has JSON mode but no OpenAI-style strict json_schema, so the schema
34
+ * rides along in the system prompt; callers still Zod-validate the output. */
35
+ function adaptParamsForFallback(params) {
36
+ const schema = params.options?.responseFormat?.json_schema?.schema;
37
+ if (!schema || !Array.isArray(params.input)) {
38
+ return { ...params, modelKey: exports.TEXT_FALLBACK_MODEL };
39
+ }
40
+ const hint = `Respond with a single JSON object that matches this JSON Schema exactly:\n${JSON.stringify(schema)}`;
41
+ const input = params.input;
42
+ const hasSystem = input.some((m) => m.role === "system");
43
+ const adapted = hasSystem
44
+ ? input.map((m) => (m.role === "system" && typeof m.content === "string" ? { ...m, content: `${m.content}\n\n${hint}` } : m))
45
+ : [{ role: "system", content: hint }, ...input];
46
+ return { ...params, input: adapted, modelKey: exports.TEXT_FALLBACK_MODEL };
47
+ }
48
+ /** Run `params` on its own provider; on failure, retry once on Gemini. If both
49
+ * fail, the PRIMARY error is rethrown (it's the one that explains the outage). */
50
+ async function generateTextWithFallback(params, context) {
51
+ try {
52
+ return await (0, aiGenFactory_service_1.getAiGenProviderService)(params.modelKey).generateText(params);
53
+ }
54
+ catch (primaryErr) {
55
+ if (params.modelKey === exports.TEXT_FALLBACK_MODEL)
56
+ throw primaryErr;
57
+ const logFn = isOperatorActionableLlmError(primaryErr) ? logger_1.logger.error.bind(logger_1.logger) : logger_1.logger.warn.bind(logger_1.logger);
58
+ logFn("Text LLM primary failed — retrying on fallback provider", {
59
+ context,
60
+ primaryModel: params.modelKey,
61
+ fallbackModel: exports.TEXT_FALLBACK_MODEL,
62
+ err: primaryErr?.message ?? String(primaryErr),
63
+ });
64
+ try {
65
+ return await (0, aiGenFactory_service_1.getAiGenProviderService)(exports.TEXT_FALLBACK_MODEL).generateText(adaptParamsForFallback(params));
66
+ }
67
+ catch (fallbackErr) {
68
+ logger_1.logger.warn("Text LLM fallback provider also failed", {
69
+ context,
70
+ fallbackModel: exports.TEXT_FALLBACK_MODEL,
71
+ err: fallbackErr?.message ?? String(fallbackErr),
72
+ });
73
+ throw primaryErr;
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,22 @@
1
+ import { IBrandKitModel } from "../models/agent.model";
2
+ import { IOrganizationBrandKitModel } from "../models/organization.model";
3
+ export interface IResolvedBrandKit {
4
+ /** Personal kit with the active org's shared fields laid over it; null when neither exists. */
5
+ brandKit: IBrandKitModel | null;
6
+ /** The org whose team kit was applied, when one was. */
7
+ teamOrgId: string | null;
8
+ }
9
+ /**
10
+ * Overlay a team kit onto a personal kit. Only the shareable fields
11
+ * (ORG_BRAND_KIT_FIELDS) move; a field the team kit leaves unset falls back
12
+ * to the member's own value, and likeness fields always stay personal.
13
+ */
14
+ export declare function mergeTeamBrandKit(userId: string, personal: IBrandKitModel | null, team: IOrganizationBrandKitModel | null): IBrandKitModel | null;
15
+ /**
16
+ * The brand kit every brand-aware surface should apply for `userId`: their
17
+ * personal kit, overridden by their ACTIVE org's shared team kit (if they
18
+ * have one and are still a member). Membership is re-checked so a removed
19
+ * member whose `organizationId` hasn't been cleared yet stops inheriting.
20
+ */
21
+ export declare function resolveBrandKitForUser(userId: string, organizationId?: string | null): Promise<IResolvedBrandKit>;
22
+ //# sourceMappingURL=brandKit.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brandKit.service.d.ts","sourceRoot":"","sources":["../../src/services/brandKit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,0BAA0B,EAG3B,MAAM,8BAA8B,CAAC;AAGtC,MAAM,WAAW,iBAAiB;IAChC,+FAA+F;IAC/F,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC,wDAAwD;IACxD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,cAAc,GAAG,IAAI,EAC/B,IAAI,EAAE,0BAA0B,GAAG,IAAI,GACtC,cAAc,GAAG,IAAI,CAevB;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAwB5B"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeTeamBrandKit = mergeTeamBrandKit;
4
+ exports.resolveBrandKitForUser = resolveBrandKitForUser;
5
+ const organization_model_1 = require("../models/organization.model");
6
+ const firestore_service_1 = require("./firestore.service");
7
+ /**
8
+ * Overlay a team kit onto a personal kit. Only the shareable fields
9
+ * (ORG_BRAND_KIT_FIELDS) move; a field the team kit leaves unset falls back
10
+ * to the member's own value, and likeness fields always stay personal.
11
+ */
12
+ function mergeTeamBrandKit(userId, personal, team) {
13
+ if (!team)
14
+ return personal;
15
+ const base = personal ?? {
16
+ userId,
17
+ createdAt: team.createdAt,
18
+ updatedAt: team.updatedAt,
19
+ };
20
+ const merged = { ...base };
21
+ for (const field of organization_model_1.ORG_BRAND_KIT_FIELDS) {
22
+ const value = team[field];
23
+ if (value === undefined || value === null || value === "")
24
+ continue;
25
+ if (Array.isArray(value) && value.length === 0)
26
+ continue;
27
+ merged[field] = value;
28
+ }
29
+ return merged;
30
+ }
31
+ /**
32
+ * The brand kit every brand-aware surface should apply for `userId`: their
33
+ * personal kit, overridden by their ACTIVE org's shared team kit (if they
34
+ * have one and are still a member). Membership is re-checked so a removed
35
+ * member whose `organizationId` hasn't been cleared yet stops inheriting.
36
+ */
37
+ async function resolveBrandKitForUser(userId, organizationId) {
38
+ const personalPromise = firestore_service_1.FirestoreService.brandKitsCol.doc(userId).get();
39
+ let orgId = organizationId;
40
+ if (orgId === undefined) {
41
+ const user = await firestore_service_1.FirestoreService.getDataById(firestore_service_1.FirestoreService.usersCol, userId);
42
+ orgId = user?.organizationId ?? null;
43
+ }
44
+ if (!orgId) {
45
+ const personal = (await personalPromise).data() ?? null;
46
+ return { brandKit: personal, teamOrgId: null };
47
+ }
48
+ const [personalSnap, memberSnap, teamSnap] = await Promise.all([
49
+ personalPromise,
50
+ firestore_service_1.FirestoreService.organizationMembersCol.doc((0, organization_model_1.organizationMemberDocId)(orgId, userId)).get(),
51
+ firestore_service_1.FirestoreService.organizationBrandKitsCol.doc(orgId).get(),
52
+ ]);
53
+ const personal = personalSnap.data() ?? null;
54
+ const team = memberSnap.exists ? (teamSnap.data() ?? null) : null;
55
+ return {
56
+ brandKit: mergeTeamBrandKit(userId, personal, team),
57
+ teamOrgId: team ? orgId : null,
58
+ };
59
+ }
@@ -8,6 +8,8 @@ import { ICommunitySeedModel } from "../models/communitySeed.model";
8
8
  import { IAssetPoolModel } from "../models/assetPool.model";
9
9
  import { IImageJobModel } from "../models/image.model";
10
10
  import { IUpscaleJobModel } from "../models/upscale.model";
11
+ import { IVideoToolJobModel } from "../models/videoTool.model";
12
+ import { IPosterExportJobModel } from "../models/posterExport.model";
11
13
  import { INotificationModel } from "../models/notification.model";
12
14
  import { IRefModel } from "../models/ref.model";
13
15
  import { IMediaUploadModel } from "../models/mediaUpload.model";
@@ -22,7 +24,7 @@ import { IGithubConnectionModel } from "../models/githubConnection.model";
22
24
  import { IProductConnectionModel } from "../models/productConnection.model";
23
25
  import { IOutreachCampaignModel, IOutreachRecipientModel, IOutreachTemplateModel, IPersonalizedVideoModel, IVideoViewModel } from "../models/outreach.model";
24
26
  import { IApiKeyModel, IWebhookSubscriptionModel } from "../models/outreachIntegration.model";
25
- import { IOrganizationCreditLedgerEntry, IOrganizationInviteModel, IOrganizationMemberModel, IOrganizationModel } from "../models/organization.model";
27
+ import { IOrganizationBrandKitModel, IOrganizationCreditLedgerEntry, IOrganizationInviteModel, IOrganizationMemberModel, IOrganizationModel } from "../models/organization.model";
26
28
  import { IPosterProjectModel } from "../models/posterProject.model";
27
29
  /**
28
30
  * FirestoreService
@@ -33,6 +35,7 @@ export declare class FirestoreService {
33
35
  static videoJobsCol: CollectionReference<IVideoJobModel, DocumentData>;
34
36
  static imageJobsCol: CollectionReference<IImageJobModel, DocumentData>;
35
37
  static upscaleJobsCol: CollectionReference<IUpscaleJobModel, DocumentData>;
38
+ static videoToolJobsCol: CollectionReference<IVideoToolJobModel, DocumentData>;
36
39
  static communitySeedCol: CollectionReference<ICommunitySeedModel, DocumentData>;
37
40
  static assetPoolCol: CollectionReference<IAssetPoolModel, DocumentData>;
38
41
  static notificationsCol: CollectionReference<INotificationModel, DocumentData>;
@@ -62,6 +65,7 @@ export declare class FirestoreService {
62
65
  static assetCacheRawCol: CollectionReference<ICachedRawAssetModel, DocumentData>;
63
66
  static brandKitsCol: CollectionReference<IBrandKitModel, DocumentData>;
64
67
  static posterProjectsCol: CollectionReference<IPosterProjectModel, DocumentData>;
68
+ static posterExportsCol: CollectionReference<IPosterExportJobModel, DocumentData>;
65
69
  static styleMemoryCol: CollectionReference<IStyleMemoryModel, DocumentData>;
66
70
  static agentProjectsCol: CollectionReference<IAgentProjectModel, DocumentData>;
67
71
  static agentRunsCol: CollectionReference<IAgentRunModel, DocumentData>;
@@ -98,6 +102,8 @@ export declare class FirestoreService {
98
102
  static webhookSubscriptionsCol: CollectionReference<IWebhookSubscriptionModel, DocumentData>;
99
103
  static organizationsCol: CollectionReference<IOrganizationModel, DocumentData>;
100
104
  static organizationMembersCol: CollectionReference<IOrganizationMemberModel, DocumentData>;
105
+ /** Shared team brand kit, doc id = orgId. */
106
+ static organizationBrandKitsCol: CollectionReference<IOrganizationBrandKitModel, DocumentData>;
101
107
  static organizationInvitesCol: CollectionReference<IOrganizationInviteModel, DocumentData>;
102
108
  static organizationCreditLedgerCol: CollectionReference<IOrganizationCreditLedgerEntry, DocumentData>;
103
109
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"firestore.service.d.ts","sourceRoot":"","sources":["../../src/services/firestore.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAEhB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,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AAE,EAAE,iBAAiB,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,CAAC,CAAC;CAGd"}
1
+ {"version":3,"file":"firestore.service.d.ts","sourceRoot":"","sources":["../../src/services/firestore.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAEhB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MA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AAC,EACrC,EAAE,EAAE,MAAM,EACV,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC,EAC9B,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAwB,GACrD,OAAO,CAAC,IAAI,CAAC;IAWhB,OAAO,CAAC,MAAM,CAAC,aAAa;IA2B5B,0CAA0C;WAC7B,cAAc,CACzB,EAAE,EAAE,MAAM,EACV,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAIhB,sBAAsB;WACT,UAAU,CAAC,CAAC,EACvB,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACrC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAKhB,kCAAkC;WACrB,cAAc,CAAC,CAAC,EAC3B,OAAO,EAAE,CAAC,EAAE,EAAE,iBAAiB,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACzD,OAAO,CAAC,CAAC,CAAC;CAGd"}
@@ -131,6 +131,9 @@ FirestoreService.imageJobsCol = firebase_1.firestore
131
131
  FirestoreService.upscaleJobsCol = firebase_1.firestore
132
132
  .collection("upscaleJobs")
133
133
  .withConverter(collectionConverter());
134
+ FirestoreService.videoToolJobsCol = firebase_1.firestore
135
+ .collection("videoToolJobs")
136
+ .withConverter(collectionConverter());
134
137
  FirestoreService.communitySeedCol = firebase_1.firestore
135
138
  .collection("communitySeed")
136
139
  .withConverter(collectionConverter());
@@ -161,6 +164,9 @@ FirestoreService.brandKitsCol = firebase_1.firestore
161
164
  FirestoreService.posterProjectsCol = firebase_1.firestore
162
165
  .collection("posterProjects")
163
166
  .withConverter(collectionConverter());
167
+ FirestoreService.posterExportsCol = firebase_1.firestore
168
+ .collection("posterExports")
169
+ .withConverter(collectionConverter());
164
170
  FirestoreService.styleMemoryCol = firebase_1.firestore
165
171
  .collection("styleMemory")
166
172
  .withConverter(collectionConverter());
@@ -248,6 +254,10 @@ FirestoreService.organizationsCol = firebase_1.firestore
248
254
  FirestoreService.organizationMembersCol = firebase_1.firestore
249
255
  .collection("organizationMembers")
250
256
  .withConverter(collectionConverter());
257
+ /** Shared team brand kit, doc id = orgId. */
258
+ FirestoreService.organizationBrandKitsCol = firebase_1.firestore
259
+ .collection("organizationBrandKits")
260
+ .withConverter(collectionConverter());
251
261
  FirestoreService.organizationInvitesCol = firebase_1.firestore
252
262
  .collection("organizationInvites")
253
263
  .withConverter(collectionConverter());
@@ -41,6 +41,7 @@ export * from "./freePlan";
41
41
  export * from "./trialGuard";
42
42
  export * from "./accountStatus";
43
43
  export * from "./organizationCredit.service";
44
+ export * from "./brandKit.service";
44
45
  export * from "./email";
45
46
  export * from "./assetPool";
46
47
  export * from "./klingElements/klingElementLibrary.service";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC;AACpD,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AAC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C;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,6CAA6C,CAAC"}
@@ -57,6 +57,7 @@ __exportStar(require("./freePlan"), exports);
57
57
  __exportStar(require("./trialGuard"), exports);
58
58
  __exportStar(require("./accountStatus"), exports);
59
59
  __exportStar(require("./organizationCredit.service"), exports);
60
+ __exportStar(require("./brandKit.service"), exports);
60
61
  __exportStar(require("./email"), exports);
61
62
  __exportStar(require("./assetPool"), exports);
62
63
  __exportStar(require("./klingElements/klingElementLibrary.service"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAiDvD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAkB,GAAG,MAAM,EAAE,CA8BjF;AA4ID;;;;;;GAMG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AA+ID;;;;;;;;;;;;;;GAcG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8ChE;AA8BD;;;;;;;;;;GAUG;AACH,iBAAe,iBAAiB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAC5C,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAejB;AAOD,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
1
+ {"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAiDvD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAkB,GAAG,MAAM,EAAE,CA8BjF;AAuJD;;;;;;GAMG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AA+ID;;;;;;;;;;;;;;GAcG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8ChE;AA8BD;;;;;;;;;;GAUG;AACH,iBAAe,iBAAiB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAC5C,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAejB;AAOD,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
@@ -209,10 +209,21 @@ async function withTimeout(promise, ms, label) {
209
209
  * api instance (concurrency 80) that alone could burn most of an 8s attempt —
210
210
  * prod logged both attempts "timed out after 8000ms" (kk→en) while OpenAI
211
211
  * itself answers the same prompt in ~2-4s. */
212
+ //
213
+ // 2026-10-23: wraps the call in the cross-provider runner (gpt-4o-mini →
214
+ // Gemini). An out-of-credits OpenAI org otherwise took translate / detect /
215
+ // pick down whenever the primary CF was also slow.
212
216
  async function loadFallbackService() {
213
- const { getAiGenProviderService } = await Promise.resolve().then(() => __importStar(require("../aiGen/aiGenFactory.service")));
214
- return getAiGenProviderService(FALLBACK_MODEL);
217
+ const { generateTextWithFallback } = await Promise.resolve().then(() => __importStar(require("../aiGen/textFallback")));
218
+ return { generateText: (params) => generateTextWithFallback(params, "translation") };
215
219
  }
220
+ // REMOVED FOR v1 — kept for reference: single-provider loader.
221
+ // async function loadFallbackService() {
222
+ // const { getAiGenProviderService } = await import(
223
+ // "../aiGen/aiGenFactory.service"
224
+ // );
225
+ // return getAiGenProviderService(FALLBACK_MODEL);
226
+ // }
216
227
  /** One un-retried LLM translate attempt. */
217
228
  async function callLlmTranslateOnce(text, from, to) {
218
229
  const service = await loadFallbackService();
@@ -29,6 +29,10 @@ export declare const USER_FACING_ERROR_CODES: {
29
29
  readonly PROMPT_TOO_LONG: "PROMPT_TOO_LONG";
30
30
  readonly PROMPT_INVALID: "PROMPT_INVALID";
31
31
  readonly INPUT_IMAGE_REJECTED: "INPUT_IMAGE_REJECTED";
32
+ /** Input clip unreadable / unsupported by a video tool. */
33
+ readonly INPUT_VIDEO_REJECTED: "INPUT_VIDEO_REJECTED";
34
+ /** Input clip longer than the tool's cap (VIDEO_BG_REMOVAL.maxDurationSec). */
35
+ readonly INPUT_VIDEO_TOO_LONG: "INPUT_VIDEO_TOO_LONG";
32
36
  readonly CONTENT_POLICY_VIOLATION: "CONTENT_POLICY_VIOLATION";
33
37
  /** Provider returned auth / config error (401, missing key) — deploy bug, fail fast. */
34
38
  readonly PROVIDER_AUTH_ERROR: "PROVIDER_AUTH_ERROR";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,iBAAiB,QAAQ;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAM1C,qEAAqE;IACrE,MAAM,IAAI;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAG7C;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;IAUlC,wFAAwF;;IAExF,qFAAqF;;IAErF,+FAA+F;;IAE/F,oGAAoG;;IAEpG,gGAAgG;;CAExF,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6B7D,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,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,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAaR"}
@@ -38,6 +38,10 @@ exports.USER_FACING_ERROR_CODES = {
38
38
  PROMPT_TOO_LONG: "PROMPT_TOO_LONG",
39
39
  PROMPT_INVALID: "PROMPT_INVALID",
40
40
  INPUT_IMAGE_REJECTED: "INPUT_IMAGE_REJECTED",
41
+ /** Input clip unreadable / unsupported by a video tool. */
42
+ INPUT_VIDEO_REJECTED: "INPUT_VIDEO_REJECTED",
43
+ /** Input clip longer than the tool's cap (VIDEO_BG_REMOVAL.maxDurationSec). */
44
+ INPUT_VIDEO_TOO_LONG: "INPUT_VIDEO_TOO_LONG",
41
45
  CONTENT_POLICY_VIOLATION: "CONTENT_POLICY_VIOLATION",
42
46
  /** Provider returned auth / config error (401, missing key) — deploy bug, fail fast. */
43
47
  PROVIDER_AUTH_ERROR: "PROVIDER_AUTH_ERROR",
@@ -70,6 +74,8 @@ exports.USER_FACING_ERROR_MESSAGES = {
70
74
  [exports.USER_FACING_ERROR_CODES.PROMPT_TOO_LONG]: "Your prompt is too long for this model. Please shorten it and try again.",
71
75
  [exports.USER_FACING_ERROR_CODES.PROMPT_INVALID]: "Your prompt was rejected by the model. Please simplify or rephrase it and try again.",
72
76
  [exports.USER_FACING_ERROR_CODES.INPUT_IMAGE_REJECTED]: "Your input image was rejected. Please try a different image.",
77
+ [exports.USER_FACING_ERROR_CODES.INPUT_VIDEO_REJECTED]: "This video couldn't be processed. Try an MP4, MOV or WebM up to 60 seconds. You haven't been charged.",
78
+ [exports.USER_FACING_ERROR_CODES.INPUT_VIDEO_TOO_LONG]: "This video is longer than 60 seconds. Trim it and try again. You haven't been charged.",
73
79
  [exports.USER_FACING_ERROR_CODES.CONTENT_POLICY_VIOLATION]: "Your prompt was flagged by the model's safety filters. Please rephrase and try again.",
74
80
  [exports.USER_FACING_ERROR_CODES.CAPABILITY_MISMATCH]: "This combination of settings isn't supported by the selected model. Please adjust your options and try again.",
75
81
  [exports.USER_FACING_ERROR_CODES.SCENES_NOT_READY]: "This video isn't fully generated yet — one or more scenes are still processing. Please wait for generation to finish and try rendering again.",
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,mBAAmB,GAAG,IASxB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,kBAAkB,GAAG,IASlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,MAAM,mBAAmB,EACzB,OAAM,kBAA+C,WAgBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,oBAAiB;AACjB;;;;;GAKG;AACH,QAAO,MAAgC,KACtC,MAYF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,MAAM,MAAM,GAAG,SAAS,EACxB,UAAU,MAAM,KACf,MASF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAInF,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,kBAAkB,GAAG,MAAM,CAEnF;AAOD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GACX,MAAM,6CAA6C,CAAC;AAErD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ,EACf,QAAQ,SAAM,oBAQf;AAGD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CA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,GAC1B,UAAU,MAAM,EAChB,MAAM,MAAM,GAAG,SAAS,EACxB,UAAU,MAAM,KACf,MASF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAInF,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,kBAAkB,GAAG,MAAM,CAEnF;AAOD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GACX,MAAM,6CAA6C,CAAC;AAErD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ,EACf,QAAQ,SAAM,oBAQf;AAGD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAGxB,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAgErB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
@@ -12,7 +12,7 @@ const logger_1 = require("./logger");
12
12
  const plans_1 = require("../globals/plans");
13
13
  const types_1 = require("../globals/types");
14
14
  const fs_extra_1 = __importDefault(require("fs-extra"));
15
- const services_1 = require("../services");
15
+ const textFallback_1 = require("../services/aiGen/textFallback");
16
16
  const globals_1 = require("../globals");
17
17
  const creditUnit_1 = require("../globals/creditUnit");
18
18
  const getPlanTypeById = (priceId) => {
@@ -133,7 +133,10 @@ async function waitForFile(path, timeout = 10000, interval = 300) {
133
133
  throw new Error(`Timeout waiting for file: ${path}`);
134
134
  }
135
135
  async function generateAndValidate({ userPrompt, systemPrompt, jsonSchema, zodSchema, modelKey = globals_1.ETextGenModels.OPENAI_GPT_4O_MINI, }) {
136
- const provider = (0, services_1.getAiGenProviderService)(globals_1.ETextGenModels.OPENAI_GPT_4O_MINI);
136
+ // REMOVED FOR v1 — kept for reference: always used the OpenAI provider
137
+ // regardless of modelKey, and had no fallback when the OpenAI account was
138
+ // out of credits (2026-10-23). generateTextWithFallback below fixes both.
139
+ // const provider = getAiGenProviderService(ETextGenModels.OPENAI_GPT_4O_MINI);
137
140
  const messages = [];
138
141
  if (systemPrompt)
139
142
  messages.push({ role: "system", content: systemPrompt });
@@ -141,11 +144,11 @@ async function generateAndValidate({ userPrompt, systemPrompt, jsonSchema, zodSc
141
144
  const responseFormat = jsonSchema
142
145
  ? { type: "json_schema", json_schema: jsonSchema }
143
146
  : undefined;
144
- const result = await provider.generateText({
147
+ const result = await (0, textFallback_1.generateTextWithFallback)({
145
148
  input: messages,
146
149
  modelKey: modelKey,
147
150
  options: responseFormat ? { responseFormat } : undefined,
148
- });
151
+ }, "generateAndValidate");
149
152
  const raw = result.text.trim();
150
153
  try {
151
154
  const parsed = JSON.parse(raw);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidspotai-shared",
3
- "version": "1.0.131",
3
+ "version": "1.0.133",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "exports": {