@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
@@ -173,14 +173,14 @@ async function belongHere(ids) {
173
173
  }
174
174
  }
175
175
  /** The organization a space synced with, when it is not the one the account is signed in to now. */
176
- async function otherOrganization(projectId) {
176
+ async function otherOrganization(spaceId) {
177
177
  const account = await linkedAccount();
178
- const owner = (await spaceOrganizations())[projectId];
178
+ const owner = (await spaceOrganizations())[spaceId];
179
179
  return owner && account && owner.id !== account.tenantId ? owner : null;
180
180
  }
181
181
  /** A space of another organization stays here and never goes up to this one. */
182
- export async function refuseOtherOrganization(projectId) {
183
- const owner = await otherOrganization(projectId);
182
+ export async function refuseOtherOrganization(spaceId) {
183
+ const owner = await otherOrganization(spaceId);
184
184
  if (owner) {
185
185
  throw new ServiceError("refused", note("spaceOfOtherOrganization", { organization: owner.name ?? owner.id }), { reason: "other_organization" });
186
186
  }
@@ -196,8 +196,8 @@ export async function syncedSpaceIds() {
196
196
  return rows.map((r) => r.key.slice("sync:space:".length));
197
197
  }
198
198
  /** Whether a space of this install syncs both ways. */
199
- export async function spaceSyncs(projectId) {
200
- return twoWayActive() && (await readState(projectId)) !== null;
199
+ export async function spaceSyncs(spaceId) {
200
+ return twoWayActive() && (await readState(spaceId)) !== null;
201
201
  }
202
202
  /** The two-way sync can run here: a runtime alone, an account linked, the switch on. */
203
203
  export async function twoWayAvailable() {
@@ -213,7 +213,7 @@ async function overview(force = false) {
213
213
  }
214
214
  const value = await transport.overview();
215
215
  overviewCache = { at: Date.now(), value };
216
- setCloudSpaceLimit(value.limits.projects);
216
+ setCloudSpaceLimit(value.limits.spaces);
217
217
  return value;
218
218
  }
219
219
  // --- bases, conflicts, merges ---------------------------------------------------------------
@@ -222,13 +222,13 @@ async function baseOf(kind, item) {
222
222
  where: and(eq(schema.syncBase.kind, kind), eq(schema.syncBase.item, item)),
223
223
  })) ?? null);
224
224
  }
225
- async function setBase(projectId, kind, item, seq, record) {
225
+ async function setBase(spaceId, kind, item, seq, record) {
226
226
  await db
227
227
  .insert(schema.syncBase)
228
- .values({ kind, item, projectId, seq, record })
228
+ .values({ kind, item, spaceId, seq, record })
229
229
  .onConflictDoUpdate({
230
230
  target: [schema.syncBase.kind, schema.syncBase.item],
231
- set: { projectId, seq, record },
231
+ set: { spaceId, seq, record },
232
232
  });
233
233
  }
234
234
  const nameOf = (x) => {
@@ -311,31 +311,31 @@ async function mergeItem(kind, base, local, remote) {
311
311
  * as it was, the delete counts; a clean merge that passes the checks is written here (and goes
312
312
  * up with the next push) and noted; anything else waits as a conflict.
313
313
  */
314
- async function reconcile(projectId, kind, item, local, remote, remoteSeq) {
314
+ async function reconcile(spaceId, kind, item, local, remote, remoteSeq) {
315
315
  const base = await baseOf(kind, item);
316
316
  const baseRecord = base?.record ?? null;
317
317
  if (same(local, remote)) {
318
- await setBase(projectId, kind, item, remoteSeq, remote);
318
+ await setBase(spaceId, kind, item, remoteSeq, remote);
319
319
  return "same";
320
320
  }
321
321
  if (base && same(local, baseRecord)) {
322
- await applyItems([{ kind, item, projectId, record: remote }], { quiet: true });
323
- await setBase(projectId, kind, item, remoteSeq, remote);
322
+ await applyItems([{ kind, item, spaceId, record: remote }], { quiet: true });
323
+ await setBase(spaceId, kind, item, remoteSeq, remote);
324
324
  return "remote";
325
325
  }
326
326
  if (base && same(remote, baseRecord)) {
327
- await setBase(projectId, kind, item, remoteSeq, remote);
328
- await notePending(projectId, kind, item);
327
+ await setBase(spaceId, kind, item, remoteSeq, remote);
328
+ await notePending(spaceId, kind, item);
329
329
  return "local";
330
330
  }
331
331
  if (local && remote) {
332
332
  const m = await mergeItem(kind, baseRecord, local, remote);
333
333
  if (!m.conflicts.length && !m.issues.length) {
334
- await applyItems([{ kind, item, projectId, record: m.value }], { quiet: false });
335
- await setBase(projectId, kind, item, remoteSeq, remote);
334
+ await applyItems([{ kind, item, spaceId, record: m.value }], { quiet: false });
335
+ await setBase(spaceId, kind, item, remoteSeq, remote);
336
336
  await db.insert(schema.syncMerge).values({
337
337
  id: nanoid(12),
338
- projectId,
338
+ spaceId,
339
339
  kind,
340
340
  item,
341
341
  local: placesChanged(baseRecord ?? {}, local),
@@ -349,7 +349,7 @@ async function reconcile(projectId, kind, item, local, remote, remoteSeq) {
349
349
  .insert(schema.syncConflict)
350
350
  .values({
351
351
  id: nanoid(12),
352
- projectId,
352
+ spaceId,
353
353
  kind,
354
354
  item,
355
355
  seq: remoteSeq,
@@ -364,15 +364,15 @@ async function reconcile(projectId, kind, item, local, remote, remoteSeq) {
364
364
  return "conflict";
365
365
  }
366
366
  // --- push and pull --------------------------------------------------------------------------
367
- async function conflicted(projectId) {
367
+ async function conflicted(spaceId) {
368
368
  const rows = await db.query.syncConflict.findMany({
369
- where: eq(schema.syncConflict.projectId, projectId),
369
+ where: eq(schema.syncConflict.spaceId, spaceId),
370
370
  columns: { kind: true, item: true },
371
371
  });
372
372
  return new Set(rows.map((r) => seqKey(r.kind, r.item)));
373
373
  }
374
374
  /** What this install changed in the space and has not pushed: from its log, or all of it the first time. */
375
- async function pending(projectId, st) {
375
+ async function pending(spaceId, st) {
376
376
  const out = new Map();
377
377
  const logged = await db
378
378
  .select({
@@ -381,7 +381,7 @@ async function pending(projectId, st) {
381
381
  seq: schema.syncChange.seq,
382
382
  })
383
383
  .from(schema.syncChange)
384
- .where(and(eq(schema.syncChange.projectId, projectId), gt(schema.syncChange.seq, st.pushed)));
384
+ .where(and(eq(schema.syncChange.spaceId, spaceId), gt(schema.syncChange.seq, st.pushed)));
385
385
  for (const x of logged) {
386
386
  const key = seqKey(x.kind, x.item);
387
387
  out.set(key, {
@@ -392,7 +392,7 @@ async function pending(projectId, st) {
392
392
  }
393
393
  if (!st.full) {
394
394
  for (const kind of KIND_ORDER) {
395
- for (const item of await KINDS[kind].list(projectId)) {
395
+ for (const item of await KINDS[kind].list(spaceId)) {
396
396
  if (!out.has(seqKey(kind, item))) {
397
397
  out.set(seqKey(kind, item), { kind, item, seq: 0 });
398
398
  }
@@ -402,10 +402,10 @@ async function pending(projectId, st) {
402
402
  return [...out.values()];
403
403
  }
404
404
  const CHUNK = 300;
405
- async function push(projectId, st) {
405
+ async function push(spaceId, st) {
406
406
  for (let round = 0; round < 5; round++) {
407
- const waiting = await conflicted(projectId);
408
- const changed = (await pending(projectId, st)).filter((x) => !waiting.has(seqKey(x.kind, x.item)));
407
+ const waiting = await conflicted(spaceId);
408
+ const changed = (await pending(spaceId, st)).filter((x) => !waiting.has(seqKey(x.kind, x.item)));
409
409
  if (!changed.length) {
410
410
  st.full = true;
411
411
  return;
@@ -414,7 +414,7 @@ async function push(projectId, st) {
414
414
  const items = [];
415
415
  for (const x of changed) {
416
416
  const read = await KINDS[x.kind].read(x.item);
417
- if (read === "skip" || (read && read.projectId !== projectId)) {
417
+ if (read === "skip" || (read && read.spaceId !== spaceId)) {
418
418
  continue;
419
419
  }
420
420
  const base = await baseOf(x.kind, x.item);
@@ -430,21 +430,21 @@ async function push(projectId, st) {
430
430
  ...new Set(items.flatMap((x) => (x.record ? (KINDS[x.kind].blobs?.(x.record) ?? []) : []))),
431
431
  ];
432
432
  for (let i = 0; i < hashes.length; i += 1000) {
433
- for (const hash of await transport.missing(projectId, hashes.slice(i, i + 1000))) {
434
- await transport.putBlob(projectId, hash, new Uint8Array(await getBlob(hash)));
433
+ for (const hash of await transport.missing(spaceId, hashes.slice(i, i + 1000))) {
434
+ await transport.putBlob(spaceId, hash, new Uint8Array(await getBlob(hash)));
435
435
  }
436
436
  }
437
437
  const refusals = [];
438
438
  for (let i = 0; i < items.length; i += CHUNK) {
439
439
  const chunk = items.slice(i, i + CHUNK);
440
- const answer = await transport.push(projectId, { schema: tenantSchemaVersion, items: chunk });
440
+ const answer = await transport.push(spaceId, { schema: tenantSchemaVersion, items: chunk });
441
441
  for (const r of answer.results) {
442
442
  const sent = chunk.find((x) => x.kind === r.kind && x.item === r.item);
443
443
  if (r.status === "taken") {
444
- await setBase(projectId, r.kind, r.item, r.seq, sent?.record ?? null);
444
+ await setBase(spaceId, r.kind, r.item, r.seq, sent?.record ?? null);
445
445
  }
446
446
  else if (r.status === "conflict") {
447
- await reconcile(projectId, r.kind, r.item, sent?.record ?? null, r.record, r.seq);
447
+ await reconcile(spaceId, r.kind, r.item, sent?.record ?? null, r.record, r.seq);
448
448
  }
449
449
  else {
450
450
  refusals.push(`${KINDS[r.kind].title(sent?.record ?? null, r.item)}: ${r.message}`);
@@ -453,26 +453,26 @@ async function push(projectId, st) {
453
453
  }
454
454
  st.pushed = top;
455
455
  st.full = true;
456
- await dropPushed(projectId, top);
456
+ await dropPushed(spaceId, top);
457
457
  if (refusals.length) {
458
458
  st.error = {
459
459
  message: noteText(note("syncChangeRefused", { detail: refusals.slice(0, 3).join("; ") }), "en"),
460
460
  reason: "refused",
461
461
  at: new Date().toISOString(),
462
462
  };
463
- lastRefusals.set(projectId, refusals);
463
+ lastRefusals.set(spaceId, refusals);
464
464
  }
465
465
  }
466
466
  }
467
467
  /** Why the last push of a space was not taken, item by item, for the studio. */
468
468
  const lastRefusals = new Map();
469
- async function pull(projectId, st) {
469
+ async function pull(spaceId, st) {
470
470
  const changes = new Map();
471
471
  let since = st.pulled;
472
472
  let cursor;
473
473
  let next = since;
474
474
  for (;;) {
475
- const answer = await transport.pull(projectId, since, cursor);
475
+ const answer = await transport.pull(spaceId, since, cursor);
476
476
  for (const c of answer.changes) {
477
477
  changes.set(seqKey(c.kind, c.item), c);
478
478
  }
@@ -494,18 +494,18 @@ async function pull(projectId, st) {
494
494
  for (const c of changes.values()) {
495
495
  for (const hash of c.record ? (KINDS[c.kind].blobs?.(c.record) ?? []) : []) {
496
496
  if (!(await hasBlob(hash))) {
497
- await putBlobOf(hash, await transport.getBlob(projectId, hash));
497
+ await putBlobOf(hash, await transport.getBlob(spaceId, hash));
498
498
  }
499
499
  }
500
500
  }
501
- const waiting = await conflicted(projectId);
502
- const mine = new Set((await pending(projectId, { ...st, full: true })).map((x) => seqKey(x.kind, x.item)));
501
+ const waiting = await conflicted(spaceId);
502
+ const mine = new Set((await pending(spaceId, { ...st, full: true })).map((x) => seqKey(x.kind, x.item)));
503
503
  const direct = [];
504
504
  for (const c of changes.values()) {
505
505
  const key = seqKey(c.kind, c.item);
506
- if (c.kind === "space" && c.item === projectId && c.record === null) {
506
+ if (c.kind === "space" && c.item === spaceId && c.record === null) {
507
507
  // The space went in the cloud: the copy here stays, and syncs no more.
508
- await stopSpace(projectId);
508
+ await stopSpace(spaceId);
509
509
  return;
510
510
  }
511
511
  if (waiting.has(key)) {
@@ -521,18 +521,18 @@ async function pull(projectId, st) {
521
521
  }
522
522
  const local = read?.record ?? null;
523
523
  if (mine.has(key)) {
524
- await reconcile(projectId, c.kind, c.item, local, c.record, c.seq);
524
+ await reconcile(spaceId, c.kind, c.item, local, c.record, c.seq);
525
525
  continue;
526
526
  }
527
527
  if (same(local, c.record)) {
528
- await setBase(projectId, c.kind, c.item, c.seq, c.record);
528
+ await setBase(spaceId, c.kind, c.item, c.seq, c.record);
529
529
  continue;
530
530
  }
531
- direct.push({ kind: c.kind, item: c.item, projectId, record: c.record, seq: c.seq });
531
+ direct.push({ kind: c.kind, item: c.item, spaceId, record: c.record, seq: c.seq });
532
532
  }
533
533
  await applyItems(direct, { quiet: true });
534
534
  for (const x of direct) {
535
- await setBase(projectId, x.kind, x.item, x.seq, x.record);
535
+ await setBase(spaceId, x.kind, x.item, x.seq, x.record);
536
536
  }
537
537
  st.pulled = Math.max(st.pulled, next);
538
538
  }
@@ -541,25 +541,25 @@ const running = new Map();
541
541
  const again = new Map();
542
542
  const widen = (a, b) => (!a || a === b ? b : "both");
543
543
  /** Pushes and pulls a space; one run at a time, a call meanwhile runs once more after it. */
544
- export function syncSpace(projectId, what = "both") {
545
- const busy = running.get(projectId);
544
+ export function syncSpace(spaceId, what = "both") {
545
+ const busy = running.get(spaceId);
546
546
  if (busy) {
547
- again.set(projectId, widen(again.get(projectId), what));
547
+ again.set(spaceId, widen(again.get(spaceId), what));
548
548
  return busy;
549
549
  }
550
550
  const run = (async () => {
551
551
  let next = what;
552
552
  while (next) {
553
- again.delete(projectId);
554
- await runSync(projectId, next);
555
- next = again.get(projectId);
553
+ again.delete(spaceId);
554
+ await runSync(spaceId, next);
555
+ next = again.get(spaceId);
556
556
  }
557
- })().finally(() => running.delete(projectId));
558
- running.set(projectId, run);
557
+ })().finally(() => running.delete(spaceId));
558
+ running.set(spaceId, run);
559
559
  return run;
560
560
  }
561
- async function runSync(projectId, what) {
562
- const st = await readState(projectId);
561
+ async function runSync(spaceId, what) {
562
+ const st = await readState(spaceId);
563
563
  if (!st) {
564
564
  return;
565
565
  }
@@ -574,25 +574,25 @@ async function runSync(projectId, what) {
574
574
  };
575
575
  return;
576
576
  }
577
- const here = await db.query.project.findFirst({
578
- where: eq(schema.project.id, projectId),
577
+ const here = await db.query.space.findFirst({
578
+ where: eq(schema.space.id, spaceId),
579
579
  columns: { id: true },
580
580
  });
581
- const inCloud = ov.spaces.some((s) => s.id === projectId);
581
+ const inCloud = ov.spaces.some((s) => s.id === spaceId);
582
582
  if (!here && !inCloud) {
583
583
  return;
584
584
  }
585
585
  st.error = null;
586
- lastRefusals.delete(projectId);
586
+ lastRefusals.delete(spaceId);
587
587
  // A space this install has goes up as a whole once before anything comes down for it.
588
588
  if (what !== "push" && inCloud && (st.full || !here)) {
589
- await pull(projectId, st);
589
+ await pull(spaceId, st);
590
590
  if (!here) {
591
591
  st.full = true;
592
592
  }
593
593
  }
594
594
  if (what !== "pull") {
595
- await push(projectId, st);
595
+ await push(spaceId, st);
596
596
  if (!inCloud) {
597
597
  overviewCache = null;
598
598
  }
@@ -606,13 +606,13 @@ async function runSync(projectId, what) {
606
606
  at: new Date().toISOString(),
607
607
  };
608
608
  if (!(err instanceof ServiceError)) {
609
- console.error(`[sync] ${projectId}:`, err);
609
+ console.error(`[sync] ${spaceId}:`, err);
610
610
  }
611
611
  }
612
612
  finally {
613
613
  // The space may have been turned off meanwhile.
614
- if (await readState(projectId)) {
615
- await writeState(projectId, st);
614
+ if (await readState(spaceId)) {
615
+ await writeState(spaceId, st);
616
616
  }
617
617
  changed();
618
618
  }
@@ -631,7 +631,7 @@ export async function syncAll() {
631
631
  }
632
632
  const excluded = new Set((await readSetting(EXCLUDED)) ?? []);
633
633
  const known = new Set(await syncedSpaceIds());
634
- const local = await db.query.project.findMany({ columns: { id: true } });
634
+ const local = await db.query.space.findMany({ columns: { id: true } });
635
635
  const ov = await overview(true).catch(() => null);
636
636
  const ids = [...new Set([...local.map((p) => p.id), ...(ov?.spaces ?? []).map((s) => s.id)])];
637
637
  // Spaces that synced before their organization was noted.
@@ -653,31 +653,31 @@ export async function startTwoWay() {
653
653
  await syncAll();
654
654
  }
655
655
  /** A space starts to sync both ways: one this install synced one way becomes the cloud's own. */
656
- export async function startSpace(projectId) {
657
- await refuseOtherOrganization(projectId);
658
- const excluded = ((await readSetting(EXCLUDED)) ?? []).filter((x) => x !== projectId);
656
+ export async function startSpace(spaceId) {
657
+ await refuseOtherOrganization(spaceId);
658
+ const excluded = ((await readSetting(EXCLUDED)) ?? []).filter((x) => x !== spaceId);
659
659
  await writeSetting(EXCLUDED, excluded);
660
- if (!(await readState(projectId))) {
661
- const here = await db.query.project.findFirst({
662
- where: eq(schema.project.id, projectId),
660
+ if (!(await readState(spaceId))) {
661
+ const here = await db.query.space.findFirst({
662
+ where: eq(schema.space.id, spaceId),
663
663
  columns: { id: true },
664
664
  });
665
665
  if (here) {
666
- await transport.adopt(projectId).catch(() => undefined);
666
+ await transport.adopt(spaceId).catch(() => undefined);
667
667
  }
668
- await writeState(projectId, { pushed: 0, pulled: 0, full: false, at: null, error: null });
668
+ await writeState(spaceId, { pushed: 0, pulled: 0, full: false, at: null, error: null });
669
669
  }
670
- await belongHere([projectId]);
671
- await syncSpace(projectId);
670
+ await belongHere([spaceId]);
671
+ await syncSpace(spaceId);
672
672
  }
673
673
  /** The space syncs no more; what it holds here stays. */
674
- export async function stopSpace(projectId) {
674
+ export async function stopSpace(spaceId) {
675
675
  const excluded = new Set((await readSetting(EXCLUDED)) ?? []);
676
- excluded.add(projectId);
676
+ excluded.add(spaceId);
677
677
  await writeSetting(EXCLUDED, [...excluded]);
678
- await deleteSetting(stateKey(projectId));
678
+ await deleteSetting(stateKey(spaceId));
679
679
  for (const table of [schema.syncBase, schema.syncConflict, schema.syncMerge, schema.syncChange]) {
680
- await db.delete(table).where(eq(table.projectId, projectId));
680
+ await db.delete(table).where(eq(table.spaceId, spaceId));
681
681
  }
682
682
  }
683
683
  // --- the studio's saves and loads -------------------------------------------------------------
@@ -719,16 +719,16 @@ export async function beforeStudioLoad() {
719
719
  await Promise.race([work, new Promise((r) => setTimeout(r, LOAD_WAIT_MS).unref?.())]);
720
720
  }
721
721
  /** Pushes the space, then has the cloud publish its draft, which is now this install's. */
722
- export async function publishInCloud(projectId, wizardId) {
723
- await syncSpace(projectId, "push");
724
- const st = await readState(projectId);
722
+ export async function publishInCloud(spaceId, wizardId) {
723
+ await syncSpace(spaceId, "push");
724
+ const st = await readState(spaceId);
725
725
  if (st?.error) {
726
726
  throw new ServiceError("refused", st.error.message, { reason: st.error.reason ?? "refused" });
727
727
  }
728
- return transport.publish(projectId, wizardId);
728
+ return transport.publish(spaceId, wizardId);
729
729
  }
730
- export function rotateInCloudSpace(projectId, wizardId) {
731
- return transport.rotate(projectId, wizardId);
730
+ export function rotateInCloudSpace(spaceId, wizardId) {
731
+ return transport.rotate(spaceId, wizardId);
732
732
  }
733
733
  // --- what the studio shows and asks ---------------------------------------------------------
734
734
  function sayError(e) {
@@ -743,7 +743,7 @@ async function conflictView(row) {
743
743
  : [];
744
744
  return {
745
745
  id: row.id,
746
- spaceId: row.projectId,
746
+ spaceId: row.spaceId,
747
747
  kind: row.kind,
748
748
  item: row.item,
749
749
  title: def.title(local ?? remote, row.item),
@@ -757,7 +757,7 @@ export async function syncView() {
757
757
  if (!available) {
758
758
  return { available, spaces: [], conflicts: [], merges: [], refusals: {} };
759
759
  }
760
- const local = await db.query.project.findMany({ columns: { id: true, name: true } });
760
+ const local = await db.query.space.findMany({ columns: { id: true, name: true } });
761
761
  const cloud = await overview().catch(() => null);
762
762
  const account = await linkedAccount();
763
763
  const owners = await spaceOrganizations();
@@ -783,8 +783,8 @@ export async function syncView() {
783
783
  on: st !== null,
784
784
  syncedAt: st?.at ?? null,
785
785
  waiting,
786
- conflicts: conflicts.filter((c) => c.projectId === id).length,
787
- merges: merges.filter((m) => m.projectId === id).length,
786
+ conflicts: conflicts.filter((c) => c.spaceId === id).length,
787
+ merges: merges.filter((m) => m.spaceId === id).length,
788
788
  error: sayError(st?.error ?? null),
789
789
  organization: owners[id] && owners[id].id !== account?.tenantId
790
790
  ? (owners[id].name ?? owners[id].id)
@@ -797,7 +797,7 @@ export async function syncView() {
797
797
  conflicts: await Promise.all(conflicts.map(conflictView)),
798
798
  merges: merges.map((m) => ({
799
799
  id: m.id,
800
- spaceId: m.projectId,
800
+ spaceId: m.spaceId,
801
801
  kind: m.kind,
802
802
  item: m.item,
803
803
  title: KINDS[m.kind].title(m.before.local ?? m.before.remote, m.item),
@@ -823,8 +823,8 @@ export async function resolveConflict(id, how) {
823
823
  const local = row.local ?? null;
824
824
  const remote = row.remote ?? null;
825
825
  const settle = async (record, quiet) => {
826
- await applyItems([{ kind, item: row.item, projectId: row.projectId, record }], { quiet });
827
- await setBase(row.projectId, kind, row.item, row.seq, remote);
826
+ await applyItems([{ kind, item: row.item, spaceId: row.spaceId, record }], { quiet });
827
+ await setBase(row.spaceId, kind, row.item, row.seq, remote);
828
828
  await db.delete(schema.syncConflict).where(eq(schema.syncConflict.id, row.id));
829
829
  };
830
830
  if ("take" in how && how.take === "remote") {
@@ -835,9 +835,9 @@ export async function resolveConflict(id, how) {
835
835
  .where(and(eq(schema.syncChange.kind, kind), eq(schema.syncChange.item, row.item)));
836
836
  }
837
837
  else if ("take" in how) {
838
- await setBase(row.projectId, kind, row.item, row.seq, remote);
838
+ await setBase(row.spaceId, kind, row.item, row.seq, remote);
839
839
  await db.delete(schema.syncConflict).where(eq(schema.syncConflict.id, row.id));
840
- await notePending(row.projectId, kind, row.item);
840
+ await notePending(row.spaceId, kind, row.item);
841
841
  }
842
842
  else {
843
843
  let record;
@@ -857,12 +857,12 @@ export async function resolveConflict(id, how) {
857
857
  }
858
858
  await settle(record, false);
859
859
  }
860
- await syncSpace(row.projectId, "push");
860
+ await syncSpace(row.spaceId, "push");
861
861
  }
862
862
  /** Every conflict of a space settled with the cloud's version. */
863
- export async function keepCloudForAll(projectId) {
863
+ export async function keepCloudForAll(spaceId) {
864
864
  const rows = await db.query.syncConflict.findMany({
865
- where: eq(schema.syncConflict.projectId, projectId),
865
+ where: eq(schema.syncConflict.spaceId, spaceId),
866
866
  columns: { id: true },
867
867
  });
868
868
  for (const r of rows) {
@@ -876,9 +876,9 @@ export async function undoMerge(id, take) {
876
876
  if (!m) {
877
877
  throw new ServiceError("not_found", note("notFound"));
878
878
  }
879
- await applyItems([{ kind: m.kind, item: m.item, projectId: m.projectId, record: m.before[take] }], { quiet: false });
879
+ await applyItems([{ kind: m.kind, item: m.item, spaceId: m.spaceId, record: m.before[take] }], { quiet: false });
880
880
  await db.delete(schema.syncMerge).where(eq(schema.syncMerge.id, id));
881
- await syncSpace(m.projectId, "push");
881
+ await syncSpace(m.spaceId, "push");
882
882
  }
883
883
  export async function mergesSeen(ids) {
884
884
  if (ids.length) {
@@ -959,8 +959,8 @@ export async function sendBeforeSwitch() {
959
959
  const st = await readState(id);
960
960
  const waiting = st ? (await pending(id, st)).filter((x) => x.seq > 0 || !st.full).length : 0;
961
961
  if (st?.error || waiting) {
962
- const here = await db.query.project.findFirst({
963
- where: eq(schema.project.id, id),
962
+ const here = await db.query.space.findFirst({
963
+ where: eq(schema.space.id, id),
964
964
  columns: { name: true },
965
965
  });
966
966
  stuck.push({
@@ -983,11 +983,11 @@ export async function noteSyncedSpaces() {
983
983
  .where(like(control.setting.key, "cloud:%"));
984
984
  const wizards = sent.length
985
985
  ? await db
986
- .select({ projectId: schema.wizard.projectId })
986
+ .select({ spaceId: schema.wizard.spaceId })
987
987
  .from(schema.wizard)
988
988
  .where(inArray(schema.wizard.id, sent.map((r) => r.key.slice("cloud:".length))))
989
989
  : [];
990
- await belongHere([...new Set([...(await syncedSpaceIds()), ...wizards.map((w) => w.projectId)])]);
990
+ await belongHere([...new Set([...(await syncedSpaceIds()), ...wizards.map((w) => w.spaceId)])]);
991
991
  }
992
992
  /**
993
993
  * After a switch: spaces that never synced with any organization stay on this computer only,
@@ -995,7 +995,7 @@ export async function noteSyncedSpaces() {
995
995
  */
996
996
  export async function keepUnsyncedHere() {
997
997
  const owners = await spaceOrganizations();
998
- const local = await db.query.project.findMany({ columns: { id: true } });
998
+ const local = await db.query.space.findMany({ columns: { id: true } });
999
999
  await writeSetting(EXCLUDED, local.map((p) => p.id).filter((id) => !owners[id]));
1000
1000
  }
1001
1001
  /** The account was unlinked: nothing syncs any more, and what was kept of the cloud goes. */
@@ -1013,18 +1013,18 @@ const LIVE_SEQ = "sync:live-seq";
1013
1013
  const LIVE_PULL_MS = 2000;
1014
1014
  const livePulled = new Map();
1015
1015
  const livePending = new Map();
1016
- function pullSoon(tenant, projectId) {
1017
- if (livePending.has(projectId)) {
1016
+ function pullSoon(tenant, spaceId) {
1017
+ if (livePending.has(spaceId)) {
1018
1018
  return;
1019
1019
  }
1020
- const wait = Math.max(0, LIVE_PULL_MS - (Date.now() - (livePulled.get(projectId) ?? 0)));
1020
+ const wait = Math.max(0, LIVE_PULL_MS - (Date.now() - (livePulled.get(spaceId) ?? 0)));
1021
1021
  const timer = setTimeout(() => {
1022
- livePending.delete(projectId);
1023
- livePulled.set(projectId, Date.now());
1024
- void withTenantOf(tenant, () => syncSpace(projectId, "pull")).catch((err) => console.error(`[sync] live pull of ${projectId}:`, err));
1022
+ livePending.delete(spaceId);
1023
+ livePulled.set(spaceId, Date.now());
1024
+ void withTenantOf(tenant, () => syncSpace(spaceId, "pull")).catch((err) => console.error(`[sync] live pull of ${spaceId}:`, err));
1025
1025
  }, wait);
1026
1026
  timer.unref?.();
1027
- livePending.set(projectId, timer);
1027
+ livePending.set(spaceId, timer);
1028
1028
  }
1029
1029
  /** What the cloud's live call said: pulls the spaces that sync here and changed there. */
1030
1030
  async function heardFromCloud(tenant, e) {