vidspotai-shared 1.0.136 → 1.0.138

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 (106) hide show
  1. package/lib/globals/aiModels/enums.d.ts +2 -0
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +7 -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/film/filmCatalog.d.ts +88 -0
  7. package/lib/globals/film/filmCatalog.d.ts.map +1 -0
  8. package/lib/globals/film/filmCatalog.js +218 -0
  9. package/lib/globals/index.d.ts +2 -0
  10. package/lib/globals/index.d.ts.map +1 -1
  11. package/lib/globals/index.js +2 -0
  12. package/lib/globals/reelRemake.d.ts +116 -0
  13. package/lib/globals/reelRemake.d.ts.map +1 -0
  14. package/lib/globals/reelRemake.js +142 -0
  15. package/lib/globals/types.d.ts +15 -1
  16. package/lib/globals/types.d.ts.map +1 -1
  17. package/lib/globals/types.js +16 -0
  18. package/lib/libs/storage/cdnUrl.d.ts +1 -3
  19. package/lib/libs/storage/cdnUrl.d.ts.map +1 -1
  20. package/lib/libs/storage/cdnUrl.js +8 -6
  21. package/lib/models/filmProject.model.d.ts +424 -0
  22. package/lib/models/filmProject.model.d.ts.map +1 -0
  23. package/lib/models/filmProject.model.js +14 -0
  24. package/lib/models/image.model.d.ts +3 -0
  25. package/lib/models/image.model.d.ts.map +1 -1
  26. package/lib/models/index.d.ts +2 -0
  27. package/lib/models/index.d.ts.map +1 -1
  28. package/lib/models/index.js +2 -0
  29. package/lib/models/reelRemake.model.d.ts +222 -0
  30. package/lib/models/reelRemake.model.d.ts.map +1 -0
  31. package/lib/models/reelRemake.model.js +2 -0
  32. package/lib/models/video.model.d.ts +5 -0
  33. package/lib/models/video.model.d.ts.map +1 -1
  34. package/lib/schemas/film.schema.d.ts +500 -0
  35. package/lib/schemas/film.schema.d.ts.map +1 -0
  36. package/lib/schemas/film.schema.js +201 -0
  37. package/lib/schemas/index.d.ts +1 -0
  38. package/lib/schemas/index.d.ts.map +1 -1
  39. package/lib/schemas/index.js +1 -0
  40. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  41. package/lib/services/agent/providerFallback/chains.js +13 -0
  42. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
  43. package/lib/services/agent/tools/generateVideo.tool.js +2 -1
  44. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  45. package/lib/services/aiGen/aiGenFactory.service.js +4 -0
  46. package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
  47. package/lib/services/aiGen/providers/bytedance/bytedance.service.js +17 -0
  48. package/lib/services/aiGen/providers/fal/index.d.ts +1 -0
  49. package/lib/services/aiGen/providers/fal/index.d.ts.map +1 -1
  50. package/lib/services/aiGen/providers/fal/index.js +1 -0
  51. package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -1
  52. package/lib/services/aiGen/providers/kling/klingRequests.js +3 -0
  53. package/lib/services/aiGen/providers/types.d.ts +6 -0
  54. package/lib/services/aiGen/providers/types.d.ts.map +1 -1
  55. package/lib/services/film/compileShotPrompt.d.ts +16 -0
  56. package/lib/services/film/compileShotPrompt.d.ts.map +1 -0
  57. package/lib/services/film/compileShotPrompt.js +152 -0
  58. package/lib/services/film/filmAssets.d.ts +73 -0
  59. package/lib/services/film/filmAssets.d.ts.map +1 -0
  60. package/lib/services/film/filmAssets.js +341 -0
  61. package/lib/services/film/filmCut.d.ts +159 -0
  62. package/lib/services/film/filmCut.d.ts.map +1 -0
  63. package/lib/services/film/filmCut.js +616 -0
  64. package/lib/services/film/filmPublic.d.ts +9 -0
  65. package/lib/services/film/filmPublic.d.ts.map +1 -0
  66. package/lib/services/film/filmPublic.js +39 -0
  67. package/lib/services/film/filmTakes.d.ts +65 -0
  68. package/lib/services/film/filmTakes.d.ts.map +1 -0
  69. package/lib/services/film/filmTakes.js +168 -0
  70. package/lib/services/film/writersRoom.d.ts +276 -0
  71. package/lib/services/film/writersRoom.d.ts.map +1 -0
  72. package/lib/services/film/writersRoom.js +431 -0
  73. package/lib/services/firestore.service.d.ts +7 -0
  74. package/lib/services/firestore.service.d.ts.map +1 -1
  75. package/lib/services/firestore.service.js +15 -0
  76. package/lib/services/index.d.ts +12 -0
  77. package/lib/services/index.d.ts.map +1 -1
  78. package/lib/services/index.js +12 -0
  79. package/lib/services/providerHealth.service.d.ts +12 -0
  80. package/lib/services/providerHealth.service.d.ts.map +1 -0
  81. package/lib/services/providerHealth.service.js +75 -0
  82. package/lib/services/reelRemake/castDetection.d.ts +56 -0
  83. package/lib/services/reelRemake/castDetection.d.ts.map +1 -0
  84. package/lib/services/reelRemake/castDetection.js +146 -0
  85. package/lib/services/reelRemake/castSuggestion.d.ts +43 -0
  86. package/lib/services/reelRemake/castSuggestion.d.ts.map +1 -0
  87. package/lib/services/reelRemake/castSuggestion.js +99 -0
  88. package/lib/services/reelRemake/keyframeSwap.d.ts +44 -0
  89. package/lib/services/reelRemake/keyframeSwap.d.ts.map +1 -0
  90. package/lib/services/reelRemake/keyframeSwap.js +139 -0
  91. package/lib/services/reelRemake/shootPlan.d.ts +65 -0
  92. package/lib/services/reelRemake/shootPlan.d.ts.map +1 -0
  93. package/lib/services/reelRemake/shootPlan.js +193 -0
  94. package/lib/services/reelRemake/stopWork.d.ts +54 -0
  95. package/lib/services/reelRemake/stopWork.d.ts.map +1 -0
  96. package/lib/services/reelRemake/stopWork.js +91 -0
  97. package/lib/services/translation/translation.service.d.ts +10 -1
  98. package/lib/services/translation/translation.service.d.ts.map +1 -1
  99. package/lib/services/translation/translation.service.js +34 -1
  100. package/lib/utils/errors.d.ts +3 -0
  101. package/lib/utils/errors.d.ts.map +1 -1
  102. package/lib/utils/errors.js +6 -0
  103. package/lib/utils/helpers.d.ts +1 -1
  104. package/lib/utils/helpers.d.ts.map +1 -1
  105. package/lib/utils/helpers.js +2 -1
  106. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Reel Remake — shoot (Stage 4). Pure routing, pricing and request building
3
+ * for the per-shot generations; the worker runs them, Functions charges from
4
+ * the plan. Routing follows the spike (notes/REEL_REMAKE_PLAN.md §3a):
5
+ * - replace-in-place, shot ≤ editMaxSec → Kling 3.0 Omni edit (base_video =
6
+ * the real clip, so scene + motion are kept by construction)
7
+ * - longer shots, and new-world mode → Kling Motion Control (swapped
8
+ * keyframe + the clip's motion, 3–30s)
9
+ * - fallback once on refusal/failure → Hailuo H3 (reference video + image)
10
+ * Seedance is never used: it refuses real-person references.
11
+ */
12
+ import { REEL_REMAKE } from "../../globals/reelRemake";
13
+ import type { IReelRemakeModel, ReelRemakePerson, ReelRemakeShot } from "../../models/reelRemake.model";
14
+ import type { VideoGenerationParams } from "../aiGen/providers/types";
15
+ export type ReelShootEngine = typeof REEL_REMAKE.shootEditModel | typeof REEL_REMAKE.shootMotionModel | typeof REEL_REMAKE.shootFallbackModel;
16
+ export interface PlannedTake {
17
+ shotId: string;
18
+ engine: ReelShootEngine;
19
+ billedSec: number;
20
+ credits: number;
21
+ keyframeUrl: string;
22
+ }
23
+ /** Whole seconds an engine is asked for: the shot, rounded up, clamped to the engine's range. */
24
+ export declare function billedSecFor(engine: ReelShootEngine, sec: number): number;
25
+ export declare function primaryEngineFor(mode: IReelRemakeModel["mode"], shot: Pick<ReelRemakeShot, "startSec" | "endSec">): ReelShootEngine;
26
+ /** Provider $/s for an engine, from the model configs (720p / std / 768P — what we submit). */
27
+ export declare function shootUsdPerSec(engine: ReelShootEngine): number;
28
+ /** Credits one take costs. No per-op floor: a remake is many short takes billed as one order. */
29
+ export declare function reelTakeCredits(engine: ReelShootEngine, billedSec: number): number;
30
+ /**
31
+ * Shots that get generated: those with a finished swapped keyframe. Every
32
+ * other shot keeps its original footage in the cut.
33
+ */
34
+ export declare function planShoot(remake: Pick<IReelRemakeModel, "mode" | "shots">): PlannedTake[];
35
+ export declare function quoteShoot(remake: Pick<IReelRemakeModel, "mode" | "shots">): {
36
+ totalCredits: number;
37
+ takes: PlannedTake[];
38
+ };
39
+ /**
40
+ * The engine a failed take is retried on once, or null. Replace shots swap
41
+ * between `replaceEngineOrder`; motion control falls back to MiniMax. Both
42
+ * MiniMax and the Omni edit cap at 15s, so longer shots have no fallback.
43
+ */
44
+ export declare function fallbackEngineFor(engine: ReelShootEngine, shot: Pick<ReelRemakeShot, "startSec" | "endSec">): ReelShootEngine | null;
45
+ /** True when a failed take on `engine` gets one retry on another engine. */
46
+ export declare function canFallBack(engine: ReelShootEngine, shot: Pick<ReelRemakeShot, "startSec" | "endSec">): boolean;
47
+ /**
48
+ * Provider params for one take. `clipUrl` is the shot cut out of the source
49
+ * (padded to `billedSec`, upscaled, silent); `keyframeUrl` the swapped
50
+ * keyframe the user approved.
51
+ */
52
+ export declare function buildReelTakeRequest(args: {
53
+ engine: ReelShootEngine;
54
+ shot: Pick<ReelRemakeShot, "people">;
55
+ cast: ReelRemakePerson[];
56
+ mode: IReelRemakeModel["mode"];
57
+ theme?: string;
58
+ clipUrl: string;
59
+ keyframeUrl: string;
60
+ billedSec: number;
61
+ aspectRatio: string;
62
+ }): VideoGenerationParams;
63
+ /** Nearest aspect ratio an engine accepts for a w×h source. */
64
+ export declare function shootAspectRatio(engine: ReelShootEngine, width: number, height: number): string;
65
+ //# sourceMappingURL=shootPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shootPlan.d.ts","sourceRoot":"","sources":["../../../src/services/reelRemake/shootPlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAItE,MAAM,MAAM,eAAe,GACvB,OAAO,WAAW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AE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,QAAQ,CAAC,GAAG,OAAO,CAE/G;AAiBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACrC,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,qBAAqB,CAiExB;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAe/F"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * Reel Remake — shoot (Stage 4). Pure routing, pricing and request building
4
+ * for the per-shot generations; the worker runs them, Functions charges from
5
+ * the plan. Routing follows the spike (notes/REEL_REMAKE_PLAN.md §3a):
6
+ * - replace-in-place, shot ≤ editMaxSec → Kling 3.0 Omni edit (base_video =
7
+ * the real clip, so scene + motion are kept by construction)
8
+ * - longer shots, and new-world mode → Kling Motion Control (swapped
9
+ * keyframe + the clip's motion, 3–30s)
10
+ * - fallback once on refusal/failure → Hailuo H3 (reference video + image)
11
+ * Seedance is never used: it refuses real-person references.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.billedSecFor = billedSecFor;
15
+ exports.primaryEngineFor = primaryEngineFor;
16
+ exports.shootUsdPerSec = shootUsdPerSec;
17
+ exports.reelTakeCredits = reelTakeCredits;
18
+ exports.planShoot = planShoot;
19
+ exports.quoteShoot = quoteShoot;
20
+ exports.fallbackEngineFor = fallbackEngineFor;
21
+ exports.canFallBack = canFallBack;
22
+ exports.buildReelTakeRequest = buildReelTakeRequest;
23
+ exports.shootAspectRatio = shootAspectRatio;
24
+ const aiModels_1 = require("../../globals/aiModels");
25
+ const reelRemake_1 = require("../../globals/reelRemake");
26
+ const helpers_1 = require("../../utils/helpers");
27
+ const types_1 = require("../aiGen/types");
28
+ const keyframeSwap_1 = require("./keyframeSwap");
29
+ const shotSec = (shot) => shot.endSec - shot.startSec;
30
+ /** Whole seconds an engine is asked for: the shot, rounded up, clamped to the engine's range. */
31
+ function billedSecFor(engine, sec) {
32
+ const whole = Math.ceil(sec - 1e-3);
33
+ if (engine === reelRemake_1.REEL_REMAKE.shootEditModel) {
34
+ return Math.min(Math.max(whole, reelRemake_1.REEL_REMAKE.minClipSec), reelRemake_1.REEL_REMAKE.editMaxSec);
35
+ }
36
+ if (engine === reelRemake_1.REEL_REMAKE.shootFallbackModel) {
37
+ return Math.min(Math.max(whole, reelRemake_1.REEL_REMAKE.fallbackMinSec), reelRemake_1.REEL_REMAKE.fallbackMaxSec);
38
+ }
39
+ return Math.max(whole, reelRemake_1.REEL_REMAKE.minClipSec);
40
+ }
41
+ function primaryEngineFor(mode, shot) {
42
+ if (mode === "new-world")
43
+ return reelRemake_1.REEL_REMAKE.shootMotionModel;
44
+ return shotSec(shot) <= reelRemake_1.REEL_REMAKE.editMaxSec + 0.5 ? reelRemake_1.REEL_REMAKE.replaceEngineOrder[0] : reelRemake_1.REEL_REMAKE.shootMotionModel;
45
+ }
46
+ /** Provider $/s for an engine, from the model configs (720p / std / 768P — what we submit). */
47
+ function shootUsdPerSec(engine) {
48
+ const cost = aiModels_1.aiModelConfigs[engine]?.cost;
49
+ if (engine === reelRemake_1.REEL_REMAKE.shootEditModel)
50
+ return cost?.videoInputPerSecondByResolution?.["720p"] ?? 0.126;
51
+ if (engine === reelRemake_1.REEL_REMAKE.shootMotionModel) {
52
+ const five = cost?.table?.std?.[5];
53
+ return typeof five === "number" ? five / 5 : 0.126;
54
+ }
55
+ // H3 bills the reference video's input seconds on top of the output.
56
+ return (cost?.perSecondByResolution?.["768P"] ?? 0.08) + (cost?.inputVideoPerSecond?.["768P"] ?? 0.08);
57
+ }
58
+ /** Credits one take costs. No per-op floor: a remake is many short takes billed as one order. */
59
+ function reelTakeCredits(engine, billedSec) {
60
+ return (0, helpers_1.getCreditsFromCost)(shootUsdPerSec(engine) * billedSec, false);
61
+ }
62
+ /**
63
+ * Shots that get generated: those with a finished swapped keyframe. Every
64
+ * other shot keeps its original footage in the cut.
65
+ */
66
+ function planShoot(remake) {
67
+ return remake.shots.flatMap((shot) => {
68
+ if (shot.swap?.status !== "done" || !shot.swap.url)
69
+ return [];
70
+ const engine = primaryEngineFor(remake.mode, shot);
71
+ const billedSec = billedSecFor(engine, shotSec(shot));
72
+ return [{ shotId: shot.id, engine, billedSec, credits: reelTakeCredits(engine, billedSec), keyframeUrl: shot.swap.url }];
73
+ });
74
+ }
75
+ function quoteShoot(remake) {
76
+ const takes = planShoot(remake);
77
+ return { totalCredits: takes.reduce((n, t) => n + t.credits, 0), takes };
78
+ }
79
+ /**
80
+ * The engine a failed take is retried on once, or null. Replace shots swap
81
+ * between `replaceEngineOrder`; motion control falls back to MiniMax. Both
82
+ * MiniMax and the Omni edit cap at 15s, so longer shots have no fallback.
83
+ */
84
+ function fallbackEngineFor(engine, shot) {
85
+ if (shotSec(shot) > Math.min(reelRemake_1.REEL_REMAKE.fallbackMaxSec, reelRemake_1.REEL_REMAKE.editMaxSec) + 0.5)
86
+ return null;
87
+ const [first, second] = reelRemake_1.REEL_REMAKE.replaceEngineOrder;
88
+ if (engine === first)
89
+ return second;
90
+ if (engine === reelRemake_1.REEL_REMAKE.shootMotionModel)
91
+ return reelRemake_1.REEL_REMAKE.shootFallbackModel;
92
+ return null;
93
+ }
94
+ /** True when a failed take on `engine` gets one retry on another engine. */
95
+ function canFallBack(engine, shot) {
96
+ return fallbackEngineFor(engine, shot) !== null;
97
+ }
98
+ const PROMINENCE_ORDER = { primary: 0, secondary: 1, background: 2 };
99
+ /** Mapped people in a shot, most prominent first. */
100
+ function castInShot(shot, cast) {
101
+ const byId = new Map(cast.map((p) => [p.id, p]));
102
+ return [...shot.people]
103
+ .sort((a, b) => PROMINENCE_ORDER[a.prominence] - PROMINENCE_ORDER[b.prominence])
104
+ .flatMap((sp) => {
105
+ const person = byId.get(sp.personId);
106
+ return person?.character ? [{ sp, person, character: person.character }] : [];
107
+ });
108
+ }
109
+ const describe = (c) => `${c.name}${c.prompt ? ` (${c.prompt})` : ""}`;
110
+ /**
111
+ * Provider params for one take. `clipUrl` is the shot cut out of the source
112
+ * (padded to `billedSec`, upscaled, silent); `keyframeUrl` the swapped
113
+ * keyframe the user approved.
114
+ */
115
+ function buildReelTakeRequest(args) {
116
+ const people = castInShot(args.shot, args.cast);
117
+ const keep = "Keep the camera movement, framing, timing, body motion, gestures, mouth movement and expressions unchanged.";
118
+ const scene = args.mode === "new-world"
119
+ ? `The setting is the one in the image${args.theme ? `, fitting "${args.theme}"` : ""}.`
120
+ : "The background, lighting, other people and objects stay exactly as they are.";
121
+ const faces = "Faces stay clearly visible — no helmet, mask or visor unless the description asks for one.";
122
+ if (args.engine === reelRemake_1.REEL_REMAKE.shootEditModel) {
123
+ // @image_1 = the approved swapped keyframe (whole cast in place); one
124
+ // identity ref per character after it, inside Kling's 4-image budget.
125
+ const refs = [args.keyframeUrl];
126
+ const lines = people.map(({ sp, person, character }) => {
127
+ const ref = (0, keyframeSwap_1.characterRefs)(character)[0];
128
+ let look = "";
129
+ if (ref && refs.length < reelRemake_1.REEL_REMAKE.maxShootRefImages && ref !== args.keyframeUrl) {
130
+ refs.push(ref);
131
+ look = ` and @image_${refs.length}`;
132
+ }
133
+ return `the ${person.description} ${(0, keyframeSwap_1.horizontalPosition)(sp.box)} becomes ${describe(character)}, looking exactly as in @image_1${look}`;
134
+ });
135
+ return {
136
+ modelKey: args.engine,
137
+ type: "video-to-video",
138
+ prompt: [`Edit @video_1: ${lines.join("; ")}.`, keep, scene, faces].join(" "),
139
+ inputVideoUrl: args.clipUrl,
140
+ referenceImageUrls: refs,
141
+ duration: args.billedSec,
142
+ resolution: "720p",
143
+ mode: types_1.EVideoMode.STANDARD,
144
+ aspectRatio: args.aspectRatio,
145
+ audio: false,
146
+ };
147
+ }
148
+ const who = people.map(({ character }) => describe(character)).join(" and ");
149
+ if (args.engine === reelRemake_1.REEL_REMAKE.shootMotionModel) {
150
+ return {
151
+ modelKey: args.engine,
152
+ endpoint: "motion-control",
153
+ characterOrientation: "video",
154
+ mode: types_1.EVideoMode.STANDARD,
155
+ prompt: `${who}, exactly as in the image. ${scene} ${faces}`,
156
+ inputImageUrl: args.keyframeUrl,
157
+ inputVideoUrl: args.clipUrl,
158
+ };
159
+ }
160
+ return {
161
+ modelKey: args.engine,
162
+ prompt: [
163
+ "Recreate the reference video exactly: same camera movement, framing, timing, background and lighting.",
164
+ `The ${people.length > 1 ? "people are" : "person is"} now ${who}, looking exactly like the reference image.`,
165
+ keep,
166
+ scene,
167
+ faces,
168
+ ].join(" "),
169
+ referenceVideoUrls: [args.clipUrl],
170
+ referenceImageUrls: [args.keyframeUrl],
171
+ duration: args.billedSec,
172
+ resolution: "768P",
173
+ aspectRatio: args.aspectRatio,
174
+ };
175
+ }
176
+ /** Nearest aspect ratio an engine accepts for a w×h source. */
177
+ function shootAspectRatio(engine, width, height) {
178
+ const allowed = (aiModels_1.aiModelConfigs[engine]?.fields.aspectRatio?.allowedValues ?? ["9:16", "16:9", "1:1"]);
179
+ const target = Math.log(width / height);
180
+ let best = allowed[0];
181
+ let bestDiff = Infinity;
182
+ for (const a of allowed) {
183
+ const [w, h] = a.split(":").map(Number);
184
+ if (!w || !h)
185
+ continue;
186
+ const diff = Math.abs(Math.log(w / h) - target);
187
+ if (diff < bestDiff) {
188
+ best = a;
189
+ bestDiff = diff;
190
+ }
191
+ }
192
+ return best;
193
+ }
@@ -0,0 +1,54 @@
1
+ import type { IReelRemakeModel, ReelRemakePerson, ReelRemakeShot, ReelRemakeStatus } from "../../models/reelRemake.model";
2
+ /**
3
+ * Stopping a Reel Remake's in-flight work — shared by the user's cancel
4
+ * (Functions) and the stuck-job reaper (worker), so both settle identically.
5
+ *
6
+ * Every pending portrait / keyframe swap / take is marked `failed` with
7
+ * `error` and its held credits are returned in the totals for the caller to
8
+ * refund (inside the same transaction that writes `shots` / `cast`, so a
9
+ * second stop finds nothing pending and refunds nothing). The worker's own
10
+ * writes only apply to a pending item while the remake is in the matching
11
+ * status, so a stopped item stays stopped.
12
+ */
13
+ /**
14
+ * Where a refund for `item` goes. Each billable item records the org it was
15
+ * charged to, so refunds stay correct when the user switches orgs between
16
+ * actions on one remake. Legacy items (no `chargedOrgId`) fall back to the
17
+ * remake-level `spentFromOrgId`, which only tracks the latest charge.
18
+ */
19
+ export declare function refundOrgFor(item: {
20
+ chargedOrgId?: string | null;
21
+ }, remake: Pick<IReelRemakeModel, "spentFromOrgId">): string | undefined;
22
+ export type ReelRefundTally = "previewCredits" | "shootCredits";
23
+ /** One refund to issue: `credits` back to `orgId` (undefined = the user's own balance). */
24
+ export interface ReelRefund {
25
+ orgId: string | undefined;
26
+ tally: ReelRefundTally;
27
+ credits: number;
28
+ }
29
+ export interface StoppedReelWork {
30
+ shots: ReelRemakeShot[];
31
+ cast: ReelRemakePerson[];
32
+ /** Credits to refund against `previewCredits`. */
33
+ previewRefund: number;
34
+ /** Credits to refund against `shootCredits`. */
35
+ shootRefund: number;
36
+ /** The same credits grouped by destination org + tally — what to actually refund. */
37
+ refunds: ReelRefund[];
38
+ /** Items stopped (0 = nothing was pending). */
39
+ stopped: number;
40
+ }
41
+ export declare function stopPendingReelWork(r: Pick<IReelRemakeModel, "shots" | "cast" | "spentFromOrgId">, error: string, nowIso: string): StoppedReelWork;
42
+ /**
43
+ * Where a remake lands once its current step is stopped:
44
+ * - analyzing → `cancelled` (nothing to keep)
45
+ * - keyframing → `previewing` if any frame came out, else back to `casting`
46
+ * - shooting → `assembling` if any shot has a clip (an earlier version's
47
+ * counts — a reshoot keeps the previous clip) when `assembleIfAny`,
48
+ * otherwise `completed` if a remake was already delivered, else `previewing`
49
+ * Returns null for a status with nothing to stop.
50
+ */
51
+ export declare function statusAfterStop(r: Pick<IReelRemakeModel, "status" | "shots" | "outputVideoUrl">, stoppedShots: ReelRemakeShot[], opts: {
52
+ assembleIfAny: boolean;
53
+ }): ReelRemakeStatus | null;
54
+ //# sourceMappingURL=stopWork.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopWork.d.ts","sourceRoot":"","sources":["../../../src/services/reelRemake/stopWork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC;;;;;;;;;;GAUG;AACH;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACtC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,GAC/C,MAAM,GAAG,SAAS,CAGpB;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAEhE,2FAA2F;AAC3F,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,wBAAgB,mBAAmB,CACjC,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,gBAAgB,CAAC,EAC9D,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,eAAe,CAwCjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,OAAO,GAAG,gBAAgB,CAAC,EAChE,YAAY,EAAE,cAAc,EAAE,EAC9B,IAAI,EAAE;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,GAC/B,gBAAgB,GAAG,IAAI,CAYzB"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refundOrgFor = refundOrgFor;
4
+ exports.stopPendingReelWork = stopPendingReelWork;
5
+ exports.statusAfterStop = statusAfterStop;
6
+ /**
7
+ * Stopping a Reel Remake's in-flight work — shared by the user's cancel
8
+ * (Functions) and the stuck-job reaper (worker), so both settle identically.
9
+ *
10
+ * Every pending portrait / keyframe swap / take is marked `failed` with
11
+ * `error` and its held credits are returned in the totals for the caller to
12
+ * refund (inside the same transaction that writes `shots` / `cast`, so a
13
+ * second stop finds nothing pending and refunds nothing). The worker's own
14
+ * writes only apply to a pending item while the remake is in the matching
15
+ * status, so a stopped item stays stopped.
16
+ */
17
+ /**
18
+ * Where a refund for `item` goes. Each billable item records the org it was
19
+ * charged to, so refunds stay correct when the user switches orgs between
20
+ * actions on one remake. Legacy items (no `chargedOrgId`) fall back to the
21
+ * remake-level `spentFromOrgId`, which only tracks the latest charge.
22
+ */
23
+ function refundOrgFor(item, remake) {
24
+ if (item.chargedOrgId === undefined)
25
+ return remake.spentFromOrgId;
26
+ return item.chargedOrgId ?? undefined;
27
+ }
28
+ const isPending = (s) => s?.status === "queued" || s?.status === "running";
29
+ function stopPendingReelWork(r, error, nowIso) {
30
+ let previewRefund = 0;
31
+ let shootRefund = 0;
32
+ let stopped = 0;
33
+ const byOrg = new Map();
34
+ const owe = (item, tally) => {
35
+ if (item.credits <= 0)
36
+ return;
37
+ const orgId = refundOrgFor(item, r);
38
+ const key = `${tally}:${orgId ?? ""}`;
39
+ const prev = byOrg.get(key);
40
+ byOrg.set(key, { orgId, tally, credits: (prev?.credits ?? 0) + item.credits });
41
+ };
42
+ const cast = r.cast.map((p) => {
43
+ const anchor = p.character?.anchor;
44
+ if (!p.character || !anchor || !isPending(anchor))
45
+ return p;
46
+ previewRefund += anchor.credits;
47
+ owe(anchor, "previewCredits");
48
+ stopped++;
49
+ return { ...p, character: { ...p.character, anchor: { ...anchor, status: "failed", error, updatedAt: nowIso } } };
50
+ });
51
+ const shots = r.shots.map((s) => {
52
+ let next = s;
53
+ if (s.swap && isPending(s.swap)) {
54
+ previewRefund += s.swap.credits;
55
+ owe(s.swap, "previewCredits");
56
+ stopped++;
57
+ next = { ...next, swap: { ...s.swap, status: "failed", error, updatedAt: nowIso } };
58
+ }
59
+ if (s.take && isPending(s.take)) {
60
+ shootRefund += s.take.credits;
61
+ owe(s.take, "shootCredits");
62
+ stopped++;
63
+ next = { ...next, take: { ...s.take, status: "failed", error, updatedAt: nowIso } };
64
+ }
65
+ return next;
66
+ });
67
+ return { shots, cast, previewRefund, shootRefund, refunds: [...byOrg.values()], stopped };
68
+ }
69
+ /**
70
+ * Where a remake lands once its current step is stopped:
71
+ * - analyzing → `cancelled` (nothing to keep)
72
+ * - keyframing → `previewing` if any frame came out, else back to `casting`
73
+ * - shooting → `assembling` if any shot has a clip (an earlier version's
74
+ * counts — a reshoot keeps the previous clip) when `assembleIfAny`,
75
+ * otherwise `completed` if a remake was already delivered, else `previewing`
76
+ * Returns null for a status with nothing to stop.
77
+ */
78
+ function statusAfterStop(r, stoppedShots, opts) {
79
+ switch (r.status) {
80
+ case "analyzing":
81
+ return "cancelled";
82
+ case "keyframing":
83
+ return stoppedShots.some((s) => s.swap?.status === "done") ? "previewing" : "casting";
84
+ case "shooting":
85
+ if (opts.assembleIfAny && stoppedShots.some((s) => !!s.take?.url))
86
+ return "assembling";
87
+ return r.outputVideoUrl ? "completed" : "previewing";
88
+ default:
89
+ return null;
90
+ }
91
+ }
@@ -72,14 +72,23 @@ declare function pickCloseLanguage(text: string, candidates: {
72
72
  code: string;
73
73
  name: string;
74
74
  }[], hint?: string): Promise<string>;
75
+ export declare const REQUEST_PATH_TRANSLATION_DEADLINE_MS = 15000;
76
+ /**
77
+ * `translate` with an overall deadline. On expiry throws
78
+ * Error(TRANSLATION_FAILED) — the same contract as both layers failing — so
79
+ * existing best-effort catch blocks fall back to the original text. The
80
+ * abandoned translation keeps running to completion in the background.
81
+ */
82
+ declare function translateWithinDeadline(text: string, from: ELANGUAGE_CODE, to?: ELANGUAGE_CODE, deadlineMs?: number): Promise<string>;
75
83
  export declare const translationService: {
76
84
  translate: typeof translate;
85
+ translateWithinDeadline: typeof translateWithinDeadline;
77
86
  detectLanguage: typeof detectLanguage;
78
87
  pickCloseLanguage: typeof pickCloseLanguage;
79
88
  };
80
89
  /** @deprecated use `translationService.translate` */
81
90
  export declare const getTranslationWrapper: typeof translate;
91
+ export { translateWithinDeadline };
82
92
  /** @deprecated use `translationService.detectLanguage` */
83
93
  export declare const detectLang: typeof detectLanguage;
84
- export {};
85
94
  //# sourceMappingURL=translation.service.d.ts.map
@@ -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;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"}
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;AAYD,eAAO,MAAM,oCAAoC,QAAS,CAAC;AAE3D;;;;;GAKG;AACH,iBAAe,uBAAuB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,UAAU,GAAE,MAA6C,GACxD,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,CAAC;AACnC,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
@@ -36,8 +36,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.detectLang = exports.getTranslationWrapper = exports.translationService = exports.TRANSLATION_FAILED = void 0;
39
+ exports.detectLang = exports.getTranslationWrapper = exports.translationService = exports.REQUEST_PATH_TRANSLATION_DEADLINE_MS = exports.TRANSLATION_FAILED = void 0;
40
40
  exports.splitForTranslation = splitForTranslation;
41
+ exports.translateWithinDeadline = translateWithinDeadline;
41
42
  const axios_1 = __importDefault(require("axios"));
42
43
  const enums_1 = require("../../globals/aiModels/enums");
43
44
  const types_1 = require("../../globals/types");
@@ -524,8 +525,40 @@ function errMsg(err) {
524
525
  return err.stack ?? err.message;
525
526
  return String(err);
526
527
  }
528
+ // 2026-11-02: hedging bounds each chunk, but a long prompt is many chunks
529
+ // run CHUNK_CONCURRENCY at a time, so a uniformly slow primary still stacked
530
+ // into 37-41s on the generate path (prod `ru` / `vi`, ~10 chunks hedged in
531
+ // waves). Callers on a user-facing request path translate best-effort anyway
532
+ // (they keep the original prompt on TRANSLATION_FAILED), so cap the whole call.
533
+ exports.REQUEST_PATH_TRANSLATION_DEADLINE_MS = 15000;
534
+ /**
535
+ * `translate` with an overall deadline. On expiry throws
536
+ * Error(TRANSLATION_FAILED) — the same contract as both layers failing — so
537
+ * existing best-effort catch blocks fall back to the original text. The
538
+ * abandoned translation keeps running to completion in the background.
539
+ */
540
+ async function translateWithinDeadline(text, from, to = types_1.ELANGUAGE_CODE.en, deadlineMs = exports.REQUEST_PATH_TRANSLATION_DEADLINE_MS) {
541
+ try {
542
+ return await withTimeout(translate(text, from, to), deadlineMs, "translation deadline");
543
+ }
544
+ catch (err) {
545
+ if (err instanceof Error && err.message === exports.TRANSLATION_FAILED)
546
+ throw err;
547
+ logger_1.logger.warn("translation: request-path deadline hit — caller keeps the original text", {
548
+ sourceLang: from,
549
+ targetLang: to,
550
+ deadlineMs,
551
+ chars: text.length,
552
+ err: errMsg(err),
553
+ });
554
+ const e = new Error(exports.TRANSLATION_FAILED);
555
+ e.cause = err;
556
+ throw e;
557
+ }
558
+ }
527
559
  exports.translationService = {
528
560
  translate,
561
+ translateWithinDeadline,
529
562
  detectLanguage,
530
563
  pickCloseLanguage,
531
564
  };
@@ -61,6 +61,9 @@ export declare const USER_FACING_ERROR_MESSAGES: Record<string, string>;
61
61
  * codes. Duck-typed on `isUserFacingError` so it survives errors crossing a
62
62
  * package-copy boundary (functions' npm shared vs the worker's workspace one).
63
63
  */
64
+ /** True for a UserFacingError code an operator must act on (see
65
+ * OPERATOR_ACTION_CODES) — e.g. to trip the provider-depletion breaker. */
66
+ export declare function isOperatorActionCode(code: string | undefined): boolean;
64
67
  export declare function isQuietUserFacingError(err: unknown): boolean;
65
68
  /** Friendly default for a code, or undefined if the code is unknown/unset. */
66
69
  export declare function friendlyMessageForCode(code: string | undefined): string | undefined;
@@ -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;;;;;;;;;IASlC,2DAA2D;;IAE3D,+EAA+E;;;IAG/E,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,CAiC7D,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAK5D;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEnF;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAaR"}
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;;;;;;;;;IASlC,2DAA2D;;IAE3D,+EAA+E;;;IAG/E,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,CAiC7D,CAAC;AAWF;;;;;GAKG;AACH;4EAC4E;AAC5E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEtE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAK5D;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEnF;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAaR"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USER_FACING_ERROR_MESSAGES = exports.USER_FACING_ERROR_CODES = exports.UserFacingError = void 0;
4
+ exports.isOperatorActionCode = isOperatorActionCode;
4
5
  exports.isQuietUserFacingError = isQuietUserFacingError;
5
6
  exports.friendlyMessageForCode = friendlyMessageForCode;
6
7
  exports.sanitizeUserFacingMessage = sanitizeUserFacingMessage;
@@ -94,6 +95,11 @@ const OPERATOR_ACTION_CODES = new Set([
94
95
  * codes. Duck-typed on `isUserFacingError` so it survives errors crossing a
95
96
  * package-copy boundary (functions' npm shared vs the worker's workspace one).
96
97
  */
98
+ /** True for a UserFacingError code an operator must act on (see
99
+ * OPERATOR_ACTION_CODES) — e.g. to trip the provider-depletion breaker. */
100
+ function isOperatorActionCode(code) {
101
+ return typeof code === "string" && OPERATOR_ACTION_CODES.has(code);
102
+ }
97
103
  function isQuietUserFacingError(err) {
98
104
  if (!err || typeof err !== "object")
99
105
  return false;
@@ -39,7 +39,7 @@ export declare const assertCostFound: (modelKey: string, cost: number | undefine
39
39
  */
40
40
  export declare const MULTI_CLIP_DISCOUNT_FACTORS: Partial<Record<EVideoDurationType, number>>;
41
41
  export declare function getMultiClipDiscountFactor(durationType: EVideoDurationType): number;
42
- export { TRANSLATION_FAILED, getTranslationWrapper, detectLang, } from "../services/translation/translation.service";
42
+ export { TRANSLATION_FAILED, getTranslationWrapper, translateWithinDeadline, detectLang, } from "../services/translation/translation.service";
43
43
  export declare function waitForFile(path: string, timeout?: number, interval?: number): Promise<boolean>;
44
44
  export declare function generateAndValidate<T extends z.ZodSchema<any>>(args: {
45
45
  userPrompt: string;
@@ -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;AAGpB,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,GAC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,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"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.detectLang = exports.getTranslationWrapper = exports.TRANSLATION_FAILED = exports.MULTI_CLIP_DISCOUNT_FACTORS = exports.assertCostFound = exports.getCreditsFromCost = exports.getPriceIdByType = exports.getFreqById = exports.getPlanTypeById = void 0;
6
+ exports.detectLang = exports.translateWithinDeadline = exports.getTranslationWrapper = exports.TRANSLATION_FAILED = exports.MULTI_CLIP_DISCOUNT_FACTORS = exports.assertCostFound = exports.getCreditsFromCost = exports.getPriceIdByType = exports.getFreqById = exports.getPlanTypeById = void 0;
7
7
  exports.getMultiClipDiscountFactor = getMultiClipDiscountFactor;
8
8
  exports.waitForFile = waitForFile;
9
9
  exports.generateAndValidate = generateAndValidate;
@@ -122,6 +122,7 @@ function getMultiClipDiscountFactor(durationType) {
122
122
  var translation_service_1 = require("../services/translation/translation.service");
123
123
  Object.defineProperty(exports, "TRANSLATION_FAILED", { enumerable: true, get: function () { return translation_service_1.TRANSLATION_FAILED; } });
124
124
  Object.defineProperty(exports, "getTranslationWrapper", { enumerable: true, get: function () { return translation_service_1.getTranslationWrapper; } });
125
+ Object.defineProperty(exports, "translateWithinDeadline", { enumerable: true, get: function () { return translation_service_1.translateWithinDeadline; } });
125
126
  Object.defineProperty(exports, "detectLang", { enumerable: true, get: function () { return translation_service_1.detectLang; } });
126
127
  async function waitForFile(path, timeout = 10000, interval = 300) {
127
128
  const start = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidspotai-shared",
3
- "version": "1.0.136",
3
+ "version": "1.0.138",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "exports": {