@engenty/wizards-runtime 0.7.6 → 0.7.8
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/apps/runtime/dist/authoring/guide.js +12 -3
- package/apps/runtime/dist/browser/fast/classifier.js +9 -4
- package/apps/runtime/dist/cli/main.js +1 -1
- package/apps/runtime/dist/cli/menu.js +5 -1
- package/apps/runtime/dist/cli/ollama.js +302 -0
- package/apps/runtime/dist/cli/setup.js +102 -2
- package/apps/runtime/dist/decision-model.js +33 -0
- package/apps/runtime/dist/docs/dev/index.md +6 -1
- package/apps/runtime/dist/docs/dev/integration/channels.md +11 -0
- package/apps/runtime/dist/docs/dev/integration/claude-code-plugin.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/embed.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/index.md +36 -0
- package/apps/runtime/dist/docs/dev/integration/link-and-share.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/mcp-apps.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/mcp.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/meta.json +20 -0
- package/apps/runtime/dist/docs/dev/integration/openui.md +181 -0
- package/apps/runtime/dist/docs/dev/integration/own-ui.md +10 -0
- package/apps/runtime/dist/docs/dev/integration/results.md +11 -0
- package/apps/runtime/dist/docs/dev/integration/wordpress.md +10 -0
- package/apps/runtime/dist/docs/dev/meta.json +1 -1
- package/apps/runtime/dist/docs/user/command-line.md +1 -1
- package/apps/runtime/dist/docs/user/install.md +1 -0
- package/apps/runtime/dist/engine/decide.js +3 -1
- package/apps/runtime/dist/engine/steps.js +2 -1
- package/apps/runtime/dist/film/project.js +221 -65
- package/apps/runtime/dist/film/step.js +16 -5
- package/apps/runtime/dist/models.js +43 -3
- package/apps/runtime/dist/routes/runs.js +14 -1
- package/apps/runtime/dist/tools/code.js +173 -0
- package/apps/runtime/dist/tools/connector.js +6 -0
- package/apps/runtime/dist/tools/index.js +14 -3
- package/apps/web/dist/assets/{AboutDialog-DYgXPagX.js → AboutDialog-ByZyHXDj.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-BXqBW8j3.js → ChangelogDialog-QHYP0jAv.js} +1 -1
- package/apps/web/dist/assets/{ChatView-CK2--tsE.js → ChatView-DupTtI8K.js} +1 -1
- package/apps/web/dist/assets/EditorPage-k6qouLeS.js +4 -0
- package/apps/web/dist/assets/{FlowPreview-CusP7ci9.js → FlowPreview-Dx8AjXvE.js} +1 -1
- package/apps/web/dist/assets/{Harness-CV9uYzbv.js → Harness-NvIb36TG.js} +1 -1
- package/apps/web/dist/assets/{NewWizardChannels-BakW5q6s.js → NewWizardChannels-B2YgtJlt.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-BoA-LJuW.js → NewWizardPage-BgLY6SL6.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-DaD1XnOe.js → OnboardingPage-CxhwefJU.js} +1 -1
- package/apps/web/dist/assets/{ProjectPage-BFgk1DEv.js → ProjectPage-6ceSSS7W.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-C9MwEvxy.js → PublicRunner-6lQvReDx.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-DC2Kp7l8.js → ReadOnly-CGNHlgUT.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-CY6NZSrI.js → RunDrawer-TVGNnWyx.js} +2 -2
- package/apps/web/dist/assets/{RunnerView-BT26XgcY.js → RunnerView-DInSK0VZ.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-D3k5pXN5.js +1 -0
- package/apps/web/dist/assets/{SetupPage-DtFYAbwJ.js → SetupPage-Bj5frdzY.js} +1 -1
- package/apps/web/dist/assets/{SharePage-t2xwNS61.js → SharePage-hG7Z6SLy.js} +1 -1
- package/apps/web/dist/assets/changelog-CO9vKjV0.js +1 -0
- package/apps/web/dist/assets/{esm-DXeMu8Lb.js → esm-DVk3RJij.js} +1 -1
- package/apps/web/dist/assets/index-DfaoPjNW.css +1 -0
- package/apps/web/dist/assets/index-DlDsr9Lc.js +14 -0
- package/apps/web/dist/assets/oss-credits-X2JPiMOR.js +1 -0
- package/apps/web/dist/assets/{phone-CgrIS4_-.js → phone-CXXHXYnA.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-2IMOOlLl.js → settings-menu-DXzZCIMx.js} +1 -1
- package/apps/web/dist/assets/{ui-dzGvc3xk.js → ui-DQ4L2npj.js} +2 -2
- package/apps/web/dist/assets/{upload-BSuTilFF.js → upload-BnYHIfu5.js} +1 -1
- package/apps/web/dist/assets/{lock-R_CfU0Xo.js → wrench-BrUJ7SV6.js} +1 -1
- package/apps/web/dist/index.html +3 -3
- package/apps/web/dist/install.sh +2 -2
- package/apps/web/dist/mcp/flow.html +4 -4
- package/node_modules/@engenty/wizards/dist/openui/Wizard.d.ts +20 -0
- package/node_modules/@engenty/wizards/dist/openui/Wizard.js +62 -0
- package/node_modules/@engenty/wizards/dist/openui/index.d.ts +9 -0
- package/node_modules/@engenty/wizards/dist/openui/index.js +9 -0
- package/node_modules/@engenty/wizards/dist/openui/message.d.ts +11 -0
- package/node_modules/@engenty/wizards/dist/openui/message.js +69 -0
- package/node_modules/@engenty/wizards/dist/openui/run.d.ts +8 -0
- package/node_modules/@engenty/wizards/dist/openui/run.js +137 -0
- package/node_modules/@engenty/wizards/dist/openui/server.d.ts +37 -0
- package/node_modules/@engenty/wizards/dist/openui/server.js +77 -0
- package/node_modules/@engenty/wizards/package.json +4 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +7 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.js +16 -0
- package/node_modules/@engenty-wizards/shared/dist/fit.js +7 -2
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +14 -0
- package/node_modules/@engenty-wizards/shared/dist/run.js +2 -0
- package/package.json +4 -3
- package/apps/web/dist/assets/EditorPage-jvcwyXbU.js +0 -3
- package/apps/web/dist/assets/SettingsPage-AFt9IDLt.js +0 -1
- package/apps/web/dist/assets/changelog-CATQFxCQ.js +0 -1
- package/apps/web/dist/assets/index-AfUa8xKD.css +0 -1
- package/apps/web/dist/assets/index-Drw7FMTQ.js +0 -14
- package/apps/web/dist/assets/oss-credits-cZ9NUaLZ.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { cp, mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join, normalize } from "node:path";
|
|
5
5
|
import { dataRef, FILM_SIZES } from "@engenty-wizards/shared/definition";
|
|
6
6
|
import { gradientCss, ruleLines, textStyleLine } from "@engenty-wizards/shared/projects";
|
|
@@ -52,21 +52,43 @@ async function put(root, rel, data) {
|
|
|
52
52
|
await writeFile(path, data);
|
|
53
53
|
}
|
|
54
54
|
const safeName = (name) => name.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "file";
|
|
55
|
-
|
|
55
|
+
/** Where the client starts, by how film/ began. */
|
|
56
|
+
function startRules(start) {
|
|
57
|
+
if (start === "base") {
|
|
58
|
+
return `- **What to make:** BRIEF.md. **Start here:** film/ is already the wizard's base project in this
|
|
59
|
+
format — read film/PARTS.md first: its scene templates carry the look. Compose the film from them in
|
|
60
|
+
the one file PARTS.md names, timed to the voice; write a new scene only where no template fits, then
|
|
61
|
+
in the style of showcase/ (SHOWCASE.md says how each technique is made).
|
|
62
|
+
- **The brand:** film/brand/ holds brand.json and the logos. If film/brand/theme.json is missing, make
|
|
63
|
+
it first as film/BRAND.md says — it is kept for the next films of this space, so get it right.
|
|
64
|
+
Colours, logo and fonts come from there only.
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
if (start === "from") {
|
|
68
|
+
return `- **What to make:** BRIEF.md. **Start here:** film/ holds a finished film of this run in another
|
|
69
|
+
format. Lay it out for this one: scenes, timing, words and sound stay; only the layout changes
|
|
70
|
+
(film/PARTS.md says how when it exists). The look is showcase/'s.
|
|
71
|
+
- **The brand:** film/brand/ when it is there, else brand/brand.json and brand/logos/ — colours, logo
|
|
72
|
+
and fonts come from there only.
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
return `- **What to make:** BRIEF.md. **The bar:** showcase/ (read showcase/SHOWCASE.md and showcase/frame.md
|
|
76
|
+
first when it exists, look at its stills, reuse its helpers from showcase/assets/). **The brand:**
|
|
77
|
+
brand/brand.json and brand/logos/ — colours, logo and fonts come from there only.
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
function rules(step, skills, start) {
|
|
56
81
|
const size = FILM_SIZES[step.format];
|
|
57
82
|
return `# The film folder
|
|
58
83
|
|
|
59
84
|
You make one film here, autonomously, to the end. Nobody answers questions: where a skill asks the
|
|
60
85
|
person, decide yourself and note it in PROGRESS.md.
|
|
61
86
|
|
|
62
|
-
- **
|
|
63
|
-
first when it exists, look at its stills, reuse its helpers from showcase/assets/). **The brand:**
|
|
64
|
-
brand/brand.json and brand/logos/ — colours, logo and fonts come from there only.
|
|
65
|
-
- **Material:** input/ (see input/README.md). Use nothing from the web; you have no network.
|
|
87
|
+
${startRules(start)}- **Material:** input/ (see input/README.md). Use nothing from the web; you have no network.
|
|
66
88
|
- **Skills:** ${skills.join(", ")} in .claude/skills/<name>/SKILL.md. Start with \`hyperframes\` and
|
|
67
89
|
read the skill files directly; do not update or install skills.
|
|
68
|
-
- **The HyperFrames project is film/** (${size.width}×${size.height}
|
|
69
|
-
|
|
90
|
+
- **The HyperFrames project is film/** (${size.width}×${size.height}). Keep every file of the film
|
|
91
|
+
inside film/.
|
|
70
92
|
- **Running HyperFrames:** only through the \`hyperframes\` tool (MCP server \`film\`), e.g.
|
|
71
93
|
\`["lint","film"]\`, \`["check","film"]\`, \`["snapshot","film","--at","1,4,8"]\`,
|
|
72
94
|
\`["render","film","-q","draft"]\`, \`["transcribe","input/voice/l01.wav","--json","-d","input/voice"]\`.
|
|
@@ -86,57 +108,25 @@ person, decide yourself and note it in PROGRESS.md.
|
|
|
86
108
|
- Install nothing (no pip, brew, npm).
|
|
87
109
|
`;
|
|
88
110
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.update(JSON.stringify([
|
|
96
|
-
brief,
|
|
97
|
-
Object.values(step.inputs).map((raw) => {
|
|
98
|
-
const ref = dataRef(raw);
|
|
99
|
-
const [head, id] = ref.split(".");
|
|
100
|
-
return head === "steps" ? ctx.state.outputs[id]?.at : ctx.state.values[ref];
|
|
101
|
-
}),
|
|
102
|
-
]))
|
|
103
|
-
.digest("hex");
|
|
104
|
-
const stampFile = join(root, ".engenty", "inputs");
|
|
105
|
-
const same = existsSync(stampFile) && (await readFile(stampFile, "utf8")) === stamp;
|
|
106
|
-
if (same && existsSync(join(root, "film", "index.html")) && (await savedSession(root))) {
|
|
107
|
-
return { root, brief };
|
|
108
|
-
}
|
|
109
|
-
await rm(root, { recursive: true, force: true });
|
|
110
|
-
await mkdir(root, { recursive: true });
|
|
111
|
-
const skills = await placeSkills(step.skills, ctx.files, join(root, ".claude", "skills"));
|
|
112
|
-
const size = FILM_SIZES[step.format];
|
|
113
|
-
await put(root, "BRIEF.md", `# Brief\n\nFormat ${step.format}, ${size.width}×${size.height}${step.seconds ? `, about ${step.seconds} s` : ""}. Language of all text on screen: the brief's language.\n\n${brief}\n`);
|
|
114
|
-
const text = rules(step, skills);
|
|
115
|
-
await put(root, "CLAUDE.md", text);
|
|
116
|
-
await put(root, "AGENTS.md", text);
|
|
117
|
-
// The style kit.
|
|
118
|
-
if (step.kit) {
|
|
119
|
-
const file = ctx.files.find((f) => f.path === step.kit);
|
|
120
|
-
if (file) {
|
|
121
|
-
const entries = unzipSync(new Uint8Array(await getBlob(file.hash)));
|
|
122
|
-
for (const [name, data] of Object.entries(entries)) {
|
|
123
|
-
if (!name.endsWith("/")) {
|
|
124
|
-
await put(join(root, "showcase"), name.replace(/^showcase\//, ""), data);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// The space's brand.
|
|
111
|
+
const BRAND_STAMP = join(".engenty", "brand");
|
|
112
|
+
/**
|
|
113
|
+
* Writes the space's brand into brand/ as it is now (brand.json, logos). True when it differs
|
|
114
|
+
* from what the folder had before — the film's code then still carries the old one.
|
|
115
|
+
*/
|
|
116
|
+
async function writeBrand(root, ctx) {
|
|
130
117
|
const b = ctx.scope.brand;
|
|
131
|
-
const
|
|
118
|
+
const hash = createHash("sha256");
|
|
119
|
+
const files = [];
|
|
120
|
+
const fileName = (dir, f) => `${dir}/${safeName(f.name.replace(/\.[^.]+$/, ""))}.${extFor(f.mime) === "bin" ? (f.name.split(".").pop() ?? "bin") : extFor(f.mime)}`;
|
|
132
121
|
const patterns = [];
|
|
133
122
|
for (const p of b.patterns ?? []) {
|
|
134
123
|
const f = ctx.projectFiles.find((x) => x.id === p.file);
|
|
135
124
|
try {
|
|
136
125
|
if (f) {
|
|
137
126
|
const { data } = await projectFileContent(f.projectId, f.id);
|
|
138
|
-
const name =
|
|
139
|
-
|
|
127
|
+
const name = fileName("patterns", f);
|
|
128
|
+
files.push({ name, data });
|
|
129
|
+
hash.update(name).update(data);
|
|
140
130
|
patterns.push({
|
|
141
131
|
file: name,
|
|
142
132
|
name: p.name,
|
|
@@ -149,11 +139,13 @@ export async function prepareFilmFolder(step, ctx) {
|
|
|
149
139
|
// a pattern less
|
|
150
140
|
}
|
|
151
141
|
}
|
|
142
|
+
const logos = [];
|
|
152
143
|
for (const f of ctx.projectFiles.filter((p) => p.kind === "logo")) {
|
|
153
144
|
try {
|
|
154
145
|
const { data } = await projectFileContent(f.projectId, f.id);
|
|
155
|
-
const name =
|
|
156
|
-
|
|
146
|
+
const name = fileName("logos", f);
|
|
147
|
+
files.push({ name, data });
|
|
148
|
+
hash.update(name).update(data);
|
|
157
149
|
const section = logoSectionLine(b.logoSections, f.id);
|
|
158
150
|
logos.push({
|
|
159
151
|
file: name,
|
|
@@ -165,7 +157,7 @@ export async function prepareFilmFolder(step, ctx) {
|
|
|
165
157
|
// a logo less
|
|
166
158
|
}
|
|
167
159
|
}
|
|
168
|
-
|
|
160
|
+
const json = JSON.stringify({
|
|
169
161
|
note: "The space's brand. Colours are named by what they are for; the first is the accent. A logo's section, a gradient's or a pattern's description says when to use it; colorRules, logoRules and typeRules, where there are any, say how colours, logos and type may be used; text is set in the fonts — a font with `uses` that leave out video is not used in a film: its text gets a system font.",
|
|
170
162
|
name: b.name ?? "",
|
|
171
163
|
about: b.about ?? "",
|
|
@@ -199,16 +191,149 @@ export async function prepareFilmFolder(step, ctx) {
|
|
|
199
191
|
: {}),
|
|
200
192
|
...(b.textStyles?.length
|
|
201
193
|
? {
|
|
202
|
-
textStyles: b.textStyles.map((
|
|
203
|
-
name:
|
|
204
|
-
style: textStyleLine(
|
|
194
|
+
textStyles: b.textStyles.map((t) => ({
|
|
195
|
+
name: t.name,
|
|
196
|
+
style: textStyleLine(t, b.fonts ?? []),
|
|
205
197
|
})),
|
|
206
198
|
}
|
|
207
199
|
: {}),
|
|
208
200
|
...(b.typeRules?.length ? { typeRules: ruleLines(b.typeRules).split("\n") } : {}),
|
|
209
201
|
...(b.logoRules?.length ? { logoRules: ruleLines(b.logoRules).split("\n") } : {}),
|
|
210
202
|
facts: (b.facts ?? []).map((f) => `${f.label}: ${f.value}`),
|
|
211
|
-
}, null, 1)
|
|
203
|
+
}, null, 1);
|
|
204
|
+
const stamp = hash.update(json).digest("hex");
|
|
205
|
+
let changed = false;
|
|
206
|
+
try {
|
|
207
|
+
changed = (await readFile(join(root, BRAND_STAMP), "utf8")) !== stamp;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// A folder from before the stamp: its brand.json tells; a new folder has none.
|
|
211
|
+
const old = await readFile(join(root, "brand", "brand.json"), "utf8").catch(() => null);
|
|
212
|
+
changed = old !== null && old !== json;
|
|
213
|
+
}
|
|
214
|
+
await rm(join(root, "brand"), { recursive: true, force: true });
|
|
215
|
+
for (const f of files) {
|
|
216
|
+
await put(join(root, "brand"), f.name, f.data);
|
|
217
|
+
}
|
|
218
|
+
await put(join(root, "brand"), "brand.json", json);
|
|
219
|
+
await put(root, BRAND_STAMP, stamp);
|
|
220
|
+
return { changed, stamp };
|
|
221
|
+
}
|
|
222
|
+
const START = join(".engenty", "start");
|
|
223
|
+
const BASE = join(".engenty", "base");
|
|
224
|
+
/**
|
|
225
|
+
* The brand base: what a film made once from the space's brand for the kit's base (the base's
|
|
226
|
+
* BRAND.md says what — theme.json at least), kept per space for the kit and the brand as they are.
|
|
227
|
+
* A changed brand or kit is another key, so it is made again.
|
|
228
|
+
*/
|
|
229
|
+
function brandBaseDir(ctx, kitHash, brandStamp) {
|
|
230
|
+
const key = createHash("sha256").update(`${kitHash}:${brandStamp}`).digest("hex").slice(0, 24);
|
|
231
|
+
return join(env.dataDir, "brand-bases", ctx.project.id, key);
|
|
232
|
+
}
|
|
233
|
+
/** What in film/brand/ is the brand base: everything but the brand itself. */
|
|
234
|
+
const isBrandItself = (name) => name === "brand.json" || name === "logos" || name === "patterns";
|
|
235
|
+
/**
|
|
236
|
+
* Brings the brand into a project that started from a base: brand.json and the logos as they are
|
|
237
|
+
* now, and the brand base kept for them when there is one. A base that no longer fits the brand
|
|
238
|
+
* is removed — the film makes it again, as BRAND.md says.
|
|
239
|
+
*/
|
|
240
|
+
async function brandIntoFilm(root, brandChanged) {
|
|
241
|
+
const base = await readFile(join(root, BASE), "utf8").catch(() => "");
|
|
242
|
+
if (!base) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const target = join(root, "film", "brand");
|
|
246
|
+
await mkdir(target, { recursive: true });
|
|
247
|
+
for (const name of await readdir(target)) {
|
|
248
|
+
if (isBrandItself(name) || (brandChanged && !existsSync(base))) {
|
|
249
|
+
await rm(join(target, name), { recursive: true, force: true });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
await cp(join(root, "brand"), target, { recursive: true });
|
|
253
|
+
if (existsSync(base) && (brandChanged || !existsSync(join(target, "theme.json")))) {
|
|
254
|
+
await cp(base, target, { recursive: true });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** A new brand is another brand base: the marker points at the one for the brand as it is now. */
|
|
258
|
+
async function refreshBrandBase(root, ctx, step) {
|
|
259
|
+
if (!existsSync(join(root, BASE))) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const kitHash = ctx.files.find((f) => f.path === step.kit)?.hash ?? "";
|
|
263
|
+
const stamp = await readFile(join(root, BRAND_STAMP), "utf8");
|
|
264
|
+
await put(root, BASE, brandBaseDir(ctx, kitHash, stamp));
|
|
265
|
+
}
|
|
266
|
+
/** After a film: keeps what it made from the brand for the next films in this space. */
|
|
267
|
+
export async function keepBrandBase(root) {
|
|
268
|
+
const base = await readFile(join(root, BASE), "utf8").catch(() => "");
|
|
269
|
+
const source = join(root, "film", "brand");
|
|
270
|
+
if (!base || !existsSync(join(source, "theme.json"))) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
await rm(base, { recursive: true, force: true });
|
|
274
|
+
await mkdir(base, { recursive: true });
|
|
275
|
+
for (const name of await readdir(source)) {
|
|
276
|
+
if (!isBrandItself(name)) {
|
|
277
|
+
await cp(join(source, name), join(base, name), { recursive: true });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/** Sets up the folder for a first attempt; a later attempt finds it as it was left. */
|
|
282
|
+
export async function prepareFilmFolder(step, ctx) {
|
|
283
|
+
const root = filmRoot(ctx.runId, step.id);
|
|
284
|
+
const brief = renderTemplate(step.brief, ctx.scope).trim();
|
|
285
|
+
// An earlier film to start from, when it ran.
|
|
286
|
+
const fromId = step.from ? dataRef(step.from).replace(/^steps\./, "") : null;
|
|
287
|
+
const fromDir = fromId ? join(filmRoot(ctx.runId, fromId), "film") : null;
|
|
288
|
+
const from = fromId && fromDir && existsSync(join(fromDir, "index.html")) ? fromId : null;
|
|
289
|
+
// The same brief and material as last time: the film is there to go on with or to change.
|
|
290
|
+
const stamp = createHash("sha256")
|
|
291
|
+
.update(JSON.stringify([
|
|
292
|
+
brief,
|
|
293
|
+
Object.values(step.inputs).map((raw) => {
|
|
294
|
+
const ref = dataRef(raw);
|
|
295
|
+
const [head, id] = ref.split(".");
|
|
296
|
+
return head === "steps" ? ctx.state.outputs[id]?.at : ctx.state.values[ref];
|
|
297
|
+
}),
|
|
298
|
+
from ? ctx.state.outputs[from]?.at : null,
|
|
299
|
+
]))
|
|
300
|
+
.digest("hex");
|
|
301
|
+
const stampFile = join(root, ".engenty", "inputs");
|
|
302
|
+
const same = existsSync(stampFile) && (await readFile(stampFile, "utf8")) === stamp;
|
|
303
|
+
if (same && existsSync(join(root, "film", "index.html")) && (await savedSession(root))) {
|
|
304
|
+
// The brand is the space's as it is now, also for a change: colours or a logo may be new.
|
|
305
|
+
const { changed } = await writeBrand(root, ctx);
|
|
306
|
+
const start = ((await readFile(join(root, START), "utf8").catch(() => "")) ||
|
|
307
|
+
"init");
|
|
308
|
+
if (changed) {
|
|
309
|
+
await refreshBrandBase(root, ctx, step);
|
|
310
|
+
}
|
|
311
|
+
await brandIntoFilm(root, changed);
|
|
312
|
+
return { root, brief, brandChanged: changed, start };
|
|
313
|
+
}
|
|
314
|
+
await rm(root, { recursive: true, force: true });
|
|
315
|
+
await mkdir(root, { recursive: true });
|
|
316
|
+
const skills = await placeSkills(step.skills, ctx.files, join(root, ".claude", "skills"));
|
|
317
|
+
const size = FILM_SIZES[step.format];
|
|
318
|
+
await put(root, "BRIEF.md", `# Brief\n\nFormat ${step.format}, ${size.width}×${size.height}${step.seconds ? `, about ${step.seconds} s` : ""}. Language of all text on screen: the brief's language.\n\n${brief}\n`);
|
|
319
|
+
// The style kit: the showcase to look at, and the base a film starts from when it has one.
|
|
320
|
+
const kitFile = step.kit ? ctx.files.find((f) => f.path === step.kit) : undefined;
|
|
321
|
+
const base = {};
|
|
322
|
+
if (kitFile) {
|
|
323
|
+
const entries = unzipSync(new Uint8Array(await getBlob(kitFile.hash)));
|
|
324
|
+
for (const [name, data] of Object.entries(entries)) {
|
|
325
|
+
if (name.endsWith("/")) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (name.startsWith("base/")) {
|
|
329
|
+
base[name.slice("base/".length)] = data;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
await put(join(root, "showcase"), name.replace(/^showcase\//, ""), data);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const { stamp: brandStamp } = await writeBrand(root, ctx);
|
|
212
337
|
// What the run made before.
|
|
213
338
|
const listed = [];
|
|
214
339
|
for (const [name, raw] of Object.entries(step.inputs)) {
|
|
@@ -246,12 +371,43 @@ export async function prepareFilmFolder(step, ctx) {
|
|
|
246
371
|
}
|
|
247
372
|
await put(join(root, "input"), "README.md", `# Material for this film\n\n${listed.join("\n") || "(none)"}\n\nVoice lines play one after another in their order; their lengths decide the timing.\n`);
|
|
248
373
|
await cp(await soundCatalog(), join(root, "audio-catalog"), { recursive: true });
|
|
249
|
-
// The HyperFrames project
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
374
|
+
// The HyperFrames project: the earlier film, the kit's base in this format, or a new one.
|
|
375
|
+
const index = `index.${step.format.replace(":", "x")}.html`;
|
|
376
|
+
let start;
|
|
377
|
+
if (from && fromDir) {
|
|
378
|
+
start = "from";
|
|
379
|
+
await cp(fromDir, join(root, "film"), {
|
|
380
|
+
recursive: true,
|
|
381
|
+
filter: (path) => !/\/(renders|snapshots)(\/|$)/.test(path.slice(fromDir.length)),
|
|
382
|
+
});
|
|
383
|
+
const fromBase = await readFile(join(filmRoot(ctx.runId, from), BASE), "utf8").catch(() => "");
|
|
384
|
+
if (fromBase) {
|
|
385
|
+
await put(root, BASE, fromBase);
|
|
386
|
+
}
|
|
254
387
|
}
|
|
388
|
+
else if (base[index]) {
|
|
389
|
+
start = "base";
|
|
390
|
+
for (const [name, data] of Object.entries(base)) {
|
|
391
|
+
if (!/^index\.\d+x\d+\.html$/.test(name)) {
|
|
392
|
+
await put(join(root, "film"), name, data);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
await put(join(root, "film"), "index.html", base[index]);
|
|
396
|
+
await put(root, BASE, brandBaseDir(ctx, kitFile?.hash ?? "", brandStamp));
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
start = "init";
|
|
400
|
+
const preset = { "16:9": "landscape", "9:16": "portrait", "1:1": "square" }[step.format];
|
|
401
|
+
const init = await runHyperframes(["init", "film", "--non-interactive", "--skip-transcribe", `--resolution=${preset}`], { cwd: root, signal: ctx.signal, timeoutMs: 5 * 60_000 });
|
|
402
|
+
if (init.code !== 0 || !existsSync(join(root, "film"))) {
|
|
403
|
+
throw new Error(`The film project could not be set up: ${init.out.slice(-300)}`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
await brandIntoFilm(root, false);
|
|
407
|
+
const text = rules(step, skills, start);
|
|
408
|
+
await put(root, "CLAUDE.md", text);
|
|
409
|
+
await put(root, "AGENTS.md", text);
|
|
410
|
+
await put(root, START, start);
|
|
255
411
|
await put(root, ".engenty/inputs", stamp);
|
|
256
|
-
return { root, brief };
|
|
412
|
+
return { root, brief, brandChanged: false, start };
|
|
257
413
|
}
|
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { readFile, rm, stat } from "node:fs/promises";
|
|
4
4
|
import { isAbsolute, join, normalize } from "node:path";
|
|
5
|
+
import { FILM_SIZES } from "@engenty-wizards/shared/definition";
|
|
5
6
|
import { note as runNote } from "@engenty-wizards/shared/run";
|
|
6
7
|
import { StepError } from "../engine/types.js";
|
|
7
8
|
import { CLAUDE_BIN, claudeEnv } from "../harness/claude.js";
|
|
@@ -9,7 +10,7 @@ import { failureOf } from "../harness/model.js";
|
|
|
9
10
|
import { openBridge } from "../mcp/bridge.js";
|
|
10
11
|
import { saidOf } from "../model-errors.js";
|
|
11
12
|
import { filmClient } from "../models.js";
|
|
12
|
-
import { prepareFilmFolder, savedSession, saveSession } from "./project.js";
|
|
13
|
+
import { keepBrandBase, prepareFilmFolder, savedSession, saveSession } from "./project.js";
|
|
13
14
|
import { runHyperframes } from "./tools.js";
|
|
14
15
|
/**
|
|
15
16
|
* A film step: the installed client (Claude Code) works in the film's folder with the skills,
|
|
@@ -99,7 +100,7 @@ export async function runFilmStep(step, ctx) {
|
|
|
99
100
|
}
|
|
100
101
|
const { client, alias } = found;
|
|
101
102
|
await ctx.emit("info", { code: "filmSetup" });
|
|
102
|
-
const { root, brief } = await prepareFilmFolder(step, ctx);
|
|
103
|
+
const { root, brief, brandChanged, start } = await prepareFilmFolder(step, ctx);
|
|
103
104
|
const resume = await savedSession(root);
|
|
104
105
|
await ctx.emit("info", resume ? { code: "filmResume" } : { code: "filmClient", params: { client: client.name } });
|
|
105
106
|
const limit = AbortSignal.any([ctx.signal, AbortSignal.timeout(LIMIT_MS)]);
|
|
@@ -244,11 +245,20 @@ export async function runFilmStep(step, ctx) {
|
|
|
244
245
|
try {
|
|
245
246
|
// A review's note asks for a change: the film's code is there, so it is edited, not redone.
|
|
246
247
|
const note = ctx.state.notes[step.id]?.trim();
|
|
248
|
+
// A brand changed in the space since the film was made: the film's code carries the old one.
|
|
249
|
+
const brandNote = !brandChanged
|
|
250
|
+
? ""
|
|
251
|
+
: start === "init"
|
|
252
|
+
? "\n\nThe space's brand has changed since the film was made: brand/brand.json and brand/logos/ are new. Carry them into the film wherever it uses the brand (its own copies included), so every colour, logo and name is the new one, and check the frames for contrast."
|
|
253
|
+
: "\n\nThe space's brand has changed since the film was made: film/brand/brand.json and the logos are new. If film/brand/theme.json is missing, make it again as film/BRAND.md says. Make sure every colour, logo and name in the film is the new one, and check the frames for contrast.";
|
|
254
|
+
const size = FILM_SIZES[step.format];
|
|
247
255
|
const prompt = resume && note
|
|
248
|
-
? `The person watched the film and asks for this change:\n\n${note}\n\nChange the film in film/ accordingly — keep what they did not mention — check the frames again, and end with a short summary of what you changed.`
|
|
256
|
+
? `The person watched the film and asks for this change:\n\n${note}${brandNote}\n\nChange the film in film/ accordingly — keep what they did not mention — check the frames again, and end with a short summary of what you changed.`
|
|
249
257
|
: resume
|
|
250
|
-
?
|
|
251
|
-
:
|
|
258
|
+
? `Carry on with the film where you stopped. Read PROGRESS.md and the folder to see where that was, then finish it.${brandNote}`
|
|
259
|
+
: start === "from"
|
|
260
|
+
? `film/ holds this run's film in another format. Lay it out for ${step.format} (${size.width}×${size.height}), following CLAUDE.md: set the size of film/index.html, then make every scene fit — scenes, timing, words and sound stay. Check the frames, render a draft, and end with a short summary of what you changed.\n\nThe brief, for reference:\n\n${brief}`
|
|
261
|
+
: `Make the film BRIEF.md asks for, following CLAUDE.md.\n\n${brief}`;
|
|
252
262
|
const first = await turn(prompt, resume);
|
|
253
263
|
summary = typeof first.result === "string" ? first.result.trim() : "";
|
|
254
264
|
// The final render is ours: it does not depend on the client still running. What fails
|
|
@@ -277,6 +287,7 @@ export async function runFilmStep(step, ctx) {
|
|
|
277
287
|
finally {
|
|
278
288
|
bridge.close();
|
|
279
289
|
}
|
|
290
|
+
await keepBrandBase(root).catch(() => { });
|
|
280
291
|
const ref = await ctx.saveAsset({
|
|
281
292
|
stepId: step.id,
|
|
282
293
|
kind: "video",
|
|
@@ -11,6 +11,7 @@ import { CAPABILITY_CLASSES, creditsModelOf, isCreditsRef, PROVIDER_IDS, provide
|
|
|
11
11
|
import { note, saidText } from "@engenty-wizards/shared/run";
|
|
12
12
|
import { generateSpeech, generateText, } from "ai";
|
|
13
13
|
import { accountToken, linkedAccount } from "./auth/account.js";
|
|
14
|
+
import { ollamaDecisionModel, ollamaRoot } from "./decision-model.js";
|
|
14
15
|
import { DeviceModel, deviceThinks } from "./engine/device.js";
|
|
15
16
|
import { env } from "./env.js";
|
|
16
17
|
import { appleModel, appleStatus, appleTranscriptionModel, appleUnavailableNote, } from "./harness/apple.js";
|
|
@@ -652,10 +653,37 @@ export async function embeddingModel() {
|
|
|
652
653
|
? { model: gatewayClient(access, {}).embeddingModel("wizards/embedding"), ref: bound.model }
|
|
653
654
|
: null;
|
|
654
655
|
}
|
|
656
|
+
/** What the local Ollama held at the last look, so a decision does not ask it every time. */
|
|
657
|
+
let localDecision = null;
|
|
658
|
+
/** The decision model in the local Ollama (Clef-flash, pulled by the setup), looked up once a minute. */
|
|
659
|
+
async function localDecisionModel(url) {
|
|
660
|
+
if (localDecision?.url === url && Date.now() < localDecision.at) {
|
|
661
|
+
return localDecision.model;
|
|
662
|
+
}
|
|
663
|
+
const model = await ollamaDecisionModel(url);
|
|
664
|
+
localDecision = { url, model, at: Date.now() + 60_000 };
|
|
665
|
+
return model;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Ollama refused the model itself, not the question: a newer Ollama that wants it downloaded
|
|
669
|
+
* again, a model that was removed, one that does not fit into memory. Decisions take the next
|
|
670
|
+
* way for ten minutes, and the log says what Ollama says fixes it.
|
|
671
|
+
*/
|
|
672
|
+
function localModelRefused(url, status, body) {
|
|
673
|
+
const cannotRun = status === 404 ||
|
|
674
|
+
status >= 500 ||
|
|
675
|
+
/no longer supported|re-?download|ollama pull|not found/i.test(body);
|
|
676
|
+
if (!cannotRun) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
console.warn(`[decide] the local decision model cannot run, left out for 10 minutes: ${body}`);
|
|
680
|
+
localDecision = { url, model: null, at: Date.now() + 10 * 60_000 };
|
|
681
|
+
}
|
|
655
682
|
/**
|
|
656
|
-
* The way to
|
|
657
|
-
*
|
|
658
|
-
* key
|
|
683
|
+
* The way to a decision model, one that answers typed questions with probabilities and writes
|
|
684
|
+
* no text: the credits on a Manage-App's runtime; alone, TypeSafe's Jev through an AI Gateway
|
|
685
|
+
* key or a TypeSafe key, then Clef-flash in Ollama on this machine, then Jev on the linked
|
|
686
|
+
* account's credits. Null when there is none.
|
|
659
687
|
*/
|
|
660
688
|
export async function systemOneAccess() {
|
|
661
689
|
const cfg = await config();
|
|
@@ -687,6 +715,18 @@ export async function systemOneAccess() {
|
|
|
687
715
|
model: "jev-latest",
|
|
688
716
|
};
|
|
689
717
|
}
|
|
718
|
+
// Free, and nothing leaves the machine: before the credits.
|
|
719
|
+
const ollama = cfg.settings.ollamaUrl ?? env.ollamaUrl;
|
|
720
|
+
const local = await localDecisionModel(ollama);
|
|
721
|
+
if (local) {
|
|
722
|
+
return {
|
|
723
|
+
url: `${ollamaRoot(ollama)}/v1/systemone`,
|
|
724
|
+
headers: {},
|
|
725
|
+
model: local,
|
|
726
|
+
local: true,
|
|
727
|
+
refused: (status, body) => localModelRefused(ollama, status, body),
|
|
728
|
+
};
|
|
729
|
+
}
|
|
690
730
|
const access = await creditAccess(cfg, false).catch(() => null);
|
|
691
731
|
return access ? viaCredits(access) : null;
|
|
692
732
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FORMATS, isLang, LANG_CODE, LANGS, LIST_FORMATS, TEXT_CLASSES, wizardLang, } from "@engenty-wizards/shared/definition";
|
|
2
2
|
import { TableColumnValueError } from "@engenty-wizards/shared/engenty/data-tables";
|
|
3
|
-
import { noteText } from "@engenty-wizards/shared/run";
|
|
3
|
+
import { noteText, } from "@engenty-wizards/shared/run";
|
|
4
4
|
import { machineTranslated, translateDefinition, } from "@engenty-wizards/shared/translation";
|
|
5
5
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
6
6
|
import { and, eq } from "drizzle-orm";
|
|
@@ -220,6 +220,18 @@ async function publishedWizard(token) {
|
|
|
220
220
|
function wantsTranslation(w, def, lang) {
|
|
221
221
|
return w.translate && lang !== wizardLang(def);
|
|
222
222
|
}
|
|
223
|
+
/** What the wizard's pages ask, in order (`PublicWizard.fields`). */
|
|
224
|
+
export function pageFields(def) {
|
|
225
|
+
return def.steps.flatMap((step) => step.type === "page"
|
|
226
|
+
? step.fields.map((f) => ({
|
|
227
|
+
id: f.id,
|
|
228
|
+
label: f.label,
|
|
229
|
+
kind: f.kind,
|
|
230
|
+
...(f.options?.length ? { options: f.options } : {}),
|
|
231
|
+
...(f.required ? { required: true } : {}),
|
|
232
|
+
}))
|
|
233
|
+
: []);
|
|
234
|
+
}
|
|
223
235
|
/** What a wizard's page shows before a run: in the viewer's language where `as` is given. */
|
|
224
236
|
async function publicBody(c, w, original, as) {
|
|
225
237
|
const translated = as ? translateDefinition(original, as.memory) : null;
|
|
@@ -245,6 +257,7 @@ async function publicBody(c, w, original, as) {
|
|
|
245
257
|
machine: machineTranslated(as.memory, original),
|
|
246
258
|
}
|
|
247
259
|
: null,
|
|
260
|
+
fields: pageFields(def),
|
|
248
261
|
};
|
|
249
262
|
}
|
|
250
263
|
export const publicRoutes = new Hono()
|