@productmaker/mcp 12.45.0 → 12.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stdio.js CHANGED
@@ -8423,7 +8423,7 @@ var scenes = z19.array(MarketLedVideoSceneSchema).min(2).max(40).superRefine((sh
8423
8423
  if (shot.characterId) anchored.add(shot.characterId);
8424
8424
  }
8425
8425
  });
8426
- var quoteDirectorChoice = z19.enum([
8426
+ var MarketLedVideoDirectorSchema = z19.enum([
8427
8427
  "productmaker",
8428
8428
  "external_agent"
8429
8429
  ]);
@@ -8436,7 +8436,7 @@ var marketLedVideoWalletRecoveryPolicy = z19.literal(MARKET_LED_VIDEO_WALLET_REC
8436
8436
  var MarketLedVideoStateSchema = z19.object({
8437
8437
  recoveryDebitPolicy: marketLedVideoWalletRecoveryPolicy.optional(),
8438
8438
  director: z19.literal("external_agent").optional(),
8439
- quoteDirector: quoteDirectorChoice.optional(),
8439
+ quoteDirector: MarketLedVideoDirectorSchema.optional(),
8440
8440
  phase: z19.enum([
8441
8441
  "angles",
8442
8442
  "formats",
@@ -8624,13 +8624,13 @@ var MarketLedVideoCommandSchema = z19.discriminatedUnion("type", [
8624
8624
  z19.object({
8625
8625
  type: z19.literal("submit_storyboards"),
8626
8626
  revision,
8627
- director: quoteDirectorChoice.optional(),
8627
+ director: MarketLedVideoDirectorSchema.optional(),
8628
8628
  pieces: z19.array(MarketLedVideoAuthoredPieceSchema).min(1).max(MARKET_LED_VIDEO_BATCH_LIMIT)
8629
8629
  }).strict(),
8630
8630
  z19.object({
8631
8631
  type: z19.literal("save_scripts"),
8632
8632
  revision,
8633
- director: quoteDirectorChoice.optional(),
8633
+ director: MarketLedVideoDirectorSchema.optional(),
8634
8634
  pieces: z19.array(scriptEdit).min(1).max(MARKET_LED_VIDEO_BATCH_LIMIT)
8635
8635
  }).strict(),
8636
8636
  z19.object({
@@ -13451,6 +13451,8 @@ var IngestOptions = z42.object({
13451
13451
  /** Canonical public route axes; legacy provider fields remain compatibility aliases. */
13452
13452
  videoStructure: VideoStructure.optional(),
13453
13453
  videoQuality: VideoQuality.optional(),
13454
+ /** Direction supplied by the agent for guided Multiescena. */
13455
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
13454
13456
  videoModel: VideoModel.default("veo").nonoptional(),
13455
13457
  /**
13456
13458
  * An explicit registry model id for Free mode (Defect 1, follow-up to the
@@ -15908,6 +15910,8 @@ var IngestEstimationOptions = z55.object({
15908
15910
  var IngestResumeEstimationOptions = z55.object({
15909
15911
  /** Autopilot quotes before creation share new video admission. Saved resumes omit this. */
15910
15912
  forNewVideo: z55.literal(true).optional(),
15913
+ /** Direction supplied by the agent for a new guided Multiescena. */
15914
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
15911
15915
  /** The guided market-led intake quotes reference preparation separately. */
15912
15916
  marketLedDeferredCopy: z55.literal(true).optional(),
15913
15917
  sourceProductUrl: z55.string().max(4096).optional(),
@@ -16020,6 +16024,7 @@ var VideoCreativeEstimationOptions = z55.object({
16020
16024
  competitorScanEnabled: z55.boolean().optional(),
16021
16025
  /** Explicit consent for the paid deep commercial study and market planner. */
16022
16026
  competitorCommercialStudyRequested: z55.boolean().optional(),
16027
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
16023
16028
  marketLedDeferredCopy: z55.literal(true).optional(),
16024
16029
  replicateWinnerWhenFound: z55.boolean().optional(),
16025
16030
  automaticVideoFormats: AutomaticVideoFormatsSchema.optional(),
@@ -17426,7 +17431,8 @@ var CreateTaskVideoVariantRequest = CreateTaskCreativeVariantBase.extend({
17426
17431
  videoPreset: TaskCreativeVariantVideoPreset.optional(),
17427
17432
  ugcFormat: VideoFormat.optional(),
17428
17433
  videoResolution: VideoResolution.optional(),
17429
- generateAiMusic: z58.boolean().optional()
17434
+ generateAiMusic: z58.boolean().optional(),
17435
+ maxApprovedCredits: z58.number().int().positive().optional()
17430
17436
  }).strict();
17431
17437
  var CreateTaskImageVariantRequest = CreateTaskCreativeVariantBase.extend({
17432
17438
  kind: z58.literal("image"),
@@ -17453,7 +17459,8 @@ var EstimateTaskCreativeVariantRequest = z58.discriminatedUnion("kind", [
17453
17459
  z58.object({
17454
17460
  kind: z58.literal("video"),
17455
17461
  videoPreset: TaskCreativeVariantVideoPreset.optional(),
17456
- videoResolution: VideoResolution.optional()
17462
+ videoResolution: VideoResolution.optional(),
17463
+ generateAiMusic: z58.boolean().optional()
17457
17464
  }).strict(),
17458
17465
  z58.object({
17459
17466
  kind: z58.literal("image"),
@@ -27284,7 +27291,7 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27284
27291
  // MCP 8.10.0: storyteller family blocked (BLOCKED_NARRATIVE_STYLES).
27285
27292
  // MCP 9.1.0: combine current animated-video controls and initial GIF choice.
27286
27293
  // MCP 12.8.0: + manual-only, cohort-gated «viral» preset/angle narrative.
27287
- "bfe5130b1941f5f0a690949411d83cdbd32c1ee65cc75f2c22568b87bfe90a42",
27294
+ "0d6cfdb4d48aa60eae18e27e4b735145a61cecc8acad052f2465dc673c00b6d3",
27288
27295
  "credit_consuming",
27289
27296
  "creative",
27290
27297
  [
@@ -27299,7 +27306,8 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27299
27306
  "kind"
27300
27307
  ]),
27301
27308
  slot("confirmation", true, [
27302
- "confirm"
27309
+ "confirm",
27310
+ "maxApprovedCredits"
27303
27311
  ], [], "confirmation"),
27304
27312
  slot("idempotency", true, [
27305
27313
  "clientRequestId"
@@ -27562,7 +27570,7 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27562
27570
  defineCapability(
27563
27571
  "estimate_creative_variant",
27564
27572
  // MCP 12.8.0: + manual-only, cohort-gated «viral» preset/angle narrative.
27565
- "743d227d050dab27a8b385c9bc2c0c2d5b450e22abfed811c344b65faffb29ab",
27573
+ "16f9f648c61371bb4be138c6026e2f88052ee5d9a3b6e541b100c91a386a9408",
27566
27574
  "none",
27567
27575
  "read_only",
27568
27576
  [
@@ -27581,7 +27589,10 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27581
27589
  "nVariants",
27582
27590
  "sectionKey",
27583
27591
  "instructions"
27584
- ])
27592
+ ]),
27593
+ slot("video_music", false, [
27594
+ "generateAiMusic"
27595
+ ], [])
27585
27596
  ],
27586
27597
  [
27587
27598
  "task",
@@ -34992,7 +35003,7 @@ var ApiClient = class {
34992
35003
  };
34993
35004
 
34994
35005
  // src/index.ts
34995
- var MCP_VERSION = "12.45.0";
35006
+ var MCP_VERSION = "12.46.0";
34996
35007
 
34997
35008
  // src/meta-upload-app.ts
34998
35009
  import { readFileSync } from "fs";
@@ -37820,7 +37831,13 @@ function formatCredits(creditCents) {
37820
37831
  __name(formatCredits, "formatCredits");
37821
37832
 
37822
37833
  // src/tools/task-outputs.ts
37823
- function creativeDeliveryNextAction(media, locale = "es", codeLandingUrl) {
37834
+ function creativeDeliveryNextAction(media, locale = "es", codeLandingUrl, videoReviewRequired = false) {
37835
+ if (videoReviewRequired) {
37836
+ return {
37837
+ kind: "review_creatives",
37838
+ question: OUTPUT_MARKDOWN_COPY[locale].reviewVideoQuestion
37839
+ };
37840
+ }
37824
37841
  if (codeLandingUrl) {
37825
37842
  return {
37826
37843
  kind: "review_code_landing",
@@ -38000,7 +38017,20 @@ function sanitizeFilename(s) {
38000
38017
  }
38001
38018
  __name(sanitizeFilename, "sanitizeFilename");
38002
38019
  async function fetchTaskOutputs(api, taskId, options) {
38003
- const raw = await api.getJson(`/v1/results/${encodeURIComponent(taskId)}?signedUrls=true`, options);
38020
+ const { partialDelivery, ...requestOptions } = options ?? {};
38021
+ const raw = await api.getJson(`/v1/results/${encodeURIComponent(taskId)}?signedUrls=true`, requestOptions);
38022
+ if (partialDelivery) {
38023
+ return projectTaskOutputs({
38024
+ videoGenerators: raw.videoGenerators?.filter((video) => video.status === "success"),
38025
+ ...partialDelivery.landingReady ? {
38026
+ landing: raw.landing,
38027
+ creativeVariants: raw.creativeVariants
38028
+ } : {},
38029
+ ...partialDelivery.imageReady ? {
38030
+ adCreative: raw.adCreative
38031
+ } : {}
38032
+ }, taskId);
38033
+ }
38004
38034
  const creativeVariants = (raw.creativeVariants ?? []).flatMap((child) => {
38005
38035
  const identity2 = CreativeVariantIdentity.safeParse(child);
38006
38036
  if (!identity2.success || identity2.data.sourceTaskId !== taskId) return [];
@@ -38034,16 +38064,30 @@ __name(fetchTaskOutputs, "fetchTaskOutputs");
38034
38064
  function applyMarketLedVideoReview(outputs, marketLedVideo) {
38035
38065
  const draft = MarketLedVideoStateSchema.safeParse(marketLedVideo);
38036
38066
  if (!draft.success) return outputs;
38037
- const flagged = draft.data.pieces.filter(({ selected, renderStatus, qualityReviewRequired, resultAngleKey }) => selected !== false && resultAngleKey !== void 0 && (renderStatus === "failed" || qualityReviewRequired));
38038
- if (!flagged.length) return outputs;
38039
- const angleKeys = new Set(flagged.map(({ resultAngleKey }) => resultAngleKey));
38067
+ const piecesByAngle = new Map(draft.data.pieces.flatMap((piece) => piece.selected !== false && piece.resultAngleKey ? [
38068
+ [
38069
+ piece.resultAngleKey,
38070
+ piece
38071
+ ]
38072
+ ] : []));
38073
+ const reviewAngles = new Set(Array.from(piecesByAngle).filter(([, piece]) => piece.renderStatus === "failed" || piece.qualityReviewRequired).map(([angleKey]) => angleKey));
38074
+ const videos = outputs.videos.map((video) => {
38075
+ const piece = piecesByAngle.get(video.angleKey);
38076
+ if (!piece) return video;
38077
+ return {
38078
+ ...video,
38079
+ requestedDurationSeconds: piece.durationSeconds,
38080
+ ...reviewAngles.has(video.angleKey) ? {
38081
+ reviewFailed: true
38082
+ } : {}
38083
+ };
38084
+ });
38040
38085
  return {
38041
38086
  ...outputs,
38042
- videoReviewFailed: true,
38043
- videos: outputs.videos.map((video) => angleKeys.has(video.angleKey) ? {
38044
- ...video,
38045
- reviewFailed: true
38046
- } : video)
38087
+ ...reviewAngles.size > 0 ? {
38088
+ videoReviewFailed: true
38089
+ } : {},
38090
+ videos
38047
38091
  };
38048
38092
  }
38049
38093
  __name(applyMarketLedVideoReview, "applyMarketLedVideoReview");
@@ -38060,6 +38104,9 @@ function projectTaskOutputs(raw, taskId) {
38060
38104
  return {
38061
38105
  angleKey: vg.angleKey ?? "",
38062
38106
  angleIndex: vg.angleIndex ?? 0,
38107
+ ...typeof vg.durationSeconds === "number" && Number.isFinite(vg.durationSeconds) && vg.durationSeconds > 0 ? {
38108
+ durationSeconds: vg.durationSeconds
38109
+ } : {},
38063
38110
  ...vg.marketVideoFormatLabel ? {
38064
38111
  marketVideoFormatLabel: vg.marketVideoFormatLabel
38065
38112
  } : {},
@@ -38136,15 +38183,57 @@ function projectTaskOutputs(raw, taskId) {
38136
38183
  };
38137
38184
  }
38138
38185
  __name(projectTaskOutputs, "projectTaskOutputs");
38139
- function renderOutputsMarkdown(outputs) {
38140
- const parts = [];
38141
- parts.push(outputs.videoReviewFailed ? `\u26A0\uFE0F **Hay videos que no pasaron la revisi\xF3n** \u2014 [Abrir en Product Maker](${outputs.webappUrl})` : `\u2705 **Tu tarea est\xE1 lista** \u2014 [Abrir en Product Maker](${outputs.webappUrl})`);
38186
+ var OUTPUT_MARKDOWN_COPY = {
38187
+ es: {
38188
+ download: "Descargar",
38189
+ variant: "variante",
38190
+ variants: "variantes",
38191
+ sections: "secciones",
38192
+ gif: "GIF de producto",
38193
+ gifPreview: "Vista est\xE1tica del GIF",
38194
+ unapproved: " \xB7 No aprobado",
38195
+ rewritten: " \u26A0\uFE0F No pudimos usar el guion que aprobaste para este \xE1ngulo, as\xED que generamos el video con un guion nuevo. Si no te sirve, ed\xEDtalo o vuelve a generarlo.",
38196
+ ready: "Tu tarea est\xE1 lista",
38197
+ reviewFailed: "Hay videos que no pasaron la revisi\xF3n",
38198
+ durationDifference: /* @__PURE__ */ __name((delivered, requested) => `Duraci\xF3n entregada: ${delivered} s. Duraci\xF3n solicitada: ${requested} s.`, "durationDifference"),
38199
+ reviewVideoQuestion: "\xBFQuieres que cotice una correcci\xF3n para el video que necesita revisi\xF3n?",
38200
+ openTask: "Abrir en Product Maker",
38201
+ variantOf: "Variante de",
38202
+ image: "imagen",
38203
+ variantFailed: "No se pudo entregar esta variante.",
38204
+ variantPending: "La variante sigue gener\xE1ndose. Consulta su estado antes de iniciar otra."
38205
+ },
38206
+ en: {
38207
+ download: "Download",
38208
+ variant: "version",
38209
+ variants: "versions",
38210
+ sections: "sections",
38211
+ gif: "Product GIF",
38212
+ gifPreview: "GIF preview",
38213
+ unapproved: " \xB7 Not approved",
38214
+ rewritten: " \u26A0\uFE0F We couldn't use the approved script for this video, so we used a new one. You can edit or regenerate the video.",
38215
+ ready: "Your task is ready",
38216
+ reviewFailed: "Some videos did not pass review",
38217
+ durationDifference: /* @__PURE__ */ __name((delivered, requested) => `Delivered duration: ${delivered} s. Requested duration: ${requested} s.`, "durationDifference"),
38218
+ reviewVideoQuestion: "Would you like a quote to fix the video that needs review?",
38219
+ openTask: "Open in ProductMaker",
38220
+ variantOf: "Variation of",
38221
+ image: "image",
38222
+ variantFailed: "This variation could not be delivered.",
38223
+ variantPending: "This variation is still being generated. Check its status before starting another."
38224
+ }
38225
+ };
38226
+ function renderOutputsMarkdown(outputs, introduction, locale = "es") {
38227
+ const copy = OUTPUT_MARKDOWN_COPY[locale];
38228
+ const parts = [
38229
+ introduction ?? (outputs.videoReviewFailed ? `\u26A0\uFE0F **${copy.reviewFailed}** \u2014 [${copy.openTask}](${outputs.webappUrl})` : `\u2705 **${copy.ready}** \u2014 [${copy.openTask}](${outputs.webappUrl})`)
38230
+ ];
38142
38231
  if (outputs.images.length) {
38143
38232
  parts.push(`
38144
- ### Ad creative (${outputs.images.length} ${outputs.images.length === 1 ? "variante" : "variantes"})`);
38233
+ ### Ad creative (${outputs.images.length} ${outputs.images.length === 1 ? copy.variant : copy.variants})`);
38145
38234
  outputs.images.forEach((img, i) => {
38146
38235
  parts.push(`![v${i}](${img.url})`);
38147
- parts.push(`[\u2B07 Descargar v${i}](${img.url})`);
38236
+ parts.push(`[\u2B07 ${copy.download} v${i}](${img.url})`);
38148
38237
  if (img.adCopy) parts.push(`Copy: ${img.adCopy}`);
38149
38238
  });
38150
38239
  }
@@ -38154,39 +38243,42 @@ function renderOutputsMarkdown(outputs) {
38154
38243
  }
38155
38244
  if (outputs.landing.sections.length) {
38156
38245
  parts.push(`
38157
- ### Landing (${outputs.landing.sections.length} secciones)`);
38246
+ ### Landing (${outputs.landing.sections.length} ${copy.sections})`);
38158
38247
  for (const s of outputs.landing.sections) {
38159
38248
  parts.push(`![${escapeMdLabel(s.role)}](${s.url})`);
38160
- parts.push(`[\u2B07 Descargar ${escapeMdLabel(s.role)}](${s.url})`);
38249
+ parts.push(`[\u2B07 ${copy.download} ${escapeMdLabel(s.role)}](${s.url})`);
38161
38250
  }
38162
38251
  }
38163
38252
  for (const gif of outputGifs(outputs)) {
38164
38253
  parts.push(`
38165
- ### GIF de producto (${gif.durationSeconds}s \xB7 QA: ${gif.quality.verdict})`);
38166
- parts.push(`![Vista est\xE1tica del GIF](${gif.posterUrl})`);
38167
- parts.push(`[\u2B07 Descargar GIF](${gif.gifUrl})`);
38254
+ ### ${copy.gif} (${gif.durationSeconds}s \xB7 QA: ${gif.quality.verdict})`);
38255
+ parts.push(`![${copy.gifPreview}](${gif.posterUrl})`);
38256
+ parts.push(`[\u2B07 ${copy.download} GIF](${gif.gifUrl})`);
38168
38257
  }
38169
38258
  if (outputs.videos.length) {
38170
38259
  parts.push("\n### Video");
38171
38260
  for (const v of outputs.videos) {
38261
+ if (v.durationSeconds && v.requestedDurationSeconds && v.durationSeconds !== v.requestedDurationSeconds) {
38262
+ parts.push(copy.durationDifference(v.durationSeconds, v.requestedDurationSeconds));
38263
+ }
38172
38264
  for (const variant of v.variants) {
38173
- parts.push(`- [${escapeMdLabel(v.marketVideoFormatLabel ?? v.angleKey)} \xB7 ${escapeMdLabel(variant.kind)}${v.reviewFailed ? " \xB7 No aprobado" : ""}](${variant.url})`);
38265
+ parts.push(`- [${escapeMdLabel(v.marketVideoFormatLabel ?? v.angleKey)} \xB7 ${escapeMdLabel(variant.kind)}${v.reviewFailed ? copy.unapproved : ""}](${variant.url})`);
38174
38266
  }
38175
38267
  if (v.scriptRewritten) {
38176
- parts.push(` \u26A0\uFE0F No pudimos usar el guion que aprobaste para este \xE1ngulo, as\xED que generamos el video con un guion nuevo. Si no te sirve, ed\xEDtalo o vuelve a generarlo.`);
38268
+ parts.push(copy.rewritten);
38177
38269
  }
38178
38270
  }
38179
38271
  }
38180
38272
  for (const child of outputs.creativeVariants ?? []) {
38181
- const label2 = child.kind === "image" ? "imagen" : child.kind;
38273
+ const label2 = child.kind === "image" ? copy.image : child.kind;
38182
38274
  parts.push(`
38183
- ### Variante de ${label2}`);
38275
+ ### ${copy.variantOf} ${label2}`);
38184
38276
  if (child.status === "done" && child.outputs) {
38185
- parts.push(renderOutputsMarkdown(child.outputs));
38277
+ parts.push(renderOutputsMarkdown(child.outputs, void 0, locale));
38186
38278
  } else if (child.status === "error") {
38187
- parts.push(escapeMarkdownText(child.error ?? "No se pudo entregar esta variante."));
38279
+ parts.push(escapeMarkdownText(child.error ?? copy.variantFailed));
38188
38280
  } else {
38189
- parts.push("La variante sigue gener\xE1ndose. Consulta su estado antes de iniciar otra.");
38281
+ parts.push(copy.variantPending);
38190
38282
  }
38191
38283
  }
38192
38284
  return parts.join("\n");
@@ -39619,6 +39711,11 @@ var MARKET_LED_REVIEW_QUESTIONS = {
39619
39711
  en: "Do you approve the script or want to change anything?"
39620
39712
  }
39621
39713
  };
39714
+ var TaskOutputStageStatuses = z161.object({
39715
+ landing: z161.string().optional(),
39716
+ creative: z161.string().optional(),
39717
+ video_generator: z161.string().optional()
39718
+ });
39622
39719
  var TASK_STATUS_COPY = {
39623
39720
  es: {
39624
39721
  readDraft: "Consulta get_market_led_video sin cotizaci\xF3n para esta misma tarea. Si cambi\xF3 la fase o la revisi\xF3n, usa solo la decisi\xF3n del borrador vigente.",
@@ -39629,6 +39726,12 @@ var TASK_STATUS_COPY = {
39629
39726
  trackingFallback: "Si se acaba el turno antes de la pr\xF3xima pregunta, explica el progreso real y comparte este enlace para seguir la misma tarea:",
39630
39727
  webAngleReview: "Falta elegir los \xE1ngulos de tu anuncio. Abre esta tarea en ProductMaker, elige c\xF3mo quieres vender tu producto y vuelve al chat cuando termines.",
39631
39728
  webReview: "Tu tarea necesita una revisi\xF3n. Abre esta tarea en ProductMaker para ver y resolver la decisi\xF3n pendiente. Cuando termines, vuelve al chat para continuar.",
39729
+ terminalFailure: "No pudimos terminar esta tarea.",
39730
+ partialDelivery: "Parte de tu contenido est\xE1 lista. Te muestro las piezas disponibles.",
39731
+ partialInProgress: "Estas piezas ya est\xE1n listas. El resto sigue en preparaci\xF3n.",
39732
+ continueVideoRepair: "Consulta el video de esta misma tarea para comprobar si alguna toma necesita un ajuste.",
39733
+ partialVideoDelivery: "El video no se pudo terminar.",
39734
+ partialVideosDelivery: "Algunos videos no se pudieron terminar.",
39632
39735
  openTask: "Abrir esta tarea en ProductMaker"
39633
39736
  },
39634
39737
  en: {
@@ -39640,6 +39743,12 @@ var TASK_STATUS_COPY = {
39640
39743
  trackingFallback: "If the turn ends before the next question, explain the current progress and share this link to follow the same task:",
39641
39744
  webAngleReview: "Your ad angles are ready to choose. Open this task in ProductMaker, choose how you want to sell your product, and return to the chat when you finish.",
39642
39745
  webReview: "Your task needs a review. Open this task in ProductMaker to see and resolve the pending decision, then return to the chat to continue.",
39746
+ terminalFailure: "We could not finish this task.",
39747
+ partialDelivery: "Part of your content is ready. Here are the pieces available now.",
39748
+ partialInProgress: "These pieces are ready. The rest is still in progress.",
39749
+ continueVideoRepair: "Check the video draft for this task to see if a shot needs an adjustment.",
39750
+ partialVideoDelivery: "The video could not be completed.",
39751
+ partialVideosDelivery: "Some videos could not be completed.",
39643
39752
  openTask: "Open this task in ProductMaker"
39644
39753
  }
39645
39754
  };
@@ -40164,6 +40273,7 @@ function registerTaskTools(server, api, { proxyBaseUrl = null, transport = "http
40164
40273
  "options.narrativeStyle": resolved?.narrativeStyle,
40165
40274
  "options.videoTier": wireTier,
40166
40275
  "options.videoStructure": videoStructure,
40276
+ "options.marketLedVideoDirector": selectedOutputs.includes("video") && videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && reviewPolicy.pauseForAngleReview ? "external_agent" : void 0,
40167
40277
  "options.videoQuality": input.videoQuality,
40168
40278
  "options.ugcFormat": resolveVideoFormatForDuration(input.durationSeconds),
40169
40279
  "options.videoResolution": input.videoResolution,
@@ -40369,13 +40479,21 @@ function registerTaskTools(server, api, { proxyBaseUrl = null, transport = "http
40369
40479
  } : {}
40370
40480
  }
40371
40481
  };
40372
- if (snapshot.status !== "done") {
40373
- const locale = input.viewerLocale ?? "es";
40374
- const copy = TASK_STATUS_COPY[locale];
40375
- const webLink = `[${copy.openTask}](${taskWebUrl(input.taskId, locale)})`;
40482
+ const marketAction = readMarketLedVideoNextAction(snapshot);
40483
+ const productTask = snapshot.kind !== "service";
40484
+ const failedProductTask = snapshot.status === "error" && productTask;
40485
+ const canDeliverDuringProcessing = snapshot.status === "processing" && productTask && !openReview && snapshot.pendingUserAction == null && !marketAction?.phase && !readVideoScriptReviewNextAction(snapshot);
40486
+ const outputStages = failedProductTask || canDeliverDuringProcessing ? TaskOutputStageStatuses.safeParse(snapshot.stageStatuses).data : void 0;
40487
+ const partialVideo = failedProductTask ? StatusResponse.shape.partialVideoResult.safeParse(snapshot.partialVideoResult).data : void 0;
40488
+ const landingReady = outputStages?.landing === "success";
40489
+ const imageReady = outputStages?.creative === "success";
40490
+ const hasPartialDelivery = landingReady || imageReady || outputStages?.video_generator === "success" || Boolean(partialVideo?.successAngles.length);
40491
+ const locale = input.viewerLocale ?? "es";
40492
+ const copy = TASK_STATUS_COPY[locale];
40493
+ const webLink = `[${copy.openTask}](${taskWebUrl(input.taskId, locale)})`;
40494
+ if (snapshot.status !== "done" && !hasPartialDelivery) {
40376
40495
  const reviewFallback = `${copy.reviewFallback} ${webLink}`;
40377
40496
  const trackingFallback = `${copy.trackingFallback} ${webLink}`;
40378
- const marketAction = readMarketLedVideoNextAction(snapshot);
40379
40497
  if (marketAction && (marketAction.phase || !openReview)) {
40380
40498
  const { phase, scriptPreparationFailed, ...reviewNextAction } = marketAction;
40381
40499
  const { pendingUserAction: _legacyAction, ...current } = snapshot;
@@ -40604,9 +40722,47 @@ ${trackingFallback}`
40604
40722
  ]
40605
40723
  };
40606
40724
  }
40725
+ const pollingContinuation = canDeliverDuringProcessing ? buildPollingContinuation(snapshot) : null;
40726
+ const repairAction = canDeliverDuringProcessing && marketAction?.kind === "check_market_led_video_repair" ? {
40727
+ reviewNextAction: {
40728
+ kind: marketAction.kind,
40729
+ tool: marketAction.tool,
40730
+ arguments: marketAction.arguments
40731
+ }
40732
+ } : {};
40733
+ const statusWithContinuation = {
40734
+ ...snapshot,
40735
+ ...pollingContinuation ? {
40736
+ pollingContinuation
40737
+ } : {},
40738
+ ...repairAction
40739
+ };
40740
+ const continuationText = [
40741
+ "reviewNextAction" in repairAction ? copy.continueVideoRepair : null,
40742
+ pollingContinuation?.instruction
40743
+ ].filter(Boolean).join("\n\n");
40744
+ const statusWithoutOutputs = {
40745
+ structuredContent: statusWithContinuation,
40746
+ content: [
40747
+ {
40748
+ type: "text",
40749
+ text: [
40750
+ failedProductTask ? copy.terminalFailure : continuationText,
40751
+ webLink
40752
+ ].filter(Boolean).join("\n\n")
40753
+ }
40754
+ ],
40755
+ _meta: statusMeta
40756
+ };
40607
40757
  try {
40608
40758
  const rawOutputs = await fetchTaskOutputs(api, input.taskId, {
40609
- signal
40759
+ signal,
40760
+ ...hasPartialDelivery ? {
40761
+ partialDelivery: {
40762
+ landingReady,
40763
+ imageReady
40764
+ }
40765
+ } : {}
40610
40766
  });
40611
40767
  const imageContent = await buildMcpGeneratedImageContent(rawOutputs.images.map((image2, i) => ({
40612
40768
  url: image2.url,
@@ -40635,10 +40791,24 @@ ${trackingFallback}`
40635
40791
  }))),
40636
40792
  links: []
40637
40793
  };
40794
+ const codeLandingUrl = snapshot.landingMode === "code" && (!hasPartialDelivery || landingReady) ? outputs.webappUrl : void 0;
40795
+ const gifLinks = buildGifResourceLinks(outputs);
40796
+ if (hasPartialDelivery && !media.images.length && !media.videos.length && !media.landingSections.length && !gifLinks.length && !codeLandingUrl) {
40797
+ return statusWithoutOutputs;
40798
+ }
40799
+ const partialMessage = hasPartialDelivery ? [
40800
+ canDeliverDuringProcessing ? copy.partialInProgress : copy.partialDelivery,
40801
+ ...outputStages?.video_generator === "error" || partialVideo?.failedAngles.length ? [
40802
+ media.videos.length ? copy.partialVideosDelivery : copy.partialVideoDelivery
40803
+ ] : [],
40804
+ webLink
40805
+ ].join(" ") : void 0;
40638
40806
  const delivery = {
40639
- ...snapshot,
40807
+ ...statusWithContinuation,
40640
40808
  outputs,
40641
- nextAction: creativeDeliveryNextAction(media, input.viewerLocale, snapshot.landingMode === "code" ? outputs.webappUrl : void 0)
40809
+ ...codeLandingUrl || !hasPartialDelivery ? {
40810
+ nextAction: creativeDeliveryNextAction(media, input.viewerLocale, codeLandingUrl, outputs.videoReviewFailed)
40811
+ } : {}
40642
40812
  };
40643
40813
  return {
40644
40814
  structuredContent: delivery,
@@ -40652,16 +40822,23 @@ ${trackingFallback}`
40652
40822
  },
40653
40823
  {
40654
40824
  type: "text",
40655
- text: renderOutputsMarkdown(outputs)
40825
+ text: renderOutputsMarkdown(outputs, partialMessage, locale)
40656
40826
  },
40657
40827
  ...imageContent,
40658
- ...buildGifResourceLinks(outputs)
40828
+ ...gifLinks,
40829
+ ...continuationText ? [
40830
+ {
40831
+ type: "text",
40832
+ text: continuationText
40833
+ }
40834
+ ] : []
40659
40835
  ]
40660
40836
  };
40661
40837
  } catch (err) {
40662
40838
  const detail = err instanceof Error ? err.stack ?? err.message : String(err);
40663
40839
  process.stderr.write(`mcp get_task_status: fetchTaskOutputs failed for ${input.taskId}: ${detail}
40664
40840
  `);
40841
+ if (hasPartialDelivery) return statusWithoutOutputs;
40665
40842
  const delivery = {
40666
40843
  ...snapshot,
40667
40844
  nextAction: creativeDeliveryNextAction(null, input.viewerLocale)
@@ -42555,6 +42732,7 @@ function registerCreativeTools(server, api, { transport = "http", proxyBaseUrl =
42555
42732
  else {
42556
42733
  wirePayload.pauseForAngleReview = true;
42557
42734
  wirePayload.pauseForVideoScriptReview = true;
42735
+ if (input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE) wirePayload.marketLedVideoDirector = "external_agent";
42558
42736
  }
42559
42737
  return await submitCreative(api, {
42560
42738
  path: "/v1/creatives/videos",
@@ -42803,6 +42981,7 @@ var EstimateCreativeVariantInputBase = z166.object({
42803
42981
  kind: CreativeVariantKindEnum,
42804
42982
  videoPreset: TaskCreativeVariantVideoPresetEnum.optional().describe("Opcional para video. Solo cambia el preset p\xFAblico; el servidor conserva el modelo/tier del task origen."),
42805
42983
  videoResolution: VideoResolutionEnum.optional().describe("Opcional para video. Resoluci\xF3n del nuevo render."),
42984
+ generateAiMusic: z166.boolean().optional().describe("Opcional para video. Incluye m\xFAsica generada en la cotizaci\xF3n."),
42806
42985
  nVariants: z166.number().int().min(1).max(3).optional().describe("Opcional para imagen. N\xFAmero de im\xE1genes adicionales (1-3)."),
42807
42986
  sectionKey: LandingSectionKeyEnum.optional().describe("Opcional para landing. Si ya conoces la secci\xF3n, evita cotizar la clasificaci\xF3n con IA."),
42808
42987
  instructions: z166.string().trim().min(1).max(2e3).optional().describe("Opcional para landing. Si se env\xEDa sin sectionKey, el estimado suma la clasificaci\xF3n pagada con IA.")
@@ -42818,6 +42997,15 @@ var EstimateCreativeVariantInput = EstimateCreativeVariantInputBase.superRefine(
42818
42997
  });
42819
42998
  }
42820
42999
  if (input.kind !== "video") {
43000
+ if (input.generateAiMusic !== void 0) {
43001
+ ctx.addIssue({
43002
+ code: z166.ZodIssueCode.custom,
43003
+ path: [
43004
+ "generateAiMusic"
43005
+ ],
43006
+ message: "generateAiMusic solo aplica a variantes de video."
43007
+ });
43008
+ }
42821
43009
  if (input.videoPreset !== void 0) {
42822
43010
  ctx.addIssue({
42823
43011
  code: z166.ZodIssueCode.custom,
@@ -42870,6 +43058,7 @@ var EstimateCreativeVariantInput = EstimateCreativeVariantInputBase.superRefine(
42870
43058
  var CreateCreativeVariantInputBase = z166.object({
42871
43059
  sourceTaskId: z166.string().guid().describe("ID de la tarea original completada."),
42872
43060
  kind: CreativeVariantKindEnum,
43061
+ maxApprovedCredits: CreateTaskVideoVariantRequest.shape.maxApprovedCredits.describe("Para video, env\xEDa el m\xE1ximo vigente que confirm\xF3 el usuario."),
42873
43062
  confirm: z166.literal(true).describe("Confirmaci\xF3n expl\xEDcita del usuario despu\xE9s de mostrarle el estimado de cr\xE9ditos."),
42874
43063
  clientRequestId: z166.string().guid().describe("UUID estable para esta intenci\xF3n (obligatorio por compatibilidad de contrato; el servidor deriva la identidad real del request desde los argumentos sem\xE1nticos, as\xED que un UUID nuevo en un retry NO crea una variante duplicada). Si la API devuelve status=error, una nueva generaci\xF3n exige otra confirmaci\xF3n."),
42875
43064
  angle: z166.string().trim().min(1).max(500).optional().describe("\xC1ngulo nuevo para video o imagen."),
@@ -42889,6 +43078,15 @@ var CreateCreativeVariantInputBase = z166.object({
42889
43078
  instructions: z166.string().trim().min(1).max(2e3).optional().describe("Solicitud libre para una nueva secci\xF3n de landing. La IA la clasifica si no env\xEDas sectionKey.")
42890
43079
  }).strict();
42891
43080
  var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((input, ctx) => {
43081
+ if (input.kind === "video" && input.maxApprovedCredits === void 0) {
43082
+ ctx.addIssue({
43083
+ code: z166.ZodIssueCode.custom,
43084
+ path: [
43085
+ "maxApprovedCredits"
43086
+ ],
43087
+ message: "Cotiza el video y confirma el m\xE1ximo antes de iniciar."
43088
+ });
43089
+ }
42892
43090
  if ((input.kind === "video" || input.kind === "image") && !input.angle) {
42893
43091
  ctx.addIssue({
42894
43092
  code: z166.ZodIssueCode.custom,
@@ -42920,6 +43118,7 @@ var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((inp
42920
43118
  "instructions"
42921
43119
  ],
42922
43120
  image: [
43121
+ "maxApprovedCredits",
42923
43122
  "scriptNotes",
42924
43123
  "videoPreset",
42925
43124
  "videoResolution",
@@ -42928,6 +43127,7 @@ var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((inp
42928
43127
  "instructions"
42929
43128
  ],
42930
43129
  landing: [
43130
+ "maxApprovedCredits",
42931
43131
  "angle",
42932
43132
  "buyerPersona",
42933
43133
  "scriptNotes",
@@ -42975,7 +43175,8 @@ function estimatePayload(input) {
42975
43175
  kind: input.kind,
42976
43176
  ...input.kind === "video" ? {
42977
43177
  videoPreset: input.videoPreset,
42978
- videoResolution: input.videoResolution
43178
+ videoResolution: input.videoResolution,
43179
+ generateAiMusic: input.generateAiMusic
42979
43180
  } : input.kind === "image" ? {
42980
43181
  nVariants: input.nVariants
42981
43182
  } : {
@@ -43009,19 +43210,21 @@ function registerCreativeVariantTools(server, api) {
43009
43210
  }
43010
43211
  });
43011
43212
  server.registerTool("create_creative_variant", {
43012
- description: createCreativeVariantGuidance.summary + " ES UNA ACCI\xD3N DE PAGO: primero llama estimate_creative_variant, muestra el rango de cr\xE9ditos al usuario y solo despu\xE9s invoca este tool con confirm=true. Las recomendaciones IA tambi\xE9n son acciones pagas a 2x del costo real. clientRequestId es obligatorio por contrato: genera un UUID por intenci\xF3n. El servidor deriva la identidad real del request desde los argumentos sem\xE1nticos, as\xED que un UUID nuevo NO desbloquea un intento distinto \u2014 si recibes status=error, pide confirmaci\xF3n al usuario y reinvoca con los mismos argumentos. Reutiliza el producto y referencias del task origen; crea un child task independiente y devuelve variantTaskId. Para landing puedes enviar instructions en texto libre y omitir sectionKey: el backend lo clasifica con IA. No expone ni permite cambiar videoModel, videoTier, videoStyle o narrativeStyle; esos valores se heredan del task origen. Para un video nuevo de un producto ya anunciado, si estimate_creative_variant devolvi\xF3 creativeMemory, propone primero el \xE1ngulo (angle = suggestedAngle) y el videoPreset ganadores y ofrece 1-2 formatos \xABNuevo\xBB; un \xE1ngulo o formato que descansa se puede usar solo si el usuario lo pide sabiendo que perdi\xF3.",
43213
+ description: createCreativeVariantGuidance.summary + " Para video env\xEDa el m\xE1ximo revisado y confirmado en maxApprovedCredits. ES UNA ACCI\xD3N DE PAGO: primero llama estimate_creative_variant, muestra el rango de cr\xE9ditos al usuario y solo despu\xE9s invoca este tool con confirm=true. Las recomendaciones IA tambi\xE9n son acciones pagas a 2x del costo real. clientRequestId es obligatorio por contrato: genera un UUID por intenci\xF3n. El servidor deriva la identidad real del request desde los argumentos sem\xE1nticos, as\xED que un UUID nuevo NO desbloquea un intento distinto \u2014 si recibes status=error, pide confirmaci\xF3n al usuario y reinvoca con los mismos argumentos. Reutiliza el producto y referencias del task origen; crea un child task independiente y devuelve variantTaskId. Para landing puedes enviar instructions en texto libre y omitir sectionKey: el backend lo clasifica con IA. No expone ni permite cambiar videoModel, videoTier, videoStyle o narrativeStyle; esos valores se heredan del task origen. Para un video nuevo de un producto ya anunciado, si estimate_creative_variant devolvi\xF3 creativeMemory, propone primero el \xE1ngulo (angle = suggestedAngle) y el videoPreset ganadores y ofrece 1-2 formatos \xABNuevo\xBB; un \xE1ngulo o formato que descansa se puede usar solo si el usuario lo pide sabiendo que perdi\xF3.",
43013
43214
  inputSchema: CreateCreativeVariantInputBase.shape,
43014
43215
  annotations: CREATES_PAID
43015
43216
  }, async (input) => {
43016
43217
  let sourceTaskId;
43218
+ let estimateInput;
43017
43219
  try {
43018
43220
  const validatedInput = parseVariantInput(CreateCreativeVariantInput, input);
43019
43221
  sourceTaskId = validatedInput.sourceTaskId;
43020
- const estimateInput = EstimateCreativeVariantInput.parse({
43222
+ estimateInput = EstimateCreativeVariantInput.parse({
43021
43223
  sourceTaskId: validatedInput.sourceTaskId,
43022
43224
  kind: validatedInput.kind,
43023
43225
  videoPreset: validatedInput.videoPreset,
43024
43226
  videoResolution: validatedInput.videoResolution,
43227
+ generateAiMusic: validatedInput.generateAiMusic,
43025
43228
  nVariants: validatedInput.nVariants,
43026
43229
  sectionKey: validatedInput.sectionKey,
43027
43230
  instructions: validatedInput.instructions
@@ -43041,12 +43244,11 @@ function registerCreativeVariantTools(server, api) {
43041
43244
  });
43042
43245
  sectionKey = LandingSectionKeyEnum.parse(recommendation.value);
43043
43246
  }
43247
+ const { maxApprovedCredits, ...intent } = validatedInput;
43044
43248
  const derivedClientRequestId = derivePaidRequestKey({
43045
43249
  fingerprint: api.fingerprint(),
43046
43250
  tool: "create_creative_variant",
43047
- input: {
43048
- ...validatedInput
43049
- },
43251
+ input: intent,
43050
43252
  nowMs: Date.now()
43051
43253
  });
43052
43254
  const payload = {
@@ -43060,6 +43262,7 @@ function registerCreativeVariantTools(server, api) {
43060
43262
  instructions: validatedInput.instructions
43061
43263
  },
43062
43264
  ...validatedInput.kind === "video" ? {
43265
+ maxApprovedCredits,
43063
43266
  scriptNotes: validatedInput.scriptNotes,
43064
43267
  videoPreset: validatedInput.videoPreset,
43065
43268
  videoResolution: validatedInput.videoResolution,
@@ -43085,6 +43288,23 @@ function registerCreativeVariantTools(server, api) {
43085
43288
  estimate
43086
43289
  });
43087
43290
  } catch (error) {
43291
+ if (estimateInput && error instanceof ApiHttpError && error.status === 409 && isRecord3(error.body) && error.body.code === "CREATIVE_VARIANT_QUOTE_CHANGED" && typeof error.body.estimatedMaxCostCredits === "number") {
43292
+ return {
43293
+ ...asText({
43294
+ error: {
43295
+ code: error.body.code,
43296
+ message: "La cotizaci\xF3n del video cambi\xF3.",
43297
+ estimatedMaxCostCredits: error.body.estimatedMaxCostCredits
43298
+ },
43299
+ nextAction: {
43300
+ tool: "estimate_creative_variant",
43301
+ arguments: estimateInput,
43302
+ instruction: "Vuelve a cotizar esta misma versi\xF3n y pide confirmaci\xF3n del m\xE1ximo vigente antes de iniciarla."
43303
+ }
43304
+ }),
43305
+ isError: true
43306
+ };
43307
+ }
43088
43308
  const translated = translateError(error);
43089
43309
  if (!sourceTaskId) throw translated;
43090
43310
  const details = isRecord3(translated.data) ? translated.data : {};
@@ -47125,6 +47345,7 @@ function buildMarketStudyEstimateRequests(input) {
47125
47345
  const productImageCount = input.productImageCount !== void 0 ? {
47126
47346
  productImageCount: input.productImageCount
47127
47347
  } : {};
47348
+ const guidedMarketLedVideo = quotesVideo && input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && resolveConversationalReviewPolicy(input.aiDecidesAll).pauseForAngleReview;
47128
47349
  const common = {
47129
47350
  nVideos: input.videoAngleCount,
47130
47351
  durationSeconds: input.durationSeconds,
@@ -47134,12 +47355,14 @@ function buildMarketStudyEstimateRequests(input) {
47134
47355
  videoPreset: "auto",
47135
47356
  generateAiMusic: input.generateAiMusic ?? false,
47136
47357
  generateAiEdit: input.generateAiEdit ?? false,
47358
+ ...guidedMarketLedVideo ? {
47359
+ marketLedVideoDirector: "external_agent"
47360
+ } : {},
47137
47361
  ...productImageCount,
47138
47362
  ...input.replicateWinnerWhenFound !== void 0 ? {
47139
47363
  replicateWinnerWhenFound: input.replicateWinnerWhenFound
47140
47364
  } : {}
47141
47365
  };
47142
- const marketLedStudy = quotesVideo && input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && resolveConversationalReviewPolicy(input.aiDecidesAll).pauseForAngleReview;
47143
47366
  if (input.kind === "video") {
47144
47367
  const build2 = /* @__PURE__ */ __name((study) => ({
47145
47368
  type: "video-creative",
@@ -47153,7 +47376,7 @@ function buildMarketStudyEstimateRequests(input) {
47153
47376
  competitorScanEnabled: study,
47154
47377
  competitorCommercialStudyRequested: study,
47155
47378
  requiresCompetitorScan: study,
47156
- ...study && marketLedStudy ? {
47379
+ ...study && guidedMarketLedVideo ? {
47157
47380
  marketLedDeferredCopy: true
47158
47381
  } : {}
47159
47382
  }
@@ -47185,7 +47408,7 @@ function buildMarketStudyEstimateRequests(input) {
47185
47408
  ugcFormat: resolveVideoFormatForDuration(input.durationSeconds === 30 ? 30 : 15),
47186
47409
  competitorScanEnabled: study,
47187
47410
  competitorCommercialStudyRequested: study && videoGeneratorEnabled,
47188
- ...study && marketLedStudy ? {
47411
+ ...study && guidedMarketLedVideo ? {
47189
47412
  marketLedDeferredCopy: true
47190
47413
  } : {}
47191
47414
  }