@engenty/wizards-runtime 0.11.1 → 0.11.2
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/README.md +25 -6
- package/apps/runtime/dist/app.js +5 -0
- package/apps/runtime/dist/authoring/guide.js +19 -19
- package/apps/runtime/dist/docs/dev/index.md +1 -0
- package/apps/runtime/dist/docs/dev/licensing.md +60 -0
- package/apps/runtime/dist/docs/dev/meta.json +2 -1
- package/apps/runtime/dist/docs/dev/plugins/runners.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/index.md +4 -4
- package/apps/runtime/dist/docs/dev/wizard-format/meta.json +1 -1
- package/apps/runtime/dist/docs/dev/wizard-format/motion-graphics-steps.md +47 -0
- package/apps/runtime/dist/docs/dev/wizard-format/review-and-result.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +4 -4
- package/apps/runtime/dist/docs/user-guide/steps.md +12 -12
- package/apps/runtime/dist/engine/requirements.js +7 -7
- package/apps/runtime/dist/engine/runner.js +8 -1
- package/apps/runtime/dist/engine/steps.js +3 -3
- package/apps/runtime/dist/files/storage.js +3 -3
- package/apps/runtime/dist/index.js +3 -0
- package/apps/runtime/dist/limits.js +16 -0
- package/apps/runtime/dist/manage.js +19 -0
- package/apps/runtime/dist/models.js +8 -8
- package/apps/runtime/dist/{film → motion-graphics}/project.js +54 -54
- package/apps/runtime/dist/{film → motion-graphics}/sounds.js +3 -3
- package/apps/runtime/dist/{film → motion-graphics}/step.js +37 -37
- package/apps/runtime/dist/{film → motion-graphics}/tools.js +1 -1
- package/apps/runtime/dist/render/downloads.js +2 -2
- package/apps/runtime/dist/render/guard.js +1 -1
- package/apps/runtime/dist/routes/delivery.js +1 -1
- package/apps/runtime/dist/routes/internal.js +1 -1
- package/apps/runtime/dist/routes/marketplace.js +4 -3
- package/apps/runtime/dist/routes/reports.js +80 -0
- package/apps/runtime/dist/routes/runs.js +25 -1
- package/apps/runtime/dist/services/brand.js +1 -1
- package/apps/runtime/dist/services/manage-reports.js +190 -0
- package/apps/runtime/dist/services/marketplace.js +33 -1
- package/apps/runtime/dist/services/pages.js +1 -1
- package/apps/runtime/dist/services/shipped-fonts.js +2 -1
- package/apps/runtime/dist/services/wizards.js +7 -0
- package/apps/runtime/dist/widgets/render.js +9 -9
- package/apps/runtime/dist/widgets/runtime.js +3 -3
- package/apps/runtime/dist/widgets/step.js +20 -20
- package/apps/web/dist/assets/{AboutDialog-D2r8kBfV.js → AboutDialog-Bx6j5lZO.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-j7Z1YhNv.js → ChangelogDialog-C620Sw_A.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BTCMfVFJ.js → CodeEditor-DifBNaqQ.js} +1 -1
- package/apps/web/dist/assets/EditorPage-DWf9QG-U.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-BtVgtW7P.js → FlowPreview-ucwQ_dTr.js} +1 -1
- package/apps/web/dist/assets/{Harness-H4Ue1HOd.js → Harness-Br0Z_anI.js} +2 -2
- package/apps/web/dist/assets/Marketplace-CFDpVMWM.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-K1HOzkXf.js → NewWizardChannels-Cau6XSbl.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-CrFqInHR.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-BZk42_R7.js +1 -0
- package/apps/web/dist/assets/PreviewPane-D9n6tylf.js +10 -0
- package/apps/web/dist/assets/ProjectPage-CteRfxpz.js +1 -0
- package/apps/web/dist/assets/PublicRunner-CNanj6-w.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-Duk1YpNM.js → ReadOnly-DGBDtXFP.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-ClFQewEL.js +2 -0
- package/apps/web/dist/assets/SetupPage-k9gyFvow.js +1 -0
- package/apps/web/dist/assets/{SharePage-DvAUwrOl.js → SharePage-BhWeqF3w.js} +1 -1
- package/apps/web/dist/assets/changelog-BrhGlZT6.js +1 -0
- package/apps/web/dist/assets/{coins-DSvwvqtQ.js → coins-CwURUZyt.js} +1 -1
- package/apps/web/dist/assets/i18n-DEmaSTJV.js +55 -0
- package/apps/web/dist/assets/index-ClNm5JaU.js +34 -0
- package/apps/web/dist/assets/index-DImS12WR.css +1 -0
- package/apps/web/dist/assets/{oss-credits-BLVLXRzs.js → oss-credits-C6bPkfSE.js} +1 -1
- package/apps/web/dist/assets/{phone-xIUU1ZFn.js → phone-DTxGRwhK.js} +1 -1
- package/apps/web/dist/assets/runners-BMOIT6Ze.js +1 -0
- package/apps/web/dist/assets/{session-CbWzkHl0.js → session-xJpGiTU_.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-DoRItnPf.js → settings-menu-DcPFhgGA.js} +1 -1
- package/apps/web/dist/assets/theme-DTi1Zdw8.js +11 -0
- package/apps/web/dist/assets/{ui-6AgUKJhQ.js → ui-gsqxnFnT.js} +6 -6
- package/apps/web/dist/assets/{upload-C8WgcG1g.js → upload-BkwjFS-0.js} +1 -1
- package/apps/web/dist/assets/{useMutation-BdCg6qrc.js → useMutation-BS-U9g_a.js} +1 -1
- package/apps/web/dist/assets/{volume-2-jlgQapiz.js → volume-2-CYOgux-z.js} +1 -1
- package/apps/web/dist/assets/{wrench-Ca_TrBQk.js → wrench-DIfUvYPN.js} +1 -1
- package/apps/web/dist/index.html +9 -9
- package/apps/web/dist/mcp/flow.html +32 -32
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +11 -11
- package/node_modules/@engenty/wizards-shared/dist/definition.js +24 -23
- package/node_modules/@engenty/wizards-shared/dist/engenty/data-tables/columns-value.js +1 -0
- package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +7 -2
- package/node_modules/@engenty/wizards-shared/dist/fit.js +23 -6
- package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -7
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +7 -23
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +15 -14
- package/node_modules/@engenty/wizards-shared/dist/run.js +30 -28
- package/node_modules/@engenty/wizards-shared/dist/runners.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/runners.js +5 -5
- package/node_modules/@engenty/wizards-shared/dist/store.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/store.js +1 -2
- package/node_modules/@engenty/wizards-shared/dist/theme-look.d.ts +39 -0
- package/node_modules/@engenty/wizards-shared/dist/theme-look.js +112 -0
- package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +0 -38
- package/node_modules/@engenty/wizards-shared/dist/theme.js +1 -108
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +1 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +0 -47
- package/apps/web/dist/assets/EditorPage-mx6XuEIw.js +0 -3
- package/apps/web/dist/assets/Marketplace-YEZDpGm9.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-DSHVwwnU.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-CoBNtV_1.js +0 -1
- package/apps/web/dist/assets/PreviewPane-z0-Glj7p.js +0 -10
- package/apps/web/dist/assets/ProjectPage-DFaPSeda.js +0 -1
- package/apps/web/dist/assets/PublicRunner-DgT4CApp.js +0 -1
- package/apps/web/dist/assets/SettingsPage-FimvOhQq.js +0 -2
- package/apps/web/dist/assets/SetupPage-BxEMrMtA.js +0 -1
- package/apps/web/dist/assets/changelog-CS9GmnXd.js +0 -1
- package/apps/web/dist/assets/i18n-UTsgNY5M.js +0 -55
- package/apps/web/dist/assets/index-DHIXX69l.js +0 -20
- package/apps/web/dist/assets/index-Mt1sNdPx.css +0 -1
- package/apps/web/dist/assets/runners-CrSLA6HI.js +0 -1
- package/apps/web/dist/assets/theme-znovbShL.js +0 -11
- /package/apps/runtime/dist/{film → motion-graphics}/skills.js +0 -0
|
@@ -7,7 +7,7 @@ export const HTML_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-
|
|
|
7
7
|
/** The response header for a generated document opened on its own: an opaque origin, scripts allowed. */
|
|
8
8
|
export const HTML_RESPONSE_CSP = `sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox; ${HTML_CSP}`;
|
|
9
9
|
/**
|
|
10
|
-
* `media`: one more origin images, video and audio may come from — a
|
|
10
|
+
* `media`: one more origin images, video and audio may come from — a video's page gets this
|
|
11
11
|
* run's clips from the renderer that way; they are too large to inline.
|
|
12
12
|
*/
|
|
13
13
|
export function guardHtml(html, media) {
|
|
@@ -44,7 +44,7 @@ export function uploadMime(declared) {
|
|
|
44
44
|
? mime
|
|
45
45
|
: "application/octet-stream";
|
|
46
46
|
}
|
|
47
|
-
/** What a browser shows in place without running anything of the file's: photos, sound,
|
|
47
|
+
/** What a browser shows in place without running anything of the file's: photos, sound, video, PDFs. */
|
|
48
48
|
export function inlineSafe(mime) {
|
|
49
49
|
return ((/^(image|audio|video)\//.test(mime) && !mime.startsWith("image/svg")) ||
|
|
50
50
|
mime === "application/pdf");
|
|
@@ -62,7 +62,7 @@ export const internalRoutes = new Hono()
|
|
|
62
62
|
return c.json({ error: "bad tenant id" }, 400);
|
|
63
63
|
}
|
|
64
64
|
const { action } = z
|
|
65
|
-
.object({ action: z.enum(["suspend", "resume", "delete"]) })
|
|
65
|
+
.object({ action: z.enum(["suspend", "resume", "delete", "holds"]) })
|
|
66
66
|
.parse(await c.req.json());
|
|
67
67
|
forgetTenant(id);
|
|
68
68
|
if (action === "delete") {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CAPABILITY_IDS
|
|
1
|
+
import { CAPABILITY_IDS } from "@engenty/wizards-shared/fit";
|
|
2
|
+
import { INDUSTRY_IDS, ITEM_FORMAT_IDS, MARKETPLACE_PLAN_IDS, USE_CASE_IDS, } from "@engenty/wizards-shared/marketplace";
|
|
2
3
|
import { Hono } from "hono";
|
|
3
4
|
import { z } from "zod";
|
|
4
|
-
import { asLang, marketplaceDetail, searchMarketplace, searchMarketplaceAsGuest, starEntry, } from "../services/marketplace.js";
|
|
5
|
+
import { asLang, byLevel, marketplaceDetail, searchMarketplace, searchMarketplaceAsGuest, starEntry, } from "../services/marketplace.js";
|
|
5
6
|
import { notFoundAnswer } from "./lang.js";
|
|
6
7
|
const searchSchema = z.object({
|
|
7
8
|
q: z.string().trim().max(200).default(""),
|
|
@@ -22,7 +23,7 @@ const searchSchema = z.object({
|
|
|
22
23
|
export const marketplaceStudio = new Hono()
|
|
23
24
|
.get("/", async (c) => {
|
|
24
25
|
const { lang, ...search } = searchSchema.parse(c.req.query());
|
|
25
|
-
return c.json(await searchMarketplace({ ...search, lang: asLang(lang) }));
|
|
26
|
+
return c.json(await byLevel(await searchMarketplace({ ...search, lang: asLang(lang) }), search));
|
|
26
27
|
})
|
|
27
28
|
.get("/:id", async (c) => {
|
|
28
29
|
const detail = await marketplaceDetail(c.req.param("id"), asLang(c.req.query("lang")));
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { bodyLimit } from "hono/body-limit";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { principalOf } from "../auth/index.js";
|
|
6
|
+
import { db, schema, withTenant } from "../db/client.js";
|
|
7
|
+
import { allowed, hashIp } from "../limits.js";
|
|
8
|
+
import { managed, postBugReport } from "../manage.js";
|
|
9
|
+
import { tenantOfRun } from "../tenants/control.js";
|
|
10
|
+
import { clientIp } from "./runs.js";
|
|
11
|
+
/**
|
|
12
|
+
* "Report a problem" (docs/plans/wizards-admin.md in the Manage repository): what a person chose
|
|
13
|
+
* to send from the run page or the studio – their words, a screenshot with their marks, the
|
|
14
|
+
* error, the log lines – goes on to the Manage-App's bug reports. The dialog masked what was
|
|
15
|
+
* typed into the wizard before it left the browser. A runtime that runs alone has nobody to
|
|
16
|
+
* send it to: the report goes into its own log.
|
|
17
|
+
*/
|
|
18
|
+
const SCREENSHOT = /^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;
|
|
19
|
+
const line = (max) => z.string().trim().max(max);
|
|
20
|
+
export const bugReportBody = z.object({
|
|
21
|
+
where: z.enum(["run", "studio", "page"]),
|
|
22
|
+
url: z.string().url().max(2000),
|
|
23
|
+
runId: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^[A-Za-z0-9_-]{1,64}$/)
|
|
26
|
+
.nullable()
|
|
27
|
+
.optional(),
|
|
28
|
+
comment: line(4000).nullable().optional(),
|
|
29
|
+
error: z
|
|
30
|
+
.object({ message: line(2000), stack: line(8000).optional() })
|
|
31
|
+
.nullable()
|
|
32
|
+
.optional(),
|
|
33
|
+
logs: z.array(line(2000)).max(200).default([]),
|
|
34
|
+
screenshot: z.string().max(4_000_000).regex(SCREENSHOT).nullable().optional(),
|
|
35
|
+
contact: z.string().trim().email().max(200).nullable().optional(),
|
|
36
|
+
});
|
|
37
|
+
export const reportRoutes = new Hono().post("/bug-reports", bodyLimit({ maxSize: 4_500_000 }), async (c) => {
|
|
38
|
+
const ip = hashIp(clientIp(c));
|
|
39
|
+
if (!allowed(`bug:${ip ?? "?"}`, 10, 60 * 60 * 1000)) {
|
|
40
|
+
return c.json({ ok: false }, 429);
|
|
41
|
+
}
|
|
42
|
+
const parsed = bugReportBody.safeParse(await c.req.json().catch(() => null));
|
|
43
|
+
if (!parsed.success) {
|
|
44
|
+
return c.json({ ok: false, issues: parsed.error.issues.map((i) => i.path.join(".")) }, 400);
|
|
45
|
+
}
|
|
46
|
+
const body = parsed.data;
|
|
47
|
+
// The team and the wizard, as far as the run or the signed-in person tells them.
|
|
48
|
+
const who = await principalOf(c).catch(() => null);
|
|
49
|
+
let tenantId = who?.tenantId ?? null;
|
|
50
|
+
let wizardId = null;
|
|
51
|
+
if (body.runId) {
|
|
52
|
+
const runTenant = await tenantOfRun(body.runId);
|
|
53
|
+
if (runTenant && (!tenantId || tenantId === runTenant)) {
|
|
54
|
+
tenantId = runTenant;
|
|
55
|
+
const run = await withTenant(runTenant, () => db.query.run.findFirst({
|
|
56
|
+
where: eq(schema.run.id, body.runId),
|
|
57
|
+
columns: { wizardId: true },
|
|
58
|
+
}));
|
|
59
|
+
wizardId = run?.wizardId ?? null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const report = {
|
|
63
|
+
...body,
|
|
64
|
+
tenantId,
|
|
65
|
+
wizardId,
|
|
66
|
+
userAgent: c.req.header("user-agent")?.slice(0, 400) ?? null,
|
|
67
|
+
};
|
|
68
|
+
if (!managed) {
|
|
69
|
+
console.error(`[bug report ${tenantId ?? "visitor"}] at ${body.url}: ${body.comment ?? ""} ${body.error?.message ?? ""}`);
|
|
70
|
+
return c.json({ ok: true, sent: false });
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const { id } = await postBugReport(report);
|
|
74
|
+
return c.json({ ok: true, sent: true, id });
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.error("[bug report] not sent:", err.message);
|
|
78
|
+
return c.json({ ok: false }, 502);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -28,6 +28,7 @@ import { loadAsset, saveAsset } from "../files/storage.js";
|
|
|
28
28
|
import { checkUpload } from "../files/upload-check.js";
|
|
29
29
|
import { reverseGeocode } from "../geocode.js";
|
|
30
30
|
import { allowed, hashIp, verifyTurnstile, wizardUnavailable } from "../limits.js";
|
|
31
|
+
import { managed, postFeedback } from "../manage.js";
|
|
31
32
|
import { mintConversation } from "../media/conversation.js";
|
|
32
33
|
import { transcribeAudio } from "../media/transcribe.js";
|
|
33
34
|
import { errorText, ModelUnavailableError, noteOf } from "../model-errors.js";
|
|
@@ -1375,6 +1376,29 @@ export const runRoutes = new Hono()
|
|
|
1375
1376
|
}
|
|
1376
1377
|
await unshareRun(run);
|
|
1377
1378
|
return c.json({ ok: true });
|
|
1379
|
+
})
|
|
1380
|
+
// "How did it go?" at the end of a run: the answer goes on to the Manage-App's feedback.
|
|
1381
|
+
.post("/:id/feedback", async (c) => {
|
|
1382
|
+
const run = await accessibleRun(c, c.req.param("id"));
|
|
1383
|
+
if (!run) {
|
|
1384
|
+
return c.json(notFoundAnswer(c), 404);
|
|
1385
|
+
}
|
|
1386
|
+
if (run.status !== "done" && run.status !== "failed") {
|
|
1387
|
+
return c.json({ error: "The run is not over yet." }, 409);
|
|
1388
|
+
}
|
|
1389
|
+
const body = z
|
|
1390
|
+
.object({ good: z.boolean(), comment: z.string().trim().max(1000).optional() })
|
|
1391
|
+
.parse(await c.req.json());
|
|
1392
|
+
if (managed) {
|
|
1393
|
+
await postFeedback(run.tenantId, {
|
|
1394
|
+
runId: run.id,
|
|
1395
|
+
wizardId: run.wizardId,
|
|
1396
|
+
good: body.good,
|
|
1397
|
+
comment: body.comment || null,
|
|
1398
|
+
lang: run.lang ?? wizardLang(run.definition),
|
|
1399
|
+
}).catch((err) => console.warn(`[run ${run.id}] feedback not sent:`, err.message));
|
|
1400
|
+
}
|
|
1401
|
+
return c.json({ ok: true });
|
|
1378
1402
|
})
|
|
1379
1403
|
// --- sending the result on: by e-mail, into a folder, to a channel, onto a website ---------
|
|
1380
1404
|
.get("/:id/share/targets", async (c) => {
|
|
@@ -1526,7 +1550,7 @@ async function serveAsset(c, run, assetId) {
|
|
|
1526
1550
|
// A PDF is left to the browser's own viewer, which a sandbox would keep from starting.
|
|
1527
1551
|
...(mime === "application/pdf" ? {} : { "content-security-policy": "sandbox" }),
|
|
1528
1552
|
};
|
|
1529
|
-
// Foreign files are downloads, never pages of ours: only photos, sound,
|
|
1553
|
+
// Foreign files are downloads, never pages of ours: only photos, sound, video and PDFs show in place.
|
|
1530
1554
|
if (foreign && !inlineSafe(mime)) {
|
|
1531
1555
|
headers["content-disposition"] =
|
|
1532
1556
|
`attachment; filename="${found.row.name.replace(/["\\\r\n]/g, "")}"`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GRADIENT_TYPES, gradientCss, mainLogo, runTheme, } from "@engenty/wizards-shared/projects";
|
|
2
2
|
import { note } from "@engenty/wizards-shared/run";
|
|
3
|
-
import { chosenTheme, lookColours, themedLook } from "@engenty/wizards-shared/theme";
|
|
3
|
+
import { chosenTheme, lookColours, themedLook } from "@engenty/wizards-shared/theme-look";
|
|
4
4
|
import { generateText, Output } from "ai";
|
|
5
5
|
import { and, asc, eq } from "drizzle-orm";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { capabilitiesOf, effortOf } from "@engenty/wizards-shared/marketplace";
|
|
2
|
+
import { resultsOf } from "@engenty/wizards-shared/marketplace-entry";
|
|
3
|
+
import { and, eq, inArray } from "drizzle-orm";
|
|
4
|
+
import { db, knownTenants, schema, withTenant } from "../db/client.js";
|
|
5
|
+
import { env } from "../env.js";
|
|
6
|
+
import { managed, postRunReport, putWizards } from "../manage.js";
|
|
7
|
+
import { currentTenant } from "../tenants/tenant.js";
|
|
8
|
+
import { pageLangOf, pageSteps } from "./pages.js";
|
|
9
|
+
/**
|
|
10
|
+
* What the Manage-App's admin app learns of a team (docs/plans/wizards-admin.md in the Manage
|
|
11
|
+
* repository): its wizards, whole, after every change that shows there, and each run's turns.
|
|
12
|
+
* Manage never reads a tenant's database. Only a managed runtime reports.
|
|
13
|
+
*/
|
|
14
|
+
let last = Promise.resolve();
|
|
15
|
+
/** The team's wizards as the admin app lists them: the published version where there is one. */
|
|
16
|
+
export async function wizardsReport() {
|
|
17
|
+
const tenantId = currentTenant();
|
|
18
|
+
const [wizards, projects] = await Promise.all([
|
|
19
|
+
db.select().from(schema.wizard).where(eq(schema.wizard.tenantId, tenantId)),
|
|
20
|
+
db
|
|
21
|
+
.select({ id: schema.project.id, name: schema.project.name })
|
|
22
|
+
.from(schema.project)
|
|
23
|
+
.where(eq(schema.project.tenantId, tenantId)),
|
|
24
|
+
]);
|
|
25
|
+
const published = wizards.filter((w) => w.publishedVersion !== null);
|
|
26
|
+
const versions = published.length
|
|
27
|
+
? await db
|
|
28
|
+
.select({
|
|
29
|
+
wizardId: schema.wizardVersion.wizardId,
|
|
30
|
+
version: schema.wizardVersion.version,
|
|
31
|
+
definition: schema.wizardVersion.definition,
|
|
32
|
+
createdAt: schema.wizardVersion.createdAt,
|
|
33
|
+
})
|
|
34
|
+
.from(schema.wizardVersion)
|
|
35
|
+
.where(inArray(schema.wizardVersion.wizardId, published.map((w) => w.id)))
|
|
36
|
+
: [];
|
|
37
|
+
const spaces = new Map(projects.map((p) => [p.id, p.name]));
|
|
38
|
+
return {
|
|
39
|
+
wizards: wizards.map((w) => {
|
|
40
|
+
const live = versions.find((v) => v.wizardId === w.id && v.version === w.publishedVersion);
|
|
41
|
+
const def = live?.definition ?? w.draft;
|
|
42
|
+
return {
|
|
43
|
+
id: w.id,
|
|
44
|
+
title: (def.title || w.title).slice(0, 160),
|
|
45
|
+
description: (def.description ?? "").slice(0, 1000),
|
|
46
|
+
avatar: def.avatar ?? "round",
|
|
47
|
+
lang: (def.lang ?? "de").slice(0, 5),
|
|
48
|
+
space: spaces.has(w.projectId) ? { id: w.projectId, name: spaces.get(w.projectId) } : null,
|
|
49
|
+
published: Boolean(live),
|
|
50
|
+
publishedAt: live?.createdAt.toISOString() ?? null,
|
|
51
|
+
template: w.starter ? { id: w.starter, revision: w.starterRevision ?? null } : null,
|
|
52
|
+
runUrl: live && w.shareEnabled ? `${env.publicUrl}/w/${w.shareToken}` : null,
|
|
53
|
+
effort: effortSent(def),
|
|
54
|
+
results: [...new Set(resultsOf(def).map((r) => r.kind))],
|
|
55
|
+
// The overview the admin app shows: the intro, the way through as the page's teaser
|
|
56
|
+
// draws it (about five rows), and each result with its kind and files.
|
|
57
|
+
intro: (def.intro ?? "").slice(0, 1000),
|
|
58
|
+
outline: pageSteps(def, pageLangOf(def, "en")),
|
|
59
|
+
deliverables: resultsOf(def).slice(0, 12),
|
|
60
|
+
capabilities: capabilitiesOf(def),
|
|
61
|
+
steps: def.steps.length,
|
|
62
|
+
changedAt: w.updatedAt.toISOString(),
|
|
63
|
+
};
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Fields whose answer is a file the person brings. */
|
|
68
|
+
const UPLOAD_KINDS = new Set(["file", "image", "audio"]);
|
|
69
|
+
/** What a run asks of the person: fields, drafts to check, minutes, and whether files come along. */
|
|
70
|
+
function effortSent(def) {
|
|
71
|
+
const effort = effortOf(def);
|
|
72
|
+
return {
|
|
73
|
+
fields: effort.fields,
|
|
74
|
+
reviews: effort.reviews,
|
|
75
|
+
minutes: effort.minutes,
|
|
76
|
+
uploads: def.steps.some((s) => s.type === "page" && s.fields.some((f) => UPLOAD_KINDS.has(f.kind))),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Sends the team's wizards; one send after the other, a failure is only written down. */
|
|
80
|
+
export function pushWizards() {
|
|
81
|
+
if (!managed) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const tenantId = currentTenant();
|
|
85
|
+
const send = async () => {
|
|
86
|
+
await putWizards(tenantId, await withTenant(tenantId, () => wizardsReport()));
|
|
87
|
+
};
|
|
88
|
+
last = last.then(send, send).catch((err) => {
|
|
89
|
+
console.error("[reports] the wizards were not sent:", err.message);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export function wizardsSettled() {
|
|
93
|
+
return last;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Every team's wizards once, at the start: what changed while no report went out, and the wizards
|
|
97
|
+
* of teams from before this report existed. One team after the other.
|
|
98
|
+
*/
|
|
99
|
+
export async function reportAllWizards() {
|
|
100
|
+
if (!managed) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const tenantId of await knownTenants()) {
|
|
104
|
+
await withTenant(tenantId, async () => {
|
|
105
|
+
pushWizards();
|
|
106
|
+
await wizardsSettled();
|
|
107
|
+
}).catch((err) => console.warn(`[reports] ${tenantId}:`, err.message));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const STATE = {
|
|
111
|
+
waiting_input: "waiting",
|
|
112
|
+
running: "running",
|
|
113
|
+
done: "finished",
|
|
114
|
+
failed: "failed",
|
|
115
|
+
cancelled: "cancelled",
|
|
116
|
+
};
|
|
117
|
+
/** A run at work says so again after this long, so the admin app can tell it from a stuck one. */
|
|
118
|
+
const AGAIN_MS = 2 * 60_000;
|
|
119
|
+
const said = new Map();
|
|
120
|
+
const OWN_CLIENTS = new Set(["web", "app"]);
|
|
121
|
+
/** Where the run came from, as the admin app sorts it. */
|
|
122
|
+
function viaOf(run) {
|
|
123
|
+
if (run.mode === "test") {
|
|
124
|
+
return "test";
|
|
125
|
+
}
|
|
126
|
+
// The run page names itself `web`, the mobile app `app`: any other client is the public API's.
|
|
127
|
+
if (run.client && !OWN_CLIENTS.has(run.client)) {
|
|
128
|
+
return "api";
|
|
129
|
+
}
|
|
130
|
+
if (run.origin) {
|
|
131
|
+
return "page";
|
|
132
|
+
}
|
|
133
|
+
return run.userId ? "studio" : "link";
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Tells the admin app of a run's turn: a new state at once, the same state again only after a
|
|
137
|
+
* while (a long step at work is not stuck). Runs in the current tenant's context.
|
|
138
|
+
*/
|
|
139
|
+
export function reportRun(runId, status) {
|
|
140
|
+
if (!managed) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const state = STATE[status];
|
|
144
|
+
const before = said.get(runId);
|
|
145
|
+
if (before && before.state === state && Date.now() - before.at < AGAIN_MS) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
said.set(runId, { state, at: Date.now() });
|
|
149
|
+
if (state === "finished" || state === "failed" || state === "cancelled") {
|
|
150
|
+
// A run that ended says nothing more; the map forgets it.
|
|
151
|
+
setTimeout(() => said.delete(runId), AGAIN_MS).unref?.();
|
|
152
|
+
}
|
|
153
|
+
const tenantId = currentTenant();
|
|
154
|
+
void (async () => {
|
|
155
|
+
const run = await db.query.run.findFirst({
|
|
156
|
+
where: and(eq(schema.run.id, runId), eq(schema.run.tenantId, tenantId)),
|
|
157
|
+
columns: {
|
|
158
|
+
wizardId: true,
|
|
159
|
+
mode: true,
|
|
160
|
+
client: true,
|
|
161
|
+
origin: true,
|
|
162
|
+
userId: true,
|
|
163
|
+
cursor: true,
|
|
164
|
+
error: true,
|
|
165
|
+
definition: true,
|
|
166
|
+
createdAt: true,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
if (!run) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const step = state === "failed" && run.cursor
|
|
173
|
+
? run.definition.steps.find((s) => s.id === run.cursor)
|
|
174
|
+
: undefined;
|
|
175
|
+
await postRunReport(tenantId, {
|
|
176
|
+
runId,
|
|
177
|
+
wizardId: run.wizardId,
|
|
178
|
+
via: viaOf(run),
|
|
179
|
+
state,
|
|
180
|
+
startedAt: run.createdAt.toISOString(),
|
|
181
|
+
at: new Date().toISOString(),
|
|
182
|
+
...(step
|
|
183
|
+
? { step: { id: step.id, title: (step.title ?? step.id).slice(0, 160), kind: step.type } }
|
|
184
|
+
: {}),
|
|
185
|
+
...(state === "failed" && run.error ? { error: run.error.slice(0, 2000) } : {}),
|
|
186
|
+
});
|
|
187
|
+
})().catch((err) => {
|
|
188
|
+
console.warn(`[reports] run ${runId}:`, err.message);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
@@ -10,7 +10,7 @@ import { formulaEstimate } from "../credits/estimate.js";
|
|
|
10
10
|
import { control, controlDb, db, schema, withTenant } from "../db/client.js";
|
|
11
11
|
import { missingCapabilities, optionalCapabilities, stepsWithoutModel, } from "../engine/requirements.js";
|
|
12
12
|
import { env } from "../env.js";
|
|
13
|
-
import { managed } from "../manage.js";
|
|
13
|
+
import { managed, tenantInfo } from "../manage.js";
|
|
14
14
|
import { classCatalog, imageCostUsd, tokenCostUsd, videoCostUsd, WEB_SEARCH_COST_USD, } from "../models.js";
|
|
15
15
|
import { pluginIdsOf, pluginStartersOf } from "../plugins/registry.js";
|
|
16
16
|
import { readSetting, writeSetting } from "../settings.js";
|
|
@@ -219,6 +219,38 @@ async function keptOptional(ids, lang, unavailable) {
|
|
|
219
219
|
}
|
|
220
220
|
return out;
|
|
221
221
|
}
|
|
222
|
+
/** The team's level: the Manage-App's word on a managed runtime; elsewhere every level is open. */
|
|
223
|
+
async function teamLevel() {
|
|
224
|
+
if (!managed) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const info = await tenantInfo(currentTenant()).catch(() => null);
|
|
228
|
+
return info?.level ?? null;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The catalog as the team's level leaves it (docs/plans/wizards-admin.md in the Manage
|
|
232
|
+
* repository): a template above the level is not shown, the featured ones come first – those of
|
|
233
|
+
* the team's own level before the rest – and the answer says the level.
|
|
234
|
+
*/
|
|
235
|
+
export async function byLevel(page, opts) {
|
|
236
|
+
const level = await teamLevel();
|
|
237
|
+
const top = level?.level ?? Number.POSITIVE_INFINITY;
|
|
238
|
+
const shown = page.entries.filter((e) => (e.level ?? 1) <= top);
|
|
239
|
+
// A search keeps its order: the words found what fits best.
|
|
240
|
+
const rank = (e) => e.featured ? ((e.level ?? 1) === level?.level ? 0 : 1) : 2;
|
|
241
|
+
const entries = opts.q?.trim()
|
|
242
|
+
? shown
|
|
243
|
+
: shown
|
|
244
|
+
.map((e, i) => ({ e, i }))
|
|
245
|
+
.sort((a, b) => rank(a.e) - rank(b.e) || a.i - b.i)
|
|
246
|
+
.map((x) => x.e);
|
|
247
|
+
return {
|
|
248
|
+
...page,
|
|
249
|
+
entries,
|
|
250
|
+
total: Math.max(0, page.total - (page.entries.length - shown.length)),
|
|
251
|
+
level,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
222
254
|
/**
|
|
223
255
|
* Searches the tenant's plugins' starters and the marketplace, in that order: a page holds the
|
|
224
256
|
* plugins' starters the words and filters find, then the marketplace's entries.
|
|
@@ -16,7 +16,7 @@ const UPLOAD_KINDS = new Set(["file", "image", "audio"]);
|
|
|
16
16
|
/** Facts that name who stands behind the page, by key. */
|
|
17
17
|
const NAME_KEYS = ["name", "firma", "unternehmen", "company", "firmenname", "kanzlei"];
|
|
18
18
|
/** A wizard's language where the page knows it, else the page's. */
|
|
19
|
-
function pageLangOf(def, fallback) {
|
|
19
|
+
export function pageLangOf(def, fallback) {
|
|
20
20
|
const lang = langOf(wizardLang(def));
|
|
21
21
|
return lang === "de" || lang === "en" ? lang : fallback;
|
|
22
22
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
-
import { SHIPPED_FONTS
|
|
4
|
+
import { SHIPPED_FONTS } from "@engenty/wizards-shared/theme";
|
|
5
|
+
import { shippedFontSlug } from "@engenty/wizards-shared/theme-look";
|
|
5
6
|
/**
|
|
6
7
|
* The fonts the runner ships (SHIPPED_FONTS), served for pages that are not the runtime's own: a
|
|
7
8
|
* host's OpenUI chat loads a theme's font from here. Each comes from its Fontsource package as
|
|
@@ -17,6 +17,7 @@ import { changedSteps, emitDraftChanged } from "./draft-events.js";
|
|
|
17
17
|
import { notFound, ServiceError } from "./errors.js";
|
|
18
18
|
import { copyFiles, draftFiles, sameFiles, seedFiles } from "./files.js";
|
|
19
19
|
import { forgetWizardLinks } from "./links.js";
|
|
20
|
+
import { pushWizards } from "./manage-reports.js";
|
|
20
21
|
import { asLang, countInstall, marketplaceWizard } from "./marketplace.js";
|
|
21
22
|
import { pushPages } from "./pages.js";
|
|
22
23
|
import { defaultProject, ownedProject } from "./projects.js";
|
|
@@ -271,6 +272,7 @@ export async function createWizard(userId, input, writer = { source: "studio" })
|
|
|
271
272
|
starterRevision: fromStarter?.revision ?? null,
|
|
272
273
|
});
|
|
273
274
|
await putLink(shareToken, "wizard", id);
|
|
275
|
+
pushWizards();
|
|
274
276
|
if (fromStarter) {
|
|
275
277
|
await seedFiles(id, fromStarter.files);
|
|
276
278
|
// Counted at the marketplace, beside the request; a plugin's starter is not the marketplace's.
|
|
@@ -367,6 +369,7 @@ export async function updateWizardSettings(userId, wizardId, patch) {
|
|
|
367
369
|
// Switched off, the wizard leaves the organization's public page; on, it may return to it.
|
|
368
370
|
if (patch.shareEnabled !== undefined && patch.shareEnabled !== w.shareEnabled) {
|
|
369
371
|
pushPages();
|
|
372
|
+
pushWizards();
|
|
370
373
|
}
|
|
371
374
|
return wizardSummary(await ownedWizard(userId, wizardId));
|
|
372
375
|
}
|
|
@@ -381,6 +384,7 @@ export async function rotateShareLink(userId, wizardId) {
|
|
|
381
384
|
await putLink(token, "wizard", w.id);
|
|
382
385
|
// The public page's start button leads to the new link.
|
|
383
386
|
pushPages();
|
|
387
|
+
pushWizards();
|
|
384
388
|
return { shareToken: token, shareUrl: shareUrl(token) };
|
|
385
389
|
}
|
|
386
390
|
export async function duplicateWizard(userId, wizardId) {
|
|
@@ -401,6 +405,7 @@ export async function duplicateWizard(userId, wizardId) {
|
|
|
401
405
|
});
|
|
402
406
|
await putLink(shareToken, "wizard", id);
|
|
403
407
|
await copyFiles(w.id, id);
|
|
408
|
+
pushWizards();
|
|
404
409
|
return { id };
|
|
405
410
|
}
|
|
406
411
|
export async function deleteWizard(userId, wizardId) {
|
|
@@ -411,6 +416,7 @@ export async function deleteWizard(userId, wizardId) {
|
|
|
411
416
|
.delete(schema.wizard)
|
|
412
417
|
.where(and(eq(schema.wizard.id, wizardId), eq(schema.wizard.tenantId, currentTenant())));
|
|
413
418
|
await unlistWizard(w.projectId, wizardId);
|
|
419
|
+
pushWizards();
|
|
414
420
|
}
|
|
415
421
|
/** A wizard that is gone leaves its space's public page, which is sent again without it. */
|
|
416
422
|
async function unlistWizard(projectId, wizardId) {
|
|
@@ -453,5 +459,6 @@ export async function publishWizard(userId, wizardId) {
|
|
|
453
459
|
.where(eq(schema.wizard.id, w.id));
|
|
454
460
|
// The organization's public page shows the new version's title, results and steps.
|
|
455
461
|
pushPages();
|
|
462
|
+
pushWizards();
|
|
456
463
|
return { version, shareUrl: shareUrl(w.shareToken), shareEnabled: w.shareEnabled };
|
|
457
464
|
}
|
|
@@ -43,7 +43,7 @@ async function timelineOf(page) {
|
|
|
43
43
|
}
|
|
44
44
|
async function seek(page, seconds) {
|
|
45
45
|
await page.evaluate(async (t) => {
|
|
46
|
-
// A
|
|
46
|
+
// A video's seek waits for its clips to reach the frame; a drawn animation returns at once.
|
|
47
47
|
await window.wizard.__timeline().seek(t);
|
|
48
48
|
await new Promise((r) => requestAnimationFrame(() => r(null)));
|
|
49
49
|
}, seconds);
|
|
@@ -151,17 +151,17 @@ export async function widgetMp4(html, size) {
|
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
// ---
|
|
155
|
-
/** Where a
|
|
156
|
-
export const
|
|
157
|
-
/** A
|
|
154
|
+
// --- videos: a timeline of clips and stills, with sound ---------------------------------
|
|
155
|
+
/** Where a video's page finds this run's clips, images and voice-over while it is rendered. */
|
|
156
|
+
export const MOTION_MEDIA_ORIGIN = "http://wizard.media";
|
|
157
|
+
/** A video names at most this many sound tracks: voice-over, music, and every cut of a recording. */
|
|
158
158
|
const MAX_TRACKS = 48;
|
|
159
159
|
/**
|
|
160
|
-
* Renders a
|
|
160
|
+
* Renders a video widget: its page draws every frame from this run's clips and images, and names
|
|
161
161
|
* the sound that belongs to it (voice-over, the clips' own sound). Clips are re-encoded with a
|
|
162
162
|
* key frame every few frames first, so the page reaches any frame quickly and exactly.
|
|
163
163
|
*/
|
|
164
|
-
export async function
|
|
164
|
+
export async function renderMotion(html, size, media, onProgress) {
|
|
165
165
|
if (!(await hasFfmpeg())) {
|
|
166
166
|
return null;
|
|
167
167
|
}
|
|
@@ -231,7 +231,7 @@ export async function renderFilm(html, size, media, onProgress) {
|
|
|
231
231
|
const page = await context.newPage();
|
|
232
232
|
page.on("pageerror", (err) => errors.push(err.message));
|
|
233
233
|
await page.setContent(forExport(html), { waitUntil: "load", timeout: 30_000 });
|
|
234
|
-
// A
|
|
234
|
+
// A video is ready once its clips are loaded; that takes longer than a drawn widget.
|
|
235
235
|
await page.evaluate(() => Promise.race([window.wizard?.__ready, new Promise((r) => setTimeout(r, 45_000))]));
|
|
236
236
|
const timeline = await page.evaluate(() => {
|
|
237
237
|
const t = window.wizard?.__timeline?.();
|
|
@@ -270,7 +270,7 @@ export async function renderFilm(html, size, media, onProgress) {
|
|
|
270
270
|
}
|
|
271
271
|
let out = silent;
|
|
272
272
|
if (tracks.length) {
|
|
273
|
-
const mixed = join(dir, "
|
|
273
|
+
const mixed = join(dir, "video.mp4");
|
|
274
274
|
const chains = tracks.map((track, i) => {
|
|
275
275
|
const length = Math.min(track.duration ?? seconds, seconds - track.start);
|
|
276
276
|
const volume = Math.max(0, Math.min(2, track.volume ?? 1));
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* wizard.save(state) keeps `state` with the run (small JSON); the next visit reads it
|
|
11
11
|
* wizard.share(text) hands text to the device's share sheet (or copies it)
|
|
12
12
|
* wizard.ai "generated" | "edited" when the run's media in `data` was made or
|
|
13
|
-
* changed by a model, else null — a
|
|
13
|
+
* changed by a model, else null — a video labels itself with it
|
|
14
14
|
* wizard.mode "view" in the browser, "export" while a PNG/PDF/MP4 is rendered
|
|
15
15
|
* wizard.file(path) text of a workspace file (JSON, CSV, SVG, …)
|
|
16
16
|
* wizard.json(path) a workspace JSON file, parsed
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
* wizard.timeline({ duration, seek, poster?, audio? })
|
|
20
20
|
* an animation of `duration` seconds; seek(t) must draw time t —
|
|
21
21
|
* synchronously, or as a promise that resolves once it is drawn (a
|
|
22
|
-
*
|
|
23
|
-
* second the PNG/PDF show (default 0). A
|
|
22
|
+
* video waits for its clips). Enables the MP4 export; `poster` is the
|
|
23
|
+
* second the PNG/PDF show (default 0). A video names its sound in
|
|
24
24
|
* `audio`: [{ src, start, duration?, from?, volume? }] — `from` is the
|
|
25
25
|
* second of the source a cut plays from.
|
|
26
26
|
*/
|