@engenty/wizards-runtime 0.12.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/apps/runtime/dist/agents/architect.js +8 -7
  2. package/apps/runtime/dist/agents/goose-connections.js +82 -0
  3. package/apps/runtime/dist/agents/space-agent.js +9 -2
  4. package/apps/runtime/dist/agents/studio-assistant.js +126 -71
  5. package/apps/runtime/dist/agents/website.js +1 -1
  6. package/apps/runtime/dist/app.js +28 -3
  7. package/apps/runtime/dist/assistant/knows.js +6 -5
  8. package/apps/runtime/dist/authoring/guide.js +25 -5
  9. package/apps/runtime/dist/broker/account.js +166 -0
  10. package/apps/runtime/dist/broker/call.js +417 -0
  11. package/apps/runtime/dist/broker/caller.js +10 -0
  12. package/apps/runtime/dist/broker/grant.js +152 -0
  13. package/apps/runtime/dist/broker/host.js +51 -0
  14. package/apps/runtime/dist/broker/index.js +8 -0
  15. package/apps/runtime/dist/broker/kept.js +31 -0
  16. package/apps/runtime/dist/broker/log.js +240 -0
  17. package/apps/runtime/dist/broker/registry.js +9 -0
  18. package/apps/runtime/dist/broker/rwx.js +367 -0
  19. package/apps/runtime/dist/broker/send.js +189 -0
  20. package/apps/runtime/dist/connectors/builtin.js +1 -1
  21. package/apps/runtime/dist/connectors/external.js +38 -37
  22. package/apps/runtime/dist/connectors/index.js +30 -91
  23. package/apps/runtime/dist/connectors/mail.js +0 -8
  24. package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
  25. package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
  26. package/apps/runtime/dist/connectors/smtp.js +1 -1
  27. package/apps/runtime/dist/connectors/space-connections.js +436 -0
  28. package/apps/runtime/dist/credits/estimate.js +3 -3
  29. package/apps/runtime/dist/db/adopt.js +3 -3
  30. package/apps/runtime/dist/db/client.js +9 -0
  31. package/apps/runtime/dist/db/live-triggers.js +65 -23
  32. package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
  33. package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
  34. package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
  35. package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
  36. package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
  37. package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
  38. package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
  39. package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
  40. package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
  41. package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
  42. package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
  43. package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
  47. package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
  48. package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
  49. package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
  50. package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
  51. package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
  52. package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
  53. package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
  54. package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
  55. package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
  56. package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
  57. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
  58. package/apps/runtime/dist/db/schema.js +295 -72
  59. package/apps/runtime/dist/docs/dev/architecture.md +215 -0
  60. package/apps/runtime/dist/docs/dev/broker.md +298 -0
  61. package/apps/runtime/dist/docs/dev/index.md +5 -1
  62. package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
  63. package/apps/runtime/dist/docs/dev/meta.json +3 -0
  64. package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
  65. package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
  66. package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
  67. package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
  68. package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
  69. package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
  70. package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
  71. package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
  72. package/apps/runtime/dist/docs/dev/skills.md +16 -9
  73. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +59 -6
  74. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
  75. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
  76. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
  77. package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
  78. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
  79. package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
  80. package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
  81. package/apps/runtime/dist/docs/user-guide/index.md +10 -1
  82. package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
  83. package/apps/runtime/dist/docs/user-guide/models.md +105 -30
  84. package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
  85. package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
  86. package/apps/runtime/dist/docs/user-guide/space.md +5 -4
  87. package/apps/runtime/dist/docs/user-guide/together.md +29 -2
  88. package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
  89. package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
  90. package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
  91. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
  92. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
  93. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
  94. package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
  95. package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
  96. package/apps/runtime/dist/engine/decide.js +1 -1
  97. package/apps/runtime/dist/engine/requirements.js +139 -11
  98. package/apps/runtime/dist/engine/resources.js +43 -12
  99. package/apps/runtime/dist/engine/runner.js +121 -27
  100. package/apps/runtime/dist/engine/steps.js +42 -16
  101. package/apps/runtime/dist/engine/template.js +35 -1
  102. package/apps/runtime/dist/env.js +9 -4
  103. package/apps/runtime/dist/index.js +18 -2
  104. package/apps/runtime/dist/link-preview.js +9 -0
  105. package/apps/runtime/dist/live/feed.js +2 -2
  106. package/apps/runtime/dist/live/origin.js +2 -2
  107. package/apps/runtime/dist/live/views.js +51 -26
  108. package/apps/runtime/dist/manage.js +32 -0
  109. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  110. package/apps/runtime/dist/mcp/handler.js +55 -1
  111. package/apps/runtime/dist/mcp/seen.js +47 -0
  112. package/apps/runtime/dist/mcp/tools.js +75 -34
  113. package/apps/runtime/dist/models.js +203 -12
  114. package/apps/runtime/dist/motion-graphics/project.js +8 -8
  115. package/apps/runtime/dist/motion-graphics/step.js +2 -2
  116. package/apps/runtime/dist/motion-graphics/tools.js +1 -1
  117. package/apps/runtime/dist/plugins/events.js +2 -2
  118. package/apps/runtime/dist/plugins/jobs.js +4 -1
  119. package/apps/runtime/dist/plugins/loader.js +2 -2
  120. package/apps/runtime/dist/prompts/architect.md +3 -3
  121. package/apps/runtime/dist/prompts/authoring.md +46 -12
  122. package/apps/runtime/dist/prompts/goose.md +14 -13
  123. package/apps/runtime/dist/prompts/mcp.md +6 -6
  124. package/apps/runtime/dist/prompts/safety.md +18 -0
  125. package/apps/runtime/dist/prompts/services.md +4 -4
  126. package/apps/runtime/dist/prompts/step.md +3 -3
  127. package/apps/runtime/dist/prompts/tools.md +39 -10
  128. package/apps/runtime/dist/routes/api.js +31 -20
  129. package/apps/runtime/dist/routes/broker.js +316 -0
  130. package/apps/runtime/dist/routes/connections.js +71 -0
  131. package/apps/runtime/dist/routes/delivery.js +25 -0
  132. package/apps/runtime/dist/routes/discover.js +17 -0
  133. package/apps/runtime/dist/routes/live.js +11 -1
  134. package/apps/runtime/dist/routes/marketplace.js +3 -3
  135. package/apps/runtime/dist/routes/person.js +4 -1
  136. package/apps/runtime/dist/routes/plugins.js +3 -1
  137. package/apps/runtime/dist/routes/rules.js +26 -0
  138. package/apps/runtime/dist/routes/runs.js +59 -33
  139. package/apps/runtime/dist/routes/skills.js +6 -6
  140. package/apps/runtime/dist/routes/studio.js +256 -148
  141. package/apps/runtime/dist/routes/work.js +199 -0
  142. package/apps/runtime/dist/safety.js +60 -18
  143. package/apps/runtime/dist/sandbox/index.js +27 -0
  144. package/apps/runtime/dist/services/access.js +38 -17
  145. package/apps/runtime/dist/services/api.js +38 -13
  146. package/apps/runtime/dist/services/architect.js +3 -3
  147. package/apps/runtime/dist/services/assistant-chats.js +9 -1
  148. package/apps/runtime/dist/services/brand.js +12 -12
  149. package/apps/runtime/dist/services/broker-bell.js +69 -0
  150. package/apps/runtime/dist/services/broker-notify.js +127 -0
  151. package/apps/runtime/dist/services/client-steps.js +79 -0
  152. package/apps/runtime/dist/services/cloud.js +42 -42
  153. package/apps/runtime/dist/services/command-risk.js +51 -0
  154. package/apps/runtime/dist/services/discover.js +85 -0
  155. package/apps/runtime/dist/services/knowledge-model.js +13 -13
  156. package/apps/runtime/dist/services/knowledge.js +117 -80
  157. package/apps/runtime/dist/services/manage-reports.js +77 -7
  158. package/apps/runtime/dist/services/marketplace.js +7 -31
  159. package/apps/runtime/dist/services/members-studio.js +165 -0
  160. package/apps/runtime/dist/services/onboarding.js +22 -22
  161. package/apps/runtime/dist/services/package-file.js +1 -1
  162. package/apps/runtime/dist/services/package.js +22 -22
  163. package/apps/runtime/dist/services/pages.js +13 -9
  164. package/apps/runtime/dist/services/runs.js +4 -3
  165. package/apps/runtime/dist/services/seen.js +55 -0
  166. package/apps/runtime/dist/services/shares.js +28 -13
  167. package/apps/runtime/dist/services/site.js +23 -23
  168. package/apps/runtime/dist/services/skills-registry.js +15 -15
  169. package/apps/runtime/dist/services/skills.js +44 -44
  170. package/apps/runtime/dist/services/space-categories.js +35 -35
  171. package/apps/runtime/dist/services/space-data.js +130 -111
  172. package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
  173. package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
  174. package/apps/runtime/dist/services/space-origin.js +19 -11
  175. package/apps/runtime/dist/services/spaces.js +478 -598
  176. package/apps/runtime/dist/services/synced-spaces.js +668 -0
  177. package/apps/runtime/dist/services/themes.js +15 -15
  178. package/apps/runtime/dist/services/widgets.js +6 -6
  179. package/apps/runtime/dist/services/wizards.js +112 -38
  180. package/apps/runtime/dist/services/work-ai.js +257 -0
  181. package/apps/runtime/dist/services/work-approvals.js +104 -0
  182. package/apps/runtime/dist/services/work-chats.js +908 -0
  183. package/apps/runtime/dist/services/work-connections.js +90 -0
  184. package/apps/runtime/dist/services/work-files.js +85 -0
  185. package/apps/runtime/dist/services/work-mastra.js +73 -0
  186. package/apps/runtime/dist/services/work-sandbox.js +42 -0
  187. package/apps/runtime/dist/sharing/files.js +14 -4
  188. package/apps/runtime/dist/sharing/index.js +40 -39
  189. package/apps/runtime/dist/sharing/jobs.js +67 -17
  190. package/apps/runtime/dist/sharing/targets/connector.js +10 -6
  191. package/apps/runtime/dist/sharing/targets/email.js +10 -8
  192. package/apps/runtime/dist/sharing/targets/slack.js +10 -8
  193. package/apps/runtime/dist/sharing/targets/storage.js +6 -4
  194. package/apps/runtime/dist/store/index.js +14 -3
  195. package/apps/runtime/dist/store/shared-lists.js +4 -2
  196. package/apps/runtime/dist/sync/apply.js +2 -2
  197. package/apps/runtime/dist/sync/client.js +113 -113
  198. package/apps/runtime/dist/sync/hub.js +41 -41
  199. package/apps/runtime/dist/sync/log.js +12 -12
  200. package/apps/runtime/dist/sync/records.js +118 -120
  201. package/apps/runtime/dist/texts.js +44 -2
  202. package/apps/runtime/dist/tools/connections.js +112 -0
  203. package/apps/runtime/dist/tools/connector.js +157 -67
  204. package/apps/runtime/dist/tools/index.js +31 -15
  205. package/apps/runtime/dist/tools/mail.js +40 -11
  206. package/apps/runtime/dist/tools/pages.js +11 -5
  207. package/apps/runtime/dist/tools/plugin.js +43 -7
  208. package/apps/runtime/dist/tools/skills.js +1 -1
  209. package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
  210. package/apps/runtime/dist/tools/store.js +3 -2
  211. package/apps/runtime/dist/widgets/step.js +10 -10
  212. package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
  213. package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
  214. package/apps/web/dist/assets/{ChangelogDialog-CKLgFL6r.js → ChangelogDialog-Duab4zTO.js} +1 -1
  215. package/apps/web/dist/assets/{CodeEditor-B3nto_26.js → CodeEditor-nxoOt8ge.js} +1 -1
  216. package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
  217. package/apps/web/dist/assets/{FlowPreview-zJCtixSi.js → FlowPreview-aMfwcPul.js} +1 -1
  218. package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
  219. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
  220. package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
  221. package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
  222. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
  223. package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
  224. package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
  225. package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
  226. package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
  227. package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
  228. package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
  229. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
  230. package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
  231. package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
  232. package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
  233. package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
  234. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
  235. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
  236. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
  237. package/apps/web/dist/assets/{code-xml-Hx7YxCg0.js → code-xml-B4kLFZSj.js} +1 -1
  238. package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
  239. package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
  240. package/apps/web/dist/assets/{eye-BkMFLnYu.js → eye-BpoKpIdt.js} +1 -1
  241. package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
  242. package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
  243. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
  244. package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
  245. package/apps/web/dist/assets/index-D2akynS-.js +10 -0
  246. package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
  247. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
  248. package/apps/web/dist/assets/{phone-DMfwuh9V.js → phone-Ctvf-Am-.js} +1 -1
  249. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
  250. package/apps/web/dist/assets/{runners-D5qz6b_s.js → runners-CyIvJIHr.js} +1 -1
  251. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
  252. package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
  253. package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
  254. package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
  255. package/apps/web/dist/assets/{upload-DQJwLSGj.js → upload-BchUnQGV.js} +1 -1
  256. package/apps/web/dist/assets/{useMutation-C20c2EH3.js → useMutation-DEkZhp5c.js} +1 -1
  257. package/apps/web/dist/assets/{volume-2-CC5qamYT.js → volume-2-CU_oy81Z.js} +1 -1
  258. package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
  259. package/apps/web/dist/index.html +17 -10
  260. package/apps/web/dist/mcp/flow.html +119 -64
  261. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
  262. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +7 -1
  263. package/node_modules/@engenty/wizards-shared/dist/assistant.js +11 -1
  264. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
  265. package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
  266. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +257 -8
  267. package/node_modules/@engenty/wizards-shared/dist/definition.js +113 -15
  268. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
  269. package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
  270. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +38 -2
  271. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +38 -2
  272. package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
  273. package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
  274. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
  275. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
  276. package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
  277. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +0 -5
  278. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
  279. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +115 -6
  280. package/node_modules/@engenty/wizards-shared/dist/run.js +135 -0
  281. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
  282. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
  283. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
  284. package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
  285. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
  286. package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
  287. package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
  288. package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
  289. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
  290. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
  291. package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
  292. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
  293. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
  294. package/node_modules/@engenty/wizards-shared/dist/tiers.d.ts +195 -0
  295. package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
  296. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
  297. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
  298. package/package.json +4 -1
  299. package/plugin/.claude-plugin/plugin.json +1 -1
  300. package/plugin/plugin.json +1 -1
  301. package/plugin/skills/build-wizard/SKILL.md +1 -1
  302. package/apps/runtime/dist/services/projects.js +0 -473
  303. package/apps/web/dist/assets/AboutDialog-CLgnoYTI.js +0 -1
  304. package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +0 -3
  305. package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +0 -2
  306. package/apps/web/dist/assets/NewWizardChannels-B4N7GIYh.js +0 -1
  307. package/apps/web/dist/assets/NewWizardPage-Dpt0Mzk8.js +0 -7
  308. package/apps/web/dist/assets/OnboardingPage-CDoYVjRC.js +0 -1
  309. package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +0 -10
  310. package/apps/web/dist/assets/ProjectPage-408YOoNa.js +0 -10
  311. package/apps/web/dist/assets/PublicRunner-BZ66xdRX.js +0 -1
  312. package/apps/web/dist/assets/ReadOnly-C9oGMkUB.js +0 -1
  313. package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +0 -2
  314. package/apps/web/dist/assets/SetupPage-CP3lbyZc.js +0 -1
  315. package/apps/web/dist/assets/SharePage-DdMm1Y8K.js +0 -1
  316. package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +0 -1
  317. package/apps/web/dist/assets/changelog-82-DHogQ.js +0 -1
  318. package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
  319. package/apps/web/dist/assets/i18n-CKKh3Pn0.js +0 -55
  320. package/apps/web/dist/assets/index-Cy2NHzAx.js +0 -49
  321. package/apps/web/dist/assets/index-wR_-1hfN.css +0 -1
  322. package/apps/web/dist/assets/lock-CGXM95Mi.js +0 -1
  323. package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
  324. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
  325. package/apps/web/dist/assets/session-DRy0k0nh.js +0 -2
  326. package/apps/web/dist/assets/theme-DNPm6r4e.js +0 -11
  327. package/apps/web/dist/assets/ui-CwFQAfE-.js +0 -83
  328. /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
@@ -0,0 +1,90 @@
1
+ import { eq } from "drizzle-orm";
2
+ import { listSpaceConnections } from "../connectors/space-connections.js";
3
+ import { db, schema } from "../db/client.js";
4
+ import { prompt } from "../prompts.js";
5
+ import { callConnection, connectionRefusalNote, connectionResult, connectionToolsOf, makeConnectionTools, usableConnections, } from "../tools/connections.js";
6
+ import { assistantToolRisk } from "../tools/plugin.js";
7
+ import { isAdminRole, roleOf } from "./access.js";
8
+ import { holdCall } from "./work-approvals.js";
9
+ /*
10
+ * A Work chat's grant (docs/plans/capabilities.md, A7): the space's connections whose audience
11
+ * includes the person the turn is for. Their read actions are tools that run at once; a write, a
12
+ * send or a delete is a confirmed action: the AI fills in its fields, the gate holds the call for
13
+ * the person (`chat_approval`, the card in the chat), and once they confirm it the broker decides
14
+ * by the connection's rules. „Mit Freigabe“ on a connection that signs in as the space holds it
15
+ * again, for the space's admins under the bell; an admin's yes runs it.
16
+ */
17
+ /** Who a chat's turn calls as: the person, an admin where their role in the organization says so. */
18
+ async function chatWho(userId) {
19
+ const role = await roleOf(userId);
20
+ return { kind: isAdminRole(role) ? "admin" : "person", id: userId };
21
+ }
22
+ /**
23
+ * The connections of the space this person reaches in a chat: those open to their role, and of
24
+ * the ones in which each person signs in, only those they signed in to.
25
+ */
26
+ async function chatConnectionTools(spaceId, userId, who) {
27
+ const rows = await listSpaceConnections(spaceId);
28
+ const own = rows.some((r) => r.signIn === "person")
29
+ ? new Set((await db.query.spaceConnectionSignIn.findMany({
30
+ where: eq(schema.spaceConnectionSignIn.userId, userId),
31
+ columns: { connectionId: true },
32
+ })).map((s) => s.connectionId))
33
+ : new Set();
34
+ const reachable = rows.filter((r) => r.signIn === "space" || own.has(r.id));
35
+ return connectionToolsOf(await usableConnections(reachable, who));
36
+ }
37
+ /** What a hold answers the AI: the same shape as the gate's, so the chat draws the card. */
38
+ const waiting = (approval, note) => ({ approval, status: "waiting", note });
39
+ /**
40
+ * The space's connections as the turn's tools, for the person the turn is for. The writes are
41
+ * marked `outside`, so the gate (work-ai.ts `gated`) holds each call for the person first; what
42
+ * runs here is the confirmed call.
43
+ */
44
+ export async function workConnectionTools(turn) {
45
+ const who = await chatWho(turn.userId);
46
+ const tools = await chatConnectionTools(turn.space.id, turn.userId, who);
47
+ if (!tools.length) {
48
+ return { tools: {}, labels: {} };
49
+ }
50
+ const where = { chatId: turn.chatId ?? undefined, spaceId: turn.space.id };
51
+ const made = makeConnectionTools({
52
+ tools,
53
+ who,
54
+ where: () => where,
55
+ writeNote: (tool) => tool.row.signIn === "space" && tool.row.rules[tool.kind] === "ask"
56
+ ? prompt("tools", "connection.confirms_admins")
57
+ : prompt("tools", "connection.confirms"),
58
+ write: async (tool, input) => {
59
+ // The person confirmed this exact call on its card: their own yes is given.
60
+ const out = await callConnection(tool, who, where, input, {
61
+ confirmed: true,
62
+ approved: turn.byAdmin === true,
63
+ ask: async () => ({ type: "done" }),
64
+ });
65
+ if (!out.ok && out.refused === "needs_approval" && turn.chatId) {
66
+ const id = await holdCall({ chatId: turn.chatId, userId: turn.userId }, tool.name, input, "admins");
67
+ return waiting(id, prompt("tools", "note.connection_waits_admins"));
68
+ }
69
+ if (!out.ok) {
70
+ // Thrown, so the approved call is marked failed and the AI hears why.
71
+ throw new Error(connectionRefusalNote(out.refused, serviceOf(tool)));
72
+ }
73
+ return connectionResult(out, serviceOf(tool));
74
+ },
75
+ });
76
+ for (const name of made.writes) {
77
+ assistantToolRisk.set(made.tools[name], "outside");
78
+ }
79
+ return { tools: made.tools, labels: made.labels };
80
+ }
81
+ const serviceOf = (tool) => `${tool.row.name} (${tool.connector.name})`;
82
+ /** How the chat names the connections' tools, for the person who opened it. */
83
+ export async function workConnectionLabels(spaceId, userId) {
84
+ const who = await chatWho(userId);
85
+ const tools = await chatConnectionTools(spaceId, userId, who);
86
+ return Object.fromEntries(tools.map((t) => [
87
+ t.name,
88
+ { plugin: t.row.name, tool: t.action.summary || t.action.id, label: null },
89
+ ]));
90
+ }
@@ -0,0 +1,85 @@
1
+ import { and, eq, inArray } from "drizzle-orm";
2
+ import { db, schema } from "../db/client.js";
3
+ import { ServiceError } from "./errors.js";
4
+ import { spaceFileContent } from "./space-files.js";
5
+ /** At most this many files go with one message. */
6
+ export const FILES_PER_MESSAGE = 10;
7
+ /** What the model reads itself, up to this many bytes; larger or other files it is told of. */
8
+ const MODEL_READS = {
9
+ "image/png": 5_000_000,
10
+ "image/jpeg": 5_000_000,
11
+ "image/webp": 5_000_000,
12
+ "image/gif": 5_000_000,
13
+ "application/pdf": 10_000_000,
14
+ };
15
+ /** Where an upload goes among the space's files: pictures and media are assets, the rest documents. */
16
+ export const fileKind = (mime) => /^(image|audio|video)\//.test(mime) ? "asset" : "document";
17
+ /** The line the model gets for files it does not read itself; the chat doesn't show it. */
18
+ const elsewhere = (names) => `(Attached: ${names.join(", ")}. In the space's files; search_space finds what they say once they are read.)`;
19
+ /** The space's files a message names, in its order; one not in the chat's space is refused. */
20
+ export async function chatFiles(spaceId, ids) {
21
+ if (!ids.length) {
22
+ return [];
23
+ }
24
+ const rows = await db.query.spaceFile.findMany({
25
+ where: and(eq(schema.spaceFile.spaceId, spaceId), inArray(schema.spaceFile.id, ids)),
26
+ });
27
+ return [...new Set(ids)].map((id) => {
28
+ const row = rows.find((r) => r.id === id);
29
+ if (!row) {
30
+ throw new ServiceError("not_found", "file not found");
31
+ }
32
+ return { id: row.id, name: row.name, mime: row.mime };
33
+ });
34
+ }
35
+ /**
36
+ * A message's contents for the model: the text, the files it reads as file parts, and one line
37
+ * naming the others; and the files as the message keeps them. Without files, the text as it is.
38
+ */
39
+ export async function messageContents(spaceId, text, files,
40
+ /** Who sends the message: the files go to the model as they may read them. */
41
+ who) {
42
+ if (!files.length) {
43
+ return { contents: text, files };
44
+ }
45
+ const parts = text ? [{ type: "text", text }] : [];
46
+ const kept = [];
47
+ for (const file of files) {
48
+ const { row, data } = await spaceFileContent(spaceId, file.id, who);
49
+ const read = data.byteLength <= (MODEL_READS[row.mime] ?? 0);
50
+ if (read) {
51
+ parts.push({
52
+ type: "file",
53
+ data: Buffer.from(data).toString("base64"),
54
+ mediaType: row.mime,
55
+ filename: row.name,
56
+ });
57
+ }
58
+ kept.push({ ...file, read });
59
+ }
60
+ const told = kept.filter((f) => !f.read).map((f) => f.name);
61
+ if (told.length) {
62
+ parts.push({ type: "text", text: elsewhere(told) });
63
+ }
64
+ return { contents: parts, files: kept };
65
+ }
66
+ /**
67
+ * A stored message's parts as the chat shows them: the files as links to the space's files (not
68
+ * their bytes), after the text, without the line for the model.
69
+ */
70
+ export function viewParts(spaceId, parts, files) {
71
+ if (!files?.length) {
72
+ return parts;
73
+ }
74
+ const line = elsewhere(files.filter((f) => !f.read).map((f) => f.name));
75
+ return [
76
+ ...parts.filter((p) => p.type !== "file" && !(p.type === "text" && p.text === line)),
77
+ ...files.map((f) => ({
78
+ type: "file",
79
+ fileId: f.id,
80
+ mediaType: f.mime,
81
+ filename: f.name,
82
+ url: `/api/studio/spaces/${spaceId}/files/${f.id}/content`,
83
+ })),
84
+ ];
85
+ }
@@ -0,0 +1,73 @@
1
+ import { Mastra } from "@mastra/core";
2
+ import { Agent } from "@mastra/core/agent";
3
+ import { LibSQLStore } from "@mastra/libsql";
4
+ import { Memory } from "@mastra/memory";
5
+ import { isNotNull } from "drizzle-orm";
6
+ import { cacheMarksProcessor, markedInstructions } from "../agents/space-agent.js";
7
+ import { db, schema, tenantClient } from "../db/client.js";
8
+ import { agentModel } from "../models.js";
9
+ import { currentTenant } from "../tenants/tenant.js";
10
+ import { TURN_KEY } from "./work-ai.js";
11
+ /**
12
+ * Mastra for Work's chats (docs/plans/work-chats.md): per tenant one store in the tenant's own
13
+ * database (Mastra's `mastra_` tables beside ours), one Memory and one Mastra instance, made once
14
+ * and kept while the database stays open. A chat is a memory thread: thread id = chat id,
15
+ * resource id = the space. Messages of people go in as Mastra's messages (signals), with the
16
+ * author as attributes; the space's AI answers in the same thread. Its model, tools and
17
+ * instructions are the turn's (work-ai.ts), read from the request context.
18
+ */
19
+ /** Messages a turn of the AI reads as they are; older ones through observational memory later. */
20
+ export const LAST_MESSAGES = 40;
21
+ export const SPACE_AI = "spaceAi";
22
+ const byTenant = new Map();
23
+ /**
24
+ * A turn doesn't outlive the process that ran it: when this process first serves a tenant's
25
+ * chats, none of them is answering (a chat still marked so was left by a process that died).
26
+ */
27
+ async function forgetDeadTurns() {
28
+ await db
29
+ .update(schema.chat)
30
+ .set({ answeringSince: null })
31
+ .where(isNotNull(schema.chat.answeringSince));
32
+ }
33
+ /** The turn the request runs (work-ai.ts), made on first use; a run without one is a mistake of ours. */
34
+ function turnOf(context) {
35
+ const turn = context.get(TURN_KEY);
36
+ if (!turn) {
37
+ throw new Error("A turn of the space's AI runs without its turn context.");
38
+ }
39
+ return turn.get();
40
+ }
41
+ function make(client) {
42
+ const store = new LibSQLStore({ id: "work-chats", client });
43
+ const memory = new Memory({ storage: store, options: { lastMessages: LAST_MESSAGES } });
44
+ const mastra = new Mastra({
45
+ agents: {
46
+ [SPACE_AI]: new Agent({
47
+ id: "space-ai",
48
+ name: "Space AI",
49
+ instructions: async ({ requestContext }) => markedInstructions((await turnOf(requestContext)).instructions),
50
+ model: async ({ requestContext }) => agentModel((await turnOf(requestContext)).resolved),
51
+ tools: async ({ requestContext }) => (await turnOf(requestContext)).tools,
52
+ memory,
53
+ inputProcessors: [cacheMarksProcessor],
54
+ }),
55
+ },
56
+ storage: store,
57
+ logger: false,
58
+ });
59
+ return { client, ready: store.init().then(forgetDeadTurns), memory, mastra };
60
+ }
61
+ /** The current tenant's Mastra, its store ready. */
62
+ export async function workMastra() {
63
+ const tenant = currentTenant();
64
+ const client = await tenantClient(tenant);
65
+ let entry = byTenant.get(tenant);
66
+ if (!entry || entry.client !== client) {
67
+ entry = make(client);
68
+ byTenant.set(tenant, entry);
69
+ entry.ready.catch(() => byTenant.delete(tenant));
70
+ }
71
+ await entry.ready;
72
+ return { memory: entry.memory, agent: entry.mastra.getAgent(SPACE_AI) };
73
+ }
@@ -0,0 +1,42 @@
1
+ import { createSandbox } from "../sandbox/index.js";
2
+ /**
3
+ * A Work chat's sandbox, where the space's AI runs commands and the scripts of the space's skills
4
+ * (docs/plans/skills.md). One per chat, made on its first command and kept while the chat is in
5
+ * use, so a file one turn writes is there for the next; gone after IDLE_MS without a command, or
6
+ * when the runtime stops.
7
+ */
8
+ /** A chat's sandbox goes after this long without a command. */
9
+ export const IDLE_MS = 30 * 60_000;
10
+ const kept = new Map();
11
+ const drop = (chatId) => {
12
+ const k = kept.get(chatId);
13
+ if (k) {
14
+ kept.delete(chatId);
15
+ clearTimeout(k.timer);
16
+ void k.sandbox.destroy().catch(() => undefined);
17
+ }
18
+ };
19
+ /** The chat's sandbox, made on first use; each use keeps it IDLE_MS longer. */
20
+ export function chatSandbox(chatId) {
21
+ let k = kept.get(chatId);
22
+ if (k) {
23
+ clearTimeout(k.timer);
24
+ }
25
+ else {
26
+ k = { sandbox: createSandbox(`chat-${chatId}`), timer: undefined };
27
+ kept.set(chatId, k);
28
+ }
29
+ k.timer = setTimeout(() => drop(chatId), IDLE_MS).unref();
30
+ return k.sandbox;
31
+ }
32
+ /** Ends a chat's sandbox now: the chat was deleted. */
33
+ export const dropChatSandbox = drop;
34
+ /** Ends every chat's sandbox: the runtime stops. */
35
+ export async function dropChatSandboxes() {
36
+ const all = [...kept.values()];
37
+ kept.clear();
38
+ await Promise.all(all.map((k) => {
39
+ clearTimeout(k.timer);
40
+ return k.sandbox.destroy().catch(() => undefined);
41
+ }));
42
+ }
@@ -1,4 +1,5 @@
1
1
  import { FORMATS, LIST_FORMATS, listRef, } from "@engenty/wizards-shared/definition";
2
+ import { runHolder, subjectsOf } from "../broker/rwx.js";
2
3
  import { listDownload, renderDownload } from "../render/downloads.js";
3
4
  import { listRows, scopeOf } from "../store/index.js";
4
5
  import { line, ShareError } from "./types.js";
@@ -9,9 +10,12 @@ export function resultStepOf(run) {
9
10
  steps.findLast((s) => s.type === "result");
10
11
  return step?.type === "result" ? step : null;
11
12
  }
12
- /** One output of a run as a file: a step's output or a stored list, in one format. */
13
+ /**
14
+ * One output of a run as a file: a step's output or a stored list, in one format. `who` reads a
15
+ * shared list: the run's holder and wizard.
16
+ */
13
17
  export async function resultFile(source, from, format) {
14
- const { def, state, store } = source;
18
+ const { def, state, store, who } = source;
15
19
  const deliverable = def.steps
16
20
  .flatMap((s) => (s.type === "result" ? s.deliverables : []))
17
21
  .find((d) => d.from === from);
@@ -22,7 +26,7 @@ export async function resultFile(source, from, format) {
22
26
  return null;
23
27
  }
24
28
  const label = deliverable?.label ?? listDef.title;
25
- const download = await listDownload(listDef, await listRows(store, listDef), format, `${def.title} ${label}`);
29
+ const download = await listDownload(listDef, await listRows(store, listDef, who), format, `${def.title} ${label}`);
26
30
  return download ? { download, label } : null;
27
31
  }
28
32
  const step = def.steps.find((s) => s.id === from);
@@ -50,7 +54,13 @@ function bytes(data) {
50
54
  */
51
55
  export async function shareFiles(run, items) {
52
56
  const result = resultStepOf(run);
53
- const source = { def: run.definition, state: run.state, store: scopeOf(run) };
57
+ const store = scopeOf(run);
58
+ const source = {
59
+ def: run.definition,
60
+ state: run.state,
61
+ store,
62
+ who: subjectsOf({ holder: await runHolder(run), store }),
63
+ };
54
64
  const files = [];
55
65
  const names = new Set();
56
66
  for (const item of items) {
@@ -19,8 +19,8 @@ import { sayIn } from "./types.js";
19
19
  * To add a target, write it in `./targets` and name it here.
20
20
  */
21
21
  const FIXED = [emailTarget, slackTarget, browserTarget];
22
- /** A share target by its id; null when this project has none of that name. */
23
- export async function shareTarget(projectId, id) {
22
+ /** A share target by its id; null when this space has none of that name. */
23
+ export async function shareTarget(spaceId, id) {
24
24
  const fixed = FIXED.find((t) => t.id === id);
25
25
  if (fixed) {
26
26
  return fixed;
@@ -32,17 +32,17 @@ export async function shareTarget(projectId, id) {
32
32
  return connector ? storageTarget(connector) : null;
33
33
  }
34
34
  if (kind === "connector") {
35
- const found = await resolveConnector(projectId, connectorId);
35
+ const found = await resolveConnector(spaceId, connectorId);
36
36
  return found && canPublish(found.connector)
37
37
  ? connectorTarget(found.connector, found.imported)
38
38
  : null;
39
39
  }
40
40
  return null;
41
41
  }
42
- /** Every target of a project, in the order a result shows them. */
43
- async function projectTargets(projectId) {
44
- const imported = (await listConnectors(projectId)).filter((c) => c.sourceKind !== "builtin");
45
- const through = await Promise.all(imported.map((c) => shareTarget(projectId, `connector:${c.id}`)));
42
+ /** Every target of a space, in the order a result shows them. */
43
+ async function spaceTargets(spaceId) {
44
+ const imported = (await listConnectors(spaceId)).filter((c) => c.sourceKind !== "builtin");
45
+ const through = await Promise.all(imported.map((c) => shareTarget(spaceId, `connector:${c.id}`)));
46
46
  return [
47
47
  emailTarget,
48
48
  ...storageConnectors().flatMap((c) => storageTarget(c) ?? []),
@@ -52,14 +52,14 @@ async function projectTargets(projectId) {
52
52
  ];
53
53
  }
54
54
  /**
55
- * Every target a wizard of the project can name on its result, for the editor and for whoever
55
+ * Every target a wizard of the space can name on its result, for the editor and for whoever
56
56
  * authors a wizard: the default ones, and one for each built-in connector that can write.
57
57
  */
58
- export async function projectShareTargets(projectId, lang) {
59
- const targets = await projectTargets(projectId);
60
- const builtin = (await listConnectors(projectId)).filter((c) => c.sourceKind === "builtin");
58
+ export async function spaceShareTargets(spaceId, lang) {
59
+ const targets = await spaceTargets(spaceId);
60
+ const builtin = (await listConnectors(spaceId)).filter((c) => c.sourceKind === "builtin");
61
61
  for (const connector of builtin) {
62
- const target = await shareTarget(projectId, `connector:${connector.id}`);
62
+ const target = await shareTarget(spaceId, `connector:${connector.id}`);
63
63
  if (target) {
64
64
  targets.push(target);
65
65
  }
@@ -70,30 +70,30 @@ export async function projectShareTargets(projectId, lang) {
70
70
  description: sayIn(lang, target.description),
71
71
  icon: target.icon,
72
72
  agent: Boolean(target.agent),
73
- usable: await offerable(target, projectId),
73
+ usable: await offerable(target, spaceId),
74
74
  byDefault: target.byDefault !== false,
75
75
  fields: target.fields.map((f) => ({ id: f.id, label: sayIn(lang, f.label), kind: f.kind })),
76
76
  })));
77
77
  }
78
78
  /** Whether a target can work here right now: what it drives is there, its account can be connected. */
79
- async function offerable(target, projectId) {
79
+ async function offerable(target, spaceId) {
80
80
  if (target.available && !(await target.available())) {
81
81
  return false;
82
82
  }
83
83
  const connection = target.connection?.();
84
- return !connection || (await connectorOptions(connection, projectId)).length > 0;
84
+ return !connection || (await connectorOptions(connection, spaceId)).length > 0;
85
85
  }
86
86
  /**
87
- * The targets a result names: its own list, else every target of the project a result offers
88
- * by default. `missing` names listed targets this project does not have.
87
+ * The targets a result names: its own list, else every target of the space a result offers
88
+ * by default. `missing` names listed targets this space does not have.
89
89
  */
90
- async function namedTargets(run, projectId) {
90
+ async function namedTargets(run, spaceId) {
91
91
  const result = resultStepOf(run);
92
92
  if (!result) {
93
93
  return { entries: [], listed: true, missing: [] };
94
94
  }
95
95
  if (!result.share) {
96
- const entries = (await projectTargets(projectId))
96
+ const entries = (await spaceTargets(spaceId))
97
97
  .filter((target) => target.byDefault !== false)
98
98
  .map((target) => ({ key: target.id, target, values: {} }));
99
99
  return { entries, listed: false, missing: [] };
@@ -101,7 +101,7 @@ async function namedTargets(run, projectId) {
101
101
  const entries = [];
102
102
  const missing = [];
103
103
  for (const [i, option] of result.share.entries()) {
104
- const target = await shareTarget(projectId, option.target);
104
+ const target = await shareTarget(spaceId, option.target);
105
105
  if (target) {
106
106
  entries.push({
107
107
  key: `${i}:${option.target}`,
@@ -121,29 +121,29 @@ async function namedTargets(run, projectId) {
121
121
  * target that needs no model is offered, and the ones an agent drives only to the wizard's owner
122
122
  * — they run on the wizard's credits.
123
123
  */
124
- export async function offeredTargets(run, projectId, member) {
125
- const { entries, listed } = await namedTargets(run, projectId);
124
+ export async function offeredTargets(run, spaceId, member) {
125
+ const { entries, listed } = await namedTargets(run, spaceId);
126
126
  const asked = entries.filter((e) => listed || !e.target.agent || member);
127
- const usable = await Promise.all(asked.map((e) => offerable(e.target, projectId)));
127
+ const usable = await Promise.all(asked.map((e) => offerable(e.target, spaceId)));
128
128
  return asked.filter((_, i) => usable[i]);
129
129
  }
130
- export function targetScope(run, projectId, lang) {
130
+ export function targetScope(run, spaceId, lang) {
131
131
  const result = resultStepOf(run);
132
132
  return {
133
133
  run,
134
- projectId,
134
+ spaceId,
135
135
  lang,
136
136
  title: [result?.title, run.definition.title].filter(Boolean).join(" · "),
137
137
  message: result?.message ?? null,
138
138
  text: resultText(run),
139
139
  };
140
140
  }
141
- async function templateScope(run, projectId) {
142
- const project = await db.query.project.findFirst({ where: eq(schema.project.id, projectId) });
141
+ async function templateScope(run, spaceId) {
142
+ const space = await db.query.space.findFirst({ where: eq(schema.space.id, spaceId) });
143
143
  return {
144
144
  def: run.definition,
145
145
  state: run.state,
146
- brand: project?.brand ?? {},
146
+ brand: space?.brand ?? {},
147
147
  };
148
148
  }
149
149
  async function targetView(entry, scope, templates) {
@@ -151,7 +151,7 @@ async function targetView(entry, scope, templates) {
151
151
  const { lang } = scope;
152
152
  const connection = target.connection?.() ?? null;
153
153
  const [account] = connection
154
- ? await connectionViews([connection], scopeOf(scope.run), scope.projectId, lang)
154
+ ? await connectionViews([connection], scopeOf(scope.run), scope.spaceId, lang)
155
155
  : [null];
156
156
  const defaults = (await target.defaults?.(scope)) ?? {};
157
157
  return {
@@ -179,10 +179,10 @@ async function targetView(entry, scope, templates) {
179
179
  };
180
180
  }
181
181
  /** What the share sheet shows: the targets of this result and what was sent before. */
182
- export async function shareOverview(run, projectId, member, lang) {
183
- const scope = targetScope(run, projectId, lang);
184
- const templates = await templateScope(run, projectId);
185
- const offered = await offeredTargets(run, projectId, member);
182
+ export async function shareOverview(run, spaceId, member, lang) {
183
+ const scope = targetScope(run, spaceId, lang);
184
+ const templates = await templateScope(run, spaceId);
185
+ const offered = await offeredTargets(run, spaceId, member);
186
186
  const jobs = await shareJobs(run.id);
187
187
  return {
188
188
  targets: await Promise.all(offered.map((entry) => targetView(entry, scope, templates))),
@@ -213,6 +213,7 @@ function standIn(wizard, userId) {
213
213
  tenantId: wizard.tenantId,
214
214
  definition: wizard.draft,
215
215
  files: [],
216
+ grant: null,
216
217
  version: null,
217
218
  mode: "test",
218
219
  runner: null,
@@ -255,9 +256,9 @@ export async function sharePreview(wizard, userId, resultId, member, lang) {
255
256
  definition: wizard.draft,
256
257
  cursor: resultId,
257
258
  };
258
- const scope = targetScope(run, wizard.projectId, lang);
259
- const templates = await templateScope(run, wizard.projectId);
260
- const { entries, listed, missing } = await namedTargets(run, wizard.projectId);
259
+ const scope = targetScope(run, wizard.spaceId, lang);
260
+ const templates = await templateScope(run, wizard.spaceId);
261
+ const { entries, listed, missing } = await namedTargets(run, wizard.spaceId);
261
262
  const targets = [];
262
263
  const left = missing.map((name) => ({ name, why: "setup" }));
263
264
  for (const entry of entries) {
@@ -265,7 +266,7 @@ export async function sharePreview(wizard, userId, resultId, member, lang) {
265
266
  if (!listed && entry.target.agent && !member) {
266
267
  left.push({ name, why: "agent" });
267
268
  }
268
- else if (!(await offerable(entry.target, wizard.projectId))) {
269
+ else if (!(await offerable(entry.target, wizard.spaceId))) {
269
270
  left.push({ name, why: "setup" });
270
271
  }
271
272
  else {
@@ -290,10 +291,10 @@ export async function sharePreview(wizard, userId, resultId, member, lang) {
290
291
  };
291
292
  }
292
293
  // The account a target sends with is a connection of its own, kept like the wizard's connections.
293
- registerConnectionSource(async (_run, connectionId, projectId) => {
294
+ registerConnectionSource(async (_run, connectionId, spaceId) => {
294
295
  if (!connectionId.startsWith("share:")) {
295
296
  return null;
296
297
  }
297
- const target = await shareTarget(projectId, connectionId.slice("share:".length));
298
+ const target = await shareTarget(spaceId, connectionId.slice("share:".length));
298
299
  return target?.connection?.() ?? null;
299
300
  });