@engenty/wizards-runtime 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/agents/studio-assistant.js +42 -5
- package/apps/runtime/dist/app.js +15 -4
- package/apps/runtime/dist/credits/estimate.js +3 -3
- package/apps/runtime/dist/db/live-triggers.js +13 -3
- package/apps/runtime/dist/db/migrations/tenant/0027_space_skill.sql +48 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +4120 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +31 -0
- package/apps/runtime/dist/docs/dev/skills.md +116 -0
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +20 -2
- package/apps/runtime/dist/docs/user-guide/models.md +105 -30
- package/apps/runtime/dist/docs/user-guide/skills.md +85 -0
- package/apps/runtime/dist/docs/user-guide/together.md +15 -2
- package/apps/runtime/dist/engine/decide.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +139 -11
- package/apps/runtime/dist/engine/runner.js +47 -5
- package/apps/runtime/dist/engine/steps.js +23 -6
- package/apps/runtime/dist/engine/template.js +17 -0
- package/apps/runtime/dist/harness/model.js +4 -0
- package/apps/runtime/dist/link-preview.js +9 -0
- package/apps/runtime/dist/live/views.js +2 -0
- package/apps/runtime/dist/manage.js +25 -0
- package/apps/runtime/dist/mcp/handler.js +55 -1
- package/apps/runtime/dist/mcp/seen.js +47 -0
- package/apps/runtime/dist/models.js +206 -11
- package/apps/runtime/dist/motion-graphics/step.js +2 -2
- package/apps/runtime/dist/prompts/goose.md +15 -7
- package/apps/runtime/dist/prompts/safety.md +18 -0
- package/apps/runtime/dist/prompts/step.md +20 -2
- package/apps/runtime/dist/prompts/tools.md +33 -0
- package/apps/runtime/dist/routes/marketplace.js +3 -3
- package/apps/runtime/dist/routes/runs.js +5 -0
- package/apps/runtime/dist/routes/skills.js +84 -0
- package/apps/runtime/dist/routes/studio.js +103 -4
- package/apps/runtime/dist/safety.js +60 -18
- package/apps/runtime/dist/services/manage-reports.js +3 -0
- package/apps/runtime/dist/services/marketplace.js +7 -31
- package/apps/runtime/dist/services/pages.js +6 -2
- package/apps/runtime/dist/services/shares.js +5 -0
- package/apps/runtime/dist/services/skills-registry.js +209 -0
- package/apps/runtime/dist/services/skills.js +478 -0
- package/apps/runtime/dist/services/spaces.js +15 -1
- package/apps/runtime/dist/sync/records.js +81 -1
- package/apps/runtime/dist/texts.js +45 -0
- package/apps/runtime/dist/tools/index.js +7 -4
- package/apps/runtime/dist/tools/net-guard.js +8 -4
- package/apps/runtime/dist/tools/skills.js +197 -0
- package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-BWaEdlt3.js → ChangelogDialog-SwyId00t.js} +1 -1
- package/apps/web/dist/assets/CodeEditor-BwZsk5Al.js +2 -0
- package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-DXpzFBRj.js → FlowPreview-DtSpjVTl.js} +1 -1
- package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-B5wuTm7J.js → NewWizardChannels-Tgoexgj4.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-B24AF482.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +1 -0
- package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +10 -0
- package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +10 -0
- package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-Cap_e5ke.js → ReadOnly-BXjv-MSv.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +2 -0
- package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +1 -0
- package/apps/web/dist/assets/{SharePage-DEeVGatD.js → SharePage-DXGzJSnR.js} +1 -1
- package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +1 -0
- package/apps/web/dist/assets/changelog-BLdS-0Bj.js +1 -0
- package/apps/web/dist/assets/code-xml-TwKzzMtA.js +1 -0
- package/apps/web/dist/assets/{dist-BwhPmMDu.js → dist-BdDd1FxP.js} +1 -1
- package/apps/web/dist/assets/dist-EBVTpvRr.js +10 -0
- package/apps/web/dist/assets/dist-GlRRx9Xl.js +1 -0
- package/apps/web/dist/assets/dist-H1UN89OA.js +1 -0
- package/apps/web/dist/assets/eye-Brd-xPUJ.js +1 -0
- package/apps/web/dist/assets/i18n-8-Sw11tB.js +55 -0
- package/apps/web/dist/assets/index-OsdQFHmh.js +49 -0
- package/apps/web/dist/assets/index-QPipX5Fi.css +1 -0
- package/apps/web/dist/assets/json-CEsfHdlZ.js +1 -0
- package/apps/web/dist/assets/{lock-D-CjMpqn.js → lock-C0uxcOlq.js} +1 -1
- package/apps/web/dist/assets/markdown-5-I9_izp.js +29 -0
- package/apps/web/dist/assets/{oss-credits-CUpVhKSr.js → oss-credits-DpRWUPjD.js} +1 -1
- package/apps/web/dist/assets/{phone-CXSrxw3H.js → phone-DhkHteoJ.js} +1 -1
- package/apps/web/dist/assets/{runners-D71NjXtA.js → runners-G-XYaDgR.js} +1 -1
- package/apps/web/dist/assets/{session-B2LtqeDq.js → session-BWI-KENJ.js} +1 -1
- package/apps/web/dist/assets/theme-D7krsx0_.js +11 -0
- package/apps/web/dist/assets/ui-DSXG3f49.js +83 -0
- package/apps/web/dist/assets/{upload-hLkuT3Q6.js → upload-BYZTwJTD.js} +1 -1
- package/apps/web/dist/assets/{useMutation-C3XBoSVf.js → useMutation-D0QP_k2-.js} +1 -1
- package/apps/web/dist/assets/{volume-2-DIxdTlaA.js → volume-2-CVHoxdGM.js} +1 -1
- package/apps/web/dist/index.html +9 -8
- package/apps/web/dist/mcp/flow.html +66 -66
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +3 -2
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +1 -0
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +5 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +107 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.js +67 -4
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +18 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +18 -0
- package/node_modules/@engenty/wizards-shared/dist/live.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +0 -5
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +62 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +52 -0
- package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +165 -0
- package/node_modules/@engenty/wizards-shared/dist/skills.js +346 -0
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +4 -2
- package/node_modules/@engenty/wizards-shared/dist/sync.js +2 -1
- package/node_modules/@engenty/wizards-shared/dist/tiers.d.ts +195 -0
- package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
- package/package.json +7 -7
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/AboutDialog-uGYGy2R2.js +0 -1
- package/apps/web/dist/assets/CodeEditor-B5hV1IvK.js +0 -2
- package/apps/web/dist/assets/EditorPage-j9BOx5-V.js +0 -3
- package/apps/web/dist/assets/Marketplace-DSo6uZF6.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-Ci1ZsTJk.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-QkdluEZk.js +0 -1
- package/apps/web/dist/assets/PreviewPane-swAH89un.js +0 -10
- package/apps/web/dist/assets/ProjectPage-Djv5EOYU.js +0 -1
- package/apps/web/dist/assets/PublicRunner-Bt8gMxit.js +0 -1
- package/apps/web/dist/assets/SettingsPage-C2rmXm_Q.js +0 -2
- package/apps/web/dist/assets/SetupPage-CbqGgFPZ.js +0 -1
- package/apps/web/dist/assets/changelog-DAY6ZEyy.js +0 -1
- package/apps/web/dist/assets/dist-DVpDdhG9.js +0 -1
- package/apps/web/dist/assets/dist-DzdNG7Sf.js +0 -10
- package/apps/web/dist/assets/i18n-B3J2ypKu.js +0 -55
- package/apps/web/dist/assets/index-Dxwbli0m.css +0 -1
- package/apps/web/dist/assets/index-WY5lJ_-h.js +0 -49
- package/apps/web/dist/assets/json-D2GVvTXK.js +0 -1
- package/apps/web/dist/assets/markdown-DwdMW7q0.js +0 -29
- package/apps/web/dist/assets/theme-Dab079EV.js +0 -11
- package/apps/web/dist/assets/ui-DQX_CQ7c.js +0 -83
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
2
|
+
import { textClassOf } from "@engenty/wizards-shared/definition";
|
|
2
3
|
import { cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, factKey, gradientCss, PROJECT_FILE_KINDS, PROJECT_LIMITS, parseGradient, RULE_MARKS, textStyleLine, } from "@engenty/wizards-shared/projects";
|
|
4
|
+
import { pickedClass } from "@engenty/wizards-shared/tiers";
|
|
3
5
|
import { createTool } from "@mastra/core/tools";
|
|
4
6
|
import { nanoid } from "nanoid";
|
|
5
7
|
import { z } from "zod";
|
|
6
8
|
import { knowsTools } from "../assistant/knows.js";
|
|
7
9
|
import { currentFeatures } from "../features.js";
|
|
8
10
|
import { managed } from "../manage.js";
|
|
9
|
-
import { chatModel, contextWindowOf, costOf, gatewayTools, totalUsage, usageOf, } from "../models.js";
|
|
11
|
+
import { chatModel, contextWindowOf, costOf, currentTier, gatewayTools, searchAllowed, textModel, totalUsage, usageOf, } from "../models.js";
|
|
10
12
|
import { prompt } from "../prompts.js";
|
|
11
13
|
import { contentPolicy } from "../safety.js";
|
|
12
14
|
import { knowledgeCounts } from "../services/knowledge.js";
|
|
13
15
|
import { addProjectFileFromUrl, projectFileContent, projectFiles, updateProjectFile, } from "../services/project-files.js";
|
|
14
16
|
import { documentText } from "../services/project-index.js";
|
|
15
17
|
import { ownedProject, updateProject } from "../services/projects.js";
|
|
18
|
+
import { activeSkills, skillList } from "../services/skills.js";
|
|
16
19
|
import { categoryRows } from "../services/space-categories.js";
|
|
17
20
|
import { currentTenant } from "../tenants/tenant.js";
|
|
18
21
|
import { serverText } from "../texts.js";
|
|
19
22
|
import { assistantPageOf, assistantToolsOf } from "../tools/plugin.js";
|
|
20
23
|
import { attempt as attemptTool, imageOutput } from "../tools/shared.js";
|
|
24
|
+
import { skillToolsOf } from "../tools/skills.js";
|
|
21
25
|
import { spaceAgent } from "./space-agent.js";
|
|
22
26
|
import { chatTurnWay } from "./subscription.js";
|
|
23
27
|
import { readWebsite } from "./website.js";
|
|
@@ -633,7 +637,7 @@ function traced(tools, input, record) {
|
|
|
633
637
|
}
|
|
634
638
|
/** The part of the space page a route stands on. */
|
|
635
639
|
function partOf(route) {
|
|
636
|
-
const m = route.match(/^\/space\/(info|brand|knowledge|data|results)/);
|
|
640
|
+
const m = route.match(/^\/space\/(info|brand|knowledge|data|results|skills)/);
|
|
637
641
|
return m ? m[1] : route === "/space" ? "info" : null;
|
|
638
642
|
}
|
|
639
643
|
/** How large each tool is in the prompt: its description and its schema, in characters. */
|
|
@@ -651,6 +655,23 @@ function toolSizes(tools) {
|
|
|
651
655
|
})
|
|
652
656
|
.sort((a, b) => b.chars - a.chars);
|
|
653
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* The model of a turn: the tier's class the person picked, on the credits, where the organization
|
|
660
|
+
* has a tier; else the chat's way, with its more capable model for extra effort.
|
|
661
|
+
*/
|
|
662
|
+
async function assistantModel(way, input) {
|
|
663
|
+
const tier = input.model && way === "models" ? await currentTier() : null;
|
|
664
|
+
// A model id picked in the chooser asks for the class it runs on; anything else is no pick.
|
|
665
|
+
const picked = tier && input.model ? pickedClass(tier, input.model) : null;
|
|
666
|
+
if (!picked) {
|
|
667
|
+
return chatModel(way, input.extra ? "high" : "standard");
|
|
668
|
+
}
|
|
669
|
+
return textModel(textClassOf(picked.cls), {
|
|
670
|
+
purpose: "assistant",
|
|
671
|
+
makerClass: picked.maker ? `${picked.maker}/${picked.cls}` : undefined,
|
|
672
|
+
effort: input.extra ? "high" : undefined,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
654
675
|
/** One turn of the studio assistant. */
|
|
655
676
|
export async function runStudioAssistant(input) {
|
|
656
677
|
// How often the space or a plugin's data changed: a part of the answer changed something when
|
|
@@ -658,7 +679,7 @@ export async function runStudioAssistant(input) {
|
|
|
658
679
|
let changes = 0;
|
|
659
680
|
// The way the settings chose for the studio's chats: on a client, its tools reach it over MCP.
|
|
660
681
|
const way = await chatTurnWay(managed);
|
|
661
|
-
const resolved = await
|
|
682
|
+
const resolved = await assistantModel(way, input);
|
|
662
683
|
const wrote = () => {
|
|
663
684
|
changes++;
|
|
664
685
|
input.onChanged?.();
|
|
@@ -722,6 +743,12 @@ export async function runStudioAssistant(input) {
|
|
|
722
743
|
},
|
|
723
744
|
}));
|
|
724
745
|
}
|
|
746
|
+
// The space's skills (docs/plans/skills.md): Goose reads them as a step does.
|
|
747
|
+
const skills = project && switches.skills === true ? await activeSkills(project.id) : null;
|
|
748
|
+
const allSkills = project && switches.skills === true ? await skillList(project.id) : [];
|
|
749
|
+
if (skills) {
|
|
750
|
+
Object.assign(tools, skillToolsOf(skills, (name) => input.onActivity?.(serverText(input.lang, "doingReadSkill", { name }))));
|
|
751
|
+
}
|
|
725
752
|
for (const spec of input.browserTools) {
|
|
726
753
|
if (tools[spec.name]) {
|
|
727
754
|
continue;
|
|
@@ -733,10 +760,12 @@ export async function runStudioAssistant(input) {
|
|
|
733
760
|
}
|
|
734
761
|
const toolCalls = [];
|
|
735
762
|
traced(tools, input, toolCalls);
|
|
736
|
-
|
|
763
|
+
// The organization's tier may allow no web search.
|
|
764
|
+
const search = await searchAllowed();
|
|
765
|
+
if (search && resolved.vendor === "anthropic") {
|
|
737
766
|
tools.web_search = anthropic.tools.webSearch_20250305({ maxUses: 5 });
|
|
738
767
|
}
|
|
739
|
-
else if (resolved.gateway) {
|
|
768
|
+
else if (search && resolved.gateway) {
|
|
740
769
|
tools.web_search = gatewayTools.perplexitySearch({ maxResults: 6 });
|
|
741
770
|
}
|
|
742
771
|
const instructions = system();
|
|
@@ -784,6 +813,14 @@ export async function runStudioAssistant(input) {
|
|
|
784
813
|
? prompt("goose", "turn.space_read_only", { name: project.name })
|
|
785
814
|
: "No space is open.",
|
|
786
815
|
part === "knowledge" ? prompt("goose", "turn.knowledge") : "",
|
|
816
|
+
allSkills.length
|
|
817
|
+
? [
|
|
818
|
+
prompt("goose", "turn.skills"),
|
|
819
|
+
...allSkills.map((k) => `- ${k.name} (${k.mode}): ${k.description}`),
|
|
820
|
+
].join("\n")
|
|
821
|
+
: part === "skills"
|
|
822
|
+
? prompt("goose", "turn.skills_empty")
|
|
823
|
+
: "",
|
|
787
824
|
space && !(brandOn.brandSections && brandOn.brandRules && brandOn.typography)
|
|
788
825
|
? prompt("goose", "turn.off", {
|
|
789
826
|
missing: [
|
package/apps/runtime/dist/app.js
CHANGED
|
@@ -37,6 +37,7 @@ import { pluginRoutes } from "./routes/plugins.js";
|
|
|
37
37
|
import { reportRoutes } from "./routes/reports.js";
|
|
38
38
|
import { clientIp, connectCallback, publicRoutes, runRoutes, shareRoutes } from "./routes/runs.js";
|
|
39
39
|
import { runtimeSettingsRoutes } from "./routes/runtime-settings.js";
|
|
40
|
+
import { skillRoutes } from "./routes/skills.js";
|
|
40
41
|
import { studio } from "./routes/studio.js";
|
|
41
42
|
import { wizardStream } from "./routes/wizard-stream.js";
|
|
42
43
|
import { runTicketValid } from "./secrets/signing.js";
|
|
@@ -231,8 +232,8 @@ if (serves.doors) {
|
|
|
231
232
|
]);
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
|
-
/** The studio's requests that open an item: a wizard, a page, a table, a space. */
|
|
235
|
-
const STUDIO_LOADS = /\/api\/studio\/(wizards\/[^/]+|pages\/[^/]+|tables\/[^/]+|projects(\/[^/]+(\/(data|knowledge|files|wizards|page))?)?)$/;
|
|
235
|
+
/** The studio's requests that open an item: a wizard, a page, a table, a skill, a space. */
|
|
236
|
+
const STUDIO_LOADS = /\/api\/studio\/(wizards\/[^/]+|pages\/[^/]+|tables\/[^/]+|skills\/[^/]+|projects(\/[^/]+(\/(data|knowledge|files|wizards|page|skills))?)?)$/;
|
|
236
237
|
if (serves.studio) {
|
|
237
238
|
/** Studio requests act as the signed-in person, inside that person's tenant. */
|
|
238
239
|
app.use("/api/studio/*", async (c, next) => {
|
|
@@ -307,6 +308,7 @@ if (serves.studio) {
|
|
|
307
308
|
app.route("/api/studio/plugins", pluginRoutes);
|
|
308
309
|
app.route("/api/studio/organization", organizationRoutes);
|
|
309
310
|
app.route("/api/studio/person", personRoutes);
|
|
311
|
+
app.route("/api/studio", skillRoutes);
|
|
310
312
|
app.route("/api/studio/runtime", runtimeSettingsRoutes);
|
|
311
313
|
app.route("/api/studio", studio);
|
|
312
314
|
app.route("/api/v1", apiRoutes);
|
|
@@ -426,9 +428,18 @@ if (existsSync(webDir)) {
|
|
|
426
428
|
.replace(/<link rel="apple-touch-icon"[^>]*>/, `<link rel="apple-touch-icon" href="${own}/icons/apple-touch-icon.png" />`)
|
|
427
429
|
.replace(/<link rel="icon"[^>]*>/, `<link rel="icon" href="${own}/icons/favicon.png" type="image/png" />`)
|
|
428
430
|
: html;
|
|
429
|
-
|
|
431
|
+
// A result and a run are someone's own: search engines leave them out. A wizard's start
|
|
432
|
+
// page stays findable.
|
|
433
|
+
const personal = /^\/s\/|^\/w\/[^/]+\/[^/]+\/./.test(c.req.path);
|
|
434
|
+
if (personal) {
|
|
435
|
+
c.header("X-Robots-Tag", "noindex, nofollow");
|
|
436
|
+
}
|
|
437
|
+
const withPreview = preview
|
|
430
438
|
? page.replace(/<title>[^<]*<\/title>/, "").replace("</head>", `${preview}\n</head>`)
|
|
431
|
-
: page
|
|
439
|
+
: page;
|
|
440
|
+
return c.html(personal
|
|
441
|
+
? withPreview.replace("</head>", `<meta name="robots" content="noindex, nofollow">\n</head>`)
|
|
442
|
+
: withPreview);
|
|
432
443
|
});
|
|
433
444
|
}
|
|
434
445
|
export default app;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDecidedField, isDecisionStep, } from "@engenty/wizards-shared/definition";
|
|
1
|
+
import { isDecidedField, isDecisionStep, textClassOf, } from "@engenty/wizards-shared/definition";
|
|
2
2
|
import { and, desc, eq, inArray, isNull } from "drizzle-orm";
|
|
3
3
|
import { db, schema } from "../db/client.js";
|
|
4
4
|
import { mostAlongOnePath } from "../engine/requirements.js";
|
|
@@ -51,7 +51,7 @@ function stepFormula(step, catalog) {
|
|
|
51
51
|
? TOKENS.tools
|
|
52
52
|
: TOKENS.plain;
|
|
53
53
|
// A step with `each` runs once per entry; until it has run, three stand in.
|
|
54
|
-
let credits = textCredits(cls(step.model ?? "standard"), shape) * (step.each ? 3 : 1);
|
|
54
|
+
let credits = textCredits(cls(textClassOf(step.model ?? "standard")), shape) * (step.each ? 3 : 1);
|
|
55
55
|
if (step.tools.includes("web_search")) {
|
|
56
56
|
credits += 4 * catalog.webSearchCredits;
|
|
57
57
|
}
|
|
@@ -75,7 +75,7 @@ function stepFormula(step, catalog) {
|
|
|
75
75
|
return (seconds * (catalog.classes.video?.creditsPerSecond ?? 0) +
|
|
76
76
|
textCredits(cls("low"), TOKENS.prompt));
|
|
77
77
|
}
|
|
78
|
-
return textCredits(cls(step.model ?? "standard"), TOKENS.document);
|
|
78
|
+
return textCredits(cls(textClassOf(step.model ?? "standard")), TOKENS.document);
|
|
79
79
|
}
|
|
80
80
|
return 0;
|
|
81
81
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The triggers that fill `live_change` (docs/plans/live-changes.md, 1). One entry per table
|
|
3
3
|
* names the item a write changes; `pnpm --filter @engenty/wizards-runtime exec tsx
|
|
4
|
-
* scripts/live-triggers.ts` prints the SQL that migration 0023 carries
|
|
5
|
-
* triggers (0022) they have no guard, since
|
|
6
|
-
* and they count wizard-owned pages and
|
|
4
|
+
* scripts/live-triggers.ts` prints the SQL that migration 0023 carries, or with a table's name
|
|
5
|
+
* that table's alone (0026). Unlike the two-way sync's triggers (0022) they have no guard, since
|
|
6
|
+
* a pulled write is a change on this side's screen too, and they count wizard-owned pages and
|
|
7
|
+
* tables, which the studio shows as shared lists.
|
|
7
8
|
*/
|
|
8
9
|
const ofWizard = "(SELECT project_id FROM wizard WHERE id = $.wizard_id)";
|
|
9
10
|
export const LIVE_TABLES = [
|
|
@@ -104,6 +105,15 @@ export const LIVE_TABLES = [
|
|
|
104
105
|
parent: "NULL",
|
|
105
106
|
owns: true,
|
|
106
107
|
},
|
|
108
|
+
// Migration 0027.
|
|
109
|
+
{
|
|
110
|
+
table: "space_skill",
|
|
111
|
+
project: "$.project_id",
|
|
112
|
+
kind: "'skill'",
|
|
113
|
+
item: "$.id",
|
|
114
|
+
parent: "NULL",
|
|
115
|
+
owns: true,
|
|
116
|
+
},
|
|
107
117
|
];
|
|
108
118
|
const OPS = [
|
|
109
119
|
{ suffix: "ai", event: "INSERT", row: "new", del: false },
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
CREATE TABLE `space_skill` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`tenant_id` text NOT NULL,
|
|
4
|
+
`project_id` text NOT NULL,
|
|
5
|
+
`name` text NOT NULL,
|
|
6
|
+
`description` text NOT NULL,
|
|
7
|
+
`body` text DEFAULT '' NOT NULL,
|
|
8
|
+
`meta` text DEFAULT '{}' NOT NULL,
|
|
9
|
+
`files` text DEFAULT '[]' NOT NULL,
|
|
10
|
+
`blob_files` text DEFAULT '[]' NOT NULL,
|
|
11
|
+
`mode` text DEFAULT 'demand' NOT NULL,
|
|
12
|
+
`run_scripts` integer DEFAULT false NOT NULL,
|
|
13
|
+
`source` text DEFAULT 'own' NOT NULL,
|
|
14
|
+
`origin` text,
|
|
15
|
+
`origin_hash` text,
|
|
16
|
+
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
17
|
+
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
18
|
+
FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE cascade
|
|
19
|
+
);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
CREATE UNIQUE INDEX `space_skill_name` ON `space_skill` (`project_id`,`name`);--> statement-breakpoint
|
|
22
|
+
CREATE TRIGGER `sync_space_skill_ai` AFTER INSERT ON `space_skill` BEGIN
|
|
23
|
+
INSERT INTO `sync_change` (`project_id`, `kind`, `item`, `at`)
|
|
24
|
+
SELECT p, k, i, unixepoch() * 1000 FROM (SELECT new.project_id AS p, 'skill' AS k, new.id AS i)
|
|
25
|
+
WHERE p IS NOT NULL AND i IS NOT NULL AND (SELECT `applying` FROM `sync_guard` WHERE `id` = 1) = 0;
|
|
26
|
+
END;--> statement-breakpoint
|
|
27
|
+
CREATE TRIGGER `sync_space_skill_au` AFTER UPDATE ON `space_skill` BEGIN
|
|
28
|
+
INSERT INTO `sync_change` (`project_id`, `kind`, `item`, `at`)
|
|
29
|
+
SELECT p, k, i, unixepoch() * 1000 FROM (SELECT new.project_id AS p, 'skill' AS k, new.id AS i)
|
|
30
|
+
WHERE p IS NOT NULL AND i IS NOT NULL AND (SELECT `applying` FROM `sync_guard` WHERE `id` = 1) = 0;
|
|
31
|
+
END;--> statement-breakpoint
|
|
32
|
+
CREATE TRIGGER `sync_space_skill_ad` AFTER DELETE ON `space_skill` BEGIN
|
|
33
|
+
INSERT INTO `sync_change` (`project_id`, `kind`, `item`, `at`)
|
|
34
|
+
SELECT p, k, i, unixepoch() * 1000 FROM (SELECT old.project_id AS p, 'skill' AS k, old.id AS i)
|
|
35
|
+
WHERE p IS NOT NULL AND i IS NOT NULL AND (SELECT `applying` FROM `sync_guard` WHERE `id` = 1) = 0;
|
|
36
|
+
END;--> statement-breakpoint
|
|
37
|
+
CREATE TRIGGER `live_space_skill_ai` AFTER INSERT ON `space_skill` BEGIN
|
|
38
|
+
INSERT INTO `live_change` (`project_id`, `kind`, `op`, `item`, `parent`, `at`)
|
|
39
|
+
SELECT new.project_id, 'skill', 'put', i, NULL, unixepoch() * 1000 FROM (SELECT new.id AS i) WHERE i IS NOT NULL;
|
|
40
|
+
END;--> statement-breakpoint
|
|
41
|
+
CREATE TRIGGER `live_space_skill_au` AFTER UPDATE ON `space_skill` BEGIN
|
|
42
|
+
INSERT INTO `live_change` (`project_id`, `kind`, `op`, `item`, `parent`, `at`)
|
|
43
|
+
SELECT new.project_id, 'skill', 'put', i, NULL, unixepoch() * 1000 FROM (SELECT new.id AS i) WHERE i IS NOT NULL;
|
|
44
|
+
END;--> statement-breakpoint
|
|
45
|
+
CREATE TRIGGER `live_space_skill_ad` AFTER DELETE ON `space_skill` BEGIN
|
|
46
|
+
INSERT INTO `live_change` (`project_id`, `kind`, `op`, `item`, `parent`, `at`)
|
|
47
|
+
SELECT old.project_id, 'skill', 'del', i, NULL, unixepoch() * 1000 FROM (SELECT old.id AS i) WHERE i IS NOT NULL;
|
|
48
|
+
END;
|