wizards 0.2.46 → 0.2.48
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/{project-assistant.js → studio-assistant.js} +199 -69
- package/apps/runtime/dist/agents/website.js +25 -2
- package/apps/runtime/dist/app.js +5 -1
- package/apps/runtime/dist/assistant/browser.js +26 -0
- package/apps/runtime/dist/assistant/docs.js +158 -0
- package/apps/runtime/dist/assistant/knows.js +325 -0
- package/apps/runtime/dist/assistant/primer.js +26 -0
- package/apps/runtime/dist/authoring/guide.js +5 -0
- package/apps/runtime/dist/cli/features.js +50 -0
- package/apps/runtime/dist/cli/main.js +4 -1
- package/apps/runtime/dist/connectors/plugin-connections.js +123 -29
- package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +30 -0
- package/apps/runtime/dist/docs/dev/index.md +34 -0
- package/apps/runtime/dist/docs/dev/meta.json +7 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +70 -0
- package/apps/runtime/dist/docs/dev/plugins/events.md +86 -0
- package/apps/runtime/dist/docs/dev/plugins/examples.md +99 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +72 -0
- package/apps/runtime/dist/docs/dev/plugins/layout.md +88 -0
- package/apps/runtime/dist/docs/dev/plugins/meta.json +29 -0
- package/apps/runtime/dist/docs/dev/plugins/pro-modules.md +59 -0
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +92 -0
- package/apps/runtime/dist/docs/dev/plugins/reference.md +298 -0
- package/apps/runtime/dist/docs/dev/plugins/reloading.md +75 -0
- package/apps/runtime/dist/docs/dev/plugins/routes.md +123 -0
- package/apps/runtime/dist/docs/dev/plugins/runners.md +184 -0
- package/apps/runtime/dist/docs/dev/plugins/server.md +191 -0
- package/apps/runtime/dist/docs/dev/plugins/shipping.md +98 -0
- package/apps/runtime/dist/docs/dev/plugins/space.md +260 -0
- package/apps/runtime/dist/docs/dev/plugins/starters.md +62 -0
- package/apps/runtime/dist/docs/dev/plugins/studio.md +261 -0
- package/apps/runtime/dist/docs/dev/plugins/styling.md +109 -0
- package/apps/runtime/dist/docs/dev/plugins/tables.md +102 -0
- package/apps/runtime/dist/docs/dev/plugins/tools.md +128 -0
- package/apps/runtime/dist/docs/meta.json +3 -0
- package/apps/runtime/dist/docs/user/ai-apps.md +99 -0
- package/apps/runtime/dist/docs/user/assistant.md +52 -0
- package/apps/runtime/dist/docs/user/build-a-wizard.md +79 -0
- package/apps/runtime/dist/docs/user/command-line.md +76 -0
- package/apps/runtime/dist/docs/user/connectors.md +80 -0
- package/apps/runtime/dist/docs/user/data.md +61 -0
- package/apps/runtime/dist/docs/user/first-start.md +42 -0
- package/apps/runtime/dist/docs/user/index.md +45 -0
- package/apps/runtime/dist/docs/user/install.md +76 -0
- package/apps/runtime/dist/docs/user/meta.json +29 -0
- package/apps/runtime/dist/docs/user/models.md +100 -0
- package/apps/runtime/dist/docs/user/plugins.md +61 -0
- package/apps/runtime/dist/docs/user/run.md +92 -0
- package/apps/runtime/dist/docs/user/server.md +50 -0
- package/apps/runtime/dist/docs/user/space.md +97 -0
- package/apps/runtime/dist/docs/user/steps.md +196 -0
- package/apps/runtime/dist/docs/user/test-and-share.md +210 -0
- package/apps/runtime/dist/docs/user/troubleshooting.md +57 -0
- package/apps/runtime/dist/engine/runner.js +12 -5
- package/apps/runtime/dist/features.js +123 -0
- package/apps/runtime/dist/manage.js +24 -0
- package/apps/runtime/dist/plugins/discovery.js +11 -0
- package/apps/runtime/dist/plugins/loader.js +12 -0
- package/apps/runtime/dist/routes/internal.js +3 -0
- package/apps/runtime/dist/routes/studio.js +126 -73
- package/apps/runtime/dist/services/assistant-chats.js +267 -0
- package/apps/runtime/dist/services/project-index.js +1 -1
- package/apps/runtime/dist/services/space-origin.js +45 -2
- package/apps/web/dist/assets/{AboutDialog-DkY1j7k6.js → AboutDialog-CuiVGknS.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-820LI5Jt.js → ChangelogDialog-DCEQD3Jd.js} +1 -1
- package/apps/web/dist/assets/ChatView-DFxrG2PD.js +10 -0
- package/apps/web/dist/assets/EditorPage-B5rzKNMy.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-ChXfiMn_.js → FlowPreview-CYoR5DRY.js} +1 -1
- package/apps/web/dist/assets/{Harness-CfUfchNw.js → Harness-DAR1u4Dk.js} +1 -1
- package/apps/web/dist/assets/HomePage-BnYdh_Nx.js +1 -0
- package/apps/web/dist/assets/Marketplace-BDQNwMDB.js +2 -0
- package/apps/web/dist/assets/{NewWizardPage-C3NqEGmg.js → NewWizardPage-DztTEUlG.js} +1 -1
- package/apps/web/dist/assets/ProjectPage-B7-Lqx9a.js +2 -0
- package/apps/web/dist/assets/PublicRunner-CaH3bHHd.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-C9P9aiU6.js → ReadOnly-DnB47DQC.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-Dv0KRqGA.js +4 -0
- package/apps/web/dist/assets/RunnerView-Bzwv1u4j.js +2 -0
- package/apps/web/dist/assets/SettingsPage-oVO7CKvc.js +1 -0
- package/apps/web/dist/assets/SetupPage-D--8cWA0.js +1 -0
- package/apps/web/dist/assets/{SharePage-D5AvnhlY.js → SharePage-DjU08q7T.js} +1 -1
- package/apps/web/dist/assets/ThemeSwitch-C3EJRN06.js +1 -0
- package/apps/web/dist/assets/arrow-right-F7X_SjK9.js +1 -0
- package/apps/web/dist/assets/changelog-BRoVI_JJ.js +1 -0
- package/apps/web/dist/assets/{circle-alert-CPo3Naay.js → circle-alert-DdpaAYgd.js} +1 -1
- package/apps/web/dist/assets/{definition-CQGiBQ4X.js → definition-CHacJYmI.js} +2 -2
- package/apps/web/dist/assets/{external-link-CpU8aJY2.js → external-link-Dfc1VFvS.js} +1 -1
- package/apps/web/dist/assets/index-CX_yxZVQ.js +79 -0
- package/apps/web/dist/assets/index-Dr0bv52Q.css +1 -0
- package/apps/web/dist/assets/{lock-C_WlXIQ0.js → lock-Bu1wDFs8.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-Cli5WGnW.js → refresh-cw-BUDPOT39.js} +1 -1
- package/apps/web/dist/assets/{session-miDEdw2c.js → session-Blj2os_v.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-ROT8Lbbj.js → settings-menu-BvxRnNtf.js} +1 -1
- package/apps/web/dist/assets/{sparkles-CP5H-O1E.js → sparkles-DWGJluyV.js} +1 -1
- package/apps/web/dist/assets/{trash-DU-hZpV0.js → trash-D9UB6TtS.js} +1 -1
- package/apps/web/dist/assets/ui-GsuU9WTj.js +9 -0
- package/apps/web/dist/assets/{upload-DMq5N6Fw.js → upload-BngimDBR.js} +1 -1
- package/apps/web/dist/assets/{volume-2-0SfkvOho.js → volume-2-BZju_bOP.js} +1 -1
- package/apps/web/dist/index.html +11 -11
- package/apps/web/dist/mcp/flow.html +51 -51
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +103 -7
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +58 -4
- package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +113 -0
- package/node_modules/@engenty-wizards/shared/dist/assistant.js +55 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +56 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.js +94 -4
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +54 -0
- package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +46 -0
- package/node_modules/@engenty-wizards/shared/dist/features.d.ts +36 -0
- package/node_modules/@engenty-wizards/shared/dist/features.js +78 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +3 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/ChatView-DBl0iRMg.js +0 -10
- package/apps/web/dist/assets/EditorPage-BwJ-hqPg.js +0 -3
- package/apps/web/dist/assets/HomePage-BG5OZJkv.js +0 -1
- package/apps/web/dist/assets/Marketplace-BWhUJ4UX.js +0 -2
- package/apps/web/dist/assets/ProjectPage-Btf0TeP_.js +0 -2
- package/apps/web/dist/assets/PublicRunner-BxYinn04.js +0 -1
- package/apps/web/dist/assets/RunDrawer-DfnEMPTq.js +0 -4
- package/apps/web/dist/assets/RunnerView-CLrGb-oq.js +0 -2
- package/apps/web/dist/assets/SettingsPage-FWH84btd.js +0 -1
- package/apps/web/dist/assets/SetupPage-BI0kUNVW.js +0 -1
- package/apps/web/dist/assets/ThemeSwitch-C1qYFoYP.js +0 -1
- package/apps/web/dist/assets/arrow-right-Dpp_mpHe.js +0 -1
- package/apps/web/dist/assets/changelog-B6QMrVxX.js +0 -1
- package/apps/web/dist/assets/index-CIO9W4pe.js +0 -78
- package/apps/web/dist/assets/index-DKHClEy3.css +0 -1
- package/apps/web/dist/assets/ui-D92EkdEB.js +0 -9
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The space
|
|
3
|
+
description: Wissen a plugin writes, a block and tools for every AI step of a space, texts in its search index, tools and cards of its assistant.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A space holds what all its wizards share: a title, logos, colours, facts, and Wissen — pages,
|
|
7
|
+
tables and files with their Kategorien. A plugin writes Wissen, adds to what the space's AI steps
|
|
8
|
+
know, to what its search finds, and to what its assistant can do. The runtime's own tables call a space a project: `wizard.projectId` in a
|
|
9
|
+
[run event](./events.md) is a space's id.
|
|
10
|
+
|
|
11
|
+
## Wissen a plugin writes
|
|
12
|
+
|
|
13
|
+
`server.spaceData` writes pages, tables and files into a space's Wissen under keys of the
|
|
14
|
+
plugin's own, with their Kategorien. Every write is indexed: `project_search` finds it a moment
|
|
15
|
+
later, filtered by its Kategorien and checked like everything else in Wissen.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// The source's Kategorien, once. `proposed: true` shows them to the person to take first.
|
|
19
|
+
await server.spaceData.putCategories({
|
|
20
|
+
space,
|
|
21
|
+
categories: [
|
|
22
|
+
{ name: "Baustelle", type: "choice", hint: "Kopfzeile" },
|
|
23
|
+
{ name: "Berichtsdatum", type: "date" },
|
|
24
|
+
{ name: "Arbeitsstunden", type: "number", unit: "h" },
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Then an item per entry. The same key again rewrites it, never doubles it.
|
|
29
|
+
await server.spaceData.putPage({
|
|
30
|
+
space,
|
|
31
|
+
key: `${source.id}:2026-03-14`,
|
|
32
|
+
label: "Tagesberichte",
|
|
33
|
+
title: "Tagesbericht 14.03.2026",
|
|
34
|
+
markdown,
|
|
35
|
+
categories: { Baustelle: "Graz Süd", Berichtsdatum: "2026-03-14", Arbeitsstunden: 38 },
|
|
36
|
+
fill: true, // a model fills the Kategorien the entry did not bring
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// A file is read as an upload is: a page, sub-pages, a table per sheet, or a file.
|
|
40
|
+
const doc = await server.spaceData.putDocument({ space, key, label, name, mime, data, fill: true });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| `server.spaceData.` | Does |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `putCategories({ space, categories, proposed? })` | Adds Kategorien, or values to known ones. Types: `choice`, `date`, `number` (with `unit`), `text`, `boolean`. `column: { table, column }` makes a column of a table the plugin wrote one |
|
|
46
|
+
| `putPage(input)` | A page: `title`, `markdown`, `parent` (the key of a page to stand under), `original` (the file it was read from), `categories`, `fill`, `review` (why a person should look) |
|
|
47
|
+
| `putTable(input)` | A table: typed `columns`, `rows` (cells by column id, they replace the rows the key had), `format: "faq"` |
|
|
48
|
+
| `putFile(input)` | A file that is no page: found by its name, `description` and Kategorien; `text` is what a step reads of it |
|
|
49
|
+
| `putDocument(input)` | A file read as an upload is. Gives what it became: `items` (pages, tables), `review` when it read badly or not at all |
|
|
50
|
+
| `readPages(space, { parent? })` | The space's own pages, whoever wrote them, with their Markdown: `{ id, title, path, parentId, markdown, origin, originKey, updatedAt }` |
|
|
51
|
+
| `files(space, kind?)`, `readFile(space, id)` | The space's files (`document` when no kind is named), and one with its bytes: a price list someone dropped into Wissen |
|
|
52
|
+
| `list(space)` | Everything the plugin wrote, by key, with its path and `state` |
|
|
53
|
+
| `remove(space, key?)` | Takes out one key, or everything of the plugin in the space |
|
|
54
|
+
| `summarize(space, category?, value?)` | Writes the Übersicht of values with three items or more; a model call each |
|
|
55
|
+
|
|
56
|
+
- `label` is what the person knows the source as; Wissen shows it beside the item.
|
|
57
|
+
- A person who changes an item keeps it: the plugin's next write answers `state: "kept"` and
|
|
58
|
+
changes nothing, and `remove` leaves it.
|
|
59
|
+
- What a step reads of an item is its path: `pages/…`, `tables/…`, `files/…`.
|
|
60
|
+
|
|
61
|
+
## A block for every AI step
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
server.registerSpaceContext({
|
|
65
|
+
block: async (space) => {
|
|
66
|
+
const titles = await pageTitles(space.id);
|
|
67
|
+
return titles.length
|
|
68
|
+
? `# THE SPACE'S WIKI\nPages, read one with wiki_page: ${titles.join(" · ")}`
|
|
69
|
+
: null;
|
|
70
|
+
},
|
|
71
|
+
tools: [
|
|
72
|
+
{
|
|
73
|
+
name: "page",
|
|
74
|
+
description: "Reads a page of the space's wiki by its title.",
|
|
75
|
+
inputSchema: z.object({ title: z.string() }),
|
|
76
|
+
execute: async ({ title }, step) => pageOf(step.space.id, title),
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Every agent step of the space's wizards gets the block in its instructions, after what the
|
|
83
|
+
space says about itself and its documents, and gets the tools with it. No step lists them.
|
|
84
|
+
- `block` is asked once per step. `null` or an empty text: the step gets neither the block nor
|
|
85
|
+
the tools.
|
|
86
|
+
- A block is cut at 8,000 characters. A block that throws is logged, and the step runs without
|
|
87
|
+
it.
|
|
88
|
+
- The tools are [tools](./tools.md) like the ones a step lists; the model sees
|
|
89
|
+
`<plugin>_<name>`. Their names and the names of the plugin's other tools are one list.
|
|
90
|
+
|
|
91
|
+
## The search index
|
|
92
|
+
|
|
93
|
+
Every agent step can search the space with `project_search`. It finds Wissen — written by people
|
|
94
|
+
and by `server.spaceData` — and the texts plugins put in themselves, outside Wissen:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await server.index.put({
|
|
98
|
+
space: space.id,
|
|
99
|
+
key: `page:${page.id}`,
|
|
100
|
+
title: page.title,
|
|
101
|
+
text: page.markdown,
|
|
102
|
+
link: "/space/knowledge#wiki",
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await server.index.remove(space.id, `page:${page.id}`);
|
|
106
|
+
await server.index.remove(space.id); // every text of the plugin in the space
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Putting a key again replaces what it held.
|
|
110
|
+
- A text is cut into passages. Its title is searched with it, and a hit is called by it. The test
|
|
111
|
+
search under Wissen shows hits as a step gets them.
|
|
112
|
+
- The index searches by words and by trigrams (codes, parts of compounds); with an embedding model
|
|
113
|
+
set up, also by meaning. A classifier then judges each candidate.
|
|
114
|
+
- Such a text has no Kategorien: a search with a filter leaves it out. Write Wissen with
|
|
115
|
+
`server.spaceData` when it should be filtered.
|
|
116
|
+
- A step gets `project_search` as soon as the space has Wissen or a plugin's text.
|
|
117
|
+
- A tenant without the plugin does not find its texts. They go with the space when it is
|
|
118
|
+
deleted.
|
|
119
|
+
|
|
120
|
+
## Tools of the space assistant
|
|
121
|
+
|
|
122
|
+
The studio's assistant stands on every page of the studio but the editor. Where a space is open
|
|
123
|
+
and may be changed, it fills it in from what the person says, a website or files. A plugin gives
|
|
124
|
+
it tools:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
server.registerAssistantTool({
|
|
128
|
+
name: "propose_source",
|
|
129
|
+
description: "Looks at a website the person names and proposes it as a source of the wiki.",
|
|
130
|
+
inputSchema: z.object({ url: z.string() }),
|
|
131
|
+
card: true,
|
|
132
|
+
execute: async ({ url }, turn) => {
|
|
133
|
+
turn.emit("Liest die Sitemap …");
|
|
134
|
+
const found = await sample(url, turn.signal);
|
|
135
|
+
return { url, pages: found.length };
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
| `turn.` | |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `space` | `{ id, name }`: the space the person is filling in |
|
|
143
|
+
| `tenantId`, `userId` | The tenant and the person |
|
|
144
|
+
| `signal` | Aborted when the person leaves or stops the answer |
|
|
145
|
+
| `emit(message)` | The line the chat shows while the assistant works |
|
|
146
|
+
| `changed()` | The tool changed what the space page shows: the page draws it again |
|
|
147
|
+
|
|
148
|
+
- The model sees the tool as `<plugin>_<name>`, beside the assistant's own tools.
|
|
149
|
+
- The assistant does not keep a tool's result from one message to the next. Keep what a later
|
|
150
|
+
message needs in the plugin's tables.
|
|
151
|
+
|
|
152
|
+
### A card in the chat
|
|
153
|
+
|
|
154
|
+
With `card: true` the result also goes to the chat. The studio half draws it:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
studio.registerAssistantCard({
|
|
158
|
+
tool: "propose_source",
|
|
159
|
+
component: ({ data, send }) => (
|
|
160
|
+
<Card className="flex items-center gap-3 p-4">
|
|
161
|
+
<span className="flex-1 text-[0.875rem]">
|
|
162
|
+
{data.url}: {data.pages} pages
|
|
163
|
+
</span>
|
|
164
|
+
<Button size="sm" onClick={() => send("Übernehmen")}>
|
|
165
|
+
Übernehmen
|
|
166
|
+
</Button>
|
|
167
|
+
</Card>
|
|
168
|
+
),
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- The card stands below the assistant's answer. Without a card for the tool, nothing shows.
|
|
173
|
+
- `data` is what `execute` returned, sent as it is: keep it small.
|
|
174
|
+
- `send(message)` sends a message to the assistant as if the person typed it.
|
|
175
|
+
|
|
176
|
+
## Events of a space
|
|
177
|
+
|
|
178
|
+
`space.created`, `space.updated`, `space.deleted`, `space.file.ready` and `space.file.removed`
|
|
179
|
+
say what changed. See [Events](./events.md).
|
|
180
|
+
|
|
181
|
+
## The assistant on the plugin's own page
|
|
182
|
+
|
|
183
|
+
The assistant stands on the plugin's pages too, as on every page of the studio. A page tells it
|
|
184
|
+
what to say there, and what it shows; the assistant is told what the page holds and uses the
|
|
185
|
+
plugin's assistant tools first.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
const Assistant = studio.Assistant;
|
|
189
|
+
|
|
190
|
+
<Assistant
|
|
191
|
+
title="Sag, wann du Zeit hast"
|
|
192
|
+
hello="Ich trage Bürozeiten, freie Tage und Blocker ein."
|
|
193
|
+
placeholder="z. B. „Ich bin vom 24.12. bis 6.1. im Urlaub“ …"
|
|
194
|
+
suggestions={[
|
|
195
|
+
{ label: "Welche Termine sind diese Woche frei?" },
|
|
196
|
+
{ label: "Ich bin im Urlaub von … bis …", fill: true },
|
|
197
|
+
]}
|
|
198
|
+
onChanged={() => queryClient.invalidateQueries({ queryKey: ["appointments"] })}
|
|
199
|
+
/>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
server.registerAssistantContext({
|
|
204
|
+
block: async (space) => `THE CALENDAR ON THIS PAGE: office hours ${await hoursText(space.id)} …`,
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
- `studio.Assistant` draws nothing: place it once, anywhere in the page. `title` and `hello`
|
|
209
|
+
greet before the first message; up to three `suggestions` stand under them. A click sends one
|
|
210
|
+
at once; `fill: true` puts it into the field to finish first.
|
|
211
|
+
- `block` is asked once per message, only when the person writes from the plugin's page. A
|
|
212
|
+
block is cut at 8,000 characters; one that throws is logged and left out.
|
|
213
|
+
- In a read-only space the assistant has none of the space's tools nor the plugins'.
|
|
214
|
+
|
|
215
|
+
### What the page shows
|
|
216
|
+
|
|
217
|
+
`studio.useAssistantPage` tells the assistant what the person sees: an open item, a selection,
|
|
218
|
+
a line on what the page holds, its fields. It goes up with every message, beside the page's
|
|
219
|
+
address and the trail of the top bar.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
studio.useAssistantPage({
|
|
223
|
+
open: product ? { kind: "product", id: product.id, label: product.title } : undefined,
|
|
224
|
+
selection: picked,
|
|
225
|
+
summary: `${products.length} products · ${withoutPrice} without a price`,
|
|
226
|
+
// A page of full-height tables keeps the assistant small, at the lower right.
|
|
227
|
+
compact: true,
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Tools in the page
|
|
232
|
+
|
|
233
|
+
`studio.useAssistantTool` gives the assistant a tool that runs in the browser while the page is
|
|
234
|
+
shown: it filters a list, opens an item, picks a tab. The model sees it as `<plugin>_<name>`;
|
|
235
|
+
`run` gets the arguments and returns what the assistant learns. It changes what the page shows,
|
|
236
|
+
never saves: saving stays with the server half's tools.
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
studio.useAssistantTool(
|
|
240
|
+
"filter_products",
|
|
241
|
+
{
|
|
242
|
+
description: "Shows only the products that match: without a price, of a source, by words.",
|
|
243
|
+
parameters: {
|
|
244
|
+
type: "object",
|
|
245
|
+
properties: {
|
|
246
|
+
missing: { type: "string", enum: ["price", "image"] },
|
|
247
|
+
query: { type: "string" },
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
({ missing, query }) => {
|
|
252
|
+
setFilter({ missing, query });
|
|
253
|
+
return { shown: count };
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Besides a page's tools the assistant can open a studio page, point at an element, read what is
|
|
259
|
+
on the screen, fill a field and scroll. It finds elements by their headings, labels and
|
|
260
|
+
buttons; `data-assist="<id>"` on an element names it for the assistant.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Starters
|
|
3
|
+
description: Wizards a plugin brings as templates — how to register one, where it shows, and what a wizard made from it gets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A starter is a wizard a plugin brings as a template. It stands beside the marketplace's starters
|
|
7
|
+
wherever a wizard is made, for the tenants that have the plugin.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
|
|
12
|
+
const read = (path: string) => readFileSync(wizards.resolvePath(path), "utf8");
|
|
13
|
+
|
|
14
|
+
server.registerStarter({
|
|
15
|
+
id: "book",
|
|
16
|
+
title: "Termin buchen",
|
|
17
|
+
description: "Fragt nach Anliegen und Wunschzeit und bucht einen freien Termin.",
|
|
18
|
+
definition: JSON.parse(read("starters/book.json")),
|
|
19
|
+
files: { "widget/slots.html": read("starters/slots.html") },
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Field | |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `id` | Lower case, digits and `-`, starting with a letter, at most 40 characters. Unique in the plugin |
|
|
26
|
+
| `title` | What the list of templates calls it |
|
|
27
|
+
| `description` | What it makes, in one or two sentences. Shown under the title |
|
|
28
|
+
| `language` | `"de"` or `"en"`, the language its texts are in. Default: `"de"` |
|
|
29
|
+
| `definition` | A complete wizard definition: the JSON the studio keeps and `get_authoring_guide` describes |
|
|
30
|
+
| `files` | Files of the wizard's workspace by path: widgets, sample data. A string is written as UTF-8, a `Uint8Array` as it is |
|
|
31
|
+
|
|
32
|
+
## Checked when it is registered
|
|
33
|
+
|
|
34
|
+
The definition is read as a wizard when `registerStarter` is called. A starter that is no wizard,
|
|
35
|
+
an id that is not allowed and an id registered twice throw, and the plugin does not load; the
|
|
36
|
+
error names the starter:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Starter "book": steps.2.fields: …
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Where it shows
|
|
43
|
+
|
|
44
|
+
The starter is known as `<plugin id>.<starter id>`: `appointments.book`. A marketplace entry's id
|
|
45
|
+
has no dot, so the two never meet.
|
|
46
|
+
|
|
47
|
+
| Where | |
|
|
48
|
+
|---|---|
|
|
49
|
+
| New wizard in the studio | First among the templates, with the plugin's name on its card. It cannot be starred: it is always there, also without a connection |
|
|
50
|
+
| `GET /api/studio/marketplace` | First on the first page, with `plugin: { id, name }` |
|
|
51
|
+
| MCP `list_starters`, `get_starter`, `create_wizard` | Listed first with `plugin`; `starterId` takes its id |
|
|
52
|
+
|
|
53
|
+
Only the tenants that have the plugin see it, by the same rule as its tools
|
|
54
|
+
([Which tenant has a plugin](./shipping.md#which-tenant-has-a-plugin)). Words and filters of a search find it by its title, its description
|
|
55
|
+
and the plugin's name.
|
|
56
|
+
|
|
57
|
+
## A wizard made from it
|
|
58
|
+
|
|
59
|
+
- gets a copy of the definition and the files; later changes of the starter do not reach it.
|
|
60
|
+
- keeps the starter's id in `starter`. `starterRevision` stays empty: the starter changes with
|
|
61
|
+
the plugin's version, not with a revision of its own.
|
|
62
|
+
- is not counted at the marketplace.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The studio half
|
|
3
|
+
description: Pages, icons in the app bar, sections of the settings and of the space page — written in React, built once, drawn inside the studio.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The studio half is `ui/plugin.tsx`. Its default export is a function; the studio calls it after
|
|
7
|
+
sign-in and hands it `studio`. What the plugin draws is part of the studio: the same React, the
|
|
8
|
+
same router, the same components.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { defineStudioPlugin } from "@engenty-wizards/plugin-sdk/studio";
|
|
12
|
+
import { Button, Card, Empty, Spinner } from "@engenty-wizards/web/ui";
|
|
13
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
14
|
+
import { Users } from "lucide-react";
|
|
15
|
+
|
|
16
|
+
interface Person {
|
|
17
|
+
id: number;
|
|
18
|
+
email: string;
|
|
19
|
+
name: string | null;
|
|
20
|
+
wizard: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const messages = {
|
|
24
|
+
de: {
|
|
25
|
+
title: "Kontakte",
|
|
26
|
+
hint: "Wer einen Wizard bis zum Ende durchlaufen hat.",
|
|
27
|
+
empty: "Noch keine Kontakte.",
|
|
28
|
+
remove: "Entfernen",
|
|
29
|
+
},
|
|
30
|
+
en: {
|
|
31
|
+
title: "Contacts",
|
|
32
|
+
hint: "Everyone who ran a wizard to its end.",
|
|
33
|
+
empty: "No contacts yet.",
|
|
34
|
+
remove: "Remove",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default defineStudioPlugin((studio) => {
|
|
39
|
+
const t = studio.i18n.register(messages);
|
|
40
|
+
|
|
41
|
+
function ContactsPage() {
|
|
42
|
+
const list = useQuery({
|
|
43
|
+
queryKey: ["contacts"],
|
|
44
|
+
queryFn: () => studio.api.get<{ contacts: Person[] }>("/"),
|
|
45
|
+
});
|
|
46
|
+
const cache = useQueryClient();
|
|
47
|
+
const remove = useMutation({
|
|
48
|
+
mutationFn: (id: number) => studio.api.del(`/${id}`),
|
|
49
|
+
onSuccess: () => cache.invalidateQueries({ queryKey: ["contacts"] }),
|
|
50
|
+
});
|
|
51
|
+
const admin = studio.me().tenant.role !== "member";
|
|
52
|
+
return (
|
|
53
|
+
<div>
|
|
54
|
+
<h1 className="font-display font-semibold text-[1.75rem] tracking-tight">{t("title")}</h1>
|
|
55
|
+
<p className="mt-1 text-[0.9375rem] text-ink-3">{t("hint")}</p>
|
|
56
|
+
<div className="mt-8 flex flex-col gap-2">
|
|
57
|
+
{list.isLoading ? <Spinner className="mx-auto" /> : null}
|
|
58
|
+
{list.data && !list.data.contacts.length ? <Empty>{t("empty")}</Empty> : null}
|
|
59
|
+
{list.data?.contacts.map((person) => (
|
|
60
|
+
<Card key={person.id} className="flex items-center gap-3 px-5 py-3.5">
|
|
61
|
+
<span className="min-w-0 flex-1 truncate font-medium text-[0.9375rem]">
|
|
62
|
+
{person.name ?? person.email}
|
|
63
|
+
</span>
|
|
64
|
+
<span className="text-[0.8125rem] text-ink-3 max-sm:hidden">{person.wizard}</span>
|
|
65
|
+
{admin ? (
|
|
66
|
+
<Button variant="ghost" size="sm" onClick={() => remove.mutate(person.id)}>
|
|
67
|
+
{t("remove")}
|
|
68
|
+
</Button>
|
|
69
|
+
) : null}
|
|
70
|
+
</Card>
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
studio.registerPage({ path: "/contacts", component: ContactsPage });
|
|
78
|
+
studio.registerNav({ to: "/contacts", label: () => t("title"), icon: Users });
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## What it registers
|
|
83
|
+
|
|
84
|
+
| Call | Adds |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `studio.registerPage({ path, component, wide? })` | A page of the studio at `/studio<path>`, inside the studio's frame. `path` takes `:name` parts. `wide`: the page lays out its own columns and takes the screen's width |
|
|
87
|
+
| `studio.registerNav({ to, label, icon })` | An icon in the app bar that opens a page |
|
|
88
|
+
| `studio.registerSettingsSection({ id, label, icon, component, menu? })` | A section of the settings at `/studio/settings/<id>`. `menu`: the user menu links to it directly |
|
|
89
|
+
| `studio.registerSpaceSection({ id, group?, label, hint?, component })` | A section of a part of the space page at `/studio/space/<group>#<id>`, below the part's own. See [The space](#the-space) |
|
|
90
|
+
| `studio.registerShareSection({ runner, component })` | A runner's own part of the share dialog, under its row once the runner is on for the wizard. See [Runners](./runners.md#the-runners-part-of-the-share-dialog) |
|
|
91
|
+
| `studio.registerAssistantCard({ tool, component })` | A card in the space assistant's chat for what a tool of the server half returned. See [The space](./space.md#a-card-in-the-chat) |
|
|
92
|
+
|
|
93
|
+
- The studio's own addresses are taken: `/new`, `/edit`, `/settings`, `/space`, `/setup`,
|
|
94
|
+
`/sign-in`.
|
|
95
|
+
- `label` is a function, since the language can change while the studio is open.
|
|
96
|
+
- `icon` is a component that takes `className`: any icon of `lucide-react`.
|
|
97
|
+
|
|
98
|
+
A settings section draws its own heading and cards:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
function ContactsSettings() {
|
|
102
|
+
return (
|
|
103
|
+
<section className="flex flex-col gap-2.5">
|
|
104
|
+
<h2 className="px-1 font-display font-semibold text-lg leading-tight">{t("title")}</h2>
|
|
105
|
+
<Card className="p-5 text-[0.875rem] text-ink-2">…</Card>
|
|
106
|
+
</section>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
studio.registerSettingsSection({
|
|
111
|
+
id: "contacts",
|
|
112
|
+
label: () => t("title"),
|
|
113
|
+
icon: Users,
|
|
114
|
+
component: ContactsSettings,
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## The space
|
|
119
|
+
|
|
120
|
+
A space holds what all its wizards share: a title, logos, colours, facts and Wissen. The
|
|
121
|
+
space page, behind the space's tile in the app bar, shows them in four parts:
|
|
122
|
+
|
|
123
|
+
| Part | `group` | Holds |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| Info & Marke | `info` | Basis, Logos, Farben, Assets, Fakten |
|
|
126
|
+
| Wissen | `knowledge` | Pages, tables and files with their Kategorien: what every AI step looks things up in |
|
|
127
|
+
| Daten | `data` | What the wizards keep |
|
|
128
|
+
| Ergebnisse | `results` | The runs that reached their result |
|
|
129
|
+
|
|
130
|
+
A plugin adds a section to one of them, below the part's own:
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
function ContactsOfSpace() {
|
|
134
|
+
const space = studio.useSpace();
|
|
135
|
+
const list = useQuery({
|
|
136
|
+
queryKey: ["contacts", space?.id],
|
|
137
|
+
queryFn: () => studio.api.get<{ contacts: Person[] }>(`/?space=${space?.id}`),
|
|
138
|
+
enabled: Boolean(space),
|
|
139
|
+
});
|
|
140
|
+
return <Card className="p-5 text-[0.875rem] text-ink-2">…</Card>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
studio.registerSpaceSection({
|
|
144
|
+
id: "contacts",
|
|
145
|
+
group: "data",
|
|
146
|
+
label: () => t("title"),
|
|
147
|
+
hint: () => t("hint"),
|
|
148
|
+
component: ContactsOfSpace,
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- `group` is the part; without one the section stands under Wissen.
|
|
153
|
+
- The studio draws the heading and the hint above the section, as it does for the space's own,
|
|
154
|
+
and lists the section in the part's menu under the plugin's name. The component draws the
|
|
155
|
+
rest, usually a `Card`.
|
|
156
|
+
- `id` is the section's anchor: `/studio/space/data#contacts` opens the page there, and so does
|
|
157
|
+
`/studio/space#contacts`. In Wissen a section is a page of its own:
|
|
158
|
+
`/studio/space/knowledge?show=s:<id>`, where `#<id>` leads too. Ids are unique on the whole page; the space's own are taken: `base`,
|
|
159
|
+
`logos`, `colors`, `assets`, `documents`, `facts`.
|
|
160
|
+
- `studio.useSpace()` is a hook: `{ id, name, readOnly }`, or `null` while there is none. A
|
|
161
|
+
component that calls it draws again when the person picks another space. `readOnly`: the
|
|
162
|
+
space came from a local install, or nothing is built on this runtime; show it, change nothing.
|
|
163
|
+
- Every wizard belongs to a space: a [run event](./events.md) names it as
|
|
164
|
+
`wizard.projectId`. Keep it with what the plugin stores to show a space's part of it.
|
|
165
|
+
|
|
166
|
+
## Words in two languages
|
|
167
|
+
|
|
168
|
+
The studio speaks German and English. `studio.i18n.register` takes the plugin's words and gives
|
|
169
|
+
the function that reads them in the language in effect:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const t = studio.i18n.register({
|
|
173
|
+
de: { count: "{n} Kontakte sind gespeichert." },
|
|
174
|
+
en: { count: "{n} contacts are kept." },
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
t("count", { n: 12 });
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- `de` is the source: a key missing in `en` shows the German.
|
|
181
|
+
- `{name}` in a text is filled from the second argument.
|
|
182
|
+
- `studio.i18n.lang()` is `"de"` or `"en"`, for dates and numbers:
|
|
183
|
+
`new Date(at).toLocaleString(studio.i18n.lang())`.
|
|
184
|
+
|
|
185
|
+
## The plugin's own routes
|
|
186
|
+
|
|
187
|
+
`studio.api` calls the routes the server half registered, signed in as the person:
|
|
188
|
+
|
|
189
|
+
| Call | Asks |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `studio.api.get<T>(path)` | `GET /api/studio/plugins/<id><path>` |
|
|
192
|
+
| `studio.api.post<T>(path, body?)` | `POST`, the body as JSON |
|
|
193
|
+
| `studio.api.put<T>(path, body?)`, `studio.api.patch<T>(path, body?)` | `PUT`, `PATCH` |
|
|
194
|
+
| `studio.api.del<T>(path)` | `DELETE` |
|
|
195
|
+
|
|
196
|
+
Each gives the parsed JSON. Use them with `useQuery` and `useMutation`, as the page above does.
|
|
197
|
+
|
|
198
|
+
## The person
|
|
199
|
+
|
|
200
|
+
`studio.me()` is the signed-in person:
|
|
201
|
+
|
|
202
|
+
| | |
|
|
203
|
+
|---|---|
|
|
204
|
+
| `user` | `{ id, name, email }` |
|
|
205
|
+
| `tenant` | `{ id, role }`, the role `owner`, `admin` or `member` |
|
|
206
|
+
| `mode` | `"local"`: the runtime runs alone. `"managed"`: signed in at a Manage-App |
|
|
207
|
+
|
|
208
|
+
Hide what a member may not do, and guard it on the server too with `role: "admin"` on the
|
|
209
|
+
route.
|
|
210
|
+
|
|
211
|
+
## Build it
|
|
212
|
+
|
|
213
|
+
The studio half is built to two files, `dist/client.js` and `dist/client.css`. The build needs
|
|
214
|
+
a checkout of the repository, since it uses the studio's own tools:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
node scripts/build-plugin.mjs <plugin folder>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
node scripts/build-plugin.mjs <plugin folder> --watch
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The plugin's folder may be anywhere, also outside the checkout. With `--watch` the files are
|
|
225
|
+
built again on every save, and an open studio takes them in place.
|
|
226
|
+
|
|
227
|
+
Ship `dist/` with the plugin: an install without a checkout cannot build it.
|
|
228
|
+
|
|
229
|
+
## What the studio shares
|
|
230
|
+
|
|
231
|
+
These imports are not in `client.js`. The script takes them from the studio that loads it, so
|
|
232
|
+
there is one React and one router on the page:
|
|
233
|
+
|
|
234
|
+
| Import | What a plugin gets of it |
|
|
235
|
+
|---|---|
|
|
236
|
+
| `react`, `react/jsx-runtime` | All of it |
|
|
237
|
+
| `react-dom` | `createPortal`, `flushSync` |
|
|
238
|
+
| `react-router` | `Link`, `NavLink`, `Navigate`, `useNavigate`, `useParams`, `useLocation`, `useSearchParams` |
|
|
239
|
+
| `@tanstack/react-query` | `useQuery`, `useMutation`, `useQueryClient` |
|
|
240
|
+
| `@engenty-wizards/web/ui` | The studio's components, see [Styles and components](./styling.md) |
|
|
241
|
+
| `@engenty-wizards/plugin-sdk/studio` | `defineStudioPlugin` and the types |
|
|
242
|
+
|
|
243
|
+
Everything else a plugin imports is bundled into `client.js`. A package the plugin's folder
|
|
244
|
+
does not have, such as `lucide-react`, comes from the studio's.
|
|
245
|
+
|
|
246
|
+
## Undo on reload
|
|
247
|
+
|
|
248
|
+
The studio half loads again when its built files change. Pages, icons and sections, also those
|
|
249
|
+
of the space page, are taken back for it. Anything else it started, it undoes itself:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
const timer = setInterval(refresh, 30_000);
|
|
253
|
+
studio.onUnload(() => clearInterval(timer));
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## When it fails
|
|
257
|
+
|
|
258
|
+
- A studio half that throws while it loads registers nothing. Settings → Plugins says "The
|
|
259
|
+
studio half did not load" with the reason. The server half keeps working.
|
|
260
|
+
- A page or section that throws while it draws shows "This part of a plugin crashed" in its
|
|
261
|
+
place. The rest of the studio stays up.
|