@engenty/wizards-runtime 0.9.3 → 0.9.4

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.
Files changed (109) hide show
  1. package/README.md +34 -39
  2. package/apps/runtime/dist/assistant/docs.js +1 -1
  3. package/apps/runtime/dist/assistant/primer.js +2 -2
  4. package/apps/runtime/dist/db/migrations/tenant/0020_project_page.sql +1 -0
  5. package/apps/runtime/dist/db/migrations/tenant/meta/0020_snapshot.json +3475 -0
  6. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  7. package/apps/runtime/dist/db/schema.js +2 -0
  8. package/apps/runtime/dist/docs/dev/api.md +1 -1
  9. package/apps/runtime/dist/docs/dev/integration/channels.md +4 -4
  10. package/apps/runtime/dist/docs/dev/integration/claude-code-plugin.md +1 -1
  11. package/apps/runtime/dist/docs/dev/integration/embed.md +1 -1
  12. package/apps/runtime/dist/docs/dev/integration/index.md +2 -3
  13. package/apps/runtime/dist/docs/dev/integration/link-and-share.md +1 -1
  14. package/apps/runtime/dist/docs/dev/integration/mcp-apps.md +1 -1
  15. package/apps/runtime/dist/docs/dev/integration/mcp.md +1 -1
  16. package/apps/runtime/dist/docs/dev/integration/meta.json +0 -1
  17. package/apps/runtime/dist/docs/dev/integration/openui.md +1 -1
  18. package/apps/runtime/dist/docs/dev/integration/results.md +1 -3
  19. package/apps/runtime/dist/docs/dev/plugins/routes.md +1 -1
  20. package/apps/runtime/dist/docs/dev/wizard-format/themes.md +2 -2
  21. package/apps/runtime/dist/docs/dev/wizard-format/validate.md +1 -1
  22. package/apps/runtime/dist/docs/meta.json +1 -1
  23. package/apps/runtime/dist/docs/{user → user-guide}/ai-apps.md +4 -5
  24. package/apps/runtime/dist/docs/{user → user-guide}/build-a-wizard.md +27 -28
  25. package/apps/runtime/dist/docs/{user → user-guide}/command-line.md +9 -8
  26. package/apps/runtime/dist/docs/{user → user-guide}/connectors.md +6 -6
  27. package/apps/runtime/dist/docs/{user → user-guide}/create-account.md +10 -11
  28. package/apps/runtime/dist/docs/{user → user-guide}/data.md +5 -5
  29. package/apps/runtime/dist/docs/{user → user-guide}/first-start.md +5 -5
  30. package/apps/runtime/dist/docs/{user → user-guide}/index.md +3 -3
  31. package/apps/runtime/dist/docs/{user → user-guide}/install.md +21 -25
  32. package/apps/runtime/dist/docs/{user → user-guide}/local-only.md +5 -6
  33. package/apps/runtime/dist/docs/{user → user-guide}/meta.json +0 -2
  34. package/apps/runtime/dist/docs/{user → user-guide}/models.md +13 -22
  35. package/apps/runtime/dist/docs/{user → user-guide}/plugins.md +2 -2
  36. package/apps/runtime/dist/docs/{user → user-guide}/run.md +21 -36
  37. package/apps/runtime/dist/docs/{user → user-guide}/server.md +1 -1
  38. package/apps/runtime/dist/docs/{user → user-guide}/space.md +17 -27
  39. package/apps/runtime/dist/docs/{user → user-guide}/steps.md +22 -34
  40. package/apps/runtime/dist/docs/{user → user-guide}/test-and-share.md +32 -75
  41. package/apps/runtime/dist/docs/{user → user-guide}/troubleshooting.md +3 -4
  42. package/apps/runtime/dist/manage.js +7 -0
  43. package/apps/runtime/dist/routes/studio.js +12 -0
  44. package/apps/runtime/dist/services/errors.js +1 -0
  45. package/apps/runtime/dist/services/pages.js +262 -0
  46. package/apps/runtime/dist/services/projects.js +73 -2
  47. package/apps/runtime/dist/services/runs.js +2 -0
  48. package/apps/runtime/dist/services/wizards.js +30 -1
  49. package/apps/web/dist/assets/{AboutDialog-DsGqq2Es.js → AboutDialog-CsqUDxPv.js} +1 -1
  50. package/apps/web/dist/assets/{ChangelogDialog-Hn7oDuyx.js → ChangelogDialog-vV9nXOBV.js} +1 -1
  51. package/apps/web/dist/assets/EditorPage-CfmubDLB.js +4 -0
  52. package/apps/web/dist/assets/{FlowPreview-DZ1XL_o1.js → FlowPreview-DoBlokAp.js} +1 -1
  53. package/apps/web/dist/assets/{Harness-BBpl_EUW.js → Harness-GnlSI4-P.js} +2 -2
  54. package/apps/web/dist/assets/Marketplace-CYsq0K7A.js +2 -0
  55. package/apps/web/dist/assets/NewWizardChannels-DUS3dRCj.js +1 -0
  56. package/apps/web/dist/assets/{NewWizardPage-kpm-UyQC.js → NewWizardPage-Cm9ydfUW.js} +2 -2
  57. package/apps/web/dist/assets/OnboardingPage-xI83C1V1.js +1 -0
  58. package/apps/web/dist/assets/PreviewPane-B-X0rChi.js +4 -0
  59. package/apps/web/dist/assets/ProjectPage-Bu6uD-Kb.js +1 -0
  60. package/apps/web/dist/assets/PublicRunner-BWBE74Kn.js +1 -0
  61. package/apps/web/dist/assets/{ReadOnly-CcW91P4l.js → ReadOnly-DKgWZ_1q.js} +1 -1
  62. package/apps/web/dist/assets/SettingsPage-B9euFl71.js +2 -0
  63. package/apps/web/dist/assets/SetupPage-C3XLbBTO.js +1 -0
  64. package/apps/web/dist/assets/{SharePage-CC7V2TYJ.js → SharePage-CSj1sAVS.js} +1 -1
  65. package/apps/web/dist/assets/changelog-pnMcOVO_.js +1 -0
  66. package/apps/web/dist/assets/{coins-RUupcqZx.js → coins-D0MI0EKw.js} +1 -1
  67. package/apps/web/dist/assets/index-DtjKnB3s.css +1 -0
  68. package/apps/web/dist/assets/index-qc7o4bkp.js +14 -0
  69. package/apps/web/dist/assets/{phone-ChnpShTU.js → phone-BZ-sPZr6.js} +1 -1
  70. package/apps/web/dist/assets/runners-CED2yPuf.js +1 -0
  71. package/apps/web/dist/assets/session-DyndueX0.js +2 -0
  72. package/apps/web/dist/assets/{settings-menu-CLw_oucZ.js → settings-menu-C960R1kx.js} +1 -1
  73. package/apps/web/dist/assets/theme-Zp5g-teI.js +11 -0
  74. package/apps/web/dist/assets/ui-DVkIZqDg.js +137 -0
  75. package/apps/web/dist/assets/{upload-0sFU9K8-.js → upload-HFTtsOaE.js} +1 -1
  76. package/apps/web/dist/assets/{useMutation-1jFwXbI6.js → useMutation-D3zIOVOt.js} +1 -1
  77. package/apps/web/dist/assets/{volume-2-C51sO2X0.js → volume-2-DazUIp6w.js} +1 -1
  78. package/apps/web/dist/assets/{wrench-DdT-nErU.js → wrench-BHe19Ol_.js} +1 -1
  79. package/apps/web/dist/index.html +8 -8
  80. package/apps/web/dist/mcp/flow.html +2 -2
  81. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +3 -3
  82. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +12 -0
  83. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +12 -0
  84. package/node_modules/@engenty/wizards-shared/dist/projects.d.ts +36 -0
  85. package/node_modules/@engenty/wizards-shared/dist/projects.js +25 -0
  86. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  87. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  88. package/package.json +1 -1
  89. package/plugin/.claude-plugin/plugin.json +1 -1
  90. package/plugin/plugin.json +2 -2
  91. package/apps/runtime/dist/docs/dev/integration/wordpress.md +0 -10
  92. package/apps/runtime/dist/docs/user/assistant.md +0 -77
  93. package/apps/runtime/dist/docs/user/wordpress.md +0 -121
  94. package/apps/web/dist/assets/EditorPage-DsJqhoXy.js +0 -4
  95. package/apps/web/dist/assets/Marketplace-BF0Rx0VR.js +0 -2
  96. package/apps/web/dist/assets/NewWizardChannels-WaAOvmzw.js +0 -1
  97. package/apps/web/dist/assets/OnboardingPage-Birm-hM5.js +0 -1
  98. package/apps/web/dist/assets/ProjectPage-CqtpxOq5.js +0 -1
  99. package/apps/web/dist/assets/PublicRunner-CXTHGYHv.js +0 -1
  100. package/apps/web/dist/assets/RunDrawer-ByvmBv6e.js +0 -4
  101. package/apps/web/dist/assets/RunnerView-DcduYZly.js +0 -1
  102. package/apps/web/dist/assets/SettingsPage-Q2CUb7kK.js +0 -2
  103. package/apps/web/dist/assets/SetupPage-C7mzUoiR.js +0 -1
  104. package/apps/web/dist/assets/changelog-7DN_qWR2.js +0 -1
  105. package/apps/web/dist/assets/index-myC3mJie.css +0 -1
  106. package/apps/web/dist/assets/index-qnpoZzuw.js +0 -14
  107. package/apps/web/dist/assets/session-DekDyd9S.js +0 -2
  108. package/apps/web/dist/assets/theme-DjpqxoRe.js +0 -11
  109. package/apps/web/dist/assets/ui-DRYauuxF.js +0 -137
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Test and share
3
3
  description: Try the wizard, publish it, and hand out its link or put it on a website.
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  ---
6
6
 
7
7
  ## Test
@@ -17,8 +17,8 @@ runs it is measured from the latest ones.
17
17
  ## Publish
18
18
 
19
19
  A wizard goes live the first time you share it. “Share” publishes the draft as version 1 as the
20
- dialog opens, and the dialog says “Published when you shared it”. Nobody has the link yet, and
21
- “Only you” under “Access” keeps it closed. A draft with issues is not published: the dialog lists
20
+ dialog opens, and the dialog says “Published when you shared it”. Nobody has the link until you hand it
21
+ out, and “Only you” under “Access” switches it off. A draft with issues is not published: the dialog lists
22
22
  what to fix first, with “Let the assistant fix it”.
23
23
 
24
24
  After that, the editor’s top bar shows “Publish changes” whenever the draft differs from the
@@ -40,7 +40,7 @@ the first share. The editor’s top bar and the wizard’s card on the start pag
40
40
  | “Live · 1 note” | It runs in the cloud, but one step does less there (see “Share”) |
41
41
  | “Local” | It is published on your computer without an account. The link only answers on this computer, while engenty wizards is running |
42
42
  | “On its way to the cloud” | The version hasn’t arrived on engenty.ai yet. The studio tries again by itself |
43
- | “Not in the cloud” | engenty.ai doesn’t run this version. “Share” says why and what helps |
43
+ | “Not in the cloud” | engenty.ai runs no version of it. “Share” says why and what helps. If an older version still runs there, the chip shows that version in amber with a crossed-out cloud |
44
44
 
45
45
  On a card, “Link” copies the address others can open, and the arrow opens it. A wizard that
46
46
  runs only on this computer has no address for others. Its “Link” says so and explains how an
@@ -53,78 +53,38 @@ The ⋯ menu on a card and in the editor has “Duplicate”, “Export as a wiz
53
53
 
54
54
  “Share” says who may open the wizard and how others reach it, and it copies the link.
55
55
 
56
+ ![The share dialog with numbered parts: Access, How others reach it, QR code, Website, Copy link and the settings gear. On this computer without an account, a box above offers “Sign in” and “Create account”](../../assets/guide-share.png)
57
+
56
58
  | Part | Does |
57
59
  |---|---|
58
- | Access | With “Anyone with the link”, anyone can open and fill it in, up to the runs a day set under “Settings”. “Only you” switches the link off: everyone else sees a notice, and you test in the studio |
59
- | How others reach it | The channels the wizard runs as (see below), grouped by kind: in the browser, on the phone, by message. A browser channel has its own link, and a message channel its keyword and number. Each row copies its own. “Change” lets you choose the channels, from the same list as for a new wizard |
60
- | QR code | One of the links as a QR code to download or print, and the wizard’s ID for the mobile app |
61
- | Website | The code for a website (see below). For WordPress, it offers the plugin, or the wizard as a package that runs without an account, with what it lacks there: see [WordPress](./wordpress.md#without-an-account) |
62
- | Copy link | The link people open. It opens the first browser channel, and the wizard offers the others on its first page |
63
- | Settings (the gear) | “Limit per day” (50 runs unless you change it, with what that costs at most), each message channel’s keyword, and “Create a new link”: the old link and its QR code stop working, in the cloud too |
64
-
65
- Where the draft has changes, the dialog says so at the top and leads to “Publish changes”.
60
+ | 1 · Access | With “Anyone with the link”, anyone can open and fill it in, up to the runs a day set under “Settings”. “Only you” switches the link off: everyone else sees a notice, and you test in the studio |
61
+ | 2 · How others reach it | The ways the wizard runs (see below). Each row copies its own link. “Change” lets you choose them, from the same list as for a new wizard |
62
+ | 3 · QR code | One of the links as a QR code to download or print |
63
+ | 4 · Website | The code for a website (see below) |
64
+ | 5 · Copy link | The link people open. It opens the first way that is on, and the wizard offers the other on its first page |
65
+ | 6 · Settings (the gear) | “Limit per day” (50 runs unless you change it, with what that costs at most), “Offer a translation” (a machine translation per language, which you can edit), and “Create a new link”: the old link and its QR code stop working, in the cloud too |
66
+
67
+ The picture is from a computer without an account: the box at the top offers “Sign in” and
68
+ “Create account”, and “Access” says “Only on this computer” (see
69
+ [Who can open the link](#who-can-open-the-link)). Where the draft has changes, the dialog says so
70
+ at the top and leads to “Publish changes”.
66
71
 
67
72
  One visitor can start 6 runs an hour.
68
73
 
69
- ### Channels
70
-
71
- A wizard can run page by page or as a chat. Where this studio offers them, it can also run as a
72
- live conversation on top of the chat, or as a video call on a stage with the chat beside it. In
73
- a conversation or a call, the person talks, and the wizard talks back and sees the camera. For
74
- now, both need an OpenAI API key under Models. A plugin can add further ways, such as a kiosk
75
- page or a messenger.
74
+ ### Page by page or as a chat
76
75
 
77
- A wizard you start on the “New wizard” page runs step by step unless you choose more under “How
76
+ A wizard can run page by page or as a chat. A wizard you start on the “New wizard” page runs step by step unless you choose more under “How
78
77
  should it run?”. A wizard without its own choice, such as one from a template or an import, has
79
- the step-by-step page and the chat switched on. You can change the channels later under “Change”
80
- in the share dialog.
81
-
82
- Where a channel can’t take a step, the step goes to the wizard’s page. The person gets a link for
83
- a photo, a signature or a sign-in, and comes back afterwards. If nobody can hand a step off (for
84
- example, one that takes minutes on a channel that can’t wait), the row shows “Not possible: …”
85
- under the channel’s name. A channel that still needs something says so in its row:
86
-
87
- | The row says | What you can do |
88
- |---|---|
89
- | “Not set up yet” | “Set up” opens the channel’s settings inside the dialog. “Back” returns to the rows |
90
- | “Waiting” | Nothing for now. The channel is waiting for something, for example a number that was requested |
91
- | “Not in your plan” | “See {plan}” or “See the plans” shows the plan that has it |
78
+ the step-by-step page and the chat switched on. You can change that later under “Change” in the
79
+ share dialog.
92
80
 
93
- The cards on the start page show the channels that are on as small icons, the link’s channel
94
- first. Once wizards with two or more statuses are in the space, a row of pills above the cards
81
+ The cards on the start page show the ways that are on as small icons, the link’s own first. Once wizards with two or more statuses are in the space, a row of pills above the cards
95
82
  narrows them to one status: “Draft”, “Local”, “Live” or “Not in the cloud”.
96
83
 
97
- The link opens the first browser channel that is on. The others answer under their own address
98
- (`/steps`, `/chat`, `/talk` for live voice, `/video` for the video call) and are offered on the
99
- wizard’s first page, for example “Or: Chat”. An address that is switched off sends people to
84
+ The link opens the first way that is on. The other answers under its own address (`/steps` or
85
+ `/chat`) and is offered on the wizard’s first page, for example “Or: Chat”. An address that is switched off sends people to
100
86
  the link instead.
101
87
 
102
- ### WhatsApp, SMS and calls
103
-
104
- On engenty.ai a wizard can also run in a WhatsApp chat, by text message and as a phone call,
105
- where the team’s plan includes them. These channels are not part of the open source engenty
106
- wizards. On your computer, you get them through your account in the cloud.
107
-
108
- When you switch one on for a wizard, its row in the share dialog shows the number and the
109
- **keyword**. Whoever sends the keyword to the number starts the wizard. “Link” copies a link that
110
- writes the message, and the QR code view draws it. You change the keyword under “Settings”.
111
-
112
- - **WhatsApp**: one field per message, buttons for up to three choices and a list for more. The
113
- person sends a photo or a file in the chat, “send location” for a place, and a voice message
114
- for a text field. A free message can go out within 24 hours of the person’s last one. A wizard
115
- that finishes later reaches back with an approved template, or waits for the person’s next
116
- message.
117
- - **SMS**: text only. Choices come as numbered lines, answered with the number, and a place as a
118
- typed address. Long texts come as their gist, and every picture, document and the whole result
119
- as links.
120
- - **Calls**: the speech model talks, as the chat’s live voice does. It asks for one field at a
121
- time, reads out the choices and reads email addresses and numbers back. If several wizards are
122
- on for calls, the call first asks which one.
123
-
124
- What a channel can’t take (a signature or a sign-in, and by text or phone also a photo or a
125
- file) arrives as a link to the wizard’s page. The conversation goes on once it has been filled in
126
- there. “stop” ends a run in a chat, and the keyword starts a new one.
127
-
128
88
  ### Who can open the link
129
89
 
130
90
  engenty wizards on your computer only answers on `localhost`. The link works on that computer,
@@ -137,8 +97,7 @@ not for anyone else. To let others run the wizard:
137
97
 
138
98
  ### In the cloud
139
99
 
140
- Once you sign in to an account under Settings → Account, every version that goes live also
141
- arrives on engenty.ai. Your avatar then carries a small cloud, and its menu says “Connected to
100
+ Once you sign in to an account under Settings → Account, your avatar carries a small cloud, and its menu says “Connected to
142
101
  engenty.ai” with your credits. The share dialog gives the wizard’s address at engenty.ai, which
143
102
  stays the same when you publish again. Where the cloud doesn’t run this version, the dialog says
144
103
  so at the top:
@@ -150,7 +109,7 @@ so at the top:
150
109
 
151
110
  Without an account, the dialog says that the wizard runs only on this computer (“Only on this
152
111
  computer” under “Access”). It greys out the ways others reach it and offers “Sign in” and “Create
153
- account”. “Website” still gives you the WordPress package.
112
+ account”.
154
113
 
155
114
  What goes to the cloud and what stays:
156
115
 
@@ -158,8 +117,8 @@ What goes to the cloud and what stays:
158
117
  |---|---|
159
118
  | The published version and its files | Drafts and the chat with the assistant |
160
119
  | The space’s name, what it says about itself, its colours, facts and logo | Runs and results on your computer |
161
- | The space’s own tables and pages | What the wizards keep: their lists and notes |
162
- | How the link is shared: on or off, runs a day, channels | Connected accounts, keys, the space’s knowledge and its connected systems |
120
+ | The pages and tables of Knowledge, with their categories | What the wizards keep: their lists and notes |
121
+ | How the link is shared: on or off, runs a day, page or chat | Connected accounts, keys, the space’s documents and its connected systems |
163
122
 
164
123
  At engenty.ai/studio you see the space and its runs there. A small laptop icon marks the space,
165
124
  and a note says “You edit this space in engenty wizards on your computer.” The studio there
@@ -195,7 +154,9 @@ has both the step-by-step page and the chat on, you first choose what the websit
195
154
  <script async src="https://example.com/embed.js" data-wizard="TOKEN" data-mode="bubble" data-label="Questions?" data-text="A quote in 2 minutes"></script>
196
155
  ```
197
156
 
198
- The code only works once the wizard is published and open to anyone with the link. A chat in the
157
+ The dialog gives the code once the wizard is published, open to anyone with the link, and
158
+ reachable by others: on your computer that takes an account (see
159
+ [Who can open the link](#who-can-open-the-link)). Until then it says so instead. A chat in the
199
160
  page that is switched off for the wizard shows the step-by-step page instead. The chat button
200
161
  always opens the chat.
201
162
 
@@ -212,9 +173,6 @@ Your website’s own styles reach the button through the class `engenty-wizard-b
212
173
  button through `engenty-wizard-launcher` and the bubble through `engenty-wizard-bubble`. A page
213
174
  shows only one bubble: a second bubble tag does nothing.
214
175
 
215
- On WordPress the plugin writes this code for you, and its results show the page: see
216
- [WordPress](./wordpress.md).
217
-
218
176
  ## Results people share
219
177
 
220
178
  On the result page, a person can share what they got as a link. The result of a run over the
@@ -224,5 +182,4 @@ website: see [Share a result](./run.md#share-a-result).
224
182
 
225
183
  ## Move a wizard
226
184
 
227
- Export it as a wizard file (`.wizard`) from its ⋯ menu, and import it in another studio or in
228
- the WordPress plugin. See [Build a wizard](./build-a-wizard.md#take-it-with-you).
185
+ Export it as a wizard file (`.wizard`) from its ⋯ menu, and import it in another studio. See [Build a wizard](./build-a-wizard.md#take-it-with-you).
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Troubleshooting
3
3
  description: What to do when a link no longer works, a client shows as not signed in, or an export fails.
4
- version: 0.5.0
4
+ version: 0.9.3
5
5
  ---
6
6
 
7
7
  `wizards doctor` checks engenty wizards on your computer and says what is wrong. Start there.
@@ -35,16 +35,15 @@ version: 0.5.0
35
35
 
36
36
  | What you see | What to do |
37
37
  |---|---|
38
- | PDF or PNG export, or a step on a website, fails | `wizards doctor` names the browser engenty wizards uses. Install Chrome, Edge or Chromium (on a Mac also Brave), or set `CHROME_PATH` to one; see [Settings](./command-line.md#settings) |
38
+ | PDF or PNG export, or a step on a website, fails | `wizards doctor` names the browser engenty wizards uses. Install Chrome, Edge or Chromium (on a Mac and on Windows also Brave), or set `CHROME_PATH` to one; see [Settings](./command-line.md#settings) |
39
39
  | A widget offers no video | Install ffmpeg, or set `FFMPEG_PATH` |
40
40
  | “This wizard isn’t available right now.” | The link is switched off, or the account the wizard runs on has no credits left. See [Test and share](./test-and-share.md) |
41
41
  | “This wizard has reached its limit for today. Try again tomorrow.” | The link’s runs for the day are used up; the day starts at midnight UTC. Raise “Limit per day” under Settings (the gear) in the share dialog |
42
42
  | “You’ve started a lot of runs just now. Try again in an hour.” | One visitor started more runs in an hour than the link allows (`LIMIT_VISITOR_RUNS_PER_HOUR`, see [Settings](./command-line.md#settings)) |
43
43
  | “This wizard doesn’t exist or was deleted.” | It is not published, or its link was replaced by a new one |
44
44
  | Others can’t open the link | engenty wizards on your computer answers on `localhost` only. See [who can open the link](./test-and-share.md#who-can-open-the-link) |
45
- | The chat has no phone button, or “Join” stays grey | A live conversation needs “Live voice” or “Video call” switched on for the wizard (see [Channels](./test-and-share.md#channels); your own test run always has it) and an OpenAI API key under Settings → Models |
46
45
  | The camera, microphone or location doesn’t work | Allow it in the browser’s site settings (the lock icon in the address bar) |
47
- | A connector says “not set up” | engenty wizards needs an OAuth client for it. See [Connectors](./connectors.md) |
46
+ | A built-in connector is missing from Settings → Connectors | It needs an OAuth client in the settings file. See [Connectors](./connectors.md) |
48
47
  | A step stops at a plugin’s tool | That plugin is not installed here. See [Plugins](./plugins.md) |
49
48
 
50
49
  ## Updating
@@ -223,6 +223,13 @@ export async function withdrawChannelRequest(id) {
223
223
  export function bookChannelUsage(id, input) {
224
224
  return call("POST", `/v1/tenants/${encodeURIComponent(id)}/channels/usage`, input);
225
225
  }
226
+ /**
227
+ * The team's public page data, whole (services/pages.ts): Manage keeps it and serves the page at
228
+ * `<slug>.<PAGES_DOMAIN>`. What it answers names the page's address.
229
+ */
230
+ export function putPages(tenantId, data) {
231
+ return call("PUT", `/v1/pages/${encodeURIComponent(tenantId)}`, data);
232
+ }
226
233
  /** A push to the mobile app on one device; the Manage-App holds the APNs and FCM keys. */
227
234
  export function pushToDevice(input) {
228
235
  return call("POST", "/v1/push", input);
@@ -51,6 +51,7 @@ import { categoryContents, listKnowledge, resolvePath, valueContents, } from "..
51
51
  import { writeSummary } from "../services/knowledge-model.js";
52
52
  import { applyWebsite, finishOnboarding, needsOnboarding } from "../services/onboarding.js";
53
53
  import { exportWizard, importWizard } from "../services/package.js";
54
+ import { pagePreview } from "../services/pages.js";
54
55
  import { profileSchema, saveProfile, saveUserLang, userLang, userProfile, } from "../services/profile.js";
55
56
  import { addProjectFile, addProjectFileFromUrl, fileView, orderProjectFiles, projectFile, projectFileContent, projectFiles, reindexProjectFile, removeProjectFile, updateProjectFile, } from "../services/project-files.js";
56
57
  import { documentText, queueIndex, searchKnowledge } from "../services/project-index.js";
@@ -236,6 +237,10 @@ export const studio = new Hono()
236
237
  role: user.role,
237
238
  /** The plan the team is on; null alone, or where the Manage-App names none. */
238
239
  plan: info?.plan ?? null,
240
+ /** The team's address for its public page (`acme.wizards.page`); null alone, or behind its switch. */
241
+ pagesHost: feature("pages", { ...info?.features, ...person?.features })
242
+ ? (info?.pagesHost ?? null)
243
+ : null,
239
244
  },
240
245
  /** The feature switches: the code's defaults, what the Manage-App says of the team and the person, this install's file. */
241
246
  features: features(managed ? { ...info?.features, ...person?.features } : overview?.tenant.features),
@@ -508,6 +513,8 @@ export const studio = new Hono()
508
513
  name: p.name,
509
514
  brand: p.brand,
510
515
  facts: p.facts,
516
+ /** The space's public page; null until it is set up. */
517
+ page: p.page ?? null,
511
518
  mcpServers: maskedServers(p),
512
519
  wizardCount: p.wizardCount,
513
520
  /** `local`: synced from a local install, where it is changed. */
@@ -524,6 +531,11 @@ export const studio = new Hono()
524
531
  const patch = projectPatchSchema.parse(await c.req.json());
525
532
  await updateProject(c.get("user").id, c.req.param("id"), patch);
526
533
  return c.json({ ok: true });
534
+ })
535
+ // The team's public page as Manage will draw it, for the preview beside the page's fields.
536
+ .get("/projects/:id/page", async (c) => {
537
+ await ownedProject(c.get("user").id, c.req.param("id"));
538
+ return c.json(await pagePreview());
527
539
  })
528
540
  // --- the space's themes: how its wizards' pages look (docs/plans/themes.md) ---
529
541
  .get("/projects/:id/themes", async (c) => c.json(await listThemes(c.get("user").id, c.req.param("id"))))
@@ -7,6 +7,7 @@ const STATUS = {
7
7
  revision_conflict: 409,
8
8
  no_credits: 402,
9
9
  refused: 400,
10
+ page_taken: 409,
10
11
  read_only: 403,
11
12
  forbidden: 403,
12
13
  };
@@ -0,0 +1,262 @@
1
+ import { langOf, wizardLang, } from "@engenty/wizards-shared/definition";
2
+ import { effortOf } from "@engenty/wizards-shared/marketplace";
3
+ import { resultsOf } from "@engenty/wizards-shared/marketplace-entry";
4
+ import { factType, pageSlugOf, runTheme, } from "@engenty/wizards-shared/projects";
5
+ import { and, eq, inArray } from "drizzle-orm";
6
+ import { db, schema } from "../db/client.js";
7
+ import { env } from "../env.js";
8
+ import { feature } from "../features.js";
9
+ import { managed, putPages, tenantInfo } from "../manage.js";
10
+ import { currentTenant } from "../tenants/tenant.js";
11
+ import { mainLogoId } from "./brand.js";
12
+ /** About how many rows the teaser's step list has. */
13
+ const STEP_ROWS = 5;
14
+ /** Fields whose answer is a file the person brings. */
15
+ const UPLOAD_KINDS = new Set(["file", "image", "audio"]);
16
+ /** Facts that name who stands behind the page, by key. */
17
+ const NAME_KEYS = ["name", "firma", "unternehmen", "company", "firmenname", "kanzlei"];
18
+ /** A wizard's language where the page knows it, else the page's. */
19
+ function pageLangOf(def, fallback) {
20
+ const lang = langOf(wizardLang(def));
21
+ return lang === "de" || lang === "en" ? lang : fallback;
22
+ }
23
+ /** Who acts in a step: the person on a page, in a review or a surface; the AI everywhere else. */
24
+ const by = (step) => step.type === "page" || step.type === "review" || step.type === "surface" ? "you" : "ai";
25
+ /** "A und B", "A, B und C". */
26
+ function joinTitles(titles, lang) {
27
+ if (titles.length <= 1) {
28
+ return titles[0] ?? "";
29
+ }
30
+ const and = lang === "de" ? " und " : " and ";
31
+ return `${titles.slice(0, -1).join(", ")}${and}${titles.at(-1)}`;
32
+ }
33
+ /**
34
+ * The way through as the teaser shows it: the steps along the path a run takes when no
35
+ * condition applies (a branch's "otherwise", else the next step), each page, review and result
36
+ * step as written, the AI steps between them merged into one row, and about five rows in all.
37
+ * An `each` step is one step and so one row.
38
+ */
39
+ export function pageSteps(def, lang) {
40
+ const path = [];
41
+ const seen = new Set();
42
+ let at = 0;
43
+ while (at >= 0 && at < def.steps.length && !seen.has(def.steps[at].id)) {
44
+ const step = def.steps[at];
45
+ seen.add(step.id);
46
+ path.push(step);
47
+ const otherwise = step.next?.find((r) => r.when === undefined && r.ask === undefined);
48
+ if (!otherwise) {
49
+ at += 1;
50
+ }
51
+ else if (otherwise.goto === "end") {
52
+ break;
53
+ }
54
+ else {
55
+ at = def.steps.findIndex((s) => s.id === otherwise.goto);
56
+ }
57
+ }
58
+ const rows = [];
59
+ for (const step of path) {
60
+ const who = by(step);
61
+ const merge = who === "ai" && step.type !== "result";
62
+ const last = rows.at(-1);
63
+ if (merge && last?.merge) {
64
+ last.titles.push(step.title);
65
+ }
66
+ else {
67
+ rows.push({ titles: [step.title], by: who, merge });
68
+ }
69
+ }
70
+ const kept = rows.length > STEP_ROWS ? [...rows.slice(0, STEP_ROWS - 1), rows.at(-1)] : rows;
71
+ return kept.map((r) => ({ title: joinTitles(r.titles, lang).slice(0, 80), by: r.by }));
72
+ }
73
+ /**
74
+ * The space's facts as the imprint: who stands behind the page, one line per fact, the postcode
75
+ * and the town as one line after the address, the website apart; null without filled facts.
76
+ */
77
+ export function imprintOf(facts, fallbackName) {
78
+ const filled = facts.filter((f) => f.value.trim());
79
+ if (!filled.length) {
80
+ return null;
81
+ }
82
+ const named = filled.find((f) => NAME_KEYS.includes(f.key));
83
+ const website = filled.find((f) => f.key === "website" || factType(f) === "url");
84
+ const town = ["plz", "ort"]
85
+ .map((key) => filled.find((f) => f.key === key)?.value.trim())
86
+ .filter(Boolean)
87
+ .join(" ");
88
+ const apart = new Set(["plz", "ort", named?.key, website?.key]);
89
+ const lines = [];
90
+ for (const f of filled) {
91
+ const type = factType(f);
92
+ if (apart.has(f.key) || type === "longtext" || type === "boolean") {
93
+ continue;
94
+ }
95
+ lines.push(f.value.trim());
96
+ if (f.key === "adresse" && town) {
97
+ lines.push(town);
98
+ }
99
+ }
100
+ if (town && !lines.includes(town)) {
101
+ lines.push(town);
102
+ }
103
+ const site = website?.value.trim();
104
+ return {
105
+ name: (named?.value.trim() || fallbackName).slice(0, 200),
106
+ lines: lines.map((l) => l.slice(0, 200)).slice(0, 8),
107
+ ...(site ? { website: /^https?:\/\//i.test(site) ? site : `https://${site}` } : {}),
108
+ };
109
+ }
110
+ /** A wizard's address on the page, from its title, unique among the page's wizards; kept once made. */
111
+ function wizardSlug(title, taken) {
112
+ const base = pageSlugOf(title) || "wizard";
113
+ let slug = base;
114
+ for (let n = 2; taken.has(slug); n++) {
115
+ slug = `${base.slice(0, 44)}-${n}`;
116
+ }
117
+ taken.add(slug);
118
+ return slug;
119
+ }
120
+ /** The team's page data as Manage expects it; null where this runtime is not a team's. */
121
+ export async function pageTeam() {
122
+ if (!managed) {
123
+ return null;
124
+ }
125
+ const tenantId = currentTenant();
126
+ const team = await tenantInfo(tenantId);
127
+ // Only one space of a team has its page on (services/projects.ts).
128
+ const spaces = await db.query.project.findMany({
129
+ where: eq(schema.project.tenantId, tenantId),
130
+ });
131
+ // Behind its switch the team has no page: what Manage holds is sent as none.
132
+ const space = feature("pages", team.features) ? (spaces.find((p) => p.page?.on) ?? null) : null;
133
+ const page = space?.page;
134
+ const lang = page?.lang ?? "de";
135
+ const base = { slug: team.slug ?? tenantId, name: team.name, lang };
136
+ if (!(space && page)) {
137
+ return { ...base, space: null };
138
+ }
139
+ const listed = page.wizards.length
140
+ ? await db.query.wizard.findMany({
141
+ where: and(eq(schema.wizard.projectId, space.id), inArray(schema.wizard.id, page.wizards), eq(schema.wizard.shareEnabled, true)),
142
+ })
143
+ : [];
144
+ // Addresses made before hold; a wizard new to the page gets one that is free among them.
145
+ const kept = page.slugs ?? {};
146
+ const taken = new Set(Object.values(kept));
147
+ const made = {};
148
+ const wizards = [];
149
+ for (const id of page.wizards) {
150
+ const w = listed.find((x) => x.id === id);
151
+ if (!w || w.publishedVersion === null) {
152
+ continue;
153
+ }
154
+ const version = await db.query.wizardVersion.findFirst({
155
+ where: and(eq(schema.wizardVersion.wizardId, w.id), eq(schema.wizardVersion.version, w.publishedVersion)),
156
+ columns: { definition: true },
157
+ });
158
+ if (!version) {
159
+ continue;
160
+ }
161
+ const def = version.definition;
162
+ const wizardLanguage = pageLangOf(def, lang);
163
+ const effort = effortOf(def);
164
+ const uploads = def.steps.some((s) => s.type === "page" && s.fields.some((f) => UPLOAD_KINDS.has(f.kind)));
165
+ const exampleToken = page.examples[w.id];
166
+ const example = exampleToken
167
+ ? await db.query.run.findFirst({
168
+ where: and(eq(schema.run.wizardId, w.id), eq(schema.run.shareToken, exampleToken)),
169
+ columns: { status: true, expiresAt: true },
170
+ })
171
+ : null;
172
+ const shown = example?.status === "done" && !(example.expiresAt && example.expiresAt < new Date());
173
+ const slug = kept[w.id] ?? wizardSlug(def.title, taken);
174
+ if (!kept[w.id]) {
175
+ made[w.id] = slug;
176
+ }
177
+ wizards.push({
178
+ slug,
179
+ title: def.title.slice(0, 120),
180
+ description: def.description.slice(0, 600),
181
+ avatar: def.avatar,
182
+ lang: wizardLanguage,
183
+ results: resultsOf(def).slice(0, 12),
184
+ effort: { fields: effort.fields, reviews: effort.reviews, minutes: effort.minutes, uploads },
185
+ steps: pageSteps(def, wizardLanguage),
186
+ runUrl: `${env.publicUrl}/w/${w.shareToken}`,
187
+ ...(shown ? { exampleUrl: `${env.publicUrl}/s/${exampleToken}` } : {}),
188
+ });
189
+ }
190
+ if (Object.keys(made).length) {
191
+ await db
192
+ .update(schema.project)
193
+ .set({ page: { ...page, slugs: { ...kept, ...made } } })
194
+ .where(eq(schema.project.id, space.id));
195
+ }
196
+ if (!wizards.length) {
197
+ return { ...base, space: null };
198
+ }
199
+ const logo = await mainLogoId(space.id);
200
+ return {
201
+ ...base,
202
+ space: {
203
+ slug: page.slug,
204
+ title: page.title,
205
+ ...(page.headline ? { headline: page.headline } : {}),
206
+ ...(page.intro ? { intro: page.intro } : {}),
207
+ lang,
208
+ ...(lang === "de" && page.form ? { form: page.form } : {}),
209
+ brand: {
210
+ name: (space.brand.name ?? "").slice(0, 120),
211
+ logoUrl: logo ? `${env.publicUrl}/api/public/logos/${logo}` : null,
212
+ theme: runTheme(space.brand),
213
+ },
214
+ imprint: imprintOf(space.facts, space.brand.name || space.name),
215
+ wizards,
216
+ },
217
+ };
218
+ }
219
+ /**
220
+ * Where the team's page is opened: `https://<host>`; on a `.localhost` domain in development
221
+ * `http://<host>:<Manage's port>`, as Manage serves it there.
222
+ */
223
+ export function pageOrigin(host) {
224
+ if (host.endsWith(".localhost")) {
225
+ const port = URL.canParse(env.manage.url) ? new URL(env.manage.url).port : "";
226
+ return `http://${host}${port ? `:${port}` : ""}`;
227
+ }
228
+ return `https://${host}`;
229
+ }
230
+ /** What the studio's "Public page" part shows beside its fields: the team's address and page data. */
231
+ export async function pagePreview() {
232
+ if (!managed) {
233
+ return { host: null, origin: null, team: null };
234
+ }
235
+ const team = await tenantInfo(currentTenant());
236
+ const host = feature("pages", team.features) ? (team.pagesHost ?? null) : null;
237
+ return { host, origin: host ? pageOrigin(host) : null, team: await pageTeam() };
238
+ }
239
+ let last = Promise.resolve();
240
+ /**
241
+ * Sends the team's page data to Manage, whole; a space switched off or with no listed wizard
242
+ * published and shared is sent as none. Not waited for by the change that caused it: a failure
243
+ * is logged, and the next change sends everything again. `pagesSettled` waits for the last send.
244
+ */
245
+ export function pushPages() {
246
+ if (!managed) {
247
+ return;
248
+ }
249
+ const send = async () => {
250
+ const data = await pageTeam();
251
+ if (data) {
252
+ await putPages(currentTenant(), data);
253
+ }
254
+ };
255
+ last = last.then(send, send).catch((err) => {
256
+ console.error("[pages] the page was not sent:", err.message);
257
+ });
258
+ }
259
+ /** Resolves once every push so far has been answered or has failed. */
260
+ export function pagesSettled() {
261
+ return last;
262
+ }
@@ -1,6 +1,6 @@
1
- import { COLOR_SECTION_KINDS, cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, FONT_WEIGHTS, GRADIENT_TYPES, orderColors, PROJECT_LIMITS, RULE_MARKS, } from "@engenty/wizards-shared/projects";
1
+ import { COLOR_SECTION_KINDS, cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, FONT_WEIGHTS, GRADIENT_TYPES, orderColors, PAGE_LANGS, PAGE_LIMITS, PAGE_SLUG, PROJECT_LIMITS, RULE_MARKS, } from "@engenty/wizards-shared/projects";
2
2
  import { note } from "@engenty/wizards-shared/run";
3
- import { and, count, eq, isNull } from "drizzle-orm";
3
+ import { and, count, eq, isNull, ne } from "drizzle-orm";
4
4
  import { nanoid } from "nanoid";
5
5
  import { z } from "zod";
6
6
  import { db, schema } from "../db/client.js";
@@ -13,6 +13,7 @@ import { serverText } from "../texts.js";
13
13
  import { mayBuild, requireAdmin, requireBuild, requireWritable } from "./access.js";
14
14
  import { notFound, ServiceError } from "./errors.js";
15
15
  import { forgetWizardLinks } from "./links.js";
16
+ import { pushPages } from "./pages.js";
16
17
  import { removeProjectFiles } from "./project-files.js";
17
18
  const MASK = "••••";
18
19
  export const mcpServerSchema = z.object({
@@ -103,8 +104,28 @@ export const projectFactSchema = z.object({
103
104
  value: z.string().max(4000),
104
105
  type: z.enum(FACT_TYPES).optional(),
105
106
  });
107
+ const trimmed = (max) => z
108
+ .string()
109
+ .trim()
110
+ .max(max)
111
+ .transform((v) => v || undefined)
112
+ .optional();
113
+ /** The space's public page as the studio sends it, whole. */
114
+ export const projectPageSchema = z.object({
115
+ on: z.boolean(),
116
+ slug: z.string().trim().toLowerCase().max(PAGE_LIMITS.slug),
117
+ title: z.string().trim().min(1).max(PAGE_LIMITS.title),
118
+ headline: trimmed(PAGE_LIMITS.headline),
119
+ intro: trimmed(PAGE_LIMITS.intro),
120
+ lang: z.enum(PAGE_LANGS),
121
+ form: z.enum(["du", "sie"]).optional(),
122
+ wizards: z.array(z.string().max(40)).max(60),
123
+ examples: z.record(z.string().max(40), z.string().regex(/^[A-Za-z0-9_-]{1,40}$/)),
124
+ slugs: z.record(z.string().max(40), z.string().regex(PAGE_SLUG)).optional(),
125
+ });
106
126
  export const projectPatchSchema = z.object({
107
127
  name: z.string().min(1).max(80).optional(),
128
+ page: projectPageSchema.optional(),
108
129
  brand: z
109
130
  .object({
110
131
  name: z.string().max(120).optional(),
@@ -270,6 +291,7 @@ export async function updateProject(userId, projectId, patch) {
270
291
  if (patch.brand?.fonts) {
271
292
  await linkFontFiles(p.id, patch.brand.fonts);
272
293
  }
294
+ const page = patch.page ? await checkedPage(p, patch.page) : undefined;
273
295
  await db
274
296
  .update(schema.project)
275
297
  .set({
@@ -277,10 +299,58 @@ export async function updateProject(userId, projectId, patch) {
277
299
  ...(patch.brand ? { brand: brandAfter(p.brand, patch.brand) } : {}),
278
300
  ...(patch.facts ? { facts: patch.facts } : {}),
279
301
  ...(mcpServers ? { mcpServers } : {}),
302
+ ...(page ? { page } : {}),
280
303
  updatedAt: new Date(),
281
304
  })
282
305
  .where(eq(schema.project.id, p.id));
283
306
  spaceChanged("space.updated", p.id);
307
+ // The page itself, and what it is drawn from: the brand, the facts as the imprint.
308
+ if (page || patch.brand || patch.facts) {
309
+ pushPages();
310
+ }
311
+ }
312
+ /**
313
+ * The page as it is kept: its address made of the allowed characters and taken by no other space
314
+ * of the tenant, only this tenant's wizards of this space on it, and the page on in one space at
315
+ * most (`409 page_taken`, naming that space). The form is German's alone.
316
+ */
317
+ async function checkedPage(p, page) {
318
+ if (!PAGE_SLUG.test(page.slug)) {
319
+ throw new ServiceError("invalid", note("pageSlugInvalid"));
320
+ }
321
+ const others = await db.query.project.findMany({
322
+ where: and(eq(schema.project.tenantId, currentTenant()), ne(schema.project.id, p.id)),
323
+ columns: { id: true, name: true, page: true },
324
+ });
325
+ if (others.some((o) => o.page?.slug === page.slug)) {
326
+ throw new ServiceError("invalid", note("pageSlugTaken"));
327
+ }
328
+ const holder = page.on ? others.find((o) => o.page?.on) : undefined;
329
+ if (holder) {
330
+ throw new ServiceError("page_taken", note("pageTaken", { space: holder.name }), {
331
+ project: { id: holder.id, name: holder.name },
332
+ });
333
+ }
334
+ const own = new Set((await db.query.wizard.findMany({
335
+ where: eq(schema.wizard.projectId, p.id),
336
+ columns: { id: true },
337
+ })).map((w) => w.id));
338
+ const wizards = [...new Set(page.wizards)].filter((id) => own.has(id));
339
+ const examples = Object.fromEntries(Object.entries(page.examples).filter(([id]) => own.has(id)));
340
+ // The wizards' addresses are kept as made (pages.ts); a wizard that is gone frees its address.
341
+ const slugs = Object.fromEntries(Object.entries({ ...p.page?.slugs, ...page.slugs }).filter(([id]) => own.has(id)));
342
+ return {
343
+ on: page.on,
344
+ slug: page.slug,
345
+ title: page.title,
346
+ ...(page.headline ? { headline: page.headline } : {}),
347
+ ...(page.intro ? { intro: page.intro } : {}),
348
+ lang: page.lang,
349
+ ...(page.lang === "de" && page.form ? { form: page.form } : {}),
350
+ wizards,
351
+ examples,
352
+ ...(Object.keys(slugs).length ? { slugs } : {}),
353
+ };
284
354
  }
285
355
  /**
286
356
  * A brand font's own file is a font of the space; run pages ask for it by its id, before the
@@ -418,4 +488,5 @@ export async function removeProject(projectId) {
418
488
  .delete(schema.project)
419
489
  .where(and(eq(schema.project.id, projectId), eq(schema.project.tenantId, currentTenant())));
420
490
  spaceChanged("space.deleted", projectId);
491
+ pushPages();
421
492
  }