@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/http.js CHANGED
@@ -8547,7 +8547,7 @@ var scenes = z19.array(MarketLedVideoSceneSchema).min(2).max(40).superRefine((sh
8547
8547
  if (shot.characterId) anchored.add(shot.characterId);
8548
8548
  }
8549
8549
  });
8550
- var quoteDirectorChoice = z19.enum([
8550
+ var MarketLedVideoDirectorSchema = z19.enum([
8551
8551
  "productmaker",
8552
8552
  "external_agent"
8553
8553
  ]);
@@ -8560,7 +8560,7 @@ var marketLedVideoWalletRecoveryPolicy = z19.literal(MARKET_LED_VIDEO_WALLET_REC
8560
8560
  var MarketLedVideoStateSchema = z19.object({
8561
8561
  recoveryDebitPolicy: marketLedVideoWalletRecoveryPolicy.optional(),
8562
8562
  director: z19.literal("external_agent").optional(),
8563
- quoteDirector: quoteDirectorChoice.optional(),
8563
+ quoteDirector: MarketLedVideoDirectorSchema.optional(),
8564
8564
  phase: z19.enum([
8565
8565
  "angles",
8566
8566
  "formats",
@@ -8748,13 +8748,13 @@ var MarketLedVideoCommandSchema = z19.discriminatedUnion("type", [
8748
8748
  z19.object({
8749
8749
  type: z19.literal("submit_storyboards"),
8750
8750
  revision,
8751
- director: quoteDirectorChoice.optional(),
8751
+ director: MarketLedVideoDirectorSchema.optional(),
8752
8752
  pieces: z19.array(MarketLedVideoAuthoredPieceSchema).min(1).max(MARKET_LED_VIDEO_BATCH_LIMIT)
8753
8753
  }).strict(),
8754
8754
  z19.object({
8755
8755
  type: z19.literal("save_scripts"),
8756
8756
  revision,
8757
- director: quoteDirectorChoice.optional(),
8757
+ director: MarketLedVideoDirectorSchema.optional(),
8758
8758
  pieces: z19.array(scriptEdit).min(1).max(MARKET_LED_VIDEO_BATCH_LIMIT)
8759
8759
  }).strict(),
8760
8760
  z19.object({
@@ -13575,6 +13575,8 @@ var IngestOptions = z42.object({
13575
13575
  /** Canonical public route axes; legacy provider fields remain compatibility aliases. */
13576
13576
  videoStructure: VideoStructure.optional(),
13577
13577
  videoQuality: VideoQuality.optional(),
13578
+ /** Direction supplied by the agent for guided Multiescena. */
13579
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
13578
13580
  videoModel: VideoModel.default("veo").nonoptional(),
13579
13581
  /**
13580
13582
  * An explicit registry model id for Free mode (Defect 1, follow-up to the
@@ -16032,6 +16034,8 @@ var IngestEstimationOptions = z55.object({
16032
16034
  var IngestResumeEstimationOptions = z55.object({
16033
16035
  /** Autopilot quotes before creation share new video admission. Saved resumes omit this. */
16034
16036
  forNewVideo: z55.literal(true).optional(),
16037
+ /** Direction supplied by the agent for a new guided Multiescena. */
16038
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
16035
16039
  /** The guided market-led intake quotes reference preparation separately. */
16036
16040
  marketLedDeferredCopy: z55.literal(true).optional(),
16037
16041
  sourceProductUrl: z55.string().max(4096).optional(),
@@ -16144,6 +16148,7 @@ var VideoCreativeEstimationOptions = z55.object({
16144
16148
  competitorScanEnabled: z55.boolean().optional(),
16145
16149
  /** Explicit consent for the paid deep commercial study and market planner. */
16146
16150
  competitorCommercialStudyRequested: z55.boolean().optional(),
16151
+ marketLedVideoDirector: MarketLedVideoDirectorSchema.optional(),
16147
16152
  marketLedDeferredCopy: z55.literal(true).optional(),
16148
16153
  replicateWinnerWhenFound: z55.boolean().optional(),
16149
16154
  automaticVideoFormats: AutomaticVideoFormatsSchema.optional(),
@@ -17550,7 +17555,8 @@ var CreateTaskVideoVariantRequest = CreateTaskCreativeVariantBase.extend({
17550
17555
  videoPreset: TaskCreativeVariantVideoPreset.optional(),
17551
17556
  ugcFormat: VideoFormat.optional(),
17552
17557
  videoResolution: VideoResolution.optional(),
17553
- generateAiMusic: z58.boolean().optional()
17558
+ generateAiMusic: z58.boolean().optional(),
17559
+ maxApprovedCredits: z58.number().int().positive().optional()
17554
17560
  }).strict();
17555
17561
  var CreateTaskImageVariantRequest = CreateTaskCreativeVariantBase.extend({
17556
17562
  kind: z58.literal("image"),
@@ -17577,7 +17583,8 @@ var EstimateTaskCreativeVariantRequest = z58.discriminatedUnion("kind", [
17577
17583
  z58.object({
17578
17584
  kind: z58.literal("video"),
17579
17585
  videoPreset: TaskCreativeVariantVideoPreset.optional(),
17580
- videoResolution: VideoResolution.optional()
17586
+ videoResolution: VideoResolution.optional(),
17587
+ generateAiMusic: z58.boolean().optional()
17581
17588
  }).strict(),
17582
17589
  z58.object({
17583
17590
  kind: z58.literal("image"),
@@ -27408,7 +27415,7 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27408
27415
  // MCP 8.10.0: storyteller family blocked (BLOCKED_NARRATIVE_STYLES).
27409
27416
  // MCP 9.1.0: combine current animated-video controls and initial GIF choice.
27410
27417
  // MCP 12.8.0: + manual-only, cohort-gated «viral» preset/angle narrative.
27411
- "bfe5130b1941f5f0a690949411d83cdbd32c1ee65cc75f2c22568b87bfe90a42",
27418
+ "0d6cfdb4d48aa60eae18e27e4b735145a61cecc8acad052f2465dc673c00b6d3",
27412
27419
  "credit_consuming",
27413
27420
  "creative",
27414
27421
  [
@@ -27423,7 +27430,8 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27423
27430
  "kind"
27424
27431
  ]),
27425
27432
  slot("confirmation", true, [
27426
- "confirm"
27433
+ "confirm",
27434
+ "maxApprovedCredits"
27427
27435
  ], [], "confirmation"),
27428
27436
  slot("idempotency", true, [
27429
27437
  "clientRequestId"
@@ -27686,7 +27694,7 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27686
27694
  defineCapability(
27687
27695
  "estimate_creative_variant",
27688
27696
  // MCP 12.8.0: + manual-only, cohort-gated «viral» preset/angle narrative.
27689
- "743d227d050dab27a8b385c9bc2c0c2d5b450e22abfed811c344b65faffb29ab",
27697
+ "16f9f648c61371bb4be138c6026e2f88052ee5d9a3b6e541b100c91a386a9408",
27690
27698
  "none",
27691
27699
  "read_only",
27692
27700
  [
@@ -27705,7 +27713,10 @@ var PRODUCTMAKER_CAPABILITY_REGISTRY = deepFreeze([
27705
27713
  "nVariants",
27706
27714
  "sectionKey",
27707
27715
  "instructions"
27708
- ])
27716
+ ]),
27717
+ slot("video_music", false, [
27718
+ "generateAiMusic"
27719
+ ], [])
27709
27720
  ],
27710
27721
  [
27711
27722
  "task",
@@ -37355,7 +37366,7 @@ function registerGuidedStepApp(server, capture) {
37355
37366
  __name(registerGuidedStepApp, "registerGuidedStepApp");
37356
37367
 
37357
37368
  // src/index.ts
37358
- var MCP_VERSION = "12.45.0";
37369
+ var MCP_VERSION = "12.46.0";
37359
37370
 
37360
37371
  // src/guided-form-http.ts
37361
37372
  var MODERN_VERSION = "2026-07-28";
@@ -39728,7 +39739,13 @@ function formatCredits(creditCents) {
39728
39739
  __name(formatCredits, "formatCredits");
39729
39740
 
39730
39741
  // src/tools/task-outputs.ts
39731
- function creativeDeliveryNextAction(media, locale = "es", codeLandingUrl) {
39742
+ function creativeDeliveryNextAction(media, locale = "es", codeLandingUrl, videoReviewRequired = false) {
39743
+ if (videoReviewRequired) {
39744
+ return {
39745
+ kind: "review_creatives",
39746
+ question: OUTPUT_MARKDOWN_COPY[locale].reviewVideoQuestion
39747
+ };
39748
+ }
39732
39749
  if (codeLandingUrl) {
39733
39750
  return {
39734
39751
  kind: "review_code_landing",
@@ -39908,7 +39925,20 @@ function sanitizeFilename(s) {
39908
39925
  }
39909
39926
  __name(sanitizeFilename, "sanitizeFilename");
39910
39927
  async function fetchTaskOutputs(api, taskId, options) {
39911
- const raw = await api.getJson(`/v1/results/${encodeURIComponent(taskId)}?signedUrls=true`, options);
39928
+ const { partialDelivery, ...requestOptions } = options ?? {};
39929
+ const raw = await api.getJson(`/v1/results/${encodeURIComponent(taskId)}?signedUrls=true`, requestOptions);
39930
+ if (partialDelivery) {
39931
+ return projectTaskOutputs({
39932
+ videoGenerators: raw.videoGenerators?.filter((video) => video.status === "success"),
39933
+ ...partialDelivery.landingReady ? {
39934
+ landing: raw.landing,
39935
+ creativeVariants: raw.creativeVariants
39936
+ } : {},
39937
+ ...partialDelivery.imageReady ? {
39938
+ adCreative: raw.adCreative
39939
+ } : {}
39940
+ }, taskId);
39941
+ }
39912
39942
  const creativeVariants = (raw.creativeVariants ?? []).flatMap((child) => {
39913
39943
  const identity2 = CreativeVariantIdentity.safeParse(child);
39914
39944
  if (!identity2.success || identity2.data.sourceTaskId !== taskId) return [];
@@ -39942,16 +39972,30 @@ __name(fetchTaskOutputs, "fetchTaskOutputs");
39942
39972
  function applyMarketLedVideoReview(outputs, marketLedVideo) {
39943
39973
  const draft = MarketLedVideoStateSchema.safeParse(marketLedVideo);
39944
39974
  if (!draft.success) return outputs;
39945
- const flagged = draft.data.pieces.filter(({ selected, renderStatus, qualityReviewRequired, resultAngleKey }) => selected !== false && resultAngleKey !== void 0 && (renderStatus === "failed" || qualityReviewRequired));
39946
- if (!flagged.length) return outputs;
39947
- const angleKeys = new Set(flagged.map(({ resultAngleKey }) => resultAngleKey));
39975
+ const piecesByAngle = new Map(draft.data.pieces.flatMap((piece) => piece.selected !== false && piece.resultAngleKey ? [
39976
+ [
39977
+ piece.resultAngleKey,
39978
+ piece
39979
+ ]
39980
+ ] : []));
39981
+ const reviewAngles = new Set(Array.from(piecesByAngle).filter(([, piece]) => piece.renderStatus === "failed" || piece.qualityReviewRequired).map(([angleKey]) => angleKey));
39982
+ const videos = outputs.videos.map((video) => {
39983
+ const piece = piecesByAngle.get(video.angleKey);
39984
+ if (!piece) return video;
39985
+ return {
39986
+ ...video,
39987
+ requestedDurationSeconds: piece.durationSeconds,
39988
+ ...reviewAngles.has(video.angleKey) ? {
39989
+ reviewFailed: true
39990
+ } : {}
39991
+ };
39992
+ });
39948
39993
  return {
39949
39994
  ...outputs,
39950
- videoReviewFailed: true,
39951
- videos: outputs.videos.map((video) => angleKeys.has(video.angleKey) ? {
39952
- ...video,
39953
- reviewFailed: true
39954
- } : video)
39995
+ ...reviewAngles.size > 0 ? {
39996
+ videoReviewFailed: true
39997
+ } : {},
39998
+ videos
39955
39999
  };
39956
40000
  }
39957
40001
  __name(applyMarketLedVideoReview, "applyMarketLedVideoReview");
@@ -39968,6 +40012,9 @@ function projectTaskOutputs(raw, taskId) {
39968
40012
  return {
39969
40013
  angleKey: vg.angleKey ?? "",
39970
40014
  angleIndex: vg.angleIndex ?? 0,
40015
+ ...typeof vg.durationSeconds === "number" && Number.isFinite(vg.durationSeconds) && vg.durationSeconds > 0 ? {
40016
+ durationSeconds: vg.durationSeconds
40017
+ } : {},
39971
40018
  ...vg.marketVideoFormatLabel ? {
39972
40019
  marketVideoFormatLabel: vg.marketVideoFormatLabel
39973
40020
  } : {},
@@ -40044,15 +40091,57 @@ function projectTaskOutputs(raw, taskId) {
40044
40091
  };
40045
40092
  }
40046
40093
  __name(projectTaskOutputs, "projectTaskOutputs");
40047
- function renderOutputsMarkdown(outputs) {
40048
- const parts = [];
40049
- 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})`);
40094
+ var OUTPUT_MARKDOWN_COPY = {
40095
+ es: {
40096
+ download: "Descargar",
40097
+ variant: "variante",
40098
+ variants: "variantes",
40099
+ sections: "secciones",
40100
+ gif: "GIF de producto",
40101
+ gifPreview: "Vista est\xE1tica del GIF",
40102
+ unapproved: " \xB7 No aprobado",
40103
+ 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.",
40104
+ ready: "Tu tarea est\xE1 lista",
40105
+ reviewFailed: "Hay videos que no pasaron la revisi\xF3n",
40106
+ durationDifference: /* @__PURE__ */ __name((delivered, requested) => `Duraci\xF3n entregada: ${delivered} s. Duraci\xF3n solicitada: ${requested} s.`, "durationDifference"),
40107
+ reviewVideoQuestion: "\xBFQuieres que cotice una correcci\xF3n para el video que necesita revisi\xF3n?",
40108
+ openTask: "Abrir en Product Maker",
40109
+ variantOf: "Variante de",
40110
+ image: "imagen",
40111
+ variantFailed: "No se pudo entregar esta variante.",
40112
+ variantPending: "La variante sigue gener\xE1ndose. Consulta su estado antes de iniciar otra."
40113
+ },
40114
+ en: {
40115
+ download: "Download",
40116
+ variant: "version",
40117
+ variants: "versions",
40118
+ sections: "sections",
40119
+ gif: "Product GIF",
40120
+ gifPreview: "GIF preview",
40121
+ unapproved: " \xB7 Not approved",
40122
+ 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.",
40123
+ ready: "Your task is ready",
40124
+ reviewFailed: "Some videos did not pass review",
40125
+ durationDifference: /* @__PURE__ */ __name((delivered, requested) => `Delivered duration: ${delivered} s. Requested duration: ${requested} s.`, "durationDifference"),
40126
+ reviewVideoQuestion: "Would you like a quote to fix the video that needs review?",
40127
+ openTask: "Open in ProductMaker",
40128
+ variantOf: "Variation of",
40129
+ image: "image",
40130
+ variantFailed: "This variation could not be delivered.",
40131
+ variantPending: "This variation is still being generated. Check its status before starting another."
40132
+ }
40133
+ };
40134
+ function renderOutputsMarkdown(outputs, introduction, locale = "es") {
40135
+ const copy = OUTPUT_MARKDOWN_COPY[locale];
40136
+ const parts = [
40137
+ introduction ?? (outputs.videoReviewFailed ? `\u26A0\uFE0F **${copy.reviewFailed}** \u2014 [${copy.openTask}](${outputs.webappUrl})` : `\u2705 **${copy.ready}** \u2014 [${copy.openTask}](${outputs.webappUrl})`)
40138
+ ];
40050
40139
  if (outputs.images.length) {
40051
40140
  parts.push(`
40052
- ### Ad creative (${outputs.images.length} ${outputs.images.length === 1 ? "variante" : "variantes"})`);
40141
+ ### Ad creative (${outputs.images.length} ${outputs.images.length === 1 ? copy.variant : copy.variants})`);
40053
40142
  outputs.images.forEach((img, i) => {
40054
40143
  parts.push(`![v${i}](${img.url})`);
40055
- parts.push(`[\u2B07 Descargar v${i}](${img.url})`);
40144
+ parts.push(`[\u2B07 ${copy.download} v${i}](${img.url})`);
40056
40145
  if (img.adCopy) parts.push(`Copy: ${img.adCopy}`);
40057
40146
  });
40058
40147
  }
@@ -40062,39 +40151,42 @@ function renderOutputsMarkdown(outputs) {
40062
40151
  }
40063
40152
  if (outputs.landing.sections.length) {
40064
40153
  parts.push(`
40065
- ### Landing (${outputs.landing.sections.length} secciones)`);
40154
+ ### Landing (${outputs.landing.sections.length} ${copy.sections})`);
40066
40155
  for (const s of outputs.landing.sections) {
40067
40156
  parts.push(`![${escapeMdLabel(s.role)}](${s.url})`);
40068
- parts.push(`[\u2B07 Descargar ${escapeMdLabel(s.role)}](${s.url})`);
40157
+ parts.push(`[\u2B07 ${copy.download} ${escapeMdLabel(s.role)}](${s.url})`);
40069
40158
  }
40070
40159
  }
40071
40160
  for (const gif of outputGifs(outputs)) {
40072
40161
  parts.push(`
40073
- ### GIF de producto (${gif.durationSeconds}s \xB7 QA: ${gif.quality.verdict})`);
40074
- parts.push(`![Vista est\xE1tica del GIF](${gif.posterUrl})`);
40075
- parts.push(`[\u2B07 Descargar GIF](${gif.gifUrl})`);
40162
+ ### ${copy.gif} (${gif.durationSeconds}s \xB7 QA: ${gif.quality.verdict})`);
40163
+ parts.push(`![${copy.gifPreview}](${gif.posterUrl})`);
40164
+ parts.push(`[\u2B07 ${copy.download} GIF](${gif.gifUrl})`);
40076
40165
  }
40077
40166
  if (outputs.videos.length) {
40078
40167
  parts.push("\n### Video");
40079
40168
  for (const v of outputs.videos) {
40169
+ if (v.durationSeconds && v.requestedDurationSeconds && v.durationSeconds !== v.requestedDurationSeconds) {
40170
+ parts.push(copy.durationDifference(v.durationSeconds, v.requestedDurationSeconds));
40171
+ }
40080
40172
  for (const variant of v.variants) {
40081
- parts.push(`- [${escapeMdLabel(v.marketVideoFormatLabel ?? v.angleKey)} \xB7 ${escapeMdLabel(variant.kind)}${v.reviewFailed ? " \xB7 No aprobado" : ""}](${variant.url})`);
40173
+ parts.push(`- [${escapeMdLabel(v.marketVideoFormatLabel ?? v.angleKey)} \xB7 ${escapeMdLabel(variant.kind)}${v.reviewFailed ? copy.unapproved : ""}](${variant.url})`);
40082
40174
  }
40083
40175
  if (v.scriptRewritten) {
40084
- 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.`);
40176
+ parts.push(copy.rewritten);
40085
40177
  }
40086
40178
  }
40087
40179
  }
40088
40180
  for (const child of outputs.creativeVariants ?? []) {
40089
- const label2 = child.kind === "image" ? "imagen" : child.kind;
40181
+ const label2 = child.kind === "image" ? copy.image : child.kind;
40090
40182
  parts.push(`
40091
- ### Variante de ${label2}`);
40183
+ ### ${copy.variantOf} ${label2}`);
40092
40184
  if (child.status === "done" && child.outputs) {
40093
- parts.push(renderOutputsMarkdown(child.outputs));
40185
+ parts.push(renderOutputsMarkdown(child.outputs, void 0, locale));
40094
40186
  } else if (child.status === "error") {
40095
- parts.push(escapeMarkdownText(child.error ?? "No se pudo entregar esta variante."));
40187
+ parts.push(escapeMarkdownText(child.error ?? copy.variantFailed));
40096
40188
  } else {
40097
- parts.push("La variante sigue gener\xE1ndose. Consulta su estado antes de iniciar otra.");
40189
+ parts.push(copy.variantPending);
40098
40190
  }
40099
40191
  }
40100
40192
  return parts.join("\n");
@@ -41527,6 +41619,11 @@ var MARKET_LED_REVIEW_QUESTIONS = {
41527
41619
  en: "Do you approve the script or want to change anything?"
41528
41620
  }
41529
41621
  };
41622
+ var TaskOutputStageStatuses = z162.object({
41623
+ landing: z162.string().optional(),
41624
+ creative: z162.string().optional(),
41625
+ video_generator: z162.string().optional()
41626
+ });
41530
41627
  var TASK_STATUS_COPY = {
41531
41628
  es: {
41532
41629
  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.",
@@ -41537,6 +41634,12 @@ var TASK_STATUS_COPY = {
41537
41634
  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:",
41538
41635
  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.",
41539
41636
  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.",
41637
+ terminalFailure: "No pudimos terminar esta tarea.",
41638
+ partialDelivery: "Parte de tu contenido est\xE1 lista. Te muestro las piezas disponibles.",
41639
+ partialInProgress: "Estas piezas ya est\xE1n listas. El resto sigue en preparaci\xF3n.",
41640
+ continueVideoRepair: "Consulta el video de esta misma tarea para comprobar si alguna toma necesita un ajuste.",
41641
+ partialVideoDelivery: "El video no se pudo terminar.",
41642
+ partialVideosDelivery: "Algunos videos no se pudieron terminar.",
41540
41643
  openTask: "Abrir esta tarea en ProductMaker"
41541
41644
  },
41542
41645
  en: {
@@ -41548,6 +41651,12 @@ var TASK_STATUS_COPY = {
41548
41651
  trackingFallback: "If the turn ends before the next question, explain the current progress and share this link to follow the same task:",
41549
41652
  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.",
41550
41653
  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.",
41654
+ terminalFailure: "We could not finish this task.",
41655
+ partialDelivery: "Part of your content is ready. Here are the pieces available now.",
41656
+ partialInProgress: "These pieces are ready. The rest is still in progress.",
41657
+ continueVideoRepair: "Check the video draft for this task to see if a shot needs an adjustment.",
41658
+ partialVideoDelivery: "The video could not be completed.",
41659
+ partialVideosDelivery: "Some videos could not be completed.",
41551
41660
  openTask: "Open this task in ProductMaker"
41552
41661
  }
41553
41662
  };
@@ -42072,6 +42181,7 @@ function registerTaskTools(server, api, { proxyBaseUrl = null, transport = "http
42072
42181
  "options.narrativeStyle": resolved?.narrativeStyle,
42073
42182
  "options.videoTier": wireTier,
42074
42183
  "options.videoStructure": videoStructure,
42184
+ "options.marketLedVideoDirector": selectedOutputs.includes("video") && videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && reviewPolicy.pauseForAngleReview ? "external_agent" : void 0,
42075
42185
  "options.videoQuality": input.videoQuality,
42076
42186
  "options.ugcFormat": resolveVideoFormatForDuration(input.durationSeconds),
42077
42187
  "options.videoResolution": input.videoResolution,
@@ -42277,13 +42387,21 @@ function registerTaskTools(server, api, { proxyBaseUrl = null, transport = "http
42277
42387
  } : {}
42278
42388
  }
42279
42389
  };
42280
- if (snapshot.status !== "done") {
42281
- const locale = input.viewerLocale ?? "es";
42282
- const copy = TASK_STATUS_COPY[locale];
42283
- const webLink = `[${copy.openTask}](${taskWebUrl(input.taskId, locale)})`;
42390
+ const marketAction = readMarketLedVideoNextAction(snapshot);
42391
+ const productTask = snapshot.kind !== "service";
42392
+ const failedProductTask = snapshot.status === "error" && productTask;
42393
+ const canDeliverDuringProcessing = snapshot.status === "processing" && productTask && !openReview && snapshot.pendingUserAction == null && !marketAction?.phase && !readVideoScriptReviewNextAction(snapshot);
42394
+ const outputStages = failedProductTask || canDeliverDuringProcessing ? TaskOutputStageStatuses.safeParse(snapshot.stageStatuses).data : void 0;
42395
+ const partialVideo = failedProductTask ? StatusResponse.shape.partialVideoResult.safeParse(snapshot.partialVideoResult).data : void 0;
42396
+ const landingReady = outputStages?.landing === "success";
42397
+ const imageReady = outputStages?.creative === "success";
42398
+ const hasPartialDelivery = landingReady || imageReady || outputStages?.video_generator === "success" || Boolean(partialVideo?.successAngles.length);
42399
+ const locale = input.viewerLocale ?? "es";
42400
+ const copy = TASK_STATUS_COPY[locale];
42401
+ const webLink = `[${copy.openTask}](${taskWebUrl(input.taskId, locale)})`;
42402
+ if (snapshot.status !== "done" && !hasPartialDelivery) {
42284
42403
  const reviewFallback = `${copy.reviewFallback} ${webLink}`;
42285
42404
  const trackingFallback = `${copy.trackingFallback} ${webLink}`;
42286
- const marketAction = readMarketLedVideoNextAction(snapshot);
42287
42405
  if (marketAction && (marketAction.phase || !openReview)) {
42288
42406
  const { phase, scriptPreparationFailed, ...reviewNextAction } = marketAction;
42289
42407
  const { pendingUserAction: _legacyAction, ...current } = snapshot;
@@ -42512,9 +42630,47 @@ ${trackingFallback}`
42512
42630
  ]
42513
42631
  };
42514
42632
  }
42633
+ const pollingContinuation = canDeliverDuringProcessing ? buildPollingContinuation(snapshot) : null;
42634
+ const repairAction = canDeliverDuringProcessing && marketAction?.kind === "check_market_led_video_repair" ? {
42635
+ reviewNextAction: {
42636
+ kind: marketAction.kind,
42637
+ tool: marketAction.tool,
42638
+ arguments: marketAction.arguments
42639
+ }
42640
+ } : {};
42641
+ const statusWithContinuation = {
42642
+ ...snapshot,
42643
+ ...pollingContinuation ? {
42644
+ pollingContinuation
42645
+ } : {},
42646
+ ...repairAction
42647
+ };
42648
+ const continuationText = [
42649
+ "reviewNextAction" in repairAction ? copy.continueVideoRepair : null,
42650
+ pollingContinuation?.instruction
42651
+ ].filter(Boolean).join("\n\n");
42652
+ const statusWithoutOutputs = {
42653
+ structuredContent: statusWithContinuation,
42654
+ content: [
42655
+ {
42656
+ type: "text",
42657
+ text: [
42658
+ failedProductTask ? copy.terminalFailure : continuationText,
42659
+ webLink
42660
+ ].filter(Boolean).join("\n\n")
42661
+ }
42662
+ ],
42663
+ _meta: statusMeta
42664
+ };
42515
42665
  try {
42516
42666
  const rawOutputs = await fetchTaskOutputs(api, input.taskId, {
42517
- signal
42667
+ signal,
42668
+ ...hasPartialDelivery ? {
42669
+ partialDelivery: {
42670
+ landingReady,
42671
+ imageReady
42672
+ }
42673
+ } : {}
42518
42674
  });
42519
42675
  const imageContent = await buildMcpGeneratedImageContent(rawOutputs.images.map((image2, i) => ({
42520
42676
  url: image2.url,
@@ -42543,10 +42699,24 @@ ${trackingFallback}`
42543
42699
  }))),
42544
42700
  links: []
42545
42701
  };
42702
+ const codeLandingUrl = snapshot.landingMode === "code" && (!hasPartialDelivery || landingReady) ? outputs.webappUrl : void 0;
42703
+ const gifLinks = buildGifResourceLinks(outputs);
42704
+ if (hasPartialDelivery && !media.images.length && !media.videos.length && !media.landingSections.length && !gifLinks.length && !codeLandingUrl) {
42705
+ return statusWithoutOutputs;
42706
+ }
42707
+ const partialMessage = hasPartialDelivery ? [
42708
+ canDeliverDuringProcessing ? copy.partialInProgress : copy.partialDelivery,
42709
+ ...outputStages?.video_generator === "error" || partialVideo?.failedAngles.length ? [
42710
+ media.videos.length ? copy.partialVideosDelivery : copy.partialVideoDelivery
42711
+ ] : [],
42712
+ webLink
42713
+ ].join(" ") : void 0;
42546
42714
  const delivery = {
42547
- ...snapshot,
42715
+ ...statusWithContinuation,
42548
42716
  outputs,
42549
- nextAction: creativeDeliveryNextAction(media, input.viewerLocale, snapshot.landingMode === "code" ? outputs.webappUrl : void 0)
42717
+ ...codeLandingUrl || !hasPartialDelivery ? {
42718
+ nextAction: creativeDeliveryNextAction(media, input.viewerLocale, codeLandingUrl, outputs.videoReviewFailed)
42719
+ } : {}
42550
42720
  };
42551
42721
  return {
42552
42722
  structuredContent: delivery,
@@ -42560,16 +42730,23 @@ ${trackingFallback}`
42560
42730
  },
42561
42731
  {
42562
42732
  type: "text",
42563
- text: renderOutputsMarkdown(outputs)
42733
+ text: renderOutputsMarkdown(outputs, partialMessage, locale)
42564
42734
  },
42565
42735
  ...imageContent,
42566
- ...buildGifResourceLinks(outputs)
42736
+ ...gifLinks,
42737
+ ...continuationText ? [
42738
+ {
42739
+ type: "text",
42740
+ text: continuationText
42741
+ }
42742
+ ] : []
42567
42743
  ]
42568
42744
  };
42569
42745
  } catch (err) {
42570
42746
  const detail = err instanceof Error ? err.stack ?? err.message : String(err);
42571
42747
  process.stderr.write(`mcp get_task_status: fetchTaskOutputs failed for ${input.taskId}: ${detail}
42572
42748
  `);
42749
+ if (hasPartialDelivery) return statusWithoutOutputs;
42573
42750
  const delivery = {
42574
42751
  ...snapshot,
42575
42752
  nextAction: creativeDeliveryNextAction(null, input.viewerLocale)
@@ -44463,6 +44640,7 @@ function registerCreativeTools(server, api, { transport = "http", proxyBaseUrl =
44463
44640
  else {
44464
44641
  wirePayload.pauseForAngleReview = true;
44465
44642
  wirePayload.pauseForVideoScriptReview = true;
44643
+ if (input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE) wirePayload.marketLedVideoDirector = "external_agent";
44466
44644
  }
44467
44645
  return await submitCreative(api, {
44468
44646
  path: "/v1/creatives/videos",
@@ -44711,6 +44889,7 @@ var EstimateCreativeVariantInputBase = z167.object({
44711
44889
  kind: CreativeVariantKindEnum,
44712
44890
  videoPreset: TaskCreativeVariantVideoPresetEnum.optional().describe("Opcional para video. Solo cambia el preset p\xFAblico; el servidor conserva el modelo/tier del task origen."),
44713
44891
  videoResolution: VideoResolutionEnum.optional().describe("Opcional para video. Resoluci\xF3n del nuevo render."),
44892
+ generateAiMusic: z167.boolean().optional().describe("Opcional para video. Incluye m\xFAsica generada en la cotizaci\xF3n."),
44714
44893
  nVariants: z167.number().int().min(1).max(3).optional().describe("Opcional para imagen. N\xFAmero de im\xE1genes adicionales (1-3)."),
44715
44894
  sectionKey: LandingSectionKeyEnum.optional().describe("Opcional para landing. Si ya conoces la secci\xF3n, evita cotizar la clasificaci\xF3n con IA."),
44716
44895
  instructions: z167.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.")
@@ -44726,6 +44905,15 @@ var EstimateCreativeVariantInput = EstimateCreativeVariantInputBase.superRefine(
44726
44905
  });
44727
44906
  }
44728
44907
  if (input.kind !== "video") {
44908
+ if (input.generateAiMusic !== void 0) {
44909
+ ctx.addIssue({
44910
+ code: z167.ZodIssueCode.custom,
44911
+ path: [
44912
+ "generateAiMusic"
44913
+ ],
44914
+ message: "generateAiMusic solo aplica a variantes de video."
44915
+ });
44916
+ }
44729
44917
  if (input.videoPreset !== void 0) {
44730
44918
  ctx.addIssue({
44731
44919
  code: z167.ZodIssueCode.custom,
@@ -44778,6 +44966,7 @@ var EstimateCreativeVariantInput = EstimateCreativeVariantInputBase.superRefine(
44778
44966
  var CreateCreativeVariantInputBase = z167.object({
44779
44967
  sourceTaskId: z167.string().guid().describe("ID de la tarea original completada."),
44780
44968
  kind: CreativeVariantKindEnum,
44969
+ maxApprovedCredits: CreateTaskVideoVariantRequest.shape.maxApprovedCredits.describe("Para video, env\xEDa el m\xE1ximo vigente que confirm\xF3 el usuario."),
44781
44970
  confirm: z167.literal(true).describe("Confirmaci\xF3n expl\xEDcita del usuario despu\xE9s de mostrarle el estimado de cr\xE9ditos."),
44782
44971
  clientRequestId: z167.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."),
44783
44972
  angle: z167.string().trim().min(1).max(500).optional().describe("\xC1ngulo nuevo para video o imagen."),
@@ -44797,6 +44986,15 @@ var CreateCreativeVariantInputBase = z167.object({
44797
44986
  instructions: z167.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.")
44798
44987
  }).strict();
44799
44988
  var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((input, ctx) => {
44989
+ if (input.kind === "video" && input.maxApprovedCredits === void 0) {
44990
+ ctx.addIssue({
44991
+ code: z167.ZodIssueCode.custom,
44992
+ path: [
44993
+ "maxApprovedCredits"
44994
+ ],
44995
+ message: "Cotiza el video y confirma el m\xE1ximo antes de iniciar."
44996
+ });
44997
+ }
44800
44998
  if ((input.kind === "video" || input.kind === "image") && !input.angle) {
44801
44999
  ctx.addIssue({
44802
45000
  code: z167.ZodIssueCode.custom,
@@ -44828,6 +45026,7 @@ var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((inp
44828
45026
  "instructions"
44829
45027
  ],
44830
45028
  image: [
45029
+ "maxApprovedCredits",
44831
45030
  "scriptNotes",
44832
45031
  "videoPreset",
44833
45032
  "videoResolution",
@@ -44836,6 +45035,7 @@ var CreateCreativeVariantInput = CreateCreativeVariantInputBase.superRefine((inp
44836
45035
  "instructions"
44837
45036
  ],
44838
45037
  landing: [
45038
+ "maxApprovedCredits",
44839
45039
  "angle",
44840
45040
  "buyerPersona",
44841
45041
  "scriptNotes",
@@ -44883,7 +45083,8 @@ function estimatePayload(input) {
44883
45083
  kind: input.kind,
44884
45084
  ...input.kind === "video" ? {
44885
45085
  videoPreset: input.videoPreset,
44886
- videoResolution: input.videoResolution
45086
+ videoResolution: input.videoResolution,
45087
+ generateAiMusic: input.generateAiMusic
44887
45088
  } : input.kind === "image" ? {
44888
45089
  nVariants: input.nVariants
44889
45090
  } : {
@@ -44917,19 +45118,21 @@ function registerCreativeVariantTools(server, api) {
44917
45118
  }
44918
45119
  });
44919
45120
  server.registerTool("create_creative_variant", {
44920
- 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.",
45121
+ 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.",
44921
45122
  inputSchema: CreateCreativeVariantInputBase.shape,
44922
45123
  annotations: CREATES_PAID
44923
45124
  }, async (input) => {
44924
45125
  let sourceTaskId;
45126
+ let estimateInput;
44925
45127
  try {
44926
45128
  const validatedInput = parseVariantInput(CreateCreativeVariantInput, input);
44927
45129
  sourceTaskId = validatedInput.sourceTaskId;
44928
- const estimateInput = EstimateCreativeVariantInput.parse({
45130
+ estimateInput = EstimateCreativeVariantInput.parse({
44929
45131
  sourceTaskId: validatedInput.sourceTaskId,
44930
45132
  kind: validatedInput.kind,
44931
45133
  videoPreset: validatedInput.videoPreset,
44932
45134
  videoResolution: validatedInput.videoResolution,
45135
+ generateAiMusic: validatedInput.generateAiMusic,
44933
45136
  nVariants: validatedInput.nVariants,
44934
45137
  sectionKey: validatedInput.sectionKey,
44935
45138
  instructions: validatedInput.instructions
@@ -44949,12 +45152,11 @@ function registerCreativeVariantTools(server, api) {
44949
45152
  });
44950
45153
  sectionKey = LandingSectionKeyEnum.parse(recommendation.value);
44951
45154
  }
45155
+ const { maxApprovedCredits, ...intent } = validatedInput;
44952
45156
  const derivedClientRequestId = derivePaidRequestKey({
44953
45157
  fingerprint: api.fingerprint(),
44954
45158
  tool: "create_creative_variant",
44955
- input: {
44956
- ...validatedInput
44957
- },
45159
+ input: intent,
44958
45160
  nowMs: Date.now()
44959
45161
  });
44960
45162
  const payload = {
@@ -44968,6 +45170,7 @@ function registerCreativeVariantTools(server, api) {
44968
45170
  instructions: validatedInput.instructions
44969
45171
  },
44970
45172
  ...validatedInput.kind === "video" ? {
45173
+ maxApprovedCredits,
44971
45174
  scriptNotes: validatedInput.scriptNotes,
44972
45175
  videoPreset: validatedInput.videoPreset,
44973
45176
  videoResolution: validatedInput.videoResolution,
@@ -44993,6 +45196,23 @@ function registerCreativeVariantTools(server, api) {
44993
45196
  estimate
44994
45197
  });
44995
45198
  } catch (error) {
45199
+ if (estimateInput && error instanceof ApiHttpError && error.status === 409 && isRecord3(error.body) && error.body.code === "CREATIVE_VARIANT_QUOTE_CHANGED" && typeof error.body.estimatedMaxCostCredits === "number") {
45200
+ return {
45201
+ ...asText({
45202
+ error: {
45203
+ code: error.body.code,
45204
+ message: "La cotizaci\xF3n del video cambi\xF3.",
45205
+ estimatedMaxCostCredits: error.body.estimatedMaxCostCredits
45206
+ },
45207
+ nextAction: {
45208
+ tool: "estimate_creative_variant",
45209
+ arguments: estimateInput,
45210
+ instruction: "Vuelve a cotizar esta misma versi\xF3n y pide confirmaci\xF3n del m\xE1ximo vigente antes de iniciarla."
45211
+ }
45212
+ }),
45213
+ isError: true
45214
+ };
45215
+ }
44996
45216
  const translated = translateError(error);
44997
45217
  if (!sourceTaskId) throw translated;
44998
45218
  const details = isRecord3(translated.data) ? translated.data : {};
@@ -49033,6 +49253,7 @@ function buildMarketStudyEstimateRequests(input) {
49033
49253
  const productImageCount = input.productImageCount !== void 0 ? {
49034
49254
  productImageCount: input.productImageCount
49035
49255
  } : {};
49256
+ const guidedMarketLedVideo = quotesVideo && input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && resolveConversationalReviewPolicy(input.aiDecidesAll).pauseForAngleReview;
49036
49257
  const common = {
49037
49258
  nVideos: input.videoAngleCount,
49038
49259
  durationSeconds: input.durationSeconds,
@@ -49042,12 +49263,14 @@ function buildMarketStudyEstimateRequests(input) {
49042
49263
  videoPreset: "auto",
49043
49264
  generateAiMusic: input.generateAiMusic ?? false,
49044
49265
  generateAiEdit: input.generateAiEdit ?? false,
49266
+ ...guidedMarketLedVideo ? {
49267
+ marketLedVideoDirector: "external_agent"
49268
+ } : {},
49045
49269
  ...productImageCount,
49046
49270
  ...input.replicateWinnerWhenFound !== void 0 ? {
49047
49271
  replicateWinnerWhenFound: input.replicateWinnerWhenFound
49048
49272
  } : {}
49049
49273
  };
49050
- const marketLedStudy = quotesVideo && input.videoStructure === DEFAULT_GUIDED_VIDEO_STRUCTURE && resolveConversationalReviewPolicy(input.aiDecidesAll).pauseForAngleReview;
49051
49274
  if (input.kind === "video") {
49052
49275
  const build2 = /* @__PURE__ */ __name((study) => ({
49053
49276
  type: "video-creative",
@@ -49061,7 +49284,7 @@ function buildMarketStudyEstimateRequests(input) {
49061
49284
  competitorScanEnabled: study,
49062
49285
  competitorCommercialStudyRequested: study,
49063
49286
  requiresCompetitorScan: study,
49064
- ...study && marketLedStudy ? {
49287
+ ...study && guidedMarketLedVideo ? {
49065
49288
  marketLedDeferredCopy: true
49066
49289
  } : {}
49067
49290
  }
@@ -49093,7 +49316,7 @@ function buildMarketStudyEstimateRequests(input) {
49093
49316
  ugcFormat: resolveVideoFormatForDuration(input.durationSeconds === 30 ? 30 : 15),
49094
49317
  competitorScanEnabled: study,
49095
49318
  competitorCommercialStudyRequested: study && videoGeneratorEnabled,
49096
- ...study && marketLedStudy ? {
49319
+ ...study && guidedMarketLedVideo ? {
49097
49320
  marketLedDeferredCopy: true
49098
49321
  } : {}
49099
49322
  }