@engenty/wizards-runtime 0.13.0 → 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 (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 +9 -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/0031_space.sql +624 -0
  35. package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
  36. package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
  37. package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
  38. package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
  39. package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
  40. package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
  41. package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
  42. package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
  43. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
  47. package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
  48. package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
  49. package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
  50. package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
  51. package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
  52. package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
  53. package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
  54. package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
  55. package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
  56. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
  57. package/apps/runtime/dist/db/schema.js +295 -72
  58. package/apps/runtime/dist/docs/dev/architecture.md +215 -0
  59. package/apps/runtime/dist/docs/dev/broker.md +298 -0
  60. package/apps/runtime/dist/docs/dev/index.md +5 -1
  61. package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
  62. package/apps/runtime/dist/docs/dev/meta.json +3 -0
  63. package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
  64. package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
  65. package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
  66. package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
  67. package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
  68. package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
  69. package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
  70. package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
  71. package/apps/runtime/dist/docs/dev/skills.md +16 -9
  72. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +40 -5
  73. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
  74. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
  75. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
  76. package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
  77. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
  78. package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
  79. package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
  80. package/apps/runtime/dist/docs/user-guide/index.md +10 -1
  81. package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
  82. package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
  83. package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
  84. package/apps/runtime/dist/docs/user-guide/space.md +5 -4
  85. package/apps/runtime/dist/docs/user-guide/together.md +16 -2
  86. package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
  87. package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
  88. package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
  89. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
  90. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
  91. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
  92. package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
  93. package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
  94. package/apps/runtime/dist/engine/resources.js +43 -12
  95. package/apps/runtime/dist/engine/runner.js +75 -23
  96. package/apps/runtime/dist/engine/steps.js +30 -12
  97. package/apps/runtime/dist/engine/template.js +18 -1
  98. package/apps/runtime/dist/env.js +9 -4
  99. package/apps/runtime/dist/index.js +18 -2
  100. package/apps/runtime/dist/live/feed.js +2 -2
  101. package/apps/runtime/dist/live/origin.js +2 -2
  102. package/apps/runtime/dist/live/views.js +51 -26
  103. package/apps/runtime/dist/manage.js +7 -0
  104. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  105. package/apps/runtime/dist/mcp/tools.js +75 -34
  106. package/apps/runtime/dist/models.js +1 -1
  107. package/apps/runtime/dist/motion-graphics/project.js +8 -8
  108. package/apps/runtime/dist/motion-graphics/tools.js +1 -1
  109. package/apps/runtime/dist/plugins/events.js +2 -2
  110. package/apps/runtime/dist/plugins/jobs.js +4 -1
  111. package/apps/runtime/dist/plugins/loader.js +2 -2
  112. package/apps/runtime/dist/prompts/architect.md +3 -3
  113. package/apps/runtime/dist/prompts/authoring.md +46 -12
  114. package/apps/runtime/dist/prompts/goose.md +7 -7
  115. package/apps/runtime/dist/prompts/mcp.md +6 -6
  116. package/apps/runtime/dist/prompts/services.md +4 -4
  117. package/apps/runtime/dist/prompts/step.md +2 -2
  118. package/apps/runtime/dist/prompts/tools.md +39 -10
  119. package/apps/runtime/dist/routes/api.js +31 -20
  120. package/apps/runtime/dist/routes/broker.js +316 -0
  121. package/apps/runtime/dist/routes/connections.js +71 -0
  122. package/apps/runtime/dist/routes/delivery.js +25 -0
  123. package/apps/runtime/dist/routes/discover.js +17 -0
  124. package/apps/runtime/dist/routes/live.js +11 -1
  125. package/apps/runtime/dist/routes/person.js +4 -1
  126. package/apps/runtime/dist/routes/plugins.js +3 -1
  127. package/apps/runtime/dist/routes/rules.js +26 -0
  128. package/apps/runtime/dist/routes/runs.js +54 -33
  129. package/apps/runtime/dist/routes/skills.js +6 -6
  130. package/apps/runtime/dist/routes/studio.js +153 -144
  131. package/apps/runtime/dist/routes/work.js +199 -0
  132. package/apps/runtime/dist/sandbox/index.js +27 -0
  133. package/apps/runtime/dist/services/access.js +38 -17
  134. package/apps/runtime/dist/services/api.js +38 -13
  135. package/apps/runtime/dist/services/architect.js +3 -3
  136. package/apps/runtime/dist/services/assistant-chats.js +9 -1
  137. package/apps/runtime/dist/services/brand.js +12 -12
  138. package/apps/runtime/dist/services/broker-bell.js +69 -0
  139. package/apps/runtime/dist/services/broker-notify.js +127 -0
  140. package/apps/runtime/dist/services/client-steps.js +79 -0
  141. package/apps/runtime/dist/services/cloud.js +42 -42
  142. package/apps/runtime/dist/services/command-risk.js +51 -0
  143. package/apps/runtime/dist/services/discover.js +85 -0
  144. package/apps/runtime/dist/services/knowledge-model.js +13 -13
  145. package/apps/runtime/dist/services/knowledge.js +117 -80
  146. package/apps/runtime/dist/services/manage-reports.js +74 -7
  147. package/apps/runtime/dist/services/members-studio.js +165 -0
  148. package/apps/runtime/dist/services/onboarding.js +22 -22
  149. package/apps/runtime/dist/services/package-file.js +1 -1
  150. package/apps/runtime/dist/services/package.js +22 -22
  151. package/apps/runtime/dist/services/pages.js +7 -7
  152. package/apps/runtime/dist/services/runs.js +4 -3
  153. package/apps/runtime/dist/services/seen.js +55 -0
  154. package/apps/runtime/dist/services/shares.js +23 -13
  155. package/apps/runtime/dist/services/site.js +23 -23
  156. package/apps/runtime/dist/services/skills-registry.js +15 -15
  157. package/apps/runtime/dist/services/skills.js +44 -44
  158. package/apps/runtime/dist/services/space-categories.js +35 -35
  159. package/apps/runtime/dist/services/space-data.js +130 -111
  160. package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
  161. package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
  162. package/apps/runtime/dist/services/space-origin.js +19 -11
  163. package/apps/runtime/dist/services/spaces.js +478 -612
  164. package/apps/runtime/dist/services/synced-spaces.js +668 -0
  165. package/apps/runtime/dist/services/themes.js +15 -15
  166. package/apps/runtime/dist/services/widgets.js +6 -6
  167. package/apps/runtime/dist/services/wizards.js +112 -38
  168. package/apps/runtime/dist/services/work-ai.js +257 -0
  169. package/apps/runtime/dist/services/work-approvals.js +104 -0
  170. package/apps/runtime/dist/services/work-chats.js +908 -0
  171. package/apps/runtime/dist/services/work-connections.js +90 -0
  172. package/apps/runtime/dist/services/work-files.js +85 -0
  173. package/apps/runtime/dist/services/work-mastra.js +73 -0
  174. package/apps/runtime/dist/services/work-sandbox.js +42 -0
  175. package/apps/runtime/dist/sharing/files.js +14 -4
  176. package/apps/runtime/dist/sharing/index.js +40 -39
  177. package/apps/runtime/dist/sharing/jobs.js +67 -17
  178. package/apps/runtime/dist/sharing/targets/connector.js +10 -6
  179. package/apps/runtime/dist/sharing/targets/email.js +10 -8
  180. package/apps/runtime/dist/sharing/targets/slack.js +10 -8
  181. package/apps/runtime/dist/sharing/targets/storage.js +6 -4
  182. package/apps/runtime/dist/store/index.js +14 -3
  183. package/apps/runtime/dist/store/shared-lists.js +4 -2
  184. package/apps/runtime/dist/sync/apply.js +2 -2
  185. package/apps/runtime/dist/sync/client.js +113 -113
  186. package/apps/runtime/dist/sync/hub.js +41 -41
  187. package/apps/runtime/dist/sync/log.js +12 -12
  188. package/apps/runtime/dist/sync/records.js +118 -120
  189. package/apps/runtime/dist/texts.js +38 -2
  190. package/apps/runtime/dist/tools/connections.js +112 -0
  191. package/apps/runtime/dist/tools/connector.js +157 -67
  192. package/apps/runtime/dist/tools/index.js +28 -13
  193. package/apps/runtime/dist/tools/mail.js +40 -11
  194. package/apps/runtime/dist/tools/pages.js +11 -5
  195. package/apps/runtime/dist/tools/plugin.js +43 -7
  196. package/apps/runtime/dist/tools/skills.js +1 -1
  197. package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
  198. package/apps/runtime/dist/tools/store.js +3 -2
  199. package/apps/runtime/dist/widgets/step.js +10 -10
  200. package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
  201. package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
  202. package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-Duab4zTO.js} +1 -1
  203. package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
  204. package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
  205. package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.js → FlowPreview-aMfwcPul.js} +1 -1
  206. package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
  207. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
  208. package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
  209. package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
  210. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
  211. package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
  212. package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
  213. package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
  214. package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
  215. package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
  216. package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
  217. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
  218. package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
  219. package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
  220. package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
  221. package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
  222. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
  223. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
  224. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
  225. package/apps/web/dist/assets/{code-xml-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
  226. package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
  227. package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
  228. package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
  229. package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
  230. package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
  231. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
  232. package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
  233. package/apps/web/dist/assets/index-D2akynS-.js +10 -0
  234. package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
  235. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
  236. package/apps/web/dist/assets/{phone-DhkHteoJ.js → phone-Ctvf-Am-.js} +1 -1
  237. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
  238. package/apps/web/dist/assets/{runners-G-XYaDgR.js → runners-CyIvJIHr.js} +1 -1
  239. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
  240. package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
  241. package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
  242. package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
  243. package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
  244. package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
  245. package/apps/web/dist/assets/{volume-2-CVHoxdGM.js → volume-2-CU_oy81Z.js} +1 -1
  246. package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
  247. package/apps/web/dist/index.html +17 -10
  248. package/apps/web/dist/mcp/flow.html +119 -64
  249. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
  250. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -1
  251. package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -1
  252. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
  253. package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
  254. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +150 -8
  255. package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
  256. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
  257. package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
  258. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +26 -2
  259. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -2
  260. package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
  261. package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
  262. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
  263. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
  264. package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
  265. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
  266. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
  267. package/node_modules/@engenty/wizards-shared/dist/run.js +85 -0
  268. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
  269. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
  270. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
  271. package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
  272. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
  273. package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
  274. package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
  275. package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
  276. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
  277. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
  278. package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
  279. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
  280. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
  281. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
  282. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
  283. package/package.json +4 -1
  284. package/plugin/.claude-plugin/plugin.json +1 -1
  285. package/plugin/plugin.json +1 -1
  286. package/plugin/skills/build-wizard/SKILL.md +1 -1
  287. package/apps/runtime/dist/services/projects.js +0 -473
  288. package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +0 -1
  289. package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
  290. package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
  291. package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
  292. package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
  293. package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
  294. package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
  295. package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
  296. package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
  297. package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
  298. package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
  299. package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
  300. package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
  301. package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
  302. package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
  303. package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
  304. package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
  305. package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
  306. package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
  307. package/apps/web/dist/assets/lock-C0uxcOlq.js +0 -1
  308. package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
  309. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
  310. package/apps/web/dist/assets/session-BWI-KENJ.js +0 -2
  311. package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
  312. package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
  313. /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
@@ -0,0 +1,257 @@
1
+ import { anthropic } from "@ai-sdk/anthropic";
2
+ import { surfaceComponentsSchema, validateSurface } from "@engenty/wizards-shared/surface";
3
+ import { createTool } from "@mastra/core/tools";
4
+ import { z } from "zod";
5
+ import { sortedTools } from "../agents/space-agent.js";
6
+ import { chatTurnWay } from "../agents/subscription.js";
7
+ import { subjectsOfPerson } from "../broker/rwx.js";
8
+ import { currentFeatures } from "../features.js";
9
+ import { HarnessModel } from "../harness/index.js";
10
+ import { managed } from "../manage.js";
11
+ import { attachTools, chatModel, gatewayTools } from "../models.js";
12
+ import { pluginsOf } from "../plugins/registry.js";
13
+ import { prompt } from "../prompts.js";
14
+ import { sandboxCapabilities, shellToolDescription } from "../sandbox/index.js";
15
+ import { currentTenant } from "../tenants/tenant.js";
16
+ import { assistantToolPlugin, assistantToolRisk, assistantToolsOf } from "../tools/plugin.js";
17
+ import { clip } from "../tools/shared.js";
18
+ import { skillsBlock, skillToolsOf } from "../tools/skills.js";
19
+ import { roleOf } from "./access.js";
20
+ import { ClientSteps } from "./client-steps.js";
21
+ import { activeSkills } from "./skills.js";
22
+ import { searchKnowledge } from "./space-index.js";
23
+ import { holdCall } from "./work-approvals.js";
24
+ import { workConnectionTools } from "./work-connections.js";
25
+ import { chatSandbox } from "./work-sandbox.js";
26
+ /**
27
+ * What the space's AI gets for one turn of a Work chat (docs/plans/work-chats.md): the model of
28
+ * the way the settings chose, the space's tools, and instructions that stay the same for the
29
+ * space, so the prompt's start is cached. The agent itself is the tenant's (work-mastra.ts); it
30
+ * reads this from the request context.
31
+ */
32
+ export const TURN_KEY = "workTurn";
33
+ /** A turn stops after this long. */
34
+ export const TURN_MS = 20 * 60_000;
35
+ /** Steps one turn may take. */
36
+ export const MAX_STEPS = 16;
37
+ const instructionsFor = (space, skills) => [
38
+ `You are the AI of the space "${space}" in engenty wizards. The team of the space talks with you and with each other in this chat.`,
39
+ 'Each message of a person comes as <user name="…">; answer the person who asked you, in their language, and call them by their name only when it helps.',
40
+ "Before you answer about the space (its clients, matters, files, data), look it up with search_space; say where you found it. When you can't find it, say so.",
41
+ "Write short, plain answers. Use lists or a table where they help. Rows, figures, a comparison or a few questions to the team can be a view instead: show_view.",
42
+ skills,
43
+ ]
44
+ .filter(Boolean)
45
+ .join("\n\n");
46
+ /** The space's skills that count, while the `skills` switch is on. */
47
+ async function spaceSkills(spaceId) {
48
+ return (await currentFeatures()).skills === true ? activeSkills(spaceId) : null;
49
+ }
50
+ /**
51
+ * The chat's sandbox (work-sandbox.ts) as the tools see it: `run_command`, and the skills whose
52
+ * scripts may run written into it. None without a chat (an approved call runs alone) or where
53
+ * this server has no sandbox.
54
+ */
55
+ function sandboxTools(chatId) {
56
+ const caps = chatId ? sandboxCapabilities() : null;
57
+ if (!(caps && chatId)) {
58
+ return { tools: {}, skill: null };
59
+ }
60
+ const handle = () => chatSandbox(chatId);
61
+ const report = (result) => ({
62
+ exitCode: result.exitCode,
63
+ stdout: clip(result.stdout, 8000),
64
+ stderr: clip(result.stderr, 4000),
65
+ });
66
+ return {
67
+ skill: { handle, workdir: caps.workdir },
68
+ tools: {
69
+ run_command: createTool({
70
+ id: "run_command",
71
+ description: shellToolDescription(caps),
72
+ inputSchema: z.object({ command: z.string(), timeoutSeconds: z.number().optional() }),
73
+ execute: async ({ command, timeoutSeconds }) => report(await handle().exec(command, {
74
+ timeoutMs: Math.min((timeoutSeconds ?? 120) * 1000, 600_000),
75
+ })),
76
+ }),
77
+ },
78
+ };
79
+ }
80
+ /** A view stays this small: what a chat shows at a glance, not a data dump. */
81
+ export const VIEW_MAX_BYTES = 64_000;
82
+ /**
83
+ * The view a turn draws in the chat (docs/plans/work-chats.md, generative UI): components of the
84
+ * surface catalog, the chat's own (Form, Ref, ask) among them, and the data they bind. It is
85
+ * checked here, so the model gets the issues and tries again; the chat draws the call's input
86
+ * once its result says ok. A client as the model calls it like any tool of the space.
87
+ */
88
+ export const showView = () => createTool({
89
+ id: "show_view",
90
+ description: [
91
+ "Shows a view in the chat: key figures, a table, a chart, a list of files, a form that asks the team. Everyone in the chat sees it.",
92
+ prompt("authoring", "surfaces"),
93
+ prompt("authoring", "surfaces.chat"),
94
+ ].join("\n\n"),
95
+ inputSchema: z.object({
96
+ title: z.string().max(120).optional().describe("What the view shows, in a few words"),
97
+ components: surfaceComponentsSchema,
98
+ data: z
99
+ .record(z.string(), z.unknown())
100
+ .default({})
101
+ .describe('What the components bind by {"path": "/key/…"}: the rows and figures you found'),
102
+ }),
103
+ execute: async ({ components, data }) => {
104
+ const bytes = Buffer.byteLength(JSON.stringify({ components, data }));
105
+ const issues = bytes > VIEW_MAX_BYTES
106
+ ? [
107
+ `The view is ${bytes} bytes, more than ${VIEW_MAX_BYTES}: show fewer rows or less text.`,
108
+ ]
109
+ : validateSurface(components, Object.keys(data ?? {}), { chat: true }).map((i) => i.message);
110
+ return issues.length
111
+ ? { ok: false, issues, note: "Nothing was shown. Fix these and call show_view again." }
112
+ : { ok: true, note: "Shown in the chat. Don't repeat what it shows." };
113
+ },
114
+ });
115
+ /** Whether the model can search the web itself: on Anthropic's API, or through the gateway. */
116
+ const searches = (resolved) => resolved.vendor === "anthropic" || resolved.gateway;
117
+ /**
118
+ * The space's tools for a turn: its knowledge, its skills, the chat's sandbox, the space's
119
+ * connections open to the person (work-connections.ts), the plugins' tools, the web; the plugins
120
+ * and the web the person turned off (`choice`) left out.
121
+ */
122
+ async function toolsFor(resolved, space, userId, signal, choice = {}, chatId = null, approved = null) {
123
+ const sandbox = sandboxTools(chatId);
124
+ const connections = await workConnectionTools({
125
+ space,
126
+ userId,
127
+ chatId: chatId ?? approved?.chatId ?? null,
128
+ byAdmin: approved?.byAdmin,
129
+ });
130
+ const skills = await spaceSkills(space.id);
131
+ // The turn reads as the person who asked: what they may not read, the AI does not find.
132
+ const who = subjectsOfPerson(userId, await roleOf(userId));
133
+ const tools = {
134
+ search_space: createTool({
135
+ id: "search_space",
136
+ description: "Searches the space's knowledge: its documents, pages, tables and the sources its plugins bring. Returns the best matches with where they are.",
137
+ inputSchema: z.object({ query: z.string().min(2).max(300) }),
138
+ execute: async ({ query }) => {
139
+ const found = await searchKnowledge(space.id, query, { limit: 8, signal, who });
140
+ return { hits: found.hits };
141
+ },
142
+ }),
143
+ show_view: showView(),
144
+ ...sandbox.tools,
145
+ ...(skills ? skillToolsOf(skills, () => { }, sandbox.skill) : {}),
146
+ ...connections.tools,
147
+ ...(await assistantToolsOf({
148
+ tenantId: currentTenant(),
149
+ space,
150
+ userId,
151
+ signal,
152
+ emit: () => { },
153
+ changed: () => { },
154
+ card: () => { },
155
+ })),
156
+ };
157
+ for (const [name, tool] of Object.entries(tools)) {
158
+ const plugin = tool && typeof tool === "object" ? assistantToolPlugin.get(tool) : undefined;
159
+ if (plugin && choice.pluginsOff?.includes(plugin)) {
160
+ delete tools[name];
161
+ }
162
+ }
163
+ if (choice.web !== false && resolved?.vendor === "anthropic") {
164
+ tools.web_search = anthropic.tools.webSearch_20250305({ maxUses: 5 });
165
+ }
166
+ else if (choice.web !== false && resolved?.gateway) {
167
+ tools.web_search = gatewayTools.perplexitySearch({ maxResults: 6 });
168
+ }
169
+ return sortedTools(tools);
170
+ }
171
+ /**
172
+ * What the composer offers for a turn: web search where the model can search, and the plugins
173
+ * whose tools the AI has. A way that isn't ready yet searches nothing.
174
+ */
175
+ export async function composerTools() {
176
+ const resolved = await chatModel(await chatTurnWay(managed), "standard").catch(() => null);
177
+ const plugins = (await pluginsOf(currentTenant()))
178
+ .filter((p) => p.assistantTools.size > 0)
179
+ .map((p) => ({ id: p.source.id, name: p.source.manifest.name }));
180
+ return { web: Boolean(resolved && searches(resolved)), plugins };
181
+ }
182
+ /**
183
+ * Whether a call of the tool waits for a person's approval: a plugin's tool marked `outside`
184
+ * does, and so does one without a mark (decided: "risk per tool", the safe side); a connection's
185
+ * write, send or delete is marked so too (a confirmed action). The space's own tools only read.
186
+ */
187
+ const UNMARKED_ASKS = true;
188
+ export function asksFirst(tool) {
189
+ if (!tool || typeof tool !== "object" || !assistantToolRisk.has(tool)) {
190
+ return false;
191
+ }
192
+ const risk = assistantToolRisk.get(tool);
193
+ return risk === "outside" || (risk === null && UNMARKED_ASKS);
194
+ }
195
+ /**
196
+ * The gate on the tool: a call that waits for approval doesn't run. It is stored, and the AI is
197
+ * told it waits; Approve runs it later (work-chats.ts). On a client too, since the gate is the
198
+ * tool's own and the client calls the tool.
199
+ */
200
+ export function gated(tools, turn) {
201
+ return Object.fromEntries(Object.entries(tools).map(([name, tool]) => {
202
+ if (!asksFirst(tool)) {
203
+ return [name, tool];
204
+ }
205
+ return [
206
+ name,
207
+ Object.assign(Object.create(Object.getPrototypeOf(tool)), tool, {
208
+ execute: async (input) => {
209
+ const id = await holdCall(turn, name, input);
210
+ return {
211
+ approval: id,
212
+ status: "waiting",
213
+ note: "Held for a person's approval. Don't call it again: the chat tells you once it is decided.",
214
+ };
215
+ },
216
+ }),
217
+ ];
218
+ }));
219
+ }
220
+ /** One tool of the space as it runs once approved, for the person the turn was for. */
221
+ export async function toolToRun(space, userId, name, signal, approved) {
222
+ const tools = await toolsFor(null, space, userId, signal, {}, null, approved);
223
+ return tools[name] ?? null;
224
+ }
225
+ /**
226
+ * Everything a turn of the space's AI needs, made for the person who asked. Calls that reach past
227
+ * the space are held (`gated`); on a client the tools are recorded as they run
228
+ * (client-steps.ts): the client runs them itself. `choice`: what the person chose in the
229
+ * composer.
230
+ */
231
+ export async function workTurn(turn, signal, steps, choice = {}) {
232
+ const resolved = await chatModel(await chatTurnWay(managed), choice.extra ? "high" : "standard");
233
+ const made = gated(await toolsFor(resolved, turn.space, turn.userId, signal, choice, turn.chatId), turn);
234
+ const tools = resolved.model instanceof HarnessModel ? steps.wrap(made) : made;
235
+ attachTools(resolved, tools);
236
+ const skills = await spaceSkills(turn.space.id);
237
+ const block = skills
238
+ ? skillsBlock(skills, { tools: true, sandbox: sandboxCapabilities() !== null })
239
+ : "";
240
+ return { resolved, tools, instructions: instructionsFor(turn.space.name, block) };
241
+ }
242
+ export function lazyTurn(turn, choice = {}) {
243
+ const controller = new AbortController();
244
+ const steps = new ClientSteps();
245
+ let made = null;
246
+ return {
247
+ signal: controller.signal,
248
+ steps,
249
+ get() {
250
+ if (!made) {
251
+ setTimeout(() => controller.abort(new Error("The turn took too long.")), TURN_MS).unref();
252
+ made = workTurn(turn, controller.signal, steps, choice);
253
+ }
254
+ return made;
255
+ },
256
+ };
257
+ }
@@ -0,0 +1,104 @@
1
+ import { and, asc, desc, eq, inArray } from "drizzle-orm";
2
+ import { nanoid } from "nanoid";
3
+ import { db, schema } from "../db/client.js";
4
+ import { currentTenant } from "../tenants/tenant.js";
5
+ import { isAdminRole } from "./access.js";
6
+ import { ServiceError } from "./errors.js";
7
+ const view = (a) => ({
8
+ id: a.id,
9
+ chatId: a.chatId,
10
+ toolName: a.toolName,
11
+ input: a.input ?? null,
12
+ askedBy: a.askedBy,
13
+ heldFor: a.heldFor,
14
+ state: a.state,
15
+ output: a.output ?? null,
16
+ decidedBy: a.decidedBy,
17
+ createdAt: a.createdAt.toISOString(),
18
+ });
19
+ /** Stores a call the gate held; its id goes to the AI and the chat's card. */
20
+ export async function holdCall(turn, toolName, input, heldFor = "asker") {
21
+ const id = nanoid(12);
22
+ await db.insert(schema.chatApproval).values({
23
+ id,
24
+ tenantId: currentTenant(),
25
+ chatId: turn.chatId,
26
+ toolName,
27
+ input: input ?? null,
28
+ askedBy: turn.userId,
29
+ heldFor,
30
+ });
31
+ return id;
32
+ }
33
+ export async function approvalsOf(chatId) {
34
+ const rows = await db.query.chatApproval.findMany({
35
+ where: eq(schema.chatApproval.chatId, chatId),
36
+ orderBy: [asc(schema.chatApproval.createdAt)],
37
+ });
38
+ return rows.map(view);
39
+ }
40
+ /**
41
+ * Whether the person may decide: the turn was theirs, or they own or run the organization. A call
42
+ * held for the admins is theirs alone, whoever asked.
43
+ */
44
+ export const mayDecide = (user, approval) => isAdminRole(user.role) || (approval.heldFor === "asker" && approval.askedBy === user.id);
45
+ /**
46
+ * Takes the decision, once: only a pending approval of this chat changes, so a second click or a
47
+ * second person gets a conflict and nothing runs twice.
48
+ */
49
+ export async function takeDecision(user, chatId, id, approve) {
50
+ const found = await db.query.chatApproval.findFirst({
51
+ where: and(eq(schema.chatApproval.id, id), eq(schema.chatApproval.chatId, chatId)),
52
+ });
53
+ if (!found) {
54
+ throw new ServiceError("not_found", "approval not found");
55
+ }
56
+ if (!mayDecide(user, found)) {
57
+ throw new ServiceError("forbidden", found.heldFor === "admins"
58
+ ? "only an owner or admin decides"
59
+ : "only who asked, or an owner or admin, decides");
60
+ }
61
+ const [taken] = await db
62
+ .update(schema.chatApproval)
63
+ .set({ state: approve ? "approved" : "denied", decidedBy: user.id, decidedAt: new Date() })
64
+ .where(and(eq(schema.chatApproval.id, id), eq(schema.chatApproval.state, "pending")))
65
+ .returning();
66
+ if (!taken) {
67
+ throw new ServiceError("revision_conflict", "already decided");
68
+ }
69
+ return taken;
70
+ }
71
+ /** What the approved call gave, or why it failed. */
72
+ export async function noteOutcome(id, outcome) {
73
+ await db
74
+ .update(schema.chatApproval)
75
+ .set("error" in outcome
76
+ ? { state: "failed", output: { error: outcome.error } }
77
+ : { output: outcome.output ?? null })
78
+ .where(eq(schema.chatApproval.id, id));
79
+ }
80
+ /**
81
+ * The approvals waiting for the person, newest first: the bell. A member sees their own, in the
82
+ * chats they see; an owner or admin every pending call of the organization, those held for the
83
+ * admins among them, in private chats they are not in too (docs/plans/capabilities.md, A7a).
84
+ */
85
+ export async function waitingFor(user, visibleChatIds) {
86
+ const admin = isAdminRole(user.role);
87
+ if (!(admin || visibleChatIds.length)) {
88
+ return [];
89
+ }
90
+ const rows = await db.query.chatApproval.findMany({
91
+ where: and(eq(schema.chatApproval.tenantId, user.tenantId), eq(schema.chatApproval.state, "pending"), admin
92
+ ? undefined
93
+ : and(inArray(schema.chatApproval.chatId, visibleChatIds), eq(schema.chatApproval.askedBy, user.id), eq(schema.chatApproval.heldFor, "asker"))),
94
+ orderBy: [desc(schema.chatApproval.createdAt)],
95
+ });
96
+ return rows.map(view);
97
+ }
98
+ /** Whether a tool's result says the call is held: the gate's answer, and a hold for the admins. */
99
+ export function heldBy(output) {
100
+ const o = output;
101
+ return o && typeof o === "object" && typeof o.approval === "string" && o.status === "waiting"
102
+ ? o.approval
103
+ : null;
104
+ }