@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
|
@@ -4,9 +4,10 @@ import { ASSISTANT_LAYOUTS, ASSISTANT_PAGE_BYTES, ASSISTANT_WIDTH, assistantSign
|
|
|
4
4
|
import { LANGS, MODEL_CLASSES, TEXT_CLASSES, } from "@engenty/wizards-shared/definition";
|
|
5
5
|
import { CATEGORY_TYPES, whereSchema } from "@engenty/wizards-shared/knowledge";
|
|
6
6
|
import { PRESENCE_KINDS } from "@engenty/wizards-shared/live";
|
|
7
|
-
import { PROJECT_FILE_KINDS } from "@engenty/wizards-shared/projects";
|
|
8
7
|
import { CLASS_NAMES, isCreditsRef, modelLabel } from "@engenty/wizards-shared/providers";
|
|
9
8
|
import { note } from "@engenty/wizards-shared/run";
|
|
9
|
+
import { SPACE_FILE_KINDS } from "@engenty/wizards-shared/spaces";
|
|
10
|
+
import { MAX_MASK_LABEL_CHARS, MAX_MASK_LABELS, modelPolicySchema, } from "@engenty/wizards-shared/tiers";
|
|
10
11
|
import { PACKAGE_EXTENSION, PACKAGE_MAX_BYTES, PACKAGE_MIME, } from "@engenty/wizards-shared/wizard-package";
|
|
11
12
|
import { generateText } from "ai";
|
|
12
13
|
import { Hono } from "hono";
|
|
@@ -20,6 +21,7 @@ import { answerBrowser, awaitBrowser } from "../assistant/browser.js";
|
|
|
20
21
|
import { endRun, signalRun, startRun, takeSignals } from "../assistant/runs.js";
|
|
21
22
|
import { accountOverview, linkedAccount, startLink, unlink } from "../auth/account.js";
|
|
22
23
|
import { createLocalKey, deleteLocalKey, listLocalKeys } from "../auth/keys.js";
|
|
24
|
+
import { assertRwx, subjectsOfPerson } from "../broker/rwx.js";
|
|
23
25
|
import { appStates, connectApps } from "../cli/connect.js";
|
|
24
26
|
import { layout } from "../cli/home.js";
|
|
25
27
|
import { connectorImportSchema, importConnector, previewSource, refreshConnector, registryService, removeConnector, searchRegistry, } from "../connectors/external.js";
|
|
@@ -34,17 +36,17 @@ import { detectHarness, detectHarnesses, HARNESS_IDS, harness, installSpec, } fr
|
|
|
34
36
|
import { closeTerminal, openTerminal, resizeTerminal, subscribeTerminal, writeTerminal, } from "../harness/terminal.js";
|
|
35
37
|
import { connectorsView, filesView, spacesView, translationsView, wizardsView, wizardView, } from "../live/views.js";
|
|
36
38
|
import { downloadLocalModel, localModels, removeLocalModel, startLocalOllama, } from "../local-models.js";
|
|
37
|
-
import { installMail, managed, renameTenant, saveOrganizationProfile, tenantInfo, tenantMembers, userInfo, } from "../manage.js";
|
|
38
|
-
import { seenApps } from "../mcp/seen.js";
|
|
39
|
+
import { installMail, ManageError, managed, renameTenant, saveModelPolicy, saveModelTier, saveOrganizationProfile, tenantInfo, tenantMembers, tryMasking, userInfo, } from "../manage.js";
|
|
40
|
+
import { checkedApps, seenApps } from "../mcp/seen.js";
|
|
39
41
|
import { generateImageMedia, generateSpeechMedia, generateVideoMedia } from "../media/generate.js";
|
|
40
42
|
import { transcribeAudio } from "../media/transcribe.js";
|
|
41
43
|
import { errorText, saidOf } from "../model-errors.js";
|
|
42
44
|
import { blockedBinding, CHAT_WAYS, checkKey, classProblem, classWays, DECISION_CHOICES, EMBEDDING_CHOICES, embeddingModel, hasTextModel, LOCAL_KEYS, localModelSettings, ModelUnavailableError, modelSettings, saveLocalModels, saveModels, setUpKey, setUpOllama, storedKey, textModel, } from "../models.js";
|
|
43
45
|
import { refreshPro } from "../plugins/pro.js";
|
|
44
46
|
import { HTML_RESPONSE_CSP } from "../render/guard.js";
|
|
45
|
-
import { isAdminRole, mayBuild, mayCreate,
|
|
47
|
+
import { isAdminRole, mayBuild, mayCreate, requireAdmin, requireWritable, spaceWritable, } from "../services/access.js";
|
|
46
48
|
import { architectTurn } from "../services/architect.js";
|
|
47
|
-
import { addMessage, assistantLayout, assistantWidth, currentChat, earlierChats, foldChat, newChat, openChat, readChat, turnHistory, } from "../services/assistant-chats.js";
|
|
49
|
+
import { addMessage, assistantLayout, assistantLayouts, assistantWidth, currentChat, earlierChats, foldChat, newChat, openChat, readChat, turnHistory, } from "../services/assistant-chats.js";
|
|
48
50
|
import { describeGradient, themeLooks } from "../services/brand.js";
|
|
49
51
|
import { chatCatalog, chatModelChoices, setChatModelChoice } from "../services/chat-models.js";
|
|
50
52
|
import { checkForCloud, cloudLinked, cloudSpaces, cloudState, forgetCloud, publishAndSync, pushSharing, removeFromCloud, replaceCloudSpaces, rotateInCloud, syncToCloud, } from "../services/cloud.js";
|
|
@@ -52,6 +54,7 @@ import { notFound, ServiceError } from "../services/errors.js";
|
|
|
52
54
|
import { deleteFile, listFiles, readFile, writeFile } from "../services/files.js";
|
|
53
55
|
import { categoryContents, listKnowledge, resolvePath, valueContents, } from "../services/knowledge.js";
|
|
54
56
|
import { writeSummary } from "../services/knowledge-model.js";
|
|
57
|
+
import { closedToMe } from "../services/members-studio.js";
|
|
55
58
|
import { applyAddresses, finishOnboarding, onboardingFor, startingName, } from "../services/onboarding.js";
|
|
56
59
|
import { findAddresses, siteOfEmail } from "../services/onboarding-find.js";
|
|
57
60
|
import { setOrganizationContext } from "../services/organization-context.js";
|
|
@@ -59,25 +62,25 @@ import { exportWizard, importWizard } from "../services/package.js";
|
|
|
59
62
|
import { pagePreview } from "../services/pages.js";
|
|
60
63
|
import { asAssistantIn, leave, markPresent, presentByItem, presentIn, } from "../services/presence.js";
|
|
61
64
|
import { profileSchema, saveProfile, saveUserLang, userLang, userProfile, } from "../services/profile.js";
|
|
62
|
-
import { addProjectFile, addProjectFileFromUrl, fileView, orderProjectFiles, projectFile, projectFileContent, reindexProjectFile, removeProjectFile, updateProjectFile, } from "../services/project-files.js";
|
|
63
|
-
import { documentText, queueIndex, reindexAll, searchKnowledge, } from "../services/project-index.js";
|
|
64
|
-
import { createProject, deleteProject, gradientSchema, ownedProject, projectLimitOrNull, projectPatchSchema, updateProject, } from "../services/projects.js";
|
|
65
65
|
import { runnersOf, wizardRunners } from "../services/runners.js";
|
|
66
66
|
import { draftStepView, listResults, listRuns, startTestRun } from "../services/runs.js";
|
|
67
67
|
import { addCategoryValue, categoryRow, categoryValue, deleteCategory, deleteCategoryValue, mergeCategoryValues, orderCategoryValues, putCategory, renameCategoryValue, setItemCategory, updateCategory, } from "../services/space-categories.js";
|
|
68
68
|
import { addTableRow, createPage, createTable, deletePage, deleteTable, deleteTableRows, getPage, getTable, listSpaceData, orderSubPages, updatePage, updateTable, updateTableRow, } from "../services/space-data.js";
|
|
69
|
+
import { addSpaceFile, addSpaceFileFromUrl, fileView, orderSpaceFiles, reindexSpaceFile, removeSpaceFile, spaceFile, spaceFileContent, updateSpaceFile, } from "../services/space-files.js";
|
|
70
|
+
import { documentText, queueIndex, reindexAll, searchKnowledge } from "../services/space-index.js";
|
|
71
|
+
import { createSpace, deleteSpace, gradientSchema, ownedSpace, spaceLimitOrNull, spacePatchSchema, updateSpace, } from "../services/spaces.js";
|
|
69
72
|
import { deleteTheme, listThemes, saveTheme } from "../services/themes.js";
|
|
70
73
|
import { deleteTranslation, editTranslation, isLangCode, publishedDefinition, } from "../services/translations.js";
|
|
71
74
|
import { draftWidgetPreview } from "../services/widgets.js";
|
|
72
75
|
import { createWizard, deleteWizard, draftChanges, duplicateWizard, hasWizards, ownedWizard, rotateShareLink, updateWizardSettings, writableWizard, writeDraft, } from "../services/wizards.js";
|
|
73
76
|
import { deleteSetting, readSetting, writeSetting } from "../settings.js";
|
|
74
|
-
import {
|
|
77
|
+
import { sharePreview, spaceShareTargets } from "../sharing/index.js";
|
|
75
78
|
import { keepCloudForAll, mergesSeen, proposeMerge, resolveConflict, sendBeforeSwitch, startSpace, stopSpace, syncAll, syncView, undoMerge, } from "../sync/client.js";
|
|
76
79
|
import { codeOf } from "../tenants/control.js";
|
|
77
80
|
import { currentTenant } from "../tenants/tenant.js";
|
|
78
81
|
import { serverText } from "../texts.js";
|
|
79
82
|
import { applyUpdate, updateStatus } from "../update.js";
|
|
80
|
-
import {
|
|
83
|
+
import { spaceFileResponse } from "./delivery.js";
|
|
81
84
|
import { notFoundAnswer, requestLang, say } from "./lang.js";
|
|
82
85
|
import { mayChangeRuntime } from "./runtime-settings.js";
|
|
83
86
|
const presenceSchema = z.object({
|
|
@@ -89,7 +92,13 @@ const presenceSchema = z.object({
|
|
|
89
92
|
placeLabel: z.string().max(120).nullish(),
|
|
90
93
|
});
|
|
91
94
|
/** Who reads, for the views the live stream sends too (live/views.ts). */
|
|
92
|
-
|
|
95
|
+
/** Who reads, for the broker (broker/rwx.ts): the signed-in person and their role. */
|
|
96
|
+
const whoOf = (c) => subjectsOfPerson(c.get("user").id, c.get("user").role);
|
|
97
|
+
const reader = (c) => ({
|
|
98
|
+
userId: c.get("user").id,
|
|
99
|
+
lang: requestLang(c),
|
|
100
|
+
who: whoOf(c),
|
|
101
|
+
});
|
|
93
102
|
/** The model sources a test call has worked on: the setup is done for those, not for the others. */
|
|
94
103
|
async function testedSources() {
|
|
95
104
|
const tested = await readSetting("setup-done");
|
|
@@ -125,6 +134,8 @@ const localModelName = z
|
|
|
125
134
|
.min(1)
|
|
126
135
|
.max(120)
|
|
127
136
|
.regex(/^[\w.:/-]+$/);
|
|
137
|
+
/** The Manage-App's masking errors, passed on as it sends them: 502 labels, 503 the detector. */
|
|
138
|
+
const MASKING_CODES = new Set(["labels_unavailable", "masking_unavailable"]);
|
|
128
139
|
const modelsInput = z.object({
|
|
129
140
|
source: z.enum([...HARNESS_IDS, "account", "own"]).optional(),
|
|
130
141
|
bindings: z.partialRecord(z.enum(MODEL_CLASSES), z.string().max(160)).optional(),
|
|
@@ -140,6 +151,11 @@ const modelsInput = z.object({
|
|
|
140
151
|
function mayChangeModels(user) {
|
|
141
152
|
return !managed || user.role === "owner" || user.role === "admin";
|
|
142
153
|
}
|
|
154
|
+
/** The model settings for the person who asks: the key hints only for those who change the keys. */
|
|
155
|
+
async function settingsFor(c) {
|
|
156
|
+
const settings = await modelSettings(requestLang(c));
|
|
157
|
+
return mayChangeModels(c.get("user")) ? settings : { ...settings, keyHints: {} };
|
|
158
|
+
}
|
|
143
159
|
/** A binding the cloud can run: a provider's model or the credits, no client, no local model. */
|
|
144
160
|
function cloudBinding(ref) {
|
|
145
161
|
return (isCreditsRef(ref) || /^(openai|anthropic|google|fal|elevenlabs|replicate|gateway):/.test(ref));
|
|
@@ -237,8 +253,8 @@ async function testClass(cls, lang) {
|
|
|
237
253
|
}
|
|
238
254
|
}
|
|
239
255
|
/** The size of an inline terminal, as the page lays it out. */
|
|
240
|
-
/** Whether the
|
|
241
|
-
async function assistantDevFor(user) {
|
|
256
|
+
/** Whether the developer mode (Goose's, a Work chat's) is offered to this person. */
|
|
257
|
+
export async function assistantDevFor(user) {
|
|
242
258
|
return managed ? (await userInfo(user.id)).admin : env.assistantDev;
|
|
243
259
|
}
|
|
244
260
|
const terminalSize = z.object({
|
|
@@ -352,13 +368,13 @@ export const studio = new Hono()
|
|
|
352
368
|
aiReady: (await hasTextModel()) || (!managed && (await subscriptionClients()).length > 0),
|
|
353
369
|
mcpUrl: `${env.appUrl}/api/mcp`,
|
|
354
370
|
/**
|
|
355
|
-
* One
|
|
371
|
+
* One space: the studio shows no space switcher; null: as many as wanted. `build:
|
|
356
372
|
* false`: nothing is made or changed here; the studio shows what the person's local
|
|
357
373
|
* install synced. `create`: the person makes and deletes here (builds, and is no mere
|
|
358
374
|
* member). `members`: the people the plan allows, null for no limit.
|
|
359
375
|
*/
|
|
360
376
|
limits: {
|
|
361
|
-
|
|
377
|
+
spaces: await spaceLimitOrNull(),
|
|
362
378
|
build: await mayBuild(),
|
|
363
379
|
create: await mayCreate(),
|
|
364
380
|
members: info?.limits.members ?? null,
|
|
@@ -421,6 +437,7 @@ export const studio = new Hono()
|
|
|
421
437
|
// Where the assistant stands, and the sidebar's width (null: the default); a PUT sends either.
|
|
422
438
|
.get("/assistant/layout", async (c) => c.json({
|
|
423
439
|
layout: await assistantLayout(c.get("user")),
|
|
440
|
+
layouts: await assistantLayouts(c.get("user")),
|
|
424
441
|
width: await assistantWidth(c.get("user")),
|
|
425
442
|
}))
|
|
426
443
|
.put("/assistant/layout", async (c) => {
|
|
@@ -428,6 +445,11 @@ export const studio = new Hono()
|
|
|
428
445
|
const body = z
|
|
429
446
|
.object({
|
|
430
447
|
layout: z.enum(ASSISTANT_LAYOUTS).optional(),
|
|
448
|
+
/** The studio's area the layout is for; without it the person's default. */
|
|
449
|
+
area: z
|
|
450
|
+
.string()
|
|
451
|
+
.regex(/^[a-z0-9-]{1,40}$/)
|
|
452
|
+
.optional(),
|
|
431
453
|
width: z
|
|
432
454
|
.number()
|
|
433
455
|
.int()
|
|
@@ -438,7 +460,13 @@ export const studio = new Hono()
|
|
|
438
460
|
})
|
|
439
461
|
.refine((b) => b.layout !== undefined || b.width !== undefined)
|
|
440
462
|
.parse(await c.req.json());
|
|
441
|
-
if (body.layout) {
|
|
463
|
+
if (body.layout && body.area) {
|
|
464
|
+
await writeSetting(`assistant-layouts:${user.tenantId}:${user.id}`, {
|
|
465
|
+
...(await assistantLayouts(user)),
|
|
466
|
+
[body.area]: body.layout,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
else if (body.layout) {
|
|
442
470
|
await writeSetting(`assistant-layout:${user.tenantId}:${user.id}`, body.layout);
|
|
443
471
|
}
|
|
444
472
|
if (body.width === null) {
|
|
@@ -447,7 +475,11 @@ export const studio = new Hono()
|
|
|
447
475
|
else if (body.width !== undefined) {
|
|
448
476
|
await writeSetting(`assistant-width:${user.tenantId}:${user.id}`, body.width);
|
|
449
477
|
}
|
|
450
|
-
return c.json({
|
|
478
|
+
return c.json({
|
|
479
|
+
layout: await assistantLayout(user),
|
|
480
|
+
layouts: await assistantLayouts(user),
|
|
481
|
+
width: await assistantWidth(user),
|
|
482
|
+
});
|
|
451
483
|
})
|
|
452
484
|
// Live chat reads answers aloud with the speech model where one is set up; else the browser's voices.
|
|
453
485
|
.get("/assistant/voice", async (c) => c.json({ way: (await classWays()).speech.kind }))
|
|
@@ -482,8 +514,10 @@ export const studio = new Hono()
|
|
|
482
514
|
if (!(await canSpend())) {
|
|
483
515
|
throw new ServiceError("no_credits", note("creditsUsedUp"));
|
|
484
516
|
}
|
|
485
|
-
|
|
486
|
-
const
|
|
517
|
+
// A space whose Studio is closed to a member is none of Goose's: no knowledge, skills or tools of it.
|
|
518
|
+
const opened = body.spaceId ? await ownedSpace(user.id, body.spaceId) : null;
|
|
519
|
+
const space = opened && !(await closedToMe(opened.id)) ? opened : null;
|
|
520
|
+
const writable = space ? await spaceWritable(space) : false;
|
|
487
521
|
// The page's snapshot is cut, not refused: a page that says too much still gets an answer.
|
|
488
522
|
const page = body.page && JSON.stringify(body.page).length > ASSISTANT_PAGE_BYTES
|
|
489
523
|
? { route: body.page.route, title: body.page.title, view: body.page.view }
|
|
@@ -536,10 +570,11 @@ export const studio = new Hono()
|
|
|
536
570
|
user,
|
|
537
571
|
chat,
|
|
538
572
|
history,
|
|
539
|
-
|
|
573
|
+
space,
|
|
540
574
|
writable,
|
|
541
575
|
message,
|
|
542
576
|
extra: body.extra,
|
|
577
|
+
model: body.model,
|
|
543
578
|
page,
|
|
544
579
|
browserTools: body.tools,
|
|
545
580
|
lang: body.lang,
|
|
@@ -601,39 +636,39 @@ export const studio = new Hono()
|
|
|
601
636
|
void foldChat(chat.id).catch((err) => console.error("[studio-assistant] fold:", err));
|
|
602
637
|
});
|
|
603
638
|
})
|
|
604
|
-
// ---
|
|
605
|
-
.get("/
|
|
606
|
-
.post("/
|
|
639
|
+
// --- spaces --------------------------------------------------------------
|
|
640
|
+
.get("/spaces", async (c) => c.json(await spacesView(reader(c))))
|
|
641
|
+
.post("/spaces", async (c) => {
|
|
607
642
|
const body = z.object({ name: z.string().min(1).max(80) }).parse(await c.req.json());
|
|
608
|
-
return c.json(await
|
|
643
|
+
return c.json(await createSpace(c.get("user").id, body.name));
|
|
609
644
|
})
|
|
610
|
-
.patch("/
|
|
611
|
-
const patch =
|
|
612
|
-
await
|
|
645
|
+
.patch("/spaces/:id", async (c) => {
|
|
646
|
+
const patch = spacePatchSchema.parse(await c.req.json());
|
|
647
|
+
await updateSpace(c.get("user").id, c.req.param("id"), patch);
|
|
613
648
|
return c.json({ ok: true });
|
|
614
649
|
})
|
|
615
650
|
// The organization's public page as Manage will draw it, for the preview beside the page's fields.
|
|
616
|
-
.get("/
|
|
617
|
-
await
|
|
651
|
+
.get("/spaces/:id/page", async (c) => {
|
|
652
|
+
await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
618
653
|
return c.json(await pagePreview());
|
|
619
654
|
})
|
|
620
655
|
// --- the space's themes: how its wizards' pages look (docs/plans/themes.md) ---
|
|
621
|
-
.get("/
|
|
622
|
-
.put("/
|
|
623
|
-
.delete("/
|
|
656
|
+
.get("/spaces/:id/themes", async (c) => c.json(await listThemes(c.get("user").id, c.req.param("id"))))
|
|
657
|
+
.put("/spaces/:id/themes", async (c) => c.json(await saveTheme(c.get("user").id, c.req.param("id"), await c.req.json())))
|
|
658
|
+
.delete("/spaces/:id/themes/:themeId{.+}", async (c) => {
|
|
624
659
|
await deleteTheme(c.get("user").id, c.req.param("id"), c.req.param("themeId"));
|
|
625
660
|
return c.json({ ok: true });
|
|
626
661
|
})
|
|
627
|
-
// --- what a
|
|
628
|
-
.get("/
|
|
629
|
-
.post("/
|
|
630
|
-
const
|
|
631
|
-
const kind = z.enum(
|
|
662
|
+
// --- what a space holds for all its wizards: logos, assets, documents -------
|
|
663
|
+
.get("/spaces/:id/files", async (c) => c.json(await filesView(reader(c), c.req.param("id"))))
|
|
664
|
+
.post("/spaces/:id/files", async (c) => {
|
|
665
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
666
|
+
const kind = z.enum(SPACE_FILE_KINDS).parse(c.req.query("kind"));
|
|
632
667
|
const file = (await c.req.formData()).get("file");
|
|
633
668
|
if (!(file instanceof File)) {
|
|
634
669
|
throw new ServiceError("invalid", note("chooseFile"));
|
|
635
670
|
}
|
|
636
|
-
const row = await
|
|
671
|
+
const row = await addSpaceFile(space.id, {
|
|
637
672
|
kind,
|
|
638
673
|
name: file.name,
|
|
639
674
|
mime: file.type.split(";")[0].trim().toLowerCase(),
|
|
@@ -641,14 +676,14 @@ export const studio = new Hono()
|
|
|
641
676
|
});
|
|
642
677
|
return c.json(fileView(row));
|
|
643
678
|
})
|
|
644
|
-
.post("/
|
|
645
|
-
const
|
|
679
|
+
.post("/spaces/:id/files/url", async (c) => {
|
|
680
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
646
681
|
const input = z
|
|
647
|
-
.object({ url: z.string().min(1).max(500_000), kind: z.enum(
|
|
682
|
+
.object({ url: z.string().min(1).max(500_000), kind: z.enum(SPACE_FILE_KINDS) })
|
|
648
683
|
.parse(await c.req.json());
|
|
649
684
|
const url = /^(https?:\/\/|data:)/i.test(input.url) ? input.url : `https://${input.url}`;
|
|
650
685
|
try {
|
|
651
|
-
return c.json({ file: fileView(await
|
|
686
|
+
return c.json({ file: fileView(await addSpaceFileFromUrl(space.id, { ...input, url })) });
|
|
652
687
|
}
|
|
653
688
|
catch (err) {
|
|
654
689
|
// A web page where a logo or an asset was asked for: its logos or pictures, to pick from.
|
|
@@ -660,8 +695,8 @@ export const studio = new Hono()
|
|
|
660
695
|
throw err;
|
|
661
696
|
}
|
|
662
697
|
})
|
|
663
|
-
.post("/
|
|
664
|
-
await
|
|
698
|
+
.post("/spaces/:id/colors/scan", async (c) => {
|
|
699
|
+
await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
665
700
|
const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
|
|
666
701
|
const colors = await scanColors(url).catch(() => {
|
|
667
702
|
throw new ServiceError("invalid", note("pageNotReached"));
|
|
@@ -669,8 +704,8 @@ export const studio = new Hono()
|
|
|
669
704
|
return c.json({ colors });
|
|
670
705
|
})
|
|
671
706
|
// A gradient from the admin's words, or theirs changed as they say. Nothing is saved.
|
|
672
|
-
.post("/
|
|
673
|
-
const
|
|
707
|
+
.post("/spaces/:id/gradients/describe", async (c) => {
|
|
708
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
674
709
|
const { text, gradient } = z
|
|
675
710
|
.object({
|
|
676
711
|
text: z.string().trim().min(1).max(1000),
|
|
@@ -684,7 +719,7 @@ export const studio = new Hono()
|
|
|
684
719
|
}
|
|
685
720
|
try {
|
|
686
721
|
return c.json({
|
|
687
|
-
gradient: await describeGradient(
|
|
722
|
+
gradient: await describeGradient(space.brand.colors ?? [], text, gradient),
|
|
688
723
|
});
|
|
689
724
|
}
|
|
690
725
|
catch (err) {
|
|
@@ -694,66 +729,48 @@ export const studio = new Hono()
|
|
|
694
729
|
throw err;
|
|
695
730
|
}
|
|
696
731
|
})
|
|
697
|
-
.post("/
|
|
698
|
-
await
|
|
732
|
+
.post("/spaces/:id/fonts/scan", async (c) => {
|
|
733
|
+
await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
699
734
|
const { url } = z.object({ url: z.string().min(1).max(2000) }).parse(await c.req.json());
|
|
700
735
|
const fonts = await scanFonts(url).catch(() => {
|
|
701
736
|
throw new ServiceError("invalid", note("pageNotReached"));
|
|
702
737
|
});
|
|
703
738
|
return c.json({ fonts });
|
|
704
739
|
})
|
|
705
|
-
.put("/
|
|
706
|
-
const
|
|
740
|
+
.put("/spaces/:id/files/order", async (c) => {
|
|
741
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
707
742
|
const body = z
|
|
708
|
-
.object({ kind: z.enum(
|
|
743
|
+
.object({ kind: z.enum(SPACE_FILE_KINDS), ids: z.array(z.string()).max(200) })
|
|
709
744
|
.parse(await c.req.json());
|
|
710
|
-
await
|
|
745
|
+
await orderSpaceFiles(space.id, body.kind, body.ids);
|
|
711
746
|
return c.json({ ok: true });
|
|
712
747
|
})
|
|
713
|
-
.patch("/
|
|
714
|
-
const
|
|
748
|
+
.patch("/spaces/:id/files/:fileId", async (c) => {
|
|
749
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
715
750
|
const patch = z
|
|
716
751
|
.object({ name: z.string().max(120).optional(), description: z.string().max(600).optional() })
|
|
717
752
|
.parse(await c.req.json());
|
|
718
|
-
return c.json(fileView(await
|
|
753
|
+
return c.json(fileView(await updateSpaceFile(space.id, c.req.param("fileId"), patch)));
|
|
719
754
|
})
|
|
720
|
-
.post("/
|
|
721
|
-
const
|
|
722
|
-
return c.json(fileView(await
|
|
755
|
+
.post("/spaces/:id/files/:fileId/reindex", async (c) => {
|
|
756
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
757
|
+
return c.json(fileView(await reindexSpaceFile(space.id, c.req.param("fileId"))));
|
|
723
758
|
})
|
|
724
|
-
.delete("/
|
|
725
|
-
const
|
|
726
|
-
await
|
|
759
|
+
.delete("/spaces/:id/files/:fileId", async (c) => {
|
|
760
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
761
|
+
await removeSpaceFile(space.id, c.req.param("fileId"));
|
|
727
762
|
return c.json({ ok: true });
|
|
728
763
|
})
|
|
729
|
-
.get("/
|
|
730
|
-
const
|
|
731
|
-
const { row, data } = await
|
|
732
|
-
|
|
733
|
-
"content-type": bareMime(row.mime) ?? "application/octet-stream",
|
|
734
|
-
"cache-control": "private, max-age=3600",
|
|
735
|
-
"x-content-type-options": "nosniff",
|
|
736
|
-
// An uploaded SVG or HTML file is shown, never run. A PDF is left to the browser's own
|
|
737
|
-
// viewer, which a sandbox would keep from starting.
|
|
738
|
-
...(row.mime === "application/pdf" ? {} : { "content-security-policy": "sandbox" }),
|
|
739
|
-
};
|
|
740
|
-
if (/^(audio|video)\//.test(row.mime)) {
|
|
741
|
-
headers["accept-ranges"] = "bytes";
|
|
742
|
-
const range = byteRange(c.req.header("range"), data.byteLength);
|
|
743
|
-
if (range === "unsatisfiable") {
|
|
744
|
-
return c.body(null, 416, { "content-range": `bytes */${data.byteLength}` });
|
|
745
|
-
}
|
|
746
|
-
if (range) {
|
|
747
|
-
headers["content-range"] = `bytes ${range.start}-${range.end}/${data.byteLength}`;
|
|
748
|
-
return c.body(new Uint8Array(data.subarray(range.start, range.end + 1)), 206, headers);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
return c.body(new Uint8Array(data), 200, headers);
|
|
764
|
+
.get("/spaces/:id/files/:fileId/content", async (c) => {
|
|
765
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
766
|
+
const { row, data } = await spaceFileContent(space.id, c.req.param("fileId"), whoOf(c));
|
|
767
|
+
return spaceFileResponse(c, row.mime, data);
|
|
752
768
|
})
|
|
753
769
|
// A document as the models read it: its text as Markdown, or the start of it.
|
|
754
|
-
.get("/
|
|
755
|
-
const
|
|
756
|
-
const row = await
|
|
770
|
+
.get("/spaces/:id/files/:fileId/text", async (c) => {
|
|
771
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
772
|
+
const row = await spaceFile(space.id, c.req.param("fileId"));
|
|
773
|
+
await assertRwx(space.id, whoOf(c), { kind: "document", id: row.id }, "r");
|
|
757
774
|
const limit = z.coerce
|
|
758
775
|
.number()
|
|
759
776
|
.int()
|
|
@@ -765,15 +782,15 @@ export const studio = new Hono()
|
|
|
765
782
|
return c.json({ text: text.slice(0, limit), chars: text.length });
|
|
766
783
|
})
|
|
767
784
|
// What a search of Knowledge finds for a question: the items an agent step would get.
|
|
768
|
-
.post("/
|
|
769
|
-
const
|
|
785
|
+
.post("/spaces/:id/search", async (c) => {
|
|
786
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
770
787
|
const body = z
|
|
771
788
|
.object({ query: z.string().min(1).max(400), where: whereSchema.optional() })
|
|
772
789
|
.parse(await c.req.json());
|
|
773
|
-
return c.json(await searchKnowledge(
|
|
790
|
+
return c.json(await searchKnowledge(space.id, body.query, { where: body.where, who: whoOf(c) }));
|
|
774
791
|
})
|
|
775
|
-
.delete("/
|
|
776
|
-
await
|
|
792
|
+
.delete("/spaces/:id", async (c) => {
|
|
793
|
+
await deleteSpace(c.get("user").id, c.req.param("id"));
|
|
777
794
|
return c.json({ ok: true });
|
|
778
795
|
})
|
|
779
796
|
// --- connectors: services imported from the integrations registry ------------
|
|
@@ -792,24 +809,24 @@ export const studio = new Hono()
|
|
|
792
809
|
.parse(await c.req.json());
|
|
793
810
|
return c.json(await previewSource(body));
|
|
794
811
|
})
|
|
795
|
-
.get("/
|
|
796
|
-
.post("/
|
|
812
|
+
.get("/spaces/:id/connectors", async (c) => c.json(await connectorsView(reader(c), c.req.param("id"))))
|
|
813
|
+
.post("/spaces/:id/connectors", async (c) => {
|
|
797
814
|
const user = c.get("user");
|
|
798
|
-
const
|
|
799
|
-
return c.json(await importConnector(user.id,
|
|
815
|
+
const space = await ownedSpace(user.id, c.req.param("id"));
|
|
816
|
+
return c.json(await importConnector(user.id, space.id, connectorImportSchema.parse(await c.req.json())));
|
|
800
817
|
})
|
|
801
|
-
.post("/
|
|
802
|
-
const
|
|
803
|
-
return c.json(await refreshConnector(
|
|
818
|
+
.post("/spaces/:id/connectors/:connectorId/refresh", async (c) => {
|
|
819
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
820
|
+
return c.json(await refreshConnector(space.id, c.req.param("connectorId"), null));
|
|
804
821
|
})
|
|
805
|
-
.delete("/
|
|
806
|
-
const
|
|
807
|
-
await removeConnector(
|
|
822
|
+
.delete("/spaces/:id/connectors/:connectorId", async (c) => {
|
|
823
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
824
|
+
await removeConnector(space.id, c.req.param("connectorId"));
|
|
808
825
|
return c.json({ ok: true });
|
|
809
826
|
})
|
|
810
827
|
// The runs of the space's wizards that reached their result: of one wizard, or of all.
|
|
811
|
-
.get("/
|
|
812
|
-
const
|
|
828
|
+
.get("/spaces/:id/results", async (c) => {
|
|
829
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
813
830
|
const query = z
|
|
814
831
|
.object({
|
|
815
832
|
wizard: z.string().optional(),
|
|
@@ -818,7 +835,7 @@ export const studio = new Hono()
|
|
|
818
835
|
days: z.coerce.number().int().min(1).max(3650).optional(),
|
|
819
836
|
})
|
|
820
837
|
.parse(c.req.query());
|
|
821
|
-
return c.json(await listResults(
|
|
838
|
+
return c.json(await listResults(space.id, {
|
|
822
839
|
wizardId: query.wizard || undefined,
|
|
823
840
|
q: query.q,
|
|
824
841
|
mode: query.mode,
|
|
@@ -826,19 +843,19 @@ export const studio = new Hono()
|
|
|
826
843
|
}));
|
|
827
844
|
})
|
|
828
845
|
// --- Knowledge: its items and categories ------------------------------------
|
|
829
|
-
.get("/
|
|
846
|
+
.get("/spaces/:id/knowledge", async (c) => c.json(await listKnowledge(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
830
847
|
// What a link in a page names (`pages/bgb/p-281`): the studio opens it.
|
|
831
|
-
.get("/
|
|
832
|
-
const
|
|
833
|
-
const found = await resolvePath(
|
|
848
|
+
.get("/spaces/:id/resolve", async (c) => {
|
|
849
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
850
|
+
const found = await resolvePath(space.id, z.string().max(600).parse(c.req.query("path")));
|
|
834
851
|
if (!found) {
|
|
835
852
|
throw notFound();
|
|
836
853
|
}
|
|
837
854
|
return c.json(found);
|
|
838
855
|
})
|
|
839
|
-
.post("/
|
|
840
|
-
const
|
|
841
|
-
await requireWritable(
|
|
856
|
+
.post("/spaces/:id/categories", async (c) => {
|
|
857
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
858
|
+
await requireWritable(space);
|
|
842
859
|
const body = z
|
|
843
860
|
.object({
|
|
844
861
|
name: z.string().min(1).max(80),
|
|
@@ -852,12 +869,12 @@ export const studio = new Hono()
|
|
|
852
869
|
columnId: z.string().nullish(),
|
|
853
870
|
})
|
|
854
871
|
.parse(await c.req.json());
|
|
855
|
-
const row = await putCategory(
|
|
872
|
+
const row = await putCategory(space.id, body);
|
|
856
873
|
return c.json({ id: row.id });
|
|
857
874
|
})
|
|
858
875
|
.patch("/categories/:id", async (c) => {
|
|
859
876
|
const row = await categoryRow(c.req.param("id"));
|
|
860
|
-
await
|
|
877
|
+
await ownedSpace(c.get("user").id, row.spaceId);
|
|
861
878
|
const body = z
|
|
862
879
|
.object({
|
|
863
880
|
name: z.string().min(1).max(80).optional(),
|
|
@@ -874,57 +891,57 @@ export const studio = new Hono()
|
|
|
874
891
|
})
|
|
875
892
|
.delete("/categories/:id", async (c) => {
|
|
876
893
|
const row = await categoryRow(c.req.param("id"));
|
|
877
|
-
await
|
|
894
|
+
await ownedSpace(c.get("user").id, row.spaceId);
|
|
878
895
|
await deleteCategory(row.id);
|
|
879
896
|
return c.json({ ok: true });
|
|
880
897
|
})
|
|
881
898
|
.post("/categories/:id/values", async (c) => {
|
|
882
899
|
const row = await categoryRow(c.req.param("id"));
|
|
883
|
-
await
|
|
900
|
+
await ownedSpace(c.get("user").id, row.spaceId);
|
|
884
901
|
const { value } = z.object({ value: z.string().min(1).max(200) }).parse(await c.req.json());
|
|
885
902
|
return c.json(await addCategoryValue(row.id, value));
|
|
886
903
|
})
|
|
887
904
|
.put("/categories/:id/values/order", async (c) => {
|
|
888
905
|
const row = await categoryRow(c.req.param("id"));
|
|
889
|
-
await
|
|
906
|
+
await ownedSpace(c.get("user").id, row.spaceId);
|
|
890
907
|
const { ids } = z.object({ ids: z.array(z.string()).max(500) }).parse(await c.req.json());
|
|
891
908
|
await orderCategoryValues(row.id, ids);
|
|
892
909
|
return c.json({ ok: true });
|
|
893
910
|
})
|
|
894
|
-
.get("/values/:id", async (c) => c.json(await valueContents(c.get("user").id, c.req.param("id"))))
|
|
911
|
+
.get("/values/:id", async (c) => c.json(await valueContents(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
895
912
|
// Everything that has a category: the entries its page lists.
|
|
896
|
-
.get("/categories/:id/items", async (c) => c.json(await categoryContents(c.get("user").id, c.req.param("id"))))
|
|
913
|
+
.get("/categories/:id/items", async (c) => c.json(await categoryContents(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
897
914
|
.patch("/values/:id", async (c) => {
|
|
898
915
|
const { category } = await categoryValue(c.req.param("id"));
|
|
899
|
-
await
|
|
916
|
+
await ownedSpace(c.get("user").id, category.spaceId);
|
|
900
917
|
const { value } = z.object({ value: z.string().min(1).max(200) }).parse(await c.req.json());
|
|
901
918
|
await renameCategoryValue(c.req.param("id"), value);
|
|
902
919
|
return c.json({ ok: true });
|
|
903
920
|
})
|
|
904
921
|
.post("/values/:id/merge", async (c) => {
|
|
905
922
|
const { category } = await categoryValue(c.req.param("id"));
|
|
906
|
-
await
|
|
923
|
+
await ownedSpace(c.get("user").id, category.spaceId);
|
|
907
924
|
const { into } = z.object({ into: z.string() }).parse(await c.req.json());
|
|
908
925
|
await mergeCategoryValues(c.req.param("id"), into);
|
|
909
926
|
return c.json({ ok: true });
|
|
910
927
|
})
|
|
911
928
|
.delete("/values/:id", async (c) => {
|
|
912
929
|
const { category } = await categoryValue(c.req.param("id"));
|
|
913
|
-
await
|
|
930
|
+
await ownedSpace(c.get("user").id, category.spaceId);
|
|
914
931
|
await deleteCategoryValue(c.req.param("id"));
|
|
915
932
|
return c.json({ ok: true });
|
|
916
933
|
})
|
|
917
934
|
// The summary of a value: a model writes it from the value's items.
|
|
918
935
|
.post("/values/:id/summary", async (c) => {
|
|
919
936
|
const { category } = await categoryValue(c.req.param("id"));
|
|
920
|
-
const
|
|
921
|
-
await requireWritable(
|
|
937
|
+
const space = await ownedSpace(c.get("user").id, category.spaceId);
|
|
938
|
+
await requireWritable(space);
|
|
922
939
|
return c.json({ summary: await writeSummary(c.req.param("id")) });
|
|
923
940
|
})
|
|
924
941
|
// A category a person sets on an item: `p:<page>`, `t:<table>`, `r:<row>`, `f:<file>`.
|
|
925
|
-
.put("/
|
|
926
|
-
const
|
|
927
|
-
await requireWritable(
|
|
942
|
+
.put("/spaces/:id/items/:key/categories/:categoryId", async (c) => {
|
|
943
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
944
|
+
await requireWritable(space);
|
|
928
945
|
const key = c.req.param("key");
|
|
929
946
|
const id = key.slice(2);
|
|
930
947
|
const ref = key[0] === "p"
|
|
@@ -942,14 +959,14 @@ export const studio = new Hono()
|
|
|
942
959
|
const { values } = z
|
|
943
960
|
.object({ values: z.array(z.union([z.string().max(300), z.number(), z.boolean()])).max(50) })
|
|
944
961
|
.parse(await c.req.json());
|
|
945
|
-
if (await setItemCategory(
|
|
962
|
+
if (await setItemCategory(space.id, ref, c.req.param("categoryId"), values)) {
|
|
946
963
|
queueIndex(key[0] === "p" ? `P:${id}` : key);
|
|
947
964
|
}
|
|
948
965
|
return c.json({ ok: true });
|
|
949
966
|
})
|
|
950
967
|
// --- the space's tables and pages --------------------------------------------
|
|
951
|
-
.get("/
|
|
952
|
-
.post("/
|
|
968
|
+
.get("/spaces/:id/data", async (c) => c.json(await listSpaceData(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
969
|
+
.post("/spaces/:id/tables", async (c) => {
|
|
953
970
|
const body = z
|
|
954
971
|
.object({
|
|
955
972
|
title: z.string().max(120),
|
|
@@ -960,7 +977,7 @@ export const studio = new Hono()
|
|
|
960
977
|
.parse(await c.req.json());
|
|
961
978
|
return c.json(await createTable(c.get("user").id, c.req.param("id"), body, requestLang(c)));
|
|
962
979
|
})
|
|
963
|
-
.get("/tables/:id", async (c) => c.json(await getTable(c.get("user").id, c.req.param("id"))))
|
|
980
|
+
.get("/tables/:id", async (c) => c.json(await getTable(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
964
981
|
.patch("/tables/:id", async (c) => {
|
|
965
982
|
const body = z
|
|
966
983
|
.object({
|
|
@@ -993,7 +1010,7 @@ export const studio = new Hono()
|
|
|
993
1010
|
await deleteTableRows(c.get("user").id, c.req.param("id"), body.ids);
|
|
994
1011
|
return c.json({ ok: true });
|
|
995
1012
|
})
|
|
996
|
-
.post("/
|
|
1013
|
+
.post("/spaces/:id/pages", async (c) => {
|
|
997
1014
|
const body = z
|
|
998
1015
|
.object({
|
|
999
1016
|
title: z.string().max(200),
|
|
@@ -1004,7 +1021,7 @@ export const studio = new Hono()
|
|
|
1004
1021
|
.parse(await c.req.json());
|
|
1005
1022
|
return c.json(await createPage(c.get("user").id, c.req.param("id"), body));
|
|
1006
1023
|
})
|
|
1007
|
-
.get("/pages/:id", async (c) => c.json(await getPage(c.get("user").id, c.req.param("id"))))
|
|
1024
|
+
.get("/pages/:id", async (c) => c.json(await getPage(c.get("user").id, c.req.param("id"), whoOf(c))))
|
|
1008
1025
|
.patch("/pages/:id", async (c) => {
|
|
1009
1026
|
const body = z
|
|
1010
1027
|
.object({
|
|
@@ -1028,11 +1045,11 @@ export const studio = new Hono()
|
|
|
1028
1045
|
return c.json({ ok: true });
|
|
1029
1046
|
})
|
|
1030
1047
|
// --- wizards ---------------------------------------------------------------
|
|
1031
|
-
.get("/
|
|
1048
|
+
.get("/spaces/:id/wizards", async (c) => c.json(await wizardsView(reader(c), c.req.param("id"))))
|
|
1032
1049
|
.post("/wizards", async (c) => {
|
|
1033
1050
|
const body = z
|
|
1034
1051
|
.object({
|
|
1035
|
-
|
|
1052
|
+
spaceId: z.string(),
|
|
1036
1053
|
starterId: z.string().optional(),
|
|
1037
1054
|
lang: z.string().optional(),
|
|
1038
1055
|
})
|
|
@@ -1041,7 +1058,7 @@ export const studio = new Hono()
|
|
|
1041
1058
|
return c.json({ id });
|
|
1042
1059
|
})
|
|
1043
1060
|
// A wizard as a file, and a new wizard made of such a file.
|
|
1044
|
-
.post("/
|
|
1061
|
+
.post("/spaces/:id/wizards/import", async (c) => {
|
|
1045
1062
|
const file = (await c.req.formData()).get("file");
|
|
1046
1063
|
if (!(file instanceof File) || !file.size || file.size > PACKAGE_MAX_BYTES) {
|
|
1047
1064
|
throw new ServiceError("invalid", note("chooseWizardFileMb", { PACKAGE_EXTENSION }));
|
|
@@ -1068,7 +1085,7 @@ export const studio = new Hono()
|
|
|
1068
1085
|
// The share targets a result of this wizard can name, for the editor.
|
|
1069
1086
|
.get("/wizards/:id/share-targets", async (c) => {
|
|
1070
1087
|
const w = await ownedWizard(c.get("user").id, c.req.param("id"));
|
|
1071
|
-
return c.json(await
|
|
1088
|
+
return c.json(await spaceShareTargets(w.spaceId, requestLang(c)));
|
|
1072
1089
|
})
|
|
1073
1090
|
// The draft's result page with its share sheet, for a visitor (`as=visitor`) or the owner.
|
|
1074
1091
|
.get("/wizards/:id/share-preview", async (c) => {
|
|
@@ -1089,7 +1106,8 @@ export const studio = new Hono()
|
|
|
1089
1106
|
.object({
|
|
1090
1107
|
shareEnabled: z.boolean().optional(),
|
|
1091
1108
|
dailyRunLimit: z.number().int().min(1).max(10_000).optional(),
|
|
1092
|
-
|
|
1109
|
+
dailyMailLimit: z.number().int().min(0).max(10_000).optional(),
|
|
1110
|
+
spaceId: z.string().optional(),
|
|
1093
1111
|
runners: z.object({ default: z.string(), enabled: z.array(z.string()).max(20) }).optional(),
|
|
1094
1112
|
translate: z.boolean().optional(),
|
|
1095
1113
|
})
|
|
@@ -1182,7 +1200,7 @@ export const studio = new Hono()
|
|
|
1182
1200
|
const linked = await cloudLinked();
|
|
1183
1201
|
return c.json({ linked, ...(linked ? await cloudState(w.id) : { copy: null, error: null }) });
|
|
1184
1202
|
})
|
|
1185
|
-
// Sends the published version again: after a try that failed, or a change of the
|
|
1203
|
+
// Sends the published version again: after a try that failed, or a change of the space.
|
|
1186
1204
|
.post("/wizards/:id/cloud", async (c) => {
|
|
1187
1205
|
if (!(await cloudLinked())) {
|
|
1188
1206
|
return c.notFound();
|
|
@@ -1265,14 +1283,14 @@ export const studio = new Hono()
|
|
|
1265
1283
|
await mergesSeen(ids);
|
|
1266
1284
|
return c.json({ ok: true });
|
|
1267
1285
|
})
|
|
1268
|
-
// The
|
|
1286
|
+
// The spaces of local installs the account's cloud holds.
|
|
1269
1287
|
.get("/cloud/spaces", async (c) => {
|
|
1270
1288
|
if (!(await cloudLinked())) {
|
|
1271
1289
|
return c.notFound();
|
|
1272
1290
|
}
|
|
1273
1291
|
return c.json({ spaces: await cloudSpaces() });
|
|
1274
1292
|
})
|
|
1275
|
-
// Another install's
|
|
1293
|
+
// Another install's space is in the way: it goes, and what is published here is sent.
|
|
1276
1294
|
.post("/cloud/replace", async (c) => {
|
|
1277
1295
|
if (!(await cloudLinked())) {
|
|
1278
1296
|
return c.notFound();
|
|
@@ -1353,7 +1371,7 @@ export const studio = new Hono()
|
|
|
1353
1371
|
// The looks of the themes the draft offers: what the test run's preview switches between.
|
|
1354
1372
|
.get("/wizards/:id/looks", async (c) => {
|
|
1355
1373
|
const w = await ownedWizard(c.get("user").id, c.req.param("id"));
|
|
1356
|
-
return c.json({ looks: await themeLooks(w.
|
|
1374
|
+
return c.json({ looks: await themeLooks(w.spaceId, w.draft.themes) });
|
|
1357
1375
|
})
|
|
1358
1376
|
// --- workspace -------------------------------------------------------------
|
|
1359
1377
|
.get("/wizards/:id/files", async (c) => c.json(await listFiles(c.get("user").id, c.req.param("id"))))
|
|
@@ -1415,6 +1433,15 @@ export const studio = new Hono()
|
|
|
1415
1433
|
})
|
|
1416
1434
|
// What each AI client did with the MCP server since the start: the test on "Integrate".
|
|
1417
1435
|
.get("/integrations/seen", (c) => c.json(seenApps(c.get("user").tenantId)))
|
|
1436
|
+
// The apps members used on the spaces, allowed or refused by the organization's model policy.
|
|
1437
|
+
// Who used which app is for the organization's owners and admins.
|
|
1438
|
+
.get("/model-policy/apps", (c) => {
|
|
1439
|
+
const user = c.get("user");
|
|
1440
|
+
if (!mayChangeModels(user)) {
|
|
1441
|
+
return c.json({ error: say(c, "onlyOrganizationAdminsChange"), code: "forbidden" }, 403);
|
|
1442
|
+
}
|
|
1443
|
+
return c.json({ apps: checkedApps(user.tenantId) });
|
|
1444
|
+
})
|
|
1418
1445
|
.get("/local/models", (c) => (managed ? c.notFound() : c.json(localModelSettings())))
|
|
1419
1446
|
.put("/local/models", async (c) => {
|
|
1420
1447
|
if (managed) {
|
|
@@ -1425,7 +1452,7 @@ export const studio = new Hono()
|
|
|
1425
1452
|
})
|
|
1426
1453
|
// --- models: where each class runs, own API keys, the credits behind them -----------------
|
|
1427
1454
|
// Alone for this machine; on a Manage-App's runtime for the organization, whose admins change it.
|
|
1428
|
-
.get("/models", async (c) => c.json(await
|
|
1455
|
+
.get("/models", async (c) => c.json(await settingsFor(c)))
|
|
1429
1456
|
.put("/models", async (c) => {
|
|
1430
1457
|
if (!mayChangeModels(c.get("user"))) {
|
|
1431
1458
|
return c.json({
|
|
@@ -1467,6 +1494,10 @@ export const studio = new Hono()
|
|
|
1467
1494
|
code: "plan",
|
|
1468
1495
|
}, 403);
|
|
1469
1496
|
}
|
|
1497
|
+
// The organization's admins may allow no own keys at all.
|
|
1498
|
+
if (feature("modelTiers", info.features) && info.modelPolicy?.ownKeys === false) {
|
|
1499
|
+
return c.json({ error: say(c, "ownKeysNotInPolicy"), code: "tier" }, 403);
|
|
1500
|
+
}
|
|
1470
1501
|
}
|
|
1471
1502
|
const blocked = input.bindings ? blockedBinding(input.bindings) : null;
|
|
1472
1503
|
if (blocked) {
|
|
@@ -1485,7 +1516,84 @@ export const studio = new Hono()
|
|
|
1485
1516
|
if (((await embeddingModel().catch(() => null))?.ref ?? null) !== embeddedBy) {
|
|
1486
1517
|
void reindexAll().catch((err) => console.error("[models] reindex failed", err));
|
|
1487
1518
|
}
|
|
1488
|
-
return c.json(await
|
|
1519
|
+
return c.json(await settingsFor(c));
|
|
1520
|
+
})
|
|
1521
|
+
// The organization's model policy (way A/B/C, the lists, where models may run), saved at the
|
|
1522
|
+
// Manage-App by its admins. Behind `modelTiers`.
|
|
1523
|
+
.put("/model-policy", async (c) => {
|
|
1524
|
+
const user = c.get("user");
|
|
1525
|
+
if (!managed || !mayChangeModels(user)) {
|
|
1526
|
+
return c.json({ error: say(c, "onlyOrganizationAdminsChange"), code: "forbidden" }, 403);
|
|
1527
|
+
}
|
|
1528
|
+
const info = await tenantInfo(user.tenantId).catch(() => null);
|
|
1529
|
+
if (!info) {
|
|
1530
|
+
return c.json({ error: say(c, "planUnavailable"), code: "manage_unavailable" }, 503);
|
|
1531
|
+
}
|
|
1532
|
+
if (!feature("modelTiers", info.features) || !info.tier) {
|
|
1533
|
+
return c.notFound();
|
|
1534
|
+
}
|
|
1535
|
+
// The Manage-App checks the policy against the plan and the tier, and keeps what its way uses.
|
|
1536
|
+
const policy = modelPolicySchema.parse(await c.req.json());
|
|
1537
|
+
try {
|
|
1538
|
+
await saveModelPolicy(user.tenantId, user.id, policy);
|
|
1539
|
+
}
|
|
1540
|
+
catch (err) {
|
|
1541
|
+
if (err instanceof ManageError && (err.status < 500 || MASKING_CODES.has(err.code))) {
|
|
1542
|
+
return c.json({ error: err.message, code: err.code }, err.status);
|
|
1543
|
+
}
|
|
1544
|
+
throw err;
|
|
1545
|
+
}
|
|
1546
|
+
return c.json(await settingsFor(c));
|
|
1547
|
+
})
|
|
1548
|
+
// The organization's tier, picked by its admins among those the plan offers. Behind `modelTiers`.
|
|
1549
|
+
.put("/model-tier", async (c) => {
|
|
1550
|
+
const user = c.get("user");
|
|
1551
|
+
if (!managed || !mayChangeModels(user)) {
|
|
1552
|
+
return c.json({ error: say(c, "onlyOrganizationAdminsChange"), code: "forbidden" }, 403);
|
|
1553
|
+
}
|
|
1554
|
+
const info = await tenantInfo(user.tenantId).catch(() => null);
|
|
1555
|
+
if (!info) {
|
|
1556
|
+
return c.json({ error: say(c, "planUnavailable"), code: "manage_unavailable" }, 503);
|
|
1557
|
+
}
|
|
1558
|
+
if (!feature("modelTiers", info.features) || !info.tier) {
|
|
1559
|
+
return c.notFound();
|
|
1560
|
+
}
|
|
1561
|
+
const { tier } = z.object({ tier: z.string().min(1).max(40) }).parse(await c.req.json());
|
|
1562
|
+
try {
|
|
1563
|
+
await saveModelTier(user.tenantId, user.id, tier);
|
|
1564
|
+
}
|
|
1565
|
+
catch (err) {
|
|
1566
|
+
if (err instanceof ManageError && err.status < 500) {
|
|
1567
|
+
return c.json({ error: err.message, code: err.code }, err.status);
|
|
1568
|
+
}
|
|
1569
|
+
throw err;
|
|
1570
|
+
}
|
|
1571
|
+
return c.json(await settingsFor(c));
|
|
1572
|
+
})
|
|
1573
|
+
// "Try a sentence" under the masking instructions: what a model would see of it.
|
|
1574
|
+
.post("/model-policy/try", async (c) => {
|
|
1575
|
+
const user = c.get("user");
|
|
1576
|
+
if (!managed || !mayChangeModels(user)) {
|
|
1577
|
+
return c.json({ error: say(c, "onlyOrganizationAdminsChange"), code: "forbidden" }, 403);
|
|
1578
|
+
}
|
|
1579
|
+
const { text, maskLabels } = z
|
|
1580
|
+
.object({
|
|
1581
|
+
text: z.string().trim().min(1).max(2000),
|
|
1582
|
+
maskLabels: z
|
|
1583
|
+
.array(z.string().trim().min(1).max(MAX_MASK_LABEL_CHARS))
|
|
1584
|
+
.max(MAX_MASK_LABELS)
|
|
1585
|
+
.optional(),
|
|
1586
|
+
})
|
|
1587
|
+
.parse(await c.req.json());
|
|
1588
|
+
try {
|
|
1589
|
+
return c.json(await tryMasking(user.tenantId, user.id, text, maskLabels));
|
|
1590
|
+
}
|
|
1591
|
+
catch (err) {
|
|
1592
|
+
if (err instanceof ManageError && (err.status < 500 || MASKING_CODES.has(err.code))) {
|
|
1593
|
+
return c.json({ error: err.message, code: err.code }, err.status);
|
|
1594
|
+
}
|
|
1595
|
+
throw err;
|
|
1596
|
+
}
|
|
1489
1597
|
})
|
|
1490
1598
|
// Ollama on this computer: its models, what each can do, the ones to download, the downloads.
|
|
1491
1599
|
.get("/models/local", async (c) => {
|
|
@@ -1839,9 +1947,9 @@ export const studio = new Hono()
|
|
|
1839
1947
|
}
|
|
1840
1948
|
return c.json({ ok: true });
|
|
1841
1949
|
})
|
|
1842
|
-
.post("/
|
|
1950
|
+
.post("/spaces/:id/website", async (c) => {
|
|
1843
1951
|
const user = c.get("user");
|
|
1844
|
-
const
|
|
1952
|
+
const space = await ownedSpace(user.id, c.req.param("id"));
|
|
1845
1953
|
// One address (as before) or several: the first website is read, the others kept as facts.
|
|
1846
1954
|
const { url, urls, lang } = z
|
|
1847
1955
|
.object({
|
|
@@ -1850,7 +1958,7 @@ export const studio = new Hono()
|
|
|
1850
1958
|
lang: z.enum(LANGS).optional(),
|
|
1851
1959
|
})
|
|
1852
1960
|
.parse(await c.req.json());
|
|
1853
|
-
const outcome = await applyAddresses(user.id,
|
|
1961
|
+
const outcome = await applyAddresses(user.id, space.id, urls ?? (url ? [url] : []), lang ?? requestLang(c));
|
|
1854
1962
|
return c.json(outcome);
|
|
1855
1963
|
})
|
|
1856
1964
|
// The install command and the first steps, mailed to the signed-in person by the Manage-App.
|