The loop an agent works in
An agent that writes a video cannot watch it play. It works in a loop of small steps, each one a call of a tool that answers in JSON or with a picture:
- Edit the video's files with
bash. Framescript writes the change only when the video still runs. - Check it:
checkanswers with the diagnostics. Fix them before anything else. Check is the one gate: a video it finds an error in is not written by an agent's tools, and no one exports it, from the studio, the toolexportsorrender; the studio shows every finding after every change, whatever made it. - Look:
framereturns a frame as a picture. Read the picture. - Trace what you see back to its line:
inspectwithaction: "pick"for a pixel,inspectfor a whole frame, and withaction: "schedule"for the whole video. - Change the thing: a control with
controlsandaction: "set", or the literal on the line the trace named. - Answer the comment that asked for it, with
commentsandaction: "reply".
Then check and look again. How to plan a video, build it in parts and judge what you see is on Making a video that holds up. The tools are described in Checking a video, Reading a video, Looking at a frame and Controls and comments. This page walks through one pass on a small video. A call is shown as the parameters the tool named above it is given, and every answer below is from a real run, shortened where it says so.
Before the first edit
The person's wishes come first. Each video has a brief.md at its root, which the person writes in the studio's Brief: what they want of the video and the decisions they approved. Read it before changing the video and keep what it settles. Framescript's own pages, these, are in the app at /framescript/docs, and an example for every concept at /framescript/videos/examples: start from the one closest to the task.
While an agent works, the person sees it: its name stands at the top right of the window, and what it opens or moves to shows there as it happens. The tool app shows them what it means, a frame, a step or a comment's thread, and takes a screenshot of the window as they see it.
The video
A video has this file as /videos/hello/index.ts, written with bash. A title rises into place letter by letter, as every title does by default, then moves up.
import {
add,
by,
camera,
clip,
input,
timeline,
tween,
video,
wait,
} from "framescript"
import { rise } from "framescript/motion"
import { text } from "framescript/text"
import * as THREE from "three"
export default video(
{
width: 1280,
height: 720,
fps: 30,
inputs: {
ink: input.color("#ededed", { label: "Ink" }),
rise: input.slider(0.4, { min: 0, max: 1, step: 0.05, label: "Rise" }),
},
},
timeline(function* ({ stage, inputs }) {
;(stage.scene as THREE.Scene).background = new THREE.Color("#0e0e0e")
const lens = yield* add(new THREE.PerspectiveCamera(32, 16 / 9, 0.1, 100), {
position: [0, 0, 14],
})
yield* camera(lens)
yield* clip("intro", function* () {
const title = yield* add(
text("Hello", { fontSize: 1.2, color: inputs.ink, anchorX: "center" }),
{ position: [0, -0.3, 0] }
)
title.name = "title"
yield* rise(title)
yield* tween(title.position, { y: by(inputs.rise) }, 0.8)
yield* wait(0.6)
})
})
)
Check
The first draft of this file had no camera, and it moved the title by a fixed by(0.4) while still declaring rise. Framescript wrote it, since it ran, and check said what was wrong:
{ "video": "/videos/hello" }
{
"ok": true,
"video": "hello",
"status": "ready",
"duration": 2.412,
"frames": 73,
"diagnostics": [
{
"severity": "warning",
"rule": "input-unread",
"message": "The input \"rise\" is declared and never read, so turning it changes nothing. Read it in the timeline, or remove it.",
"site": "hello/index.ts:12:13",
"span": null,
"time": 2.412,
"frame": 72
},
{
"severity": "warning",
"rule": "no-camera",
"message": "The video never calls camera(). A default camera is used; add one and make it active with camera(cam).",
"site": null,
"span": null,
"time": 0,
"frame": 0
}
]
}
The line number is the draft's. A diagnostic's message says what is wrong and what to do, and its site is the file:line:column to do it at. Warnings leave ok true; an error makes ok false and marks the answer as an error. Treat both as work to do: the file above is the draft with both warnings fixed, and it checks clean, with "diagnostics": []. The taste warnings are strict on purpose and the same: meet the rule, as the library's defaults such as rise do, or lift it for one object with allow and a reason a person reads. A taste finding names its objects with their lines, its clip and the crop that shows them, and check with shots: true returns a picture of each, so you see what it points at (what a finding carries).
Look
Draw frame 30 with frame:
{ "video": "/videos/hello", "frame": 30, "out": "out/hello-30.png" }
{
"video": "hello",
"frame": 30,
"time": 1,
"path": "/videos/hello/out/hello-30.png",
"width": 1280,
"height": 720,
"bytes": 26919
}
The picture comes back with the answer: read it. Here it shows the word "Hello" in light grey on a dark ground, centred, a little below the middle.
A frame shows where things are, not how they move. To judge an entrance or a camera move, draw the stretch as a contact sheet, each tile labelled with its time and frame: frame with from: 0 and to: 1.5 (a stretch as a contact sheet).
A comment arrives
A reviewer leaves a comment on the title in the studio. List what is open with comments:
{ "video": "/videos/hello", "status": "open" }
{
"comments": [
{
"id": "c5eeff7",
"video": "hello",
"time": 1.9,
"point": {
"x": 0.43,
"y": 0.58
},
"object": {
"name": "title",
"site": "hello/index.ts:33:28",
"at": {
"x": 0.155,
"y": 0.511
}
},
"status": "open",
"author": "Mara",
"body": "The title ends too low. Bring it up to the middle of the frame.",
"at": "2026-11-22T17:09:03.229Z",
"replies": []
}
]
}
The thread gives the moment (1.9 s), the point, and the object under it: title, added at hello/index.ts:33. Look at exactly what the reviewer saw with frame, and keep the picture for comparison:
{ "video": "/videos/hello", "comment": "c5eeff7", "crop": "comment", "out": "out/before.png" }
{
"video": "hello",
"frame": 57,
"time": 1.9,
"comment": "c5eeff7",
"crop": [0.18, 0.32999999999999996, 0.5, 0.5],
"path": "/videos/hello/out/before.png",
"width": 640,
"height": 360,
"bytes": 11446
}
Trace
The comment already names the object. To learn what decides where it ends, pick a pixel of it at that frame. The point is a share of the frame; pick takes pixels, so 0.43 of 1280 is 550 and 0.58 of 720 is 418. Call inspect:
{ "video": "/videos/hello", "action": "pick", "frame": 57, "x": 550, "y": 418 }
{
"frame": 57,
"time": 1.9,
"x": 550,
"y": 418,
"object": {
"id": "o1",
"name": "title",
"type": "Mesh",
"span": "s4",
"site": "hello/index.ts:33:28"
},
"pointers": [
{
"frame": 57,
"time": 1.9,
"object": {
"id": "o1",
"name": "title",
"type": "Mesh",
"span": "s4",
"site": "hello/index.ts:33:28"
},
"path": "position.y",
"value": 0.10000000000000003,
"segment": {
"id": "g6",
"span": "s14",
"site": "hello/index.ts:39:14",
"from": -0.3,
"to": 0.10000000000000003,
"start": 1.012,
"end": 1.812,
"easing": {
"name": "easeOut",
"params": []
},
"state": "ended"
},
"chain": [
{
"id": "s3",
"kind": "clip",
"name": "intro",
"site": "hello/index.ts:32:12"
}
],
"editable": {
"to": {
"class": "computed",
"range": "hello/index.ts:39:41-39:56",
"text": "by(inputs.rise)"
},
"duration": {
"class": "literal",
"range": "hello/index.ts:39:60-39:63",
"text": "0.8"
}
}
}
]
}
The pointers for the rise, the line's cut and each letter's move, are cut. This one says: at frame 57 the title's position.y is 0.1, put there by the tween on line 39, which ended at 1.812 s inside the clip intro. Its end value is by(inputs.rise): a control decides it.
Change
List the controls with controls to see the one to turn, its limits and its line:
{ "video": "/videos/hello" }
{
"video": "hello",
"controls": [
{
"name": "rise",
"section": null,
"kind": "slider",
"label": "Rise",
"min": 0,
"max": 1,
"step": 0.05,
"default": 0.4,
"value": 0.4,
"site": "hello/index.ts:23:13",
"declared": true,
"line": "hello/index.ts:23"
}
]
}
The control ink is cut. Try a value before writing it, as the inputs of frame. The source stays as it is, and no checkpoint is made.
{ "video": "/videos/hello", "comment": "c5eeff7", "crop": "comment", "inputs": { "rise": 0.9 } }
The picture shows the title in the middle. Write the value with controls:
{ "video": "/videos/hello", "action": "set", "name": "rise", "value": "0.9" }
{
"ok": true,
"video": "hello",
"control": "rise",
"from": 0.4,
"to": 0.9,
"line": "hello/index.ts:23",
"text": "0.9"
}
Line 23 now reads rise: input.slider(0.9, { min: 0, max: 1, step: 0.05, label: "Rise" }),. A value outside the limits is refused and nothing is written:
{
"ok": false,
"video": "hello",
"error": "The control \"rise\" must lie from 0 to 1; it is 1.5."
}
Then run the loop's first steps again: check (clean), and the same frame call with out: "out/after.png", to compare with before.png.
Answer
Say what you changed, where, and where to look. Set the thread to review, so the reviewer sees it waits for them; resolving it is theirs. Call comments:
{
"video": "/videos/hello",
"action": "reply",
"id": "c5eeff7",
"status": "review",
"body": "Raised the Rise control from 0.4 to 0.9 (hello/index.ts:23). Frame 57 shows the title in the middle."
}
The answer is the thread with the reply in it and "status": "review". The window shows it at once, and app with action: "thread" opens the thread there for the person.
Going back
Every change Framescript writes is a checkpoint of the video's history, so a step that went wrong is undone by putting the one before it back. In the video's folder, bash's history lists the checkpoints, checkpoint <message> makes one by name, such as an approved cut, and restore <id> puts one back through the same checks.
What to prefer
- A control for anything a person may want to turn. When someone asks for a dial, declare one input with
inputand alabel, and read it where it applies. Then they can turn it in the studio, and you can set it withcontrols. See Inputs and controls. - Literals and named constants for the rest. A pointer's
editablegives each value a class. Aliteral(0.8) and alinkedvalue (a constant such asTIME) can be changed by the studio; acomputedone (BASE * 2,(v) => v + 2) cannot. Writeby(2), not a function, and an options object with plain numbers, so that a person can still drag what you wrote. See Editing by dragging. - Change the line the pointer names. For a
literal, edit the text at itsrange. For alinkedvalue therangeis the constant's definition, and changing it changes every use. - Names on objects.
title.name = "title"makes every pointer, pick and comment say which object it means. checkafter every edit, before looking, also after an edit your own client's tools wrote outside Framescript's: those pass no gate until check runs. A timeline that throws ends at the error, so the frames after it do not exist.- Small pictures first.
scale0.5 for the layout,cropat full size for a detail,crop: "comment"for what a reviewer pointed at. - Short pointers in what you write. "frame 57,
titleposition.y,hello/index.ts:39" is enough for a person to find it.