@engenty/wizards-runtime 0.12.0 → 0.12.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/apps/runtime/dist/agents/space-agent.js +55 -0
- package/apps/runtime/dist/agents/studio-assistant.js +22 -11
- package/apps/runtime/dist/app.js +4 -2
- package/apps/runtime/dist/auth/account.js +3 -0
- 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/user-guide/skills.md +85 -0
- package/apps/runtime/dist/engine/steps.js +10 -1
- package/apps/runtime/dist/env.js +2 -0
- package/apps/runtime/dist/features.js +11 -3
- package/apps/runtime/dist/harness/model.js +4 -0
- package/apps/runtime/dist/live/views.js +2 -0
- package/apps/runtime/dist/models.js +4 -0
- package/apps/runtime/dist/plugins/pro.js +26 -0
- package/apps/runtime/dist/prompts/goose.md +7 -0
- package/apps/runtime/dist/prompts/step.md +19 -1
- package/apps/runtime/dist/prompts/tools.md +33 -0
- package/apps/runtime/dist/routes/skills.js +84 -0
- package/apps/runtime/dist/routes/studio.js +12 -1
- package/apps/runtime/dist/services/assistant-chats.js +5 -2
- package/apps/runtime/dist/services/skills-registry.js +209 -0
- package/apps/runtime/dist/services/skills.js +478 -0
- package/apps/runtime/dist/sync/records.js +81 -1
- package/apps/runtime/dist/texts.js +39 -0
- package/apps/runtime/dist/tools/index.js +4 -2
- 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-BOJjBIYk.js → AboutDialog-CLgnoYTI.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-I9DEn_ra.js → ChangelogDialog-CKLgFL6r.js} +1 -1
- package/apps/web/dist/assets/CodeEditor-B3nto_26.js +2 -0
- package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-C6DeATyk.js → FlowPreview-zJCtixSi.js} +1 -1
- package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-BrVFc6PV.js → NewWizardChannels-B4N7GIYh.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-Dl8sMR2e.js → NewWizardPage-Dpt0Mzk8.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-BN5IfLGL.js → OnboardingPage-CDoYVjRC.js} +1 -1
- package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +10 -0
- package/apps/web/dist/assets/ProjectPage-408YOoNa.js +10 -0
- package/apps/web/dist/assets/{PublicRunner-bAakEGwv.js → PublicRunner-BZ66xdRX.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-MBVPGEhw.js → ReadOnly-C9oGMkUB.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +2 -0
- package/apps/web/dist/assets/{SetupPage-CmTC9K8_.js → SetupPage-CP3lbyZc.js} +1 -1
- package/apps/web/dist/assets/{SharePage-D9_IxO3M.js → SharePage-DdMm1Y8K.js} +1 -1
- package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +1 -0
- package/apps/web/dist/assets/changelog-82-DHogQ.js +1 -0
- package/apps/web/dist/assets/code-xml-Hx7YxCg0.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-BkMFLnYu.js +1 -0
- package/apps/web/dist/assets/i18n-CKKh3Pn0.js +55 -0
- package/apps/web/dist/assets/index-Cy2NHzAx.js +49 -0
- package/apps/web/dist/assets/index-wR_-1hfN.css +1 -0
- package/apps/web/dist/assets/json-CEsfHdlZ.js +1 -0
- package/apps/web/dist/assets/{lock-D1093O6-.js → lock-CGXM95Mi.js} +1 -1
- package/apps/web/dist/assets/markdown-5-I9_izp.js +29 -0
- package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +1 -0
- package/apps/web/dist/assets/{phone-YeDiW-kN.js → phone-DMfwuh9V.js} +1 -1
- package/apps/web/dist/assets/{runners-DP0vYvTF.js → runners-D5qz6b_s.js} +1 -1
- package/apps/web/dist/assets/{session-Bio3Vaq1.js → session-DRy0k0nh.js} +1 -1
- package/apps/web/dist/assets/{theme-AlaEfdLQ.js → theme-DNPm6r4e.js} +2 -2
- package/apps/web/dist/assets/{ui-CU-cIuyK.js → ui-CwFQAfE-.js} +2 -2
- package/apps/web/dist/assets/{upload-DbWtEr1f.js → upload-DQJwLSGj.js} +1 -1
- package/apps/web/dist/assets/{useMutation-erJIov3t.js → useMutation-C20c2EH3.js} +1 -1
- package/apps/web/dist/assets/{volume-2-V1P9DYWO.js → volume-2-CC5qamYT.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/feature-flags.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
- package/node_modules/@engenty/wizards-shared/dist/live.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +1 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +2 -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/package.json +11 -11
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/CodeEditor-BgUofYLQ.js +0 -2
- package/apps/web/dist/assets/EditorPage-DEOxHFXn.js +0 -3
- package/apps/web/dist/assets/Marketplace-Dt7ktvc3.js +0 -2
- package/apps/web/dist/assets/PreviewPane-BDzDuTz1.js +0 -10
- package/apps/web/dist/assets/ProjectPage-BqkkyEpP.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DDe1BC-3.js +0 -2
- package/apps/web/dist/assets/changelog-iTu1De5h.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-7CvqRUdn.js +0 -55
- package/apps/web/dist/assets/index-CNwXyMzH.js +0 -49
- package/apps/web/dist/assets/index-Dxwbli0m.css +0 -1
- 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/oss-credits-Da4KrYmP.js +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Agent } from "@mastra/core/agent";
|
|
2
|
+
import { agentModel, attachTools } from "../models.js";
|
|
3
|
+
/**
|
|
4
|
+
* The agent that acts in a space: the studio assistant (Goose) today, Work's chats next
|
|
5
|
+
* (docs/plans/work-chats.md). Made the same way for both, so that each request starts with the
|
|
6
|
+
* one before and the provider's prompt cache holds: the tools sorted by name, the instructions
|
|
7
|
+
* marked, and the end of what the chat already said marked.
|
|
8
|
+
*/
|
|
9
|
+
const EPHEMERAL = { anthropic: { cacheControl: { type: "ephemeral" } } };
|
|
10
|
+
/** The tools by name, in that order: a request's tool block doesn't change with the order they were added in. */
|
|
11
|
+
export function sortedTools(tools) {
|
|
12
|
+
return Object.fromEntries(Object.entries(tools).sort(([a], [b]) => a.localeCompare(b)));
|
|
13
|
+
}
|
|
14
|
+
const marked = (message) => ({
|
|
15
|
+
...message,
|
|
16
|
+
providerOptions: {
|
|
17
|
+
...message.providerOptions,
|
|
18
|
+
anthropic: {
|
|
19
|
+
...message.providerOptions?.anthropic,
|
|
20
|
+
...EPHEMERAL.anthropic,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Where a request's prompt gets Anthropic's cache marks besides the instructions: on the last
|
|
26
|
+
* message before the newest message of the person (what the chat already said, the same next
|
|
27
|
+
* turn), and on the newest message once tool steps follow it within the turn. The person's
|
|
28
|
+
* message itself carries what changes each turn (the page, the time), so it is never marked:
|
|
29
|
+
* the next turn sends it without that, and a mark there would only be paid for.
|
|
30
|
+
*/
|
|
31
|
+
export function cacheMarks(prompt) {
|
|
32
|
+
const lastUser = prompt.findLastIndex((m) => m.role === "user");
|
|
33
|
+
return prompt.map((message, at) => {
|
|
34
|
+
const historyEnd = at === lastUser - 1 && message.role !== "system";
|
|
35
|
+
const stepEnd = at === prompt.length - 1 && at > lastUser && lastUser >= 0;
|
|
36
|
+
return historyEnd || stepEnd ? marked(message) : message;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const cacheMarksProcessor = {
|
|
40
|
+
id: "cache-marks",
|
|
41
|
+
processLLMRequest: ({ prompt }) => ({ prompt: cacheMarks(prompt) }),
|
|
42
|
+
};
|
|
43
|
+
/** The agent for a request: its model, instructions and tools. */
|
|
44
|
+
export function spaceAgent(options) {
|
|
45
|
+
const tools = sortedTools(options.tools);
|
|
46
|
+
attachTools(options.resolved, tools);
|
|
47
|
+
return new Agent({
|
|
48
|
+
id: options.id,
|
|
49
|
+
name: options.name,
|
|
50
|
+
instructions: { role: "system", content: options.instructions, providerOptions: EPHEMERAL },
|
|
51
|
+
model: agentModel(options.resolved),
|
|
52
|
+
tools: tools,
|
|
53
|
+
inputProcessors: [cacheMarksProcessor],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, factKey, gradientCss, PROJECT_FILE_KINDS, PROJECT_LIMITS, parseGradient, RULE_MARKS, textStyleLine, } from "@engenty/wizards-shared/projects";
|
|
3
|
-
import { Agent } from "@mastra/core/agent";
|
|
4
3
|
import { createTool } from "@mastra/core/tools";
|
|
5
4
|
import { nanoid } from "nanoid";
|
|
6
5
|
import { z } from "zod";
|
|
7
6
|
import { knowsTools } from "../assistant/knows.js";
|
|
8
7
|
import { currentFeatures } from "../features.js";
|
|
9
8
|
import { managed } from "../manage.js";
|
|
10
|
-
import {
|
|
9
|
+
import { chatModel, contextWindowOf, costOf, gatewayTools, totalUsage, usageOf, } from "../models.js";
|
|
11
10
|
import { prompt } from "../prompts.js";
|
|
12
11
|
import { contentPolicy } from "../safety.js";
|
|
13
12
|
import { knowledgeCounts } from "../services/knowledge.js";
|
|
14
13
|
import { addProjectFileFromUrl, projectFileContent, projectFiles, updateProjectFile, } from "../services/project-files.js";
|
|
15
14
|
import { documentText } from "../services/project-index.js";
|
|
16
15
|
import { ownedProject, updateProject } from "../services/projects.js";
|
|
16
|
+
import { activeSkills, skillList } from "../services/skills.js";
|
|
17
17
|
import { categoryRows } from "../services/space-categories.js";
|
|
18
18
|
import { currentTenant } from "../tenants/tenant.js";
|
|
19
19
|
import { serverText } from "../texts.js";
|
|
20
20
|
import { assistantPageOf, assistantToolsOf } from "../tools/plugin.js";
|
|
21
21
|
import { attempt as attemptTool, imageOutput } from "../tools/shared.js";
|
|
22
|
+
import { skillToolsOf } from "../tools/skills.js";
|
|
23
|
+
import { spaceAgent } from "./space-agent.js";
|
|
22
24
|
import { chatTurnWay } from "./subscription.js";
|
|
23
25
|
import { readWebsite } from "./website.js";
|
|
24
26
|
/** How a message written meanwhile reaches the model. */
|
|
@@ -633,7 +635,7 @@ function traced(tools, input, record) {
|
|
|
633
635
|
}
|
|
634
636
|
/** The part of the space page a route stands on. */
|
|
635
637
|
function partOf(route) {
|
|
636
|
-
const m = route.match(/^\/space\/(info|brand|knowledge|data|results)/);
|
|
638
|
+
const m = route.match(/^\/space\/(info|brand|knowledge|data|results|skills)/);
|
|
637
639
|
return m ? m[1] : route === "/space" ? "info" : null;
|
|
638
640
|
}
|
|
639
641
|
/** How large each tool is in the prompt: its description and its schema, in characters. */
|
|
@@ -722,6 +724,12 @@ export async function runStudioAssistant(input) {
|
|
|
722
724
|
},
|
|
723
725
|
}));
|
|
724
726
|
}
|
|
727
|
+
// The space's skills (docs/plans/skills.md): Goose reads them as a step does.
|
|
728
|
+
const skills = project && switches.skills === true ? await activeSkills(project.id) : null;
|
|
729
|
+
const allSkills = project && switches.skills === true ? await skillList(project.id) : [];
|
|
730
|
+
if (skills) {
|
|
731
|
+
Object.assign(tools, skillToolsOf(skills, (name) => input.onActivity?.(serverText(input.lang, "doingReadSkill", { name }))));
|
|
732
|
+
}
|
|
725
733
|
for (const spec of input.browserTools) {
|
|
726
734
|
if (tools[spec.name]) {
|
|
727
735
|
continue;
|
|
@@ -739,17 +747,12 @@ export async function runStudioAssistant(input) {
|
|
|
739
747
|
else if (resolved.gateway) {
|
|
740
748
|
tools.web_search = gatewayTools.perplexitySearch({ maxResults: 6 });
|
|
741
749
|
}
|
|
742
|
-
attachTools(resolved, tools);
|
|
743
750
|
const instructions = system();
|
|
744
|
-
const agent =
|
|
751
|
+
const agent = spaceAgent({
|
|
745
752
|
id: "studio-assistant",
|
|
746
753
|
name: "Studio assistant",
|
|
747
|
-
instructions
|
|
748
|
-
|
|
749
|
-
content: instructions,
|
|
750
|
-
providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
|
|
751
|
-
},
|
|
752
|
-
model: agentModel(resolved),
|
|
754
|
+
instructions,
|
|
755
|
+
resolved,
|
|
753
756
|
tools,
|
|
754
757
|
});
|
|
755
758
|
const page = input.page;
|
|
@@ -789,6 +792,14 @@ export async function runStudioAssistant(input) {
|
|
|
789
792
|
? prompt("goose", "turn.space_read_only", { name: project.name })
|
|
790
793
|
: "No space is open.",
|
|
791
794
|
part === "knowledge" ? prompt("goose", "turn.knowledge") : "",
|
|
795
|
+
allSkills.length
|
|
796
|
+
? [
|
|
797
|
+
prompt("goose", "turn.skills"),
|
|
798
|
+
...allSkills.map((k) => `- ${k.name} (${k.mode}): ${k.description}`),
|
|
799
|
+
].join("\n")
|
|
800
|
+
: part === "skills"
|
|
801
|
+
? prompt("goose", "turn.skills_empty")
|
|
802
|
+
: "",
|
|
792
803
|
space && !(brandOn.brandSections && brandOn.brandRules && brandOn.typography)
|
|
793
804
|
? prompt("goose", "turn.off", {
|
|
794
805
|
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);
|
|
@@ -209,6 +209,9 @@ export async function accountOverview() {
|
|
|
209
209
|
const overview = (await res.json());
|
|
210
210
|
if (overview?.tenant) {
|
|
211
211
|
await rememberOrganization(overview.tenant).catch(() => undefined);
|
|
212
|
+
// A plan that changed brings its Pro modules along (plugins/pro.ts).
|
|
213
|
+
const tenant = overview.tenant;
|
|
214
|
+
void import("../plugins/pro.js").then((pro) => pro.followPlan(tenant));
|
|
212
215
|
}
|
|
213
216
|
return overview;
|
|
214
217
|
}
|
|
@@ -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;
|