agentcut 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -2
- package/dist/bridge.d.ts +45 -0
- package/dist/bridge.js +691 -0
- package/dist/bridge.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/studio/agents/claude.d.ts +7 -0
- package/dist/studio/agents/claude.js +155 -0
- package/dist/studio/agents/claude.js.map +1 -0
- package/dist/studio/agents/codex.d.ts +4 -0
- package/dist/studio/agents/codex.js +169 -0
- package/dist/studio/agents/codex.js.map +1 -0
- package/dist/studio/agents/index.d.ts +8 -0
- package/dist/studio/agents/index.js +50 -0
- package/dist/studio/agents/index.js.map +1 -0
- package/dist/studio/agents/types.d.ts +131 -0
- package/dist/studio/agents/types.js +11 -0
- package/dist/studio/agents/types.js.map +1 -0
- package/dist/studio/bundler.d.ts +29 -0
- package/dist/studio/bundler.js +136 -0
- package/dist/studio/bundler.js.map +1 -0
- package/dist/studio/chat.d.ts +147 -0
- package/dist/studio/chat.js +681 -0
- package/dist/studio/chat.js.map +1 -0
- package/dist/studio/cli.d.ts +2 -0
- package/dist/studio/cli.js +194 -0
- package/dist/studio/cli.js.map +1 -0
- package/dist/studio/components.d.ts +4 -0
- package/dist/studio/components.js +36 -0
- package/dist/studio/components.js.map +1 -0
- package/dist/studio/host.d.ts +105 -0
- package/dist/studio/host.js +634 -0
- package/dist/studio/host.js.map +1 -0
- package/dist/studio/http.d.ts +21 -0
- package/dist/studio/http.js +240 -0
- package/dist/studio/http.js.map +1 -0
- package/dist/studio/music.d.ts +35 -0
- package/dist/studio/music.js +130 -0
- package/dist/studio/music.js.map +1 -0
- package/dist/studio/proc.d.ts +11 -0
- package/dist/studio/proc.js +69 -0
- package/dist/studio/proc.js.map +1 -0
- package/dist/studio/projects.d.ts +84 -0
- package/dist/studio/projects.js +369 -0
- package/dist/studio/projects.js.map +1 -0
- package/dist/studio/render.d.ts +24 -0
- package/dist/studio/render.js +197 -0
- package/dist/studio/render.js.map +1 -0
- package/dist/studio/reveal.d.ts +7 -0
- package/dist/studio/reveal.js +49 -0
- package/dist/studio/reveal.js.map +1 -0
- package/dist/studio/schema.d.ts +4152 -0
- package/dist/studio/schema.js +358 -0
- package/dist/studio/schema.js.map +1 -0
- package/dist/studio/tools.d.ts +2 -0
- package/dist/studio/tools.js +165 -0
- package/dist/studio/tools.js.map +1 -0
- package/dist/studio/voice.d.ts +150 -0
- package/dist/studio/voice.js +434 -0
- package/dist/studio/voice.js.map +1 -0
- package/dist/studio/workspace.d.ts +31 -0
- package/dist/studio/workspace.js +187 -0
- package/dist/studio/workspace.js.map +1 -0
- package/package.json +50 -4
- package/template/AGENTS.md +13 -0
- package/template/components/CATALOG.md +1306 -0
- package/template/components/README.md +61 -0
- package/template/components/STYLES.md +246 -0
- package/template/components/arcade-title/ArcadeTitle.tsx +860 -0
- package/template/components/arcade-title/meta.json +28 -0
- package/template/components/aurora/Aurora.tsx +63 -0
- package/template/components/aurora/meta.json +28 -0
- package/template/components/bar-wipe-title/BarWipeTitle.tsx +94 -0
- package/template/components/bar-wipe-title/meta.json +29 -0
- package/template/components/before-after/BeforeAfter.tsx +89 -0
- package/template/components/before-after/meta.json +233 -0
- package/template/components/bento-grid/BentoGrid.tsx +202 -0
- package/template/components/bento-grid/meta.json +25 -0
- package/template/components/blur-in-title/BlurInTitle.tsx +121 -0
- package/template/components/blur-in-title/meta.json +32 -0
- package/template/components/catalog.json +8730 -0
- package/template/components/catalog.ts +103 -0
- package/template/components/chat-thread/ChatThread.tsx +128 -0
- package/template/components/chat-thread/meta.json +24 -0
- package/template/components/checklist/Checklist.tsx +129 -0
- package/template/components/checklist/meta.json +25 -0
- package/template/components/confetti/Confetti.tsx +109 -0
- package/template/components/confetti/meta.json +28 -0
- package/template/components/countdown/Countdown.tsx +166 -0
- package/template/components/countdown/meta.json +28 -0
- package/template/components/cut-and-paste/CutAndPaste.tsx +654 -0
- package/template/components/cut-and-paste/meta.json +29 -0
- package/template/components/decode-text/DecodeText.tsx +97 -0
- package/template/components/decode-text/meta.json +29 -0
- package/template/components/editorial-quote/EditorialQuote.tsx +122 -0
- package/template/components/editorial-quote/meta.json +28 -0
- package/template/components/glitch-title/GlitchTitle.tsx +171 -0
- package/template/components/glitch-title/meta.json +32 -0
- package/template/components/halftone-wave/HalftoneWave.tsx +106 -0
- package/template/components/halftone-wave/meta.json +28 -0
- package/template/components/highlighter/Highlighter.tsx +142 -0
- package/template/components/highlighter/meta.json +28 -0
- package/template/components/hook-card/HookCard.tsx +552 -0
- package/template/components/hook-card/meta.json +304 -0
- package/template/components/index.ts +149 -0
- package/template/components/iris-wipe/IrisWipe.tsx +76 -0
- package/template/components/iris-wipe/meta.json +24 -0
- package/template/components/kinetic-poster/KineticPoster.tsx +437 -0
- package/template/components/kinetic-poster/meta.json +31 -0
- package/template/components/kinetic-punch/KineticPunch.tsx +80 -0
- package/template/components/kinetic-punch/meta.json +30 -0
- package/template/components/lava-lamp/LavaLamp.tsx +92 -0
- package/template/components/lava-lamp/meta.json +28 -0
- package/template/components/letter-cascade/LetterCascade.tsx +102 -0
- package/template/components/letter-cascade/meta.json +29 -0
- package/template/components/lib.ts +179 -0
- package/template/components/light-leak/LightLeakTransition.tsx +43 -0
- package/template/components/light-leak/meta.json +74 -0
- package/template/components/line-diagram/LineDiagram.tsx +205 -0
- package/template/components/line-diagram/meta.json +217 -0
- package/template/components/list-card/ListCard.tsx +104 -0
- package/template/components/list-card/meta.json +232 -0
- package/template/components/logo-sting/LogoSting.tsx +129 -0
- package/template/components/logo-sting/meta.json +29 -0
- package/template/components/looks.tsx +1447 -0
- package/template/components/lower-third/LowerThird.tsx +100 -0
- package/template/components/lower-third/meta.json +24 -0
- package/template/components/marquee/Marquee.tsx +100 -0
- package/template/components/marquee/meta.json +30 -0
- package/template/components/notification/Notification.tsx +115 -0
- package/template/components/notification/meta.json +27 -0
- package/template/components/outline-fill/OutlineFill.tsx +106 -0
- package/template/components/outline-fill/meta.json +28 -0
- package/template/components/panel-sweep/PanelSweep.tsx +86 -0
- package/template/components/panel-sweep/meta.json +25 -0
- package/template/components/prompt-box/PromptBox.tsx +131 -0
- package/template/components/prompt-box/meta.json +24 -0
- package/template/components/props.ts +73 -0
- package/template/components/quote-card/QuoteCard.tsx +71 -0
- package/template/components/quote-card/meta.json +216 -0
- package/template/components/shape-shift/ShapeShift.tsx +420 -0
- package/template/components/shape-shift/meta.json +31 -0
- package/template/components/slide-zoom-message/SlideZoomMessage.tsx +179 -0
- package/template/components/slide-zoom-message/meta.json +199 -0
- package/template/components/social-post/SocialPost.tsx +185 -0
- package/template/components/social-post/meta.json +30 -0
- package/template/components/split-flap/SplitFlap.tsx +191 -0
- package/template/components/split-flap/meta.json +29 -0
- package/template/components/spotlight-grid/SpotlightGrid.tsx +84 -0
- package/template/components/spotlight-grid/meta.json +25 -0
- package/template/components/stat-counter/StatCounter.tsx +117 -0
- package/template/components/stat-counter/meta.json +27 -0
- package/template/components/sticker-badge/StickerBadge.tsx +46 -0
- package/template/components/sticker-badge/meta.json +220 -0
- package/template/components/sticker-slam/StickerSlam.tsx +941 -0
- package/template/components/sticker-slam/meta.json +34 -0
- package/template/components/style-layer.tsx +233 -0
- package/template/components/styles.json +762 -0
- package/template/components/styles.ts +113 -0
- package/template/components/target-lock/TargetLock.tsx +662 -0
- package/template/components/target-lock/meta.json +32 -0
- package/template/components/text-reveal/TextReveal.tsx +99 -0
- package/template/components/text-reveal/meta.json +28 -0
- package/template/components/tile-wipe/TileWipe.tsx +75 -0
- package/template/components/tile-wipe/meta.json +24 -0
- package/template/components/type-zoom/TypeZoom.tsx +103 -0
- package/template/components/type-zoom/meta.json +27 -0
- package/template/components/types.ts +66 -0
- package/template/components/typewriter/Typewriter.tsx +112 -0
- package/template/components/typewriter/meta.json +29 -0
- package/template/components/word-pop/WordPop.tsx +59 -0
- package/template/components/word-pop/meta.json +237 -0
- package/template/components/word-stack/WordStack.tsx +122 -0
- package/template/components/word-stack/meta.json +27 -0
- package/template/components/word-swap/WordSwap.tsx +127 -0
- package/template/components/word-swap/meta.json +30 -0
- package/template/presets/charcoal-sketch/PROMPT.md +48 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-0.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-1.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-2.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/sketch-paper.jpg +0 -0
- package/template/presets/charcoal-sketch/assets/paper/smudge.png +0 -0
- package/template/presets/charcoal-sketch/poster.jpg +0 -0
- package/template/presets/charcoal-sketch/preset.json +17 -0
- package/template/presets/charcoal-sketch/preview.mp4 +0 -0
- package/template/presets/charcoal-sketch/scenes/Grain.tsx +23 -0
- package/template/presets/charcoal-sketch/scenes/Paper.tsx +17 -0
- package/template/presets/charcoal-sketch/scenes/examples/Agents.tsx +100 -0
- package/template/presets/charcoal-sketch/scenes/examples/Approvals.tsx +110 -0
- package/template/presets/charcoal-sketch/scenes/examples/Blog.tsx +105 -0
- package/template/presets/charcoal-sketch/scenes/examples/EndCard.tsx +41 -0
- package/template/presets/charcoal-sketch/scenes/examples/Hook.tsx +130 -0
- package/template/presets/charcoal-sketch/scenes/examples/Ideas.tsx +92 -0
- package/template/presets/charcoal-sketch/scenes/examples/Posting.tsx +128 -0
- package/template/presets/charcoal-sketch/scenes/lib/painfix.tsx +119 -0
- package/template/presets/charcoal-sketch/scenes/lib/sketch.tsx +291 -0
- package/template/presets/charcoal-sketch/scripts/build_layers.example.py +193 -0
- package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -0
- package/template/presets/charcoal-sketch/scripts/make_textures.py +93 -0
- package/template/presets/punk-cut-paper/PROMPT.md +37 -0
- package/template/presets/punk-cut-paper/assets/paper/desk-cream.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/grain-overlay.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-black.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-red.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-yellow.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/kraft.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/newsprint.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/paper-cream.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/paper-white.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/tape.png +0 -0
- package/template/presets/punk-cut-paper/build_layers.example.py +150 -0
- package/template/presets/punk-cut-paper/poster.jpg +0 -0
- package/template/presets/punk-cut-paper/preset.json +15 -0
- package/template/presets/punk-cut-paper/preview.mp4 +0 -0
- package/template/presets/punk-cut-paper/scenes/Backdrop.tsx +76 -0
- package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -0
- package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -0
- package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -0
- package/template/presets/punk-cut-paper/scenes/Xerox.tsx +31 -0
- package/template/presets/punk-cut-paper/scenes/lib/punk.tsx +208 -0
- package/template/runtime/composition.tsx +918 -0
- package/template/runtime/helpers.tsx +228 -0
- package/template/runtime/index.tsx +22 -0
- package/template/runtime/types.ts +248 -0
- package/template/skill/SKILL.md +149 -0
- package/template/skill/references/browser-export.md +61 -0
- package/template/skill/references/components.md +38 -0
- package/template/skill/references/craft.md +53 -0
- package/template/skill/references/cursor.md +91 -0
- package/template/skill/references/footage.md +73 -0
- package/template/skill/references/format.md +140 -0
- package/template/skill/references/presets.md +56 -0
- package/template/skill/references/sound.md +128 -0
- package/template/starter/.studio/chat.json +1 -0
- package/template/starter/assets/.keep +0 -0
- package/template/starter/layers.json +46 -0
- package/template/starter/notes.md +4 -0
- package/template/starter/project.json +13 -0
- package/template/starter/renders/.keep +0 -0
- package/template/starter/scenes/Title.tsx +38 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, watch, writeFileSync } from "node:fs";
|
|
2
|
+
import { join, sep } from "node:path";
|
|
3
|
+
import { getEditorSession, sendToEditor } from "../bridge.js";
|
|
4
|
+
import { PACKAGE_VERSION } from "../config.js";
|
|
5
|
+
import { generateMusic, musicOptions } from "./music.js";
|
|
6
|
+
import { debugLog } from "../log.js";
|
|
7
|
+
import { buildProjectBundle, buildRenderEntrySource } from "./bundler.js";
|
|
8
|
+
import { detectAgents, getAgent } from "./agents/index.js";
|
|
9
|
+
import { ChatEngine } from "./chat.js";
|
|
10
|
+
import { handleStudioHttp } from "./http.js";
|
|
11
|
+
import { assertSlug, createProject, deleteProject, listAssets, listLibrary, listProjects, projectDir, readProjectState, StudioError, writeLayers, writeProjectFile, } from "./projects.js";
|
|
12
|
+
import { cancelLocalRender, runLocalRender } from "./render.js";
|
|
13
|
+
import { openFile, projectFile, revealFile } from "./reveal.js";
|
|
14
|
+
import { generateVoice, listVoices, removeKey, saveKey, setDefaultProvider, voiceOptions, voiceSettings, } from "./voice.js";
|
|
15
|
+
import { studioMcpServer } from "./workspace.js";
|
|
16
|
+
/** The hosted studio page, plus `npm run dev` of this repo. More with --origin or AGENTCUT_ORIGINS. */
|
|
17
|
+
export const STUDIO_APP_URL = "https://agentcut.synteq.app";
|
|
18
|
+
export const DEFAULT_ALLOWED_ORIGINS = [STUDIO_APP_URL, "http://localhost:3000", "http://127.0.0.1:3000"];
|
|
19
|
+
function asRecord(value) {
|
|
20
|
+
return value && typeof value === "object" ? value : {};
|
|
21
|
+
}
|
|
22
|
+
export class StudioHost {
|
|
23
|
+
paths;
|
|
24
|
+
options;
|
|
25
|
+
bundles = new Map();
|
|
26
|
+
building = new Map();
|
|
27
|
+
rebuildQueued = new Set();
|
|
28
|
+
watched = new Set();
|
|
29
|
+
timers = new Map();
|
|
30
|
+
watcher = null;
|
|
31
|
+
libraryWatcher = null;
|
|
32
|
+
agents = null;
|
|
33
|
+
pageSession = null;
|
|
34
|
+
chat;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.options = options;
|
|
37
|
+
this.paths = options.paths;
|
|
38
|
+
this.chat = new ChatEngine({
|
|
39
|
+
paths: this.paths,
|
|
40
|
+
allowBash: options.allowBash,
|
|
41
|
+
emit: (event, data) => this.emit(event, data),
|
|
42
|
+
getAgents: () => this.getAgents(),
|
|
43
|
+
defaultAgent: () => this.defaultAgent(),
|
|
44
|
+
mcp: studioMcpServer(this.paths),
|
|
45
|
+
getPageContext: () => this.pageSession,
|
|
46
|
+
addDirs: options.addDirs ?? [],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// BridgeExtension
|
|
51
|
+
isOriginAllowed(origin) {
|
|
52
|
+
if (!origin)
|
|
53
|
+
return true; // local tools (curl, MCP server) send no Origin
|
|
54
|
+
return this.options.allowedOrigins.includes(origin.replace(/\/+$/, ""));
|
|
55
|
+
}
|
|
56
|
+
handleHttp(request, response) {
|
|
57
|
+
return handleStudioHttp(request, response, {
|
|
58
|
+
paths: this.paths,
|
|
59
|
+
getBundle: (slug) => this.bundles.get(slug) ?? null,
|
|
60
|
+
ensureBundle: async (slug) => {
|
|
61
|
+
if (!this.bundles.has(slug))
|
|
62
|
+
await this.rebuild(slug);
|
|
63
|
+
},
|
|
64
|
+
onUploaded: (slug, rel) => this.emit("studio.assets", { slug, path: rel }),
|
|
65
|
+
importFootage: (input) => this.importFootage(input),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* "Send to Agentcut" from the editor: a project sized to the footage, with the
|
|
70
|
+
* editor's subtitles as an editable captions clip. Two modes:
|
|
71
|
+
* - edited (default): the rendered edit on one Footage track.
|
|
72
|
+
* - raw: the untouched recordings, screen takes back to back on a Screen track and the
|
|
73
|
+
* camera as a picture-in-picture clip on a Camera track, so the agent does the editing.
|
|
74
|
+
* The page uploads the files to the returned paths right after.
|
|
75
|
+
*/
|
|
76
|
+
importFootage(input) {
|
|
77
|
+
const num = (value, fallback) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback);
|
|
78
|
+
const frames = (value) => (typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.round(value)) : 0);
|
|
79
|
+
const extension = (value) => (typeof value === "string" && /^[a-z0-9]{2,4}$/.test(value) ? value : "mp4");
|
|
80
|
+
const raw = input.mode === "raw";
|
|
81
|
+
const screens = raw ? (Array.isArray(input.screens) ? input.screens : []).map((s) => asRecord(s)) : [];
|
|
82
|
+
if (raw && !screens.length)
|
|
83
|
+
throw new StudioError("No screen recording to import.", "bad_input");
|
|
84
|
+
const width = Math.round(num(input.width, 1920) / 2) * 2;
|
|
85
|
+
const height = Math.round(num(input.height, 1080) / 2) * 2;
|
|
86
|
+
const fps = Math.round(num(input.fps, 30));
|
|
87
|
+
const durationInFrames = Math.max(1, Math.round(num(input.durationInFrames, fps * 10)));
|
|
88
|
+
const vertical = height > width;
|
|
89
|
+
const variant = vertical ? "mobile" : "wide";
|
|
90
|
+
const fallbackName = raw ? "Raw takes from the editor" : "Footage from the editor";
|
|
91
|
+
const name = typeof input.name === "string" && input.name.trim() ? input.name.trim().slice(0, 80) : fallbackName;
|
|
92
|
+
const { slug } = createProject(this.paths, {
|
|
93
|
+
name,
|
|
94
|
+
fps,
|
|
95
|
+
durationInFrames,
|
|
96
|
+
variants: { [variant]: { width, height } },
|
|
97
|
+
defaultVariant: variant,
|
|
98
|
+
background: "#000000",
|
|
99
|
+
});
|
|
100
|
+
const words = (Array.isArray(input.words) ? input.words : [])
|
|
101
|
+
.map((w) => asRecord(w))
|
|
102
|
+
.filter((w) => typeof w.text === "string" && typeof w.from === "number" && typeof w.to === "number")
|
|
103
|
+
.map((w) => ({
|
|
104
|
+
text: String(w.text),
|
|
105
|
+
from: Math.max(0, Math.round(Number(w.from))),
|
|
106
|
+
to: Math.max(Math.round(Number(w.from)) + 1, Math.round(Number(w.to))),
|
|
107
|
+
}))
|
|
108
|
+
.filter((w) => w.from < durationInFrames);
|
|
109
|
+
// Clamp a clip to the project: starts inside it, at least one frame long.
|
|
110
|
+
const span = (from, duration) => {
|
|
111
|
+
const start = Math.min(frames(from), durationInFrames - 1);
|
|
112
|
+
return { from: start, duration: Math.max(1, Math.min(frames(duration) || durationInFrames, durationInFrames - start)) };
|
|
113
|
+
};
|
|
114
|
+
const tracks = [];
|
|
115
|
+
if (words.length) {
|
|
116
|
+
tracks.push({
|
|
117
|
+
id: "captions",
|
|
118
|
+
name: "Captions",
|
|
119
|
+
kind: "captions",
|
|
120
|
+
clips: [{ id: "captions", name: "Subtitles from the editor", from: 0, duration: durationInFrames, words }],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const seconds = (durationInFrames / fps).toFixed(1);
|
|
124
|
+
// Companion recordings come with `<video>.cursor.json` (uploaded by the page next to the video).
|
|
125
|
+
const cursorPathFor = (videoPath) => videoPath.replace(/\.[^./]+$/, "") + ".cursor.json";
|
|
126
|
+
const clickCount = (value) => frames(asRecord(value).clicks);
|
|
127
|
+
const captionsNote = words.length ? `\n- Subtitles: ${words.length} words on the Captions track (word timings in frames)` : "";
|
|
128
|
+
let notes;
|
|
129
|
+
let paths;
|
|
130
|
+
if (raw) {
|
|
131
|
+
const screenPaths = screens.map((s, i) => `assets/screen${screens.length > 1 ? `-${i + 1}` : ""}.${extension(s.extension)}`);
|
|
132
|
+
const camera = input.camera ? asRecord(input.camera) : null;
|
|
133
|
+
const cameraPath = camera ? `assets/camera.${extension(camera.extension)}` : undefined;
|
|
134
|
+
if (camera && cameraPath) {
|
|
135
|
+
const box = asRecord(camera.box);
|
|
136
|
+
const unit = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : fallback;
|
|
137
|
+
const radius = frames(camera.radius);
|
|
138
|
+
const trimStart = frames(camera.trimStart);
|
|
139
|
+
tracks.push({
|
|
140
|
+
id: "camera",
|
|
141
|
+
name: "Camera",
|
|
142
|
+
kind: "video",
|
|
143
|
+
clips: [
|
|
144
|
+
{
|
|
145
|
+
id: "camera",
|
|
146
|
+
name: "Camera",
|
|
147
|
+
...span(camera.from, camera.duration),
|
|
148
|
+
src: cameraPath,
|
|
149
|
+
...(trimStart ? { trimStart } : {}),
|
|
150
|
+
fit: "cover",
|
|
151
|
+
box: {
|
|
152
|
+
x: unit(box.x, 0.8),
|
|
153
|
+
y: unit(box.y, 0.75),
|
|
154
|
+
width: Math.max(0.01, unit(box.width, 0.15)),
|
|
155
|
+
height: Math.max(0.01, unit(box.height, 0.2)),
|
|
156
|
+
},
|
|
157
|
+
...(radius ? { radius } : {}),
|
|
158
|
+
muted: true,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
tracks.push({
|
|
164
|
+
id: "screen",
|
|
165
|
+
name: "Screen",
|
|
166
|
+
kind: "video",
|
|
167
|
+
clips: screens.map((s, i) => {
|
|
168
|
+
const cursor = s.cursor ? asRecord(s.cursor) : null;
|
|
169
|
+
return {
|
|
170
|
+
id: `screen-${i + 1}`,
|
|
171
|
+
name: screens.length > 1 ? `Screen take ${i + 1}` : "Screen",
|
|
172
|
+
...span(s.from, s.duration),
|
|
173
|
+
src: screenPaths[i],
|
|
174
|
+
fit: "contain",
|
|
175
|
+
// The recording has no pointer of its own: draw the recorded one. Otherwise keep
|
|
176
|
+
// the data linked (style hidden) so click effects are one switch away.
|
|
177
|
+
...(cursor
|
|
178
|
+
? {
|
|
179
|
+
cursor: cursor.cursorInVideo === false
|
|
180
|
+
? { src: cursorPathFor(screenPaths[i]), style: "classic", clicks: true }
|
|
181
|
+
: { src: cursorPathFor(screenPaths[i]), style: "hidden", clicks: false },
|
|
182
|
+
}
|
|
183
|
+
: {}),
|
|
184
|
+
};
|
|
185
|
+
}),
|
|
186
|
+
});
|
|
187
|
+
const cursorTakes = screens.flatMap((s, i) => (s.cursor ? [{ path: cursorPathFor(screenPaths[i]), cursor: asRecord(s.cursor) }] : []));
|
|
188
|
+
notes =
|
|
189
|
+
`# ${name}\n\nRaw takes sent from a video editor: nothing cut, zoomed or styled yet (${width}×${height}, ${seconds} s).\n` +
|
|
190
|
+
`- Screen: ${screenPaths.join(", ")} on the Screen track (back to back). Its audio is the user's voice.\n` +
|
|
191
|
+
(cameraPath
|
|
192
|
+
? `- Camera: ${cameraPath} on the Camera track, a picture-in-picture box where the editor had it. Muted: the voice is on the screen recording.${camera?.mirrored ? " The user had it mirrored in the editor." : ""}\n`
|
|
193
|
+
: "") +
|
|
194
|
+
(words.length ? `- Subtitles: ${words.length} words on the Captions track, timed to the raw recording (word timings in frames)\n` : "") +
|
|
195
|
+
cursorTakes
|
|
196
|
+
.map(({ path, cursor }) => `- Cursor: ${path} (${clickCount(cursor)} clicks). ${cursor.cursorInVideo === false
|
|
197
|
+
? "The recording has no pointer: the Screen clip draws this one (its \`cursor\` field)."
|
|
198
|
+
: "The recording shows its own pointer; the Screen clip links the data with style hidden."} See references/cursor.md.\n`)
|
|
199
|
+
.join("");
|
|
200
|
+
paths = { screenPaths, cameraPath };
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const videoPath = `assets/footage.${extension(input.extension)}`;
|
|
204
|
+
tracks.push({
|
|
205
|
+
id: "footage",
|
|
206
|
+
name: "Footage",
|
|
207
|
+
kind: "video",
|
|
208
|
+
clips: [{ id: "footage", name: "Footage", from: 0, duration: durationInFrames, src: videoPath, fit: "contain" }],
|
|
209
|
+
});
|
|
210
|
+
notes =
|
|
211
|
+
`# ${name}\n\nFootage sent from a video editor (the edit as it was exported: ${width}×${height}, ${seconds} s).\n` +
|
|
212
|
+
`- Video: ${videoPath} on the Footage track${captionsNote}\n` +
|
|
213
|
+
(input.cursor
|
|
214
|
+
? `- Clicks: ${cursorPathFor(videoPath)} (${clickCount(input.cursor)} clicks, timed to this edit; positions are on the original screen, not the edited frame). See references/cursor.md.\n`
|
|
215
|
+
: "");
|
|
216
|
+
paths = { videoPath };
|
|
217
|
+
}
|
|
218
|
+
const dir = projectDir(this.paths, slug);
|
|
219
|
+
writeFileSync(join(dir, "layers.json"), `${JSON.stringify({ version: 1, tracks, markers: [] }, null, 2)}\n`);
|
|
220
|
+
writeFileSync(join(dir, "notes.md"), notes);
|
|
221
|
+
this.emit("studio.projects", { projects: listProjects(this.paths) });
|
|
222
|
+
debugLog(`import: created ${slug} (${raw ? "raw" : "edited"}, ${width}x${height}, ${durationInFrames}f, ${words.length} words)`);
|
|
223
|
+
return { slug, ...paths };
|
|
224
|
+
}
|
|
225
|
+
onEditorChange(connected, session) {
|
|
226
|
+
const record = asRecord(session);
|
|
227
|
+
this.pageSession = connected && record.workspace === "studio" ? record : null;
|
|
228
|
+
if (this.pageSession?.activeProject && typeof this.pageSession.activeProject === "string") {
|
|
229
|
+
this.watchProject(this.pageSession.activeProject);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async handlePageRequest(method, params) {
|
|
233
|
+
const p = asRecord(params);
|
|
234
|
+
switch (method) {
|
|
235
|
+
case "studio.info":
|
|
236
|
+
return this.info();
|
|
237
|
+
case "studio.projects.list":
|
|
238
|
+
return listProjects(this.paths);
|
|
239
|
+
case "studio.projects.create": {
|
|
240
|
+
const created = createProject(this.paths, p);
|
|
241
|
+
this.emit("studio.projects", { projects: listProjects(this.paths) });
|
|
242
|
+
return created;
|
|
243
|
+
}
|
|
244
|
+
case "studio.projects.delete":
|
|
245
|
+
return this.deleteProject(assertSlug(p.slug));
|
|
246
|
+
case "studio.project.open":
|
|
247
|
+
return this.openProject(assertSlug(p.slug));
|
|
248
|
+
case "studio.session":
|
|
249
|
+
// The page tells us which project is active, the playhead and the selection.
|
|
250
|
+
this.pageSession = { ...(this.pageSession ?? {}), ...p, workspace: "studio" };
|
|
251
|
+
if (typeof p.activeProject === "string")
|
|
252
|
+
this.watchProject(p.activeProject);
|
|
253
|
+
return { ok: true };
|
|
254
|
+
case "studio.layers.write": {
|
|
255
|
+
const slug = assertSlug(p.slug);
|
|
256
|
+
const result = writeLayers(this.paths, slug, p.layers, typeof p.baseHash === "string" ? p.baseHash : null);
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
case "studio.project.write": {
|
|
260
|
+
const slug = assertSlug(p.slug);
|
|
261
|
+
return writeProjectFile(this.paths, slug, p.project);
|
|
262
|
+
}
|
|
263
|
+
case "studio.assets.list":
|
|
264
|
+
return {
|
|
265
|
+
assets: listAssets(this.paths, assertSlug(p.slug)),
|
|
266
|
+
library: listLibrary(this.paths),
|
|
267
|
+
};
|
|
268
|
+
case "studio.chat.send":
|
|
269
|
+
return this.chat.send(assertSlug(p.slug), String(p.text ?? ""), asRecord(p.context), p.agent);
|
|
270
|
+
case "studio.chat.cancel":
|
|
271
|
+
return this.chat.cancel(assertSlug(p.slug));
|
|
272
|
+
case "studio.chat.queue.edit":
|
|
273
|
+
return this.chat.editQueued(assertSlug(p.slug), String(p.messageId ?? ""), String(p.text ?? ""));
|
|
274
|
+
case "studio.chat.queue.remove":
|
|
275
|
+
return this.chat.removeQueued(assertSlug(p.slug), String(p.messageId ?? ""));
|
|
276
|
+
case "studio.chat.queue.now":
|
|
277
|
+
return this.chat.sendQueuedNow(assertSlug(p.slug), String(p.messageId ?? ""));
|
|
278
|
+
case "studio.chat.reset":
|
|
279
|
+
return this.chat.reset(assertSlug(p.slug));
|
|
280
|
+
case "studio.chat.history":
|
|
281
|
+
return this.chat.history(assertSlug(p.slug));
|
|
282
|
+
case "studio.render.cancel":
|
|
283
|
+
return { cancelled: cancelLocalRender() };
|
|
284
|
+
case "studio.file.reveal":
|
|
285
|
+
revealFile(projectFile(this.paths, assertSlug(p.slug), String(p.path ?? "")));
|
|
286
|
+
return { ok: true };
|
|
287
|
+
case "studio.file.open":
|
|
288
|
+
openFile(projectFile(this.paths, assertSlug(p.slug), String(p.path ?? "")));
|
|
289
|
+
return { ok: true };
|
|
290
|
+
case "studio.render.local":
|
|
291
|
+
return this.renderLocal(assertSlug(p.slug), String(p.variant ?? ""), p);
|
|
292
|
+
// Voice providers: the page sends a key once; it never comes back.
|
|
293
|
+
case "studio.voice.settings":
|
|
294
|
+
return voiceSettings();
|
|
295
|
+
case "studio.voice.saveKey":
|
|
296
|
+
return saveKey(p.provider, p.key, Boolean(p.makeDefault));
|
|
297
|
+
case "studio.voice.removeKey":
|
|
298
|
+
return removeKey(p.provider);
|
|
299
|
+
case "studio.voice.setDefault":
|
|
300
|
+
return setDefaultProvider(p.provider);
|
|
301
|
+
case "studio.voice.voices":
|
|
302
|
+
return { voices: await listVoices(String(p.provider)) };
|
|
303
|
+
case "studio.voice.generate": {
|
|
304
|
+
const slug = assertSlug(p.slug);
|
|
305
|
+
const result = await generateVoice(this.paths, slug, p);
|
|
306
|
+
this.emit("studio.assets", { slug });
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
default:
|
|
310
|
+
throw new StudioError(`Unknown studio method "${method}".`, "unknown_method");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** MCP tool calls the helper answers itself (files, not pixels). */
|
|
314
|
+
handleLocalCall(method, params) {
|
|
315
|
+
const p = asRecord(params);
|
|
316
|
+
switch (method) {
|
|
317
|
+
case "studio.local.workspace":
|
|
318
|
+
return Promise.resolve(this.workspaceSummary());
|
|
319
|
+
case "studio.local.create_project":
|
|
320
|
+
return (async () => {
|
|
321
|
+
const created = createProject(this.paths, p);
|
|
322
|
+
// The chat that asked for it follows the new project.
|
|
323
|
+
this.chat.moveRunningTurn(created.slug);
|
|
324
|
+
this.emit("studio.projects", { projects: listProjects(this.paths) });
|
|
325
|
+
this.emit("studio.open", { slug: created.slug });
|
|
326
|
+
this.watchProject(created.slug);
|
|
327
|
+
return { ...created, dir: projectDir(this.paths, created.slug) };
|
|
328
|
+
})();
|
|
329
|
+
case "studio.local.voice_options":
|
|
330
|
+
return (async () => {
|
|
331
|
+
const options = voiceOptions();
|
|
332
|
+
if (p.provider === "elevenlabs") {
|
|
333
|
+
const voices = await listVoices("elevenlabs");
|
|
334
|
+
return { ...options, elevenlabsVoices: voices.map((v) => ({ id: v.id, name: v.name, description: v.description })) };
|
|
335
|
+
}
|
|
336
|
+
return options;
|
|
337
|
+
})();
|
|
338
|
+
case "studio.local.music_options":
|
|
339
|
+
return Promise.resolve(musicOptions());
|
|
340
|
+
case "studio.local.generate_music":
|
|
341
|
+
return (async () => {
|
|
342
|
+
const slug = assertSlug(p.slug ?? this.pageSession?.activeProject);
|
|
343
|
+
const result = await generateMusic(this.paths, slug, p);
|
|
344
|
+
this.emit("studio.assets", { slug });
|
|
345
|
+
return result;
|
|
346
|
+
})();
|
|
347
|
+
case "studio.local.generate_voice":
|
|
348
|
+
return (async () => {
|
|
349
|
+
const slug = assertSlug(p.slug ?? this.pageSession?.activeProject);
|
|
350
|
+
const result = await generateVoice(this.paths, slug, p);
|
|
351
|
+
this.emit("studio.assets", { slug });
|
|
352
|
+
return result;
|
|
353
|
+
})();
|
|
354
|
+
case "studio.local.project_state":
|
|
355
|
+
return (async () => {
|
|
356
|
+
const slug = assertSlug(p.slug);
|
|
357
|
+
this.watchProject(slug);
|
|
358
|
+
await this.rebuild(slug);
|
|
359
|
+
return this.projectStatus(slug);
|
|
360
|
+
})();
|
|
361
|
+
default:
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// ---------------------------------------------------------------------------
|
|
366
|
+
start() {
|
|
367
|
+
try {
|
|
368
|
+
this.watcher = watch(this.paths.projects, { recursive: true }, (_event, filename) => {
|
|
369
|
+
if (!filename)
|
|
370
|
+
return;
|
|
371
|
+
this.onProjectFileChange(String(filename));
|
|
372
|
+
});
|
|
373
|
+
this.watcher.on("error", (error) => debugLog(`studio watcher error ${error.message}`));
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
debugLog(`studio watcher failed ${error.message}`);
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
this.libraryWatcher = watch(this.paths.library, { recursive: true }, () => {
|
|
380
|
+
this.debounce("library", () => this.emit("studio.library", {}), 200);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
catch { }
|
|
384
|
+
void this.getAgents();
|
|
385
|
+
}
|
|
386
|
+
stop() {
|
|
387
|
+
this.watcher?.close();
|
|
388
|
+
this.libraryWatcher?.close();
|
|
389
|
+
this.chat.cancelAll();
|
|
390
|
+
}
|
|
391
|
+
emit(event, data) {
|
|
392
|
+
sendToEditor({ type: "studio.event", event, data });
|
|
393
|
+
}
|
|
394
|
+
/** Every agent and whether it's installed (looked up once per helper run). */
|
|
395
|
+
getAgents() {
|
|
396
|
+
this.agents ??= Promise.resolve().then(detectAgents);
|
|
397
|
+
return this.agents;
|
|
398
|
+
}
|
|
399
|
+
async defaultAgent() {
|
|
400
|
+
const agents = await this.getAgents();
|
|
401
|
+
const wanted = this.options.agent;
|
|
402
|
+
if (wanted && getAgent(wanted))
|
|
403
|
+
return wanted;
|
|
404
|
+
return (agents.find((agent) => agent.found) ?? agents[0])?.id ?? null;
|
|
405
|
+
}
|
|
406
|
+
debounce(key, run, ms) {
|
|
407
|
+
const existing = this.timers.get(key);
|
|
408
|
+
if (existing)
|
|
409
|
+
clearTimeout(existing);
|
|
410
|
+
this.timers.set(key, setTimeout(() => {
|
|
411
|
+
this.timers.delete(key);
|
|
412
|
+
run();
|
|
413
|
+
}, ms));
|
|
414
|
+
}
|
|
415
|
+
onProjectFileChange(filename) {
|
|
416
|
+
const parts = filename.split(/[\\/]/);
|
|
417
|
+
const slug = parts[0];
|
|
418
|
+
const rest = parts.slice(1).join("/");
|
|
419
|
+
if (!slug || !rest) {
|
|
420
|
+
this.debounce("projects", () => this.emit("studio.projects", { projects: listProjects(this.paths) }), 150);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (rest.startsWith(".studio/") || rest.endsWith(".tmp"))
|
|
424
|
+
return;
|
|
425
|
+
if (rest === "project.json" || rest === "layers.json") {
|
|
426
|
+
this.debounce(`${slug}:project`, () => {
|
|
427
|
+
this.emitProject(slug);
|
|
428
|
+
// Validation of layers depends on scenes; the bundle doesn't change.
|
|
429
|
+
}, 60);
|
|
430
|
+
if (rest === "project.json") {
|
|
431
|
+
this.debounce("projects", () => this.emit("studio.projects", { projects: listProjects(this.paths) }), 150);
|
|
432
|
+
}
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (rest.startsWith("assets/") || rest.startsWith("renders/")) {
|
|
436
|
+
this.debounce(`${slug}:assets`, () => this.emit("studio.assets", { slug }), 150);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (/\.(tsx?|jsx?|json|svg|txt)$/.test(rest) && this.watched.has(slug)) {
|
|
440
|
+
this.debounce(`${slug}:bundle`, () => {
|
|
441
|
+
void this.rebuild(slug).then(() => this.emitProject(slug));
|
|
442
|
+
}, 80);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
emitProject(slug) {
|
|
446
|
+
try {
|
|
447
|
+
const state = readProjectState(this.paths, slug);
|
|
448
|
+
this.emit("studio.project", {
|
|
449
|
+
slug,
|
|
450
|
+
project: state.projectRaw,
|
|
451
|
+
layers: state.layersRaw,
|
|
452
|
+
layersHash: state.layersHash,
|
|
453
|
+
projectHash: state.projectHash,
|
|
454
|
+
issues: state.issues,
|
|
455
|
+
scenes: state.scenes,
|
|
456
|
+
projectValid: state.project !== null,
|
|
457
|
+
layersValid: state.layers !== null,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
debugLog(`emitProject ${slug} failed ${error.message}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
watchProject(slug) {
|
|
465
|
+
try {
|
|
466
|
+
assertSlug(slug);
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (this.watched.has(slug))
|
|
472
|
+
return;
|
|
473
|
+
this.watched.add(slug);
|
|
474
|
+
void this.rebuild(slug);
|
|
475
|
+
}
|
|
476
|
+
async rebuild(slug) {
|
|
477
|
+
const inFlight = this.building.get(slug);
|
|
478
|
+
if (inFlight) {
|
|
479
|
+
this.rebuildQueued.add(slug);
|
|
480
|
+
return inFlight;
|
|
481
|
+
}
|
|
482
|
+
const promise = (async () => {
|
|
483
|
+
let state = await buildProjectBundle(this.paths, slug, this.bundles.get(slug));
|
|
484
|
+
this.bundles.set(slug, state);
|
|
485
|
+
while (this.rebuildQueued.has(slug)) {
|
|
486
|
+
this.rebuildQueued.delete(slug);
|
|
487
|
+
state = await buildProjectBundle(this.paths, slug, state);
|
|
488
|
+
this.bundles.set(slug, state);
|
|
489
|
+
}
|
|
490
|
+
this.emit("studio.bundle", this.bundleSummary(state));
|
|
491
|
+
return state;
|
|
492
|
+
})();
|
|
493
|
+
this.building.set(slug, promise);
|
|
494
|
+
try {
|
|
495
|
+
return await promise;
|
|
496
|
+
}
|
|
497
|
+
finally {
|
|
498
|
+
this.building.delete(slug);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
bundleSummary(state) {
|
|
502
|
+
return {
|
|
503
|
+
slug: state.slug,
|
|
504
|
+
revision: state.revision,
|
|
505
|
+
ok: state.ok,
|
|
506
|
+
hasCode: Boolean(state.code),
|
|
507
|
+
errors: state.errors,
|
|
508
|
+
warnings: state.warnings,
|
|
509
|
+
scenes: state.scenes,
|
|
510
|
+
builtAt: state.builtAt,
|
|
511
|
+
durationMs: state.durationMs,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
async openProject(slug) {
|
|
515
|
+
this.watchProject(slug);
|
|
516
|
+
const bundle = await this.rebuild(slug);
|
|
517
|
+
const state = readProjectState(this.paths, slug);
|
|
518
|
+
return {
|
|
519
|
+
slug,
|
|
520
|
+
project: state.projectRaw,
|
|
521
|
+
layers: state.layersRaw,
|
|
522
|
+
layersHash: state.layersHash,
|
|
523
|
+
projectHash: state.projectHash,
|
|
524
|
+
issues: state.issues,
|
|
525
|
+
scenes: state.scenes,
|
|
526
|
+
projectValid: state.project !== null,
|
|
527
|
+
layersValid: state.layers !== null,
|
|
528
|
+
bundle: this.bundleSummary(bundle),
|
|
529
|
+
assets: listAssets(this.paths, slug),
|
|
530
|
+
chat: this.chat.history(slug),
|
|
531
|
+
dir: state.dir,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/** Delete a project from disk (the page confirms first). Not while the agent works on it. */
|
|
535
|
+
deleteProject(slug) {
|
|
536
|
+
if (this.chat.runningSlug() === slug) {
|
|
537
|
+
throw new StudioError("The agent is working on this project. Stop it first, then delete.", "busy");
|
|
538
|
+
}
|
|
539
|
+
this.chat.dropQueued(slug);
|
|
540
|
+
this.watched.delete(slug);
|
|
541
|
+
this.bundles.delete(slug);
|
|
542
|
+
for (const [key, timer] of this.timers) {
|
|
543
|
+
if (key.startsWith(`${slug}:`)) {
|
|
544
|
+
clearTimeout(timer);
|
|
545
|
+
this.timers.delete(key);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const result = deleteProject(this.paths, slug);
|
|
549
|
+
if (this.pageSession?.activeProject === slug)
|
|
550
|
+
this.pageSession.activeProject = null;
|
|
551
|
+
this.emit("studio.projects", { projects: listProjects(this.paths) });
|
|
552
|
+
debugLog(`deleted project ${slug} (${result.bytes} bytes)`);
|
|
553
|
+
return result;
|
|
554
|
+
}
|
|
555
|
+
projectStatus(slug) {
|
|
556
|
+
const state = readProjectState(this.paths, slug);
|
|
557
|
+
const bundle = this.bundles.get(slug);
|
|
558
|
+
return {
|
|
559
|
+
slug,
|
|
560
|
+
dir: state.dir,
|
|
561
|
+
projectValid: state.project !== null,
|
|
562
|
+
layersValid: state.layers !== null,
|
|
563
|
+
issues: state.issues,
|
|
564
|
+
scenes: state.scenes,
|
|
565
|
+
bundle: bundle ? this.bundleSummary(bundle) : null,
|
|
566
|
+
durationInFrames: state.project?.durationInFrames ?? null,
|
|
567
|
+
fps: state.project?.fps ?? null,
|
|
568
|
+
variants: state.project?.variants ?? null,
|
|
569
|
+
tracks: state.layers?.tracks.map((track) => ({
|
|
570
|
+
id: track.id,
|
|
571
|
+
name: track.name,
|
|
572
|
+
kind: track.kind,
|
|
573
|
+
clips: track.clips.length,
|
|
574
|
+
})) ?? null,
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
workspaceSummary() {
|
|
578
|
+
const session = getEditorSession();
|
|
579
|
+
return {
|
|
580
|
+
version: PACKAGE_VERSION,
|
|
581
|
+
workspace: this.paths.root,
|
|
582
|
+
projectsDir: this.paths.projects,
|
|
583
|
+
libraryDir: this.paths.library,
|
|
584
|
+
projects: listProjects(this.paths),
|
|
585
|
+
page: this.pageSession ?? (session ? { workspace: asRecord(session).workspace } : null),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
async info() {
|
|
589
|
+
const agents = await this.getAgents();
|
|
590
|
+
const claude = agents.find((agent) => agent.id === "claude");
|
|
591
|
+
return {
|
|
592
|
+
version: PACKAGE_VERSION,
|
|
593
|
+
workspace: this.paths.root,
|
|
594
|
+
agents,
|
|
595
|
+
defaultAgent: await this.defaultAgent(),
|
|
596
|
+
// Pages from before agents were pluggable read this.
|
|
597
|
+
claude: claude ? { found: claude.found, path: claude.path, version: claude.version, error: claude.error } : null,
|
|
598
|
+
allowBash: this.options.allowBash,
|
|
599
|
+
projects: listProjects(this.paths),
|
|
600
|
+
bridgePort: this.options.port,
|
|
601
|
+
// What the page may rely on beyond the basics ("styles": project.json accepts a style).
|
|
602
|
+
features: ["styles"],
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
async renderLocal(slug, variant, params) {
|
|
606
|
+
const state = readProjectState(this.paths, slug);
|
|
607
|
+
if (!state.project)
|
|
608
|
+
throw new StudioError("project.json is invalid; fix it before rendering.");
|
|
609
|
+
const chosen = variant || state.project.defaultVariant;
|
|
610
|
+
if (!state.project.variants[chosen])
|
|
611
|
+
throw new StudioError(`Unknown variant "${chosen}".`);
|
|
612
|
+
const entryPath = join(this.paths.render, `${slug}.render.tsx`);
|
|
613
|
+
mkdirSync(this.paths.render, { recursive: true });
|
|
614
|
+
writeFileSync(entryPath, buildRenderEntrySource(this.paths, slug, state.scenes));
|
|
615
|
+
const masterGain = typeof params.masterGain === "number" ? params.masterGain : 1;
|
|
616
|
+
return runLocalRender({
|
|
617
|
+
paths: this.paths,
|
|
618
|
+
slug,
|
|
619
|
+
variant: chosen,
|
|
620
|
+
entryPath,
|
|
621
|
+
port: this.options.port,
|
|
622
|
+
masterGain,
|
|
623
|
+
project: state.project,
|
|
624
|
+
layers: state.layersRaw,
|
|
625
|
+
onProgress: (data) => this.emit("studio.render", { slug, variant: chosen, ...data }),
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
export function ensureProjectsDir(paths) {
|
|
630
|
+
if (!existsSync(paths.projects))
|
|
631
|
+
mkdirSync(paths.projects, { recursive: true });
|
|
632
|
+
}
|
|
633
|
+
export const PATH_SEP = sep;
|
|
634
|
+
//# sourceMappingURL=host.js.map
|