vidspotai-shared 1.0.86 → 1.0.88

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 (82) hide show
  1. package/lib/globals/creditUnit.d.ts +17 -0
  2. package/lib/globals/creditUnit.d.ts.map +1 -1
  3. package/lib/globals/creditUnit.js +18 -1
  4. package/lib/globals/index.d.ts +1 -0
  5. package/lib/globals/index.d.ts.map +1 -1
  6. package/lib/globals/index.js +1 -0
  7. package/lib/globals/types.d.ts +11 -2
  8. package/lib/globals/types.d.ts.map +1 -1
  9. package/lib/globals/types.js +9 -0
  10. package/lib/models/agent.model.d.ts +18 -0
  11. package/lib/models/agent.model.d.ts.map +1 -1
  12. package/lib/models/video.model.d.ts +11 -0
  13. package/lib/models/video.model.d.ts.map +1 -1
  14. package/lib/schemas/agentRunJob.schema.d.ts +1 -0
  15. package/lib/schemas/agentRunJob.schema.d.ts.map +1 -1
  16. package/lib/schemas/agentRunJob.schema.js +9 -0
  17. package/lib/schemas/videoPlan.schema.d.ts +1 -0
  18. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  19. package/lib/schemas/videoPlan.schema.js +8 -0
  20. package/lib/services/agent/beatSnap.d.ts +3 -0
  21. package/lib/services/agent/beatSnap.d.ts.map +1 -1
  22. package/lib/services/agent/beatSnap.js +5 -0
  23. package/lib/services/agent/executor/core.d.ts +6 -0
  24. package/lib/services/agent/executor/core.d.ts.map +1 -1
  25. package/lib/services/agent/executor/core.js +45 -0
  26. package/lib/services/agent/executor/types.d.ts +29 -0
  27. package/lib/services/agent/executor/types.d.ts.map +1 -1
  28. package/lib/services/agent/executor/visual.d.ts.map +1 -1
  29. package/lib/services/agent/executor/visual.js +7 -0
  30. package/lib/services/agent/index.d.ts +1 -0
  31. package/lib/services/agent/index.d.ts.map +1 -1
  32. package/lib/services/agent/index.js +1 -0
  33. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -1
  34. package/lib/services/agent/planner/plannerMessages.js +7 -0
  35. package/lib/services/agent/resnapVo.d.ts +51 -0
  36. package/lib/services/agent/resnapVo.d.ts.map +1 -0
  37. package/lib/services/agent/resnapVo.js +102 -0
  38. package/lib/services/agent/tools/planVideo.tool.d.ts +1 -0
  39. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  40. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +1 -1
  41. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -1
  42. package/lib/services/aiGen/providers/alibaba/alibaba.js +2 -2
  43. package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
  44. package/lib/services/aiGen/providers/bytedance/bytedance.service.js +8 -0
  45. package/lib/services/aiGen/providers/google/google.service.d.ts +1 -1
  46. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  47. package/lib/services/aiGen/providers/google/google.service.js +71 -16
  48. package/lib/services/aiGen/providers/google/googleErrors.d.ts +28 -0
  49. package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -1
  50. package/lib/services/aiGen/providers/google/googleErrors.js +75 -2
  51. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts +8 -1
  52. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts.map +1 -1
  53. package/lib/services/aiGen/providers/google/googleKeyPool.js +77 -9
  54. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts +1 -1
  55. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts.map +1 -1
  56. package/lib/services/aiGen/providers/kling/klingImage.service.js +3 -3
  57. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +1 -1
  58. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
  59. package/lib/services/aiGen/providers/minimax/minimax.service.js +16 -7
  60. package/lib/services/aiGen/providers/openai/openai.service.d.ts +1 -1
  61. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
  62. package/lib/services/aiGen/providers/openai/openai.service.js +13 -3
  63. package/lib/services/aiGen/providers/runway/runway.service.d.ts +1 -1
  64. package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
  65. package/lib/services/aiGen/providers/runway/runway.service.js +3 -3
  66. package/lib/services/aiGen/providers/types.d.ts +8 -0
  67. package/lib/services/aiGen/providers/types.d.ts.map +1 -1
  68. package/lib/services/bullmq.service.d.ts.map +1 -1
  69. package/lib/services/bullmq.service.js +13 -5
  70. package/lib/services/freePlan/index.d.ts +38 -0
  71. package/lib/services/freePlan/index.d.ts.map +1 -0
  72. package/lib/services/freePlan/index.js +55 -0
  73. package/lib/services/index.d.ts +1 -0
  74. package/lib/services/index.d.ts.map +1 -1
  75. package/lib/services/index.js +1 -0
  76. package/lib/utils/errors.d.ts +23 -0
  77. package/lib/utils/errors.d.ts.map +1 -1
  78. package/lib/utils/errors.js +75 -1
  79. package/lib/utils/helpers.d.ts +8 -1
  80. package/lib/utils/helpers.d.ts.map +1 -1
  81. package/lib/utils/helpers.js +9 -2
  82. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USER_FACING_ERROR_CODES = exports.UserFacingError = void 0;
3
+ exports.USER_FACING_ERROR_MESSAGES = exports.USER_FACING_ERROR_CODES = exports.UserFacingError = void 0;
4
+ exports.friendlyMessageForCode = friendlyMessageForCode;
5
+ exports.sanitizeUserFacingMessage = sanitizeUserFacingMessage;
4
6
  /**
5
7
  * Thrown when an error should be shown to the user rather than retried/escalated.
6
8
  * These are logged as `warn` (Loki only) instead of `error` (Slack) to reduce noise.
@@ -45,3 +47,75 @@ exports.USER_FACING_ERROR_CODES = {
45
47
  /** Provider classified the request as unavailable (general service degradation, 5xx persistent). */
46
48
  PROVIDER_UNAVAILABLE: "PROVIDER_UNAVAILABLE",
47
49
  };
50
+ /**
51
+ * Canned, user-safe default message per code. The frontend translates by `code`
52
+ * via the `Toasts` namespace; these are the English fallback shown when a code
53
+ * isn't translated AND the safe text we store in `scene.errorMessage` so raw
54
+ * provider internals (billing consoles, API-key hints, request ids) never reach
55
+ * a user. Each reassures "you haven't been charged" where the failure is ours /
56
+ * the provider's, matching the credit-refund behaviour on failed jobs.
57
+ */
58
+ exports.USER_FACING_ERROR_MESSAGES = {
59
+ [exports.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_RATE_LIMITED]: "Our video provider is handling a lot of requests right now and couldn't start your video. You haven't been charged — please try again in a few minutes.",
60
+ [exports.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_HIGH_DEMAND]: "The video model is experiencing high demand right now. You haven't been charged — please try again in a few minutes.",
61
+ [exports.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_TIMEOUT]: "Your video took too long to generate and timed out. You haven't been charged — please try again.",
62
+ [exports.USER_FACING_ERROR_CODES.ACCOUNT_QUOTA_EXCEEDED]: "We've hit a temporary capacity limit with this video model. You haven't been charged — please try again shortly, or pick a different model.",
63
+ [exports.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE]: "The video service is temporarily unavailable. You haven't been charged — please try again in a few minutes.",
64
+ [exports.USER_FACING_ERROR_CODES.PROVIDER_AUTH_ERROR]: "Something went wrong on our side starting your video. You haven't been charged — please try again, and contact support if it keeps happening.",
65
+ [exports.USER_FACING_ERROR_CODES.TTS_PROVIDER_TIMEOUT]: "The voiceover service timed out. Please try again.",
66
+ [exports.USER_FACING_ERROR_CODES.TTS_PROVIDER_UNAVAILABLE]: "The voiceover service is temporarily unavailable. Please try again in a few minutes.",
67
+ [exports.USER_FACING_ERROR_CODES.PROMPT_TOO_LONG]: "Your prompt is too long for this model. Please shorten it and try again.",
68
+ [exports.USER_FACING_ERROR_CODES.PROMPT_INVALID]: "Your prompt was rejected by the model. Please simplify or rephrase it and try again.",
69
+ [exports.USER_FACING_ERROR_CODES.INPUT_IMAGE_REJECTED]: "Your input image was rejected. Please try a different image.",
70
+ [exports.USER_FACING_ERROR_CODES.CONTENT_POLICY_VIOLATION]: "Your prompt was flagged by the model's safety filters. Please rephrase and try again.",
71
+ [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.",
72
+ };
73
+ /** Friendly default for a code, or undefined if the code is unknown/unset. */
74
+ function friendlyMessageForCode(code) {
75
+ return code ? exports.USER_FACING_ERROR_MESSAGES[code] : undefined;
76
+ }
77
+ // Detection patterns (non-global, for .test) for provider-internal detail that
78
+ // must never be shown to a user: billing/console URLs, dashboards, API-key
79
+ // hints, and request ids. Kept in sync with REPLACE_PATTERNS below.
80
+ const LEAK_DETECT_PATTERNS = [
81
+ /https?:\/\/\S+/i,
82
+ /ai\.studio|aistudio\.google|console\.cloud\.google|platform\.openai|dashboard/i,
83
+ /prepayment|\bbilling\b|quota project|API[_ ]?key|service account|GOOGLE_[A-Z_]+/i,
84
+ /Request id:/i,
85
+ ];
86
+ // Replacement patterns (global) used to strip leaked fragments when we have no
87
+ // canned message to substitute.
88
+ const LEAK_REPLACE_PATTERNS = [
89
+ /https?:\/\/\S+/gi,
90
+ /\s*Request id:.*$/gi,
91
+ ];
92
+ const GENERIC_USER_FACING_MESSAGE = "Something went wrong generating your video. You haven't been charged — please try again, and contact support if it keeps happening.";
93
+ /**
94
+ * Display-boundary guard. Returns a message that is safe to show a user:
95
+ * - if `code` has a canned friendly message, always prefer it (provider text
96
+ * is never authoritative for display);
97
+ * - else, if the message contains provider-internal leak markers, strip them;
98
+ * if stripping leaves it too short / still internal, fall back to generic;
99
+ * - else return the message unchanged.
100
+ *
101
+ * This is the last line of defence against ANY provider (Google, Kling, Runway,
102
+ * …) leaking billing/console/internal text into a user-visible error.
103
+ */
104
+ function sanitizeUserFacingMessage(message, code) {
105
+ const canned = friendlyMessageForCode(code);
106
+ if (canned)
107
+ return canned;
108
+ if (!message)
109
+ return GENERIC_USER_FACING_MESSAGE;
110
+ const hasLeak = LEAK_DETECT_PATTERNS.some((re) => re.test(message));
111
+ if (!hasLeak)
112
+ return message;
113
+ let scrubbed = message;
114
+ for (const re of LEAK_REPLACE_PATTERNS)
115
+ scrubbed = scrubbed.replace(re, "");
116
+ scrubbed = scrubbed.replace(/\s{2,}/g, " ").trim();
117
+ // If, after stripping, the remaining text still trips a detector or is too
118
+ // short to be meaningful, don't risk it — use the generic message.
119
+ const stillLeaks = LEAK_DETECT_PATTERNS.some((re) => re.test(scrubbed));
120
+ return !stillLeaks && scrubbed.length >= 12 ? scrubbed : GENERIC_USER_FACING_MESSAGE;
121
+ }
@@ -4,7 +4,14 @@ import { ETextGenModels } from "../globals";
4
4
  export declare const getPlanTypeById: (priceId: string) => ESUBSCRIPTION_PLANS | null;
5
5
  export declare const getFreqById: (priceId: string) => ERENEWAL_FREQUENCY | null;
6
6
  export declare const getPriceIdByType: (type: ESUBSCRIPTION_PLANS, freq?: ERENEWAL_FREQUENCY) => string;
7
- export declare const getCreditsFromCost: (cost: number, applyFloor?: boolean) => number;
7
+ export declare const getCreditsFromCost: (cost: number, applyFloor?: boolean,
8
+ /**
9
+ * Per-op minimum when `applyFloor`. Defaults to MIN_CREDITS_PER_PAID_OP (10).
10
+ * Image-gen passes a lower floor (MIN_CREDITS_PER_IMAGE_OP) so cheap images
11
+ * aren't billed as if they cost $1 — see creditUnit.ts. Callers other than
12
+ * the image path leave it unset and keep the standard floor.
13
+ */
14
+ floor?: number) => number;
8
15
  /**
9
16
  * Guard against silent under-billing when a model's `cost` block is missing
10
17
  * from `aiModelConfigs`. Every provider's `getCreditUsed()` historically fell
@@ -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,IAS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,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;AA0DrB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
@@ -50,13 +50,20 @@ const getPriceIdByType = (type, freq = types_1.ERENEWAL_FREQUENCY.MONTHLY) => {
50
50
  : planDetails?.monthly?.id;
51
51
  };
52
52
  exports.getPriceIdByType = getPriceIdByType;
53
- const getCreditsFromCost = (cost, applyFloor = true) => {
53
+ const getCreditsFromCost = (cost, applyFloor = true,
54
+ /**
55
+ * Per-op minimum when `applyFloor`. Defaults to MIN_CREDITS_PER_PAID_OP (10).
56
+ * Image-gen passes a lower floor (MIN_CREDITS_PER_IMAGE_OP) so cheap images
57
+ * aren't billed as if they cost $1 — see creditUnit.ts. Callers other than
58
+ * the image path leave it unset and keep the standard floor.
59
+ */
60
+ floor = creditUnit_1.MIN_CREDITS_PER_PAID_OP) => {
54
61
  if (cost <= 0)
55
62
  return 0;
56
63
  // Canonical rate (see globals/creditUnit.ts). USD_PER_CREDIT is cost basis;
57
64
  // the 2× user markup lives in plan pricing, not here.
58
65
  const credits = Math.ceil(cost / creditUnit_1.USD_PER_CREDIT);
59
- return applyFloor ? Math.max(credits, creditUnit_1.MIN_CREDITS_PER_PAID_OP) : credits;
66
+ return applyFloor ? Math.max(credits, floor) : credits;
60
67
  };
61
68
  exports.getCreditsFromCost = getCreditsFromCost;
62
69
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidspotai-shared",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "exports": {