agent-screenplay 0.0.0-stage → 0.1.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -2
  3. package/assets/editor/index.html +650 -0
  4. package/assets/fonts/Inter-Bold.ttf +0 -0
  5. package/assets/fonts/Inter-LICENSE.txt +92 -0
  6. package/assets/fonts/Inter-Medium.ttf +0 -0
  7. package/assets/fonts/Inter-Regular.ttf +0 -0
  8. package/assets/fonts/Inter-SemiBold.ttf +0 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +163 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/core.d.ts +18 -0
  13. package/dist/core.js +73 -0
  14. package/dist/core.js.map +1 -0
  15. package/dist/direct/plan.d.ts +100 -0
  16. package/dist/direct/plan.js +274 -0
  17. package/dist/direct/plan.js.map +1 -0
  18. package/dist/drivers/browser.d.ts +9 -0
  19. package/dist/drivers/browser.js +44 -0
  20. package/dist/drivers/browser.js.map +1 -0
  21. package/dist/drivers/desktop.d.ts +53 -0
  22. package/dist/drivers/desktop.js +650 -0
  23. package/dist/drivers/desktop.js.map +1 -0
  24. package/dist/drivers/pace.d.ts +11 -0
  25. package/dist/drivers/pace.js +44 -0
  26. package/dist/drivers/pace.js.map +1 -0
  27. package/dist/drivers/web.d.ts +49 -0
  28. package/dist/drivers/web.js +580 -0
  29. package/dist/drivers/web.js.map +1 -0
  30. package/dist/editor/server.d.ts +111 -0
  31. package/dist/editor/server.js +312 -0
  32. package/dist/editor/server.js.map +1 -0
  33. package/dist/ffmpeg.d.ts +5 -0
  34. package/dist/ffmpeg.js +44 -0
  35. package/dist/ffmpeg.js.map +1 -0
  36. package/dist/guide.d.ts +6 -0
  37. package/dist/guide.js +25 -0
  38. package/dist/guide.js.map +1 -0
  39. package/dist/init.d.ts +19 -0
  40. package/dist/init.js +147 -0
  41. package/dist/init.js.map +1 -0
  42. package/dist/login.d.ts +2 -0
  43. package/dist/login.js +50 -0
  44. package/dist/login.js.map +1 -0
  45. package/dist/mcp/server.d.ts +1 -0
  46. package/dist/mcp/server.js +132 -0
  47. package/dist/mcp/server.js.map +1 -0
  48. package/dist/render/compose.d.ts +68 -0
  49. package/dist/render/compose.js +361 -0
  50. package/dist/render/compose.js.map +1 -0
  51. package/dist/render/presets.d.ts +42 -0
  52. package/dist/render/presets.js +111 -0
  53. package/dist/render/presets.js.map +1 -0
  54. package/dist/render/render.d.ts +27 -0
  55. package/dist/render/render.js +259 -0
  56. package/dist/render/render.js.map +1 -0
  57. package/dist/render/sources.d.ts +15 -0
  58. package/dist/render/sources.js +146 -0
  59. package/dist/render/sources.js.map +1 -0
  60. package/dist/render/style.d.ts +41 -0
  61. package/dist/render/style.js +151 -0
  62. package/dist/render/style.js.map +1 -0
  63. package/dist/scenario/config.d.ts +43 -0
  64. package/dist/scenario/config.js +69 -0
  65. package/dist/scenario/config.js.map +1 -0
  66. package/dist/scenario/fingerprint.d.ts +10 -0
  67. package/dist/scenario/fingerprint.js +58 -0
  68. package/dist/scenario/fingerprint.js.map +1 -0
  69. package/dist/scenario/load.d.ts +36 -0
  70. package/dist/scenario/load.js +101 -0
  71. package/dist/scenario/load.js.map +1 -0
  72. package/dist/scenario/schema.d.ts +555 -0
  73. package/dist/scenario/schema.js +264 -0
  74. package/dist/scenario/schema.js.map +1 -0
  75. package/dist/scenario/target.d.ts +26 -0
  76. package/dist/scenario/target.js +40 -0
  77. package/dist/scenario/target.js.map +1 -0
  78. package/dist/take.d.ts +100 -0
  79. package/dist/take.js +15 -0
  80. package/dist/take.js.map +1 -0
  81. package/dist/version.d.ts +1 -0
  82. package/dist/version.js +2 -0
  83. package/dist/version.js.map +1 -0
  84. package/dist/voice/cartesia.d.ts +12 -0
  85. package/dist/voice/cartesia.js +103 -0
  86. package/dist/voice/cartesia.js.map +1 -0
  87. package/package.json +69 -4
  88. package/schema/scenario.schema.json +1098 -0
  89. package/skills/screenplay/SKILL.md +126 -0
Binary file
@@ -0,0 +1,92 @@
1
+ Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+ -----------------------------------------------------------
8
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9
+ -----------------------------------------------------------
10
+
11
+ PREAMBLE
12
+ The goals of the Open Font License (OFL) are to stimulate worldwide
13
+ development of collaborative font projects, to support the font creation
14
+ efforts of academic and linguistic communities, and to provide a free and
15
+ open framework in which fonts may be shared and improved in partnership
16
+ with others.
17
+
18
+ The OFL allows the licensed fonts to be used, studied, modified and
19
+ redistributed freely as long as they are not sold by themselves. The
20
+ fonts, including any derivative works, can be bundled, embedded,
21
+ redistributed and/or sold with any software provided that any reserved
22
+ names are not used by derivative works. The fonts and derivatives,
23
+ however, cannot be released under any other type of license. The
24
+ requirement for fonts to remain under this license does not apply
25
+ to any document created using the fonts or their derivatives.
26
+
27
+ DEFINITIONS
28
+ "Font Software" refers to the set of files released by the Copyright
29
+ Holder(s) under this license and clearly marked as such. This may
30
+ include source files, build scripts and documentation.
31
+
32
+ "Reserved Font Name" refers to any names specified as such after the
33
+ copyright statement(s).
34
+
35
+ "Original Version" refers to the collection of Font Software components as
36
+ distributed by the Copyright Holder(s).
37
+
38
+ "Modified Version" refers to any derivative made by adding to, deleting,
39
+ or substituting -- in part or in whole -- any of the components of the
40
+ Original Version, by changing formats or by porting the Font Software to a
41
+ new environment.
42
+
43
+ "Author" refers to any designer, engineer, programmer, technical
44
+ writer or other person who contributed to the Font Software.
45
+
46
+ PERMISSION AND CONDITIONS
47
+ Permission is hereby granted, free of charge, to any person obtaining
48
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
49
+ redistribute, and sell modified and unmodified copies of the Font
50
+ Software, subject to the following conditions:
51
+
52
+ 1) Neither the Font Software nor any of its individual components,
53
+ in Original or Modified Versions, may be sold by itself.
54
+
55
+ 2) Original or Modified Versions of the Font Software may be bundled,
56
+ redistributed and/or sold with any software, provided that each copy
57
+ contains the above copyright notice and this license. These can be
58
+ included either as stand-alone text files, human-readable headers or
59
+ in the appropriate machine-readable metadata fields within text or
60
+ binary files as long as those fields can be easily viewed by the user.
61
+
62
+ 3) No Modified Version of the Font Software may use the Reserved Font
63
+ Name(s) unless explicit written permission is granted by the corresponding
64
+ Copyright Holder. This restriction only applies to the primary font name as
65
+ presented to the users.
66
+
67
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68
+ Software shall not be used to promote, endorse or advertise any
69
+ Modified Version, except to acknowledge the contribution(s) of the
70
+ Copyright Holder(s) and the Author(s) or with their explicit written
71
+ permission.
72
+
73
+ 5) The Font Software, modified or unmodified, in part or in whole,
74
+ must be distributed entirely under this license, and must not be
75
+ distributed under any other license. The requirement for fonts to
76
+ remain under this license does not apply to any document created
77
+ using the Font Software.
78
+
79
+ TERMINATION
80
+ This license becomes null and void if any of the above conditions are
81
+ not met.
82
+
83
+ DISCLAIMER
84
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
Binary file
Binary file
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { check, record, render } from "./core.js";
4
+ import { guideText, schemaText } from "./guide.js";
5
+ import { init } from "./init.js";
6
+ import { login } from "./login.js";
7
+ import { ScenarioError } from "./scenario/load.js";
8
+ import { VERSION } from "./version.js";
9
+ const program = new Command();
10
+ program
11
+ .name("screenplay")
12
+ .description("Screen Studio-quality screen recordings for AI agents.")
13
+ .version(VERSION);
14
+ const log = (msg) => process.stderr.write(`${msg}\n`);
15
+ function fail(e) {
16
+ const msg = e instanceof Error ? e.message : String(e);
17
+ process.stderr.write(`\n✗ ${msg}\n`);
18
+ if (process.env.SCREENPLAY_DEBUG && e instanceof Error && !(e instanceof ScenarioError))
19
+ process.stderr.write(`${e.stack}\n`);
20
+ process.exit(1);
21
+ }
22
+ program
23
+ .command("record")
24
+ .argument("<scenario>", "scenario JSON file")
25
+ .description("Film the scenario and edit the video (MP4 + storyboard).")
26
+ .option("--no-voice", "skip the voice-over even if the scenario enables it")
27
+ .option("--gif", "also write a GIF")
28
+ .option("--json", "print the result as JSON")
29
+ .action(async (file, o) => {
30
+ try {
31
+ const r = await record(file, { noVoice: !o.voice, gif: o.gif, log });
32
+ if (o.json)
33
+ console.log(JSON.stringify(r, null, 2));
34
+ else {
35
+ log(`\n✓ ${r.mp4} (${r.duration.toFixed(1)}s, ${r.steps} steps, edited in ${r.seconds.toFixed(0)}s)`);
36
+ log(` storyboard: ${r.storyboard}`);
37
+ if (r.gif)
38
+ log(` gif: ${r.gif}`);
39
+ }
40
+ }
41
+ catch (e) {
42
+ fail(e);
43
+ }
44
+ });
45
+ program
46
+ .command("render")
47
+ .argument("<scenario>", "scenario JSON file")
48
+ .description("Edit the last recording again without filming (style, zoom, captions, narration).")
49
+ .option("--no-voice", "skip the voice-over even if the scenario enables it")
50
+ .option("--gif", "also write a GIF")
51
+ .option("--json", "print the result as JSON")
52
+ .action(async (file, o) => {
53
+ try {
54
+ const r = await render(file, { noVoice: !o.voice, gif: o.gif, log });
55
+ if (o.json)
56
+ console.log(JSON.stringify(r, null, 2));
57
+ else
58
+ log(`\n✓ ${r.mp4} (${r.duration.toFixed(1)}s)\n storyboard: ${r.storyboard}`);
59
+ }
60
+ catch (e) {
61
+ fail(e);
62
+ }
63
+ });
64
+ program
65
+ .command("style")
66
+ .argument("<scenario>", "scenario JSON file")
67
+ .description("Open the style editor in your browser: background, padding, corners and shadow, on a frame of the recording.")
68
+ .option("--port <port>", "port to listen on (default: any free port)")
69
+ .option("--no-open", "print the link instead of opening the browser")
70
+ .action(async (file, o) => {
71
+ try {
72
+ const { startStyleEditor } = await import("./editor/server.js");
73
+ await startStyleEditor(file, { port: o.port ? Number(o.port) : undefined, open: o.open, log });
74
+ log("Press Ctrl+C to stop.");
75
+ }
76
+ catch (e) {
77
+ fail(e);
78
+ }
79
+ });
80
+ program
81
+ .command("check")
82
+ .argument("<scenario>", "scenario JSON file")
83
+ .description("Play the scenario quickly without filming: every element exists and the flow completes.")
84
+ .option("--json", "print the report as JSON")
85
+ .action(async (file, o) => {
86
+ try {
87
+ const r = await check(file, { log: o.json ? undefined : log });
88
+ if (o.json)
89
+ console.log(JSON.stringify(r, null, 2));
90
+ else {
91
+ for (const s of r.steps) {
92
+ log(`${s.ok ? "✓" : "✗"} ${s.index + 1}. ${s.step}${s.error && s.error !== "not reached" ? `\n ${s.error}` : ""}`);
93
+ if (s.candidates?.length)
94
+ log(` visible targets: ${s.candidates.slice(0, 15).join(", ")}`);
95
+ }
96
+ if (r.screenshot)
97
+ log(`\nScreenshot where it stopped: ${r.screenshot}`);
98
+ log(r.ok ? "\n✓ The scenario plays to the end." : "\n✗ The scenario stops before the end.");
99
+ }
100
+ if (!r.ok)
101
+ process.exit(2);
102
+ }
103
+ catch (e) {
104
+ fail(e);
105
+ }
106
+ });
107
+ program
108
+ .command("init")
109
+ .description("Set up Screenplay: download Chromium, add the MCP server to Claude Code, Codex and Cursor, install the guide.")
110
+ .option("--no-browser", "do not download Chromium")
111
+ .option("--no-mcp", "do not add the MCP server to agents")
112
+ .option("--no-skill", "do not install the guide as a skill")
113
+ .option("--dry-run", "show what would change")
114
+ .action(async (o) => {
115
+ try {
116
+ const r = await init({ browser: o.browser, mcp: o.mcp, skill: o.skill, dryRun: o.dryRun, log });
117
+ for (const d of r.done)
118
+ log(`✓ ${d}`);
119
+ for (const s of r.skipped)
120
+ log(`· ${s}`);
121
+ for (const w of r.warnings)
122
+ log(`! ${w}`);
123
+ log("\nReady. Ask your agent: \"Make a screen recording that shows how <feature> works.\"");
124
+ }
125
+ catch (e) {
126
+ fail(e);
127
+ }
128
+ });
129
+ program
130
+ .command("login")
131
+ .argument("<url>", "page to sign in on")
132
+ .option("-o, --out <file>", "where to save the session", ".screenplay/auth.json")
133
+ .description("Open a browser to sign in once; the session is saved for scenarios (auth.storageState).")
134
+ .action(async (url, o) => {
135
+ try {
136
+ const file = await login(url, o.out, log);
137
+ log(`✓ Session saved to ${file}. Use it with "auth": { "storageState": "${o.out}" }. Keep it out of git.`);
138
+ }
139
+ catch (e) {
140
+ fail(e);
141
+ }
142
+ });
143
+ program
144
+ .command("mcp")
145
+ .description("Run the MCP server on stdio (for agents).")
146
+ .action(async () => {
147
+ const { startMcpServer } = await import("./mcp/server.js");
148
+ await startMcpServer();
149
+ });
150
+ program
151
+ .command("guide")
152
+ .description("Print the guide to writing good scenarios.")
153
+ .action(() => {
154
+ process.stdout.write(guideText());
155
+ });
156
+ program
157
+ .command("schema")
158
+ .description("Print the JSON schema of scenarios.")
159
+ .action(() => {
160
+ process.stdout.write(schemaText());
161
+ });
162
+ program.parseAsync(process.argv).catch(fail);
163
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,E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W,CAAC,qCAAqC,CAAC;KAClD,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { type CheckReport } from "./drivers/web.js";
2
+ import { type RenderResult } from "./render/render.js";
3
+ export interface RunOptions {
4
+ /** Force the voice-over off (true) regardless of the scenario. */
5
+ noVoice?: boolean;
6
+ gif?: boolean;
7
+ log?: (msg: string) => void;
8
+ /** Editing progress, 0 to 1, a few times a second. */
9
+ onProgress?: (fraction: number) => void;
10
+ }
11
+ export interface RecordResult extends RenderResult {
12
+ take: string;
13
+ steps: number;
14
+ }
15
+ export declare function record(file: string, opts?: RunOptions): Promise<RecordResult>;
16
+ export declare function render(file: string, opts?: RunOptions): Promise<RenderResult>;
17
+ export declare function check(file: string, opts?: RunOptions): Promise<CheckReport>;
18
+ export declare function takeExists(file: string): boolean;
package/dist/core.js ADDED
@@ -0,0 +1,73 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { loadScenario } from "./scenario/load.js";
4
+ import { runWeb } from "./drivers/web.js";
5
+ import { readingTime } from "./drivers/pace.js";
6
+ import { readTake, writeTake } from "./take.js";
7
+ import { captureInputs } from "./scenario/fingerprint.js";
8
+ import { renderTake } from "./render/render.js";
9
+ import { synthesizeAll } from "./voice/cartesia.js";
10
+ async function narration(loaded, opts) {
11
+ const voice = loaded.scenario.voice;
12
+ if (!voice?.enabled || opts.noVoice)
13
+ return new Map();
14
+ const texts = new Map();
15
+ loaded.scenario.steps.forEach((s, i) => {
16
+ const say = s.say;
17
+ if (say)
18
+ texts.set(i, say);
19
+ });
20
+ if (texts.size === 0)
21
+ return new Map();
22
+ opts.log?.(`Generating narration for ${texts.size} step(s)`);
23
+ return synthesizeAll(texts, voice, path.join(loaded.workDir, "cache", "voice"));
24
+ }
25
+ /** How long each step must last so its narration or caption can be heard or read. */
26
+ function minDurations(loaded, audio) {
27
+ const captions = loaded.scenario.style?.captions ?? true;
28
+ return loaded.scenario.steps.map((s, i) => {
29
+ const a = audio.get(i);
30
+ if (a)
31
+ return a.duration + 0.35;
32
+ const say = s.say;
33
+ return say && captions ? readingTime(say) : 0;
34
+ });
35
+ }
36
+ export async function record(file, opts = {}) {
37
+ const loaded = loadScenario(file);
38
+ const audio = await narration(loaded, opts);
39
+ let take;
40
+ if (loaded.scenario.url) {
41
+ const res = await runWeb(loaded, { mode: "record", minDurations: minDurations(loaded, audio), log: opts.log });
42
+ take = res.take;
43
+ }
44
+ else {
45
+ const { runDesktop } = await import("./drivers/desktop.js");
46
+ take = await runDesktop(loaded, { mode: "record", minDurations: minDurations(loaded, audio), log: opts.log });
47
+ }
48
+ take.inputs = captureInputs(loaded.scenario);
49
+ const takeFile = writeTake(loaded.takeDir, take);
50
+ opts.log?.("Editing the video");
51
+ const result = await renderTake(loaded, take, { audio, gif: opts.gif, log: opts.log });
52
+ return { ...result, take: takeFile, steps: take.steps.length };
53
+ }
54
+ export async function render(file, opts = {}) {
55
+ const loaded = loadScenario(file);
56
+ const take = readTake(loaded.takeDir);
57
+ const audio = await narration(loaded, opts);
58
+ return renderTake(loaded, take, { audio, gif: opts.gif, log: opts.log, onProgress: opts.onProgress });
59
+ }
60
+ export async function check(file, opts = {}) {
61
+ const loaded = loadScenario(file);
62
+ if (loaded.scenario.url) {
63
+ const res = await runWeb(loaded, { mode: "check", log: opts.log });
64
+ return res.check;
65
+ }
66
+ const { checkDesktop } = await import("./drivers/desktop.js");
67
+ return checkDesktop(loaded, { log: opts.log });
68
+ }
69
+ export function takeExists(file) {
70
+ const loaded = loadScenario(file, { env: false });
71
+ return fs.existsSync(path.join(loaded.takeDir, "take.json"));
72
+ }
73
+ //# sourceMappingURL=core.js.map
@@ -0,0 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AC,IAAY,EAAE,IAAI,GAAe,EAAE;IAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACnE,OAAO,GAAG,CAAC,KAAM,CAAC;IACpB,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAC9D,OAAO,YAAY,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { Scenario } from "../scenario/schema.js";
2
+ import type { Box, Point, Take, TakeStep } from "../take.js";
3
+ /**
4
+ * The edit of a take: how output time maps to recording time, where the
5
+ * camera looks, where the cursor is, and which overlays show when.
6
+ * Pure data, computed once, then drawn frame by frame by the compositor.
7
+ */
8
+ export type Piece = {
9
+ kind: "capture";
10
+ o0: number;
11
+ o1: number;
12
+ s0: number;
13
+ s1: number;
14
+ } | {
15
+ kind: "card";
16
+ o0: number;
17
+ o1: number;
18
+ step: TakeStep;
19
+ card: CardContent;
20
+ };
21
+ export interface CardContent {
22
+ kind: "title" | "end";
23
+ title: string;
24
+ subtitle?: string;
25
+ }
26
+ export interface Camera {
27
+ z: number;
28
+ cx: number;
29
+ cy: number;
30
+ }
31
+ export interface Caption {
32
+ o0: number;
33
+ o1: number;
34
+ text: string;
35
+ }
36
+ export interface Annotation {
37
+ kind: "callout" | "highlight";
38
+ o0: number;
39
+ o1: number;
40
+ box: Box;
41
+ text?: string;
42
+ }
43
+ export interface VoiceClip {
44
+ file: string;
45
+ at: number;
46
+ duration: number;
47
+ }
48
+ export interface Plan {
49
+ fps: number;
50
+ duration: number;
51
+ frameCount: number;
52
+ pieces: Piece[];
53
+ /** Camera state for each output frame. */
54
+ cameras: Camera[];
55
+ captions: Caption[];
56
+ annotations: Annotation[];
57
+ /** Output times of clicks. */
58
+ clicks: number[];
59
+ voice: VoiceClip[];
60
+ /** Output time span of each step. */
61
+ stepTimes: Array<{
62
+ o0: number;
63
+ o1: number;
64
+ oAction?: number;
65
+ }>;
66
+ movements: Movement[];
67
+ typing: Array<[number, number]>;
68
+ width: number;
69
+ height: number;
70
+ }
71
+ export interface Movement {
72
+ s0: number;
73
+ s1: number;
74
+ from: Point;
75
+ to: Point;
76
+ /** Side of the arc (+1/-1). */
77
+ bend: number;
78
+ }
79
+ export interface PlanOptions {
80
+ fps: number;
81
+ audio: Map<number, {
82
+ file: string;
83
+ duration: number;
84
+ }>;
85
+ autoZoom: boolean;
86
+ maxZoom: number;
87
+ captions: boolean;
88
+ }
89
+ export declare const OVERLAY_DELAY = 0.55;
90
+ export declare function planTake(take: Take, scenario: Scenario, opts: PlanOptions): Plan;
91
+ /** Zoom that frames a box with comfortable context. */
92
+ export declare function autoZoom(box: Box, W: number, H: number, maxZoom: number): number;
93
+ /** Where the cursor is at recording time s (minimum-jerk motion along a gentle arc). */
94
+ export declare function cursorAt(movements: Movement[], start: Point, s: number): Point;
95
+ /** Locate output time o: the piece, and the recording time when it is a capture. */
96
+ export declare function locate(plan: Plan, o: number): {
97
+ piece: Piece;
98
+ index: number;
99
+ s?: number;
100
+ };