@engenty/wizards-runtime 0.12.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/apps/runtime/dist/agents/architect.js +8 -7
  2. package/apps/runtime/dist/agents/goose-connections.js +82 -0
  3. package/apps/runtime/dist/agents/space-agent.js +9 -2
  4. package/apps/runtime/dist/agents/studio-assistant.js +126 -71
  5. package/apps/runtime/dist/agents/website.js +1 -1
  6. package/apps/runtime/dist/app.js +28 -3
  7. package/apps/runtime/dist/assistant/knows.js +6 -5
  8. package/apps/runtime/dist/authoring/guide.js +25 -5
  9. package/apps/runtime/dist/broker/account.js +166 -0
  10. package/apps/runtime/dist/broker/call.js +417 -0
  11. package/apps/runtime/dist/broker/caller.js +10 -0
  12. package/apps/runtime/dist/broker/grant.js +152 -0
  13. package/apps/runtime/dist/broker/host.js +51 -0
  14. package/apps/runtime/dist/broker/index.js +8 -0
  15. package/apps/runtime/dist/broker/kept.js +31 -0
  16. package/apps/runtime/dist/broker/log.js +240 -0
  17. package/apps/runtime/dist/broker/registry.js +9 -0
  18. package/apps/runtime/dist/broker/rwx.js +367 -0
  19. package/apps/runtime/dist/broker/send.js +189 -0
  20. package/apps/runtime/dist/connectors/builtin.js +1 -1
  21. package/apps/runtime/dist/connectors/external.js +38 -37
  22. package/apps/runtime/dist/connectors/index.js +30 -91
  23. package/apps/runtime/dist/connectors/mail.js +0 -8
  24. package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
  25. package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
  26. package/apps/runtime/dist/connectors/smtp.js +1 -1
  27. package/apps/runtime/dist/connectors/space-connections.js +436 -0
  28. package/apps/runtime/dist/credits/estimate.js +3 -3
  29. package/apps/runtime/dist/db/adopt.js +3 -3
  30. package/apps/runtime/dist/db/client.js +9 -0
  31. package/apps/runtime/dist/db/live-triggers.js +65 -23
  32. package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
  33. package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
  34. package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
  35. package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
  36. package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
  37. package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
  38. package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
  39. package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
  40. package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
  41. package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
  42. package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
  43. package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
  47. package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
  48. package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
  49. package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
  50. package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
  51. package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
  52. package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
  53. package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
  54. package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
  55. package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
  56. package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
  57. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
  58. package/apps/runtime/dist/db/schema.js +295 -72
  59. package/apps/runtime/dist/docs/dev/architecture.md +215 -0
  60. package/apps/runtime/dist/docs/dev/broker.md +298 -0
  61. package/apps/runtime/dist/docs/dev/index.md +5 -1
  62. package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
  63. package/apps/runtime/dist/docs/dev/meta.json +3 -0
  64. package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
  65. package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
  66. package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
  67. package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
  68. package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
  69. package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
  70. package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
  71. package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
  72. package/apps/runtime/dist/docs/dev/skills.md +16 -9
  73. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +59 -6
  74. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
  75. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
  76. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
  77. package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
  78. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
  79. package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
  80. package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
  81. package/apps/runtime/dist/docs/user-guide/index.md +10 -1
  82. package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
  83. package/apps/runtime/dist/docs/user-guide/models.md +105 -30
  84. package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
  85. package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
  86. package/apps/runtime/dist/docs/user-guide/space.md +5 -4
  87. package/apps/runtime/dist/docs/user-guide/together.md +29 -2
  88. package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
  89. package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
  90. package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
  91. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
  92. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
  93. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
  94. package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
  95. package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
  96. package/apps/runtime/dist/engine/decide.js +1 -1
  97. package/apps/runtime/dist/engine/requirements.js +139 -11
  98. package/apps/runtime/dist/engine/resources.js +43 -12
  99. package/apps/runtime/dist/engine/runner.js +121 -27
  100. package/apps/runtime/dist/engine/steps.js +42 -16
  101. package/apps/runtime/dist/engine/template.js +35 -1
  102. package/apps/runtime/dist/env.js +9 -4
  103. package/apps/runtime/dist/index.js +18 -2
  104. package/apps/runtime/dist/link-preview.js +9 -0
  105. package/apps/runtime/dist/live/feed.js +2 -2
  106. package/apps/runtime/dist/live/origin.js +2 -2
  107. package/apps/runtime/dist/live/views.js +51 -26
  108. package/apps/runtime/dist/manage.js +32 -0
  109. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  110. package/apps/runtime/dist/mcp/handler.js +55 -1
  111. package/apps/runtime/dist/mcp/seen.js +47 -0
  112. package/apps/runtime/dist/mcp/tools.js +75 -34
  113. package/apps/runtime/dist/models.js +203 -12
  114. package/apps/runtime/dist/motion-graphics/project.js +8 -8
  115. package/apps/runtime/dist/motion-graphics/step.js +2 -2
  116. package/apps/runtime/dist/motion-graphics/tools.js +1 -1
  117. package/apps/runtime/dist/plugins/events.js +2 -2
  118. package/apps/runtime/dist/plugins/jobs.js +4 -1
  119. package/apps/runtime/dist/plugins/loader.js +2 -2
  120. package/apps/runtime/dist/prompts/architect.md +3 -3
  121. package/apps/runtime/dist/prompts/authoring.md +46 -12
  122. package/apps/runtime/dist/prompts/goose.md +14 -13
  123. package/apps/runtime/dist/prompts/mcp.md +6 -6
  124. package/apps/runtime/dist/prompts/safety.md +18 -0
  125. package/apps/runtime/dist/prompts/services.md +4 -4
  126. package/apps/runtime/dist/prompts/step.md +3 -3
  127. package/apps/runtime/dist/prompts/tools.md +39 -10
  128. package/apps/runtime/dist/routes/api.js +31 -20
  129. package/apps/runtime/dist/routes/broker.js +316 -0
  130. package/apps/runtime/dist/routes/connections.js +71 -0
  131. package/apps/runtime/dist/routes/delivery.js +25 -0
  132. package/apps/runtime/dist/routes/discover.js +17 -0
  133. package/apps/runtime/dist/routes/live.js +11 -1
  134. package/apps/runtime/dist/routes/marketplace.js +3 -3
  135. package/apps/runtime/dist/routes/person.js +4 -1
  136. package/apps/runtime/dist/routes/plugins.js +3 -1
  137. package/apps/runtime/dist/routes/rules.js +26 -0
  138. package/apps/runtime/dist/routes/runs.js +59 -33
  139. package/apps/runtime/dist/routes/skills.js +6 -6
  140. package/apps/runtime/dist/routes/studio.js +256 -148
  141. package/apps/runtime/dist/routes/work.js +199 -0
  142. package/apps/runtime/dist/safety.js +60 -18
  143. package/apps/runtime/dist/sandbox/index.js +27 -0
  144. package/apps/runtime/dist/services/access.js +38 -17
  145. package/apps/runtime/dist/services/api.js +38 -13
  146. package/apps/runtime/dist/services/architect.js +3 -3
  147. package/apps/runtime/dist/services/assistant-chats.js +9 -1
  148. package/apps/runtime/dist/services/brand.js +12 -12
  149. package/apps/runtime/dist/services/broker-bell.js +69 -0
  150. package/apps/runtime/dist/services/broker-notify.js +127 -0
  151. package/apps/runtime/dist/services/client-steps.js +79 -0
  152. package/apps/runtime/dist/services/cloud.js +42 -42
  153. package/apps/runtime/dist/services/command-risk.js +51 -0
  154. package/apps/runtime/dist/services/discover.js +85 -0
  155. package/apps/runtime/dist/services/knowledge-model.js +13 -13
  156. package/apps/runtime/dist/services/knowledge.js +117 -80
  157. package/apps/runtime/dist/services/manage-reports.js +77 -7
  158. package/apps/runtime/dist/services/marketplace.js +7 -31
  159. package/apps/runtime/dist/services/members-studio.js +165 -0
  160. package/apps/runtime/dist/services/onboarding.js +22 -22
  161. package/apps/runtime/dist/services/package-file.js +1 -1
  162. package/apps/runtime/dist/services/package.js +22 -22
  163. package/apps/runtime/dist/services/pages.js +13 -9
  164. package/apps/runtime/dist/services/runs.js +4 -3
  165. package/apps/runtime/dist/services/seen.js +55 -0
  166. package/apps/runtime/dist/services/shares.js +28 -13
  167. package/apps/runtime/dist/services/site.js +23 -23
  168. package/apps/runtime/dist/services/skills-registry.js +15 -15
  169. package/apps/runtime/dist/services/skills.js +44 -44
  170. package/apps/runtime/dist/services/space-categories.js +35 -35
  171. package/apps/runtime/dist/services/space-data.js +130 -111
  172. package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
  173. package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
  174. package/apps/runtime/dist/services/space-origin.js +19 -11
  175. package/apps/runtime/dist/services/spaces.js +478 -598
  176. package/apps/runtime/dist/services/synced-spaces.js +668 -0
  177. package/apps/runtime/dist/services/themes.js +15 -15
  178. package/apps/runtime/dist/services/widgets.js +6 -6
  179. package/apps/runtime/dist/services/wizards.js +112 -38
  180. package/apps/runtime/dist/services/work-ai.js +257 -0
  181. package/apps/runtime/dist/services/work-approvals.js +104 -0
  182. package/apps/runtime/dist/services/work-chats.js +908 -0
  183. package/apps/runtime/dist/services/work-connections.js +90 -0
  184. package/apps/runtime/dist/services/work-files.js +85 -0
  185. package/apps/runtime/dist/services/work-mastra.js +73 -0
  186. package/apps/runtime/dist/services/work-sandbox.js +42 -0
  187. package/apps/runtime/dist/sharing/files.js +14 -4
  188. package/apps/runtime/dist/sharing/index.js +40 -39
  189. package/apps/runtime/dist/sharing/jobs.js +67 -17
  190. package/apps/runtime/dist/sharing/targets/connector.js +10 -6
  191. package/apps/runtime/dist/sharing/targets/email.js +10 -8
  192. package/apps/runtime/dist/sharing/targets/slack.js +10 -8
  193. package/apps/runtime/dist/sharing/targets/storage.js +6 -4
  194. package/apps/runtime/dist/store/index.js +14 -3
  195. package/apps/runtime/dist/store/shared-lists.js +4 -2
  196. package/apps/runtime/dist/sync/apply.js +2 -2
  197. package/apps/runtime/dist/sync/client.js +113 -113
  198. package/apps/runtime/dist/sync/hub.js +41 -41
  199. package/apps/runtime/dist/sync/log.js +12 -12
  200. package/apps/runtime/dist/sync/records.js +118 -120
  201. package/apps/runtime/dist/texts.js +44 -2
  202. package/apps/runtime/dist/tools/connections.js +112 -0
  203. package/apps/runtime/dist/tools/connector.js +157 -67
  204. package/apps/runtime/dist/tools/index.js +31 -15
  205. package/apps/runtime/dist/tools/mail.js +40 -11
  206. package/apps/runtime/dist/tools/pages.js +11 -5
  207. package/apps/runtime/dist/tools/plugin.js +43 -7
  208. package/apps/runtime/dist/tools/skills.js +1 -1
  209. package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
  210. package/apps/runtime/dist/tools/store.js +3 -2
  211. package/apps/runtime/dist/widgets/step.js +10 -10
  212. package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
  213. package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
  214. package/apps/web/dist/assets/{ChangelogDialog-CKLgFL6r.js → ChangelogDialog-Duab4zTO.js} +1 -1
  215. package/apps/web/dist/assets/{CodeEditor-B3nto_26.js → CodeEditor-nxoOt8ge.js} +1 -1
  216. package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
  217. package/apps/web/dist/assets/{FlowPreview-zJCtixSi.js → FlowPreview-aMfwcPul.js} +1 -1
  218. package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
  219. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
  220. package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
  221. package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
  222. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
  223. package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
  224. package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
  225. package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
  226. package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
  227. package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
  228. package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
  229. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
  230. package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
  231. package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
  232. package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
  233. package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
  234. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
  235. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
  236. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
  237. package/apps/web/dist/assets/{code-xml-Hx7YxCg0.js → code-xml-B4kLFZSj.js} +1 -1
  238. package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
  239. package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
  240. package/apps/web/dist/assets/{eye-BkMFLnYu.js → eye-BpoKpIdt.js} +1 -1
  241. package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
  242. package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
  243. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
  244. package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
  245. package/apps/web/dist/assets/index-D2akynS-.js +10 -0
  246. package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
  247. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
  248. package/apps/web/dist/assets/{phone-DMfwuh9V.js → phone-Ctvf-Am-.js} +1 -1
  249. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
  250. package/apps/web/dist/assets/{runners-D5qz6b_s.js → runners-CyIvJIHr.js} +1 -1
  251. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
  252. package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
  253. package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
  254. package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
  255. package/apps/web/dist/assets/{upload-DQJwLSGj.js → upload-BchUnQGV.js} +1 -1
  256. package/apps/web/dist/assets/{useMutation-C20c2EH3.js → useMutation-DEkZhp5c.js} +1 -1
  257. package/apps/web/dist/assets/{volume-2-CC5qamYT.js → volume-2-CU_oy81Z.js} +1 -1
  258. package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
  259. package/apps/web/dist/index.html +17 -10
  260. package/apps/web/dist/mcp/flow.html +119 -64
  261. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
  262. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +7 -1
  263. package/node_modules/@engenty/wizards-shared/dist/assistant.js +11 -1
  264. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
  265. package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
  266. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +257 -8
  267. package/node_modules/@engenty/wizards-shared/dist/definition.js +113 -15
  268. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
  269. package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
  270. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +38 -2
  271. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +38 -2
  272. package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
  273. package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
  274. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
  275. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
  276. package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
  277. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +0 -5
  278. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
  279. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +115 -6
  280. package/node_modules/@engenty/wizards-shared/dist/run.js +135 -0
  281. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
  282. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
  283. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
  284. package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
  285. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
  286. package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
  287. package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
  288. package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
  289. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
  290. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
  291. package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
  292. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
  293. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
  294. package/node_modules/@engenty/wizards-shared/dist/tiers.d.ts +195 -0
  295. package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
  296. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
  297. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
  298. package/package.json +4 -1
  299. package/plugin/.claude-plugin/plugin.json +1 -1
  300. package/plugin/plugin.json +1 -1
  301. package/plugin/skills/build-wizard/SKILL.md +1 -1
  302. package/apps/runtime/dist/services/projects.js +0 -473
  303. package/apps/web/dist/assets/AboutDialog-CLgnoYTI.js +0 -1
  304. package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +0 -3
  305. package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +0 -2
  306. package/apps/web/dist/assets/NewWizardChannels-B4N7GIYh.js +0 -1
  307. package/apps/web/dist/assets/NewWizardPage-Dpt0Mzk8.js +0 -7
  308. package/apps/web/dist/assets/OnboardingPage-CDoYVjRC.js +0 -1
  309. package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +0 -10
  310. package/apps/web/dist/assets/ProjectPage-408YOoNa.js +0 -10
  311. package/apps/web/dist/assets/PublicRunner-BZ66xdRX.js +0 -1
  312. package/apps/web/dist/assets/ReadOnly-C9oGMkUB.js +0 -1
  313. package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +0 -2
  314. package/apps/web/dist/assets/SetupPage-CP3lbyZc.js +0 -1
  315. package/apps/web/dist/assets/SharePage-DdMm1Y8K.js +0 -1
  316. package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +0 -1
  317. package/apps/web/dist/assets/changelog-82-DHogQ.js +0 -1
  318. package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
  319. package/apps/web/dist/assets/i18n-CKKh3Pn0.js +0 -55
  320. package/apps/web/dist/assets/index-Cy2NHzAx.js +0 -49
  321. package/apps/web/dist/assets/index-wR_-1hfN.css +0 -1
  322. package/apps/web/dist/assets/lock-CGXM95Mi.js +0 -1
  323. package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
  324. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
  325. package/apps/web/dist/assets/session-DRy0k0nh.js +0 -2
  326. package/apps/web/dist/assets/theme-DNPm6r4e.js +0 -11
  327. package/apps/web/dist/assets/ui-CwFQAfE-.js +0 -83
  328. /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
@@ -1,9 +1,10 @@
1
1
  import { capabilitiesOf, effortOf } from "@engenty/wizards-shared/marketplace";
2
2
  import { resultsOf } from "@engenty/wizards-shared/marketplace-entry";
3
3
  import { and, eq, inArray } from "drizzle-orm";
4
+ import { onCritical } from "../broker/index.js";
4
5
  import { db, knownTenants, schema, withTenant } from "../db/client.js";
5
6
  import { env } from "../env.js";
6
- import { managed, postRunReport, putWizards } from "../manage.js";
7
+ import { managed, postBrokerReport, postRunReport, putWizards } from "../manage.js";
7
8
  import { currentTenant } from "../tenants/tenant.js";
8
9
  import { pageLangOf, pageSteps } from "./pages.js";
9
10
  /**
@@ -15,12 +16,12 @@ let last = Promise.resolve();
15
16
  /** The team's wizards as the admin app lists them: the published version where there is one. */
16
17
  export async function wizardsReport() {
17
18
  const tenantId = currentTenant();
18
- const [wizards, projects] = await Promise.all([
19
+ const [wizards, spaceRows] = await Promise.all([
19
20
  db.select().from(schema.wizard).where(eq(schema.wizard.tenantId, tenantId)),
20
21
  db
21
- .select({ id: schema.project.id, name: schema.project.name })
22
- .from(schema.project)
23
- .where(eq(schema.project.tenantId, tenantId)),
22
+ .select({ id: schema.space.id, name: schema.space.name })
23
+ .from(schema.space)
24
+ .where(eq(schema.space.tenantId, tenantId)),
24
25
  ]);
25
26
  const published = wizards.filter((w) => w.publishedVersion !== null);
26
27
  const versions = published.length
@@ -34,7 +35,7 @@ export async function wizardsReport() {
34
35
  .from(schema.wizardVersion)
35
36
  .where(inArray(schema.wizardVersion.wizardId, published.map((w) => w.id)))
36
37
  : [];
37
- const spaces = new Map(projects.map((p) => [p.id, p.name]));
38
+ const spaces = new Map(spaceRows.map((p) => [p.id, p.name]));
38
39
  return {
39
40
  wizards: wizards.map((w) => {
40
41
  const live = versions.find((v) => v.wizardId === w.id && v.version === w.publishedVersion);
@@ -45,7 +46,7 @@ export async function wizardsReport() {
45
46
  description: (def.description ?? "").slice(0, 1000),
46
47
  avatar: def.avatar ?? "round",
47
48
  lang: (def.lang ?? "de").slice(0, 5),
48
- space: spaces.has(w.projectId) ? { id: w.projectId, name: spaces.get(w.projectId) } : null,
49
+ space: spaces.has(w.spaceId) ? { id: w.spaceId, name: spaces.get(w.spaceId) } : null,
49
50
  published: Boolean(live),
50
51
  publishedAt: live?.createdAt.toISOString() ?? null,
51
52
  template: w.starter ? { id: w.starter, revision: w.starterRevision ?? null } : null,
@@ -163,6 +164,7 @@ export function reportRun(runId, status) {
163
164
  cursor: true,
164
165
  error: true,
165
166
  definition: true,
167
+ state: true,
166
168
  createdAt: true,
167
169
  },
168
170
  });
@@ -183,8 +185,76 @@ export function reportRun(runId, status) {
183
185
  ? { step: { id: step.id, title: (step.title ?? step.id).slice(0, 160), kind: step.type } }
184
186
  : {}),
185
187
  ...(state === "failed" && run.error ? { error: run.error.slice(0, 2000) } : {}),
188
+ // What the content rules stopped: an image, a guest's text, their input, an override.
189
+ ...(state === "failed" && run.state.blocked ? { blocked: run.state.blocked } : {}),
186
190
  });
187
191
  })().catch((err) => {
188
192
  console.warn(`[reports] run ${runId}:`, err.message);
189
193
  });
190
194
  }
195
+ // --- the broker's critical lines ---------------------------------------------------------------
196
+ /** How often the lines that are not a guest's go out. */
197
+ const DAILY_MS = 24 * 3600_000;
198
+ /** How many lines one report carries at most. */
199
+ const REPORT_LINES = 200;
200
+ /** A line as the admin app takes it: who, where, what, the outcome; never the input. */
201
+ export function criticalLine(row) {
202
+ return {
203
+ id: row.id,
204
+ at: row.at.toISOString(),
205
+ kind: row.criticalKind,
206
+ who: { kind: row.whoKind, id: row.whoId },
207
+ where: { runId: row.runId, chatId: row.chatId, wizardId: row.wizardId, spaceId: row.spaceId },
208
+ connection: row.connectionId,
209
+ action: row.actionId,
210
+ actionKind: row.kind,
211
+ outcome: row.outcome,
212
+ rule: row.rule,
213
+ result: row.result,
214
+ reason: (row.reason ?? "").slice(0, 500),
215
+ };
216
+ }
217
+ const kept = new Map();
218
+ function post(tenantId, rows, batch) {
219
+ if (!rows.length) {
220
+ return Promise.resolve();
221
+ }
222
+ return postBrokerReport(tenantId, { batch, lines: rows.map(criticalLine) }).then(() => undefined, (err) => console.warn(`[reports] broker ${tenantId}:`, err.message));
223
+ }
224
+ /**
225
+ * Hears every critical row (broker/log.ts): a guest's goes to the admin app at once – someone at a
226
+ * wizard's link reached for what the rules keep from them; the rest wait for the daily report.
227
+ */
228
+ export function reportCritical(row) {
229
+ if (!managed) {
230
+ return Promise.resolve();
231
+ }
232
+ const tenantId = currentTenant();
233
+ if (row.whoKind === "guest") {
234
+ return post(tenantId, [row], "at_once");
235
+ }
236
+ const rows = kept.get(tenantId) ?? [];
237
+ rows.push(row);
238
+ kept.set(tenantId, rows.slice(-REPORT_LINES));
239
+ return Promise.resolve();
240
+ }
241
+ /** The daily report: what was kept for each tenant, one tenant after the other. */
242
+ export async function reportCriticalDaily() {
243
+ for (const [tenantId, rows] of [...kept]) {
244
+ kept.delete(tenantId);
245
+ await post(tenantId, rows, "daily");
246
+ }
247
+ }
248
+ /** Starts hearing the broker and the daily report; the handle stops both. */
249
+ export function startCriticalReports() {
250
+ if (!managed) {
251
+ return () => undefined;
252
+ }
253
+ const off = onCritical((row) => void reportCritical(row));
254
+ const timer = setInterval(() => void reportCriticalDaily(), DAILY_MS);
255
+ timer.unref?.();
256
+ return () => {
257
+ off();
258
+ clearInterval(timer);
259
+ };
260
+ }
@@ -10,7 +10,7 @@ import { formulaEstimate } from "../credits/estimate.js";
10
10
  import { control, controlDb, db, schema, withTenant } from "../db/client.js";
11
11
  import { missingCapabilities, optionalCapabilities, stepsWithoutModel, } from "../engine/requirements.js";
12
12
  import { env } from "../env.js";
13
- import { managed, tenantInfo } from "../manage.js";
13
+ import { managed } from "../manage.js";
14
14
  import { classCatalog, imageCostUsd, tokenCostUsd, videoCostUsd, WEB_SEARCH_COST_USD, } from "../models.js";
15
15
  import { pluginIdsOf, pluginStartersOf } from "../plugins/registry.js";
16
16
  import { readSetting, writeSetting } from "../settings.js";
@@ -219,37 +219,13 @@ async function keptOptional(ids, lang, unavailable) {
219
219
  }
220
220
  return out;
221
221
  }
222
- /** The team's level: the Manage-App's word on a managed runtime; elsewhere every level is open. */
223
- async function teamLevel() {
224
- if (!managed) {
225
- return null;
222
+ /** The featured entries first, under "Recommended"; a search keeps its order. */
223
+ export function featuredFirst(page, opts) {
224
+ if (opts.q?.trim()) {
225
+ return page;
226
226
  }
227
- const info = await tenantInfo(currentTenant()).catch(() => null);
228
- return info?.level ?? null;
229
- }
230
- /**
231
- * The catalog as the team's level leaves it (docs/plans/wizards-admin.md in the Manage
232
- * repository): a template above the level is not shown, the featured ones come first – those of
233
- * the team's own level before the rest – and the answer says the level.
234
- */
235
- export async function byLevel(page, opts) {
236
- const level = await teamLevel();
237
- const top = level?.level ?? Number.POSITIVE_INFINITY;
238
- const shown = page.entries.filter((e) => (e.level ?? 1) <= top);
239
- // A search keeps its order: the words found what fits best.
240
- const rank = (e) => e.featured ? ((e.level ?? 1) === level?.level ? 0 : 1) : 2;
241
- const entries = opts.q?.trim()
242
- ? shown
243
- : shown
244
- .map((e, i) => ({ e, i }))
245
- .sort((a, b) => rank(a.e) - rank(b.e) || a.i - b.i)
246
- .map((x) => x.e);
247
- return {
248
- ...page,
249
- entries,
250
- total: Math.max(0, page.total - (page.entries.length - shown.length)),
251
- level,
252
- };
227
+ const entries = [...page.entries].sort((a, b) => Number(!!b.featured) - Number(!!a.featured));
228
+ return { ...page, entries };
253
229
  }
254
230
  /**
255
231
  * Searches the tenant's plugins' starters and the marketplace, in that order: a page holds the
@@ -0,0 +1,165 @@
1
+ import { featureOn } from "@engenty/wizards-shared/features";
2
+ import { note } from "@engenty/wizards-shared/run";
3
+ import { and, eq } from "drizzle-orm";
4
+ import { db, schema } from "../db/client.js";
5
+ import { currentFeatures } from "../features.js";
6
+ import { managed } from "../manage.js";
7
+ import { currentTenant } from "../tenants/tenant.js";
8
+ import { currentRole, isAdminRole, requireAdmin } from "./access.js";
9
+ import { ServiceError } from "./errors.js";
10
+ /**
11
+ * Members in the Studio, one rule per space (docs/plans/capabilities.md, "Who sees the place"):
12
+ * „Mitglieder dürfen ins Studio“. Behind the `capabilities` switch; while it is off, a member
13
+ * reaches every space's studio API as before and edits what is there.
14
+ *
15
+ * With the switch on, a member of an organization reaches a space's studio API only where its
16
+ * admins opened the Studio to members. There they build and test wizards and add and change
17
+ * skills, knowledge and data. They publish nothing and share nothing outside the space, and they
18
+ * set up no connection and change no rule: those stay with the admins (their own guards). Work
19
+ * keeps what it reads in every space: the space's wizards to start, its files, its connectors and
20
+ * connections.
21
+ */
22
+ const CLOSED = () => new ServiceError("forbidden", note("studioClosedToMembers"));
23
+ const PUBLISH = () => new ServiceError("forbidden", note("onlyAdminsPublish"));
24
+ /** Whether the rule counts here: an organization's member, with `capabilities` on. */
25
+ async function ruledMember() {
26
+ return (managed && !isAdminRole(currentRole()) && featureOn(await currentFeatures(), "capabilities"));
27
+ }
28
+ /** Whether the person at hand builds in this space's Studio: always, but for a member by the rule. */
29
+ export async function studioOpen(space) {
30
+ return space.membersStudio || !(await ruledMember());
31
+ }
32
+ /**
33
+ * Making a wizard in a space: the admins', and with the switch on also the members' where the
34
+ * Studio is open to them.
35
+ */
36
+ export async function requireMaker(space) {
37
+ if (!(await ruledMember())) {
38
+ return requireAdmin();
39
+ }
40
+ if (!(await openToMembers(await space()))) {
41
+ throw CLOSED();
42
+ }
43
+ }
44
+ async function openToMembers(spaceId) {
45
+ const space = await db.query.space.findFirst({
46
+ where: and(eq(schema.space.id, spaceId), eq(schema.space.tenantId, currentTenant())),
47
+ columns: { membersStudio: true },
48
+ });
49
+ // A space that is not there is the route's "not found", not ours.
50
+ return space?.membersStudio ?? true;
51
+ }
52
+ /** What Work reads in any space of the organization, whatever the rule says. */
53
+ const WORK_READS = /^\/spaces\/[^/]+\/(wizards|files(\/[^/]+\/(content|text))?|connectors|connections)$/;
54
+ /** Publishing and sharing outside the space: the admins' alone. */
55
+ const PUBLISHING = [
56
+ ["POST", /^\/wizards\/[^/]+\/(publish|rotate-link|cloud)$/],
57
+ // Its settings: the link on or off, its limits, its channels, its translation, its space.
58
+ ["PATCH", /^\/wizards\/[^/]+$/],
59
+ ["PUT", /^\/wizards\/[^/]+\/translations\/[^/]+$/],
60
+ ["DELETE", /^\/wizards\/[^/]+\/translations\/[^/]+$/],
61
+ ];
62
+ /**
63
+ * The space of an item, by the kind and id the studio's addresses name it with
64
+ * (`/spaces/:id`, `/wizards/:id`, …; `runs` for a run's wizard), and what follows them.
65
+ */
66
+ async function spaceOfItem(kind, id, sub) {
67
+ const one = async (found) => (await found)?.spaceId ?? null;
68
+ const tenant = currentTenant();
69
+ switch (kind) {
70
+ case "spaces":
71
+ return id;
72
+ case "wizards":
73
+ return one(db.query.wizard.findFirst({
74
+ where: and(eq(schema.wizard.id, id), eq(schema.wizard.tenantId, tenant)),
75
+ columns: { spaceId: true },
76
+ }));
77
+ case "runs": {
78
+ const run = await db.query.run.findFirst({
79
+ where: and(eq(schema.run.id, id), eq(schema.run.tenantId, tenant)),
80
+ columns: { wizardId: true },
81
+ });
82
+ return run ? spaceOfItem("wizards", run.wizardId) : null;
83
+ }
84
+ case "tables":
85
+ return one(db.query.spaceTable.findFirst({
86
+ where: eq(schema.spaceTable.id, id),
87
+ columns: { spaceId: true },
88
+ }));
89
+ case "pages":
90
+ return one(db.query.spacePage.findFirst({
91
+ where: eq(schema.spacePage.id, id),
92
+ columns: { spaceId: true },
93
+ }));
94
+ case "categories":
95
+ return one(db.query.spaceCategory.findFirst({
96
+ where: eq(schema.spaceCategory.id, id),
97
+ columns: { spaceId: true },
98
+ }));
99
+ case "values": {
100
+ const value = await db.query.spaceCategoryValue.findFirst({
101
+ where: eq(schema.spaceCategoryValue.id, id),
102
+ columns: { categoryId: true },
103
+ });
104
+ return value ? spaceOfItem("categories", value.categoryId) : null;
105
+ }
106
+ case "skills":
107
+ return one(db.query.spaceSkill.findFirst({
108
+ where: eq(schema.spaceSkill.id, id),
109
+ columns: { spaceId: true },
110
+ }));
111
+ case "connections":
112
+ // A person's own sign-in is theirs, in their menu.
113
+ return sub === "my-sign-in"
114
+ ? null
115
+ : one(db.query.spaceConnection.findFirst({
116
+ where: eq(schema.spaceConnection.id, id),
117
+ columns: { spaceId: true },
118
+ }));
119
+ default:
120
+ return null;
121
+ }
122
+ }
123
+ /**
124
+ * Whether this space's Studio is closed to the person at hand: a member, where its admins did not
125
+ * open it. What a list leaves out for them.
126
+ */
127
+ export async function closedToMe(spaceId) {
128
+ return (await ruledMember()) && !(await openToMembers(spaceId));
129
+ }
130
+ /**
131
+ * The studio's „closed“ answer for an item of a space closed to the person at hand: the same 403
132
+ * through every door (the studio API, MCP, `/api/v1`, Goose). `kind` as the studio's addresses
133
+ * name it: `spaces`, `wizards`, `runs`, `tables`, `pages`, `skills`, `connections`, ….
134
+ */
135
+ export async function requireStudio(kind, id, sub) {
136
+ if (!(await ruledMember())) {
137
+ return;
138
+ }
139
+ const spaceId = await spaceOfItem(kind, id, sub);
140
+ if (spaceId && !(await openToMembers(spaceId))) {
141
+ throw CLOSED();
142
+ }
143
+ }
144
+ /**
145
+ * The studio API for a member, after the guard in app.ts set who they are: refuses a space whose
146
+ * Studio is closed to members, and publishing anywhere. Admins and owners pass untouched.
147
+ */
148
+ export async function membersStudioGate(c, next) {
149
+ if (!(await ruledMember())) {
150
+ return next();
151
+ }
152
+ const method = c.req.method;
153
+ const path = c.req.path.slice(c.req.path.indexOf("/api/studio") + "/api/studio".length);
154
+ if (PUBLISHING.some(([m, re]) => m === method && re.test(path))) {
155
+ throw PUBLISH();
156
+ }
157
+ if (method === "GET" && WORK_READS.test(path)) {
158
+ return next();
159
+ }
160
+ const [, kind = "", id, sub] = path.split("/");
161
+ if (id) {
162
+ await requireStudio(kind, id, sub);
163
+ }
164
+ return next();
165
+ }
@@ -1,6 +1,6 @@
1
1
  import { ADDRESS_NAMES, addressKind, addressUrl } from "@engenty/wizards-shared/addresses";
2
- import { factKey, PROJECT_LIMITS, } from "@engenty/wizards-shared/projects";
3
2
  import { matchSectors } from "@engenty/wizards-shared/sectors";
3
+ import { factKey, SPACE_LIMITS, } from "@engenty/wizards-shared/spaces";
4
4
  import { nanoid } from "nanoid";
5
5
  import { readCompany } from "../agents/company.js";
6
6
  import { readContact, readWebsite } from "../agents/website.js";
@@ -8,8 +8,8 @@ import { managed } from "../manage.js";
8
8
  import { readSetting, writeSetting } from "../settings.js";
9
9
  import { serverText } from "../texts.js";
10
10
  import { isAdminRole } from "./access.js";
11
- import { addProjectFileFromUrl, projectFiles } from "./project-files.js";
12
- import { listProjects, ownedProject, updateProject } from "./projects.js";
11
+ import { addSpaceFileFromUrl, spaceFiles } from "./space-files.js";
12
+ import { listSpaces, ownedSpace, updateSpace } from "./spaces.js";
13
13
  const organizationKey = (tenantId) => `onboarding:${tenantId}`;
14
14
  const personKey = (userId) => `onboarding:person:${userId}`;
15
15
  const visitKey = (tenantId, userId) => `onboarding:visit:${tenantId}:${userId}`;
@@ -18,8 +18,8 @@ async function setUp(user) {
18
18
  if (await readSetting(organizationKey(user.tenantId))) {
19
19
  return true;
20
20
  }
21
- const projects = await listProjects(user.id);
22
- return projects.some((p) => p.wizardCount > 0);
21
+ const spaces = await listSpaces(user.id);
22
+ return spaces.some((p) => p.wizardCount > 0);
23
23
  }
24
24
  /**
25
25
  * The person went through the studio's first visit before: their own mark, or, from before
@@ -276,7 +276,7 @@ export function withFacts(facts, found, lang, more = []) {
276
276
  // Beyond the basics, a value the space has under another label is not added twice.
277
277
  (i >= FACTS.length && next.some((f) => sameValue(f.value, value))) ||
278
278
  (at >= 0 && next[at].value.trim()) ||
279
- (at < 0 && next.length >= PROJECT_LIMITS.facts)) {
279
+ (at < 0 && next.length >= SPACE_LIMITS.facts)) {
280
280
  continue;
281
281
  }
282
282
  if (at >= 0) {
@@ -305,7 +305,7 @@ const ASSETS = 4;
305
305
  * completes name, about, facts and fonts; without a model or credits the patterns' reading
306
306
  * stands.
307
307
  */
308
- export async function applyWebsite(userId, projectId, url, lang) {
308
+ export async function applyWebsite(userId, spaceId, url, lang) {
309
309
  const signal = AbortSignal.timeout(30_000);
310
310
  const reading = await readWebsite(url, signal, { inline: true });
311
311
  const colors = brandColors(reading.brand);
@@ -336,15 +336,15 @@ export async function applyWebsite(userId, projectId, url, lang) {
336
336
  const name = read?.name ?? found.name;
337
337
  const about = read?.about ?? found.about;
338
338
  const company = read?.company ?? contact.company;
339
- const project = await ownedProject(userId, projectId);
340
- const fonts = project.brand.fonts?.length ? [] : read?.fonts.length ? read.fonts : found.fonts;
341
- const facts = withFacts(project.facts, {
339
+ const space = await ownedSpace(userId, spaceId);
340
+ const fonts = space.brand.fonts?.length ? [] : read?.fonts.length ? read.fonts : found.fonts;
341
+ const facts = withFacts(space.facts, {
342
342
  ...contact,
343
343
  // The full name only where it says more than the name the space goes by.
344
344
  company: company?.toLowerCase() === name.toLowerCase() ? undefined : company,
345
345
  website,
346
346
  }, lang, read?.facts);
347
- await updateProject(userId, projectId, {
347
+ await updateSpace(userId, spaceId, {
348
348
  brand: {
349
349
  name,
350
350
  ...(about ? { about } : {}),
@@ -357,13 +357,13 @@ export async function applyWebsite(userId, projectId, url, lang) {
357
357
  const [logo, assets] = await Promise.all([
358
358
  (async () => {
359
359
  const first = reading.brand.logos[0];
360
- if (!first || (await projectFiles(projectId, "logo")).length > 0) {
360
+ if (!first || (await spaceFiles(spaceId, "logo")).length > 0) {
361
361
  return false;
362
362
  }
363
- return keep(projectId, first.url, "logo", first.hint);
363
+ return keep(spaceId, first.url, "logo", first.hint);
364
364
  })(),
365
365
  (async () => {
366
- if ((await projectFiles(projectId, "asset")).length > 0) {
366
+ if ((await spaceFiles(spaceId, "asset")).length > 0) {
367
367
  return 0;
368
368
  }
369
369
  const pictures = reading.brand.images.filter((i) => i.hero).slice(0, ASSETS);
@@ -374,7 +374,7 @@ export async function applyWebsite(userId, projectId, url, lang) {
374
374
  const description = picture.alt.startsWith("share image")
375
375
  ? `share image of ${host}`
376
376
  : picture.alt || `picture on the home page of ${host}`;
377
- kept += Number(await keep(projectId, picture.url, "asset", description, until));
377
+ kept += Number(await keep(spaceId, picture.url, "asset", description, until));
378
378
  }
379
379
  return kept;
380
380
  })(),
@@ -395,13 +395,13 @@ export async function applyWebsite(userId, projectId, url, lang) {
395
395
  * `applyWebsite` does, every other address (profiles, a blog, a second site) as a fact under its
396
396
  * name. Null where none of them is a website.
397
397
  */
398
- export async function applyAddresses(userId, projectId, raw, lang) {
398
+ export async function applyAddresses(userId, spaceId, raw, lang) {
399
399
  const urls = [...new Set(raw.flatMap((r) => addressUrl(r) ?? []))].slice(0, 10);
400
400
  const site = urls.find((u) => addressKind(u) === "website");
401
- const outcome = site ? await applyWebsite(userId, projectId, site, lang) : null;
401
+ const outcome = site ? await applyWebsite(userId, spaceId, site, lang) : null;
402
402
  const rest = urls.filter((u) => u !== site);
403
403
  if (rest.length) {
404
- const project = await ownedProject(userId, projectId);
404
+ const space = await ownedSpace(userId, spaceId);
405
405
  const named = rest.map((url) => {
406
406
  const kind = addressKind(url);
407
407
  const count = rest.filter((u) => addressKind(u) === kind).indexOf(url);
@@ -410,9 +410,9 @@ export async function applyAddresses(userId, projectId, raw, lang) {
410
410
  value: url,
411
411
  };
412
412
  });
413
- const facts = withFacts(project.facts, {}, lang, named);
413
+ const facts = withFacts(space.facts, {}, lang, named);
414
414
  if (facts.added) {
415
- await updateProject(userId, projectId, { facts: facts.facts });
415
+ await updateSpace(userId, spaceId, { facts: facts.facts });
416
416
  }
417
417
  if (outcome) {
418
418
  outcome.facts += facts.added;
@@ -421,9 +421,9 @@ export async function applyAddresses(userId, projectId, raw, lang) {
421
421
  return outcome;
422
422
  }
423
423
  /** A picture of the site kept in the space; one that cannot be fetched is no loss. */
424
- async function keep(projectId, url, kind, description, signal = AbortSignal.timeout(15_000)) {
424
+ async function keep(spaceId, url, kind, description, signal = AbortSignal.timeout(15_000)) {
425
425
  try {
426
- await addProjectFileFromUrl(projectId, { url, kind, description, signal });
426
+ await addSpaceFileFromUrl(spaceId, { url, kind, description, signal });
427
427
  return true;
428
428
  }
429
429
  catch {
@@ -4,7 +4,7 @@ import { cleanPath, WORKSPACE_LIMITS } from "@engenty/wizards-shared/workspace";
4
4
  import { strFromU8, unzipSync } from "fflate";
5
5
  import { ServiceError } from "./errors.js";
6
6
  /**
7
- * Reading a `.wizard` package, with nothing of a project or a database: the studio's import and
7
+ * Reading a `.wizard` package, with nothing of a space or a database: the studio's import and
8
8
  * `wizards validate` both start here.
9
9
  */
10
10
  const invalid = (said) => new ServiceError("invalid", said);
@@ -5,17 +5,17 @@ import { listConnectors } from "../connectors/external.js";
5
5
  import { db, schema } from "../db/client.js";
6
6
  import { getBlob } from "../files/blobs.js";
7
7
  import { serverText } from "../texts.js";
8
- import { requireAdmin } from "./access.js";
9
8
  import { draftFiles, writeFile } from "./files.js";
10
9
  import { pageTree } from "./knowledge.js";
10
+ import { requireMaker } from "./members-studio.js";
11
11
  import { readPackage } from "./package-file.js";
12
- import { ownedProject } from "./projects.js";
12
+ import { ownedSpace } from "./spaces.js";
13
13
  import { importThemes, themesOf } from "./themes.js";
14
14
  import { createWizard, deleteWizard, draftIssues, ownedWizard, parseDraft } from "./wizards.js";
15
15
  /** A wizard as a file — the format is `@engenty/wizards-shared/wizard-package`'s. */
16
- /** Where the project's pages go in a package, as Markdown the standalone runner reads inline. */
16
+ /** Where the space's pages go in a package, as Markdown the standalone runner reads inline. */
17
17
  export const KNOWLEDGE_DIR = "knowledge/";
18
- /** How much of the project's knowledge a package takes along: enough pages, never the whole space. */
18
+ /** How much of the space's knowledge a package takes along: enough pages, never the whole space. */
19
19
  export const KNOWLEDGE_MAX_CHARS = 2_000_000;
20
20
  /** What one page may hold in the package (the plugin hands a file to the model up to there). */
21
21
  export const KNOWLEDGE_PAGE_CHARS = 60_000;
@@ -44,7 +44,7 @@ export async function exportWizard(userId, wizardId, options = {}) {
44
44
  return null;
45
45
  }
46
46
  const definition = live ? live.definition : w.draft;
47
- const project = await ownedProject(userId, w.projectId);
47
+ const space = await ownedSpace(userId, w.spaceId);
48
48
  const named = new Set((definition.connections ?? []).map((c) => c.connector));
49
49
  const manifest = {
50
50
  $schema: PACKAGE_SCHEMA_URL,
@@ -52,7 +52,7 @@ export async function exportWizard(userId, wizardId, options = {}) {
52
52
  version: 1,
53
53
  exportedAt: new Date().toISOString(),
54
54
  definition,
55
- connectors: (await listConnectors(project.id))
55
+ connectors: (await listConnectors(space.id))
56
56
  .filter((c) => c.sourceKind !== "builtin" && named.has(c.id))
57
57
  .map((c) => ({
58
58
  id: c.id,
@@ -60,14 +60,14 @@ export async function exportWizard(userId, wizardId, options = {}) {
60
60
  domain: c.domain,
61
61
  sourceKind: c.sourceKind,
62
62
  })),
63
- themes: themesOf(definition.themes, project.themes),
63
+ themes: themesOf(definition.themes, space.themes),
64
64
  };
65
65
  const entries = {};
66
66
  for (const f of live ? live.files : await draftFiles(w.id)) {
67
67
  entries[PACKAGE_FILES + f.path] = new Uint8Array(await getBlob(f.hash));
68
68
  }
69
69
  if (options.knowledge) {
70
- const snapshot = await knowledgeSnapshot(project.id);
70
+ const snapshot = await knowledgeSnapshot(space.id);
71
71
  manifest.knowledge = { pages: snapshot.pages.length, truncated: snapshot.truncated };
72
72
  for (const page of snapshot.pages) {
73
73
  entries[PACKAGE_FILES + KNOWLEDGE_DIR + page.path] = strToU8(page.text);
@@ -77,15 +77,15 @@ export async function exportWizard(userId, wizardId, options = {}) {
77
77
  return { name: fileName(definition.title), zip: zipSync(entries, { level: 6 }) };
78
78
  }
79
79
  /**
80
- * The project's pages as Markdown files, one per page at its path (`pages/<a>/<b>` becomes
80
+ * The space's pages as Markdown files, one per page at its path (`pages/<a>/<b>` becomes
81
81
  * `a/b.md`), each with its title in front: what a wizard that ran with `pages` reads inline on
82
82
  * a site without the space. Opt-in, and capped: a page is cut at its own limit, and the pages
83
83
  * stop where the whole would pass the snapshot's; `truncated` says so.
84
84
  */
85
- export async function knowledgeSnapshot(projectId) {
86
- const tree = await pageTree(projectId);
85
+ export async function knowledgeSnapshot(spaceId) {
86
+ const tree = await pageTree(spaceId);
87
87
  const rows = await db.query.spacePage.findMany({
88
- where: and(eq(schema.spacePage.projectId, projectId), isNull(schema.spacePage.wizardId)),
88
+ where: and(eq(schema.spacePage.spaceId, spaceId), isNull(schema.spacePage.wizardId)),
89
89
  columns: { id: true, markdown: true },
90
90
  });
91
91
  const markdown = new Map(rows.map((r) => [r.id, r.markdown]));
@@ -114,10 +114,10 @@ export async function knowledgeSnapshot(projectId) {
114
114
  function yamlValue(s) {
115
115
  return JSON.stringify(s);
116
116
  }
117
- /** What the wizard names that the project does not have, in words for the chat. */
118
- async function missing(userId, projectId, draft, manifest) {
119
- const project = await ownedProject(userId, projectId);
120
- const connectors = await listConnectors(project.id);
117
+ /** What the wizard names that the space does not have, in words for the chat. */
118
+ async function missing(userId, spaceId, draft, manifest) {
119
+ const space = await ownedSpace(userId, spaceId);
120
+ const connectors = await listConnectors(space.id);
121
121
  const wanted = [...new Set((draft.connections ?? []).flatMap((c) => c.connector ?? []))];
122
122
  return [
123
123
  ...wanted
@@ -128,17 +128,17 @@ async function missing(userId, projectId, draft, manifest) {
128
128
  }),
129
129
  ];
130
130
  }
131
- /** Makes a new wizard of a package in the project: the draft and its workspace, not published. */
132
- export async function importWizard(userId, projectId, data, name,
131
+ /** Makes a new wizard of a package in the space: the draft and its workspace, not published. */
132
+ export async function importWizard(userId, spaceId, data, name,
133
133
  /** The language the admin reads the import's note in. */
134
134
  lang = "en") {
135
- await requireAdmin();
135
+ await requireMaker(async () => spaceId);
136
136
  const { manifest, files } = readPackage(data);
137
137
  // The shape is checked before anything is written; a wrong one leaves no wizard behind.
138
138
  const { draft } = parseDraft(manifest.definition, files.map((f) => f.path));
139
- const lacks = await missing(userId, projectId, draft, manifest);
139
+ const lacks = await missing(userId, spaceId, draft, manifest);
140
140
  // The wizard's looks come into the space; one whose id is taken by another look is renamed.
141
- const renamed = await importThemes(projectId, manifest.themes);
141
+ const renamed = await importThemes(spaceId, manifest.themes);
142
142
  if (draft.themes) {
143
143
  draft.themes = draft.themes.map((id) => renamed[id] ?? id);
144
144
  }
@@ -153,7 +153,7 @@ lang = "en") {
153
153
  ]
154
154
  .filter(Boolean)
155
155
  .join("\n\n");
156
- const { id } = await createWizard(userId, { projectId, definition: draft, note });
156
+ const { id } = await createWizard(userId, { spaceId, definition: draft, note });
157
157
  try {
158
158
  for (const file of files) {
159
159
  await writeFile(userId, id, file.path, file.data);