@engenty/wizards-runtime 0.13.0 → 0.14.1

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 (313) 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 +101 -67
  5. package/apps/runtime/dist/agents/website.js +1 -1
  6. package/apps/runtime/dist/app.js +17 -1
  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/db/adopt.js +3 -3
  29. package/apps/runtime/dist/db/client.js +26 -0
  30. package/apps/runtime/dist/db/live-triggers.js +65 -23
  31. package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
  32. package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
  33. package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
  34. package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +8 -8
  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 +40 -5
  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/protocol.md +80 -0
  84. package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
  85. package/apps/runtime/dist/docs/user-guide/space.md +5 -4
  86. package/apps/runtime/dist/docs/user-guide/together.md +16 -2
  87. package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
  88. package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
  89. package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
  90. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
  91. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
  92. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
  93. package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
  94. package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
  95. package/apps/runtime/dist/engine/resources.js +43 -12
  96. package/apps/runtime/dist/engine/runner.js +75 -23
  97. package/apps/runtime/dist/engine/steps.js +30 -12
  98. package/apps/runtime/dist/engine/template.js +18 -1
  99. package/apps/runtime/dist/env.js +9 -4
  100. package/apps/runtime/dist/index.js +18 -2
  101. package/apps/runtime/dist/live/feed.js +2 -2
  102. package/apps/runtime/dist/live/origin.js +2 -2
  103. package/apps/runtime/dist/live/views.js +51 -26
  104. package/apps/runtime/dist/manage.js +7 -0
  105. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  106. package/apps/runtime/dist/mcp/tools.js +75 -34
  107. package/apps/runtime/dist/models.js +1 -1
  108. package/apps/runtime/dist/motion-graphics/project.js +8 -8
  109. package/apps/runtime/dist/motion-graphics/tools.js +1 -1
  110. package/apps/runtime/dist/plugins/events.js +2 -2
  111. package/apps/runtime/dist/plugins/jobs.js +4 -1
  112. package/apps/runtime/dist/plugins/loader.js +2 -2
  113. package/apps/runtime/dist/prompts/architect.md +3 -3
  114. package/apps/runtime/dist/prompts/authoring.md +46 -12
  115. package/apps/runtime/dist/prompts/goose.md +7 -7
  116. package/apps/runtime/dist/prompts/mcp.md +6 -6
  117. package/apps/runtime/dist/prompts/services.md +4 -4
  118. package/apps/runtime/dist/prompts/step.md +2 -2
  119. package/apps/runtime/dist/prompts/tools.md +39 -10
  120. package/apps/runtime/dist/routes/api.js +31 -20
  121. package/apps/runtime/dist/routes/broker.js +316 -0
  122. package/apps/runtime/dist/routes/connections.js +71 -0
  123. package/apps/runtime/dist/routes/delivery.js +25 -0
  124. package/apps/runtime/dist/routes/discover.js +17 -0
  125. package/apps/runtime/dist/routes/live.js +11 -1
  126. package/apps/runtime/dist/routes/person.js +4 -1
  127. package/apps/runtime/dist/routes/plugins.js +3 -1
  128. package/apps/runtime/dist/routes/rules.js +26 -0
  129. package/apps/runtime/dist/routes/runs.js +54 -33
  130. package/apps/runtime/dist/routes/skills.js +6 -6
  131. package/apps/runtime/dist/routes/studio.js +153 -144
  132. package/apps/runtime/dist/routes/work.js +199 -0
  133. package/apps/runtime/dist/sandbox/index.js +27 -0
  134. package/apps/runtime/dist/services/access.js +38 -17
  135. package/apps/runtime/dist/services/api.js +38 -13
  136. package/apps/runtime/dist/services/architect.js +3 -3
  137. package/apps/runtime/dist/services/assistant-chats.js +9 -1
  138. package/apps/runtime/dist/services/brand.js +12 -12
  139. package/apps/runtime/dist/services/broker-bell.js +69 -0
  140. package/apps/runtime/dist/services/broker-notify.js +127 -0
  141. package/apps/runtime/dist/services/client-steps.js +79 -0
  142. package/apps/runtime/dist/services/cloud.js +42 -42
  143. package/apps/runtime/dist/services/command-risk.js +51 -0
  144. package/apps/runtime/dist/services/discover.js +85 -0
  145. package/apps/runtime/dist/services/knowledge-model.js +13 -13
  146. package/apps/runtime/dist/services/knowledge.js +117 -80
  147. package/apps/runtime/dist/services/manage-reports.js +74 -7
  148. package/apps/runtime/dist/services/members-studio.js +165 -0
  149. package/apps/runtime/dist/services/onboarding.js +22 -22
  150. package/apps/runtime/dist/services/package-file.js +1 -1
  151. package/apps/runtime/dist/services/package.js +22 -22
  152. package/apps/runtime/dist/services/pages.js +7 -7
  153. package/apps/runtime/dist/services/runs.js +4 -3
  154. package/apps/runtime/dist/services/seen.js +55 -0
  155. package/apps/runtime/dist/services/shares.js +23 -13
  156. package/apps/runtime/dist/services/site.js +23 -23
  157. package/apps/runtime/dist/services/skills-registry.js +15 -15
  158. package/apps/runtime/dist/services/skills.js +44 -44
  159. package/apps/runtime/dist/services/space-categories.js +35 -35
  160. package/apps/runtime/dist/services/space-data.js +130 -111
  161. package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
  162. package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
  163. package/apps/runtime/dist/services/space-origin.js +19 -11
  164. package/apps/runtime/dist/services/spaces.js +478 -612
  165. package/apps/runtime/dist/services/synced-spaces.js +668 -0
  166. package/apps/runtime/dist/services/themes.js +15 -15
  167. package/apps/runtime/dist/services/widgets.js +6 -6
  168. package/apps/runtime/dist/services/wizards.js +112 -38
  169. package/apps/runtime/dist/services/work-ai.js +257 -0
  170. package/apps/runtime/dist/services/work-approvals.js +104 -0
  171. package/apps/runtime/dist/services/work-chats.js +908 -0
  172. package/apps/runtime/dist/services/work-connections.js +90 -0
  173. package/apps/runtime/dist/services/work-files.js +85 -0
  174. package/apps/runtime/dist/services/work-mastra.js +73 -0
  175. package/apps/runtime/dist/services/work-sandbox.js +42 -0
  176. package/apps/runtime/dist/sharing/files.js +14 -4
  177. package/apps/runtime/dist/sharing/index.js +40 -39
  178. package/apps/runtime/dist/sharing/jobs.js +67 -17
  179. package/apps/runtime/dist/sharing/targets/connector.js +10 -6
  180. package/apps/runtime/dist/sharing/targets/email.js +10 -8
  181. package/apps/runtime/dist/sharing/targets/slack.js +10 -8
  182. package/apps/runtime/dist/sharing/targets/storage.js +6 -4
  183. package/apps/runtime/dist/store/index.js +14 -3
  184. package/apps/runtime/dist/store/shared-lists.js +4 -2
  185. package/apps/runtime/dist/sync/apply.js +2 -2
  186. package/apps/runtime/dist/sync/client.js +113 -113
  187. package/apps/runtime/dist/sync/hub.js +41 -41
  188. package/apps/runtime/dist/sync/log.js +12 -12
  189. package/apps/runtime/dist/sync/records.js +118 -120
  190. package/apps/runtime/dist/texts.js +38 -2
  191. package/apps/runtime/dist/tools/connections.js +112 -0
  192. package/apps/runtime/dist/tools/connector.js +157 -67
  193. package/apps/runtime/dist/tools/index.js +28 -13
  194. package/apps/runtime/dist/tools/mail.js +40 -11
  195. package/apps/runtime/dist/tools/pages.js +11 -5
  196. package/apps/runtime/dist/tools/plugin.js +43 -7
  197. package/apps/runtime/dist/tools/skills.js +1 -1
  198. package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
  199. package/apps/runtime/dist/tools/store.js +3 -2
  200. package/apps/runtime/dist/widgets/step.js +10 -10
  201. package/apps/web/dist/assets/AboutDialog-SpDcn8VZ.js +1 -0
  202. package/apps/web/dist/assets/CapabilitiesPage-Bgnm_3dk.js +2 -0
  203. package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-DAnjV6cZ.js} +1 -1
  204. package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
  205. package/apps/web/dist/assets/EditorPage-B98C-9Nv.js +3 -0
  206. package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.js → FlowPreview-aMfwcPul.js} +1 -1
  207. package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
  208. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
  209. package/apps/web/dist/assets/NewWizardChannels-D8IYLg_S.js +1 -0
  210. package/apps/web/dist/assets/NewWizardPage-DlBt0Mfq.js +7 -0
  211. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
  212. package/apps/web/dist/assets/PreviewPane-DC1kAi3x.js +9 -0
  213. package/apps/web/dist/assets/PublicRunner-D6lKP0j8.js +1 -0
  214. package/apps/web/dist/assets/ReadOnly-DFsuKPCw.js +1 -0
  215. package/apps/web/dist/assets/SettingsPage-DkHeCO2c.js +2 -0
  216. package/apps/web/dist/assets/SetupPage-DZ8xRkfS.js +1 -0
  217. package/apps/web/dist/assets/SharePage-494ZPsjQ.js +1 -0
  218. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
  219. package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
  220. package/apps/web/dist/assets/SpacePage-CWlU_BZP.js +2 -0
  221. package/apps/web/dist/assets/UpdateCheck-BKNkNJyG.js +2 -0
  222. package/apps/web/dist/assets/changelog-BhMZS-rs.js +1 -0
  223. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
  224. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
  225. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
  226. package/apps/web/dist/assets/{code-xml-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
  227. package/apps/web/dist/assets/connection-sign-in-Cngd_QDO.js +1 -0
  228. package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
  229. package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
  230. package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
  231. package/apps/web/dist/assets/host-C0WQlRKB.js +118 -0
  232. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
  233. package/apps/web/dist/assets/index-ClVtdDUZ.js +10 -0
  234. package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
  235. package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
  236. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
  237. package/apps/web/dist/assets/{phone-DhkHteoJ.js → phone-Ctvf-Am-.js} +1 -1
  238. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
  239. package/apps/web/dist/assets/{runners-G-XYaDgR.js → runners-CyIvJIHr.js} +1 -1
  240. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
  241. package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
  242. package/apps/web/dist/assets/theme-BCau3f6O.js +11 -0
  243. package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
  244. package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
  245. package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
  246. package/apps/web/dist/assets/{volume-2-CVHoxdGM.js → volume-2-CU_oy81Z.js} +1 -1
  247. package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
  248. package/apps/web/dist/index.html +17 -10
  249. package/apps/web/dist/mcp/flow.html +119 -64
  250. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
  251. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -1
  252. package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -1
  253. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
  254. package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
  255. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +150 -8
  256. package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
  257. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
  258. package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
  259. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +26 -2
  260. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -2
  261. package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
  262. package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
  263. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
  264. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
  265. package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
  266. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
  267. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
  268. package/node_modules/@engenty/wizards-shared/dist/run.js +85 -0
  269. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
  270. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
  271. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
  272. package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
  273. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
  274. package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
  275. package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
  276. package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
  277. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
  278. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
  279. package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
  280. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
  281. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
  282. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
  283. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
  284. package/package.json +4 -1
  285. package/plugin/.claude-plugin/plugin.json +1 -1
  286. package/plugin/plugin.json +1 -1
  287. package/plugin/skills/build-wizard/SKILL.md +1 -1
  288. package/apps/runtime/dist/services/projects.js +0 -473
  289. package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +0 -1
  290. package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
  291. package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
  292. package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
  293. package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
  294. package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
  295. package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
  296. package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
  297. package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
  298. package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
  299. package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
  300. package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
  301. package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
  302. package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
  303. package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
  304. package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
  305. package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
  306. package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
  307. package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
  308. package/apps/web/dist/assets/lock-C0uxcOlq.js +0 -1
  309. package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
  310. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
  311. package/apps/web/dist/assets/session-BWI-KENJ.js +0 -2
  312. package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
  313. package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
@@ -4,9 +4,9 @@ import { ASSISTANT_LAYOUTS, ASSISTANT_PAGE_BYTES, ASSISTANT_WIDTH, assistantSign
4
4
  import { LANGS, MODEL_CLASSES, TEXT_CLASSES, } from "@engenty/wizards-shared/definition";
5
5
  import { CATEGORY_TYPES, whereSchema } from "@engenty/wizards-shared/knowledge";
6
6
  import { PRESENCE_KINDS } from "@engenty/wizards-shared/live";
7
- import { PROJECT_FILE_KINDS } from "@engenty/wizards-shared/projects";
8
7
  import { CLASS_NAMES, isCreditsRef, modelLabel } from "@engenty/wizards-shared/providers";
9
8
  import { note } from "@engenty/wizards-shared/run";
9
+ import { SPACE_FILE_KINDS } from "@engenty/wizards-shared/spaces";
10
10
  import { MAX_MASK_LABEL_CHARS, MAX_MASK_LABELS, modelPolicySchema, } from "@engenty/wizards-shared/tiers";
11
11
  import { PACKAGE_EXTENSION, PACKAGE_MAX_BYTES, PACKAGE_MIME, } from "@engenty/wizards-shared/wizard-package";
12
12
  import { generateText } from "ai";
@@ -21,6 +21,7 @@ import { answerBrowser, awaitBrowser } from "../assistant/browser.js";
21
21
  import { endRun, signalRun, startRun, takeSignals } from "../assistant/runs.js";
22
22
  import { accountOverview, linkedAccount, startLink, unlink } from "../auth/account.js";
23
23
  import { createLocalKey, deleteLocalKey, listLocalKeys } from "../auth/keys.js";
24
+ import { assertRwx, subjectsOfPerson } from "../broker/rwx.js";
24
25
  import { appStates, connectApps } from "../cli/connect.js";
25
26
  import { layout } from "../cli/home.js";
26
27
  import { connectorImportSchema, importConnector, previewSource, refreshConnector, registryService, removeConnector, searchRegistry, } from "../connectors/external.js";
@@ -43,9 +44,9 @@ import { errorText, saidOf } from "../model-errors.js";
43
44
  import { blockedBinding, CHAT_WAYS, checkKey, classProblem, classWays, DECISION_CHOICES, EMBEDDING_CHOICES, embeddingModel, hasTextModel, LOCAL_KEYS, localModelSettings, ModelUnavailableError, modelSettings, saveLocalModels, saveModels, setUpKey, setUpOllama, storedKey, textModel, } from "../models.js";
44
45
  import { refreshPro } from "../plugins/pro.js";
45
46
  import { HTML_RESPONSE_CSP } from "../render/guard.js";
46
- import { isAdminRole, mayBuild, mayCreate, projectWritable, requireAdmin, requireWritable, } from "../services/access.js";
47
+ import { isAdminRole, mayBuild, mayCreate, requireAdmin, requireWritable, spaceWritable, } from "../services/access.js";
47
48
  import { architectTurn } from "../services/architect.js";
48
- import { addMessage, assistantLayout, assistantWidth, currentChat, earlierChats, foldChat, newChat, openChat, readChat, turnHistory, } from "../services/assistant-chats.js";
49
+ import { addMessage, assistantLayout, assistantLayouts, assistantWidth, currentChat, earlierChats, foldChat, newChat, openChat, readChat, turnHistory, } from "../services/assistant-chats.js";
49
50
  import { describeGradient, themeLooks } from "../services/brand.js";
50
51
  import { chatCatalog, chatModelChoices, setChatModelChoice } from "../services/chat-models.js";
51
52
  import { checkForCloud, cloudLinked, cloudSpaces, cloudState, forgetCloud, publishAndSync, pushSharing, removeFromCloud, replaceCloudSpaces, rotateInCloud, syncToCloud, } from "../services/cloud.js";
@@ -53,6 +54,7 @@ import { notFound, ServiceError } from "../services/errors.js";
53
54
  import { deleteFile, listFiles, readFile, writeFile } from "../services/files.js";
54
55
  import { categoryContents, listKnowledge, resolvePath, valueContents, } from "../services/knowledge.js";
55
56
  import { writeSummary } from "../services/knowledge-model.js";
57
+ import { closedToMe } from "../services/members-studio.js";
56
58
  import { applyAddresses, finishOnboarding, onboardingFor, startingName, } from "../services/onboarding.js";
57
59
  import { findAddresses, siteOfEmail } from "../services/onboarding-find.js";
58
60
  import { setOrganizationContext } from "../services/organization-context.js";
@@ -60,25 +62,25 @@ import { exportWizard, importWizard } from "../services/package.js";
60
62
  import { pagePreview } from "../services/pages.js";
61
63
  import { asAssistantIn, leave, markPresent, presentByItem, presentIn, } from "../services/presence.js";
62
64
  import { profileSchema, saveProfile, saveUserLang, userLang, userProfile, } from "../services/profile.js";
63
- import { addProjectFile, addProjectFileFromUrl, fileView, orderProjectFiles, projectFile, projectFileContent, reindexProjectFile, removeProjectFile, updateProjectFile, } from "../services/project-files.js";
64
- import { documentText, queueIndex, reindexAll, searchKnowledge, } from "../services/project-index.js";
65
- import { createProject, deleteProject, gradientSchema, ownedProject, projectLimitOrNull, projectPatchSchema, updateProject, } from "../services/projects.js";
66
65
  import { runnersOf, wizardRunners } from "../services/runners.js";
67
66
  import { draftStepView, listResults, listRuns, startTestRun } from "../services/runs.js";
68
67
  import { addCategoryValue, categoryRow, categoryValue, deleteCategory, deleteCategoryValue, mergeCategoryValues, orderCategoryValues, putCategory, renameCategoryValue, setItemCategory, updateCategory, } from "../services/space-categories.js";
69
68
  import { addTableRow, createPage, createTable, deletePage, deleteTable, deleteTableRows, getPage, getTable, listSpaceData, orderSubPages, updatePage, updateTable, updateTableRow, } from "../services/space-data.js";
69
+ import { addSpaceFile, addSpaceFileFromUrl, fileView, orderSpaceFiles, reindexSpaceFile, removeSpaceFile, spaceFile, spaceFileContent, updateSpaceFile, } from "../services/space-files.js";
70
+ import { documentText, queueIndex, reindexAll, searchKnowledge } from "../services/space-index.js";
71
+ import { createSpace, deleteSpace, gradientSchema, ownedSpace, spaceLimitOrNull, spacePatchSchema, updateSpace, } from "../services/spaces.js";
70
72
  import { deleteTheme, listThemes, saveTheme } from "../services/themes.js";
71
73
  import { deleteTranslation, editTranslation, isLangCode, publishedDefinition, } from "../services/translations.js";
72
74
  import { draftWidgetPreview } from "../services/widgets.js";
73
75
  import { createWizard, deleteWizard, draftChanges, duplicateWizard, hasWizards, ownedWizard, rotateShareLink, updateWizardSettings, writableWizard, writeDraft, } from "../services/wizards.js";
74
76
  import { deleteSetting, readSetting, writeSetting } from "../settings.js";
75
- import { projectShareTargets, sharePreview } from "../sharing/index.js";
77
+ import { sharePreview, spaceShareTargets } from "../sharing/index.js";
76
78
  import { keepCloudForAll, mergesSeen, proposeMerge, resolveConflict, sendBeforeSwitch, startSpace, stopSpace, syncAll, syncView, undoMerge, } from "../sync/client.js";
77
79
  import { codeOf } from "../tenants/control.js";
78
80
  import { currentTenant } from "../tenants/tenant.js";
79
81
  import { serverText } from "../texts.js";
80
82
  import { applyUpdate, updateStatus } from "../update.js";
81
- import { bareMime, byteRange } from "./delivery.js";
83
+ import { spaceFileResponse } from "./delivery.js";
82
84
  import { notFoundAnswer, requestLang, say } from "./lang.js";
83
85
  import { mayChangeRuntime } from "./runtime-settings.js";
84
86
  const presenceSchema = z.object({
@@ -90,7 +92,13 @@ const presenceSchema = z.object({
90
92
  placeLabel: z.string().max(120).nullish(),
91
93
  });
92
94
  /** Who reads, for the views the live stream sends too (live/views.ts). */
93
- const reader = (c) => ({ userId: c.get("user").id, lang: requestLang(c) });
95
+ /** Who reads, for the broker (broker/rwx.ts): the signed-in person and their role. */
96
+ const whoOf = (c) => subjectsOfPerson(c.get("user").id, c.get("user").role);
97
+ const reader = (c) => ({
98
+ userId: c.get("user").id,
99
+ lang: requestLang(c),
100
+ who: whoOf(c),
101
+ });
94
102
  /** The model sources a test call has worked on: the setup is done for those, not for the others. */
95
103
  async function testedSources() {
96
104
  const tested = await readSetting("setup-done");
@@ -245,8 +253,8 @@ async function testClass(cls, lang) {
245
253
  }
246
254
  }
247
255
  /** The size of an inline terminal, as the page lays it out. */
248
- /** Whether the studio assistant's developer mode is offered to this person. */
249
- async function assistantDevFor(user) {
256
+ /** Whether the developer mode (Goose's, a Work chat's) is offered to this person. */
257
+ export async function assistantDevFor(user) {
250
258
  return managed ? (await userInfo(user.id)).admin : env.assistantDev;
251
259
  }
252
260
  const terminalSize = z.object({
@@ -360,13 +368,13 @@ export const studio = new Hono()
360
368
  aiReady: (await hasTextModel()) || (!managed && (await subscriptionClients()).length > 0),
361
369
  mcpUrl: `${env.appUrl}/api/mcp`,
362
370
  /**
363
- * One project: the studio shows no project switcher; null: as many as wanted. `build:
371
+ * One space: the studio shows no space switcher; null: as many as wanted. `build:
364
372
  * false`: nothing is made or changed here; the studio shows what the person's local
365
373
  * install synced. `create`: the person makes and deletes here (builds, and is no mere
366
374
  * member). `members`: the people the plan allows, null for no limit.
367
375
  */
368
376
  limits: {
369
- projects: await projectLimitOrNull(),
377
+ spaces: await spaceLimitOrNull(),
370
378
  build: await mayBuild(),
371
379
  create: await mayCreate(),
372
380
  members: info?.limits.members ?? null,
@@ -429,6 +437,7 @@ export const studio = new Hono()
429
437
  // Where the assistant stands, and the sidebar's width (null: the default); a PUT sends either.
430
438
  .get("/assistant/layout", async (c) => c.json({
431
439
  layout: await assistantLayout(c.get("user")),
440
+ layouts: await assistantLayouts(c.get("user")),
432
441
  width: await assistantWidth(c.get("user")),
433
442
  }))
434
443
  .put("/assistant/layout", async (c) => {
@@ -436,6 +445,11 @@ export const studio = new Hono()
436
445
  const body = z
437
446
  .object({
438
447
  layout: z.enum(ASSISTANT_LAYOUTS).optional(),
448
+ /** The studio's area the layout is for; without it the person's default. */
449
+ area: z
450
+ .string()
451
+ .regex(/^[a-z0-9-]{1,40}$/)
452
+ .optional(),
439
453
  width: z
440
454
  .number()
441
455
  .int()
@@ -446,7 +460,13 @@ export const studio = new Hono()
446
460
  })
447
461
  .refine((b) => b.layout !== undefined || b.width !== undefined)
448
462
  .parse(await c.req.json());
449
- if (body.layout) {
463
+ if (body.layout && body.area) {
464
+ await writeSetting(`assistant-layouts:${user.tenantId}:${user.id}`, {
465
+ ...(await assistantLayouts(user)),
466
+ [body.area]: body.layout,
467
+ });
468
+ }
469
+ else if (body.layout) {
450
470
  await writeSetting(`assistant-layout:${user.tenantId}:${user.id}`, body.layout);
451
471
  }
452
472
  if (body.width === null) {
@@ -455,7 +475,11 @@ export const studio = new Hono()
455
475
  else if (body.width !== undefined) {
456
476
  await writeSetting(`assistant-width:${user.tenantId}:${user.id}`, body.width);
457
477
  }
458
- return c.json({ layout: await assistantLayout(user), width: await assistantWidth(user) });
478
+ return c.json({
479
+ layout: await assistantLayout(user),
480
+ layouts: await assistantLayouts(user),
481
+ width: await assistantWidth(user),
482
+ });
459
483
  })
460
484
  // Live chat reads answers aloud with the speech model where one is set up; else the browser's voices.
461
485
  .get("/assistant/voice", async (c) => c.json({ way: (await classWays()).speech.kind }))
@@ -490,8 +514,10 @@ export const studio = new Hono()
490
514
  if (!(await canSpend())) {
491
515
  throw new ServiceError("no_credits", note("creditsUsedUp"));
492
516
  }
493
- const project = body.projectId ? await ownedProject(user.id, body.projectId) : null;
494
- const writable = project ? await projectWritable(project) : false;
517
+ // A space whose Studio is closed to a member is none of Goose's: no knowledge, skills or tools of it.
518
+ const opened = body.spaceId ? await ownedSpace(user.id, body.spaceId) : null;
519
+ const space = opened && !(await closedToMe(opened.id)) ? opened : null;
520
+ const writable = space ? await spaceWritable(space) : false;
495
521
  // The page's snapshot is cut, not refused: a page that says too much still gets an answer.
496
522
  const page = body.page && JSON.stringify(body.page).length > ASSISTANT_PAGE_BYTES
497
523
  ? { route: body.page.route, title: body.page.title, view: body.page.view }
@@ -544,7 +570,7 @@ export const studio = new Hono()
544
570
  user,
545
571
  chat,
546
572
  history,
547
- project,
573
+ space,
548
574
  writable,
549
575
  message,
550
576
  extra: body.extra,
@@ -610,39 +636,39 @@ export const studio = new Hono()
610
636
  void foldChat(chat.id).catch((err) => console.error("[studio-assistant] fold:", err));
611
637
  });
612
638
  })
613
- // --- projects --------------------------------------------------------------
614
- .get("/projects", async (c) => c.json(await spacesView(reader(c))))
615
- .post("/projects", async (c) => {
639
+ // --- spaces --------------------------------------------------------------
640
+ .get("/spaces", async (c) => c.json(await spacesView(reader(c))))
641
+ .post("/spaces", async (c) => {
616
642
  const body = z.object({ name: z.string().min(1).max(80) }).parse(await c.req.json());
617
- return c.json(await createProject(c.get("user").id, body.name));
643
+ return c.json(await createSpace(c.get("user").id, body.name));
618
644
  })
619
- .patch("/projects/:id", async (c) => {
620
- const patch = projectPatchSchema.parse(await c.req.json());
621
- await updateProject(c.get("user").id, c.req.param("id"), patch);
645
+ .patch("/spaces/:id", async (c) => {
646
+ const patch = spacePatchSchema.parse(await c.req.json());
647
+ await updateSpace(c.get("user").id, c.req.param("id"), patch);
622
648
  return c.json({ ok: true });
623
649
  })
624
650
  // The organization's public page as Manage will draw it, for the preview beside the page's fields.
625
- .get("/projects/:id/page", async (c) => {
626
- await ownedProject(c.get("user").id, c.req.param("id"));
651
+ .get("/spaces/:id/page", async (c) => {
652
+ await ownedSpace(c.get("user").id, c.req.param("id"));
627
653
  return c.json(await pagePreview());
628
654
  })
629
655
  // --- the space's themes: how its wizards' pages look (docs/plans/themes.md) ---
630
- .get("/projects/:id/themes", async (c) => c.json(await listThemes(c.get("user").id, c.req.param("id"))))
631
- .put("/projects/:id/themes", async (c) => c.json(await saveTheme(c.get("user").id, c.req.param("id"), await c.req.json())))
632
- .delete("/projects/:id/themes/:themeId{.+}", async (c) => {
656
+ .get("/spaces/:id/themes", async (c) => c.json(await listThemes(c.get("user").id, c.req.param("id"))))
657
+ .put("/spaces/:id/themes", async (c) => c.json(await saveTheme(c.get("user").id, c.req.param("id"), await c.req.json())))
658
+ .delete("/spaces/:id/themes/:themeId{.+}", async (c) => {
633
659
  await deleteTheme(c.get("user").id, c.req.param("id"), c.req.param("themeId"));
634
660
  return c.json({ ok: true });
635
661
  })
636
- // --- what a project holds for all its wizards: logos, assets, documents -------
637
- .get("/projects/:id/files", async (c) => c.json(await filesView(reader(c), c.req.param("id"))))
638
- .post("/projects/:id/files", async (c) => {
639
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
640
- const kind = z.enum(PROJECT_FILE_KINDS).parse(c.req.query("kind"));
662
+ // --- what a space holds for all its wizards: logos, assets, documents -------
663
+ .get("/spaces/:id/files", async (c) => c.json(await filesView(reader(c), c.req.param("id"))))
664
+ .post("/spaces/:id/files", async (c) => {
665
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
666
+ const kind = z.enum(SPACE_FILE_KINDS).parse(c.req.query("kind"));
641
667
  const file = (await c.req.formData()).get("file");
642
668
  if (!(file instanceof File)) {
643
669
  throw new ServiceError("invalid", note("chooseFile"));
644
670
  }
645
- const row = await addProjectFile(project.id, {
671
+ const row = await addSpaceFile(space.id, {
646
672
  kind,
647
673
  name: file.name,
648
674
  mime: file.type.split(";")[0].trim().toLowerCase(),
@@ -650,14 +676,14 @@ export const studio = new Hono()
650
676
  });
651
677
  return c.json(fileView(row));
652
678
  })
653
- .post("/projects/:id/files/url", async (c) => {
654
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
679
+ .post("/spaces/:id/files/url", async (c) => {
680
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
655
681
  const input = z
656
- .object({ url: z.string().min(1).max(500_000), kind: z.enum(PROJECT_FILE_KINDS) })
682
+ .object({ url: z.string().min(1).max(500_000), kind: z.enum(SPACE_FILE_KINDS) })
657
683
  .parse(await c.req.json());
658
684
  const url = /^(https?:\/\/|data:)/i.test(input.url) ? input.url : `https://${input.url}`;
659
685
  try {
660
- return c.json({ file: fileView(await addProjectFileFromUrl(project.id, { ...input, url })) });
686
+ return c.json({ file: fileView(await addSpaceFileFromUrl(space.id, { ...input, url })) });
661
687
  }
662
688
  catch (err) {
663
689
  // A web page where a logo or an asset was asked for: its logos or pictures, to pick from.
@@ -669,8 +695,8 @@ export const studio = new Hono()
669
695
  throw err;
670
696
  }
671
697
  })
672
- .post("/projects/:id/colors/scan", async (c) => {
673
- await ownedProject(c.get("user").id, c.req.param("id"));
698
+ .post("/spaces/:id/colors/scan", async (c) => {
699
+ await ownedSpace(c.get("user").id, c.req.param("id"));
674
700
  const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
675
701
  const colors = await scanColors(url).catch(() => {
676
702
  throw new ServiceError("invalid", note("pageNotReached"));
@@ -678,8 +704,8 @@ export const studio = new Hono()
678
704
  return c.json({ colors });
679
705
  })
680
706
  // A gradient from the admin's words, or theirs changed as they say. Nothing is saved.
681
- .post("/projects/:id/gradients/describe", async (c) => {
682
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
707
+ .post("/spaces/:id/gradients/describe", async (c) => {
708
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
683
709
  const { text, gradient } = z
684
710
  .object({
685
711
  text: z.string().trim().min(1).max(1000),
@@ -693,7 +719,7 @@ export const studio = new Hono()
693
719
  }
694
720
  try {
695
721
  return c.json({
696
- gradient: await describeGradient(project.brand.colors ?? [], text, gradient),
722
+ gradient: await describeGradient(space.brand.colors ?? [], text, gradient),
697
723
  });
698
724
  }
699
725
  catch (err) {
@@ -703,66 +729,48 @@ export const studio = new Hono()
703
729
  throw err;
704
730
  }
705
731
  })
706
- .post("/projects/:id/fonts/scan", async (c) => {
707
- await ownedProject(c.get("user").id, c.req.param("id"));
732
+ .post("/spaces/:id/fonts/scan", async (c) => {
733
+ await ownedSpace(c.get("user").id, c.req.param("id"));
708
734
  const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
709
735
  const fonts = await scanFonts(url).catch(() => {
710
736
  throw new ServiceError("invalid", note("pageNotReached"));
711
737
  });
712
738
  return c.json({ fonts });
713
739
  })
714
- .put("/projects/:id/files/order", async (c) => {
715
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
740
+ .put("/spaces/:id/files/order", async (c) => {
741
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
716
742
  const body = z
717
- .object({ kind: z.enum(PROJECT_FILE_KINDS), ids: z.array(z.string()).max(200) })
743
+ .object({ kind: z.enum(SPACE_FILE_KINDS), ids: z.array(z.string()).max(200) })
718
744
  .parse(await c.req.json());
719
- await orderProjectFiles(project.id, body.kind, body.ids);
745
+ await orderSpaceFiles(space.id, body.kind, body.ids);
720
746
  return c.json({ ok: true });
721
747
  })
722
- .patch("/projects/:id/files/:fileId", async (c) => {
723
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
748
+ .patch("/spaces/:id/files/:fileId", async (c) => {
749
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
724
750
  const patch = z
725
751
  .object({ name: z.string().max(120).optional(), description: z.string().max(600).optional() })
726
752
  .parse(await c.req.json());
727
- return c.json(fileView(await updateProjectFile(project.id, c.req.param("fileId"), patch)));
753
+ return c.json(fileView(await updateSpaceFile(space.id, c.req.param("fileId"), patch)));
728
754
  })
729
- .post("/projects/:id/files/:fileId/reindex", async (c) => {
730
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
731
- return c.json(fileView(await reindexProjectFile(project.id, c.req.param("fileId"))));
755
+ .post("/spaces/:id/files/:fileId/reindex", async (c) => {
756
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
757
+ return c.json(fileView(await reindexSpaceFile(space.id, c.req.param("fileId"))));
732
758
  })
733
- .delete("/projects/:id/files/:fileId", async (c) => {
734
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
735
- await removeProjectFile(project.id, c.req.param("fileId"));
759
+ .delete("/spaces/:id/files/:fileId", async (c) => {
760
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
761
+ await removeSpaceFile(space.id, c.req.param("fileId"));
736
762
  return c.json({ ok: true });
737
763
  })
738
- .get("/projects/:id/files/:fileId/content", async (c) => {
739
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
740
- const { row, data } = await projectFileContent(project.id, c.req.param("fileId"));
741
- const headers = {
742
- "content-type": bareMime(row.mime) ?? "application/octet-stream",
743
- "cache-control": "private, max-age=3600",
744
- "x-content-type-options": "nosniff",
745
- // An uploaded SVG or HTML file is shown, never run. A PDF is left to the browser's own
746
- // viewer, which a sandbox would keep from starting.
747
- ...(row.mime === "application/pdf" ? {} : { "content-security-policy": "sandbox" }),
748
- };
749
- if (/^(audio|video)\//.test(row.mime)) {
750
- headers["accept-ranges"] = "bytes";
751
- const range = byteRange(c.req.header("range"), data.byteLength);
752
- if (range === "unsatisfiable") {
753
- return c.body(null, 416, { "content-range": `bytes */${data.byteLength}` });
754
- }
755
- if (range) {
756
- headers["content-range"] = `bytes ${range.start}-${range.end}/${data.byteLength}`;
757
- return c.body(new Uint8Array(data.subarray(range.start, range.end + 1)), 206, headers);
758
- }
759
- }
760
- return c.body(new Uint8Array(data), 200, headers);
764
+ .get("/spaces/:id/files/:fileId/content", async (c) => {
765
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
766
+ const { row, data } = await spaceFileContent(space.id, c.req.param("fileId"), whoOf(c));
767
+ return spaceFileResponse(c, row.mime, data);
761
768
  })
762
769
  // A document as the models read it: its text as Markdown, or the start of it.
763
- .get("/projects/:id/files/:fileId/text", async (c) => {
764
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
765
- const row = await projectFile(project.id, c.req.param("fileId"));
770
+ .get("/spaces/:id/files/:fileId/text", async (c) => {
771
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
772
+ const row = await spaceFile(space.id, c.req.param("fileId"));
773
+ await assertRwx(space.id, whoOf(c), { kind: "document", id: row.id }, "r");
766
774
  const limit = z.coerce
767
775
  .number()
768
776
  .int()
@@ -774,15 +782,15 @@ export const studio = new Hono()
774
782
  return c.json({ text: text.slice(0, limit), chars: text.length });
775
783
  })
776
784
  // What a search of Knowledge finds for a question: the items an agent step would get.
777
- .post("/projects/:id/search", async (c) => {
778
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
785
+ .post("/spaces/:id/search", async (c) => {
786
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
779
787
  const body = z
780
788
  .object({ query: z.string().min(1).max(400), where: whereSchema.optional() })
781
789
  .parse(await c.req.json());
782
- return c.json(await searchKnowledge(project.id, body.query, { where: body.where }));
790
+ return c.json(await searchKnowledge(space.id, body.query, { where: body.where, who: whoOf(c) }));
783
791
  })
784
- .delete("/projects/:id", async (c) => {
785
- await deleteProject(c.get("user").id, c.req.param("id"));
792
+ .delete("/spaces/:id", async (c) => {
793
+ await deleteSpace(c.get("user").id, c.req.param("id"));
786
794
  return c.json({ ok: true });
787
795
  })
788
796
  // --- connectors: services imported from the integrations registry ------------
@@ -801,24 +809,24 @@ export const studio = new Hono()
801
809
  .parse(await c.req.json());
802
810
  return c.json(await previewSource(body));
803
811
  })
804
- .get("/projects/:id/connectors", async (c) => c.json(await connectorsView(reader(c), c.req.param("id"))))
805
- .post("/projects/:id/connectors", async (c) => {
812
+ .get("/spaces/:id/connectors", async (c) => c.json(await connectorsView(reader(c), c.req.param("id"))))
813
+ .post("/spaces/:id/connectors", async (c) => {
806
814
  const user = c.get("user");
807
- const project = await ownedProject(user.id, c.req.param("id"));
808
- return c.json(await importConnector(user.id, project.id, connectorImportSchema.parse(await c.req.json())));
815
+ const space = await ownedSpace(user.id, c.req.param("id"));
816
+ return c.json(await importConnector(user.id, space.id, connectorImportSchema.parse(await c.req.json())));
809
817
  })
810
- .post("/projects/:id/connectors/:connectorId/refresh", async (c) => {
811
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
812
- return c.json(await refreshConnector(project.id, c.req.param("connectorId"), null));
818
+ .post("/spaces/:id/connectors/:connectorId/refresh", async (c) => {
819
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
820
+ return c.json(await refreshConnector(space.id, c.req.param("connectorId"), null));
813
821
  })
814
- .delete("/projects/:id/connectors/:connectorId", async (c) => {
815
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
816
- await removeConnector(project.id, c.req.param("connectorId"));
822
+ .delete("/spaces/:id/connectors/:connectorId", async (c) => {
823
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
824
+ await removeConnector(space.id, c.req.param("connectorId"));
817
825
  return c.json({ ok: true });
818
826
  })
819
827
  // The runs of the space's wizards that reached their result: of one wizard, or of all.
820
- .get("/projects/:id/results", async (c) => {
821
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
828
+ .get("/spaces/:id/results", async (c) => {
829
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
822
830
  const query = z
823
831
  .object({
824
832
  wizard: z.string().optional(),
@@ -827,7 +835,7 @@ export const studio = new Hono()
827
835
  days: z.coerce.number().int().min(1).max(3650).optional(),
828
836
  })
829
837
  .parse(c.req.query());
830
- return c.json(await listResults(project.id, {
838
+ return c.json(await listResults(space.id, {
831
839
  wizardId: query.wizard || undefined,
832
840
  q: query.q,
833
841
  mode: query.mode,
@@ -835,19 +843,19 @@ export const studio = new Hono()
835
843
  }));
836
844
  })
837
845
  // --- Knowledge: its items and categories ------------------------------------
838
- .get("/projects/:id/knowledge", async (c) => c.json(await listKnowledge(c.get("user").id, c.req.param("id"))))
846
+ .get("/spaces/:id/knowledge", async (c) => c.json(await listKnowledge(c.get("user").id, c.req.param("id"), whoOf(c))))
839
847
  // What a link in a page names (`pages/bgb/p-281`): the studio opens it.
840
- .get("/projects/:id/resolve", async (c) => {
841
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
842
- const found = await resolvePath(project.id, z.string().max(600).parse(c.req.query("path")));
848
+ .get("/spaces/:id/resolve", async (c) => {
849
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
850
+ const found = await resolvePath(space.id, z.string().max(600).parse(c.req.query("path")));
843
851
  if (!found) {
844
852
  throw notFound();
845
853
  }
846
854
  return c.json(found);
847
855
  })
848
- .post("/projects/:id/categories", async (c) => {
849
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
850
- await requireWritable(project);
856
+ .post("/spaces/:id/categories", async (c) => {
857
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
858
+ await requireWritable(space);
851
859
  const body = z
852
860
  .object({
853
861
  name: z.string().min(1).max(80),
@@ -861,12 +869,12 @@ export const studio = new Hono()
861
869
  columnId: z.string().nullish(),
862
870
  })
863
871
  .parse(await c.req.json());
864
- const row = await putCategory(project.id, body);
872
+ const row = await putCategory(space.id, body);
865
873
  return c.json({ id: row.id });
866
874
  })
867
875
  .patch("/categories/:id", async (c) => {
868
876
  const row = await categoryRow(c.req.param("id"));
869
- await ownedProject(c.get("user").id, row.projectId);
877
+ await ownedSpace(c.get("user").id, row.spaceId);
870
878
  const body = z
871
879
  .object({
872
880
  name: z.string().min(1).max(80).optional(),
@@ -883,57 +891,57 @@ export const studio = new Hono()
883
891
  })
884
892
  .delete("/categories/:id", async (c) => {
885
893
  const row = await categoryRow(c.req.param("id"));
886
- await ownedProject(c.get("user").id, row.projectId);
894
+ await ownedSpace(c.get("user").id, row.spaceId);
887
895
  await deleteCategory(row.id);
888
896
  return c.json({ ok: true });
889
897
  })
890
898
  .post("/categories/:id/values", async (c) => {
891
899
  const row = await categoryRow(c.req.param("id"));
892
- await ownedProject(c.get("user").id, row.projectId);
900
+ await ownedSpace(c.get("user").id, row.spaceId);
893
901
  const { value } = z.object({ value: z.string().min(1).max(200) }).parse(await c.req.json());
894
902
  return c.json(await addCategoryValue(row.id, value));
895
903
  })
896
904
  .put("/categories/:id/values/order", async (c) => {
897
905
  const row = await categoryRow(c.req.param("id"));
898
- await ownedProject(c.get("user").id, row.projectId);
906
+ await ownedSpace(c.get("user").id, row.spaceId);
899
907
  const { ids } = z.object({ ids: z.array(z.string()).max(500) }).parse(await c.req.json());
900
908
  await orderCategoryValues(row.id, ids);
901
909
  return c.json({ ok: true });
902
910
  })
903
- .get("/values/:id", async (c) => c.json(await valueContents(c.get("user").id, c.req.param("id"))))
911
+ .get("/values/:id", async (c) => c.json(await valueContents(c.get("user").id, c.req.param("id"), whoOf(c))))
904
912
  // Everything that has a category: the entries its page lists.
905
- .get("/categories/:id/items", async (c) => c.json(await categoryContents(c.get("user").id, c.req.param("id"))))
913
+ .get("/categories/:id/items", async (c) => c.json(await categoryContents(c.get("user").id, c.req.param("id"), whoOf(c))))
906
914
  .patch("/values/:id", async (c) => {
907
915
  const { category } = await categoryValue(c.req.param("id"));
908
- await ownedProject(c.get("user").id, category.projectId);
916
+ await ownedSpace(c.get("user").id, category.spaceId);
909
917
  const { value } = z.object({ value: z.string().min(1).max(200) }).parse(await c.req.json());
910
918
  await renameCategoryValue(c.req.param("id"), value);
911
919
  return c.json({ ok: true });
912
920
  })
913
921
  .post("/values/:id/merge", async (c) => {
914
922
  const { category } = await categoryValue(c.req.param("id"));
915
- await ownedProject(c.get("user").id, category.projectId);
923
+ await ownedSpace(c.get("user").id, category.spaceId);
916
924
  const { into } = z.object({ into: z.string() }).parse(await c.req.json());
917
925
  await mergeCategoryValues(c.req.param("id"), into);
918
926
  return c.json({ ok: true });
919
927
  })
920
928
  .delete("/values/:id", async (c) => {
921
929
  const { category } = await categoryValue(c.req.param("id"));
922
- await ownedProject(c.get("user").id, category.projectId);
930
+ await ownedSpace(c.get("user").id, category.spaceId);
923
931
  await deleteCategoryValue(c.req.param("id"));
924
932
  return c.json({ ok: true });
925
933
  })
926
934
  // The summary of a value: a model writes it from the value's items.
927
935
  .post("/values/:id/summary", async (c) => {
928
936
  const { category } = await categoryValue(c.req.param("id"));
929
- const project = await ownedProject(c.get("user").id, category.projectId);
930
- await requireWritable(project);
937
+ const space = await ownedSpace(c.get("user").id, category.spaceId);
938
+ await requireWritable(space);
931
939
  return c.json({ summary: await writeSummary(c.req.param("id")) });
932
940
  })
933
941
  // A category a person sets on an item: `p:<page>`, `t:<table>`, `r:<row>`, `f:<file>`.
934
- .put("/projects/:id/items/:key/categories/:categoryId", async (c) => {
935
- const project = await ownedProject(c.get("user").id, c.req.param("id"));
936
- await requireWritable(project);
942
+ .put("/spaces/:id/items/:key/categories/:categoryId", async (c) => {
943
+ const space = await ownedSpace(c.get("user").id, c.req.param("id"));
944
+ await requireWritable(space);
937
945
  const key = c.req.param("key");
938
946
  const id = key.slice(2);
939
947
  const ref = key[0] === "p"
@@ -951,14 +959,14 @@ export const studio = new Hono()
951
959
  const { values } = z
952
960
  .object({ values: z.array(z.union([z.string().max(300), z.number(), z.boolean()])).max(50) })
953
961
  .parse(await c.req.json());
954
- if (await setItemCategory(project.id, ref, c.req.param("categoryId"), values)) {
962
+ if (await setItemCategory(space.id, ref, c.req.param("categoryId"), values)) {
955
963
  queueIndex(key[0] === "p" ? `P:${id}` : key);
956
964
  }
957
965
  return c.json({ ok: true });
958
966
  })
959
967
  // --- the space's tables and pages --------------------------------------------
960
- .get("/projects/:id/data", async (c) => c.json(await listSpaceData(c.get("user").id, c.req.param("id"))))
961
- .post("/projects/:id/tables", async (c) => {
968
+ .get("/spaces/:id/data", async (c) => c.json(await listSpaceData(c.get("user").id, c.req.param("id"), whoOf(c))))
969
+ .post("/spaces/:id/tables", async (c) => {
962
970
  const body = z
963
971
  .object({
964
972
  title: z.string().max(120),
@@ -969,7 +977,7 @@ export const studio = new Hono()
969
977
  .parse(await c.req.json());
970
978
  return c.json(await createTable(c.get("user").id, c.req.param("id"), body, requestLang(c)));
971
979
  })
972
- .get("/tables/:id", async (c) => c.json(await getTable(c.get("user").id, c.req.param("id"))))
980
+ .get("/tables/:id", async (c) => c.json(await getTable(c.get("user").id, c.req.param("id"), whoOf(c))))
973
981
  .patch("/tables/:id", async (c) => {
974
982
  const body = z
975
983
  .object({
@@ -1002,7 +1010,7 @@ export const studio = new Hono()
1002
1010
  await deleteTableRows(c.get("user").id, c.req.param("id"), body.ids);
1003
1011
  return c.json({ ok: true });
1004
1012
  })
1005
- .post("/projects/:id/pages", async (c) => {
1013
+ .post("/spaces/:id/pages", async (c) => {
1006
1014
  const body = z
1007
1015
  .object({
1008
1016
  title: z.string().max(200),
@@ -1013,7 +1021,7 @@ export const studio = new Hono()
1013
1021
  .parse(await c.req.json());
1014
1022
  return c.json(await createPage(c.get("user").id, c.req.param("id"), body));
1015
1023
  })
1016
- .get("/pages/:id", async (c) => c.json(await getPage(c.get("user").id, c.req.param("id"))))
1024
+ .get("/pages/:id", async (c) => c.json(await getPage(c.get("user").id, c.req.param("id"), whoOf(c))))
1017
1025
  .patch("/pages/:id", async (c) => {
1018
1026
  const body = z
1019
1027
  .object({
@@ -1037,11 +1045,11 @@ export const studio = new Hono()
1037
1045
  return c.json({ ok: true });
1038
1046
  })
1039
1047
  // --- wizards ---------------------------------------------------------------
1040
- .get("/projects/:id/wizards", async (c) => c.json(await wizardsView(reader(c), c.req.param("id"))))
1048
+ .get("/spaces/:id/wizards", async (c) => c.json(await wizardsView(reader(c), c.req.param("id"))))
1041
1049
  .post("/wizards", async (c) => {
1042
1050
  const body = z
1043
1051
  .object({
1044
- projectId: z.string(),
1052
+ spaceId: z.string(),
1045
1053
  starterId: z.string().optional(),
1046
1054
  lang: z.string().optional(),
1047
1055
  })
@@ -1050,7 +1058,7 @@ export const studio = new Hono()
1050
1058
  return c.json({ id });
1051
1059
  })
1052
1060
  // A wizard as a file, and a new wizard made of such a file.
1053
- .post("/projects/:id/wizards/import", async (c) => {
1061
+ .post("/spaces/:id/wizards/import", async (c) => {
1054
1062
  const file = (await c.req.formData()).get("file");
1055
1063
  if (!(file instanceof File) || !file.size || file.size > PACKAGE_MAX_BYTES) {
1056
1064
  throw new ServiceError("invalid", note("chooseWizardFileMb", { PACKAGE_EXTENSION }));
@@ -1077,7 +1085,7 @@ export const studio = new Hono()
1077
1085
  // The share targets a result of this wizard can name, for the editor.
1078
1086
  .get("/wizards/:id/share-targets", async (c) => {
1079
1087
  const w = await ownedWizard(c.get("user").id, c.req.param("id"));
1080
- return c.json(await projectShareTargets(w.projectId, requestLang(c)));
1088
+ return c.json(await spaceShareTargets(w.spaceId, requestLang(c)));
1081
1089
  })
1082
1090
  // The draft's result page with its share sheet, for a visitor (`as=visitor`) or the owner.
1083
1091
  .get("/wizards/:id/share-preview", async (c) => {
@@ -1098,7 +1106,8 @@ export const studio = new Hono()
1098
1106
  .object({
1099
1107
  shareEnabled: z.boolean().optional(),
1100
1108
  dailyRunLimit: z.number().int().min(1).max(10_000).optional(),
1101
- projectId: z.string().optional(),
1109
+ dailyMailLimit: z.number().int().min(0).max(10_000).optional(),
1110
+ spaceId: z.string().optional(),
1102
1111
  runners: z.object({ default: z.string(), enabled: z.array(z.string()).max(20) }).optional(),
1103
1112
  translate: z.boolean().optional(),
1104
1113
  })
@@ -1191,7 +1200,7 @@ export const studio = new Hono()
1191
1200
  const linked = await cloudLinked();
1192
1201
  return c.json({ linked, ...(linked ? await cloudState(w.id) : { copy: null, error: null }) });
1193
1202
  })
1194
- // Sends the published version again: after a try that failed, or a change of the project.
1203
+ // Sends the published version again: after a try that failed, or a change of the space.
1195
1204
  .post("/wizards/:id/cloud", async (c) => {
1196
1205
  if (!(await cloudLinked())) {
1197
1206
  return c.notFound();
@@ -1274,14 +1283,14 @@ export const studio = new Hono()
1274
1283
  await mergesSeen(ids);
1275
1284
  return c.json({ ok: true });
1276
1285
  })
1277
- // The projects of local installs the account's cloud holds.
1286
+ // The spaces of local installs the account's cloud holds.
1278
1287
  .get("/cloud/spaces", async (c) => {
1279
1288
  if (!(await cloudLinked())) {
1280
1289
  return c.notFound();
1281
1290
  }
1282
1291
  return c.json({ spaces: await cloudSpaces() });
1283
1292
  })
1284
- // Another install's project is in the way: it goes, and what is published here is sent.
1293
+ // Another install's space is in the way: it goes, and what is published here is sent.
1285
1294
  .post("/cloud/replace", async (c) => {
1286
1295
  if (!(await cloudLinked())) {
1287
1296
  return c.notFound();
@@ -1362,7 +1371,7 @@ export const studio = new Hono()
1362
1371
  // The looks of the themes the draft offers: what the test run's preview switches between.
1363
1372
  .get("/wizards/:id/looks", async (c) => {
1364
1373
  const w = await ownedWizard(c.get("user").id, c.req.param("id"));
1365
- return c.json({ looks: await themeLooks(w.projectId, w.draft.themes) });
1374
+ return c.json({ looks: await themeLooks(w.spaceId, w.draft.themes) });
1366
1375
  })
1367
1376
  // --- workspace -------------------------------------------------------------
1368
1377
  .get("/wizards/:id/files", async (c) => c.json(await listFiles(c.get("user").id, c.req.param("id"))))
@@ -1938,9 +1947,9 @@ export const studio = new Hono()
1938
1947
  }
1939
1948
  return c.json({ ok: true });
1940
1949
  })
1941
- .post("/projects/:id/website", async (c) => {
1950
+ .post("/spaces/:id/website", async (c) => {
1942
1951
  const user = c.get("user");
1943
- const project = await ownedProject(user.id, c.req.param("id"));
1952
+ const space = await ownedSpace(user.id, c.req.param("id"));
1944
1953
  // One address (as before) or several: the first website is read, the others kept as facts.
1945
1954
  const { url, urls, lang } = z
1946
1955
  .object({
@@ -1949,7 +1958,7 @@ export const studio = new Hono()
1949
1958
  lang: z.enum(LANGS).optional(),
1950
1959
  })
1951
1960
  .parse(await c.req.json());
1952
- const outcome = await applyAddresses(user.id, project.id, urls ?? (url ? [url] : []), lang ?? requestLang(c));
1961
+ const outcome = await applyAddresses(user.id, space.id, urls ?? (url ? [url] : []), lang ?? requestLang(c));
1953
1962
  return c.json(outcome);
1954
1963
  })
1955
1964
  // The install command and the first steps, mailed to the signed-in person by the Manage-App.