@viralspin/mcp 0.1.0 → 0.2.2

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.
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listIdeasTool = exports.queueIdeaTool = void 0;
4
+ /**
5
+ * queue_idea / list_ideas — the Prompt/Idea History bridge. Claude brainstorms
6
+ * with the user, then queues each idea (hook + script + an asset plan) here; it
7
+ * persists in Supabase (via /v1/spin/ideas) and shows up in the user's web
8
+ * /spin/history, cross-session and cross-browser. The asset_plan tells the user
9
+ * what's needed to execute (existing clips, AI B-roll, web images, kinetic text,
10
+ * or footage to film).
11
+ */
12
+ const client_js_1 = require("../client.js");
13
+ exports.queueIdeaTool = {
14
+ name: "queue_idea",
15
+ description: "Queue a content idea into the user's persistent Prompt/Idea History (shows in their web /spin/history, " +
16
+ "cross-browser). Use after brainstorming or after analyzing a saved/pasted post the user wants to replicate. " +
17
+ "Give it a `hook`, a ready-to-film `script` (they read it off the teleprompter at /create), the `topic`, and " +
18
+ "an `asset_plan` — per shot, say what to use: existing clip / AI-generated B-roll / web image (logo, person) / " +
19
+ "kinetic text overlay / footage to film. Set `source_url` if it came from a saved post. " +
20
+ "For a punchy 5-7s relatable joke where the VALUE IS THE OVERLAY CAPTION (not narration) — e.g. a video of " +
21
+ "someone on a plane captioned 'Flight attendant: OMG is there anyone onboard who can align cross-functional " +
22
+ "stakeholders while navigating ambiguity?' — use format:'reel_7s' and put the line in `caption`. " +
23
+ "GROUND every reel_7s in what is CURRENTLY GOING VIRAL in the creator's niche: call get_creator_profile " +
24
+ "for their niche + handles + topics, research the caption-reel formats + in-group jokes trending in that " +
25
+ "niche right now (their and adjacent creators' recent hits), and adapt a PROVEN pattern to their audience — " +
26
+ "don't invent a random joke. When generating a WEEK's batch of ideas, include AT LEAST ONE reel_7s modeled " +
27
+ "on that week's viral trend in the niche (set `source_url` to the post it's modeled on when there is one). " +
28
+ "reel_7s ASSET PLAN — if the caption has a SETUP → PAYOFF shape (before/after, question → reaction, 'four " +
29
+ "hours later:'), SPLIT the asset_plan into ONE BEAT PER SEGMENT so the shoot app can guide the creator " +
30
+ "part-by-part; a single-line caption = a single beat. Give each segment its own overlay line QUOTED in " +
31
+ "`note` (e.g. note: 'Overlay: \"Four hours later:\". Same framing as segment 1 - the contrast IS the joke.'), " +
32
+ "its own `search_terms`, and kind:'existing' — so the app can AI-pick that segment from the creator's camera " +
33
+ "roll (a 7s clip OR a photo) and they can still film/overwrite it themselves. " +
34
+ "HOOK PATTERN — a strong attention-grab is to OPEN ON A SURPRISED REACTION, then demonstrate the payoff " +
35
+ "('wait, what?!' → here's the thing). For ideas that PROMOTE VIRALSPIN (which are encouraged), lead the " +
36
+ "asset_plan with a reaction beat: first shot kind:'film' note the creator's surprised/delighted reaction " +
37
+ "(e.g. 'reacts stunned to how fast the reel was made'), THEN the demonstration beats. The mobile shoot flow " +
38
+ "(Take → React → Show → Build) mirrors this, so a react-first plan maps cleanly to how it's executed. " +
39
+ "SHOT PHRASING — write each `shot` as a SHORT, PLAIN, second-person creator ACTION they can just DO, not a " +
40
+ "cinematic third-person screenplay direction. GOOD: 'Show/gesture a perfect prompt', 'Sift through a bunch of AI " +
41
+ "output and pick a few good ones', 'React impressed at the polished result'. BAD (too abstract/wordy): 'Creator " +
42
+ "looking thoughtful, gesturing beyond the camera to a conceptual future', 'Hands sifting through a grid of " +
43
+ "AI-generated text/images on a tablet, selecting a few'. If a beat is really an EMOTIONAL/impressed MOMENT (e.g. " +
44
+ "'confidently presenting a refined high-quality result'), make it a REACTION the creator performs to camera — an " +
45
+ "impressed facial reaction — NOT a staged 'show' of holding up a screen. " +
46
+ "TAKE vs SHOW — the creator ON CAMERA (talking, gesturing, reacting) belongs to the Take + React steps, so those " +
47
+ "are kind:'film'. The 'SHOW IT' beats are footage of the SUBJECT — a screen recording, a demo, product/B-roll — " +
48
+ "NOT the creator; make them kind:'existing' (a clip the user records/provides) or kind:'ai_broll', and describe " +
49
+ "WHAT'S ON SCREEN, not the person. NEVER write a show/demo beat as 'creator looking thoughtful' or 'creator " +
50
+ "pointing at a screen' — that's a talking-head (Take). E.g. a demo beat = existing 'Screen-record the bad-vs-good " +
51
+ "prompt output', not film 'Creator points to the screen'. " +
52
+ "NO REDUNDANT TAKE BEATS — the creator reads the WHOLE script off the teleprompter in step 1, so NEVER add a " +
53
+ "kind:'film' beat that is just 'talk/gesture to camera as you tee up the idea': that IS the Take, and it orphans " +
54
+ "in the shoot UI. A kind:'film' beat must be a PERFORMED MOMENT — a face or a GESTURE — because those become " +
55
+ "real tasks in the React step (step 2). Reach for a gesture when a phrase invites one: 'the real secret…' → film " +
56
+ "'Shhh - index finger to your lips as you tease the secret'. " +
57
+ "EVERY LINE SHOULD HAVE SOMETHING ON SCREEN — the shoot app shows the script beside an 'on screen' column, so " +
58
+ "cover the script with beats, and lean on the NON-FILM kinds so the creator isn't asked to shoot everything: " +
59
+ "kind:'web_image' = a logo/graphic/image PULLED FROM THE WEB, floated in a card beside the creator's head (use it " +
60
+ "when a concept has an obvious visual — 'AI success' → a trending-up chart / trophy); kind:'kinetic' = text " +
61
+ "overlays AND animated motion graphics. Describe a motion graphic in PLAIN TERMS of what the viewer sees ('a " +
62
+ "terminal window that types the prompt out') — never name an implementation (don't say 'SVG', 'Lottie' or " +
63
+ "'Remotion'): these are drawn natively on the phone, so an implementation name is both wrong and meaningless to " +
64
+ "the creator reading the plan. A terminal/typing animation is the one bespoke motion graphic that renders today " +
65
+ "(say 'terminal' or 'typing' in the shot and it's picked up); any other kinetic beat renders as its text overlay, " +
66
+ "so put the words you want burned on screen IN QUOTES. " +
67
+ "For any web_image/kinetic overlay DON'T pin an exact position — say it floats above the creator's head " +
68
+ "or wherever there's space, and note that placement is resolved at render so it won't collide with the captions.",
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {
72
+ hook: { type: "string", description: "The scroll-stopping opening line / concept." },
73
+ script: { type: "string", description: "The full narration script to film (teleprompter-ready)." },
74
+ topic: { type: "string", description: "The core topic / pillar this idea belongs to." },
75
+ tags: { type: "array", items: { type: "string" }, description: "Optional tags." },
76
+ asset_plan: {
77
+ type: "array",
78
+ description: "Per-shot plan: [{shot, kind:'existing'|'ai_broll'|'web_image'|'kinetic'|'film', note, narration, search_terms, asset_url?}]. " +
79
+ "ALWAYS set `search_terms` on any SHOW beat (existing / ai_broll) AND on every `web_image` beat — on a " +
80
+ "web_image it's the WEB SEARCH we run to find the graphic, and a result is only kept if its title mentions " +
81
+ "one of these terms, so an abstract concept with no concrete nouns finds nothing and the card falls back to " +
82
+ "plain text (e.g. 'AI success' → search_terms 'trophy, winner podium, chart going up, success'). " +
83
+ "Set `asset_url` instead when a SPECIFIC image is wanted; then no search runs. search_terms are " +
84
+ "CONCRETE VISUAL NOUNS, comma-separated, " +
85
+ "that could literally appear in a photo — the shoot app matches these against on-device Vision labels of " +
86
+ "the creator's camera roll. `shot` is written for a HUMAN to read and is often abstract, which matches " +
87
+ "nothing; `search_terms` is what the matcher actually searches. E.g. shot 'Sift through a bunch of AI " +
88
+ "output and pick a few good ones' → search_terms 'tablet, laptop screen, computer monitor, grid of images, " +
89
+ "hands typing'. Use plain everyday objects/places/people (laptop, screen, desk, phone, coffee, office, " +
90
+ "whiteboard) — NOT abstractions ('AI output', 'workflow', 'the future'). " +
91
+ "ALWAYS set `narration` to the EXACT word(s) from `script` the creator is SPEAKING while this beat is on " +
92
+ "screen — the beats run in order and together cover the whole script, so each beat's narration is its slice of " +
93
+ "the script verbatim. A slice does NOT have to be a whole sentence: when an overlay is triggered by SPECIFIC " +
94
+ "WORDS, CUT THE SLICE AT THOSE WORDS so the beat lands on the row it belongs to. E.g. for 'The real secret to " +
95
+ "AI success isn't learning to prompt.' with a shush gesture on 'the real secret' and a web graphic on 'AI " +
96
+ "success', emit TWO beats — narration 'The real secret' then 'to AI success isn't learning to prompt.' — " +
97
+ "NOT one sentence-beat plus a graphic pushed onto the NEXT sentence, which mis-times the graphic. This is what the shoot UI shows in quotes under each shot, so the creator knows what " +
98
+ "they're saying during it. (A kinetic text-overlay beat still has narration playing under it.)",
99
+ items: {
100
+ type: "object",
101
+ properties: {
102
+ shot: { type: "string" },
103
+ kind: { type: "string", enum: ["existing", "ai_broll", "web_image", "kinetic", "film"] },
104
+ note: { type: "string" },
105
+ narration: { type: "string", description: "The verbatim script line(s) spoken during this beat." },
106
+ search_terms: { type: "string", description: "Concrete visual nouns (comma-separated) to match the creator's camera roll, e.g. 'tablet, laptop screen, grid of images'." },
107
+ asset_url: { type: "string" },
108
+ },
109
+ required: ["shot", "kind"],
110
+ },
111
+ },
112
+ source_url: { type: "string", description: "The saved/pasted post URL this idea is modeled on, if any." },
113
+ format: { type: "string", enum: ["video", "carousel", "image", "reel_7s"], description: "How it's executed: 'video' (film off the teleprompter) | 'carousel' (image carousel) | 'image' | 'reel_7s' (a 5-7s caption reel — see below). Default video." },
114
+ caption: { type: "string", description: "For format 'reel_7s' ONLY: the single punchy OVERLAY CAPTION that IS the joke/value (e.g. \"Flight attendant: OMG is there anyone onboard who can align cross-functional stakeholders while navigating ambiguity?\"). The user films 5-7s of themselves reacting / doing a light action (or any B-roll — it barely matters); the caption carries it. Put the caption here AND in `hook`." },
115
+ week: { type: "string", description: "ISO week tag for weekly batches, e.g. '2026-W27'. Group a week's 5 ideas under the same value." },
116
+ },
117
+ },
118
+ async execute(args) {
119
+ // For a 7s caption reel the overlay caption IS the content — use it as the hook/script if not given.
120
+ const hook = args.hook ?? args.caption;
121
+ const script = args.script ?? (args.format === "reel_7s" ? args.caption : undefined);
122
+ if (!hook && !script)
123
+ return "Give the idea at least a `hook` or a `script` (or a `caption` for reel_7s).";
124
+ const r = await (0, client_js_1.post)("/v1/spin/ideas", {
125
+ hook,
126
+ script,
127
+ topic: args.topic,
128
+ tags: args.tags,
129
+ asset_plan: args.asset_plan,
130
+ source_url: args.source_url,
131
+ format: args.format,
132
+ caption: args.caption,
133
+ week: args.week,
134
+ });
135
+ const planNote = args.asset_plan?.length ? ` with a ${args.asset_plan.length}-shot asset plan` : "";
136
+ return (`Queued idea ${r.id}${planNote} → it's in the user's Prompt/Idea History (/spin/history), saved across sessions + browsers.\n` +
137
+ `They can open it, film the script on the teleprompter at /create, and the plan says what B-roll to use vs film.`);
138
+ },
139
+ };
140
+ exports.listIdeasTool = {
141
+ name: "list_ideas",
142
+ description: "List the user's queued content ideas (their Prompt/Idea History). Optionally filter by status " +
143
+ "(queued / scripted / filmed / done / dismissed). Use to resume planning or pick the next idea to execute.",
144
+ inputSchema: {
145
+ type: "object",
146
+ properties: {
147
+ status: { type: "string", enum: ["queued", "scripted", "filmed", "done", "dismissed"], description: "Optional status filter." },
148
+ },
149
+ },
150
+ async execute(args) {
151
+ const q = args.status ? `?status=${encodeURIComponent(args.status)}` : "";
152
+ const r = await (0, client_js_1.get)(`/v1/spin/ideas${q}`);
153
+ if (!r.ideas.length)
154
+ return args.status ? `No ideas with status "${args.status}".` : "No ideas queued yet — brainstorm some and queue_idea them.";
155
+ const lines = r.ideas.map((i) => `- [${i.status}] ${i.hook || "(no hook)"}${i.topic ? ` · ${i.topic}` : ""}${i.source_url ? ` · from ${i.source_url}` : ""} (id ${i.id})`);
156
+ return [`${r.ideas.length} idea(s) in the Prompt/Idea History:`, ...lines].join("\n");
157
+ },
158
+ };
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishToMetaTool = exports.assembleImageAdTool = exports.prepareProductAssetTool = void 0;
4
+ const client_js_1 = require("../client.js");
5
+ const APP_BASE = process.env.VIRALSPIN_APP_URL || "https://app.viralspin.ai";
6
+ exports.prepareProductAssetTool = {
7
+ name: "prepare_product_asset",
8
+ description: "Download and verify a product image from a local path or public URL, upload it to ViralSpin " +
9
+ "cloud storage, and return a stable cloud URL ready for Higgsfield image ad generation.",
10
+ inputSchema: {
11
+ type: "object",
12
+ required: ["image_url"],
13
+ properties: {
14
+ image_url: {
15
+ type: "string",
16
+ description: "Local file path (e.g. C:/photos/product.jpg) or public URL of the product image.",
17
+ },
18
+ },
19
+ },
20
+ async execute({ image_url }) {
21
+ if (image_url.startsWith("http://") || image_url.startsWith("https://")) {
22
+ return `✅ Asset ready (already a URL):\n\n ${image_url}\n\nPass this to assemble_image_ad.`;
23
+ }
24
+ const { urls } = await (0, client_js_1.uploadFiles)([image_url]);
25
+ return [
26
+ `✅ Product asset uploaded:`,
27
+ ``,
28
+ ` ${urls[0]}`,
29
+ ``,
30
+ `Pass this URL to assemble_image_ad.`,
31
+ ].join("\n");
32
+ },
33
+ };
34
+ exports.assembleImageAdTool = {
35
+ name: "assemble_image_ad",
36
+ description: "Generate image ad variants from a product photo using Higgsfield AI. " +
37
+ "Uploads the product image, generates styled variants with your prompt, then creates a " +
38
+ "client review link showing all variants in a carousel. " +
39
+ "Requires Higgsfield credentials saved in ViralSpin Settings.",
40
+ inputSchema: {
41
+ type: "object",
42
+ required: ["product_image_path", "prompt"],
43
+ properties: {
44
+ product_image_path: {
45
+ type: "string",
46
+ description: "Local file path (e.g. C:/photos/product.jpg) or public URL of the product image.",
47
+ },
48
+ prompt: {
49
+ type: "string",
50
+ description: "Higgsfield styling prompt describing the desired ad aesthetic. " +
51
+ "Example: 'luxury product shot on white marble, soft studio lighting, premium brand aesthetic'",
52
+ },
53
+ pin: {
54
+ type: "string",
55
+ description: "Optional 4-digit PIN to protect the client review link.",
56
+ },
57
+ },
58
+ },
59
+ async execute({ product_image_path, prompt, pin }) {
60
+ // Upload local files; pass through URLs unchanged
61
+ let imageUrl = product_image_path;
62
+ if (!product_image_path.startsWith("http://") && !product_image_path.startsWith("https://")) {
63
+ const { urls } = await (0, client_js_1.uploadFiles)([product_image_path]);
64
+ imageUrl = urls[0];
65
+ }
66
+ // Start async generation job — Higgsfield lives on Python backend
67
+ const { job_id } = await (0, client_js_1.pyPost)("/v1/higgsfield/generate", {
68
+ product_image_url: imageUrl,
69
+ prompt,
70
+ });
71
+ // Poll until done (~3 min timeout)
72
+ let variants = [];
73
+ for (let attempt = 0; attempt < 40; attempt++) {
74
+ await new Promise((r) => setTimeout(r, 5000));
75
+ const status = await (0, client_js_1.pyGet)(`/v1/higgsfield/status/${job_id}`);
76
+ if (status.status === "complete") {
77
+ variants = status.variant_urls ?? [];
78
+ break;
79
+ }
80
+ if (status.status === "failed") {
81
+ throw new Error(`Higgsfield generation failed: ${status.error ?? "unknown error"}`);
82
+ }
83
+ }
84
+ if (!variants.length) {
85
+ throw new Error("Generation timed out after ~3 minutes — try again or check Higgsfield credentials");
86
+ }
87
+ // Create a review session with image variants displayed as a carousel
88
+ const { token } = await (0, client_js_1.post)("/v1/review-sessions", {
89
+ output_path: variants[0],
90
+ metadata: {
91
+ media_type: "image",
92
+ variants,
93
+ caption: prompt,
94
+ platform_targets: ["instagram", "facebook"],
95
+ },
96
+ pin: pin ?? null,
97
+ expires_hours: 168,
98
+ });
99
+ const reviewUrl = `${APP_BASE}/review/${token}`;
100
+ return [
101
+ `✅ ${variants.length} image ad variant${variants.length > 1 ? "s" : ""} generated!`,
102
+ ``,
103
+ `Review link: ${reviewUrl}`,
104
+ ``,
105
+ `Send this to your client — they'll see all ${variants.length} variants as a carousel`,
106
+ `and can Approve or Request Changes.`,
107
+ pin ? `PIN: ${pin}` : ``,
108
+ ``,
109
+ `To publish an approved variant:`,
110
+ ` publish_to_meta with media_url="${variants[0]}" and your caption.`,
111
+ ]
112
+ .filter((l) => l !== undefined)
113
+ .join("\n");
114
+ },
115
+ };
116
+ exports.publishToMetaTool = {
117
+ name: "publish_to_meta",
118
+ description: "Publish an image (or video) to Instagram and/or Facebook. " +
119
+ "Use after a client approves an image ad variant from assemble_image_ad.",
120
+ inputSchema: {
121
+ type: "object",
122
+ required: ["media_url", "platforms", "caption"],
123
+ properties: {
124
+ media_url: {
125
+ type: "string",
126
+ description: "Public URL of the approved image or video to publish.",
127
+ },
128
+ platforms: {
129
+ type: "array",
130
+ items: { type: "string", enum: ["instagram", "facebook"] },
131
+ description: "Target platforms: 'instagram', 'facebook', or both.",
132
+ },
133
+ caption: {
134
+ type: "string",
135
+ description: "Post caption (include hashtags here if desired).",
136
+ },
137
+ },
138
+ },
139
+ async execute({ media_url, platforms, caption }) {
140
+ const result = await (0, client_js_1.post)("/v1/publish/schedule", {
141
+ video_url: media_url,
142
+ platforms,
143
+ caption,
144
+ publish_now: true,
145
+ });
146
+ const lines = ["📸 Published to Meta:"];
147
+ const results = result.results ?? {};
148
+ for (const [platform, res] of Object.entries(results)) {
149
+ lines.push(` ${res.success ? "✅" : "❌"} ${platform}${res.error ? `: ${res.error}` : ""}`);
150
+ }
151
+ if (!Object.keys(results).length) {
152
+ lines.push(" (no platform results returned — check your connected accounts in Settings)");
153
+ }
154
+ return lines.join("\n");
155
+ },
156
+ };
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createKineticTextTool = void 0;
7
+ const child_process_1 = require("child_process");
8
+ const path_1 = __importDefault(require("path"));
9
+ const engine_js_1 = require("../engine.js");
10
+ const EFFECTS = ["typing", "billboard_flip", "isometric"];
11
+ const STYLES = ["terminal", "cinematic", "minimal"];
12
+ const FORMATS = ["9x16", "16x9", "1x1"];
13
+ function runKinetic(args) {
14
+ return new Promise((resolve, reject) => {
15
+ const child = (0, child_process_1.spawn)(process.platform === "win32" ? "node.exe" : "node", [path_1.default.join(engine_js_1.ENGINE_DIR, "kinetic.mjs"), ...args], { cwd: engine_js_1.ENGINE_DIR, env: { ...process.env } });
16
+ let stdout = "";
17
+ child.stdout.on("data", (d) => { stdout += d.toString(); });
18
+ child.stderr.on("data", (d) => process.stderr.write(d));
19
+ child.on("error", reject);
20
+ child.on("close", (code) => {
21
+ const m = stdout.match(/RESULT:(.+)/);
22
+ if (code === 0 && m)
23
+ resolve(m[1].trim());
24
+ else
25
+ reject(new Error(`Kinetic render failed (exit ${code}). ${stdout.slice(-300)}`));
26
+ });
27
+ });
28
+ }
29
+ exports.createKineticTextTool = {
30
+ name: "create_kinetic_text",
31
+ description: "Render a standalone cinematic typing-animation video — great for explainer intros that visually demo " +
32
+ "what a user types into the prompt. Text is typed out character-by-character with a blinking cursor " +
33
+ "while a 3D camera slowly pans, giving a cinematic 'Star Wars pull-back' feel. " +
34
+ "Three effects: 'typing' (character-by-character with 3D camera), " +
35
+ "'billboard_flip' (words fly from Z-depth and snap into place), " +
36
+ "'isometric' (letters extrude upward on a tilted plane). " +
37
+ "Three styles: 'terminal' (green-on-dark, monospace, scanlines), " +
38
+ "'cinematic' (white-on-black, serif, vignette), " +
39
+ "'minimal' (transparent background, for overlay use). " +
40
+ "Returns the path to a finished MP4 — feed it to publish_now or as A-roll in create_video_assembly.",
41
+ inputSchema: {
42
+ type: "object",
43
+ properties: {
44
+ text: {
45
+ type: "string",
46
+ description: "The text to animate — e.g. the prompt the user would type.",
47
+ },
48
+ effect: {
49
+ type: "string",
50
+ enum: EFFECTS,
51
+ description: "Animation style. Default: typing.",
52
+ },
53
+ style: {
54
+ type: "string",
55
+ enum: STYLES,
56
+ description: "Visual theme. terminal = green monospace; cinematic = white serif; minimal = transparent BG. Default: terminal.",
57
+ },
58
+ format: {
59
+ type: "string",
60
+ enum: FORMATS,
61
+ description: "Output aspect ratio. Default: 9x16 (vertical).",
62
+ },
63
+ font_size: {
64
+ type: "number",
65
+ description: "Font size in px. Auto-sized by format if omitted (72px for 9x16, 96px for 16x9).",
66
+ },
67
+ camera: {
68
+ type: "object",
69
+ description: "Override the 3D camera end position. Each field defaults to the effect's cinematic preset.",
70
+ properties: {
71
+ rotateX: { type: "number", description: "X-axis tilt in degrees (positive = tilt top toward viewer)." },
72
+ rotateY: { type: "number", description: "Y-axis turn in degrees." },
73
+ rotateZ: { type: "number", description: "Z-axis roll in degrees." },
74
+ translateZ: { type: "number", description: "Z-depth offset in px (negative = pull back/zoom out)." },
75
+ },
76
+ },
77
+ duration_sec: {
78
+ type: "number",
79
+ description: "Override clip length in seconds. Default: auto (≈ text.length × 0.1s + 1.5s hold).",
80
+ },
81
+ out: {
82
+ type: "string",
83
+ description: "Output MP4 path. Defaults to engine/out/kinetic_<timestamp>.mp4.",
84
+ },
85
+ },
86
+ required: ["text"],
87
+ },
88
+ async execute(args) {
89
+ if (!(0, engine_js_1.engineAvailable)("kinetic.mjs")) {
90
+ return ("create_kinetic_text needs the ViralSpin engine, which isn't bundled in this install.\n" +
91
+ "Set VIRALSPIN_ASSEMBLY_DIR to a local engine checkout to enable it.");
92
+ }
93
+ const cli = ["--text", args.text];
94
+ if (args.effect)
95
+ cli.push("--effect", args.effect);
96
+ if (args.style)
97
+ cli.push("--style", args.style);
98
+ if (args.format)
99
+ cli.push("--format", args.format);
100
+ if (args.font_size)
101
+ cli.push("--font-size", String(args.font_size));
102
+ if (args.duration_sec)
103
+ cli.push("--duration-sec", String(args.duration_sec));
104
+ if (args.out)
105
+ cli.push("--out", args.out);
106
+ if (args.camera) {
107
+ const c = args.camera;
108
+ if (c.rotateX != null)
109
+ cli.push("--camera-rx", String(c.rotateX));
110
+ if (c.rotateY != null)
111
+ cli.push("--camera-ry", String(c.rotateY));
112
+ if (c.rotateZ != null)
113
+ cli.push("--camera-rz", String(c.rotateZ));
114
+ if (c.translateZ != null)
115
+ cli.push("--camera-tz", String(c.translateZ));
116
+ }
117
+ const outPath = await runKinetic(cli);
118
+ return (`Kinetic text render complete.\n` +
119
+ `Output: ${outPath}\n` +
120
+ `Use this as a hook intro by passing it as A-roll to create_video_assembly, or publish directly with publish_now.`);
121
+ },
122
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.searchLocalIndexTool = exports.syncLocalIndexTool = void 0;
7
+ /**
8
+ * sync_local_index / search_local_index — make the user's LOCAL footage count in
9
+ * cloud idea-planning. sync_local_index analyzes a folder on the GPU (free when
10
+ * local mode is on) and pushes TAGS ONLY to the cloud catalog (files stay local);
11
+ * search_local_index finds existing local clips that fit a script/idea so Claude
12
+ * can recommend reusing them instead of filming new B-roll.
13
+ */
14
+ const child_process_1 = require("child_process");
15
+ const path_1 = __importDefault(require("path"));
16
+ const engine_js_1 = require("../engine.js");
17
+ const client_js_1 = require("../client.js");
18
+ function runIndex(folder) {
19
+ return new Promise((resolve, reject) => {
20
+ const child = (0, child_process_1.spawn)(process.platform === "win32" ? "node.exe" : "node", [path_1.default.join(engine_js_1.ENGINE_DIR, "index-folder.mjs"), folder], { cwd: engine_js_1.ENGINE_DIR, env: { ...process.env } });
21
+ let out = "";
22
+ child.stdout.on("data", (d) => { out += d.toString(); });
23
+ child.stderr.on("data", (d) => process.stderr.write(d));
24
+ child.on("error", reject);
25
+ child.on("close", (code) => {
26
+ const m = out.match(/RESULT:([\s\S]+)/);
27
+ if (code === 0 && m)
28
+ resolve(m[1].trim());
29
+ else
30
+ reject(new Error(out.slice(-400) || `index exited ${code}`));
31
+ });
32
+ });
33
+ }
34
+ exports.syncLocalIndexTool = {
35
+ name: "sync_local_index",
36
+ description: "Analyze a LOCAL folder of footage (free on the user's GPU when local mode is on) and SYNC the tags to the " +
37
+ "cloud so it's searchable when planning ideas / asset-plans — WITHOUT uploading the files (tags + paths only; " +
38
+ "media stays local until actually used). Run this once on the user's B-roll folders so search_local_index and " +
39
+ "idea planning know what they already have.",
40
+ inputSchema: {
41
+ type: "object",
42
+ properties: { folder: { type: "string", description: "Local folder of footage to index + sync." } },
43
+ required: ["folder"],
44
+ },
45
+ async execute(args) {
46
+ if (!(0, engine_js_1.engineAvailable)("index-folder.mjs")) {
47
+ return "sync_local_index needs the local engine (ffmpeg + the vision model). Unavailable in this install.";
48
+ }
49
+ let r;
50
+ try {
51
+ r = JSON.parse(await runIndex(args.folder));
52
+ }
53
+ catch (e) {
54
+ return `Couldn't index the folder: ${e instanceof Error ? e.message : String(e)}`;
55
+ }
56
+ if (!r.items.length)
57
+ return `No media analyzed in ${args.folder}.`;
58
+ try {
59
+ const res = await (0, client_js_1.post)("/v1/library/local-sync", { items: r.items });
60
+ return (`Indexed + synced ${res.synced} local asset(s) from ${args.folder} → searchable in cloud idea-planning. ` +
61
+ `The files were NOT uploaded (tags only). Use search_local_index to find them by topic when planning a reel.`);
62
+ }
63
+ catch (e) {
64
+ return `Analyzed ${r.indexed} asset(s) but couldn't sync to the cloud: ${e instanceof Error ? e.message : String(e)}`;
65
+ }
66
+ },
67
+ };
68
+ exports.searchLocalIndexTool = {
69
+ name: "search_local_index",
70
+ description: "Search the user's SYNCED local footage by topic/keyword (from sync_local_index) — use when planning an idea's " +
71
+ "asset plan to find existing local clips that fit a script BEFORE recommending they film or AI-generate new B-roll.",
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: { query: { type: "string", description: "Topic / keyword (e.g. 'hospital', 'sunset rooftop', 'laptop typing')." } },
75
+ required: ["query"],
76
+ },
77
+ async execute(args) {
78
+ const r = await (0, client_js_1.get)(`/v1/library/local-search?q=${encodeURIComponent(args.query)}`);
79
+ if (!r.items.length)
80
+ return `No synced local footage matched "${args.query}". (Run sync_local_index on the user's folders first, or recommend filming / AI B-roll.)`;
81
+ const lines = r.items.map((i) => `- ${i.path}${i.subject ? ` (${i.subject})` : ""}${i.descr ? ` — ${i.descr}` : ""}`);
82
+ return [`Local footage matching "${args.query}":`, ...lines].join("\n");
83
+ },
84
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setLocalModeTool = void 0;
7
+ /**
8
+ * set_local_mode — a persistent toggle between LOCAL analysis (free + private,
9
+ * a vision model on the user's GPU via Ollama) and CLOUD (Gemini). The choice is
10
+ * saved to ~/.viralspin/config.json, which the engine reads — so the user flips
11
+ * it once with no env vars to edit. (The VIRALSPIN_VLM env var still works as an
12
+ * explicit override.) Enabling local also verifies Ollama + the model are ready
13
+ * and, if not, returns the one-time setup steps.
14
+ */
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const os_1 = __importDefault(require("os"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const CONFIG = path_1.default.join(os_1.default.homedir(), ".viralspin", "config.json");
19
+ function readCfg() {
20
+ try {
21
+ return JSON.parse(fs_1.default.readFileSync(CONFIG, "utf8")) || {};
22
+ }
23
+ catch {
24
+ return {};
25
+ }
26
+ }
27
+ function writeCfg(c) {
28
+ try {
29
+ fs_1.default.mkdirSync(path_1.default.dirname(CONFIG), { recursive: true });
30
+ }
31
+ catch { /* ignore */ }
32
+ fs_1.default.writeFileSync(CONFIG, JSON.stringify(c, null, 2));
33
+ }
34
+ async function ollamaStatus(model) {
35
+ try {
36
+ const r = await fetch("http://localhost:11434/api/tags");
37
+ if (!r.ok)
38
+ return { up: false, hasModel: false };
39
+ const d = (await r.json());
40
+ const base = model.split(":")[0];
41
+ const hasModel = (d.models || []).some((m) => m.name === model || m.name.startsWith(base));
42
+ return { up: true, hasModel };
43
+ }
44
+ catch {
45
+ return { up: false, hasModel: false };
46
+ }
47
+ }
48
+ exports.setLocalModeTool = {
49
+ name: "set_local_mode",
50
+ description: "Toggle ViralSpin video analysis between LOCAL (free + private — runs a vision model on the user's GPU via " +
51
+ "Ollama) and CLOUD (Gemini). The choice persists in ~/.viralspin/config.json — no env vars to edit, no restart. " +
52
+ "Enabling local verifies Ollama + the model and, if missing, returns the one-time setup steps.",
53
+ inputSchema: {
54
+ type: "object",
55
+ properties: {
56
+ enabled: { type: "boolean", description: "true = LOCAL (GPU/Ollama), false = CLOUD (Gemini)." },
57
+ model: { type: "string", description: "Optional Ollama vision model (default qwen2.5vl:7b)." },
58
+ },
59
+ required: ["enabled"],
60
+ },
61
+ async execute(args) {
62
+ const cfg = readCfg();
63
+ if (!args.enabled) {
64
+ cfg.vlm = "cloud";
65
+ writeCfg(cfg);
66
+ return "Switched to CLOUD analysis (Gemini). Local mode is OFF.";
67
+ }
68
+ const model = args.model || cfg.ollama_model || "qwen2.5vl:7b";
69
+ cfg.vlm = "ollama";
70
+ cfg.ollama_model = model;
71
+ writeCfg(cfg);
72
+ const { up, hasModel } = await ollamaStatus(model);
73
+ if (!up) {
74
+ return (`Local mode is ON in settings, but Ollama isn't running. One-time setup:\n` +
75
+ ` 1) Install Ollama → https://ollama.com/download (or: winget install Ollama.Ollama / brew install ollama)\n` +
76
+ ` 2) ollama pull ${model} (~6GB, one-time)\n` +
77
+ `Once Ollama is running with the model, local analysis works automatically — no restart.`);
78
+ }
79
+ if (!hasModel) {
80
+ return `Local mode is ON and Ollama is running, but the model isn't pulled. Run: ollama pull ${model} (~6GB, one-time). Then it's ready.`;
81
+ }
82
+ return `Local mode is ON ✓ — video analysis now runs on your GPU via Ollama (${model}): free + private. Say "switch to cloud" to use Gemini instead.`;
83
+ },
84
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startPhotoPickerTool = void 0;
4
+ const client_js_1 = require("../client.js");
5
+ /**
6
+ * Opens a Google Photos Picker session for choosing B-roll. Google does NOT allow
7
+ * apps to list or search a user's albums programmatically (Library API readonly was
8
+ * removed 2025-03-31), so the user searches/selects inside Google's own picker UI.
9
+ * This tool just hands back the picker link + sessionId; create_video_assembly then
10
+ * ingests the picks via google_picker_session.
11
+ */
12
+ exports.startPhotoPickerTool = {
13
+ name: "start_photo_picker",
14
+ description: "Open a Google Photos picker to choose B-roll for create_video_assembly. Returns a link to open in your browser. " +
15
+ "Google does not allow listing or searching your albums programmatically — so use the picker's OWN search box to find an " +
16
+ "album or topic that matches your video (by person, place, event, or theme), select the photos/clips, and finish. " +
17
+ "Then call create_video_assembly with google_picker_session set to the returned sessionId. " +
18
+ "Requires a Google account connected at app.viralspin.ai/settings.",
19
+ inputSchema: { type: "object", properties: {} },
20
+ async execute() {
21
+ const r = await (0, client_js_1.post)("/v1/assembly/picker", {});
22
+ return [
23
+ "📸 Open this link to pick your Google Photos B-roll:",
24
+ r.pickerUri,
25
+ "",
26
+ "Tip: use the picker's search box to find an album/topic that matches your video — by person, place, event, or theme — then select the clips/photos and finish.",
27
+ "",
28
+ `When done, run create_video_assembly with: google_picker_session: "${r.sessionId}" (plus your A-roll).`,
29
+ ].join("\n");
30
+ },
31
+ };