@bonginkan/maria 4.3.35 → 4.3.36

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.
@@ -9409,7 +9409,7 @@ app.use(compression__default.default({
9409
9409
  }
9410
9410
  }));
9411
9411
  app.use("/api/stripe/webhook", express__default.default.raw({ type: "application/json" }));
9412
- app.use(express__default.default.json({ limit: "10mb" }));
9412
+ app.use(express__default.default.json({ limit: "50mb" }));
9413
9413
  app.use(express__default.default.urlencoded({ extended: true }));
9414
9414
  try {
9415
9415
  const artifactsDir = path__namespace.default.resolve(process.cwd(), "artifacts");
@@ -9437,7 +9437,7 @@ app.get("/api/status", (req, res) => {
9437
9437
  app.get("/", (req, res) => {
9438
9438
  res.json({
9439
9439
  name: "MARIA CODE API",
9440
- version: "4.3.35",
9440
+ version: "4.3.36",
9441
9441
  status: "running",
9442
9442
  environment: process.env.NODE_ENV || "development",
9443
9443
  endpoints: {
@@ -9826,27 +9826,56 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
9826
9826
  await loadProviderKeys();
9827
9827
  const auth = req.headers.authorization;
9828
9828
  if (!auth || !auth.startsWith("Bearer ")) return res.status(401).json({ error: "unauthorized", message: "Login required", hint: "Sign in and retry" });
9829
- const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", format = "mp4", model, seed } = req.body || {};
9829
+ const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", aspect: aspectStr, format = "mp4", model, seed } = req.body || {};
9830
9830
  if (!prompt) return res.status(400).json({ error: "bad_request", message: "prompt required" });
9831
+ let w, h2;
9832
+ const aspect = typeof aspectStr === "string" && (aspectStr === "16:9" || aspectStr === "9:16") ? aspectStr : void 0;
9833
+ const sv = String(resStr).toLowerCase().replace(/p$/, "");
9831
9834
  const m2 = /^(\d{2,4})x(\d{2,4})$/.exec(String(resStr));
9832
- if (!m2) return res.status(400).json({ error: "bad_request", message: "res must be WxH" });
9833
- const w = +m2[1], h2 = +m2[2];
9835
+ if (m2) {
9836
+ w = +m2[1];
9837
+ h2 = +m2[2];
9838
+ } else if (sv === "720") {
9839
+ if (aspect === "9:16") {
9840
+ w = 720;
9841
+ h2 = 1280;
9842
+ } else {
9843
+ w = 1280;
9844
+ h2 = 720;
9845
+ }
9846
+ } else if (sv === "1080") {
9847
+ if (aspect === "9:16") {
9848
+ w = 1080;
9849
+ h2 = 1920;
9850
+ } else {
9851
+ w = 1920;
9852
+ h2 = 1080;
9853
+ }
9854
+ } else {
9855
+ return res.status(400).json({ error: "bad_request", message: "res must be WxH or 720|1080" });
9856
+ }
9834
9857
  const { GoogleGenAI } = __require("@google/genai");
9835
9858
  const apiKey = process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY;
9836
9859
  if (!apiKey) return res.status(503).json({ error: "provider_unavailable", message: "Provider API key is not configured", hint: "Set GOOGLE_API_KEY or GEMINI_API_KEY on the server" });
9837
9860
  const ai = new GoogleGenAI({ apiKey });
9838
9861
  const veoModel = model && String(model).trim() || process.env.MARIA_VIDEO_MODEL || "veo-3.0-generate-001";
9839
- const aspectRatio = w >= h2 ? "16:9" : "9:16";
9862
+ const aspectRatio = "16:9";
9840
9863
  const startedMs = Date.now();
9841
9864
  const requestedDuration = Number(duration);
9842
9865
  const effectiveDuration = Number.isFinite(requestedDuration) && requestedDuration === 8 ? 8 : 8;
9843
9866
  const requestedFps = Number(fps);
9844
9867
  const effectiveFps = Number.isFinite(requestedFps) ? Math.min(60, Math.max(1, Math.floor(requestedFps))) : 24;
9868
+ const resolution = Math.max(w, h2) >= 1920 ? "1080p" : "720p";
9845
9869
  let operation = await ai.models.generateVideos({
9846
9870
  model: veoModel,
9847
9871
  prompt: String(prompt),
9848
- // Pass duration/fps to provider to avoid default ~1s clips
9849
- config: { aspectRatio, durationSeconds: effectiveDuration, frameRate: effectiveFps }
9872
+ // Pass aspect + resolution + duration/fps explicitly -> resolution is not supported in veo3
9873
+ config: {
9874
+ aspectRatio,
9875
+ /* resolution: resolution, */
9876
+ durationSeconds: effectiveDuration,
9877
+ frameRate: effectiveFps
9878
+ }
9850
9879
  });
9851
9880
  const deadline = Date.now() + 72e4;
9852
9881
  while (!operation?.done) {
@@ -10224,7 +10253,18 @@ app.post("/v1/ai-proxy", rateLimitMiddleware, async (req, res) => {
10224
10253
  const ai = new GoogleGenerativeAI2(gemKey);
10225
10254
  const modelName = process.env.MARIA_CODE_MODEL || "gemini-2.5-flash";
10226
10255
  const model2 = ai.getGenerativeModel({ model: modelName });
10227
- const resp = await model2.generateContent({ contents: [{ role: "user", parts: [{ text: prompt }] }] });
10256
+ const attachments = Array.isArray((req.body?.metadata || {}).attachments) ? (req.body.metadata.attachments || []).filter(Boolean) : [];
10257
+ const parts = [{ text: String(prompt) }];
10258
+ for (const a of attachments) {
10259
+ try {
10260
+ const b64 = String(a.data_base64 || "");
10261
+ const mime = String(a.mime || "application/octet-stream");
10262
+ if (!b64) continue;
10263
+ parts.push({ inlineData: { data: b64, mimeType: mime } });
10264
+ } catch {
10265
+ }
10266
+ }
10267
+ const resp = await model2.generateContent({ contents: [{ role: "user", parts }] });
10228
10268
  const content2 = resp?.response?.text?.() || resp?.response?.candidates?.[0]?.content?.parts?.[0]?.text || "";
10229
10269
  if (process.env.MARIA_TELEMETRY === "1") {
10230
10270
  try {
@@ -9409,7 +9409,7 @@ app.use(compression__default.default({
9409
9409
  }
9410
9410
  }));
9411
9411
  app.use("/api/stripe/webhook", express__default.default.raw({ type: "application/json" }));
9412
- app.use(express__default.default.json({ limit: "10mb" }));
9412
+ app.use(express__default.default.json({ limit: "50mb" }));
9413
9413
  app.use(express__default.default.urlencoded({ extended: true }));
9414
9414
  try {
9415
9415
  const artifactsDir = path__namespace.default.resolve(process.cwd(), "artifacts");
@@ -9437,7 +9437,7 @@ app.get("/api/status", (req, res) => {
9437
9437
  app.get("/", (req, res) => {
9438
9438
  res.json({
9439
9439
  name: "MARIA CODE API",
9440
- version: "4.3.35",
9440
+ version: "4.3.36",
9441
9441
  status: "running",
9442
9442
  environment: process.env.NODE_ENV || "development",
9443
9443
  endpoints: {
@@ -9826,27 +9826,56 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
9826
9826
  await loadProviderKeys();
9827
9827
  const auth = req.headers.authorization;
9828
9828
  if (!auth || !auth.startsWith("Bearer ")) return res.status(401).json({ error: "unauthorized", message: "Login required", hint: "Sign in and retry" });
9829
- const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", format = "mp4", model, seed } = req.body || {};
9829
+ const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", aspect: aspectStr, format = "mp4", model, seed } = req.body || {};
9830
9830
  if (!prompt) return res.status(400).json({ error: "bad_request", message: "prompt required" });
9831
+ let w, h2;
9832
+ const aspect = typeof aspectStr === "string" && (aspectStr === "16:9" || aspectStr === "9:16") ? aspectStr : void 0;
9833
+ const sv = String(resStr).toLowerCase().replace(/p$/, "");
9831
9834
  const m2 = /^(\d{2,4})x(\d{2,4})$/.exec(String(resStr));
9832
- if (!m2) return res.status(400).json({ error: "bad_request", message: "res must be WxH" });
9833
- const w = +m2[1], h2 = +m2[2];
9835
+ if (m2) {
9836
+ w = +m2[1];
9837
+ h2 = +m2[2];
9838
+ } else if (sv === "720") {
9839
+ if (aspect === "9:16") {
9840
+ w = 720;
9841
+ h2 = 1280;
9842
+ } else {
9843
+ w = 1280;
9844
+ h2 = 720;
9845
+ }
9846
+ } else if (sv === "1080") {
9847
+ if (aspect === "9:16") {
9848
+ w = 1080;
9849
+ h2 = 1920;
9850
+ } else {
9851
+ w = 1920;
9852
+ h2 = 1080;
9853
+ }
9854
+ } else {
9855
+ return res.status(400).json({ error: "bad_request", message: "res must be WxH or 720|1080" });
9856
+ }
9834
9857
  const { GoogleGenAI } = __require("@google/genai");
9835
9858
  const apiKey = process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY;
9836
9859
  if (!apiKey) return res.status(503).json({ error: "provider_unavailable", message: "Provider API key is not configured", hint: "Set GOOGLE_API_KEY or GEMINI_API_KEY on the server" });
9837
9860
  const ai = new GoogleGenAI({ apiKey });
9838
9861
  const veoModel = model && String(model).trim() || process.env.MARIA_VIDEO_MODEL || "veo-3.0-generate-001";
9839
- const aspectRatio = w >= h2 ? "16:9" : "9:16";
9862
+ const aspectRatio = "16:9";
9840
9863
  const startedMs = Date.now();
9841
9864
  const requestedDuration = Number(duration);
9842
9865
  const effectiveDuration = Number.isFinite(requestedDuration) && requestedDuration === 8 ? 8 : 8;
9843
9866
  const requestedFps = Number(fps);
9844
9867
  const effectiveFps = Number.isFinite(requestedFps) ? Math.min(60, Math.max(1, Math.floor(requestedFps))) : 24;
9868
+ const resolution = Math.max(w, h2) >= 1920 ? "1080p" : "720p";
9845
9869
  let operation = await ai.models.generateVideos({
9846
9870
  model: veoModel,
9847
9871
  prompt: String(prompt),
9848
- // Pass duration/fps to provider to avoid default ~1s clips
9849
- config: { aspectRatio, durationSeconds: effectiveDuration, frameRate: effectiveFps }
9872
+ // Pass aspect + resolution + duration/fps explicitly -> resolution is not supported in veo3
9873
+ config: {
9874
+ aspectRatio,
9875
+ /* resolution: resolution, */
9876
+ durationSeconds: effectiveDuration,
9877
+ frameRate: effectiveFps
9878
+ }
9850
9879
  });
9851
9880
  const deadline = Date.now() + 72e4;
9852
9881
  while (!operation?.done) {
@@ -10224,7 +10253,18 @@ app.post("/v1/ai-proxy", rateLimitMiddleware, async (req, res) => {
10224
10253
  const ai = new GoogleGenerativeAI2(gemKey);
10225
10254
  const modelName = process.env.MARIA_CODE_MODEL || "gemini-2.5-flash";
10226
10255
  const model2 = ai.getGenerativeModel({ model: modelName });
10227
- const resp = await model2.generateContent({ contents: [{ role: "user", parts: [{ text: prompt }] }] });
10256
+ const attachments = Array.isArray((req.body?.metadata || {}).attachments) ? (req.body.metadata.attachments || []).filter(Boolean) : [];
10257
+ const parts = [{ text: String(prompt) }];
10258
+ for (const a of attachments) {
10259
+ try {
10260
+ const b64 = String(a.data_base64 || "");
10261
+ const mime = String(a.mime || "application/octet-stream");
10262
+ if (!b64) continue;
10263
+ parts.push({ inlineData: { data: b64, mimeType: mime } });
10264
+ } catch {
10265
+ }
10266
+ }
10267
+ const resp = await model2.generateContent({ contents: [{ role: "user", parts }] });
10228
10268
  const content2 = resp?.response?.text?.() || resp?.response?.candidates?.[0]?.content?.parts?.[0]?.text || "";
10229
10269
  if (process.env.MARIA_TELEMETRY === "1") {
10230
10270
  try {
@@ -9409,7 +9409,7 @@ app.use(compression__default.default({
9409
9409
  }
9410
9410
  }));
9411
9411
  app.use("/api/stripe/webhook", express__default.default.raw({ type: "application/json" }));
9412
- app.use(express__default.default.json({ limit: "10mb" }));
9412
+ app.use(express__default.default.json({ limit: "50mb" }));
9413
9413
  app.use(express__default.default.urlencoded({ extended: true }));
9414
9414
  try {
9415
9415
  const artifactsDir = path__namespace.default.resolve(process.cwd(), "artifacts");
@@ -9437,7 +9437,7 @@ app.get("/api/status", (req, res) => {
9437
9437
  app.get("/", (req, res) => {
9438
9438
  res.json({
9439
9439
  name: "MARIA CODE API",
9440
- version: "4.3.35",
9440
+ version: "4.3.36",
9441
9441
  status: "running",
9442
9442
  environment: process.env.NODE_ENV || "development",
9443
9443
  endpoints: {
@@ -9826,27 +9826,56 @@ app.post("/api/v1/video", rateLimitMiddleware, async (req, res) => {
9826
9826
  await loadProviderKeys();
9827
9827
  const auth = req.headers.authorization;
9828
9828
  if (!auth || !auth.startsWith("Bearer ")) return res.status(401).json({ error: "unauthorized", message: "Login required", hint: "Sign in and retry" });
9829
- const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", format = "mp4", model, seed } = req.body || {};
9829
+ const { prompt, duration = 8, fps = 24, res: resStr = "1280x720", aspect: aspectStr, format = "mp4", model, seed } = req.body || {};
9830
9830
  if (!prompt) return res.status(400).json({ error: "bad_request", message: "prompt required" });
9831
+ let w, h2;
9832
+ const aspect = typeof aspectStr === "string" && (aspectStr === "16:9" || aspectStr === "9:16") ? aspectStr : void 0;
9833
+ const sv = String(resStr).toLowerCase().replace(/p$/, "");
9831
9834
  const m2 = /^(\d{2,4})x(\d{2,4})$/.exec(String(resStr));
9832
- if (!m2) return res.status(400).json({ error: "bad_request", message: "res must be WxH" });
9833
- const w = +m2[1], h2 = +m2[2];
9835
+ if (m2) {
9836
+ w = +m2[1];
9837
+ h2 = +m2[2];
9838
+ } else if (sv === "720") {
9839
+ if (aspect === "9:16") {
9840
+ w = 720;
9841
+ h2 = 1280;
9842
+ } else {
9843
+ w = 1280;
9844
+ h2 = 720;
9845
+ }
9846
+ } else if (sv === "1080") {
9847
+ if (aspect === "9:16") {
9848
+ w = 1080;
9849
+ h2 = 1920;
9850
+ } else {
9851
+ w = 1920;
9852
+ h2 = 1080;
9853
+ }
9854
+ } else {
9855
+ return res.status(400).json({ error: "bad_request", message: "res must be WxH or 720|1080" });
9856
+ }
9834
9857
  const { GoogleGenAI } = __require("@google/genai");
9835
9858
  const apiKey = process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY;
9836
9859
  if (!apiKey) return res.status(503).json({ error: "provider_unavailable", message: "Provider API key is not configured", hint: "Set GOOGLE_API_KEY or GEMINI_API_KEY on the server" });
9837
9860
  const ai = new GoogleGenAI({ apiKey });
9838
9861
  const veoModel = model && String(model).trim() || process.env.MARIA_VIDEO_MODEL || "veo-3.0-generate-001";
9839
- const aspectRatio = w >= h2 ? "16:9" : "9:16";
9862
+ const aspectRatio = "16:9";
9840
9863
  const startedMs = Date.now();
9841
9864
  const requestedDuration = Number(duration);
9842
9865
  const effectiveDuration = Number.isFinite(requestedDuration) && requestedDuration === 8 ? 8 : 8;
9843
9866
  const requestedFps = Number(fps);
9844
9867
  const effectiveFps = Number.isFinite(requestedFps) ? Math.min(60, Math.max(1, Math.floor(requestedFps))) : 24;
9868
+ const resolution = Math.max(w, h2) >= 1920 ? "1080p" : "720p";
9845
9869
  let operation = await ai.models.generateVideos({
9846
9870
  model: veoModel,
9847
9871
  prompt: String(prompt),
9848
- // Pass duration/fps to provider to avoid default ~1s clips
9849
- config: { aspectRatio, durationSeconds: effectiveDuration, frameRate: effectiveFps }
9872
+ // Pass aspect + resolution + duration/fps explicitly -> resolution is not supported in veo3
9873
+ config: {
9874
+ aspectRatio,
9875
+ /* resolution: resolution, */
9876
+ durationSeconds: effectiveDuration,
9877
+ frameRate: effectiveFps
9878
+ }
9850
9879
  });
9851
9880
  const deadline = Date.now() + 72e4;
9852
9881
  while (!operation?.done) {
@@ -10224,7 +10253,18 @@ app.post("/v1/ai-proxy", rateLimitMiddleware, async (req, res) => {
10224
10253
  const ai = new GoogleGenerativeAI2(gemKey);
10225
10254
  const modelName = process.env.MARIA_CODE_MODEL || "gemini-2.5-flash";
10226
10255
  const model2 = ai.getGenerativeModel({ model: modelName });
10227
- const resp = await model2.generateContent({ contents: [{ role: "user", parts: [{ text: prompt }] }] });
10256
+ const attachments = Array.isArray((req.body?.metadata || {}).attachments) ? (req.body.metadata.attachments || []).filter(Boolean) : [];
10257
+ const parts = [{ text: String(prompt) }];
10258
+ for (const a of attachments) {
10259
+ try {
10260
+ const b64 = String(a.data_base64 || "");
10261
+ const mime = String(a.mime || "application/octet-stream");
10262
+ if (!b64) continue;
10263
+ parts.push({ inlineData: { data: b64, mimeType: mime } });
10264
+ } catch {
10265
+ }
10266
+ }
10267
+ const resp = await model2.generateContent({ contents: [{ role: "user", parts }] });
10228
10268
  const content2 = resp?.response?.text?.() || resp?.response?.candidates?.[0]?.content?.parts?.[0]?.text || "";
10229
10269
  if (process.env.MARIA_TELEMETRY === "1") {
10230
10270
  try {