@engenty/wizards-runtime 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +101 -67
- package/apps/runtime/dist/agents/website.js +1 -1
- package/apps/runtime/dist/app.js +17 -1
- 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/db/adopt.js +3 -3
- package/apps/runtime/dist/db/client.js +26 -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/{0027_space_skill.sql → 0030_space_skill.sql} +8 -8
- 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 +40 -5
- 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/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 +16 -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/resources.js +43 -12
- package/apps/runtime/dist/engine/runner.js +75 -23
- package/apps/runtime/dist/engine/steps.js +30 -12
- package/apps/runtime/dist/engine/template.js +18 -1
- package/apps/runtime/dist/env.js +9 -4
- package/apps/runtime/dist/index.js +18 -2
- 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 +7 -0
- package/apps/runtime/dist/mcp/flow-app.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +75 -34
- package/apps/runtime/dist/models.js +1 -1
- package/apps/runtime/dist/motion-graphics/project.js +8 -8
- 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 +7 -7
- package/apps/runtime/dist/prompts/mcp.md +6 -6
- package/apps/runtime/dist/prompts/services.md +4 -4
- package/apps/runtime/dist/prompts/step.md +2 -2
- 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/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 +54 -33
- package/apps/runtime/dist/routes/skills.js +6 -6
- package/apps/runtime/dist/routes/studio.js +153 -144
- package/apps/runtime/dist/routes/work.js +199 -0
- 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 +74 -7
- 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 +7 -7
- 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 +23 -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 -612
- 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 +38 -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 +28 -13
- 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-SpDcn8VZ.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-Bgnm_3dk.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-DAnjV6cZ.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
- package/apps/web/dist/assets/EditorPage-B98C-9Nv.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.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-D8IYLg_S.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-DlBt0Mfq.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
- package/apps/web/dist/assets/PreviewPane-DC1kAi3x.js +9 -0
- package/apps/web/dist/assets/PublicRunner-D6lKP0j8.js +1 -0
- package/apps/web/dist/assets/ReadOnly-DFsuKPCw.js +1 -0
- package/apps/web/dist/assets/SettingsPage-DkHeCO2c.js +2 -0
- package/apps/web/dist/assets/SetupPage-DZ8xRkfS.js +1 -0
- package/apps/web/dist/assets/SharePage-494ZPsjQ.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-CWlU_BZP.js +2 -0
- package/apps/web/dist/assets/UpdateCheck-BKNkNJyG.js +2 -0
- package/apps/web/dist/assets/changelog-BhMZS-rs.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-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
- package/apps/web/dist/assets/connection-sign-in-Cngd_QDO.js +1 -0
- package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
- package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
- package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/host-C0WQlRKB.js +118 -0
- package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
- package/apps/web/dist/assets/index-ClVtdDUZ.js +10 -0
- package/apps/web/dist/assets/index-D18DvnxX.css +1 -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-DhkHteoJ.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-G-XYaDgR.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-BCau3f6O.js +11 -0
- package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
- package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CVHoxdGM.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 +6 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -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 +150 -8
- package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
- 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 +26 -2
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -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.js +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
- package/node_modules/@engenty/wizards-shared/dist/run.js +85 -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/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-B-JxkELB.js +0 -1
- package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
- package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
- package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
- package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
- package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
- package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
- package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
- package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
- package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
- package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
- package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
- package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
- package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
- package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
- package/apps/web/dist/assets/lock-C0uxcOlq.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-BWI-KENJ.js +0 -2
- package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
- package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { inAudience } from "../broker/index.js";
|
|
3
|
+
import { db, schema } from "../db/client.js";
|
|
4
|
+
import { managed, tenantMembers } from "../manage.js";
|
|
5
|
+
import { isAdminRole } from "../services/access.js";
|
|
6
|
+
import { userProfile } from "../services/profile.js";
|
|
7
|
+
import { listSpaces } from "../services/spaces.js";
|
|
8
|
+
import { currentTenant } from "../tenants/tenant.js";
|
|
9
|
+
import { resolveConnector } from "./external.js";
|
|
10
|
+
import { listSpaceConnections } from "./space-connections.js";
|
|
11
|
+
/*
|
|
12
|
+
* A person's own sign-ins (docs/plans/capabilities.md, "A person's own page"): per space of
|
|
13
|
+
* theirs, the connections within their audience. Where each person signs in, whether they did;
|
|
14
|
+
* where the space signs in, which account and who set it up. Other people's sign-ins never show.
|
|
15
|
+
*
|
|
16
|
+
* Every sign-in belongs to a connection of a space: Goose uses the person's sign-ins to those
|
|
17
|
+
* (`agents/goose-connections.ts`), so there are none „only for Goose“ to list yet.
|
|
18
|
+
*/
|
|
19
|
+
/** Names of the organization's people by id; alone, the one person. */
|
|
20
|
+
export async function namesOf(user) {
|
|
21
|
+
if (!managed) {
|
|
22
|
+
return new Map([[user.id, (await userProfile(user)).name]]);
|
|
23
|
+
}
|
|
24
|
+
const people = await tenantMembers(currentTenant()).catch(() => null);
|
|
25
|
+
return new Map((people?.members ?? []).map((m) => [m.userId, m.name]));
|
|
26
|
+
}
|
|
27
|
+
export async function personSignIns(user) {
|
|
28
|
+
const who = { kind: isAdminRole(user.role) ? "admin" : "person", id: user.id };
|
|
29
|
+
const own = await db.query.spaceConnectionSignIn.findMany({
|
|
30
|
+
where: eq(schema.spaceConnectionSignIn.userId, user.id),
|
|
31
|
+
});
|
|
32
|
+
let names = null;
|
|
33
|
+
const spaces = [];
|
|
34
|
+
for (const space of await listSpaces(user.id)) {
|
|
35
|
+
const rows = (await listSpaceConnections(space.id)).filter((row) => inAudience(row.audience, who));
|
|
36
|
+
if (rows.length && rows.some((row) => row.setUpBy) && !names) {
|
|
37
|
+
names = await namesOf(user);
|
|
38
|
+
}
|
|
39
|
+
const connections = [];
|
|
40
|
+
for (const row of rows) {
|
|
41
|
+
const connector = (await resolveConnector(space.id, row.connectorId))?.connector ?? null;
|
|
42
|
+
const mine = row.signIn === "person" ? own.find((s) => s.connectionId === row.id) : null;
|
|
43
|
+
connections.push({
|
|
44
|
+
id: row.id,
|
|
45
|
+
name: row.name,
|
|
46
|
+
connectorId: row.connectorId,
|
|
47
|
+
connector: connector
|
|
48
|
+
? {
|
|
49
|
+
id: connector.id,
|
|
50
|
+
name: connector.name,
|
|
51
|
+
auth: connector.auth.kind,
|
|
52
|
+
...(connector.auth.kind === "api_key" && row.signIn === "person"
|
|
53
|
+
? { fields: connector.auth.apiKey.fields }
|
|
54
|
+
: {}),
|
|
55
|
+
}
|
|
56
|
+
: null,
|
|
57
|
+
signIn: row.signIn,
|
|
58
|
+
audience: row.audience,
|
|
59
|
+
mySignIn: mine ? { label: mine.label, signedInAt: mine.signedInAt.toISOString() } : null,
|
|
60
|
+
account: row.signIn === "space" && row.secret
|
|
61
|
+
? {
|
|
62
|
+
label: row.label ?? connector?.name ?? row.name,
|
|
63
|
+
signedInAt: row.setUpAt.toISOString(),
|
|
64
|
+
}
|
|
65
|
+
: null,
|
|
66
|
+
setUpBy: row.setUpBy ? (names?.get(row.setUpBy) ?? null) : null,
|
|
67
|
+
setUpAt: row.setUpAt.toISOString(),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
spaces.push({ id: space.id, name: space.name, connections });
|
|
71
|
+
}
|
|
72
|
+
return { spaces };
|
|
73
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { DEFAULT_CONNECTION_RULES } from "@engenty/wizards-shared/connectors";
|
|
1
2
|
import { and, desc, eq } from "drizzle-orm";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
4
|
+
import { brokerCall, currentCaller, kindOf, reachesOutside } from "../broker/index.js";
|
|
3
5
|
import { db, schema } from "../db/client.js";
|
|
4
|
-
import { buildAuthorizationUrl, createOAuth2Pkce, exchangeAuthorizationCode,
|
|
6
|
+
import { buildAuthorizationUrl, createOAuth2Pkce, exchangeAuthorizationCode, } from "../engenty/connections-sdk/oauth2.js";
|
|
5
7
|
import { seal, unseal } from "../secrets/crypto.js";
|
|
6
8
|
import { currentTenant } from "../tenants/tenant.js";
|
|
7
9
|
import { builtinConnector, connectorFetch, resolveEnv, usable, viaAccount } from "./builtin.js";
|
|
8
10
|
import { connectRedirectUri as redirectUri } from "./index.js";
|
|
9
|
-
import {
|
|
11
|
+
import { keepSpaceSignIn, } from "./space-connections.js";
|
|
12
|
+
import { AccountConnectError, redeemTicket, startThroughAccount } from "./via-account.js";
|
|
10
13
|
function oauthConnector(id) {
|
|
11
14
|
const connector = builtinConnector(id);
|
|
12
15
|
if (connector?.auth.kind !== "oauth2") {
|
|
@@ -32,37 +35,44 @@ function knownActions(connector, actions) {
|
|
|
32
35
|
return [...new Set(actions)];
|
|
33
36
|
}
|
|
34
37
|
async function spaceExists(space) {
|
|
35
|
-
const
|
|
36
|
-
where: eq(schema.
|
|
38
|
+
const row = await db.query.space.findFirst({
|
|
39
|
+
where: eq(schema.space.id, space),
|
|
37
40
|
columns: { id: true },
|
|
38
41
|
});
|
|
39
|
-
if (!
|
|
42
|
+
if (!row) {
|
|
40
43
|
throw new Error(`There’s no space “${space}”.`);
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
/** Keeps a connection: the same account for the same space again replaces the first one. */
|
|
44
47
|
async function keep(input) {
|
|
45
|
-
const same = await db.query.
|
|
46
|
-
where: and(eq(schema.
|
|
48
|
+
const same = await db.query.spaceConnection.findFirst({
|
|
49
|
+
where: and(eq(schema.spaceConnection.plugin, input.plugin), eq(schema.spaceConnection.spaceId, input.spaceId), eq(schema.spaceConnection.connectorId, input.connector), eq(schema.spaceConnection.label, input.label)),
|
|
47
50
|
});
|
|
48
51
|
if (same) {
|
|
49
|
-
|
|
50
|
-
.update(schema.
|
|
51
|
-
.set({ actions: input.actions,
|
|
52
|
-
.where(eq(schema.
|
|
53
|
-
|
|
54
|
-
return
|
|
52
|
+
await db
|
|
53
|
+
.update(schema.spaceConnection)
|
|
54
|
+
.set({ actions: input.actions, updatedAt: new Date() })
|
|
55
|
+
.where(eq(schema.spaceConnection.id, same.id));
|
|
56
|
+
await keepSpaceSignIn(same, input.label, input.stored);
|
|
57
|
+
return (await db.query.spaceConnection.findFirst({
|
|
58
|
+
where: eq(schema.spaceConnection.id, same.id),
|
|
59
|
+
}));
|
|
55
60
|
}
|
|
56
61
|
const [row] = await db
|
|
57
|
-
.insert(schema.
|
|
62
|
+
.insert(schema.spaceConnection)
|
|
58
63
|
.values({
|
|
59
64
|
id: nanoid(14),
|
|
65
|
+
spaceId: input.spaceId,
|
|
66
|
+
connectorId: input.connector,
|
|
60
67
|
plugin: input.plugin,
|
|
61
|
-
|
|
62
|
-
connector: input.connector,
|
|
68
|
+
name: input.label,
|
|
63
69
|
label: input.label,
|
|
70
|
+
signIn: "space",
|
|
71
|
+
audience: "all",
|
|
72
|
+
rules: DEFAULT_CONNECTION_RULES,
|
|
64
73
|
actions: input.actions,
|
|
65
|
-
|
|
74
|
+
secret: seal(input.stored),
|
|
75
|
+
setUpBy: null,
|
|
66
76
|
})
|
|
67
77
|
.returning();
|
|
68
78
|
return row;
|
|
@@ -83,11 +93,11 @@ function scopesOf(connector, actions) {
|
|
|
83
93
|
}
|
|
84
94
|
const view = (row) => ({
|
|
85
95
|
id: row.id,
|
|
86
|
-
space: row.
|
|
87
|
-
connector: row.
|
|
88
|
-
label: row.label,
|
|
96
|
+
space: row.spaceId,
|
|
97
|
+
connector: row.connectorId,
|
|
98
|
+
label: row.label ?? row.name,
|
|
89
99
|
actions: row.actions,
|
|
90
|
-
createdAt: row.
|
|
100
|
+
createdAt: row.setUpAt.toISOString(),
|
|
91
101
|
});
|
|
92
102
|
/** A state the callback can tell is a plugin's: the tenant to finish it in, or null. */
|
|
93
103
|
export function pluginStateTenant(rawState) {
|
|
@@ -128,74 +138,18 @@ export async function finishPluginOAuth(answer, rawState) {
|
|
|
128
138
|
};
|
|
129
139
|
await keep({
|
|
130
140
|
plugin: state.plugin,
|
|
131
|
-
|
|
141
|
+
spaceId: state.spaceId,
|
|
132
142
|
connector: connector.id,
|
|
133
143
|
label: account.label,
|
|
134
144
|
actions: state.actions,
|
|
135
145
|
stored,
|
|
136
146
|
});
|
|
137
|
-
return { plugin: state.plugin,
|
|
138
|
-
}
|
|
139
|
-
/** The tokens of a connection, refreshed when they run out within five minutes. */
|
|
140
|
-
async function freshTokens(row, connector) {
|
|
141
|
-
let data = unseal(row.data);
|
|
142
|
-
if (!data) {
|
|
143
|
-
throw new Error("The connection's keys cannot be read here. Connect the account again.");
|
|
144
|
-
}
|
|
145
|
-
const expires = data.expiresAt ? Date.parse(data.expiresAt) : null;
|
|
146
|
-
if (connector.auth.kind === "oauth2" &&
|
|
147
|
-
data.refreshToken &&
|
|
148
|
-
expires !== null &&
|
|
149
|
-
expires - Date.now() < 5 * 60_000) {
|
|
150
|
-
const tokens = data.via === "account"
|
|
151
|
-
? await refreshThroughAccount(data.refreshToken)
|
|
152
|
-
: await refreshAccessToken({
|
|
153
|
-
config: connector.auth.oauth2,
|
|
154
|
-
refreshToken: data.refreshToken,
|
|
155
|
-
resolveEnv,
|
|
156
|
-
});
|
|
157
|
-
data = {
|
|
158
|
-
...(data.via ? { via: data.via } : {}),
|
|
159
|
-
accessToken: tokens.accessToken,
|
|
160
|
-
refreshToken: tokens.refreshToken ?? data.refreshToken,
|
|
161
|
-
expiresAt: tokens.expiresAt?.toISOString() ?? null,
|
|
162
|
-
scopes: tokens.grantedScopes.length ? tokens.grantedScopes : data.scopes,
|
|
163
|
-
};
|
|
164
|
-
await db
|
|
165
|
-
.update(schema.pluginConnection)
|
|
166
|
-
.set({ data: seal(data), updatedAt: new Date() })
|
|
167
|
-
.where(eq(schema.pluginConnection.id, row.id));
|
|
168
|
-
}
|
|
169
|
-
return data;
|
|
170
|
-
}
|
|
171
|
-
function contextOf(row, connector, data) {
|
|
172
|
-
const ctx = {
|
|
173
|
-
accessToken: data.accessToken,
|
|
174
|
-
fetchImpl: connectorFetch,
|
|
175
|
-
log: () => undefined,
|
|
176
|
-
connection: {
|
|
177
|
-
id: row.id,
|
|
178
|
-
connector_id: connector.id,
|
|
179
|
-
auth_kind: connector.auth.kind,
|
|
180
|
-
autonomous_mode: "read_only",
|
|
181
|
-
connected_by: row.createdBy,
|
|
182
|
-
created_at: row.createdAt.toISOString(),
|
|
183
|
-
display_name: row.label,
|
|
184
|
-
error_message: null,
|
|
185
|
-
external_account: row.label,
|
|
186
|
-
granted_scopes: data.scopes,
|
|
187
|
-
owner_user_id: null,
|
|
188
|
-
space_id: row.projectId,
|
|
189
|
-
status: "active",
|
|
190
|
-
tenant_id: currentTenant(),
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
return ctx;
|
|
147
|
+
return { plugin: state.plugin, spaceId: state.spaceId };
|
|
194
148
|
}
|
|
195
149
|
/** `server.connections` of one plugin; every call runs inside the current tenant. */
|
|
196
150
|
export function pluginConnections(plugin) {
|
|
197
|
-
const own = (id) => db.query.
|
|
198
|
-
where: and(eq(schema.
|
|
151
|
+
const own = (id) => db.query.spaceConnection.findFirst({
|
|
152
|
+
where: and(eq(schema.spaceConnection.id, id), eq(schema.spaceConnection.plugin, plugin)),
|
|
199
153
|
});
|
|
200
154
|
return {
|
|
201
155
|
async available(ids) {
|
|
@@ -232,7 +186,7 @@ export function pluginConnections(plugin) {
|
|
|
232
186
|
const base = {
|
|
233
187
|
plugin,
|
|
234
188
|
tenantId: currentTenant(),
|
|
235
|
-
|
|
189
|
+
spaceId: space,
|
|
236
190
|
connectorId,
|
|
237
191
|
actions: [...new Set(actions)],
|
|
238
192
|
exp: Date.now() + 15 * 60_000,
|
|
@@ -294,7 +248,7 @@ export function pluginConnections(plugin) {
|
|
|
294
248
|
}
|
|
295
249
|
const row = await keep({
|
|
296
250
|
plugin,
|
|
297
|
-
|
|
251
|
+
spaceId: space,
|
|
298
252
|
connector: connector.id,
|
|
299
253
|
label: account.label,
|
|
300
254
|
actions: wanted,
|
|
@@ -308,9 +262,9 @@ export function pluginConnections(plugin) {
|
|
|
308
262
|
return view(row);
|
|
309
263
|
},
|
|
310
264
|
async list(space) {
|
|
311
|
-
const rows = await db.query.
|
|
312
|
-
where: and(eq(schema.
|
|
313
|
-
orderBy: [desc(schema.
|
|
265
|
+
const rows = await db.query.spaceConnection.findMany({
|
|
266
|
+
where: and(eq(schema.spaceConnection.plugin, plugin), eq(schema.spaceConnection.spaceId, space)),
|
|
267
|
+
orderBy: [desc(schema.spaceConnection.setUpAt)],
|
|
314
268
|
});
|
|
315
269
|
return rows.map(view);
|
|
316
270
|
},
|
|
@@ -323,21 +277,40 @@ export function pluginConnections(plugin) {
|
|
|
323
277
|
if (!row) {
|
|
324
278
|
throw new Error(`There is no connection "${id}".`);
|
|
325
279
|
}
|
|
326
|
-
if (!row.actions.includes(actionId)) {
|
|
280
|
+
if (row.actions.length && !row.actions.includes(actionId)) {
|
|
327
281
|
throw new Error(`The connection was not made for "${actionId}". Connect it again.`);
|
|
328
282
|
}
|
|
329
|
-
const connector = connectorOf(row.
|
|
283
|
+
const connector = connectorOf(row.connectorId);
|
|
330
284
|
const action = connector.actions.find((a) => a.id === actionId);
|
|
331
285
|
if (!action) {
|
|
332
286
|
throw new Error(`${connector.name} has no action "${actionId}".`);
|
|
333
287
|
}
|
|
334
|
-
|
|
335
|
-
|
|
288
|
+
// The run or chat the plugin's code runs in, where the runtime set it; else the plugin itself.
|
|
289
|
+
const caller = currentCaller() ?? {
|
|
290
|
+
who: { kind: "plugin", id: plugin },
|
|
291
|
+
where: { spaceId: row.spaceId },
|
|
292
|
+
};
|
|
293
|
+
reachesOutside(`plugin:${plugin}`, {
|
|
294
|
+
connection: row.connectorId,
|
|
295
|
+
action: actionId,
|
|
296
|
+
kind: kindOf(action.group),
|
|
297
|
+
});
|
|
298
|
+
const out = await brokerCall({
|
|
299
|
+
who: caller.who,
|
|
300
|
+
where: { ...caller.where, spaceId: caller.where.spaceId ?? row.spaceId },
|
|
301
|
+
connection: { kind: "space_connection", row, connector },
|
|
302
|
+
action: { id: actionId },
|
|
303
|
+
input: action.inputSchema.parse(input),
|
|
304
|
+
});
|
|
305
|
+
if (!out.ok) {
|
|
306
|
+
throw new Error(out.reason);
|
|
307
|
+
}
|
|
308
|
+
return out.result;
|
|
336
309
|
},
|
|
337
310
|
async remove(id) {
|
|
338
311
|
await db
|
|
339
|
-
.delete(schema.
|
|
340
|
-
.where(and(eq(schema.
|
|
312
|
+
.delete(schema.spaceConnection)
|
|
313
|
+
.where(and(eq(schema.spaceConnection.id, id), eq(schema.spaceConnection.plugin, plugin)));
|
|
341
314
|
},
|
|
342
315
|
};
|
|
343
316
|
}
|
|
@@ -195,7 +195,7 @@ export const smtpConnector = {
|
|
|
195
195
|
id: "send_message",
|
|
196
196
|
summary: "Send an e-mail",
|
|
197
197
|
description: "Send an e-mail from the connected mailbox right away (plain text, one optional attachment). Irreversible.",
|
|
198
|
-
group: "
|
|
198
|
+
group: "send",
|
|
199
199
|
inputSchema: sendInput,
|
|
200
200
|
handler: async (raw, ctx) => {
|
|
201
201
|
const input = sendInput.parse(raw);
|