mcp-scraper 0.2.19 → 0.2.20
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/README.md +3 -3
- package/dist/bin/api-server.cjs +1020 -348
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +3 -3
- package/dist/bin/browser-agent-stdio-server.cjs +314 -55
- package/dist/bin/browser-agent-stdio-server.cjs.map +1 -1
- package/dist/bin/browser-agent-stdio-server.js +2 -2
- package/dist/bin/mcp-scraper-cli.cjs +321 -167
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +3 -2
- package/dist/bin/mcp-scraper-cli.js.map +1 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.cjs +1128 -530
- package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-scraper-combined-stdio-server.js +5 -4
- package/dist/bin/mcp-scraper-combined-stdio-server.js.map +1 -1
- package/dist/bin/mcp-scraper-install.cjs +3 -3
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +2 -2
- package/dist/bin/mcp-stdio-server.cjs +726 -387
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +3 -2
- package/dist/bin/mcp-stdio-server.js.map +1 -1
- package/dist/bin/paa-harvest.cjs +5 -3
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +2 -1
- package/dist/bin/paa-harvest.js.map +1 -1
- package/dist/{chunk-TL7YTFLH.js → chunk-DBQDG7EH.js} +99 -27
- package/dist/chunk-DBQDG7EH.js.map +1 -0
- package/dist/{chunk-F44RBOJ5.js → chunk-H2R232HK.js} +216 -108
- package/dist/chunk-H2R232HK.js.map +1 -0
- package/dist/{chunk-76P4DKWR.js → chunk-L4OWOUGR.js} +315 -56
- package/dist/chunk-L4OWOUGR.js.map +1 -0
- package/dist/chunk-LFATOGDF.js +111 -0
- package/dist/chunk-LFATOGDF.js.map +1 -0
- package/dist/{chunk-MCBOZ2JF.js → chunk-MLNCKQ2B.js} +3 -3
- package/dist/chunk-MLNCKQ2B.js.map +1 -0
- package/dist/{chunk-4UEVYYDW.js → chunk-O5J7E4VX.js} +394 -57
- package/dist/chunk-O5J7E4VX.js.map +1 -0
- package/dist/{chunk-BSYPATSM.js → chunk-SXTXMFEQ.js} +2 -2
- package/dist/{chunk-CQTAKXBN.js → chunk-XGUDTDZ2.js} +7 -104
- package/dist/chunk-XGUDTDZ2.js.map +1 -0
- package/dist/chunk-XKUDVN2E.js +7 -0
- package/dist/chunk-XKUDVN2E.js.map +1 -0
- package/dist/{db-P5X6UQ3E.js → db-BE4JVB3V.js} +8 -2
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{server-CRUSZA2Q.js → server-7NE45K2A.js} +211 -37
- package/dist/server-7NE45K2A.js.map +1 -0
- package/dist/{worker-OZSWIS3F.js → worker-MIYG2B2I.js} +5 -4
- package/dist/{worker-OZSWIS3F.js.map → worker-MIYG2B2I.js.map} +1 -1
- package/docs/adr/0001-in-page-graphql-interception-for-anti-bot-scraping.md +2 -2
- package/docs/mcp-tool-craft-lint.generated.md +51 -0
- package/docs/mcp-tool-manifest.generated.json +1406 -0
- package/docs/specs/local-competitive-audit-spec.md +1 -2
- package/docs/specs/mcp-tool-definition-quality-audit-spec.md +1602 -0
- package/package.json +4 -1
- package/dist/chunk-4UEVYYDW.js.map +0 -1
- package/dist/chunk-76P4DKWR.js.map +0 -1
- package/dist/chunk-CQTAKXBN.js.map +0 -1
- package/dist/chunk-F44RBOJ5.js.map +0 -1
- package/dist/chunk-MCBOZ2JF.js.map +0 -1
- package/dist/chunk-RU2HZD55.js +0 -7
- package/dist/chunk-RU2HZD55.js.map +0 -1
- package/dist/chunk-TL7YTFLH.js.map +0 -1
- package/dist/server-CRUSZA2Q.js.map +0 -1
- /package/dist/{chunk-BSYPATSM.js.map → chunk-SXTXMFEQ.js.map} +0 -0
- /package/dist/{db-P5X6UQ3E.js.map → db-BE4JVB3V.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -26,7 +26,7 @@ declare const HarvestOptionsSchema: z.ZodObject<{
|
|
|
26
26
|
gl: string;
|
|
27
27
|
hl: string;
|
|
28
28
|
device: "desktop" | "mobile";
|
|
29
|
-
proxyMode: "
|
|
29
|
+
proxyMode: "configured" | "location" | "none";
|
|
30
30
|
debug: boolean;
|
|
31
31
|
depth: number;
|
|
32
32
|
maxQuestions: number;
|
|
@@ -48,7 +48,7 @@ declare const HarvestOptionsSchema: z.ZodObject<{
|
|
|
48
48
|
gl?: string | undefined;
|
|
49
49
|
hl?: string | undefined;
|
|
50
50
|
device?: "desktop" | "mobile" | undefined;
|
|
51
|
-
proxyMode?: "
|
|
51
|
+
proxyMode?: "configured" | "location" | "none" | undefined;
|
|
52
52
|
proxyZip?: string | undefined;
|
|
53
53
|
debug?: boolean | undefined;
|
|
54
54
|
depth?: number | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare const HarvestOptionsSchema: z.ZodObject<{
|
|
|
26
26
|
gl: string;
|
|
27
27
|
hl: string;
|
|
28
28
|
device: "desktop" | "mobile";
|
|
29
|
-
proxyMode: "
|
|
29
|
+
proxyMode: "configured" | "location" | "none";
|
|
30
30
|
debug: boolean;
|
|
31
31
|
depth: number;
|
|
32
32
|
maxQuestions: number;
|
|
@@ -48,7 +48,7 @@ declare const HarvestOptionsSchema: z.ZodObject<{
|
|
|
48
48
|
gl?: string | undefined;
|
|
49
49
|
hl?: string | undefined;
|
|
50
50
|
device?: "desktop" | "mobile" | undefined;
|
|
51
|
-
proxyMode?: "
|
|
51
|
+
proxyMode?: "configured" | "location" | "none" | undefined;
|
|
52
52
|
proxyZip?: string | undefined;
|
|
53
53
|
debug?: boolean | undefined;
|
|
54
54
|
depth?: number | undefined;
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/video/VideoGenerator.ts","../src/video/promptBuilder.ts","../src/video/AudioGenerator.ts","../src/video/VideoMixer.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\nimport { readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { fal } from '@fal-ai/client'\nimport { buildClipPrompts, extractEpisodePrompts } from './promptBuilder.js'\nimport type { EpisodeBrief } from './episodeBrief.js'\nimport { generateVoiceover, addBackgroundAudio } from './AudioGenerator.js'\nimport { concatenateClips, uploadToFal, overlayVoiceover } from './VideoMixer.js'\n\nexport interface ClipPairOptions {\n resolution?: '480p' | '720p' | '1080p'\n aspectRatio?: '16:9' | '9:16' | '1:1'\n clipDurationSeconds?: number\n generateAudio?: boolean\n seed?: number\n outputDir?: string\n}\n\nexport interface ClipPairResult {\n clip1Url: string\n clip2Url: string\n finalVideoPath: string\n seed: number\n promptClip1: string\n promptClip2: string\n voiceover: string\n audioMood: string\n}\n\ninterface VideoOutput { video: { url: string }; seed: number }\n\nconst T2V = 'bytedance/seedance-2.0/text-to-video'\nconst I2V = 'bytedance/seedance-2.0/image-to-video'\n\nfunction buildInput(prompt: string, opts: ClipPairOptions, seed?: number, imageUrl?: string) {\n return {\n prompt,\n resolution: opts.resolution ?? '720p',\n duration: opts.clipDurationSeconds ?? 8,\n aspect_ratio: opts.aspectRatio ?? '16:9',\n generate_audio: false,\n ...(seed !== undefined ? { seed } : {}),\n ...(imageUrl !== undefined ? { image_url: imageUrl } : {}),\n }\n}\n\nasync function generate(model: string, input: Record<string, unknown>): Promise<VideoOutput> {\n const { request_id } = await fal.queue.submit(model, { input })\n console.log(`[fal] submitted ${model} → ${request_id}`)\n while (true) {\n await new Promise(r => setTimeout(r, 5000))\n const s = await fal.queue.status(model, { requestId: request_id, logs: false })\n console.log(`[fal] ${request_id} → ${s.status}`)\n if ((s.status as string) === 'FAILED') throw new Error(`Request ${request_id} failed`)\n if ((s.status as string) !== 'COMPLETED') continue\n const result = await fal.queue.result(model, { requestId: request_id })\n return result.data as VideoOutput\n }\n}\n\nasync function extractLastFrame(videoUrl: string, outDir: string): Promise<string> {\n const ts = Date.now()\n const mp4Path = join(outDir, `clip1-raw-${ts}.mp4`)\n const jpgPath = join(outDir, `last-frame-${ts}.jpg`)\n\n const res = await fetch(videoUrl)\n if (!res.ok) throw new Error(`Failed to download clip 1 (${res.status})`)\n writeFileSync(mp4Path, Buffer.from(await res.arrayBuffer()))\n\n try {\n execSync(`ffmpeg -sseof -0.1 -i \"${mp4Path}\" -vframes 1 -y \"${jpgPath}\" -loglevel error`)\n } finally {\n try { unlinkSync(mp4Path) } catch {}\n }\n return jpgPath\n}\n\nexport class VideoGenerator {\n constructor(apiKey?: string) {\n const key = apiKey ?? process.env['FAL_KEY']\n if (!key) throw new Error('FAL_KEY is required')\n fal.config({ credentials: key })\n }\n\n async generateClipPair(\n question: string,\n answer: string,\n opts: ClipPairOptions = {},\n ): Promise<ClipPairResult> {\n const outDir = opts.outputDir ?? join(tmpdir(), `paa-video-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n\n console.log('\\n[1/7] Generating prompts via QWEN 3.6...')\n const prompts = await buildClipPrompts(question, answer)\n console.log(' Voiceover:', prompts.voiceover)\n console.log(' Audio mood:', prompts.audioMood)\n\n console.log('\\n[2/7] Generating clip 1 (text-to-video)...')\n const result1 = await generate(T2V, buildInput(prompts.clip1, opts, opts.seed))\n\n console.log('\\n[3/7] Extracting last frame → clip 2 start...')\n const jpgPath = await extractLastFrame(result1.video.url, outDir)\n const imageBlob = new Blob([readFileSync(jpgPath)], { type: 'image/jpeg' })\n const frameUrl = await fal.storage.upload(imageBlob)\n try { unlinkSync(jpgPath) } catch {}\n\n console.log('\\n[4/7] Generating clip 2 (image-to-video from last frame)...')\n const seed2 = opts.seed !== undefined ? opts.seed + 1 : undefined\n const result2 = await generate(I2V, buildInput(prompts.clip2, opts, seed2, frameUrl))\n\n console.log('\\n[5/7] Concatenating clips + generating voiceover (parallel)...')\n const [combinedPath, voiceoverUrl] = await Promise.all([\n concatenateClips(result1.video.url, result2.video.url, outDir),\n generateVoiceover(prompts.voiceover),\n ])\n\n console.log('\\n[6/7] Adding background audio via MMAudio V2...')\n const falVideoUrl = await uploadToFal(combinedPath)\n const totalDuration = (opts.clipDurationSeconds ?? 8) * 2\n const videoWithAudioUrl = await addBackgroundAudio(falVideoUrl, prompts.audioMood, totalDuration)\n\n console.log('\\n[7/7] Overlaying voiceover on final video...')\n const videoWithAudioPath = join(outDir, `with-bg-audio-${Date.now()}.mp4`)\n const bgRes = await fetch(videoWithAudioUrl)\n writeFileSync(videoWithAudioPath, Buffer.from(await bgRes.arrayBuffer()))\n const finalVideoPath = await overlayVoiceover(videoWithAudioPath, voiceoverUrl, outDir)\n\n return {\n clip1Url: result1.video.url,\n clip2Url: result2.video.url,\n finalVideoPath,\n seed: result1.seed,\n promptClip1: prompts.clip1,\n promptClip2: prompts.clip2,\n voiceover: prompts.voiceover,\n audioMood: prompts.audioMood,\n }\n }\n\n async generateEpisode(\n brief: EpisodeBrief,\n opts: ClipPairOptions = {},\n ): Promise<ClipPairResult> {\n const outDir = opts.outputDir ?? join(tmpdir(), `episode-${brief.episodeNumber}-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n\n const prompts = extractEpisodePrompts(brief)\n console.log(`\\n[Episode ${brief.episodeNumber}/${brief.episodeCount}] ${brief.sectionTitle}`)\n console.log(' Voiceover:', prompts.voiceover)\n\n console.log('\\n[2/7] Generating clip 1 (text-to-video)...')\n const result1 = await generate(T2V, buildInput(prompts.clip1, opts, opts.seed))\n\n console.log('\\n[3/7] Extracting last frame → clip 2 start...')\n const jpgPath = await extractLastFrame(result1.video.url, outDir)\n const imageBlob = new Blob([readFileSync(jpgPath)], { type: 'image/jpeg' })\n const frameUrl = await fal.storage.upload(imageBlob)\n try { unlinkSync(jpgPath) } catch {}\n\n console.log('\\n[4/7] Generating clip 2 (image-to-video from last frame)...')\n const seed2 = opts.seed !== undefined ? opts.seed + 1 : undefined\n const result2 = await generate(I2V, buildInput(prompts.clip2, opts, seed2, frameUrl))\n\n console.log('\\n[5/7] Concatenating clips + generating voiceover (parallel)...')\n const [combinedPath, voiceoverUrl] = await Promise.all([\n concatenateClips(result1.video.url, result2.video.url, outDir),\n generateVoiceover(prompts.voiceover),\n ])\n\n console.log('\\n[6/7] Adding background audio via MMAudio V2...')\n const falVideoUrl = await uploadToFal(combinedPath)\n const totalDuration = (opts.clipDurationSeconds ?? 8) * 2\n const videoWithAudioUrl = await addBackgroundAudio(falVideoUrl, prompts.audioMood, totalDuration)\n\n console.log('\\n[7/7] Overlaying voiceover on final video...')\n const videoWithAudioPath = join(outDir, `with-bg-audio-${Date.now()}.mp4`)\n const bgRes = await fetch(videoWithAudioUrl)\n writeFileSync(videoWithAudioPath, Buffer.from(await bgRes.arrayBuffer()))\n const finalVideoPath = await overlayVoiceover(videoWithAudioPath, voiceoverUrl, outDir)\n\n return {\n clip1Url: result1.video.url,\n clip2Url: result2.video.url,\n finalVideoPath,\n seed: result1.seed,\n promptClip1: prompts.clip1,\n promptClip2: prompts.clip2,\n voiceover: prompts.voiceover,\n audioMood: prompts.audioMood,\n }\n }\n}\n","export interface ClipPromptPair {\n clip1: string\n clip2: string\n voiceover: string\n audioMood: string\n}\n\nexport interface EpisodeBriefInput {\n storyMoment: string\n characterName: string\n sectionTitle: string\n clip1: string\n clip2: string\n voiceover: string\n audioMood: string\n}\n\nconst DEEPINFRA_URL = 'https://api.deepinfra.com/v1/openai/chat/completions'\nconst OPENROUTER_URL = 'https://openrouter.ai/api/v1/chat/completions'\nconst QWEN_MODEL = 'Qwen/Qwen3.6-35B-A3B'\n\nconst SYSTEM_PROMPT = `You are a video prompt engineer for Seedance 2.0 text-to-video AI.\n\nIMPORTANT TECHNICAL CONTEXT: Clip 2 will be generated using image-to-video, meaning it will start from the exact last frame of Clip 1. The two clips will be visually seamless — same location, same characters, continuous motion. You must write prompts that make this feel like one uninterrupted 16-second video.\n\nYour job: turn a PAA question and its answer into a complete short-form video with visuals, narration, and a background audio mood.\n\nProduce four things:\n\n1. clip1 (~8s): Show a real person experiencing the situation the question describes. End on a specific frozen moment — a held expression, a paused action — that clip 2 continues from.\n\n2. clip2 (~8s): Continue from that exact frozen frame. Deliver the informational payoff from the answer. Show specific facts playing out visually. Describe motion continuing from clip 1's ending frame, not a new scene.\n\n3. voiceover: A spoken narration that fits in 10 seconds of TTS audio. HARD LIMIT: 22 words maximum. Count every word before finalizing — if it exceeds 22 words, cut it. Starts with the problem, ends with the answer. No filler, no \"in conclusion\". Informational and direct.\n\n4. audioMood: 6-10 words describing INSTRUMENTAL background music only — no vocals, no voice, no lyrics. Describe instruments and mood (e.g. \"warm acoustic guitar, uplifting, professional home service, no vocals\"). Will be passed to an AI audio model.\n\nRules for visuals:\n- No text, captions, graphics, or overlays\n- Photorealistic, natural lighting, specific details\n- Describe exactly what the camera sees\n\nRespond with JSON only:\n{\"clip1\": \"...\", \"clip2\": \"...\", \"voiceover\": \"...\", \"audioMood\": \"...\"}`\n\ninterface ChatResponse {\n choices: Array<{ message: { content: string } }>\n}\n\nasync function callLLM(apiKey: string, baseUrl: string, question: string, answer: string): Promise<ClipPromptPair> {\n const res = await fetch(baseUrl, {\n method: 'POST',\n headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: QWEN_MODEL,\n temperature: 0.7,\n messages: [\n { role: 'system', content: SYSTEM_PROMPT },\n { role: 'user', content: `Question: ${question}\\n\\nAnswer: ${answer.slice(0, 500)}` },\n ],\n }),\n })\n if (!res.ok) throw new Error(`LLM call failed (${res.status}): ${await res.text()}`)\n\n const data = (await res.json()) as ChatResponse\n const raw = data.choices[0]?.message?.content?.trim() ?? ''\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) throw new Error(`No JSON in QWEN response: ${raw.slice(0, 200)}`)\n\n const parsed = JSON.parse(match[0]) as Partial<ClipPromptPair>\n if (!parsed.clip1 || !parsed.clip2 || !parsed.voiceover || !parsed.audioMood) {\n throw new Error(`QWEN response missing fields: ${raw.slice(0, 200)}`)\n }\n return parsed as ClipPromptPair\n}\n\nexport async function buildClipPrompts(question: string, answer: string): Promise<ClipPromptPair> {\n const deepinfraKey = process.env['DEEPINFRA_API_KEY']\n const openrouterKey = process.env['OPENROUTER_API_KEY']\n\n if (deepinfraKey) {\n try {\n return await callLLM(deepinfraKey, DEEPINFRA_URL, question, answer)\n } catch (err) {\n console.warn('[promptBuilder] DeepInfra failed, trying OpenRouter:', (err as Error).message)\n }\n }\n if (openrouterKey) {\n return await callLLM(openrouterKey, OPENROUTER_URL, question, answer)\n }\n throw new Error('No LLM key — set DEEPINFRA_API_KEY or OPENROUTER_API_KEY')\n}\n\nexport function extractEpisodePrompts(brief: EpisodeBriefInput): ClipPromptPair {\n if (!brief.clip1 || !brief.clip2 || !brief.voiceover || !brief.audioMood) {\n throw new Error('Episode brief is missing prompt fields — run blog-to-video skill to regenerate')\n }\n return { clip1: brief.clip1, clip2: brief.clip2, voiceover: brief.voiceover, audioMood: brief.audioMood }\n}\n\nconst EPISODE_SYSTEM_PROMPT = `You are a video prompt engineer for Seedance 2.0 text-to-video AI.\n\nYou are working with a character-driven narrative brief. The clips must feel like a continuous 16-second moment in one person's story — not an explainer video.\n\nIMPORTANT TECHNICAL CONTEXT: Clip 2 will start from the exact last frame of Clip 1. Both clips must show the same person, same location, same lighting. Clip 2 continues motion from Clip 1's frozen ending frame.\n\nUse the Kling prompt format for every clip:\n[Shot type] of [character name] [action]. The scene starts at [keyframe 1]. Camera Motion: [motion] ending in [keyframe 2]. Lighting: [style]. Style: [style].\n\nShot types: Close-up, Medium shot, Over-the-shoulder, Wide shot, Tracking shot.\nCamera motions: Slow push in, Slow pull back, Rack focus, Static hold, Subtle drift right/left, Pan left/right.\n\nRules for visuals:\n- No text, no captions, no UI overlays, no readable code on screen\n- Photorealistic, specific objects, natural-feeling details\n- Keyframe 2 (clip 1's end) must be a specific held moment clip 2 continues from\n\nvoiceover: The character's internal tension, in 22 words maximum. Not a summary. Count every word.\naudioMood: Specific instruments + tempo + emotional register + \"no vocals, no lyrics\".\n\nRespond with JSON only: {\"clip1\": \"...\", \"clip2\": \"...\", \"voiceover\": \"...\", \"audioMood\": \"...\"}`\n\nasync function callEpisodeLLM(apiKey: string, baseUrl: string, brief: EpisodeBriefInput): Promise<ClipPromptPair> {\n const userContent = `Character: ${brief.characterName}\nSection: ${brief.sectionTitle}\nStory moment: ${brief.storyMoment}\n\nExisting clip1 (refine if needed): ${brief.clip1}\nExisting clip2 (refine if needed): ${brief.clip2}\nExisting voiceover: ${brief.voiceover}\nExisting audioMood: ${brief.audioMood}\n\nProduce refined Kling-format prompts that follow all rules. Keep what's good, fix what violates the format.`\n\n const res = await fetch(baseUrl, {\n method: 'POST',\n headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: QWEN_MODEL,\n temperature: 0.5,\n messages: [\n { role: 'system', content: EPISODE_SYSTEM_PROMPT },\n { role: 'user', content: userContent },\n ],\n }),\n })\n if (!res.ok) throw new Error(`LLM episode call failed (${res.status}): ${await res.text()}`)\n\n const data = (await res.json()) as ChatResponse\n const raw = data.choices[0]?.message?.content?.trim() ?? ''\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) throw new Error(`No JSON in episode response: ${raw.slice(0, 200)}`)\n\n const parsed = JSON.parse(match[0]) as Partial<ClipPromptPair>\n if (!parsed.clip1 || !parsed.clip2 || !parsed.voiceover || !parsed.audioMood) {\n throw new Error(`Episode response missing fields: ${raw.slice(0, 200)}`)\n }\n return parsed as ClipPromptPair\n}\n\nexport async function regenerateEpisodePrompts(brief: EpisodeBriefInput): Promise<ClipPromptPair> {\n const deepinfraKey = process.env['DEEPINFRA_API_KEY']\n const openrouterKey = process.env['OPENROUTER_API_KEY']\n\n if (deepinfraKey) {\n try {\n return await callEpisodeLLM(deepinfraKey, DEEPINFRA_URL, brief)\n } catch (err) {\n console.warn('[promptBuilder] DeepInfra failed, trying OpenRouter:', (err as Error).message)\n }\n }\n if (openrouterKey) {\n return await callEpisodeLLM(openrouterKey, OPENROUTER_URL, brief)\n }\n throw new Error('No LLM key — set DEEPINFRA_API_KEY or OPENROUTER_API_KEY')\n}\n","import { writeFileSync, mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { tmpdir } from 'node:os'\nimport { fal } from '@fal-ai/client'\n\nconst MMAUDIO_MODEL = 'fal-ai/mmaudio-v2'\nconst ELEVENLABS_MODEL = 'fal-ai/elevenlabs/tts'\nconst GEMINI_TTS_MODEL = 'fal-ai/google/gemini-2.5-flash-preview-tts'\n\ninterface VideoOutput { video: { url: string } }\ninterface TTSOutput { audio: { url: string } }\n\nasync function downloadAudio(url: string): Promise<Buffer> {\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Failed to download TTS audio (${res.status})`)\n return Buffer.from(await res.arrayBuffer())\n}\n\nexport async function generateVoiceover(text: string): Promise<string> {\n console.log('[AudioGenerator] Generating voiceover...')\n\n const outDir = join(tmpdir(), `tts-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n const outPath = join(outDir, 'voiceover.mp3')\n\n try {\n const voiceId = process.env['ELEVENLABS_VOICE_ID'] ?? 'pNInz6obpgDQGcFmaJgB'\n const result = await fal.run(ELEVENLABS_MODEL, {\n input: { text, voice_id: voiceId, model_id: 'eleven_v3' },\n }) as unknown as TTSOutput\n writeFileSync(outPath, await downloadAudio(result.audio.url))\n console.log('[AudioGenerator] TTS: ElevenLabs via fal')\n return outPath\n } catch (err) {\n console.warn('[AudioGenerator] ElevenLabs via fal failed, trying Gemini:', (err as Error).message)\n }\n\n const voice = process.env['GEMINI_TTS_VOICE'] ?? 'Kore'\n const result = await fal.run(GEMINI_TTS_MODEL, { input: { text, voice } }) as unknown as TTSOutput\n writeFileSync(outPath, await downloadAudio(result.audio.url))\n console.log('[AudioGenerator] TTS: Gemini via fal')\n return outPath\n}\n\nexport async function addBackgroundAudio(videoUrl: string, mood: string, durationSeconds: number): Promise<string> {\n console.log('[AudioGenerator] Adding background audio via MMAudio V2...')\n const result = await fal.run(MMAUDIO_MODEL, {\n input: {\n video_url: videoUrl,\n prompt: mood,\n negative_prompt: 'speech, voice, talking, dialogue, narration, vocals, singing, human voice, conversation, words, lyrics, announcer, commentary',\n duration: durationSeconds,\n cfg_strength: 4.5,\n },\n }) as unknown as VideoOutput\n return result.video.url\n}\n","import { execSync } from 'node:child_process'\nimport { writeFileSync, mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { fal } from '@fal-ai/client'\n\nasync function download(url: string, destPath: string): Promise<void> {\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Download failed (${res.status}): ${url}`)\n writeFileSync(destPath, Buffer.from(await res.arrayBuffer()))\n}\n\nexport async function concatenateClips(clip1Url: string, clip2Url: string, outDir: string): Promise<string> {\n mkdirSync(outDir, { recursive: true })\n const ts = Date.now()\n const p1 = join(outDir, `clip1-${ts}.mp4`)\n const p2 = join(outDir, `clip2-${ts}.mp4`)\n const out = join(outDir, `combined-${ts}.mp4`)\n\n console.log('[VideoMixer] Downloading clips...')\n await Promise.all([download(clip1Url, p1), download(clip2Url, p2)])\n\n console.log('[VideoMixer] Concatenating...')\n execSync(\n `ffmpeg -i \"${p1}\" -i \"${p2}\" -filter_complex \"[0:v][1:v]concat=n=2:v=1:a=0[v]\" -map \"[v]\" -y \"${out}\" -loglevel error`\n )\n return out\n}\n\nexport async function uploadToFal(localPath: string): Promise<string> {\n const { readFileSync } = await import('node:fs')\n const blob = new Blob([readFileSync(localPath)], { type: 'video/mp4' })\n const url = await fal.storage.upload(blob)\n console.log('[VideoMixer] Uploaded to fal:', url)\n return url\n}\n\nexport async function overlayVoiceover(\n videoPath: string,\n voiceoverUrl: string,\n outDir: string,\n): Promise<string> {\n const ts = Date.now()\n const wav = join(outDir, `voiceover-${ts}.wav`)\n const out = join(outDir, `final-${ts}.mp4`)\n\n console.log('[VideoMixer] Downloading voiceover...')\n await download(voiceoverUrl, wav)\n\n console.log('[VideoMixer] Mixing voiceover over background audio...')\n execSync(\n `ffmpeg -i \"${videoPath}\" -i \"${wav}\" ` +\n `-filter_complex \"[0:a]volume=0.2[bg];[1:a]volume=1.0[vo];[bg][vo]amix=inputs=2:duration=first[a]\" ` +\n `-map 0:v -map \"[a]\" -c:v copy -y \"${out}\" -loglevel error`\n )\n return out\n}\n"],"mappings":";;;;;;AAAA,SAAS,YAAAA,iBAAgB;AACzB,SAAS,cAAc,iBAAAC,gBAAe,YAAY,aAAAC,kBAAiB;AACnE,SAAS,UAAAC,eAAc;AACvB,SAAS,QAAAC,aAAY;AACrB,SAAS,OAAAC,YAAW;;;ACapB,IAAM,gBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,aAAiB;AAEvB,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BtB,eAAe,QAAQ,QAAgB,SAAiB,UAAkB,QAAyC;AACjH,QAAM,MAAM,MAAM,MAAM,SAAS;AAAA,IAC/B,QAAS;AAAA,IACT,SAAS,EAAE,iBAAiB,UAAU,MAAM,IAAI,gBAAgB,mBAAmB;AAAA,IACnF,MAAM,KAAK,UAAU;AAAA,MACnB,OAAa;AAAA,MACb,aAAa;AAAA,MACb,UAAU;AAAA,QACR,EAAE,MAAM,UAAU,SAAS,cAAc;AAAA,QACzC,EAAE,MAAM,QAAU,SAAS,aAAa,QAAQ;AAAA;AAAA,UAAe,OAAO,MAAM,GAAG,GAAG,CAAC,GAAG;AAAA,MACxF;AA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AiB,QAAQ,MAAM,KAAK,QAAQ,MAAM,KAAK,MAAM;AAAA,MAC7D,kBAAkB,QAAQ,SAAS;AAAA,IACrC,CAAC;AAED,YAAQ,IAAI,mDAAmD;AAC/D,UAAM,cAAqB,MAAM,YAAY,YAAY;AACzD,UAAM,iBAAsB,KAAK,uBAAuB,KAAK;AAC7D,UAAM,oBAAqB,MAAM,mBAAmB,aAAa,QAAQ,WAAW,aAAa;AAEjG,YAAQ,IAAI,gDAAgD;AAC5D,UAAM,qBAAqBC,MAAK,QAAQ,iBAAiB,KAAK,IAAI,CAAC,MAAM;AACzE,UAAM,QAAQ,MAAM,MAAM,iBAAiB;AAC3C,IAAAC,eAAc,oBAAoB,OAAO,KAAK,MAAM,MAAM,YAAY,CAAC,CAAC;AACxE,UAAM,iBAAiB,MAAM,iBAAiB,oBAAoB,cAAc,MAAM;AAEtF,WAAO;AAAA,MACL,UAAgB,QAAQ,MAAM;AAAA,MAC9B,UAAgB,QAAQ,MAAM;AAAA,MAC9B;AAAA,MACA,MAAgB,QAAQ;AAAA,MACxB,aAAgB,QAAQ;AAAA,MACxB,aAAgB,QAAQ;AAAA,MACxB,WAAgB,QAAQ;AAAA,MACxB,WAAgB,QAAQ;AAAA,IAC1B;AAAA,EACF;AACF;","names":["execSync","writeFileSync","mkdirSync","tmpdir","join","fal","result","writeFileSync","mkdirSync","join","fal","readFileSync","fal","join","writeFileSync","execSync","tmpdir","mkdirSync"]}
|
|
1
|
+
{"version":3,"sources":["../src/video/VideoGenerator.ts","../src/video/promptBuilder.ts","../src/video/AudioGenerator.ts","../src/video/VideoMixer.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\nimport { readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { fal } from '@fal-ai/client'\nimport { buildClipPrompts, extractEpisodePrompts } from './promptBuilder.js'\nimport type { EpisodeBrief } from './episodeBrief.js'\nimport { generateVoiceover, addBackgroundAudio } from './AudioGenerator.js'\nimport { concatenateClips, uploadToFal, overlayVoiceover } from './VideoMixer.js'\n\nexport interface ClipPairOptions {\n resolution?: '480p' | '720p' | '1080p'\n aspectRatio?: '16:9' | '9:16' | '1:1'\n clipDurationSeconds?: number\n generateAudio?: boolean\n seed?: number\n outputDir?: string\n}\n\nexport interface ClipPairResult {\n clip1Url: string\n clip2Url: string\n finalVideoPath: string\n seed: number\n promptClip1: string\n promptClip2: string\n voiceover: string\n audioMood: string\n}\n\ninterface VideoOutput { video: { url: string }; seed: number }\n\nconst T2V = 'bytedance/seedance-2.0/text-to-video'\nconst I2V = 'bytedance/seedance-2.0/image-to-video'\n\nfunction buildInput(prompt: string, opts: ClipPairOptions, seed?: number, imageUrl?: string) {\n return {\n prompt,\n resolution: opts.resolution ?? '720p',\n duration: opts.clipDurationSeconds ?? 8,\n aspect_ratio: opts.aspectRatio ?? '16:9',\n generate_audio: false,\n ...(seed !== undefined ? { seed } : {}),\n ...(imageUrl !== undefined ? { image_url: imageUrl } : {}),\n }\n}\n\nasync function generate(model: string, input: Record<string, unknown>): Promise<VideoOutput> {\n const { request_id } = await fal.queue.submit(model, { input })\n console.log(`[fal] submitted ${model} → ${request_id}`)\n while (true) {\n await new Promise(r => setTimeout(r, 5000))\n const s = await fal.queue.status(model, { requestId: request_id, logs: false })\n console.log(`[fal] ${request_id} → ${s.status}`)\n if ((s.status as string) === 'FAILED') throw new Error(`Request ${request_id} failed`)\n if ((s.status as string) !== 'COMPLETED') continue\n const result = await fal.queue.result(model, { requestId: request_id })\n return result.data as VideoOutput\n }\n}\n\nasync function extractLastFrame(videoUrl: string, outDir: string): Promise<string> {\n const ts = Date.now()\n const mp4Path = join(outDir, `clip1-raw-${ts}.mp4`)\n const jpgPath = join(outDir, `last-frame-${ts}.jpg`)\n\n const res = await fetch(videoUrl)\n if (!res.ok) throw new Error(`Failed to download clip 1 (${res.status})`)\n writeFileSync(mp4Path, Buffer.from(await res.arrayBuffer()))\n\n try {\n execSync(`ffmpeg -sseof -0.1 -i \"${mp4Path}\" -vframes 1 -y \"${jpgPath}\" -loglevel error`)\n } finally {\n try { unlinkSync(mp4Path) } catch {}\n }\n return jpgPath\n}\n\nexport class VideoGenerator {\n constructor(apiKey?: string) {\n const key = apiKey ?? process.env['FAL_KEY']\n if (!key) throw new Error('FAL_KEY is required')\n fal.config({ credentials: key })\n }\n\n async generateClipPair(\n question: string,\n answer: string,\n opts: ClipPairOptions = {},\n ): Promise<ClipPairResult> {\n const outDir = opts.outputDir ?? join(tmpdir(), `paa-video-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n\n console.log('\\n[1/7] Generating prompts via QWEN 3.6...')\n const prompts = await buildClipPrompts(question, answer)\n console.log(' Voiceover:', prompts.voiceover)\n console.log(' Audio mood:', prompts.audioMood)\n\n console.log('\\n[2/7] Generating clip 1 (text-to-video)...')\n const result1 = await generate(T2V, buildInput(prompts.clip1, opts, opts.seed))\n\n console.log('\\n[3/7] Extracting last frame → clip 2 start...')\n const jpgPath = await extractLastFrame(result1.video.url, outDir)\n const imageBlob = new Blob([readFileSync(jpgPath)], { type: 'image/jpeg' })\n const frameUrl = await fal.storage.upload(imageBlob)\n try { unlinkSync(jpgPath) } catch {}\n\n console.log('\\n[4/7] Generating clip 2 (image-to-video from last frame)...')\n const seed2 = opts.seed !== undefined ? opts.seed + 1 : undefined\n const result2 = await generate(I2V, buildInput(prompts.clip2, opts, seed2, frameUrl))\n\n console.log('\\n[5/7] Concatenating clips + generating voiceover (parallel)...')\n const [combinedPath, voiceoverUrl] = await Promise.all([\n concatenateClips(result1.video.url, result2.video.url, outDir),\n generateVoiceover(prompts.voiceover),\n ])\n\n console.log('\\n[6/7] Adding background audio via MMAudio V2...')\n const falVideoUrl = await uploadToFal(combinedPath)\n const totalDuration = (opts.clipDurationSeconds ?? 8) * 2\n const videoWithAudioUrl = await addBackgroundAudio(falVideoUrl, prompts.audioMood, totalDuration)\n\n console.log('\\n[7/7] Overlaying voiceover on final video...')\n const videoWithAudioPath = join(outDir, `with-bg-audio-${Date.now()}.mp4`)\n const bgRes = await fetch(videoWithAudioUrl)\n writeFileSync(videoWithAudioPath, Buffer.from(await bgRes.arrayBuffer()))\n const finalVideoPath = await overlayVoiceover(videoWithAudioPath, voiceoverUrl, outDir)\n\n return {\n clip1Url: result1.video.url,\n clip2Url: result2.video.url,\n finalVideoPath,\n seed: result1.seed,\n promptClip1: prompts.clip1,\n promptClip2: prompts.clip2,\n voiceover: prompts.voiceover,\n audioMood: prompts.audioMood,\n }\n }\n\n async generateEpisode(\n brief: EpisodeBrief,\n opts: ClipPairOptions = {},\n ): Promise<ClipPairResult> {\n const outDir = opts.outputDir ?? join(tmpdir(), `episode-${brief.episodeNumber}-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n\n const prompts = extractEpisodePrompts(brief)\n console.log(`\\n[Episode ${brief.episodeNumber}/${brief.episodeCount}] ${brief.sectionTitle}`)\n console.log(' Voiceover:', prompts.voiceover)\n\n console.log('\\n[2/7] Generating clip 1 (text-to-video)...')\n const result1 = await generate(T2V, buildInput(prompts.clip1, opts, opts.seed))\n\n console.log('\\n[3/7] Extracting last frame → clip 2 start...')\n const jpgPath = await extractLastFrame(result1.video.url, outDir)\n const imageBlob = new Blob([readFileSync(jpgPath)], { type: 'image/jpeg' })\n const frameUrl = await fal.storage.upload(imageBlob)\n try { unlinkSync(jpgPath) } catch {}\n\n console.log('\\n[4/7] Generating clip 2 (image-to-video from last frame)...')\n const seed2 = opts.seed !== undefined ? opts.seed + 1 : undefined\n const result2 = await generate(I2V, buildInput(prompts.clip2, opts, seed2, frameUrl))\n\n console.log('\\n[5/7] Concatenating clips + generating voiceover (parallel)...')\n const [combinedPath, voiceoverUrl] = await Promise.all([\n concatenateClips(result1.video.url, result2.video.url, outDir),\n generateVoiceover(prompts.voiceover),\n ])\n\n console.log('\\n[6/7] Adding background audio via MMAudio V2...')\n const falVideoUrl = await uploadToFal(combinedPath)\n const totalDuration = (opts.clipDurationSeconds ?? 8) * 2\n const videoWithAudioUrl = await addBackgroundAudio(falVideoUrl, prompts.audioMood, totalDuration)\n\n console.log('\\n[7/7] Overlaying voiceover on final video...')\n const videoWithAudioPath = join(outDir, `with-bg-audio-${Date.now()}.mp4`)\n const bgRes = await fetch(videoWithAudioUrl)\n writeFileSync(videoWithAudioPath, Buffer.from(await bgRes.arrayBuffer()))\n const finalVideoPath = await overlayVoiceover(videoWithAudioPath, voiceoverUrl, outDir)\n\n return {\n clip1Url: result1.video.url,\n clip2Url: result2.video.url,\n finalVideoPath,\n seed: result1.seed,\n promptClip1: prompts.clip1,\n promptClip2: prompts.clip2,\n voiceover: prompts.voiceover,\n audioMood: prompts.audioMood,\n }\n }\n}\n","export interface ClipPromptPair {\n clip1: string\n clip2: string\n voiceover: string\n audioMood: string\n}\n\nexport interface EpisodeBriefInput {\n storyMoment: string\n characterName: string\n sectionTitle: string\n clip1: string\n clip2: string\n voiceover: string\n audioMood: string\n}\n\nconst DEEPINFRA_URL = 'https://api.deepinfra.com/v1/openai/chat/completions'\nconst OPENROUTER_URL = 'https://openrouter.ai/api/v1/chat/completions'\nconst QWEN_MODEL = 'Qwen/Qwen3.6-35B-A3B'\n\nconst SYSTEM_PROMPT = `You are a video prompt engineer for Seedance 2.0 text-to-video AI.\n\nIMPORTANT TECHNICAL CONTEXT: Clip 2 will be generated using image-to-video, meaning it will start from the exact last frame of Clip 1. The two clips will be visually seamless — same location, same characters, continuous motion. You must write prompts that make this feel like one uninterrupted 16-second video.\n\nYour job: turn a PAA question and its answer into a complete short-form video with visuals, narration, and a background audio mood.\n\nProduce four things:\n\n1. clip1 (~8s): Show a real person experiencing the situation the question describes. End on a specific frozen moment — a held expression, a paused action — that clip 2 continues from.\n\n2. clip2 (~8s): Continue from that exact frozen frame. Deliver the informational payoff from the answer. Show specific facts playing out visually. Describe motion continuing from clip 1's ending frame, not a new scene.\n\n3. voiceover: A spoken narration that fits in 10 seconds of TTS audio. HARD LIMIT: 22 words maximum. Count every word before finalizing — if it exceeds 22 words, cut it. Starts with the problem, ends with the answer. No filler, no \"in conclusion\". Informational and direct.\n\n4. audioMood: 6-10 words describing INSTRUMENTAL background music only — no vocals, no voice, no lyrics. Describe instruments and mood (e.g. \"warm acoustic guitar, uplifting, professional home service, no vocals\"). Will be passed to an AI audio model.\n\nRules for visuals:\n- No text, captions, graphics, or overlays\n- Photorealistic, natural lighting, specific details\n- Describe exactly what the camera sees\n\nRespond with JSON only:\n{\"clip1\": \"...\", \"clip2\": \"...\", \"voiceover\": \"...\", \"audioMood\": \"...\"}`\n\ninterface ChatResponse {\n choices: Array<{ message: { content: string } }>\n}\n\nasync function callLLM(apiKey: string, baseUrl: string, question: string, answer: string): Promise<ClipPromptPair> {\n const res = await fetch(baseUrl, {\n method: 'POST',\n headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: QWEN_MODEL,\n temperature: 0.7,\n messages: [\n { role: 'system', content: SYSTEM_PROMPT },\n { role: 'user', content: `Question: ${question}\\n\\nAnswer: ${answer.slice(0, 500)}` },\n ],\n }),\n })\n if (!res.ok) throw new Error(`LLM call failed (${res.status}): ${await res.text()}`)\n\n const data = (await res.json()) as ChatResponse\n const raw = data.choices[0]?.message?.content?.trim() ?? ''\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) throw new Error(`No JSON in QWEN response: ${raw.slice(0, 200)}`)\n\n const parsed = JSON.parse(match[0]) as Partial<ClipPromptPair>\n if (!parsed.clip1 || !parsed.clip2 || !parsed.voiceover || !parsed.audioMood) {\n throw new Error(`QWEN response missing fields: ${raw.slice(0, 200)}`)\n }\n return parsed as ClipPromptPair\n}\n\nexport async function buildClipPrompts(question: string, answer: string): Promise<ClipPromptPair> {\n const deepinfraKey = process.env['DEEPINFRA_API_KEY']\n const openrouterKey = process.env['OPENROUTER_API_KEY']\n\n if (deepinfraKey) {\n try {\n return await callLLM(deepinfraKey, DEEPINFRA_URL, question, answer)\n } catch (err) {\n console.warn('[promptBuilder] DeepInfra failed, trying OpenRouter:', (err as Error).message)\n }\n }\n if (openrouterKey) {\n return await callLLM(openrouterKey, OPENROUTER_URL, question, answer)\n }\n throw new Error('No LLM key — set DEEPINFRA_API_KEY or OPENROUTER_API_KEY')\n}\n\nexport function extractEpisodePrompts(brief: EpisodeBriefInput): ClipPromptPair {\n if (!brief.clip1 || !brief.clip2 || !brief.voiceover || !brief.audioMood) {\n throw new Error('Episode brief is missing prompt fields — run blog-to-video skill to regenerate')\n }\n return { clip1: brief.clip1, clip2: brief.clip2, voiceover: brief.voiceover, audioMood: brief.audioMood }\n}\n\nconst EPISODE_SYSTEM_PROMPT = `You are a video prompt engineer for Seedance 2.0 text-to-video AI.\n\nYou are working with a character-driven narrative brief. The clips must feel like a continuous 16-second moment in one person's story — not an explainer video.\n\nIMPORTANT TECHNICAL CONTEXT: Clip 2 will start from the exact last frame of Clip 1. Both clips must show the same person, same location, same lighting. Clip 2 continues motion from Clip 1's frozen ending frame.\n\nUse the Kling prompt format for every clip:\n[Shot type] of [character name] [action]. The scene starts at [keyframe 1]. Camera Motion: [motion] ending in [keyframe 2]. Lighting: [style]. Style: [style].\n\nShot types: Close-up, Medium shot, Over-the-shoulder, Wide shot, Tracking shot.\nCamera motions: Slow push in, Slow pull back, Rack focus, Static hold, Subtle drift right/left, Pan left/right.\n\nRules for visuals:\n- No text, no captions, no UI overlays, no readable code on screen\n- Photorealistic, specific objects, natural-feeling details\n- Keyframe 2 (clip 1's end) must be a specific held moment clip 2 continues from\n\nvoiceover: The character's internal tension, in 22 words maximum. Not a summary. Count every word.\naudioMood: Specific instruments + tempo + emotional register + \"no vocals, no lyrics\".\n\nRespond with JSON only: {\"clip1\": \"...\", \"clip2\": \"...\", \"voiceover\": \"...\", \"audioMood\": \"...\"}`\n\nasync function callEpisodeLLM(apiKey: string, baseUrl: string, brief: EpisodeBriefInput): Promise<ClipPromptPair> {\n const userContent = `Character: ${brief.characterName}\nSection: ${brief.sectionTitle}\nStory moment: ${brief.storyMoment}\n\nExisting clip1 (refine if needed): ${brief.clip1}\nExisting clip2 (refine if needed): ${brief.clip2}\nExisting voiceover: ${brief.voiceover}\nExisting audioMood: ${brief.audioMood}\n\nProduce refined Kling-format prompts that follow all rules. Keep what's good, fix what violates the format.`\n\n const res = await fetch(baseUrl, {\n method: 'POST',\n headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({\n model: QWEN_MODEL,\n temperature: 0.5,\n messages: [\n { role: 'system', content: EPISODE_SYSTEM_PROMPT },\n { role: 'user', content: userContent },\n ],\n }),\n })\n if (!res.ok) throw new Error(`LLM episode call failed (${res.status}): ${await res.text()}`)\n\n const data = (await res.json()) as ChatResponse\n const raw = data.choices[0]?.message?.content?.trim() ?? ''\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) throw new Error(`No JSON in episode response: ${raw.slice(0, 200)}`)\n\n const parsed = JSON.parse(match[0]) as Partial<ClipPromptPair>\n if (!parsed.clip1 || !parsed.clip2 || !parsed.voiceover || !parsed.audioMood) {\n throw new Error(`Episode response missing fields: ${raw.slice(0, 200)}`)\n }\n return parsed as ClipPromptPair\n}\n\nexport async function regenerateEpisodePrompts(brief: EpisodeBriefInput): Promise<ClipPromptPair> {\n const deepinfraKey = process.env['DEEPINFRA_API_KEY']\n const openrouterKey = process.env['OPENROUTER_API_KEY']\n\n if (deepinfraKey) {\n try {\n return await callEpisodeLLM(deepinfraKey, DEEPINFRA_URL, brief)\n } catch (err) {\n console.warn('[promptBuilder] DeepInfra failed, trying OpenRouter:', (err as Error).message)\n }\n }\n if (openrouterKey) {\n return await callEpisodeLLM(openrouterKey, OPENROUTER_URL, brief)\n }\n throw new Error('No LLM key — set DEEPINFRA_API_KEY or OPENROUTER_API_KEY')\n}\n","import { writeFileSync, mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { tmpdir } from 'node:os'\nimport { fal } from '@fal-ai/client'\n\nconst MMAUDIO_MODEL = 'fal-ai/mmaudio-v2'\nconst ELEVENLABS_MODEL = 'fal-ai/elevenlabs/tts'\nconst GEMINI_TTS_MODEL = 'fal-ai/google/gemini-2.5-flash-preview-tts'\n\ninterface VideoOutput { video: { url: string } }\ninterface TTSOutput { audio: { url: string } }\n\nasync function downloadAudio(url: string): Promise<Buffer> {\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Failed to download TTS audio (${res.status})`)\n return Buffer.from(await res.arrayBuffer())\n}\n\nexport async function generateVoiceover(text: string): Promise<string> {\n console.log('[AudioGenerator] Generating voiceover...')\n\n const outDir = join(tmpdir(), `tts-${Date.now()}`)\n mkdirSync(outDir, { recursive: true })\n const outPath = join(outDir, 'voiceover.mp3')\n\n try {\n const voiceId = process.env['ELEVENLABS_VOICE_ID'] ?? 'pNInz6obpgDQGcFmaJgB'\n const result = await fal.run(ELEVENLABS_MODEL, {\n input: { text, voice_id: voiceId, model_id: 'eleven_v3' },\n }) as unknown as TTSOutput\n writeFileSync(outPath, await downloadAudio(result.audio.url))\n console.log('[AudioGenerator] TTS: ElevenLabs via fal')\n return outPath\n } catch (err) {\n console.warn('[AudioGenerator] ElevenLabs via fal failed, trying Gemini:', (err as Error).message)\n }\n\n const voice = process.env['GEMINI_TTS_VOICE'] ?? 'Kore'\n const result = await fal.run(GEMINI_TTS_MODEL, { input: { text, voice } }) as unknown as TTSOutput\n writeFileSync(outPath, await downloadAudio(result.audio.url))\n console.log('[AudioGenerator] TTS: Gemini via fal')\n return outPath\n}\n\nexport async function addBackgroundAudio(videoUrl: string, mood: string, durationSeconds: number): Promise<string> {\n console.log('[AudioGenerator] Adding background audio via MMAudio V2...')\n const result = await fal.run(MMAUDIO_MODEL, {\n input: {\n video_url: videoUrl,\n prompt: mood,\n negative_prompt: 'speech, voice, talking, dialogue, narration, vocals, singing, human voice, conversation, words, lyrics, announcer, commentary',\n duration: durationSeconds,\n cfg_strength: 4.5,\n },\n }) as unknown as VideoOutput\n return result.video.url\n}\n","import { execSync } from 'node:child_process'\nimport { writeFileSync, mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { fal } from '@fal-ai/client'\n\nasync function download(url: string, destPath: string): Promise<void> {\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Download failed (${res.status}): ${url}`)\n writeFileSync(destPath, Buffer.from(await res.arrayBuffer()))\n}\n\nexport async function concatenateClips(clip1Url: string, clip2Url: string, outDir: string): Promise<string> {\n mkdirSync(outDir, { recursive: true })\n const ts = Date.now()\n const p1 = join(outDir, `clip1-${ts}.mp4`)\n const p2 = join(outDir, `clip2-${ts}.mp4`)\n const out = join(outDir, `combined-${ts}.mp4`)\n\n console.log('[VideoMixer] Downloading clips...')\n await Promise.all([download(clip1Url, p1), download(clip2Url, p2)])\n\n console.log('[VideoMixer] Concatenating...')\n execSync(\n `ffmpeg -i \"${p1}\" -i \"${p2}\" -filter_complex \"[0:v][1:v]concat=n=2:v=1:a=0[v]\" -map \"[v]\" -y \"${out}\" -loglevel error`\n )\n return out\n}\n\nexport async function uploadToFal(localPath: string): Promise<string> {\n const { readFileSync } = await import('node:fs')\n const blob = new Blob([readFileSync(localPath)], { type: 'video/mp4' })\n const url = await fal.storage.upload(blob)\n console.log('[VideoMixer] Uploaded to fal:', url)\n return url\n}\n\nexport async function overlayVoiceover(\n videoPath: string,\n voiceoverUrl: string,\n outDir: string,\n): Promise<string> {\n const ts = Date.now()\n const wav = join(outDir, `voiceover-${ts}.wav`)\n const out = join(outDir, `final-${ts}.mp4`)\n\n console.log('[VideoMixer] Downloading voiceover...')\n await download(voiceoverUrl, wav)\n\n console.log('[VideoMixer] Mixing voiceover over background audio...')\n execSync(\n `ffmpeg -i \"${videoPath}\" -i \"${wav}\" ` +\n `-filter_complex \"[0:a]volume=0.2[bg];[1:a]volume=1.0[vo];[bg][vo]amix=inputs=2:duration=first[a]\" ` +\n `-map 0:v -map \"[a]\" -c:v copy -y \"${out}\" -loglevel error`\n )\n return out\n}\n"],"mappings":";;;;;;;AAAA,SAAS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AAM,YAAY,CAAC,CAAC;AACxE,UAAM,iBAAiB,MAAM,iBAAiB,oBAAoB,cAAc,MAAM;AAEtF,WAAO;AAAA,MACL,UAAgB,QAAQ,MAAM;AAAA,MAC9B,UAAgB,QAAQ,MAAM;AAAA,MAC9B;AAAA,MACA,MAAgB,QAAQ;AAAA,MACxB,aAAgB,QAAQ;AAAA,MACxB,aAAgB,QAAQ;AAAA,MACxB,WAAgB,QAAQ;AAAA,MACxB,WAAgB,QAAQ;AAAA,IAC1B;AAAA,EACF;AACF;","names":["execSync","writeFileSync","mkdirSync","tmpdir","join","fal","result","writeFileSync","mkdirSync","join","fal","readFileSync","fal","join","writeFileSync","execSync","tmpdir","mkdirSync"]}
|
|
@@ -16,9 +16,11 @@ import {
|
|
|
16
16
|
harvestProblemResponse,
|
|
17
17
|
insufficientBalanceResponse,
|
|
18
18
|
serializeHarvestProblem
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SXTXMFEQ.js";
|
|
20
20
|
import {
|
|
21
21
|
SiteAuditJobRowSchema,
|
|
22
|
+
advanceWorkflowRunStep,
|
|
23
|
+
appendWorkflowArtifacts,
|
|
22
24
|
cancelJob,
|
|
23
25
|
checkRateLimit,
|
|
24
26
|
claimMonthlyFreeRefresh,
|
|
@@ -48,6 +50,7 @@ import {
|
|
|
48
50
|
getUserStats,
|
|
49
51
|
getWorkflowArtifact,
|
|
50
52
|
getWorkflowRun,
|
|
53
|
+
getWorkflowRunStepState,
|
|
51
54
|
getWorkflowSchedule,
|
|
52
55
|
ledgerExistsForOperation,
|
|
53
56
|
ledgerExistsForStripePI,
|
|
@@ -74,33 +77,31 @@ import {
|
|
|
74
77
|
setPassword,
|
|
75
78
|
setStripeCustomerId,
|
|
76
79
|
verifyPassword
|
|
77
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-DBQDG7EH.js";
|
|
78
81
|
import {
|
|
79
82
|
BrowserDriver,
|
|
80
|
-
MapsPlaceOptionsSchema,
|
|
81
|
-
MapsSearchOptionsSchema,
|
|
82
83
|
MapsSelectors,
|
|
83
|
-
RawMapsAboutAttributeSchema,
|
|
84
|
-
RawMapsHoursRowSchema,
|
|
85
|
-
RawMapsOverviewSchema,
|
|
86
|
-
RawMapsReviewStatsSchema,
|
|
87
84
|
browserServiceApiKey,
|
|
88
85
|
browserServiceProxyId,
|
|
89
86
|
buildYouTubeChannelVideosUrl,
|
|
90
87
|
deleteKernelProxyId,
|
|
91
88
|
harvest,
|
|
92
89
|
resolveKernelProxyId
|
|
93
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-XGUDTDZ2.js";
|
|
94
91
|
import {
|
|
95
92
|
CaptureSerpPageSnapshotsInputSchema,
|
|
93
|
+
CaptureSerpPageSnapshotsOutputSchema,
|
|
96
94
|
CaptureSerpSnapshotInputSchema,
|
|
95
|
+
CaptureSerpSnapshotOutputSchema,
|
|
97
96
|
HttpMcpToolExecutor,
|
|
98
97
|
buildPaaExtractorMcpServer,
|
|
99
98
|
configureReportSaving,
|
|
99
|
+
formatCaptureSerpPageSnapshots,
|
|
100
|
+
formatCaptureSerpSnapshot,
|
|
100
101
|
harvestTimeoutBudget,
|
|
101
102
|
liveWebToolAnnotations,
|
|
102
103
|
outputBaseDir
|
|
103
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-O5J7E4VX.js";
|
|
104
105
|
import {
|
|
105
106
|
CaptchaError,
|
|
106
107
|
RECAPTCHA_INSTRUCTIONS,
|
|
@@ -111,10 +112,23 @@ import {
|
|
|
111
112
|
listWorkflowDefinitions,
|
|
112
113
|
rowsToCsv,
|
|
113
114
|
runWorkflow,
|
|
115
|
+
runWorkflowStep,
|
|
114
116
|
workflowDefinition,
|
|
115
|
-
workflowOutputBaseDir
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
workflowOutputBaseDir,
|
|
118
|
+
workflowStepCount,
|
|
119
|
+
workflowSupportsSteps
|
|
120
|
+
} from "./chunk-H2R232HK.js";
|
|
121
|
+
import {
|
|
122
|
+
DEFAULT_MAPS_PROXY_MODE,
|
|
123
|
+
DEFAULT_PROXY_MODE,
|
|
124
|
+
MapsPlaceOptionsSchema,
|
|
125
|
+
MapsSearchOptionsSchema,
|
|
126
|
+
RawMapsAboutAttributeSchema,
|
|
127
|
+
RawMapsHoursRowSchema,
|
|
128
|
+
RawMapsOverviewSchema,
|
|
129
|
+
RawMapsReviewStatsSchema
|
|
130
|
+
} from "./chunk-LFATOGDF.js";
|
|
131
|
+
import "./chunk-XKUDVN2E.js";
|
|
118
132
|
|
|
119
133
|
// src/api/outbound-sanitize.ts
|
|
120
134
|
var KEY_RENAMES = {
|
|
@@ -7245,6 +7259,7 @@ var YouTubeHarvestOptionsSchema = z10.object({
|
|
|
7245
7259
|
downloadMp3: z10.boolean().default(false),
|
|
7246
7260
|
outputDir: z10.string().default("./yt-output"),
|
|
7247
7261
|
kernelApiKey: z10.string().optional(),
|
|
7262
|
+
kernelProxyId: z10.string().optional(),
|
|
7248
7263
|
headless: z10.boolean().default(false)
|
|
7249
7264
|
}).refine(
|
|
7250
7265
|
(o) => o.mode === "search" ? !!o.query : !!o.channelHandle,
|
|
@@ -7498,6 +7513,7 @@ var YouTubeExtractor = class {
|
|
|
7498
7513
|
const config = {
|
|
7499
7514
|
headless: options.headless,
|
|
7500
7515
|
kernelApiKey: options.kernelApiKey,
|
|
7516
|
+
kernelProxyId: options.kernelProxyId,
|
|
7501
7517
|
viewport: { width: 1280, height: 800 },
|
|
7502
7518
|
locale: "en-US"
|
|
7503
7519
|
};
|
|
@@ -7697,7 +7713,11 @@ async function ytHarvest(rawOptions) {
|
|
|
7697
7713
|
throw new Error("A browser backend API key is required \u2014 YouTube harvesting requires a stealth session.");
|
|
7698
7714
|
}
|
|
7699
7715
|
const raw = typeof rawOptions === "object" && rawOptions !== null ? rawOptions : {};
|
|
7700
|
-
const options = YouTubeHarvestOptionsSchema.parse({
|
|
7716
|
+
const options = YouTubeHarvestOptionsSchema.parse({
|
|
7717
|
+
kernelApiKey,
|
|
7718
|
+
kernelProxyId: browserServiceProxyId(),
|
|
7719
|
+
...raw
|
|
7720
|
+
});
|
|
7701
7721
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
7702
7722
|
try {
|
|
7703
7723
|
const result = await extractOnce(options);
|
|
@@ -7789,10 +7809,11 @@ function parseTimedtextXml(xml) {
|
|
|
7789
7809
|
async function fetchViaKernelInnertube(videoId) {
|
|
7790
7810
|
const kernelApiKey = browserServiceApiKey();
|
|
7791
7811
|
if (!kernelApiKey) return null;
|
|
7812
|
+
const kernelProxyId = browserServiceProxyId();
|
|
7792
7813
|
const driver = new BrowserDriver();
|
|
7793
7814
|
const start = Date.now();
|
|
7794
7815
|
try {
|
|
7795
|
-
await driver.launch({ kernelApiKey, headless: true, viewport: { width: 1280, height: 800 }, locale: "en-US" });
|
|
7816
|
+
await driver.launch({ kernelApiKey, kernelProxyId, headless: true, viewport: { width: 1280, height: 800 }, locale: "en-US" });
|
|
7796
7817
|
const page = driver.getPage();
|
|
7797
7818
|
await driver.navigateTo(`https://www.youtube.com/watch?v=${videoId}`);
|
|
7798
7819
|
await page.waitForFunction(
|
|
@@ -7887,10 +7908,10 @@ async function captureAudioViaMediaRecorder(page) {
|
|
|
7887
7908
|
if (!result.ok || !result.base64 || !result.mimeType) return null;
|
|
7888
7909
|
return { bytes: Buffer.from(result.base64, "base64"), mimeType: result.mimeType };
|
|
7889
7910
|
}
|
|
7890
|
-
async function attemptKernelWhisper(videoId, kernelApiKey, falKey, start) {
|
|
7911
|
+
async function attemptKernelWhisper(videoId, kernelApiKey, kernelProxyId, falKey, start) {
|
|
7891
7912
|
const driver = new BrowserDriver();
|
|
7892
7913
|
try {
|
|
7893
|
-
await driver.launch({ kernelApiKey, headless: true, viewport: { width: 1280, height: 800 }, locale: "en-US" });
|
|
7914
|
+
await driver.launch({ kernelApiKey, kernelProxyId, headless: true, viewport: { width: 1280, height: 800 }, locale: "en-US" });
|
|
7894
7915
|
const page = driver.getPage();
|
|
7895
7916
|
await driver.navigateTo(`https://www.youtube.com/watch?v=${videoId}`);
|
|
7896
7917
|
await page.waitForFunction(
|
|
@@ -7932,12 +7953,13 @@ async function attemptKernelWhisper(videoId, kernelApiKey, falKey, start) {
|
|
|
7932
7953
|
}
|
|
7933
7954
|
async function fetchViaKernelWhisper(videoId) {
|
|
7934
7955
|
const kernelApiKey = browserServiceApiKey();
|
|
7956
|
+
const kernelProxyId = browserServiceProxyId();
|
|
7935
7957
|
const falKey = process.env.FAL_KEY;
|
|
7936
7958
|
if (!kernelApiKey || !falKey) return null;
|
|
7937
7959
|
const start = Date.now();
|
|
7938
7960
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
7939
7961
|
if (attempt > 0) await new Promise((r) => setTimeout(r, 2e3 * attempt));
|
|
7940
|
-
const result = await attemptKernelWhisper(videoId, kernelApiKey, falKey, start);
|
|
7962
|
+
const result = await attemptKernelWhisper(videoId, kernelApiKey, kernelProxyId, falKey, start);
|
|
7941
7963
|
if (result) return result;
|
|
7942
7964
|
}
|
|
7943
7965
|
return null;
|
|
@@ -9396,9 +9418,8 @@ async function kernelLaunchOptsResidential() {
|
|
|
9396
9418
|
try {
|
|
9397
9419
|
const resolution = await resolveKernelProxyId({
|
|
9398
9420
|
kernelApiKey: browserServiceApiKey(),
|
|
9399
|
-
proxyMode:
|
|
9421
|
+
proxyMode: DEFAULT_PROXY_MODE,
|
|
9400
9422
|
configuredKernelProxyId: browserServiceProxyId(),
|
|
9401
|
-
location: "New York, NY",
|
|
9402
9423
|
gl: "us"
|
|
9403
9424
|
});
|
|
9404
9425
|
if (resolution.kernelProxyId) proxyId = resolution.kernelProxyId;
|
|
@@ -10845,7 +10866,7 @@ var DirectoryWorkflowOptionsSchema = z15.object({
|
|
|
10845
10866
|
saveCsv: z15.boolean().default(true),
|
|
10846
10867
|
gl: z15.string().length(2).default("us"),
|
|
10847
10868
|
hl: z15.string().length(2).default("en"),
|
|
10848
|
-
proxyMode: z15.enum(["location", "configured", "none"]).default(
|
|
10869
|
+
proxyMode: z15.enum(["location", "configured", "none"]).default(DEFAULT_MAPS_PROXY_MODE),
|
|
10849
10870
|
proxyZip: z15.string().regex(/^\d{5}$/).optional(),
|
|
10850
10871
|
debug: z15.boolean().default(false),
|
|
10851
10872
|
headless: z15.boolean().default(true),
|
|
@@ -11302,6 +11323,88 @@ async function executeWorkflowRun(input) {
|
|
|
11302
11323
|
throw err;
|
|
11303
11324
|
}
|
|
11304
11325
|
}
|
|
11326
|
+
async function runWorkflowStepAndPersist(input) {
|
|
11327
|
+
const runId = input.run.id;
|
|
11328
|
+
const workflowId = input.run.workflow_id;
|
|
11329
|
+
await markWorkflowRunRunning(runId);
|
|
11330
|
+
let result;
|
|
11331
|
+
try {
|
|
11332
|
+
result = await runWorkflowStep(workflowId, input.workflowInput, {
|
|
11333
|
+
stepIndex: input.stepIndex,
|
|
11334
|
+
state: input.priorState ?? void 0,
|
|
11335
|
+
options: {
|
|
11336
|
+
apiKey: input.user.api_key,
|
|
11337
|
+
apiUrl: input.apiUrl,
|
|
11338
|
+
outputDir: hostedWorkflowOutputDir(),
|
|
11339
|
+
runId,
|
|
11340
|
+
headers: input.concurrencyLockId ? { "x-mcp-scraper-concurrency-lock": input.concurrencyLockId } : void 0
|
|
11341
|
+
}
|
|
11342
|
+
});
|
|
11343
|
+
} catch (err) {
|
|
11344
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
11345
|
+
await failWorkflowRunRecord(runId, message, { error: message });
|
|
11346
|
+
const failedRun = await getWorkflowRun(runId, input.user.id);
|
|
11347
|
+
if (failedRun) await deliverWorkflowWebhook({ userId: input.user.id, run: failedRun, scheduleId: failedRun.schedule_id, webhookUrl: input.webhookUrl ?? null, summary: null, artifacts: [] });
|
|
11348
|
+
throw err;
|
|
11349
|
+
}
|
|
11350
|
+
if (result.artifacts.length) {
|
|
11351
|
+
await appendWorkflowArtifacts(runId, input.user.id, result.artifacts.map((a) => ({
|
|
11352
|
+
kind: a.kind,
|
|
11353
|
+
label: a.label,
|
|
11354
|
+
path: a.path,
|
|
11355
|
+
bytes: a.bytes,
|
|
11356
|
+
rows: a.rows,
|
|
11357
|
+
content: a.content
|
|
11358
|
+
})));
|
|
11359
|
+
}
|
|
11360
|
+
const logEntry = {
|
|
11361
|
+
stepIndex: result.stepIndex,
|
|
11362
|
+
stepId: result.stepId,
|
|
11363
|
+
stepTitle: result.stepTitle,
|
|
11364
|
+
output: result.output,
|
|
11365
|
+
warnings: result.warnings,
|
|
11366
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
11367
|
+
};
|
|
11368
|
+
const status = result.isLast ? result.summary?.status ?? "succeeded" : "running";
|
|
11369
|
+
await advanceWorkflowRunStep(runId, {
|
|
11370
|
+
stepIndex: result.stepIndex + 1,
|
|
11371
|
+
totalSteps: result.totalSteps,
|
|
11372
|
+
state: result.state,
|
|
11373
|
+
status,
|
|
11374
|
+
logEntry,
|
|
11375
|
+
appendLog: input.priorLog
|
|
11376
|
+
});
|
|
11377
|
+
if (result.isLast && result.summary) {
|
|
11378
|
+
const manifest = await readManifestFromSummary(result.summary);
|
|
11379
|
+
await completeWorkflowRunRecord(runId, result.summary.status, manifest ?? { summary: result.summary });
|
|
11380
|
+
}
|
|
11381
|
+
const run = await getWorkflowRun(runId, input.user.id);
|
|
11382
|
+
const artifacts = await listWorkflowArtifacts(runId, input.user.id);
|
|
11383
|
+
if (result.isLast && run) {
|
|
11384
|
+
await deliverWorkflowWebhook({ userId: input.user.id, run, scheduleId: run.schedule_id, webhookUrl: input.webhookUrl ?? null, summary: result.summary, artifacts });
|
|
11385
|
+
}
|
|
11386
|
+
const definition = workflowDefinition(workflowId);
|
|
11387
|
+
const nextIndex = result.stepIndex + 1;
|
|
11388
|
+
const nextStep = result.isLast ? null : {
|
|
11389
|
+
index: nextIndex,
|
|
11390
|
+
id: definition.steps?.[nextIndex]?.id ?? null,
|
|
11391
|
+
title: definition.steps?.[nextIndex]?.title ?? null
|
|
11392
|
+
};
|
|
11393
|
+
return {
|
|
11394
|
+
run: run ? exposeRun(input.c, run, artifacts) : null,
|
|
11395
|
+
summary: result.isLast ? result.summary : null,
|
|
11396
|
+
step: {
|
|
11397
|
+
index: result.stepIndex,
|
|
11398
|
+
id: result.stepId,
|
|
11399
|
+
title: result.stepTitle,
|
|
11400
|
+
totalSteps: result.totalSteps,
|
|
11401
|
+
output: result.output,
|
|
11402
|
+
warnings: result.warnings
|
|
11403
|
+
},
|
|
11404
|
+
nextStep,
|
|
11405
|
+
done: result.isLast
|
|
11406
|
+
};
|
|
11407
|
+
}
|
|
11305
11408
|
workflowApp.get("/definitions", createApiKeyAuth(), (c) => {
|
|
11306
11409
|
return c.json({ workflows: listWorkflowDefinitions() });
|
|
11307
11410
|
});
|
|
@@ -11324,7 +11427,29 @@ workflowApp.post("/run", createApiKeyAuth(), async (c) => {
|
|
|
11324
11427
|
if (!gate.ok) return c.json(concurrencyLimitExceededResponse(gate), 429, { "Retry-After": String(gate.retryAfterSeconds) });
|
|
11325
11428
|
let run = null;
|
|
11326
11429
|
try {
|
|
11327
|
-
|
|
11430
|
+
const stepwise = workflowSupportsSteps(parsed.data.workflowId);
|
|
11431
|
+
run = await createWorkflowRun({
|
|
11432
|
+
userId: user.id,
|
|
11433
|
+
workflowId: parsed.data.workflowId,
|
|
11434
|
+
workflowInput: input,
|
|
11435
|
+
webhookUrl,
|
|
11436
|
+
totalSteps: stepwise ? workflowStepCount(parsed.data.workflowId) : 1
|
|
11437
|
+
});
|
|
11438
|
+
if (stepwise) {
|
|
11439
|
+
const response = await runWorkflowStepAndPersist({
|
|
11440
|
+
c,
|
|
11441
|
+
user,
|
|
11442
|
+
run,
|
|
11443
|
+
workflowInput: input,
|
|
11444
|
+
stepIndex: 0,
|
|
11445
|
+
priorState: null,
|
|
11446
|
+
priorLog: [],
|
|
11447
|
+
apiUrl: originFromUrl(c.req.url),
|
|
11448
|
+
webhookUrl,
|
|
11449
|
+
concurrencyLockId: gate.lockId
|
|
11450
|
+
});
|
|
11451
|
+
return c.json(response);
|
|
11452
|
+
}
|
|
11328
11453
|
const executed = await executeWorkflowRun({
|
|
11329
11454
|
runId: run.id,
|
|
11330
11455
|
user,
|
|
@@ -11334,7 +11459,7 @@ workflowApp.post("/run", createApiKeyAuth(), async (c) => {
|
|
|
11334
11459
|
webhookUrl,
|
|
11335
11460
|
concurrencyLockId: gate.lockId
|
|
11336
11461
|
});
|
|
11337
|
-
return c.json({ run: exposeRun(c, executed.run, executed.artifacts), summary: executed.summary });
|
|
11462
|
+
return c.json({ run: exposeRun(c, executed.run, executed.artifacts), summary: executed.summary, done: true });
|
|
11338
11463
|
} catch (err) {
|
|
11339
11464
|
const failed = run ? await getWorkflowRun(run.id, user.id) : null;
|
|
11340
11465
|
return c.json({ run: failed, error: err instanceof Error ? err.message : String(err) }, 500);
|
|
@@ -11342,6 +11467,50 @@ workflowApp.post("/run", createApiKeyAuth(), async (c) => {
|
|
|
11342
11467
|
await releaseConcurrencyGate(gate.lockId);
|
|
11343
11468
|
}
|
|
11344
11469
|
});
|
|
11470
|
+
var TERMINAL_RUN_STATUSES = ["succeeded", "partial", "failed", "cancelled"];
|
|
11471
|
+
workflowApp.post("/runs/:id/step", createApiKeyAuth(), async (c) => {
|
|
11472
|
+
const user = c.get("user");
|
|
11473
|
+
const run = await getWorkflowRun(c.req.param("id"), user.id);
|
|
11474
|
+
if (!run) return c.json({ error: "Run not found" }, 404);
|
|
11475
|
+
if (!workflowSupportsSteps(run.workflow_id)) {
|
|
11476
|
+
return c.json({ error: `Workflow "${run.workflow_id}" does not support stepwise execution` }, 400);
|
|
11477
|
+
}
|
|
11478
|
+
const artifactsNow = await listWorkflowArtifacts(run.id, user.id);
|
|
11479
|
+
if (TERMINAL_RUN_STATUSES.includes(run.status)) {
|
|
11480
|
+
return c.json({ run: exposeRun(c, run, artifactsNow), done: true, error: `Run is already ${run.status}` }, 409);
|
|
11481
|
+
}
|
|
11482
|
+
const stepState = await getWorkflowRunStepState(run.id, user.id);
|
|
11483
|
+
const stepIndex = stepState?.stepIndex ?? run.step_index;
|
|
11484
|
+
const totalSteps = workflowStepCount(run.workflow_id);
|
|
11485
|
+
if (stepIndex >= totalSteps) {
|
|
11486
|
+
return c.json({ run: exposeRun(c, run, artifactsNow), done: true, error: "No remaining steps" }, 409);
|
|
11487
|
+
}
|
|
11488
|
+
const gate = await acquireConcurrencyGate(user, "workflow_run", {
|
|
11489
|
+
ttlSeconds: 60 * 60,
|
|
11490
|
+
metadata: { workflowId: run.workflow_id, step: stepIndex }
|
|
11491
|
+
});
|
|
11492
|
+
if (!gate.ok) return c.json(concurrencyLimitExceededResponse(gate), 429, { "Retry-After": String(gate.retryAfterSeconds) });
|
|
11493
|
+
try {
|
|
11494
|
+
const response = await runWorkflowStepAndPersist({
|
|
11495
|
+
c,
|
|
11496
|
+
user,
|
|
11497
|
+
run,
|
|
11498
|
+
workflowInput: run.input,
|
|
11499
|
+
stepIndex,
|
|
11500
|
+
priorState: stepState?.state ?? null,
|
|
11501
|
+
priorLog: stepState?.stepLog ?? run.step_log,
|
|
11502
|
+
apiUrl: originFromUrl(c.req.url),
|
|
11503
|
+
webhookUrl: run.webhook_url,
|
|
11504
|
+
concurrencyLockId: gate.lockId
|
|
11505
|
+
});
|
|
11506
|
+
return c.json(response);
|
|
11507
|
+
} catch (err) {
|
|
11508
|
+
const failed = await getWorkflowRun(run.id, user.id);
|
|
11509
|
+
return c.json({ run: failed, error: err instanceof Error ? err.message : String(err) }, 500);
|
|
11510
|
+
} finally {
|
|
11511
|
+
await releaseConcurrencyGate(gate.lockId);
|
|
11512
|
+
}
|
|
11513
|
+
});
|
|
11345
11514
|
workflowApp.get("/runs", createApiKeyAuth(), async (c) => {
|
|
11346
11515
|
const user = c.get("user");
|
|
11347
11516
|
const runs = await listWorkflowRuns(user.id);
|
|
@@ -11360,14 +11529,17 @@ workflowApp.get("/runs/:id/artifacts/:artifactId", createApiKeyAuth(), async (c)
|
|
|
11360
11529
|
if (!run) return c.json({ error: "Run not found" }, 404);
|
|
11361
11530
|
const artifact = await getWorkflowArtifact(c.req.param("artifactId"), user.id);
|
|
11362
11531
|
if (!artifact || artifact.run_id !== run.id) return c.json({ error: "Artifact not found" }, 404);
|
|
11532
|
+
const filename = artifact.path.split("/").pop() || artifact.id;
|
|
11533
|
+
const headers = {
|
|
11534
|
+
"Content-Type": artifact.content_type,
|
|
11535
|
+
"Content-Disposition": `attachment; filename="${filename}"`
|
|
11536
|
+
};
|
|
11537
|
+
if (artifact.content != null) {
|
|
11538
|
+
return new Response(artifact.content, { headers });
|
|
11539
|
+
}
|
|
11363
11540
|
try {
|
|
11364
11541
|
const content = await readFile2(artifact.path);
|
|
11365
|
-
return new Response(content, {
|
|
11366
|
-
headers: {
|
|
11367
|
-
"Content-Type": artifact.content_type,
|
|
11368
|
-
"Content-Disposition": `attachment; filename="${artifact.path.split("/").pop() || artifact.id}"`
|
|
11369
|
-
}
|
|
11370
|
-
});
|
|
11542
|
+
return new Response(content, { headers });
|
|
11371
11543
|
} catch {
|
|
11372
11544
|
return c.json({ error: "Artifact file is no longer available" }, 410);
|
|
11373
11545
|
}
|
|
@@ -11905,7 +12077,7 @@ var SerpIntelligenceCaptureBodySchema = z17.object({
|
|
|
11905
12077
|
gl: z17.string().trim().length(2).default("us"),
|
|
11906
12078
|
hl: z17.string().trim().length(2).default("en"),
|
|
11907
12079
|
device: z17.enum(SerpIntelligenceDeviceValues).default("desktop"),
|
|
11908
|
-
proxyMode: z17.enum(SerpIntelligenceProxyModeValues).default(
|
|
12080
|
+
proxyMode: z17.enum(SerpIntelligenceProxyModeValues).default(DEFAULT_PROXY_MODE),
|
|
11909
12081
|
proxyZip: z17.string().regex(/^\d{5}$/).optional(),
|
|
11910
12082
|
pages: z17.number().int().min(1).max(2).default(1),
|
|
11911
12083
|
debug: z17.boolean().default(false),
|
|
@@ -12437,16 +12609,18 @@ var mcpApp = new Hono9();
|
|
|
12437
12609
|
function registerSerpIntelligenceCaptureTools(server, executor) {
|
|
12438
12610
|
server.registerTool("capture_serp_snapshot", {
|
|
12439
12611
|
title: "SERP Intelligence Snapshot",
|
|
12440
|
-
description: "Capture a structured SERP Intelligence Google snapshot through POST /serp-intelligence/capture, the same product capture path used by Phoenix. Split query from location
|
|
12612
|
+
description: "Capture a structured SERP Intelligence Google snapshot through POST /serp-intelligence/capture, the same product capture path used by Phoenix. Split query from location and infer gl/hl. Omit proxyMode for normal use; the service defaults to the configured browser-service proxy without city/ZIP targeting for the highest general success rate. Use proxyMode location only when the user explicitly needs city/ZIP-targeted residential proxy evidence. Use none only for direct-network debugging. Set debug true when investigating location evidence, proxy behavior, CAPTCHA, or capture reliability.",
|
|
12441
12613
|
inputSchema: CaptureSerpSnapshotInputSchema,
|
|
12614
|
+
outputSchema: CaptureSerpSnapshotOutputSchema,
|
|
12442
12615
|
annotations: liveWebToolAnnotations("SERP Intelligence Snapshot")
|
|
12443
|
-
}, async (input) => executor.captureSerpSnapshot(input));
|
|
12616
|
+
}, async (input) => formatCaptureSerpSnapshot(await executor.captureSerpSnapshot(input), input));
|
|
12444
12617
|
server.registerTool("capture_serp_page_snapshots", {
|
|
12445
12618
|
title: "SERP Intelligence Page Snapshots",
|
|
12446
12619
|
description: "Capture public ranking-page evidence through POST /serp-intelligence/page-snapshots, the same product page snapshot path used by Phoenix. Provide urls for simple captures or targets when preserving organic, AI citation, local-pack, configured target, or site-subject source metadata. Private IPs, localhost, file URLs, and internal URLs are rejected by the service. Use timeoutMs for slow pages and debug true for sanitized proxy/browser diagnostics.",
|
|
12447
12620
|
inputSchema: CaptureSerpPageSnapshotsInputSchema,
|
|
12621
|
+
outputSchema: CaptureSerpPageSnapshotsOutputSchema,
|
|
12448
12622
|
annotations: liveWebToolAnnotations("SERP Intelligence Page Snapshots")
|
|
12449
|
-
}, async (input) => executor.captureSerpPageSnapshots(input));
|
|
12623
|
+
}, async (input) => formatCaptureSerpPageSnapshots(await executor.captureSerpPageSnapshots(input), input));
|
|
12450
12624
|
}
|
|
12451
12625
|
mcpApp.all("/", async (c) => {
|
|
12452
12626
|
try {
|
|
@@ -14103,7 +14277,7 @@ app.post("/harvest", auth2, async (c) => {
|
|
|
14103
14277
|
gl: body.gl ?? "us",
|
|
14104
14278
|
hl: body.hl ?? "en",
|
|
14105
14279
|
device: body.device ?? "desktop",
|
|
14106
|
-
proxyMode: body.proxyMode ??
|
|
14280
|
+
proxyMode: body.proxyMode ?? DEFAULT_PROXY_MODE,
|
|
14107
14281
|
proxyZip: body.proxyZip,
|
|
14108
14282
|
debug: body.debug ?? false,
|
|
14109
14283
|
serpOnly: body.serpOnly ?? false,
|
|
@@ -14139,7 +14313,7 @@ app.post("/harvest/sync", auth2, async (c) => {
|
|
|
14139
14313
|
gl: body.gl ?? "us",
|
|
14140
14314
|
hl: body.hl ?? "en",
|
|
14141
14315
|
device: body.device ?? "desktop",
|
|
14142
|
-
proxyMode: body.proxyMode ??
|
|
14316
|
+
proxyMode: body.proxyMode ?? DEFAULT_PROXY_MODE,
|
|
14143
14317
|
proxyZip: body.proxyZip,
|
|
14144
14318
|
debug: body.debug ?? false,
|
|
14145
14319
|
serpOnly: body.serpOnly ?? false,
|
|
@@ -14605,7 +14779,7 @@ app.get("/cron/tick", async (c) => {
|
|
|
14605
14779
|
if (!process.env.CRON_SECRET || secret2 !== `Bearer ${process.env.CRON_SECRET}`) {
|
|
14606
14780
|
return c.json({ error: "Unauthorized" }, 401);
|
|
14607
14781
|
}
|
|
14608
|
-
const { drainQueue } = await import("./worker-
|
|
14782
|
+
const { drainQueue } = await import("./worker-MIYG2B2I.js");
|
|
14609
14783
|
const budget = { maxJobs: 10, deadlineMs: Date.now() + 28e4 };
|
|
14610
14784
|
const workflowDispatchResult = await dispatchDueWorkflowSchedules(`${new URL(c.req.url).protocol}//${new URL(c.req.url).host}`);
|
|
14611
14785
|
const [results, sweepResult] = await Promise.all([
|
|
@@ -14733,4 +14907,4 @@ app.get("/blog/:slug/", (c) => {
|
|
|
14733
14907
|
export {
|
|
14734
14908
|
app
|
|
14735
14909
|
};
|
|
14736
|
-
//# sourceMappingURL=server-
|
|
14910
|
+
//# sourceMappingURL=server-7NE45K2A.js.map
|