@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
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { note } from "@engenty/wizards-shared/run";
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import { db, schema } from "../db/client.js";
|
|
4
|
+
/** The grant a definition gives its runs. Pure: the same definition, the same grant. */
|
|
5
|
+
export function grantOf(definition) {
|
|
6
|
+
const connections = {};
|
|
7
|
+
const tools = new Set();
|
|
8
|
+
const hosts = new Set();
|
|
9
|
+
const defs = new Map((definition.connections ?? []).map((c) => [c.id, c]));
|
|
10
|
+
for (const step of definition.steps) {
|
|
11
|
+
if (step.type !== "agent") {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
for (const tool of step.tools) {
|
|
15
|
+
tools.add(tool);
|
|
16
|
+
}
|
|
17
|
+
if (step.call && "connection" in step.call && defs.has(step.call.connection)) {
|
|
18
|
+
const have = new Set(connections[step.call.connection] ?? []);
|
|
19
|
+
have.add(step.call.action);
|
|
20
|
+
connections[step.call.connection] = [...have].sort();
|
|
21
|
+
}
|
|
22
|
+
for (const host of step.hosts ?? []) {
|
|
23
|
+
hosts.add(host.trim().toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
for (const id of step.connections ?? []) {
|
|
26
|
+
const def = defs.get(id);
|
|
27
|
+
if (!def) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const have = new Set(connections[id] ?? []);
|
|
31
|
+
for (const action of def.actions ?? ["read"]) {
|
|
32
|
+
have.add(action);
|
|
33
|
+
}
|
|
34
|
+
connections[id] = [...have].sort();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { connections, hosts: [...hosts].sort(), tools: [...tools].sort() };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether the grant lets `http_request` reach this host: named as it is, or below a `*.` entry
|
|
41
|
+
* (`*.example.org` takes `api.example.org`, not `example.org` itself).
|
|
42
|
+
*/
|
|
43
|
+
export function hostInGrant(grant, hostname) {
|
|
44
|
+
const host = hostname
|
|
45
|
+
.replace(/^\[|\]$/g, "")
|
|
46
|
+
.toLowerCase()
|
|
47
|
+
.replace(/\.$/, "");
|
|
48
|
+
return grant.hosts.some((entry) => entry.startsWith("*.")
|
|
49
|
+
? host.endsWith(entry.slice(1)) && host.length > entry.length - 1
|
|
50
|
+
: entry === host);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether the grant lets this action run through this connection: the action by its id, or by
|
|
54
|
+
* its kind where the grant names kinds. A connection in the grant may always list its connector's
|
|
55
|
+
* tools (`list_tools`): that reads the connector, not the account's data.
|
|
56
|
+
*/
|
|
57
|
+
export function inGrant(grant, connectionId, actionId, kind) {
|
|
58
|
+
const allowed = grant.connections[connectionId];
|
|
59
|
+
if (!allowed) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return actionId === "list_tools" || allowed.includes(actionId) || allowed.includes(kind);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The grant a run holds. A run from before grants were kept gets one from the definition it
|
|
66
|
+
* started on, written once on first use; null for a run this tenant does not have.
|
|
67
|
+
*/
|
|
68
|
+
export async function runGrant(runId) {
|
|
69
|
+
const run = await db.query.run.findFirst({
|
|
70
|
+
where: eq(schema.run.id, runId),
|
|
71
|
+
columns: { grant: true, definition: true },
|
|
72
|
+
});
|
|
73
|
+
if (!run) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (run.grant) {
|
|
77
|
+
return run.grant;
|
|
78
|
+
}
|
|
79
|
+
const grant = grantOf(run.definition);
|
|
80
|
+
await db.update(schema.run).set({ grant }).where(eq(schema.run.id, runId));
|
|
81
|
+
return grant;
|
|
82
|
+
}
|
|
83
|
+
/** What a built-in tool lets a run do, in the run's log. */
|
|
84
|
+
const TOOL_NOTES = {
|
|
85
|
+
web_search: note("grantSearchesWeb"),
|
|
86
|
+
web_fetch: note("grantReadsWeb"),
|
|
87
|
+
browser: note("grantBrowser"),
|
|
88
|
+
sandbox: note("grantRunsCode"),
|
|
89
|
+
code: note("grantRunsCode"),
|
|
90
|
+
image: note("grantDrawsImages"),
|
|
91
|
+
http: note("grantCallsApis"),
|
|
92
|
+
pages: note("grantWritesPages"),
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* The line the run's log opens with: what the run may do, in words. `connectors` says, by
|
|
96
|
+
* connection id, what the connector is called and what kind each of its actions is, where the
|
|
97
|
+
* space has it; an unknown connector's actions are named as they are. Null when the run reaches
|
|
98
|
+
* nothing outside.
|
|
99
|
+
*/
|
|
100
|
+
export function grantNote(grant, definition, connectors = {}) {
|
|
101
|
+
const what = [];
|
|
102
|
+
const defs = new Map((definition.connections ?? []).map((c) => [c.id, c]));
|
|
103
|
+
for (const [id, actions] of Object.entries(grant.connections)) {
|
|
104
|
+
const def = defs.get(id);
|
|
105
|
+
const name = def?.title ?? connectors[id]?.name ?? def?.connector ?? def?.kind ?? id;
|
|
106
|
+
const known = connectors[id]?.kinds ?? {};
|
|
107
|
+
const byKind = new Set();
|
|
108
|
+
const unknown = [];
|
|
109
|
+
for (const action of actions) {
|
|
110
|
+
if (action === "read" ||
|
|
111
|
+
action === "write" ||
|
|
112
|
+
action === "send" ||
|
|
113
|
+
action === "destructive") {
|
|
114
|
+
byKind.add(action);
|
|
115
|
+
}
|
|
116
|
+
else if (known[action]) {
|
|
117
|
+
byKind.add(known[action]);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
unknown.push(action);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (byKind.has("read")) {
|
|
124
|
+
what.push(note("grantReads", { name }));
|
|
125
|
+
}
|
|
126
|
+
if (byKind.has("write")) {
|
|
127
|
+
what.push(note("grantWrites", { name }));
|
|
128
|
+
}
|
|
129
|
+
if (byKind.has("send")) {
|
|
130
|
+
what.push(note("grantSends", { name }));
|
|
131
|
+
}
|
|
132
|
+
if (byKind.has("destructive")) {
|
|
133
|
+
what.push(note("grantDeletes", { name }));
|
|
134
|
+
}
|
|
135
|
+
if (unknown.length) {
|
|
136
|
+
what.push(note("grantCalls", { name, actions: unknown }));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const [tool, own] of Object.entries(TOOL_NOTES)) {
|
|
140
|
+
if (grant.tools.includes(tool) && !what.some((w) => w.code === own.code)) {
|
|
141
|
+
// With hosts listed the run calls those, not "APIs on the web".
|
|
142
|
+
what.push(tool === "http" && grant.hosts.length
|
|
143
|
+
? note("grantCallsHosts", { hosts: grant.hosts })
|
|
144
|
+
: own);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const plugins = new Set(grant.tools.filter((tool) => !TOOL_NOTES[tool]).map((tool) => tool.split(".")[0]));
|
|
148
|
+
for (const plugin of plugins) {
|
|
149
|
+
what.push(note("grantPlugin", { name: plugin }));
|
|
150
|
+
}
|
|
151
|
+
return what.length ? note("grant", { what }) : null;
|
|
152
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { hostInGrant, runGrant } from "./grant.js";
|
|
2
|
+
import { summarizeInput, writeLog } from "./log.js";
|
|
3
|
+
import { brokerOn } from "./rwx.js";
|
|
4
|
+
export async function brokerHost(call) {
|
|
5
|
+
const started = Date.now();
|
|
6
|
+
const { who, where, url } = call;
|
|
7
|
+
const host = url.hostname.toLowerCase();
|
|
8
|
+
const line = (outcome, reason, result) => writeLog({
|
|
9
|
+
at: new Date(started),
|
|
10
|
+
durationMs: Date.now() - started,
|
|
11
|
+
whoKind: who.kind,
|
|
12
|
+
whoId: who.id ?? null,
|
|
13
|
+
runId: where.runId ?? null,
|
|
14
|
+
stepId: where.stepId ?? null,
|
|
15
|
+
chatId: where.chatId ?? null,
|
|
16
|
+
wizardId: where.wizardId ?? null,
|
|
17
|
+
spaceId: where.spaceId ?? null,
|
|
18
|
+
connectionId: `host:${host}`,
|
|
19
|
+
actionId: "http_request",
|
|
20
|
+
kind: "send",
|
|
21
|
+
// The path without its query: a query may carry a key.
|
|
22
|
+
inputSummary: summarizeInput({ method: call.method, host, path: url.pathname }),
|
|
23
|
+
outcome,
|
|
24
|
+
rule: "grant",
|
|
25
|
+
reason,
|
|
26
|
+
result,
|
|
27
|
+
resultSize: null,
|
|
28
|
+
});
|
|
29
|
+
const bound = where.guest || (await brokerOn());
|
|
30
|
+
let reason = "Members reach every public host.";
|
|
31
|
+
if (bound) {
|
|
32
|
+
const grant = where.runId ? await runGrant(where.runId) : null;
|
|
33
|
+
if (!grant || !hostInGrant(grant, host)) {
|
|
34
|
+
const why = grant
|
|
35
|
+
? `The run's grant does not include the host ${host}.`
|
|
36
|
+
: "The run is not known here.";
|
|
37
|
+
await line("deny", why, "not_in_grant");
|
|
38
|
+
return { ok: false, refused: "not_in_grant", reason: why };
|
|
39
|
+
}
|
|
40
|
+
reason = "The host is in the run's grant.";
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const result = await call.handler();
|
|
44
|
+
await line("allow", reason, "ok");
|
|
45
|
+
return { ok: true, result };
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
await line("allow", reason, err instanceof Error ? err.constructor.name || "Error" : "Error");
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { brokerCall, brokerConnected, brokerSecret, decide, grantBinds, inAudience, kindOf, signInRefused, whereOf, whereOfRun, whoOf, } from "./call.js";
|
|
2
|
+
export { currentCaller, withCaller } from "./caller.js";
|
|
3
|
+
export { grantNote, grantOf, hostInGrant, inGrant, runGrant, } from "./grant.js";
|
|
4
|
+
export { brokerHost } from "./host.js";
|
|
5
|
+
export { keptStepIds } from "./kept.js";
|
|
6
|
+
export { CRITICAL_KINDS, criticalOf, criticalSince, cursorOf, LOG_PAGE, lastUseOf, logLine, logOfSpace, logRuleChange, onCritical, RULE_CHANGE_ACTION, readCursor, SIGN_IN_FAILED, summarizeInput, } from "./log.js";
|
|
7
|
+
export { outsideReaches, reachesOutside } from "./registry.js";
|
|
8
|
+
export { brokerSend, GUEST_MAILS_PER_RUN, guestSendCheck, recipientsOf, runAddresses, } from "./send.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { and, eq, inArray, isNotNull, ne } from "drizzle-orm";
|
|
2
|
+
import { db, schema } from "../db/client.js";
|
|
3
|
+
import { guestRun } from "../safety.js";
|
|
4
|
+
/*
|
|
5
|
+
* Results that stay in the space (docs/plans/capabilities.md, A6; rule 5 of the connections
|
|
6
|
+
* plan): a step of a guest's run that read a connection the space keeps for its members or admins
|
|
7
|
+
* made its output with the space's data. The output is kept with the run — Ergebnisse in the
|
|
8
|
+
* studio shows it — and the guest's result page and share link show a note in its place. The
|
|
9
|
+
* broker's log says which step read which connection; the connection's audience is read as it is
|
|
10
|
+
* now, so narrowing it afterwards keeps the results too.
|
|
11
|
+
*/
|
|
12
|
+
/** The steps of this run whose output stays in the space; empty for a member's run. */
|
|
13
|
+
export async function keptStepIds(run) {
|
|
14
|
+
if (!guestRun(run)) {
|
|
15
|
+
return new Set();
|
|
16
|
+
}
|
|
17
|
+
const reads = await db
|
|
18
|
+
.select({ stepId: schema.brokerLog.stepId, connectionId: schema.brokerLog.connectionId })
|
|
19
|
+
.from(schema.brokerLog)
|
|
20
|
+
.where(and(eq(schema.brokerLog.runId, run.id), eq(schema.brokerLog.outcome, "allow"), eq(schema.brokerLog.result, "ok"), isNotNull(schema.brokerLog.stepId)));
|
|
21
|
+
const connectionIds = [...new Set(reads.map((r) => r.connectionId))];
|
|
22
|
+
if (!connectionIds.length) {
|
|
23
|
+
return new Set();
|
|
24
|
+
}
|
|
25
|
+
const members = await db
|
|
26
|
+
.select({ id: schema.spaceConnection.id })
|
|
27
|
+
.from(schema.spaceConnection)
|
|
28
|
+
.where(and(inArray(schema.spaceConnection.id, connectionIds), ne(schema.spaceConnection.audience, "all")));
|
|
29
|
+
const kept = new Set(members.map((c) => c.id));
|
|
30
|
+
return new Set(reads.filter((r) => kept.has(r.connectionId)).map((r) => r.stepId));
|
|
31
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { and, desc, eq, gt, inArray, lt, not, or, sql } from "drizzle-orm";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
import { db, schema } from "../db/client.js";
|
|
5
|
+
/**
|
|
6
|
+
* What the broker's admins hear of (docs/plans/broker.md, "Notifications"), one of
|
|
7
|
+
* `CRITICAL_KINDS` (shared/connectors): `refused_write` – a *Nie*, the grant or the AI-step rule
|
|
8
|
+
* stopped a write, a delete or a send; `outside_audience` – a guest's run reached a connection
|
|
9
|
+
* that is for the space's members or admins; `host_not_in_grant`; `limit_reached` – a guest's run
|
|
10
|
+
* or a wizard's guests have sent their mails for the run or the day; `sign_in_failed` – a sign-in
|
|
11
|
+
* ran out or the service refused it; `first_use` of a connection of the space; `rule_changed` –
|
|
12
|
+
* RWX, or a connection's rules or audience.
|
|
13
|
+
*/
|
|
14
|
+
export { CRITICAL_KINDS } from "@engenty/wizards-shared/connectors";
|
|
15
|
+
/** The action under which a changed rule is logged; the connection is the one changed, or `rwx`. */
|
|
16
|
+
export const RULE_CHANGE_ACTION = "change_rules";
|
|
17
|
+
/** The result under which a sign-in that ran out or was refused is logged. */
|
|
18
|
+
export const SIGN_IN_FAILED = "sign_in_failed";
|
|
19
|
+
/**
|
|
20
|
+
* Which critical kind a row is, if any: the one place that decides. Every refusal of a write, a
|
|
21
|
+
* delete or a send is critical; a refused read only where a guest reached outside a connection's
|
|
22
|
+
* audience. A connection's first use and a changed rule are critical though nothing was refused.
|
|
23
|
+
*/
|
|
24
|
+
export function criticalOf(row, context = {}) {
|
|
25
|
+
if (row.actionId === RULE_CHANGE_ACTION) {
|
|
26
|
+
return "rule_changed";
|
|
27
|
+
}
|
|
28
|
+
if (row.result === SIGN_IN_FAILED) {
|
|
29
|
+
return "sign_in_failed";
|
|
30
|
+
}
|
|
31
|
+
if (row.outcome === "deny") {
|
|
32
|
+
if (row.result === "run_limit" || row.result === "day_limit") {
|
|
33
|
+
return "limit_reached";
|
|
34
|
+
}
|
|
35
|
+
if (row.connectionId.startsWith("host:") && row.result === "not_in_grant") {
|
|
36
|
+
return "host_not_in_grant";
|
|
37
|
+
}
|
|
38
|
+
if (row.rule === "audience" && row.whoKind === "guest") {
|
|
39
|
+
return "outside_audience";
|
|
40
|
+
}
|
|
41
|
+
return row.kind === "read" ? null : "refused_write";
|
|
42
|
+
}
|
|
43
|
+
return row.result === "ok" && context.firstUse ? "first_use" : null;
|
|
44
|
+
}
|
|
45
|
+
/** A field whose value is never written down, whatever the action calls it. */
|
|
46
|
+
const SECRET = /token|secret|password|passwd|key|auth|credential|cookie|session|bearer|_base64$/i;
|
|
47
|
+
/** The widest a logged value gets. */
|
|
48
|
+
const SAMPLE = 80;
|
|
49
|
+
/** What the log keeps of a call's input. */
|
|
50
|
+
export function summarizeInput(input) {
|
|
51
|
+
const whole = JSON.stringify(input ?? null) ?? "null";
|
|
52
|
+
const fields = {};
|
|
53
|
+
let sample = null;
|
|
54
|
+
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
55
|
+
for (const [key, value] of Object.entries(input)) {
|
|
56
|
+
fields[key] = typeof value === "string" ? value.length : (JSON.stringify(value) ?? "").length;
|
|
57
|
+
if (sample === null && typeof value === "string" && value && !SECRET.test(key)) {
|
|
58
|
+
sample = `${key}: ${value.replace(/\s+/g, " ").slice(0, SAMPLE)}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return JSON.stringify({
|
|
63
|
+
fields,
|
|
64
|
+
sample,
|
|
65
|
+
size: whole.length,
|
|
66
|
+
sha256: createHash("sha256").update(whole).digest("hex"),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const listeners = new Set();
|
|
70
|
+
/** Hears every critical row as it is written: the report to the Manage-App (services/manage-reports.ts). */
|
|
71
|
+
export function onCritical(listener) {
|
|
72
|
+
listeners.add(listener);
|
|
73
|
+
return () => listeners.delete(listener);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Writes one row, deciding whether it is critical; a log that cannot be written never stops the
|
|
77
|
+
* call. A critical row is also a line of the runtime's own log, so the log ring and „wizards
|
|
78
|
+
* report“ carry it (docs/plans/remote-debug.md), and goes to whoever listens.
|
|
79
|
+
*/
|
|
80
|
+
export async function writeLog(row, context = {}) {
|
|
81
|
+
const criticalKind = criticalOf(row, context);
|
|
82
|
+
const written = { id: nanoid(14), ...row, critical: criticalKind !== null, criticalKind };
|
|
83
|
+
try {
|
|
84
|
+
await db.insert(schema.brokerLog).values(written);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.error("[broker] the log could not be written:", err);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (criticalKind) {
|
|
91
|
+
console.warn(`[broker] ${criticalKind}: ${row.whoKind}${row.whoId ? ` ${row.whoId}` : ""} → ${row.connectionId} ${row.actionId} (${row.kind}): ${row.outcome}, ${row.result ?? ""}${row.reason ? ` – ${row.reason}` : ""}`);
|
|
92
|
+
const full = written;
|
|
93
|
+
for (const listener of listeners) {
|
|
94
|
+
try {
|
|
95
|
+
listener(full);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.error("[broker] a listener failed:", err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** A rule changed by an admin: RWX (`connectionId` "rwx") or a connection's rules or audience. */
|
|
104
|
+
export function logRuleChange(change) {
|
|
105
|
+
return writeLog({
|
|
106
|
+
at: new Date(),
|
|
107
|
+
durationMs: 0,
|
|
108
|
+
whoKind: "admin",
|
|
109
|
+
whoId: change.userId,
|
|
110
|
+
runId: null,
|
|
111
|
+
stepId: null,
|
|
112
|
+
chatId: null,
|
|
113
|
+
wizardId: null,
|
|
114
|
+
spaceId: change.spaceId,
|
|
115
|
+
connectionId: change.connectionId,
|
|
116
|
+
actionId: RULE_CHANGE_ACTION,
|
|
117
|
+
kind: "write",
|
|
118
|
+
inputSummary: summarizeInput(change.summary),
|
|
119
|
+
outcome: "allow",
|
|
120
|
+
rule: null,
|
|
121
|
+
reason: change.reason,
|
|
122
|
+
result: "ok",
|
|
123
|
+
resultSize: null,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** The cursor as the API hands it out: `<ms>.<id>`. */
|
|
127
|
+
export function cursorOf(row) {
|
|
128
|
+
return `${row.at.getTime()}.${row.id}`;
|
|
129
|
+
}
|
|
130
|
+
/** A cursor the API took; null where it is none. */
|
|
131
|
+
export function readCursor(text) {
|
|
132
|
+
const match = /^(\d{1,15})\.([A-Za-z0-9_-]{1,40})$/.exec(text);
|
|
133
|
+
return match ? { at: new Date(Number(match[1])), id: match[2] } : null;
|
|
134
|
+
}
|
|
135
|
+
/** The widest the log answers at once. */
|
|
136
|
+
export const LOG_PAGE = 200;
|
|
137
|
+
/** The results of a call the person asked turned down, beside an `outcome` of `deny`. */
|
|
138
|
+
const REFUSED_BY_PERSON = ["declined"];
|
|
139
|
+
/** `%` and `_` stand for themselves in a search. */
|
|
140
|
+
function likeOf(text) {
|
|
141
|
+
return `%${text.replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
|
|
142
|
+
}
|
|
143
|
+
/** A space's log, newest first, filtered. */
|
|
144
|
+
export async function logOfSpace(spaceId, query = {}) {
|
|
145
|
+
const log = schema.brokerLog;
|
|
146
|
+
const where = [eq(log.spaceId, spaceId)];
|
|
147
|
+
if (query.connection) {
|
|
148
|
+
where.push(eq(log.connectionId, query.connection));
|
|
149
|
+
}
|
|
150
|
+
if (query.who) {
|
|
151
|
+
where.push(eq(log.whoKind, query.who));
|
|
152
|
+
}
|
|
153
|
+
if (query.outcome) {
|
|
154
|
+
where.push(eq(log.outcome, query.outcome));
|
|
155
|
+
}
|
|
156
|
+
if (query.result) {
|
|
157
|
+
where.push(eq(log.result, query.result));
|
|
158
|
+
}
|
|
159
|
+
if (query.refused !== undefined) {
|
|
160
|
+
const refused = or(eq(log.outcome, "deny"), and(eq(log.outcome, "ask"), inArray(log.result, REFUSED_BY_PERSON)));
|
|
161
|
+
where.push(query.refused ? refused : not(refused));
|
|
162
|
+
}
|
|
163
|
+
if (query.critical !== undefined) {
|
|
164
|
+
where.push(eq(log.critical, query.critical));
|
|
165
|
+
}
|
|
166
|
+
if (query.since) {
|
|
167
|
+
where.push(gt(log.at, query.since));
|
|
168
|
+
}
|
|
169
|
+
if (query.until) {
|
|
170
|
+
where.push(lt(log.at, query.until));
|
|
171
|
+
}
|
|
172
|
+
const text = query.q?.trim();
|
|
173
|
+
if (text) {
|
|
174
|
+
const like = likeOf(text);
|
|
175
|
+
const found = [
|
|
176
|
+
log.actionId,
|
|
177
|
+
log.connectionId,
|
|
178
|
+
log.reason,
|
|
179
|
+
log.result,
|
|
180
|
+
log.rule,
|
|
181
|
+
log.whoId,
|
|
182
|
+
log.inputSummary,
|
|
183
|
+
].map((column) => sql `${column} like ${like} escape '\\'`);
|
|
184
|
+
const { who = [], connections = [], wizards = [] } = query.matches ?? {};
|
|
185
|
+
if (who.length) {
|
|
186
|
+
found.push(inArray(log.whoId, who));
|
|
187
|
+
}
|
|
188
|
+
if (connections.length) {
|
|
189
|
+
found.push(inArray(log.connectionId, connections));
|
|
190
|
+
}
|
|
191
|
+
if (wizards.length) {
|
|
192
|
+
found.push(inArray(log.wizardId, wizards));
|
|
193
|
+
}
|
|
194
|
+
where.push(or(...found));
|
|
195
|
+
}
|
|
196
|
+
if (query.before) {
|
|
197
|
+
where.push(or(lt(log.at, query.before.at), and(eq(log.at, query.before.at), lt(log.id, query.before.id))));
|
|
198
|
+
}
|
|
199
|
+
return db.query.brokerLog.findMany({
|
|
200
|
+
where: and(...where),
|
|
201
|
+
orderBy: [desc(log.at), desc(log.id)],
|
|
202
|
+
limit: Math.min(Math.max(query.limit ?? LOG_PAGE, 1), LOG_PAGE),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** One line of a space's log. */
|
|
206
|
+
export async function logLine(spaceId, id) {
|
|
207
|
+
const row = await db.query.brokerLog.findFirst({
|
|
208
|
+
where: and(eq(schema.brokerLog.spaceId, spaceId), eq(schema.brokerLog.id, id)),
|
|
209
|
+
});
|
|
210
|
+
return row ?? null;
|
|
211
|
+
}
|
|
212
|
+
/** The critical rows of these spaces since a time, newest first. */
|
|
213
|
+
export async function criticalSince(spaceIds, since, limit = LOG_PAGE) {
|
|
214
|
+
if (!spaceIds.length) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
return db.query.brokerLog.findMany({
|
|
218
|
+
where: and(inArray(schema.brokerLog.spaceId, spaceIds), eq(schema.brokerLog.critical, true), gt(schema.brokerLog.at, since)),
|
|
219
|
+
orderBy: [desc(schema.brokerLog.at)],
|
|
220
|
+
limit,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/** When a connection was last used, by whom and for what: „Letzte Nutzung“. */
|
|
224
|
+
export async function lastUseOf(connectionId,
|
|
225
|
+
/** A wizard's connection ids repeat across wizards: name the wizard to tell them apart. */
|
|
226
|
+
within = {}) {
|
|
227
|
+
const row = await db.query.brokerLog.findFirst({
|
|
228
|
+
where: and(eq(schema.brokerLog.connectionId, connectionId), ...(within.wizardId ? [eq(schema.brokerLog.wizardId, within.wizardId)] : [])),
|
|
229
|
+
orderBy: [desc(schema.brokerLog.at)],
|
|
230
|
+
});
|
|
231
|
+
return row
|
|
232
|
+
? {
|
|
233
|
+
at: row.at,
|
|
234
|
+
who: { kind: row.whoKind, id: row.whoId },
|
|
235
|
+
actionId: row.actionId,
|
|
236
|
+
kind: row.kind,
|
|
237
|
+
outcome: row.outcome,
|
|
238
|
+
}
|
|
239
|
+
: null;
|
|
240
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const reaches = new Map();
|
|
2
|
+
/** A tool or target (by its id) reaches outside through these actions. Registering twice is fine. */
|
|
3
|
+
export function reachesOutside(id, list) {
|
|
4
|
+
reaches.set(id, Array.isArray(list) ? list : [list]);
|
|
5
|
+
}
|
|
6
|
+
/** What is registered, for tests and the Protokoll page later. */
|
|
7
|
+
export function outsideReaches() {
|
|
8
|
+
return reaches;
|
|
9
|
+
}
|