@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.
- package/apps/runtime/dist/agents/architect.js +8 -7
- package/apps/runtime/dist/agents/goose-connections.js +82 -0
- package/apps/runtime/dist/agents/space-agent.js +9 -2
- package/apps/runtime/dist/agents/studio-assistant.js +126 -71
- package/apps/runtime/dist/agents/website.js +1 -1
- package/apps/runtime/dist/app.js +28 -3
- package/apps/runtime/dist/assistant/knows.js +6 -5
- package/apps/runtime/dist/authoring/guide.js +25 -5
- package/apps/runtime/dist/broker/account.js +166 -0
- package/apps/runtime/dist/broker/call.js +417 -0
- package/apps/runtime/dist/broker/caller.js +10 -0
- package/apps/runtime/dist/broker/grant.js +152 -0
- package/apps/runtime/dist/broker/host.js +51 -0
- package/apps/runtime/dist/broker/index.js +8 -0
- package/apps/runtime/dist/broker/kept.js +31 -0
- package/apps/runtime/dist/broker/log.js +240 -0
- package/apps/runtime/dist/broker/registry.js +9 -0
- package/apps/runtime/dist/broker/rwx.js +367 -0
- package/apps/runtime/dist/broker/send.js +189 -0
- package/apps/runtime/dist/connectors/builtin.js +1 -1
- package/apps/runtime/dist/connectors/external.js +38 -37
- package/apps/runtime/dist/connectors/index.js +30 -91
- package/apps/runtime/dist/connectors/mail.js +0 -8
- package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
- package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
- package/apps/runtime/dist/connectors/smtp.js +1 -1
- package/apps/runtime/dist/connectors/space-connections.js +436 -0
- package/apps/runtime/dist/credits/estimate.js +3 -3
- package/apps/runtime/dist/db/adopt.js +3 -3
- package/apps/runtime/dist/db/client.js +9 -0
- package/apps/runtime/dist/db/live-triggers.js +65 -23
- package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
- package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
- package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
- package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
- package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
- package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
- package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
- package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
- package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
- package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
- package/apps/runtime/dist/db/schema.js +295 -72
- package/apps/runtime/dist/docs/dev/architecture.md +215 -0
- package/apps/runtime/dist/docs/dev/broker.md +298 -0
- package/apps/runtime/dist/docs/dev/index.md +5 -1
- package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
- package/apps/runtime/dist/docs/dev/meta.json +3 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
- package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
- package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
- package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
- package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
- package/apps/runtime/dist/docs/dev/skills.md +16 -9
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +59 -6
- package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
- package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
- package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
- package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
- package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
- package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
- package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
- package/apps/runtime/dist/docs/user-guide/index.md +10 -1
- package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
- package/apps/runtime/dist/docs/user-guide/models.md +105 -30
- package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
- package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
- package/apps/runtime/dist/docs/user-guide/space.md +5 -4
- package/apps/runtime/dist/docs/user-guide/together.md +29 -2
- package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
- package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
- package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
- package/apps/runtime/dist/engine/decide.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +139 -11
- package/apps/runtime/dist/engine/resources.js +43 -12
- package/apps/runtime/dist/engine/runner.js +121 -27
- package/apps/runtime/dist/engine/steps.js +42 -16
- package/apps/runtime/dist/engine/template.js +35 -1
- package/apps/runtime/dist/env.js +9 -4
- package/apps/runtime/dist/index.js +18 -2
- package/apps/runtime/dist/link-preview.js +9 -0
- package/apps/runtime/dist/live/feed.js +2 -2
- package/apps/runtime/dist/live/origin.js +2 -2
- package/apps/runtime/dist/live/views.js +51 -26
- package/apps/runtime/dist/manage.js +32 -0
- package/apps/runtime/dist/mcp/flow-app.js +1 -1
- package/apps/runtime/dist/mcp/handler.js +55 -1
- package/apps/runtime/dist/mcp/seen.js +47 -0
- package/apps/runtime/dist/mcp/tools.js +75 -34
- package/apps/runtime/dist/models.js +203 -12
- package/apps/runtime/dist/motion-graphics/project.js +8 -8
- package/apps/runtime/dist/motion-graphics/step.js +2 -2
- package/apps/runtime/dist/motion-graphics/tools.js +1 -1
- package/apps/runtime/dist/plugins/events.js +2 -2
- package/apps/runtime/dist/plugins/jobs.js +4 -1
- package/apps/runtime/dist/plugins/loader.js +2 -2
- package/apps/runtime/dist/prompts/architect.md +3 -3
- package/apps/runtime/dist/prompts/authoring.md +46 -12
- package/apps/runtime/dist/prompts/goose.md +14 -13
- package/apps/runtime/dist/prompts/mcp.md +6 -6
- package/apps/runtime/dist/prompts/safety.md +18 -0
- package/apps/runtime/dist/prompts/services.md +4 -4
- package/apps/runtime/dist/prompts/step.md +3 -3
- package/apps/runtime/dist/prompts/tools.md +39 -10
- package/apps/runtime/dist/routes/api.js +31 -20
- package/apps/runtime/dist/routes/broker.js +316 -0
- package/apps/runtime/dist/routes/connections.js +71 -0
- package/apps/runtime/dist/routes/delivery.js +25 -0
- package/apps/runtime/dist/routes/discover.js +17 -0
- package/apps/runtime/dist/routes/live.js +11 -1
- package/apps/runtime/dist/routes/marketplace.js +3 -3
- package/apps/runtime/dist/routes/person.js +4 -1
- package/apps/runtime/dist/routes/plugins.js +3 -1
- package/apps/runtime/dist/routes/rules.js +26 -0
- package/apps/runtime/dist/routes/runs.js +59 -33
- package/apps/runtime/dist/routes/skills.js +6 -6
- package/apps/runtime/dist/routes/studio.js +256 -148
- package/apps/runtime/dist/routes/work.js +199 -0
- package/apps/runtime/dist/safety.js +60 -18
- package/apps/runtime/dist/sandbox/index.js +27 -0
- package/apps/runtime/dist/services/access.js +38 -17
- package/apps/runtime/dist/services/api.js +38 -13
- package/apps/runtime/dist/services/architect.js +3 -3
- package/apps/runtime/dist/services/assistant-chats.js +9 -1
- package/apps/runtime/dist/services/brand.js +12 -12
- package/apps/runtime/dist/services/broker-bell.js +69 -0
- package/apps/runtime/dist/services/broker-notify.js +127 -0
- package/apps/runtime/dist/services/client-steps.js +79 -0
- package/apps/runtime/dist/services/cloud.js +42 -42
- package/apps/runtime/dist/services/command-risk.js +51 -0
- package/apps/runtime/dist/services/discover.js +85 -0
- package/apps/runtime/dist/services/knowledge-model.js +13 -13
- package/apps/runtime/dist/services/knowledge.js +117 -80
- package/apps/runtime/dist/services/manage-reports.js +77 -7
- package/apps/runtime/dist/services/marketplace.js +7 -31
- package/apps/runtime/dist/services/members-studio.js +165 -0
- package/apps/runtime/dist/services/onboarding.js +22 -22
- package/apps/runtime/dist/services/package-file.js +1 -1
- package/apps/runtime/dist/services/package.js +22 -22
- package/apps/runtime/dist/services/pages.js +13 -9
- package/apps/runtime/dist/services/runs.js +4 -3
- package/apps/runtime/dist/services/seen.js +55 -0
- package/apps/runtime/dist/services/shares.js +28 -13
- package/apps/runtime/dist/services/site.js +23 -23
- package/apps/runtime/dist/services/skills-registry.js +15 -15
- package/apps/runtime/dist/services/skills.js +44 -44
- package/apps/runtime/dist/services/space-categories.js +35 -35
- package/apps/runtime/dist/services/space-data.js +130 -111
- package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
- package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
- package/apps/runtime/dist/services/space-origin.js +19 -11
- package/apps/runtime/dist/services/spaces.js +478 -598
- package/apps/runtime/dist/services/synced-spaces.js +668 -0
- package/apps/runtime/dist/services/themes.js +15 -15
- package/apps/runtime/dist/services/widgets.js +6 -6
- package/apps/runtime/dist/services/wizards.js +112 -38
- package/apps/runtime/dist/services/work-ai.js +257 -0
- package/apps/runtime/dist/services/work-approvals.js +104 -0
- package/apps/runtime/dist/services/work-chats.js +908 -0
- package/apps/runtime/dist/services/work-connections.js +90 -0
- package/apps/runtime/dist/services/work-files.js +85 -0
- package/apps/runtime/dist/services/work-mastra.js +73 -0
- package/apps/runtime/dist/services/work-sandbox.js +42 -0
- package/apps/runtime/dist/sharing/files.js +14 -4
- package/apps/runtime/dist/sharing/index.js +40 -39
- package/apps/runtime/dist/sharing/jobs.js +67 -17
- package/apps/runtime/dist/sharing/targets/connector.js +10 -6
- package/apps/runtime/dist/sharing/targets/email.js +10 -8
- package/apps/runtime/dist/sharing/targets/slack.js +10 -8
- package/apps/runtime/dist/sharing/targets/storage.js +6 -4
- package/apps/runtime/dist/store/index.js +14 -3
- package/apps/runtime/dist/store/shared-lists.js +4 -2
- package/apps/runtime/dist/sync/apply.js +2 -2
- package/apps/runtime/dist/sync/client.js +113 -113
- package/apps/runtime/dist/sync/hub.js +41 -41
- package/apps/runtime/dist/sync/log.js +12 -12
- package/apps/runtime/dist/sync/records.js +118 -120
- package/apps/runtime/dist/texts.js +44 -2
- package/apps/runtime/dist/tools/connections.js +112 -0
- package/apps/runtime/dist/tools/connector.js +157 -67
- package/apps/runtime/dist/tools/index.js +31 -15
- package/apps/runtime/dist/tools/mail.js +40 -11
- package/apps/runtime/dist/tools/pages.js +11 -5
- package/apps/runtime/dist/tools/plugin.js +43 -7
- package/apps/runtime/dist/tools/skills.js +1 -1
- package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
- package/apps/runtime/dist/tools/store.js +3 -2
- package/apps/runtime/dist/widgets/step.js +10 -10
- package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-CKLgFL6r.js → ChangelogDialog-Duab4zTO.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-B3nto_26.js → CodeEditor-nxoOt8ge.js} +1 -1
- package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-zJCtixSi.js → FlowPreview-aMfwcPul.js} +1 -1
- package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
- package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
- package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
- package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
- package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
- package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
- package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
- package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
- package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
- package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
- package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
- package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
- package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
- package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
- package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
- package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
- package/apps/web/dist/assets/{code-xml-Hx7YxCg0.js → code-xml-B4kLFZSj.js} +1 -1
- package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
- package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
- package/apps/web/dist/assets/{eye-BkMFLnYu.js → eye-BpoKpIdt.js} +1 -1
- package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
- package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
- package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
- package/apps/web/dist/assets/index-D2akynS-.js +10 -0
- package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
- package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
- package/apps/web/dist/assets/{phone-DMfwuh9V.js → phone-Ctvf-Am-.js} +1 -1
- package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
- package/apps/web/dist/assets/{runners-D5qz6b_s.js → runners-CyIvJIHr.js} +1 -1
- package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
- package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
- package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
- package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
- package/apps/web/dist/assets/{upload-DQJwLSGj.js → upload-BchUnQGV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-C20c2EH3.js → useMutation-DEkZhp5c.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CC5qamYT.js → volume-2-CU_oy81Z.js} +1 -1
- package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
- package/apps/web/dist/index.html +17 -10
- package/apps/web/dist/mcp/flow.html +119 -64
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +7 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +11 -1
- package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
- package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +257 -8
- package/node_modules/@engenty/wizards-shared/dist/definition.js +113 -15
- package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
- package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +38 -2
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +38 -2
- package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +0 -5
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +115 -6
- package/node_modules/@engenty/wizards-shared/dist/run.js +135 -0
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
- package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
- package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
- package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
- package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
- package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/tiers.d.ts +195 -0
- package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
- package/package.json +4 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/skills/build-wizard/SKILL.md +1 -1
- package/apps/runtime/dist/services/projects.js +0 -473
- package/apps/web/dist/assets/AboutDialog-CLgnoYTI.js +0 -1
- package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +0 -3
- package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-B4N7GIYh.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-Dpt0Mzk8.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-CDoYVjRC.js +0 -1
- package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +0 -10
- package/apps/web/dist/assets/ProjectPage-408YOoNa.js +0 -10
- package/apps/web/dist/assets/PublicRunner-BZ66xdRX.js +0 -1
- package/apps/web/dist/assets/ReadOnly-C9oGMkUB.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +0 -2
- package/apps/web/dist/assets/SetupPage-CP3lbyZc.js +0 -1
- package/apps/web/dist/assets/SharePage-DdMm1Y8K.js +0 -1
- package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +0 -1
- package/apps/web/dist/assets/changelog-82-DHogQ.js +0 -1
- package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
- package/apps/web/dist/assets/i18n-CKKh3Pn0.js +0 -55
- package/apps/web/dist/assets/index-Cy2NHzAx.js +0 -49
- package/apps/web/dist/assets/index-wR_-1hfN.css +0 -1
- package/apps/web/dist/assets/lock-CGXM95Mi.js +0 -1
- package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
- package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
- package/apps/web/dist/assets/session-DRy0k0nh.js +0 -2
- package/apps/web/dist/assets/theme-DNPm6r4e.js +0 -11
- package/apps/web/dist/assets/ui-CwFQAfE-.js +0 -83
- /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GRADIENT_TYPES, gradientCss, mainLogo, runTheme, } from "@engenty/wizards-shared/projects";
|
|
2
1
|
import { note } from "@engenty/wizards-shared/run";
|
|
2
|
+
import { GRADIENT_TYPES, gradientCss, mainLogo, runTheme, } from "@engenty/wizards-shared/spaces";
|
|
3
3
|
import { chosenTheme, lookColours, themedLook } from "@engenty/wizards-shared/theme-look";
|
|
4
4
|
import { generateText, Output } from "ai";
|
|
5
5
|
import { and, asc, eq } from "drizzle-orm";
|
|
@@ -8,23 +8,23 @@ import { db, schema } from "../db/client.js";
|
|
|
8
8
|
import { textModel } from "../models.js";
|
|
9
9
|
import { prompt } from "../prompts.js";
|
|
10
10
|
import { ServiceError } from "./errors.js";
|
|
11
|
-
/** The
|
|
12
|
-
export async function mainLogoId(
|
|
13
|
-
const p = await db.query.
|
|
14
|
-
const logos = await db.query.
|
|
11
|
+
/** The space's main logo, the first standard one: what end users, documents and widgets get. */
|
|
12
|
+
export async function mainLogoId(spaceId) {
|
|
13
|
+
const p = await db.query.space.findFirst({ where: eq(schema.space.id, spaceId) });
|
|
14
|
+
const logos = await db.query.spaceFile.findMany({
|
|
15
15
|
columns: { id: true },
|
|
16
|
-
where: and(eq(schema.
|
|
17
|
-
orderBy: [asc(schema.
|
|
16
|
+
where: and(eq(schema.spaceFile.spaceId, spaceId), eq(schema.spaceFile.kind, "logo")),
|
|
17
|
+
orderBy: [asc(schema.spaceFile.position), asc(schema.spaceFile.createdAt)],
|
|
18
18
|
});
|
|
19
19
|
return mainLogo(logos, p?.brand.logoSections)?.id ?? null;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* What end users see of the
|
|
22
|
+
* What end users see of the space: its title, accent and logo — never the space name — and the
|
|
23
23
|
* look of the wizard's pages: the theme the place showing it asks for where the wizard offers
|
|
24
24
|
* it, else the first theme of the wizard's chain the space has, else the brand.
|
|
25
25
|
*/
|
|
26
|
-
export async function brandView(
|
|
27
|
-
const p = await db.query.
|
|
26
|
+
export async function brandView(spaceId, chain, asked) {
|
|
27
|
+
const p = await db.query.space.findFirst({ where: eq(schema.space.id, spaceId) });
|
|
28
28
|
const logo = p ? await mainLogoId(p.id) : null;
|
|
29
29
|
const theme = themedLook(runTheme(p?.brand ?? {}), chosenTheme(chain, p?.themes ?? [], asked));
|
|
30
30
|
return {
|
|
@@ -40,8 +40,8 @@ export async function brandView(projectId, chain, asked) {
|
|
|
40
40
|
* The looks of the themes a wizard offers, in its order: what the studio's preview switches
|
|
41
41
|
* between. A theme the space no longer has is left out.
|
|
42
42
|
*/
|
|
43
|
-
export async function themeLooks(
|
|
44
|
-
const p = await db.query.
|
|
43
|
+
export async function themeLooks(spaceId, chain) {
|
|
44
|
+
const p = await db.query.space.findFirst({ where: eq(schema.space.id, spaceId) });
|
|
45
45
|
const brand = runTheme(p?.brand ?? {});
|
|
46
46
|
return (chain ?? []).flatMap((id) => {
|
|
47
47
|
const theme = chosenTheme([id], p?.themes ?? []);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { and, eq } from "drizzle-orm";
|
|
2
|
+
import { criticalSince } from "../broker/index.js";
|
|
3
|
+
import { db, schema } from "../db/client.js";
|
|
4
|
+
import { currentTenant } from "../tenants/tenant.js";
|
|
5
|
+
import { isAdminRole } from "./access.js";
|
|
6
|
+
import { bellSeenAt, markBellSeen } from "./seen.js";
|
|
7
|
+
/**
|
|
8
|
+
* What the broker's critical lines are under Work's bell (docs/plans/broker.md,
|
|
9
|
+
* "Notifications"): the second kind of item beside the calls held for approval. An admin sees
|
|
10
|
+
* every line of the spaces they administer – every space of the tenant – that came in during the
|
|
11
|
+
* last days; the count on the bell is what came in since they last opened it. A member sees none.
|
|
12
|
+
*/
|
|
13
|
+
/** How far back the bell lists critical lines. */
|
|
14
|
+
export const BELL_DAYS = 7;
|
|
15
|
+
/** How many at most. */
|
|
16
|
+
const BELL_LINES = 50;
|
|
17
|
+
export function criticalItem(row) {
|
|
18
|
+
return {
|
|
19
|
+
id: row.id,
|
|
20
|
+
at: row.at.toISOString(),
|
|
21
|
+
kind: (row.criticalKind ?? "refused_write"),
|
|
22
|
+
spaceId: row.spaceId ?? "",
|
|
23
|
+
who: { kind: row.whoKind, id: row.whoId },
|
|
24
|
+
connectionId: row.connectionId,
|
|
25
|
+
actionId: row.actionId,
|
|
26
|
+
outcome: row.outcome,
|
|
27
|
+
result: row.result,
|
|
28
|
+
reason: row.reason,
|
|
29
|
+
runId: row.runId,
|
|
30
|
+
wizardId: row.wizardId,
|
|
31
|
+
chatId: row.chatId,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** The spaces of the tenant whose bell is on. */
|
|
35
|
+
async function bellSpaces() {
|
|
36
|
+
const rows = await db.query.space.findMany({
|
|
37
|
+
where: eq(schema.space.tenantId, currentTenant()),
|
|
38
|
+
columns: { id: true, notify: true },
|
|
39
|
+
});
|
|
40
|
+
return rows.filter((s) => s.notify.bell).map((s) => s.id);
|
|
41
|
+
}
|
|
42
|
+
/** The critical lines for this person's bell, newest first, and how many are new since they opened it. */
|
|
43
|
+
export async function criticalsFor(user) {
|
|
44
|
+
if (!isAdminRole(user.role)) {
|
|
45
|
+
return { critical: [], unseen: 0 };
|
|
46
|
+
}
|
|
47
|
+
const since = new Date(Date.now() - BELL_DAYS * 24 * 3600_000);
|
|
48
|
+
const rows = await criticalSince(await bellSpaces(), since, BELL_LINES);
|
|
49
|
+
const seen = (await bellSeenAt(user.id))?.getTime() ?? 0;
|
|
50
|
+
return {
|
|
51
|
+
critical: rows.map(criticalItem),
|
|
52
|
+
unseen: rows.filter((r) => r.at.getTime() > seen).length,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** The person opened the bell. */
|
|
56
|
+
export async function bellOpened(user) {
|
|
57
|
+
await markBellSeen(user.id);
|
|
58
|
+
}
|
|
59
|
+
/** For tests and the report: the critical rows of one space since a time. */
|
|
60
|
+
export async function criticalOfSpace(spaceId, since) {
|
|
61
|
+
const rows = await criticalSince([spaceId], since);
|
|
62
|
+
return rows.filter((r) => r.spaceId === spaceId);
|
|
63
|
+
}
|
|
64
|
+
/** Whether a space of the tenant exists (the routes' 404). */
|
|
65
|
+
export async function tenantSpace(spaceId) {
|
|
66
|
+
return db.query.space.findFirst({
|
|
67
|
+
where: and(eq(schema.space.id, spaceId), eq(schema.space.tenantId, currentTenant())),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { and, eq, inArray, isNotNull } from "drizzle-orm";
|
|
2
|
+
import { linkedAccount } from "../auth/account.js";
|
|
3
|
+
import { brokerCall } from "../broker/index.js";
|
|
4
|
+
import { MAIL_SENDERS, sendAsAccount, sendFromServer, serverSender, } from "../connectors/smtp.js";
|
|
5
|
+
import { connectorOfRow } from "../connectors/space-connections.js";
|
|
6
|
+
import { db, schema } from "../db/client.js";
|
|
7
|
+
import { env } from "../env.js";
|
|
8
|
+
import { managed, tenantMembers } from "../manage.js";
|
|
9
|
+
import { currentTenant } from "../tenants/tenant.js";
|
|
10
|
+
import { serverText } from "../texts.js";
|
|
11
|
+
import { isAdminRole } from "./access.js";
|
|
12
|
+
import { criticalOfSpace } from "./broker-bell.js";
|
|
13
|
+
import { anySeenSince } from "./seen.js";
|
|
14
|
+
/**
|
|
15
|
+
* The hourly mail to a space's admins (docs/plans/broker.md, "Notifications"): the broker's
|
|
16
|
+
* critical lines since the last mail, sent only where none of the admins was in the app
|
|
17
|
+
* meanwhile – they saw the bell then. Through the space's own mail connection where one signs in
|
|
18
|
+
* as the space, else from the server's address; where there is neither, nothing goes out. The
|
|
19
|
+
* space's `notify.mail` turns it off.
|
|
20
|
+
*/
|
|
21
|
+
const HOUR_MS = 3600_000;
|
|
22
|
+
/** How many lines one mail carries at most. */
|
|
23
|
+
const LINES = 50;
|
|
24
|
+
/** The tenant's owners and admins: what the Manage-App says; on a computer, the linked account. */
|
|
25
|
+
async function adminsOf() {
|
|
26
|
+
if (managed) {
|
|
27
|
+
const people = await tenantMembers(currentTenant());
|
|
28
|
+
return people.members
|
|
29
|
+
.filter((m) => isAdminRole(m.role) && m.email)
|
|
30
|
+
.map((m) => ({ userId: m.userId, email: m.email }));
|
|
31
|
+
}
|
|
32
|
+
const account = await linkedAccount();
|
|
33
|
+
return account?.email ? [{ userId: account.userId, email: account.email }] : [];
|
|
34
|
+
}
|
|
35
|
+
/** One line of the mail: when, who, what, which rule. */
|
|
36
|
+
function lineOf(row, lang) {
|
|
37
|
+
const at = row.at.toISOString().slice(11, 16);
|
|
38
|
+
const who = row.whoId ? `${row.whoKind} ${row.whoId}` : row.whoKind;
|
|
39
|
+
const kind = serverText(lang, `criticalKind.${row.criticalKind ?? "refused_write"}`);
|
|
40
|
+
const what = `${row.connectionId} · ${row.actionId}`;
|
|
41
|
+
return `${at} ${kind}: ${who} → ${what}${row.reason ? ` – ${row.reason}` : ""}`;
|
|
42
|
+
}
|
|
43
|
+
/** The mail for a space's lines. */
|
|
44
|
+
export function criticalMail(space, rows, to, lang) {
|
|
45
|
+
const shown = rows.slice(0, LINES);
|
|
46
|
+
const lines = shown.map((r) => `- ${lineOf(r, lang)}`).join("\n");
|
|
47
|
+
const more = rows.length > shown.length
|
|
48
|
+
? `\n${serverText(lang, "criticalMailMore", { count: rows.length - shown.length })}`
|
|
49
|
+
: "";
|
|
50
|
+
return {
|
|
51
|
+
to,
|
|
52
|
+
subject: serverText(lang, "criticalMailSubject", { space: space.name, count: rows.length }),
|
|
53
|
+
text: `${serverText(lang, "criticalMailIntro", { space: space.name })}\n\n${lines}${more}\n\n${serverText(lang, "criticalMailOutro", { url: `${env.publicUrl}/work/waiting` })}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The space's mail connection the mail goes through: signs in as the space, signed in, a mail sender. */
|
|
57
|
+
async function mailConnectionOf(spaceId) {
|
|
58
|
+
return db.query.spaceConnection.findFirst({
|
|
59
|
+
where: and(eq(schema.spaceConnection.spaceId, spaceId), eq(schema.spaceConnection.signIn, "space"), inArray(schema.spaceConnection.connectorId, [...MAIL_SENDERS]), isNotNull(schema.spaceConnection.secret)),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Sends through the space's mail connection, as the admins; else from the server's address. */
|
|
63
|
+
async function deliver(spaceId, message) {
|
|
64
|
+
const row = await mailConnectionOf(spaceId);
|
|
65
|
+
if (row) {
|
|
66
|
+
const sent = await brokerCall({
|
|
67
|
+
who: { kind: "admin" },
|
|
68
|
+
where: { spaceId },
|
|
69
|
+
connection: { kind: "space_connection", row, connector: await connectorOfRow(row) },
|
|
70
|
+
action: { id: "send_message", kind: "send" },
|
|
71
|
+
input: { to: message.to, subject: message.subject },
|
|
72
|
+
ctx: { approved: true, confirmed: true },
|
|
73
|
+
handler: (held) => sendAsAccount(held.connector, held.ctx, message),
|
|
74
|
+
}).catch((err) => {
|
|
75
|
+
console.warn(`[broker] the mail through ${row.name} failed:`, err.message);
|
|
76
|
+
return null;
|
|
77
|
+
});
|
|
78
|
+
if (sent?.ok) {
|
|
79
|
+
return "connection";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (serverSender()) {
|
|
83
|
+
await sendFromServer(message);
|
|
84
|
+
return "server";
|
|
85
|
+
}
|
|
86
|
+
return "nobody";
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* One round for the current tenant: each space with the mail on, its lines since the last round,
|
|
90
|
+
* the mail where no admin was here since. A round sets the space's mark whether it mailed or
|
|
91
|
+
* skipped, so the next one starts there.
|
|
92
|
+
*/
|
|
93
|
+
export async function sendCriticalMails(now = new Date()) {
|
|
94
|
+
const round = { sent: [], skipped: [] };
|
|
95
|
+
const spaces = await db.query.space.findMany({
|
|
96
|
+
where: eq(schema.space.tenantId, currentTenant()),
|
|
97
|
+
columns: { id: true, name: true, notify: true, criticalMailedAt: true, page: true },
|
|
98
|
+
});
|
|
99
|
+
let admins = null;
|
|
100
|
+
for (const space of spaces) {
|
|
101
|
+
if (space.notify.mail !== "hourly") {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const since = space.criticalMailedAt ?? new Date(now.getTime() - HOUR_MS);
|
|
105
|
+
const rows = (await criticalOfSpace(space.id, since)).filter((r) => r.at <= now);
|
|
106
|
+
if (!rows.length) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
admins ??= await adminsOf().catch(() => []);
|
|
110
|
+
const mark = () => db.update(schema.space).set({ criticalMailedAt: now }).where(eq(schema.space.id, space.id));
|
|
111
|
+
if (!admins.length ||
|
|
112
|
+
(await anySeenSince(admins.map((a) => a.userId), since))) {
|
|
113
|
+
await mark();
|
|
114
|
+
round.skipped.push(space.id);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const lang = space.page?.lang === "de" ? "de" : "en";
|
|
118
|
+
const message = criticalMail(space, rows, admins.map((a) => a.email), lang);
|
|
119
|
+
const via = await deliver(space.id, message).catch((err) => {
|
|
120
|
+
console.warn(`[broker] the hourly mail for ${space.name} was not sent:`, err.message);
|
|
121
|
+
return "nobody";
|
|
122
|
+
});
|
|
123
|
+
await mark();
|
|
124
|
+
(via === "nobody" ? round.skipped : round.sent).push(space.id);
|
|
125
|
+
}
|
|
126
|
+
return round;
|
|
127
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
2
|
+
export class ClientSteps {
|
|
3
|
+
list = [];
|
|
4
|
+
listeners = new Set();
|
|
5
|
+
on(listener) {
|
|
6
|
+
this.listeners.add(listener);
|
|
7
|
+
return () => this.listeners.delete(listener);
|
|
8
|
+
}
|
|
9
|
+
tell(step) {
|
|
10
|
+
for (const listener of this.listeners) {
|
|
11
|
+
listener(step);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** The tools with each call recorded; tools the provider runs itself stay as they are. */
|
|
15
|
+
wrap(tools) {
|
|
16
|
+
return Object.fromEntries(Object.entries(tools).map(([name, tool]) => {
|
|
17
|
+
const t = tool;
|
|
18
|
+
if (typeof t?.execute !== "function") {
|
|
19
|
+
return [name, tool];
|
|
20
|
+
}
|
|
21
|
+
const execute = t.execute.bind(t);
|
|
22
|
+
return [
|
|
23
|
+
name,
|
|
24
|
+
Object.assign(Object.create(Object.getPrototypeOf(t)), t, {
|
|
25
|
+
execute: async (input, context) => {
|
|
26
|
+
const step = {
|
|
27
|
+
toolCallId: `client-${nanoid(10)}`,
|
|
28
|
+
toolName: name,
|
|
29
|
+
input,
|
|
30
|
+
state: "running",
|
|
31
|
+
};
|
|
32
|
+
this.list.push(step);
|
|
33
|
+
this.tell(step);
|
|
34
|
+
try {
|
|
35
|
+
step.output = await execute(input, context);
|
|
36
|
+
step.state = "done";
|
|
37
|
+
return step.output;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
step.state = "failed";
|
|
41
|
+
step.errorText = err instanceof Error ? err.message : String(err);
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
this.tell(step);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
];
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** A step as a chunk of the AI SDK's UI message stream. */
|
|
54
|
+
export function stepChunk(step) {
|
|
55
|
+
if (step.state === "running") {
|
|
56
|
+
return {
|
|
57
|
+
type: "tool-input-available",
|
|
58
|
+
toolCallId: step.toolCallId,
|
|
59
|
+
toolName: step.toolName,
|
|
60
|
+
input: step.input,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return step.state === "done"
|
|
64
|
+
? { type: "tool-output-available", toolCallId: step.toolCallId, output: step.output }
|
|
65
|
+
: { type: "tool-output-error", toolCallId: step.toolCallId, errorText: step.errorText ?? "" };
|
|
66
|
+
}
|
|
67
|
+
/** The steps as the parts of a stored message (Mastra's format, which the chat converts). */
|
|
68
|
+
export function stepParts(steps) {
|
|
69
|
+
return steps.map((step) => ({
|
|
70
|
+
type: "tool-invocation",
|
|
71
|
+
toolInvocation: {
|
|
72
|
+
state: "result",
|
|
73
|
+
toolCallId: step.toolCallId,
|
|
74
|
+
toolName: step.toolName,
|
|
75
|
+
args: step.input,
|
|
76
|
+
result: step.state === "failed" ? { error: step.errorText ?? "" } : (step.output ?? null),
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
@@ -11,8 +11,8 @@ import { forgetTwoWay, publishInCloud, refuseOtherOrganization, rotateInCloudSpa
|
|
|
11
11
|
import { currentTenant } from "../tenants/tenant.js";
|
|
12
12
|
import { mainLogoId } from "./brand.js";
|
|
13
13
|
import { ServiceError } from "./errors.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { spaceFileContent, spaceFiles } from "./space-files.js";
|
|
15
|
+
import { ownedSpace } from "./spaces.js";
|
|
16
16
|
import { themesOf } from "./themes.js";
|
|
17
17
|
import { ownedWizard, publishedVersion, publishWizard } from "./wizards.js";
|
|
18
18
|
const key = (wizardId) => `cloud:${wizardId}`;
|
|
@@ -75,19 +75,19 @@ function nextTry(tries, from) {
|
|
|
75
75
|
const minutes = Math.min(60, 2 ** (tries - 1));
|
|
76
76
|
return new Date(from.getTime() + minutes * 60_000).toISOString();
|
|
77
77
|
}
|
|
78
|
-
/** The
|
|
79
|
-
async function spaceOf(userId,
|
|
80
|
-
const
|
|
81
|
-
const logoId = await mainLogoId(
|
|
82
|
-
const logo = logoId ? await
|
|
78
|
+
/** The space as the cloud keeps it: its name, what it says about itself, its logo. */
|
|
79
|
+
async function spaceOf(userId, spaceId) {
|
|
80
|
+
const space = await ownedSpace(userId, spaceId);
|
|
81
|
+
const logoId = await mainLogoId(space.id);
|
|
82
|
+
const logo = logoId ? await spaceFileContent(space.id, logoId).catch(() => null) : null;
|
|
83
83
|
return {
|
|
84
|
-
name:
|
|
84
|
+
name: space.name,
|
|
85
85
|
brand: {
|
|
86
|
-
name:
|
|
87
|
-
about:
|
|
88
|
-
colors:
|
|
86
|
+
name: space.brand.name,
|
|
87
|
+
about: space.brand.about,
|
|
88
|
+
colors: space.brand.colors,
|
|
89
89
|
},
|
|
90
|
-
facts:
|
|
90
|
+
facts: space.facts,
|
|
91
91
|
logo: logo
|
|
92
92
|
? {
|
|
93
93
|
name: logo.row.name,
|
|
@@ -99,8 +99,8 @@ async function spaceOf(userId, projectId) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
/** The space's own tables and pages, as they are sent: not what a wizard's runs keep. */
|
|
102
|
-
async function spaceDataOf(
|
|
103
|
-
const own = (table) => and(eq(table.
|
|
102
|
+
async function spaceDataOf(spaceId) {
|
|
103
|
+
const own = (table) => and(eq(table.spaceId, spaceId), isNull(table.wizardId));
|
|
104
104
|
const tables = await db.query.spaceTable.findMany({
|
|
105
105
|
where: own(schema.spaceTable),
|
|
106
106
|
orderBy: [asc(schema.spaceTable.id)],
|
|
@@ -116,7 +116,7 @@ async function spaceDataOf(projectId) {
|
|
|
116
116
|
orderBy: [asc(schema.spacePage.id)],
|
|
117
117
|
});
|
|
118
118
|
const categories = await db.query.spaceCategory.findMany({
|
|
119
|
-
where: and(eq(schema.spaceCategory.
|
|
119
|
+
where: and(eq(schema.spaceCategory.spaceId, spaceId), eq(schema.spaceCategory.proposed, false)),
|
|
120
120
|
orderBy: [asc(schema.spaceCategory.position), asc(schema.spaceCategory.id)],
|
|
121
121
|
});
|
|
122
122
|
const values = categories.length
|
|
@@ -127,7 +127,7 @@ async function spaceDataOf(projectId) {
|
|
|
127
127
|
: [];
|
|
128
128
|
const assignments = categories.length
|
|
129
129
|
? await db.query.spaceItemCategory.findMany({
|
|
130
|
-
where: and(eq(schema.spaceItemCategory.
|
|
130
|
+
where: and(eq(schema.spaceItemCategory.spaceId, spaceId), isNull(schema.spaceItemCategory.fileId)),
|
|
131
131
|
orderBy: [asc(schema.spaceItemCategory.id)],
|
|
132
132
|
})
|
|
133
133
|
: [];
|
|
@@ -187,15 +187,15 @@ async function spaceDataOf(projectId) {
|
|
|
187
187
|
* Sends the space's own tables and pages along with a wizard, when they changed since they last
|
|
188
188
|
* arrived. A sending that fails is tried with the next wizard; the wizard is there either way.
|
|
189
189
|
*/
|
|
190
|
-
async function syncSpaceDataToCloud(
|
|
191
|
-
const data = await spaceDataOf(
|
|
190
|
+
async function syncSpaceDataToCloud(spaceId) {
|
|
191
|
+
const data = await spaceDataOf(spaceId);
|
|
192
192
|
const hash = createHash("sha256").update(JSON.stringify(data)).digest("hex");
|
|
193
|
-
const sent = `cloud-data:${
|
|
193
|
+
const sent = `cloud-data:${spaceId}`;
|
|
194
194
|
if ((await readSetting(sent)) === hash) {
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
197
|
try {
|
|
198
|
-
const answer = await call("PUT", `/spaces/${
|
|
198
|
+
const answer = await call("PUT", `/spaces/${spaceId}/data`, data, 120_000);
|
|
199
199
|
if (answer.ok) {
|
|
200
200
|
await writeSetting(sent, hash);
|
|
201
201
|
}
|
|
@@ -219,13 +219,13 @@ export async function syncToCloud(userId, wizardId) {
|
|
|
219
219
|
throw new ServiceError("refused", note("publishWizardFirst"));
|
|
220
220
|
}
|
|
221
221
|
const before = await cloudState(w.id);
|
|
222
|
-
const twoWay = await spaceSyncs(w.
|
|
222
|
+
const twoWay = await spaceSyncs(w.spaceId);
|
|
223
223
|
try {
|
|
224
224
|
// A space of the organization the account was signed in to before stays out of this one.
|
|
225
|
-
await refuseOtherOrganization(w.
|
|
225
|
+
await refuseOtherOrganization(w.spaceId);
|
|
226
226
|
if (twoWay) {
|
|
227
227
|
// The space syncs both ways: its draft goes up with the space, then the cloud publishes it.
|
|
228
|
-
const published = await publishInCloud(w.
|
|
228
|
+
const published = await publishInCloud(w.spaceId, w.id);
|
|
229
229
|
const state = {
|
|
230
230
|
copy: {
|
|
231
231
|
shareUrl: published.shareUrl,
|
|
@@ -246,14 +246,14 @@ export async function syncToCloud(userId, wizardId) {
|
|
|
246
246
|
mime: f.mime,
|
|
247
247
|
data: (await getBlob(f.hash)).toString("base64"),
|
|
248
248
|
})));
|
|
249
|
-
const answer = await call("PUT", `/spaces/${w.
|
|
250
|
-
space: await spaceOf(userId, w.
|
|
249
|
+
const answer = await call("PUT", `/spaces/${w.spaceId}/wizards/${w.id}`, {
|
|
250
|
+
space: await spaceOf(userId, w.spaceId),
|
|
251
251
|
version: version.version,
|
|
252
252
|
definition: version.definition,
|
|
253
253
|
files,
|
|
254
254
|
shareEnabled: w.shareEnabled,
|
|
255
255
|
dailyRunLimit: w.dailyRunLimit,
|
|
256
|
-
themes: themesOf(version.definition.themes, (await
|
|
256
|
+
themes: themesOf(version.definition.themes, (await ownedSpace(userId, w.spaceId)).themes),
|
|
257
257
|
}, 120_000);
|
|
258
258
|
if (!answer.ok || !answer.body.shareUrl) {
|
|
259
259
|
throw refusal(answer, "The cloud did not take the wizard.");
|
|
@@ -271,7 +271,7 @@ export async function syncToCloud(userId, wizardId) {
|
|
|
271
271
|
error: null,
|
|
272
272
|
};
|
|
273
273
|
await writeSetting(key(w.id), state);
|
|
274
|
-
await syncSpaceDataToCloud(w.
|
|
274
|
+
await syncSpaceDataToCloud(w.spaceId);
|
|
275
275
|
return state;
|
|
276
276
|
}
|
|
277
277
|
catch (err) {
|
|
@@ -310,7 +310,7 @@ export async function pushSharing(userId, wizardId) {
|
|
|
310
310
|
}
|
|
311
311
|
// A space that syncs both ways takes the settings along with the wizard.
|
|
312
312
|
const own = await ownedWizard(userId, wizardId).catch(() => null);
|
|
313
|
-
if (own && (await spaceSyncs(own.
|
|
313
|
+
if (own && (await spaceSyncs(own.spaceId))) {
|
|
314
314
|
return;
|
|
315
315
|
}
|
|
316
316
|
const state = await cloudState(wizardId);
|
|
@@ -318,7 +318,7 @@ export async function pushSharing(userId, wizardId) {
|
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
320
|
const w = await ownedWizard(userId, wizardId);
|
|
321
|
-
await call("PATCH", `/spaces/${w.
|
|
321
|
+
await call("PATCH", `/spaces/${w.spaceId}/wizards/${w.id}`, {
|
|
322
322
|
shareEnabled: w.shareEnabled,
|
|
323
323
|
dailyRunLimit: w.dailyRunLimit,
|
|
324
324
|
translate: w.translate,
|
|
@@ -339,11 +339,11 @@ export async function rotateInCloud(userId, wizardId) {
|
|
|
339
339
|
}
|
|
340
340
|
const w = await ownedWizard(userId, wizardId);
|
|
341
341
|
let link;
|
|
342
|
-
if (await spaceSyncs(w.
|
|
343
|
-
link = await rotateInCloudSpace(w.
|
|
342
|
+
if (await spaceSyncs(w.spaceId)) {
|
|
343
|
+
link = await rotateInCloudSpace(w.spaceId, w.id);
|
|
344
344
|
}
|
|
345
345
|
else {
|
|
346
|
-
const answer = await call("POST", `/spaces/${w.
|
|
346
|
+
const answer = await call("POST", `/spaces/${w.spaceId}/wizards/${w.id}/rotate-link`);
|
|
347
347
|
if (!answer.ok || !answer.body.shareUrl) {
|
|
348
348
|
throw refusal(answer, "The link in the cloud could not be renewed.");
|
|
349
349
|
}
|
|
@@ -365,10 +365,10 @@ export async function removeFromCloud(userId, wizardId) {
|
|
|
365
365
|
const w = await ownedWizard(userId, wizardId).catch(() => null);
|
|
366
366
|
await deleteSetting(key(wizardId));
|
|
367
367
|
// A space that syncs both ways deletes the copy with the next push.
|
|
368
|
-
if (!w || !state.copy || !(await cloudLinked()) || (await spaceSyncs(w.
|
|
368
|
+
if (!w || !state.copy || !(await cloudLinked()) || (await spaceSyncs(w.spaceId))) {
|
|
369
369
|
return;
|
|
370
370
|
}
|
|
371
|
-
await call("DELETE", `/spaces/${w.
|
|
371
|
+
await call("DELETE", `/spaces/${w.spaceId}/wizards/${w.id}`).catch((err) => console.error("[cloud] copy not removed:", err.message));
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* Sends again what did not arrive and is due for another try. Called every minute by the
|
|
@@ -418,9 +418,9 @@ export async function syncAllToCloud(userId) {
|
|
|
418
418
|
const owners = await spaceOrganizations();
|
|
419
419
|
const account = await linkedAccount();
|
|
420
420
|
const wizards = (await db
|
|
421
|
-
.select({ id: schema.wizard.id,
|
|
421
|
+
.select({ id: schema.wizard.id, spaceId: schema.wizard.spaceId })
|
|
422
422
|
.from(schema.wizard)
|
|
423
|
-
.where(and(eq(schema.wizard.tenantId, currentTenant()), isNotNull(schema.wizard.publishedVersion)))).filter((w) => !owners[w.
|
|
423
|
+
.where(and(eq(schema.wizard.tenantId, currentTenant()), isNotNull(schema.wizard.publishedVersion)))).filter((w) => !owners[w.spaceId] || owners[w.spaceId].id === account?.tenantId);
|
|
424
424
|
let sent = 0;
|
|
425
425
|
let failed = 0;
|
|
426
426
|
for (const [i, { id }] of wizards.entries()) {
|
|
@@ -460,13 +460,13 @@ export async function checkForCloud(userId, wizardId) {
|
|
|
460
460
|
if (!answer.ok) {
|
|
461
461
|
throw refusal(answer, "The cloud did not answer.");
|
|
462
462
|
}
|
|
463
|
-
const documents = await
|
|
463
|
+
const documents = await spaceFiles(w.spaceId, "document");
|
|
464
464
|
return {
|
|
465
465
|
problems: answer.body.problems ?? [],
|
|
466
466
|
documents: documents.length > 0 && w.draft.steps.some((s) => s.type === "agent"),
|
|
467
467
|
};
|
|
468
468
|
}
|
|
469
|
-
/** The
|
|
469
|
+
/** The spaces the account's cloud holds of local installs: this one's, or another machine's. */
|
|
470
470
|
export async function cloudSpaces() {
|
|
471
471
|
const answer = await call("GET", "/spaces");
|
|
472
472
|
if (!answer.ok) {
|
|
@@ -475,15 +475,15 @@ export async function cloudSpaces() {
|
|
|
475
475
|
return answer.body.spaces ?? [];
|
|
476
476
|
}
|
|
477
477
|
/**
|
|
478
|
-
* Makes room for this install's
|
|
478
|
+
* Makes room for this install's space: the spaces of other installs go from the cloud, with
|
|
479
479
|
* their links, then everything published here is sent. For the person who moved to a new
|
|
480
480
|
* machine or installed anew.
|
|
481
481
|
*/
|
|
482
482
|
export async function replaceCloudSpaces(userId) {
|
|
483
483
|
const mine = new Set((await db
|
|
484
|
-
.select({ id: schema.
|
|
485
|
-
.from(schema.
|
|
486
|
-
.where(eq(schema.
|
|
484
|
+
.select({ id: schema.space.id })
|
|
485
|
+
.from(schema.space)
|
|
486
|
+
.where(eq(schema.space.tenantId, currentTenant()))).map((p) => p.id));
|
|
487
487
|
for (const space of await cloudSpaces()) {
|
|
488
488
|
if (!mine.has(space.id)) {
|
|
489
489
|
const answer = await call("DELETE", `/spaces/${space.id}`);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a shell command on the space's computer may run without asking (docs/plans/work-chats.md,
|
|
3
|
+
* "The space's computer and browser"): what stays in the container runs; what sends data out,
|
|
4
|
+
* deletes or moves the space's files, or can't be read asks; what is unclear goes to a classifier
|
|
5
|
+
* that fails closed (asks). The space's computer (piece 5) calls it before each command.
|
|
6
|
+
*/
|
|
7
|
+
/** Where the space's own files are mounted in the computer. */
|
|
8
|
+
const SPACE_PATHS = ["/space", "/files"];
|
|
9
|
+
const rules = [
|
|
10
|
+
// Can't be read before it runs: what it does is decided while it runs.
|
|
11
|
+
{
|
|
12
|
+
why: "runs code it builds while it runs",
|
|
13
|
+
test: /\beval\b|`|\$\(|\|\s*(ba|z|da)?sh\b|\bsource\s+<\(/,
|
|
14
|
+
},
|
|
15
|
+
// Sends data out of the computer.
|
|
16
|
+
{
|
|
17
|
+
why: "pushes to a remote",
|
|
18
|
+
test: /\bgit\s+push\b|\b(npm|pnpm|yarn)\s+publish\b|\bdocker\s+push\b/,
|
|
19
|
+
},
|
|
20
|
+
{ why: "connects to another computer", test: /\b(ssh|scp|sftp|rsync|ftp|telnet|nc|ncat)\b/ },
|
|
21
|
+
{ why: "sends mail", test: /\b(mail|mailx|sendmail|mutt)\b/ },
|
|
22
|
+
{
|
|
23
|
+
why: "sends data to a web address",
|
|
24
|
+
test: /\bcurl\b[^|;&]*(\s-(d|F|T)\b|\s--(data|data-\w+|form|upload-file|json)\b|\s-X\s*(POST|PUT|PATCH|DELETE)\b)|\bwget\b[^|;&]*--(post|body|method)/i,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
const touchesSpace = (command) => SPACE_PATHS.some((path) => new RegExp(`(^|[\\s='"])${path.replace("/", "\\/")}(\\/|\\s|$|['"])`).test(command));
|
|
28
|
+
export function classifyCommand(command) {
|
|
29
|
+
const line = command.trim();
|
|
30
|
+
if (!line) {
|
|
31
|
+
return { verdict: "runs" };
|
|
32
|
+
}
|
|
33
|
+
for (const rule of rules) {
|
|
34
|
+
if (rule.test.test(line)) {
|
|
35
|
+
return { verdict: "asks", why: rule.why };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (touchesSpace(line)) {
|
|
39
|
+
if (/(^|[;&|]\s*)(rm|rmdir|mv|truncate|shred|unlink)\b/.test(line) ||
|
|
40
|
+
/\bfind\b.*\s-delete\b/.test(line)) {
|
|
41
|
+
return { verdict: "asks", why: "deletes or moves the space's files" };
|
|
42
|
+
}
|
|
43
|
+
// Writing into the space's files by redirect or copy: not plainly harmless, not plainly not.
|
|
44
|
+
if (/>\s*['"]?\/(space|files)\b|\b(cp|tee|sed\s+-i|dd)\b/.test(line)) {
|
|
45
|
+
return { verdict: "unclear", why: "writes into the space's files" };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { verdict: "runs" };
|
|
49
|
+
}
|
|
50
|
+
/** What happens with a command: an unclear one is asked about until a classifier says otherwise. */
|
|
51
|
+
export const asksBeforeRunning = (risk) => risk.verdict !== "runs";
|