morpha-studio-sdk 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Morpha Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # morpha-studio-sdk
2
+
3
+ **The agentic video editor SDK — build, caption, and render short-form video in code.** Compose layers/captions/keyframes programmatically, then render a frame to PNG or export MP4 by driving a real browser. **No ffmpeg.** The client SDK for [Morpha Studio](https://morphastudio.ai).
4
+
5
+ ```bash
6
+ npm i morpha-studio-sdk
7
+ ```
8
+
9
+ ## Drive a hosted project — the MCP-equivalent client
10
+
11
+ `createClient` is the recommended way to drive a hosted Morpha account from code — the programmatic equivalent of an MCP session. Every tool you can call over MCP, you call here.
12
+
13
+ ```ts
14
+ import { createClient } from "morpha-studio-sdk";
15
+
16
+ const morpha = createClient({ token: process.env.MORPHA_TOKEN }); // origin defaults to https://morphastudio.ai
17
+
18
+ const project = await morpha.getProject("my-project");
19
+ const { result, editorUrl } = await morpha.callTool("my-project", "add_text_layer", {
20
+ text: "HELLO", x: 540, y: 600, font_family: "Anton",
21
+ });
22
+ const png = await morpha.renderFrame("my-project", 150); // a composited PNG, no ffmpeg
23
+ ```
24
+
25
+ `createClient` calls the same tool catalog as Morpha's MCP server, over the same Worker endpoints (`GET /api/project/:id`, `GET /api/tools`, `POST /api/tool/:name`) — `callTool` does the load → dispatch → write round-trip server-side. The token is your `mp_…` API key from `/app/settings`.
26
+
27
+ ## Make a video in code
28
+
29
+ ```ts
30
+ import { blankProject, dispatch, projectSchema } from "morpha-studio-sdk";
31
+
32
+ let project = blankProject({ projectId: "demo", canvasWidth: 1080, canvasHeight: 1920 });
33
+
34
+ // Every Morpha tool is a pure (project, args) => { project, result } function:
35
+ project = dispatch.add_text_layer(project, { text: "HELLO", x: 540, y: 600, font_family: "Anton" }).project;
36
+ project = dispatch.add_caption_track(project, {
37
+ lines: [{ text: "first line", startFrame: 0, endFrame: 30 }],
38
+ style: "bold-outline",
39
+ }).project;
40
+
41
+ projectSchema.parse(project); // it's a valid Morpha project, ready to save or render
42
+ ```
43
+
44
+ ## Render a video frame to PNG (no ffmpeg)
45
+
46
+ ```ts
47
+ import { renderFrame } from "morpha-studio-sdk";
48
+ import { writeFile } from "node:fs/promises";
49
+
50
+ const png = await renderFrame({ projectId: "demo", frame: 150, token: process.env.MORPHA_TOKEN });
51
+ await writeFile("frame.png", png);
52
+ ```
53
+
54
+ Rendering decodes the video and composites every overlay in a **real browser** (Playwright + system Chrome) — pixel-identical to the editor, and **without ffmpeg**. Install Playwright + have Google Chrome for rendering:
55
+
56
+ ```bash
57
+ npm i playwright # optional peer dep; only needed for renderFrame()
58
+ ```
59
+
60
+ ## Export MP4 without ffmpeg
61
+
62
+ The same browser pipeline exports the full composition to MP4 (WebCodecs) — no ffmpeg dependency, no GPL.
63
+
64
+ ## Auto-caption a clip
65
+
66
+ Turn a clip's transcript into a synced, styled caption track with `buildCaptionsForClip` / `transcriptToCaptionLines` — one text layer per line, timed to the words.
67
+
68
+ ## HEVC / iPhone video
69
+
70
+ System Chrome decodes **H.264, VP9, AV1, and HEVC** (HEVC via the OS decoder on macOS/Windows) — so 10-bit iPhone `.MOV` clips render correctly, which headless-Chromium-only tools can't do.
71
+
72
+ ## A programmatic / agentic video editor (Remotion alternative)
73
+
74
+ Unlike code-as-video frameworks, this is a real **editor project model** (layers, mattes, blend modes, keyframes, captions) you mutate via a typed tool catalog — ideal for **AI agents / LLMs** driving video edits, or any programmatic pipeline. It's the recommended client for driving Morpha programmatically: it calls the same hosted tool catalog as Morpha's MCP server, over the same Worker endpoints, so it's the typed, friendly alternative to wiring up MCP yourself (MCP stays available for MCP-native agents).
75
+
76
+ ## License
77
+
78
+ MIT © [Morpha Studio](https://morphastudio.ai)