@viralspin/mcp 0.2.0 → 0.3.1

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/dist/cli.js +40 -0
  4. package/dist/client.js +12 -3
  5. package/dist/engine.js +29 -0
  6. package/dist/hosted.js +159 -0
  7. package/dist/index.js +77 -17
  8. package/dist/local-render/kit.js +217 -0
  9. package/dist/local-render/login.js +138 -0
  10. package/dist/local-render/render.js +252 -0
  11. package/dist/local-render/tokens.js +201 -0
  12. package/dist/sanitize.js +22 -0
  13. package/dist/tools/assembly-adjust.js +107 -15
  14. package/dist/tools/carousel-video.js +7 -0
  15. package/dist/tools/color-grade.js +64 -0
  16. package/dist/tools/connections.js +23 -4
  17. package/dist/tools/edit-clip.js +136 -0
  18. package/dist/tools/engage.js +13 -4
  19. package/dist/tools/explainer-index.js +6 -0
  20. package/dist/tools/find-moments.js +140 -0
  21. package/dist/tools/folder-preview.js +71 -0
  22. package/dist/tools/ideas.js +158 -0
  23. package/dist/tools/kinetic-text.js +6 -2
  24. package/dist/tools/local-index.js +84 -0
  25. package/dist/tools/local-mode.js +84 -0
  26. package/dist/tools/profile.js +56 -0
  27. package/dist/tools/publish.js +50 -14
  28. package/dist/tools/relight-clip.js +98 -0
  29. package/dist/tools/render-locally.js +158 -0
  30. package/dist/tools/timeline-edit.js +367 -0
  31. package/dist/tools/video-assembly.js +131 -4
  32. package/package.json +42 -29
  33. package/BUNDLE_LOCAL_SPEC.md +0 -133
  34. package/engine/assemble.mjs +0 -476
  35. package/engine/gemini.mjs +0 -164
  36. package/engine/kinetic.mjs +0 -84
  37. package/engine/prompts.mjs +0 -94
  38. package/engine/remotion.config.ts +0 -4
  39. package/engine/src/Assembly.tsx +0 -330
  40. package/engine/src/KineticText.tsx +0 -253
  41. package/engine/src/Root.tsx +0 -39
  42. package/engine/src/index.ts +0 -4
  43. package/engine/tsconfig.json +0 -15
  44. package/src/client.ts +0 -119
  45. package/src/index.ts +0 -151
  46. package/src/tools/assembly-adjust.ts +0 -110
  47. package/src/tools/captions.ts +0 -32
  48. package/src/tools/carousel-video.ts +0 -211
  49. package/src/tools/connections.ts +0 -27
  50. package/src/tools/engage.ts +0 -105
  51. package/src/tools/explainer-index.ts +0 -298
  52. package/src/tools/image-ads.ts +0 -192
  53. package/src/tools/kinetic-text.ts +0 -130
  54. package/src/tools/photo-picker.ts +0 -31
  55. package/src/tools/posts.ts +0 -58
  56. package/src/tools/publish.ts +0 -236
  57. package/src/tools/review.ts +0 -126
  58. package/src/tools/video-assembly.ts +0 -205
  59. package/tsconfig.json +0 -15
@@ -5,7 +5,9 @@ const client_js_1 = require("../client.js");
5
5
  function describe(k) {
6
6
  const scope = k.media_id ? `post ${k.media_id}` : "all posts";
7
7
  const platform = k.platform ?? "any platform";
8
- const reply = k.reply_to_comment ? ", + comment reply" : ", DM only";
8
+ const reply = k.reply_to_comment
9
+ ? (k.comment_reply_text ? `, replies "${k.comment_reply_text}"` : ", + comment reply")
10
+ : ", DM only";
9
11
  const status = k.is_active ? "" : " (paused)";
10
12
  return `"${k.keyword}" → ${k.link} [${platform}, ${scope}, ${k.match_type}${reply}]${status}`;
11
13
  }
@@ -31,13 +33,19 @@ exports.setKeywordLinkTool = {
31
33
  },
32
34
  match_type: {
33
35
  type: "string",
34
- enum: ["exact", "contains"],
35
- description: "'contains' (default) fires if the comment includes the keyword; 'exact' requires a full match.",
36
+ enum: ["exact", "contains", "word"],
37
+ description: "'word' (default, recommended) fires when the keyword appears as a whole word — 'the app.' matches, " +
38
+ "'appreciate' does not. 'contains' fires on any substring, which misfires on short keywords. " +
39
+ "'exact' requires the comment to be nothing but the keyword.",
36
40
  },
37
41
  reply_to_comment: {
38
42
  type: "boolean",
39
43
  description: "Also post a public reply to the comment (e.g. 'Check your DMs', wording varies). Defaults to true.",
40
44
  },
45
+ comment_reply_text: {
46
+ type: "string",
47
+ description: "Custom wording for that public reply. Omit to rotate through the built-in phrases.",
48
+ },
41
49
  },
42
50
  required: ["keyword", "link"],
43
51
  },
@@ -47,8 +55,9 @@ exports.setKeywordLinkTool = {
47
55
  link: args.link,
48
56
  platform: args.platform ?? null,
49
57
  media_id: args.media_id ?? null,
50
- match_type: args.match_type ?? "contains",
58
+ match_type: args.match_type ?? "word",
51
59
  reply_to_comment: args.reply_to_comment ?? true,
60
+ comment_reply_text: args.comment_reply_text ?? null,
52
61
  });
53
62
  return `Saved: ${describe(created)}`;
54
63
  },
@@ -186,6 +186,12 @@ exports.indexExplainerSourcesTool = {
186
186
  required: ["sources_folder"],
187
187
  },
188
188
  async execute(args) {
189
+ // Credit gate: Twelve Labs indexing makes paid API calls that are not yet
190
+ // metered to a user's credit balance, so it is OFF by default for public
191
+ // MCP deployments. Internal/power users can enable it explicitly.
192
+ if (process.env.EXPLAINER_INDEX_ENABLED !== "true") {
193
+ return "Twelve Labs explainer indexing is disabled. This feature calls a paid API that is not yet billed to credits, so it is off by default. To enable it for internal use, set EXPLAINER_INDEX_ENABLED=true in the MCP environment.";
194
+ }
189
195
  const apiKey = process.env.TWELVE_LABS_API_KEY;
190
196
  if (!apiKey) {
191
197
  return "Error: TWELVE_LABS_API_KEY is not set in the MCP environment. Add it to your ~/.claude.json MCP config under env.TWELVE_LABS_API_KEY.";
@@ -0,0 +1,140 @@
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.findMomentsTool = void 0;
7
+ /**
8
+ * find_moments — surface highlight windows inside a long/silent local video so
9
+ * the agent can build a reel without the user pre-splitting it. Shells out to the
10
+ * engine's moments.mjs (ffmpeg frame sampling + vision scoring via the configured
11
+ * model — local Ollama when VIRALSPIN_VLM is set, else cloud Gemini).
12
+ */
13
+ const child_process_1 = require("child_process");
14
+ const path_1 = __importDefault(require("path"));
15
+ const engine_js_1 = require("../engine.js");
16
+ function runMoments(args, script = "moments.mjs") {
17
+ return new Promise((resolve, reject) => {
18
+ const child = (0, child_process_1.spawn)(process.platform === "win32" ? "node.exe" : "node", [path_1.default.join(engine_js_1.ENGINE_DIR, script), ...args], {
19
+ cwd: engine_js_1.ENGINE_DIR,
20
+ env: { ...process.env },
21
+ });
22
+ let out = "";
23
+ child.stdout.on("data", (d) => { out += d.toString(); });
24
+ child.stderr.on("data", (d) => process.stderr.write(d));
25
+ child.on("error", reject);
26
+ child.on("close", (code) => {
27
+ const m = out.match(/RESULT:([\s\S]+)/);
28
+ if (code === 0 && m)
29
+ resolve(m[1].trim());
30
+ else
31
+ reject(new Error(out.slice(-400) || `moments engine exited ${code}`));
32
+ });
33
+ });
34
+ }
35
+ exports.findMomentsTool = {
36
+ name: "find_moments",
37
+ description: "Find the highlight-worthy moments INSIDE a long or silent LOCAL video (e.g. a screen recording or B-roll " +
38
+ "reel) — no need to split it first. Samples frames and scores them with the configured vision model " +
39
+ "(free + private local Ollama when local mode is on, else cloud), and returns 0.6–3s windows with " +
40
+ "descriptions. Pass `query` to bias toward a theme. Set `extract: true` to ALSO cut each highlight into " +
41
+ "its own small clip LOCALLY — then you upload only those snippets (not the long source). Build a reel from " +
42
+ "them with create_video_assembly: destination:'hosted' uploads ONLY the snippets + opens the web editor; " +
43
+ "destination:'local' keeps everything on-device (no upload). Same analysis, two destinations.",
44
+ inputSchema: {
45
+ type: "object",
46
+ properties: {
47
+ video_path: { type: "string", description: "Local path to the long video to scan." },
48
+ query: { type: "string", description: "Optional theme to bias toward (e.g. 'surprise reveal', 'on-screen editing')." },
49
+ threshold: { type: "number", description: "Score cutoff 0..1 for a 'highlight' (default 0.55; lower = more windows)." },
50
+ extract: { type: "boolean", description: "Also cut each highlight into its own small clip locally (so you upload only the snippets). Default false = just list the windows." },
51
+ mode: { type: "string", enum: ["highlight", "screen"], description: "'highlight' (default) = VLM-scored striking moments for any footage. 'screen' = SCREEN-RECORDING mode: frame-diff finds where the on-screen ACTION is and returns a focal point (x,y) + suggested punch-in zoom per snippet, so the reel can auto-zoom to exactly where things happen (cursor, typing, output). Use for app/product demos." },
52
+ },
53
+ required: ["video_path"],
54
+ },
55
+ async execute(args) {
56
+ if (args.mode === "screen")
57
+ return runScreenMode(args);
58
+ if (!(0, engine_js_1.engineAvailable)("moments.mjs")) {
59
+ return "find_moments needs the local engine (it runs ffmpeg + the vision model). It's unavailable in this install — set VIRALSPIN_ASSEMBLY_DIR, or use the hosted transcript path (get_transcript + keep_windows) for talking/narrated video instead.";
60
+ }
61
+ const cli = [args.video_path];
62
+ if (args.query)
63
+ cli.push("--query", args.query);
64
+ if (args.threshold != null)
65
+ cli.push("--threshold", String(args.threshold));
66
+ if (args.extract)
67
+ cli.push("--extract");
68
+ let json;
69
+ try {
70
+ json = JSON.parse(await runMoments(cli));
71
+ }
72
+ catch (e) {
73
+ return `Couldn't scan the video: ${e instanceof Error ? e.message : String(e)}`;
74
+ }
75
+ if (!json.windows?.length) {
76
+ return `Scanned ${json.sampled} frames over ${Math.round(json.duration)}s but found no standout moments — lower the threshold or add a query.`;
77
+ }
78
+ const head = `Found ${json.windows.length} highlight window(s) in ${path_1.default.basename(args.video_path)} (${Math.round(json.duration)}s, ${json.sampled} frames sampled, analyzed locally if local mode is on):`;
79
+ if (json.clips?.length) {
80
+ const lines = json.clips.map((c, i) => `${i + 1}. ${c.path} (${c.from_sec.toFixed(1)}–${c.to_sec.toFixed(1)}s)${c.desc ? ` — ${c.desc}` : ""}`);
81
+ return [
82
+ head,
83
+ `Extracted ${json.clips.length} clip(s) → ${json.out_dir}`,
84
+ ...lines,
85
+ ``,
86
+ `Build a reel from these snippets with create_video_assembly:`,
87
+ ` • destination:"hosted" → uploads ONLY these snippets (not the long source) + opens the web editor.`,
88
+ ` • destination:"local" → keeps everything on-device, no upload (fully private).`,
89
+ ].join("\n");
90
+ }
91
+ const lines = json.windows.map((w, i) => `${i + 1}. ${w.from_sec.toFixed(1)}–${w.to_sec.toFixed(1)}s (score ${w.score})${w.desc ? ` — ${w.desc}` : ""}`);
92
+ return [
93
+ head,
94
+ ...lines,
95
+ ``,
96
+ `Re-run with extract:true to cut these into clips (then upload only those), or run keep_windows on a hosted project to cut to just these moments.`,
97
+ ].join("\n");
98
+ },
99
+ };
100
+ // SCREEN mode — shells to screen-moments.mjs (frame-diff focal + zoom, VLM label).
101
+ // Returns snippets that carry focal_x/focal_y + zoom so the assembly can punch-in to
102
+ // exactly where the on-screen action is. Each screen recording is a B-roll SOURCE;
103
+ // call once per recording and let the story arc stitch the snippets together.
104
+ async function runScreenMode(args) {
105
+ if (!(0, engine_js_1.engineAvailable)("screen-moments.mjs")) {
106
+ return "Screen mode needs the local engine (ffmpeg + Python opencv). It's unavailable in this install — set VIRALSPIN_ASSEMBLY_DIR and `pip install opencv-python numpy`.";
107
+ }
108
+ const cli = [args.video_path];
109
+ if (args.threshold != null)
110
+ cli.push("--threshold", String(args.threshold));
111
+ if (args.extract)
112
+ cli.push("--extract");
113
+ let json;
114
+ try {
115
+ json = JSON.parse(await runMoments(cli, "screen-moments.mjs"));
116
+ }
117
+ catch (e) {
118
+ return `Couldn't scan the screen recording: ${e instanceof Error ? e.message : String(e)}`;
119
+ }
120
+ if (!json.snippets?.length) {
121
+ return `Scanned ${json.sampled} frames over ${Math.round(json.duration)}s of ${path_1.default.basename(args.video_path)} but found no clear on-screen action — the recording may be mostly static.`;
122
+ }
123
+ const head = `Found ${json.snippets.length} on-screen action moment(s) in ${path_1.default.basename(args.video_path)} (${json.width}×${json.height}, ${Math.round(json.duration)}s). Each carries a focal point + punch-in zoom so the reel can zoom to exactly where the action is:`;
124
+ const fmt = (s, i) => `${i + 1}. ${s.from_sec.toFixed(1)}–${s.to_sec.toFixed(1)}s — focal (${s.focal_x.toFixed(2)}, ${s.focal_y.toFixed(2)}), zoom ${s.zoom}×${s.label ? ` — “${s.label}”` : ""}`;
125
+ if (json.clips?.length) {
126
+ return [
127
+ head,
128
+ ...json.snippets.map(fmt),
129
+ ``,
130
+ `Extracted ${json.clips.length} snippet clip(s) → ${json.out_dir}`,
131
+ `These are B-roll candidates: build a screen-demo reel with create_video_assembly (they stitch together with other B-roll; the focal+zoom drive the auto punch-in).`,
132
+ ].join("\n");
133
+ }
134
+ return [
135
+ head,
136
+ ...json.snippets.map(fmt),
137
+ ``,
138
+ `Re-run with extract:true to cut these into snippet clips, then assemble a screen-demo reel from them (each snippet's focal+zoom drives the punch-in).`,
139
+ ].join("\n");
140
+ }
@@ -0,0 +1,71 @@
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.previewFolderTool = void 0;
7
+ /**
8
+ * preview_folder — a pre-flight cost gate for assembling a local folder.
9
+ *
10
+ * create_video_assembly analyzes every clip (Gemini tags) and charges credits on
11
+ * create. For a big folder that adds up, so the agent should call this FIRST and
12
+ * confirm with the user before assembling. Counting is local (reads the disk),
13
+ * so it's instant and free; the exact credit charge is finalized server-side in
14
+ * the create response. An optional per-asset rate (env) gives a rough estimate.
15
+ */
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const IMAGE_EXT = new Set([".jpg", ".jpeg", ".png", ".gif", ".webp"]);
19
+ const VIDEO_EXT = new Set([".mp4", ".mov", ".webm", ".m4v"]);
20
+ exports.previewFolderTool = {
21
+ name: "preview_folder",
22
+ description: "Before assembling from a LOCAL folder, count its media so you can warn the user about cost. Each clip is " +
23
+ "analyzed (tagged for matching) and credits are charged when create_video_assembly runs — so for a big " +
24
+ "folder, call this first and CONFIRM before proceeding. Counting is instant + free; the exact charge is " +
25
+ "finalized in the create response. Returns video/image counts (+ a rough credit estimate if a per-asset " +
26
+ "rate is configured via VIRALSPIN_ANALYZE_CREDITS_PER_ASSET).",
27
+ inputSchema: {
28
+ type: "object",
29
+ properties: {
30
+ folder: { type: "string", description: "Local folder path to inspect." },
31
+ },
32
+ required: ["folder"],
33
+ },
34
+ async execute(args) {
35
+ const folder = args.folder;
36
+ if (!fs_1.default.existsSync(folder))
37
+ return `Folder not found: ${folder}`;
38
+ let names;
39
+ try {
40
+ const st = fs_1.default.statSync(folder);
41
+ if (!st.isDirectory())
42
+ return `${folder} is a file, not a folder.`;
43
+ names = fs_1.default.readdirSync(folder);
44
+ }
45
+ catch (e) {
46
+ return `Can't read folder: ${e instanceof Error ? e.message : e}`;
47
+ }
48
+ let images = 0;
49
+ let videos = 0;
50
+ for (const n of names) {
51
+ const ext = path_1.default.extname(n).toLowerCase();
52
+ if (VIDEO_EXT.has(ext))
53
+ videos++;
54
+ else if (IMAGE_EXT.has(ext))
55
+ images++;
56
+ }
57
+ const total = images + videos;
58
+ if (!total)
59
+ return `No images or videos found in ${folder}.`;
60
+ const rate = Number(process.env.VIRALSPIN_ANALYZE_CREDITS_PER_ASSET || "");
61
+ const est = Number.isFinite(rate) && rate > 0 ? ` Rough estimate: ~${Math.round(total * rate)} credits (${rate}/clip).` : "";
62
+ const warnAt = Number(process.env.VIRALSPIN_FOLDER_WARN || "40");
63
+ const big = total > warnAt;
64
+ return (`${folder}\n` +
65
+ `${total} media file(s): ${videos} video(s), ${images} image(s).\n` +
66
+ `Each is analyzed when you assemble; credits are charged on create_video_assembly and finalized in its response.${est}\n` +
67
+ (big
68
+ ? `⚠️ Large folder — CONFIRM with the user before assembling (it will cost credits). Consider a sub-folder or only the best clips.`
69
+ : `Small enough to assemble directly.`));
70
+ },
71
+ };
@@ -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
+ };
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createKineticTextTool = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const path_1 = __importDefault(require("path"));
9
- const ENGINE_DIR = process.env.VIRALSPIN_ASSEMBLY_DIR || path_1.default.resolve(__dirname, "../../engine");
9
+ const engine_js_1 = require("../engine.js");
10
10
  const EFFECTS = ["typing", "billboard_flip", "isometric"];
11
11
  const STYLES = ["terminal", "cinematic", "minimal"];
12
12
  const FORMATS = ["9x16", "16x9", "1x1"];
13
13
  function runKinetic(args) {
14
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_DIR, "kinetic.mjs"), ...args], { cwd: ENGINE_DIR, env: { ...process.env } });
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
16
  let stdout = "";
17
17
  child.stdout.on("data", (d) => { stdout += d.toString(); });
18
18
  child.stderr.on("data", (d) => process.stderr.write(d));
@@ -86,6 +86,10 @@ exports.createKineticTextTool = {
86
86
  required: ["text"],
87
87
  },
88
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
+ }
89
93
  const cli = ["--text", args.text];
90
94
  if (args.effect)
91
95
  cli.push("--effect", args.effect);
@@ -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
+ };