@eloxiv/kernel 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/AccountMail.d.ts +40 -0
- package/dist/AccountMail.d.ts.map +1 -0
- package/dist/AccountMail.js +169 -0
- package/dist/AccountMail.js.map +1 -0
- package/dist/AppConfig.d.ts +72 -0
- package/dist/AppConfig.d.ts.map +1 -0
- package/dist/AppConfig.js +87 -0
- package/dist/AppConfig.js.map +1 -0
- package/dist/Approvals.d.ts +132 -0
- package/dist/Approvals.d.ts.map +1 -0
- package/dist/Approvals.js +342 -0
- package/dist/Approvals.js.map +1 -0
- package/dist/Audit.d.ts +93 -0
- package/dist/Audit.d.ts.map +1 -0
- package/dist/Audit.js +275 -0
- package/dist/Audit.js.map +1 -0
- package/dist/AuthSeam.d.ts +58 -0
- package/dist/AuthSeam.d.ts.map +1 -0
- package/dist/AuthSeam.js +101 -0
- package/dist/AuthSeam.js.map +1 -0
- package/dist/Authority.d.ts +160 -0
- package/dist/Authority.d.ts.map +1 -0
- package/dist/Authority.js +325 -0
- package/dist/Authority.js.map +1 -0
- package/dist/Avatars.d.ts +26 -0
- package/dist/Avatars.d.ts.map +1 -0
- package/dist/Avatars.js +140 -0
- package/dist/Avatars.js.map +1 -0
- package/dist/Base64url.d.ts +9 -0
- package/dist/Base64url.d.ts.map +1 -0
- package/dist/Base64url.js +26 -0
- package/dist/Base64url.js.map +1 -0
- package/dist/BasePath.d.ts +39 -0
- package/dist/BasePath.d.ts.map +1 -0
- package/dist/BasePath.js +70 -0
- package/dist/BasePath.js.map +1 -0
- package/dist/CallActed.d.ts +10 -0
- package/dist/CallActed.d.ts.map +1 -0
- package/dist/CallActed.js +10 -0
- package/dist/CallActed.js.map +1 -0
- package/dist/Config.d.ts +459 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +415 -0
- package/dist/Config.js.map +1 -0
- package/dist/DeliveryPolicy.d.ts +20 -0
- package/dist/DeliveryPolicy.d.ts.map +1 -0
- package/dist/DeliveryPolicy.js +35 -0
- package/dist/DeliveryPolicy.js.map +1 -0
- package/dist/DesktopSignIn.d.ts +24 -0
- package/dist/DesktopSignIn.d.ts.map +1 -0
- package/dist/DesktopSignIn.js +148 -0
- package/dist/DesktopSignIn.js.map +1 -0
- package/dist/Directory.d.ts +179 -0
- package/dist/Directory.d.ts.map +1 -0
- package/dist/Directory.js +1184 -0
- package/dist/Directory.js.map +1 -0
- package/dist/Flags.d.ts +59 -0
- package/dist/Flags.d.ts.map +1 -0
- package/dist/Flags.js +195 -0
- package/dist/Flags.js.map +1 -0
- package/dist/Gate.d.ts +42 -0
- package/dist/Gate.d.ts.map +1 -0
- package/dist/Gate.js +132 -0
- package/dist/Gate.js.map +1 -0
- package/dist/Hash.d.ts +4 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +16 -0
- package/dist/Hash.js.map +1 -0
- package/dist/Identity.d.ts +327 -0
- package/dist/Identity.d.ts.map +1 -0
- package/dist/Identity.js +1232 -0
- package/dist/Identity.js.map +1 -0
- package/dist/IntervalJob.d.ts +40 -0
- package/dist/IntervalJob.d.ts.map +1 -0
- package/dist/IntervalJob.js +76 -0
- package/dist/IntervalJob.js.map +1 -0
- package/dist/Invocation.d.ts +210 -0
- package/dist/Invocation.d.ts.map +1 -0
- package/dist/Invocation.js +1680 -0
- package/dist/Invocation.js.map +1 -0
- package/dist/KernelHandlers.d.ts +19 -0
- package/dist/KernelHandlers.d.ts.map +1 -0
- package/dist/KernelHandlers.js +15 -0
- package/dist/KernelHandlers.js.map +1 -0
- package/dist/KernelModule.d.ts +65 -0
- package/dist/KernelModule.d.ts.map +1 -0
- package/dist/KernelModule.js +116 -0
- package/dist/KernelModule.js.map +1 -0
- package/dist/MemberRoutes.d.ts +6 -0
- package/dist/MemberRoutes.d.ts.map +1 -0
- package/dist/MemberRoutes.js +107 -0
- package/dist/MemberRoutes.js.map +1 -0
- package/dist/Module.d.ts +479 -0
- package/dist/Module.d.ts.map +1 -0
- package/dist/Module.js +30 -0
- package/dist/Module.js.map +1 -0
- package/dist/ModuleIdentity.d.ts +17 -0
- package/dist/ModuleIdentity.d.ts.map +1 -0
- package/dist/ModuleIdentity.js +106 -0
- package/dist/ModuleIdentity.js.map +1 -0
- package/dist/Notifications.d.ts +107 -0
- package/dist/Notifications.d.ts.map +1 -0
- package/dist/Notifications.js +475 -0
- package/dist/Notifications.js.map +1 -0
- package/dist/Outbox.d.ts +146 -0
- package/dist/Outbox.d.ts.map +1 -0
- package/dist/Outbox.js +518 -0
- package/dist/Outbox.js.map +1 -0
- package/dist/Privacy.d.ts +50 -0
- package/dist/Privacy.d.ts.map +1 -0
- package/dist/Privacy.js +167 -0
- package/dist/Privacy.js.map +1 -0
- package/dist/Progress.d.ts +42 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Progress.js +215 -0
- package/dist/Progress.js.map +1 -0
- package/dist/QuerySurface.d.ts +73 -0
- package/dist/QuerySurface.d.ts.map +1 -0
- package/dist/QuerySurface.js +440 -0
- package/dist/QuerySurface.js.map +1 -0
- package/dist/QueryViews.d.ts +70 -0
- package/dist/QueryViews.d.ts.map +1 -0
- package/dist/QueryViews.js +94 -0
- package/dist/QueryViews.js.map +1 -0
- package/dist/Readiness.d.ts +40 -0
- package/dist/Readiness.d.ts.map +1 -0
- package/dist/Readiness.js +203 -0
- package/dist/Readiness.js.map +1 -0
- package/dist/Redact.d.ts +11 -0
- package/dist/Redact.d.ts.map +1 -0
- package/dist/Redact.js +21 -0
- package/dist/Redact.js.map +1 -0
- package/dist/Registry.d.ts +117 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +297 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Release.d.ts +205 -0
- package/dist/Release.d.ts.map +1 -0
- package/dist/Release.js +880 -0
- package/dist/Release.js.map +1 -0
- package/dist/Retention.d.ts +43 -0
- package/dist/Retention.d.ts.map +1 -0
- package/dist/Retention.js +124 -0
- package/dist/Retention.js.map +1 -0
- package/dist/Scheduler.d.ts +56 -0
- package/dist/Scheduler.d.ts.map +1 -0
- package/dist/Scheduler.js +470 -0
- package/dist/Scheduler.js.map +1 -0
- package/dist/Server.d.ts +341 -0
- package/dist/Server.d.ts.map +1 -0
- package/dist/Server.js +1106 -0
- package/dist/Server.js.map +1 -0
- package/dist/Sessions.d.ts +38 -0
- package/dist/Sessions.d.ts.map +1 -0
- package/dist/Sessions.js +45 -0
- package/dist/Sessions.js.map +1 -0
- package/dist/Settings.d.ts +63 -0
- package/dist/Settings.d.ts.map +1 -0
- package/dist/Settings.js +219 -0
- package/dist/Settings.js.map +1 -0
- package/dist/Sharing.d.ts +99 -0
- package/dist/Sharing.d.ts.map +1 -0
- package/dist/Sharing.js +315 -0
- package/dist/Sharing.js.map +1 -0
- package/dist/Sync.d.ts +188 -0
- package/dist/Sync.d.ts.map +1 -0
- package/dist/Sync.js +1100 -0
- package/dist/Sync.js.map +1 -0
- package/dist/Telemetry.d.ts +154 -0
- package/dist/Telemetry.d.ts.map +1 -0
- package/dist/Telemetry.js +536 -0
- package/dist/Telemetry.js.map +1 -0
- package/dist/Versioning.d.ts +98 -0
- package/dist/Versioning.d.ts.map +1 -0
- package/dist/Versioning.js +387 -0
- package/dist/Versioning.js.map +1 -0
- package/dist/WorkItems.d.ts +67 -0
- package/dist/WorkItems.d.ts.map +1 -0
- package/dist/WorkItems.js +211 -0
- package/dist/WorkItems.js.map +1 -0
- package/dist/Workflows.d.ts +78 -0
- package/dist/Workflows.d.ts.map +1 -0
- package/dist/Workflows.js +478 -0
- package/dist/Workflows.js.map +1 -0
- package/dist/agent/Admission.d.ts +22 -0
- package/dist/agent/Admission.d.ts.map +1 -0
- package/dist/agent/Admission.js +34 -0
- package/dist/agent/Admission.js.map +1 -0
- package/dist/agent/Channels.d.ts +15 -0
- package/dist/agent/Channels.d.ts.map +1 -0
- package/dist/agent/Channels.js +50 -0
- package/dist/agent/Channels.js.map +1 -0
- package/dist/agent/Context.d.ts +73 -0
- package/dist/agent/Context.d.ts.map +1 -0
- package/dist/agent/Context.js +338 -0
- package/dist/agent/Context.js.map +1 -0
- package/dist/agent/Http.d.ts +18 -0
- package/dist/agent/Http.d.ts.map +1 -0
- package/dist/agent/Http.js +410 -0
- package/dist/agent/Http.js.map +1 -0
- package/dist/agent/Metering.d.ts +162 -0
- package/dist/agent/Metering.d.ts.map +1 -0
- package/dist/agent/Metering.js +315 -0
- package/dist/agent/Metering.js.map +1 -0
- package/dist/agent/ModelSetup.d.ts +10 -0
- package/dist/agent/ModelSetup.d.ts.map +1 -0
- package/dist/agent/ModelSetup.js +331 -0
- package/dist/agent/ModelSetup.js.map +1 -0
- package/dist/agent/Models.d.ts +197 -0
- package/dist/agent/Models.d.ts.map +1 -0
- package/dist/agent/Models.js +489 -0
- package/dist/agent/Models.js.map +1 -0
- package/dist/agent/Processors.d.ts +102 -0
- package/dist/agent/Processors.d.ts.map +1 -0
- package/dist/agent/Processors.js +80 -0
- package/dist/agent/Processors.js.map +1 -0
- package/dist/agent/Queue.d.ts +21 -0
- package/dist/agent/Queue.d.ts.map +1 -0
- package/dist/agent/Queue.js +64 -0
- package/dist/agent/Queue.js.map +1 -0
- package/dist/agent/Receipts.d.ts +41 -0
- package/dist/agent/Receipts.d.ts.map +1 -0
- package/dist/agent/Receipts.js +142 -0
- package/dist/agent/Receipts.js.map +1 -0
- package/dist/agent/Resources.d.ts +68 -0
- package/dist/agent/Resources.d.ts.map +1 -0
- package/dist/agent/Resources.js +207 -0
- package/dist/agent/Resources.js.map +1 -0
- package/dist/agent/Run.d.ts +178 -0
- package/dist/agent/Run.d.ts.map +1 -0
- package/dist/agent/Run.js +2896 -0
- package/dist/agent/Run.js.map +1 -0
- package/dist/agent/Runtime.d.ts +79 -0
- package/dist/agent/Runtime.d.ts.map +1 -0
- package/dist/agent/Runtime.js +366 -0
- package/dist/agent/Runtime.js.map +1 -0
- package/dist/agent/Settings.d.ts +126 -0
- package/dist/agent/Settings.d.ts.map +1 -0
- package/dist/agent/Settings.js +44 -0
- package/dist/agent/Settings.js.map +1 -0
- package/dist/agent/Skills.d.ts +73 -0
- package/dist/agent/Skills.d.ts.map +1 -0
- package/dist/agent/Skills.js +95 -0
- package/dist/agent/Skills.js.map +1 -0
- package/dist/agent/Store.d.ts +37 -0
- package/dist/agent/Store.d.ts.map +1 -0
- package/dist/agent/Store.js +50 -0
- package/dist/agent/Store.js.map +1 -0
- package/dist/agent/ToolSearch.d.ts +37 -0
- package/dist/agent/ToolSearch.d.ts.map +1 -0
- package/dist/agent/ToolSearch.js +119 -0
- package/dist/agent/ToolSearch.js.map +1 -0
- package/dist/agent/index.d.ts +37 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +44 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/module.d.ts +12889 -0
- package/dist/agent/module.d.ts.map +1 -0
- package/dist/agent/module.js +1550 -0
- package/dist/agent/module.js.map +1 -0
- package/dist/appState/Sweep.d.ts +21 -0
- package/dist/appState/Sweep.d.ts.map +1 -0
- package/dist/appState/Sweep.js +46 -0
- package/dist/appState/Sweep.js.map +1 -0
- package/dist/appState/module.d.ts +1710 -0
- package/dist/appState/module.d.ts.map +1 -0
- package/dist/appState/module.js +344 -0
- package/dist/appState/module.js.map +1 -0
- package/dist/audit/module.d.ts +158 -0
- package/dist/audit/module.d.ts.map +1 -0
- package/dist/audit/module.js +72 -0
- package/dist/audit/module.js.map +1 -0
- package/dist/auth/AuthProvider.d.ts +224 -0
- package/dist/auth/AuthProvider.d.ts.map +1 -0
- package/dist/auth/AuthProvider.js +104 -0
- package/dist/auth/AuthProvider.js.map +1 -0
- package/dist/auth/BetterAuthProvider.d.ts +40 -0
- package/dist/auth/BetterAuthProvider.d.ts.map +1 -0
- package/dist/auth/BetterAuthProvider.js +458 -0
- package/dist/auth/BetterAuthProvider.js.map +1 -0
- package/dist/auth/Methods.d.ts +7 -0
- package/dist/auth/Methods.d.ts.map +1 -0
- package/dist/auth/Methods.js +7 -0
- package/dist/auth/Methods.js.map +1 -0
- package/dist/auth/SessionTokens.d.ts +23 -0
- package/dist/auth/SessionTokens.d.ts.map +1 -0
- package/dist/auth/SessionTokens.js +150 -0
- package/dist/auth/SessionTokens.js.map +1 -0
- package/dist/collab/Collab.d.ts +105 -0
- package/dist/collab/Collab.d.ts.map +1 -0
- package/dist/collab/Collab.js +475 -0
- package/dist/collab/Collab.js.map +1 -0
- package/dist/collab/Housekeeping.d.ts +38 -0
- package/dist/collab/Housekeeping.d.ts.map +1 -0
- package/dist/collab/Housekeeping.js +146 -0
- package/dist/collab/Housekeeping.js.map +1 -0
- package/dist/collab/LiveCopy.d.ts +7 -0
- package/dist/collab/LiveCopy.d.ts.map +1 -0
- package/dist/collab/LiveCopy.js +79 -0
- package/dist/collab/LiveCopy.js.map +1 -0
- package/dist/collab/Socket.d.ts +19 -0
- package/dist/collab/Socket.d.ts.map +1 -0
- package/dist/collab/Socket.js +323 -0
- package/dist/collab/Socket.js.map +1 -0
- package/dist/collab/Store.d.ts +42 -0
- package/dist/collab/Store.d.ts.map +1 -0
- package/dist/collab/Store.js +59 -0
- package/dist/collab/Store.js.map +1 -0
- package/dist/collab/Ydoc.d.ts +88 -0
- package/dist/collab/Ydoc.d.ts.map +1 -0
- package/dist/collab/Ydoc.js +314 -0
- package/dist/collab/Ydoc.js.map +1 -0
- package/dist/collab/derive/bundle.gen.d.ts +2 -0
- package/dist/collab/derive/bundle.gen.d.ts.map +1 -0
- package/dist/collab/derive/bundle.gen.js +3 -0
- package/dist/collab/derive/bundle.gen.js.map +1 -0
- package/dist/collab/derive/entry.d.ts +3 -0
- package/dist/collab/derive/entry.d.ts.map +1 -0
- package/dist/collab/derive/entry.js +35 -0
- package/dist/collab/derive/entry.js.map +1 -0
- package/dist/collab/derive/polyfill.d.ts +3 -0
- package/dist/collab/derive/polyfill.d.ts.map +1 -0
- package/dist/collab/derive/polyfill.js +17 -0
- package/dist/collab/derive/polyfill.js.map +1 -0
- package/dist/collab/module.d.ts +305 -0
- package/dist/collab/module.d.ts.map +1 -0
- package/dist/collab/module.js +161 -0
- package/dist/collab/module.js.map +1 -0
- package/dist/connections/Connections.d.ts +199 -0
- package/dist/connections/Connections.d.ts.map +1 -0
- package/dist/connections/Connections.js +1633 -0
- package/dist/connections/Connections.js.map +1 -0
- package/dist/connections/Connector.d.ts +213 -0
- package/dist/connections/Connector.d.ts.map +1 -0
- package/dist/connections/Connector.js +55 -0
- package/dist/connections/Connector.js.map +1 -0
- package/dist/connections/Crypto.d.ts +55 -0
- package/dist/connections/Crypto.d.ts.map +1 -0
- package/dist/connections/Crypto.js +100 -0
- package/dist/connections/Crypto.js.map +1 -0
- package/dist/connections/Destinations.d.ts +63 -0
- package/dist/connections/Destinations.d.ts.map +1 -0
- package/dist/connections/Destinations.js +338 -0
- package/dist/connections/Destinations.js.map +1 -0
- package/dist/connections/Discovery.d.ts +53 -0
- package/dist/connections/Discovery.d.ts.map +1 -0
- package/dist/connections/Discovery.js +209 -0
- package/dist/connections/Discovery.js.map +1 -0
- package/dist/connections/EffectKinds.d.ts +17 -0
- package/dist/connections/EffectKinds.d.ts.map +1 -0
- package/dist/connections/EffectKinds.js +26 -0
- package/dist/connections/EffectKinds.js.map +1 -0
- package/dist/connections/Effects.d.ts +49 -0
- package/dist/connections/Effects.d.ts.map +1 -0
- package/dist/connections/Effects.js +347 -0
- package/dist/connections/Effects.js.map +1 -0
- package/dist/connections/Metering.d.ts +40 -0
- package/dist/connections/Metering.d.ts.map +1 -0
- package/dist/connections/Metering.js +142 -0
- package/dist/connections/Metering.js.map +1 -0
- package/dist/connections/ProviderApi.d.ts +47 -0
- package/dist/connections/ProviderApi.d.ts.map +1 -0
- package/dist/connections/ProviderApi.js +103 -0
- package/dist/connections/ProviderApi.js.map +1 -0
- package/dist/connections/Secrets.d.ts +78 -0
- package/dist/connections/Secrets.d.ts.map +1 -0
- package/dist/connections/Secrets.js +342 -0
- package/dist/connections/Secrets.js.map +1 -0
- package/dist/connections/Sync.d.ts +85 -0
- package/dist/connections/Sync.d.ts.map +1 -0
- package/dist/connections/Sync.js +201 -0
- package/dist/connections/Sync.js.map +1 -0
- package/dist/connections/module.d.ts +1061 -0
- package/dist/connections/module.d.ts.map +1 -0
- package/dist/connections/module.js +485 -0
- package/dist/connections/module.js.map +1 -0
- package/dist/data/Corpus.d.ts +79 -0
- package/dist/data/Corpus.d.ts.map +1 -0
- package/dist/data/Corpus.js +343 -0
- package/dist/data/Corpus.js.map +1 -0
- package/dist/data/Datasets.d.ts +88 -0
- package/dist/data/Datasets.d.ts.map +1 -0
- package/dist/data/Datasets.js +375 -0
- package/dist/data/Datasets.js.map +1 -0
- package/dist/data/Programs.d.ts +58 -0
- package/dist/data/Programs.d.ts.map +1 -0
- package/dist/data/Programs.js +197 -0
- package/dist/data/Programs.js.map +1 -0
- package/dist/data/module.d.ts +210 -0
- package/dist/data/module.d.ts.map +1 -0
- package/dist/data/module.js +140 -0
- package/dist/data/module.js.map +1 -0
- package/dist/db/Bootstrap.d.ts +508 -0
- package/dist/db/Bootstrap.d.ts.map +1 -0
- package/dist/db/Bootstrap.js +2368 -0
- package/dist/db/Bootstrap.js.map +1 -0
- package/dist/db/Catalog.d.ts +10 -0
- package/dist/db/Catalog.d.ts.map +1 -0
- package/dist/db/Catalog.js +9 -0
- package/dist/db/Catalog.js.map +1 -0
- package/dist/db/Conflicts.d.ts +18 -0
- package/dist/db/Conflicts.d.ts.map +1 -0
- package/dist/db/Conflicts.js +29 -0
- package/dist/db/Conflicts.js.map +1 -0
- package/dist/db/DirectoryLock.d.ts +16 -0
- package/dist/db/DirectoryLock.d.ts.map +1 -0
- package/dist/db/DirectoryLock.js +15 -0
- package/dist/db/DirectoryLock.js.map +1 -0
- package/dist/db/HandlerGate.d.ts +28 -0
- package/dist/db/HandlerGate.d.ts.map +1 -0
- package/dist/db/HandlerGate.js +76 -0
- package/dist/db/HandlerGate.js.map +1 -0
- package/dist/db/Host.d.ts +94 -0
- package/dist/db/Host.d.ts.map +1 -0
- package/dist/db/Host.js +189 -0
- package/dist/db/Host.js.map +1 -0
- package/dist/db/KernelSchema.d.ts +52 -0
- package/dist/db/KernelSchema.d.ts.map +1 -0
- package/dist/db/KernelSchema.js +4313 -0
- package/dist/db/KernelSchema.js.map +1 -0
- package/dist/db/MigrationCheck.d.ts +38 -0
- package/dist/db/MigrationCheck.d.ts.map +1 -0
- package/dist/db/MigrationCheck.js +180 -0
- package/dist/db/MigrationCheck.js.map +1 -0
- package/dist/db/QueryViewCheck.d.ts +172 -0
- package/dist/db/QueryViewCheck.d.ts.map +1 -0
- package/dist/db/QueryViewCheck.js +967 -0
- package/dist/db/QueryViewCheck.js.map +1 -0
- package/dist/db/ReadOnly.d.ts +13 -0
- package/dist/db/ReadOnly.d.ts.map +1 -0
- package/dist/db/ReadOnly.js +16 -0
- package/dist/db/ReadOnly.js.map +1 -0
- package/dist/db/Scram.d.ts +5 -0
- package/dist/db/Scram.d.ts.map +1 -0
- package/dist/db/Scram.js +17 -0
- package/dist/db/Scram.js.map +1 -0
- package/dist/db/SqlState.d.ts +36 -0
- package/dist/db/SqlState.d.ts.map +1 -0
- package/dist/db/SqlState.js +64 -0
- package/dist/db/SqlState.js.map +1 -0
- package/dist/db/Startup.d.ts +18 -0
- package/dist/db/Startup.d.ts.map +1 -0
- package/dist/db/Startup.js +22 -0
- package/dist/db/Startup.js.map +1 -0
- package/dist/db/ZeroDdl.d.ts +85 -0
- package/dist/db/ZeroDdl.d.ts.map +1 -0
- package/dist/db/ZeroDdl.js +240 -0
- package/dist/db/ZeroDdl.js.map +1 -0
- package/dist/db/ZeroPush.d.ts +7 -0
- package/dist/db/ZeroPush.d.ts.map +1 -0
- package/dist/db/ZeroPush.js +126 -0
- package/dist/db/ZeroPush.js.map +1 -0
- package/dist/devices/Devices.d.ts +130 -0
- package/dist/devices/Devices.d.ts.map +1 -0
- package/dist/devices/Devices.js +769 -0
- package/dist/devices/Devices.js.map +1 -0
- package/dist/devices/Flow.d.ts +47 -0
- package/dist/devices/Flow.d.ts.map +1 -0
- package/dist/devices/Flow.js +131 -0
- package/dist/devices/Flow.js.map +1 -0
- package/dist/devices/Http.d.ts +6 -0
- package/dist/devices/Http.d.ts.map +1 -0
- package/dist/devices/Http.js +103 -0
- package/dist/devices/Http.js.map +1 -0
- package/dist/devices/module.d.ts +1313 -0
- package/dist/devices/module.d.ts.map +1 -0
- package/dist/devices/module.js +266 -0
- package/dist/devices/module.js.map +1 -0
- package/dist/durable/Cluster.d.ts +13 -0
- package/dist/durable/Cluster.d.ts.map +1 -0
- package/dist/durable/Cluster.js +57 -0
- package/dist/durable/Cluster.js.map +1 -0
- package/dist/durable/Definition.d.ts +215 -0
- package/dist/durable/Definition.d.ts.map +1 -0
- package/dist/durable/Definition.js +18 -0
- package/dist/durable/Definition.js.map +1 -0
- package/dist/durable/Schedule.d.ts +46 -0
- package/dist/durable/Schedule.d.ts.map +1 -0
- package/dist/durable/Schedule.js +120 -0
- package/dist/durable/Schedule.js.map +1 -0
- package/dist/durable/Trust.d.ts +90 -0
- package/dist/durable/Trust.d.ts.map +1 -0
- package/dist/durable/Trust.js +61 -0
- package/dist/durable/Trust.js.map +1 -0
- package/dist/enterprise/Routes.d.ts +32 -0
- package/dist/enterprise/Routes.d.ts.map +1 -0
- package/dist/enterprise/Routes.js +448 -0
- package/dist/enterprise/Routes.js.map +1 -0
- package/dist/enterprise/WorkOs.d.ts +42 -0
- package/dist/enterprise/WorkOs.d.ts.map +1 -0
- package/dist/enterprise/WorkOs.js +109 -0
- package/dist/enterprise/WorkOs.js.map +1 -0
- package/dist/files/FileTable.d.ts +937 -0
- package/dist/files/FileTable.d.ts.map +1 -0
- package/dist/files/FileTable.js +79 -0
- package/dist/files/FileTable.js.map +1 -0
- package/dist/files/Files.d.ts +169 -0
- package/dist/files/Files.d.ts.map +1 -0
- package/dist/files/Files.js +1232 -0
- package/dist/files/Files.js.map +1 -0
- package/dist/files/Http.d.ts +13 -0
- package/dist/files/Http.d.ts.map +1 -0
- package/dist/files/Http.js +30 -0
- package/dist/files/Http.js.map +1 -0
- package/dist/files/LocalStorage.d.ts +7 -0
- package/dist/files/LocalStorage.d.ts.map +1 -0
- package/dist/files/LocalStorage.js +284 -0
- package/dist/files/LocalStorage.js.map +1 -0
- package/dist/files/Providers.d.ts +64 -0
- package/dist/files/Providers.d.ts.map +1 -0
- package/dist/files/Providers.js +245 -0
- package/dist/files/Providers.js.map +1 -0
- package/dist/files/S3Storage.d.ts +27 -0
- package/dist/files/S3Storage.d.ts.map +1 -0
- package/dist/files/S3Storage.js +301 -0
- package/dist/files/S3Storage.js.map +1 -0
- package/dist/files/SigV4.d.ts +65 -0
- package/dist/files/SigV4.d.ts.map +1 -0
- package/dist/files/SigV4.js +152 -0
- package/dist/files/SigV4.js.map +1 -0
- package/dist/files/Sniff.d.ts +50 -0
- package/dist/files/Sniff.d.ts.map +1 -0
- package/dist/files/Sniff.js +223 -0
- package/dist/files/Sniff.js.map +1 -0
- package/dist/files/Storage.d.ts +75 -0
- package/dist/files/Storage.d.ts.map +1 -0
- package/dist/files/Storage.js +70 -0
- package/dist/files/Storage.js.map +1 -0
- package/dist/files/module.d.ts +666 -0
- package/dist/files/module.d.ts.map +1 -0
- package/dist/files/module.js +217 -0
- package/dist/files/module.js.map +1 -0
- package/dist/flags/module.d.ts +966 -0
- package/dist/flags/module.d.ts.map +1 -0
- package/dist/flags/module.js +146 -0
- package/dist/flags/module.js.map +1 -0
- package/dist/inbox/Flow.d.ts +49 -0
- package/dist/inbox/Flow.d.ts.map +1 -0
- package/dist/inbox/Flow.js +425 -0
- package/dist/inbox/Flow.js.map +1 -0
- package/dist/inbox/System.d.ts +11 -0
- package/dist/inbox/System.d.ts.map +1 -0
- package/dist/inbox/System.js +26 -0
- package/dist/inbox/System.js.map +1 -0
- package/dist/inbox/approvals.d.ts +1548 -0
- package/dist/inbox/approvals.d.ts.map +1 -0
- package/dist/inbox/approvals.js +268 -0
- package/dist/inbox/approvals.js.map +1 -0
- package/dist/inbox/consent.d.ts +1213 -0
- package/dist/inbox/consent.d.ts.map +1 -0
- package/dist/inbox/consent.js +281 -0
- package/dist/inbox/consent.js.map +1 -0
- package/dist/inbox/index.d.ts +2231 -0
- package/dist/inbox/index.d.ts.map +1 -0
- package/dist/inbox/index.js +22 -0
- package/dist/inbox/index.js.map +1 -0
- package/dist/inbox/notifications.d.ts +2743 -0
- package/dist/inbox/notifications.d.ts.map +1 -0
- package/dist/inbox/notifications.js +362 -0
- package/dist/inbox/notifications.js.map +1 -0
- package/dist/inbox/tables.d.ts +1992 -0
- package/dist/inbox/tables.d.ts.map +1 -0
- package/dist/inbox/tables.js +149 -0
- package/dist/inbox/tables.js.map +1 -0
- package/dist/inbox/workItems.d.ts +1188 -0
- package/dist/inbox/workItems.d.ts.map +1 -0
- package/dist/inbox/workItems.js +158 -0
- package/dist/inbox/workItems.js.map +1 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/ingestion/Chunk.d.ts +15 -0
- package/dist/ingestion/Chunk.d.ts.map +1 -0
- package/dist/ingestion/Chunk.js +49 -0
- package/dist/ingestion/Chunk.js.map +1 -0
- package/dist/ingestion/Extract.d.ts +69 -0
- package/dist/ingestion/Extract.d.ts.map +1 -0
- package/dist/ingestion/Extract.js +376 -0
- package/dist/ingestion/Extract.js.map +1 -0
- package/dist/ingestion/ExtractChild.d.ts +2 -0
- package/dist/ingestion/ExtractChild.d.ts.map +1 -0
- package/dist/ingestion/ExtractChild.js +54 -0
- package/dist/ingestion/ExtractChild.js.map +1 -0
- package/dist/ingestion/ExtractPool.d.ts +38 -0
- package/dist/ingestion/ExtractPool.d.ts.map +1 -0
- package/dist/ingestion/ExtractPool.js +203 -0
- package/dist/ingestion/ExtractPool.js.map +1 -0
- package/dist/ingestion/Ingestion.d.ts +183 -0
- package/dist/ingestion/Ingestion.d.ts.map +1 -0
- package/dist/ingestion/Ingestion.js +650 -0
- package/dist/ingestion/Ingestion.js.map +1 -0
- package/dist/ingestion/Isolated.d.ts +18 -0
- package/dist/ingestion/Isolated.d.ts.map +1 -0
- package/dist/ingestion/Isolated.js +15 -0
- package/dist/ingestion/Isolated.js.map +1 -0
- package/dist/ingestion/Markup.d.ts +29 -0
- package/dist/ingestion/Markup.d.ts.map +1 -0
- package/dist/ingestion/Markup.js +111 -0
- package/dist/ingestion/Markup.js.map +1 -0
- package/dist/ingestion/Pdf.d.ts +6 -0
- package/dist/ingestion/Pdf.d.ts.map +1 -0
- package/dist/ingestion/Pdf.js +192 -0
- package/dist/ingestion/Pdf.js.map +1 -0
- package/dist/ingestion/Runs.d.ts +59 -0
- package/dist/ingestion/Runs.d.ts.map +1 -0
- package/dist/ingestion/Runs.js +128 -0
- package/dist/ingestion/Runs.js.map +1 -0
- package/dist/ingestion/Scrub.d.ts +16 -0
- package/dist/ingestion/Scrub.d.ts.map +1 -0
- package/dist/ingestion/Scrub.js +15 -0
- package/dist/ingestion/Scrub.js.map +1 -0
- package/dist/ingestion/Zip.d.ts +19 -0
- package/dist/ingestion/Zip.d.ts.map +1 -0
- package/dist/ingestion/Zip.js +85 -0
- package/dist/ingestion/Zip.js.map +1 -0
- package/dist/ingestion/module.d.ts +111 -0
- package/dist/ingestion/module.d.ts.map +1 -0
- package/dist/ingestion/module.js +51 -0
- package/dist/ingestion/module.js.map +1 -0
- package/dist/ingress/Definition.d.ts +146 -0
- package/dist/ingress/Definition.d.ts.map +1 -0
- package/dist/ingress/Definition.js +12 -0
- package/dist/ingress/Definition.js.map +1 -0
- package/dist/ingress/Ingress.d.ts +61 -0
- package/dist/ingress/Ingress.d.ts.map +1 -0
- package/dist/ingress/Ingress.js +929 -0
- package/dist/ingress/Ingress.js.map +1 -0
- package/dist/ingress/Verifiers.d.ts +43 -0
- package/dist/ingress/Verifiers.d.ts.map +1 -0
- package/dist/ingress/Verifiers.js +137 -0
- package/dist/ingress/Verifiers.js.map +1 -0
- package/dist/machine/MachineIdentity.d.ts +34 -0
- package/dist/machine/MachineIdentity.d.ts.map +1 -0
- package/dist/machine/MachineIdentity.js +200 -0
- package/dist/machine/MachineIdentity.js.map +1 -0
- package/dist/machine/Managed.d.ts +40 -0
- package/dist/machine/Managed.d.ts.map +1 -0
- package/dist/machine/Managed.js +163 -0
- package/dist/machine/Managed.js.map +1 -0
- package/dist/machine/OAuth.d.ts +11 -0
- package/dist/machine/OAuth.d.ts.map +1 -0
- package/dist/machine/OAuth.js +913 -0
- package/dist/machine/OAuth.js.map +1 -0
- package/dist/machine/Pages.d.ts +64 -0
- package/dist/machine/Pages.d.ts.map +1 -0
- package/dist/machine/Pages.js +54 -0
- package/dist/machine/Pages.js.map +1 -0
- package/dist/machine/Tokens.d.ts +25 -0
- package/dist/machine/Tokens.d.ts.map +1 -0
- package/dist/machine/Tokens.js +62 -0
- package/dist/machine/Tokens.js.map +1 -0
- package/dist/make/Credentials.d.ts +8 -0
- package/dist/make/Credentials.d.ts.map +1 -0
- package/dist/make/Credentials.js +29 -0
- package/dist/make/Credentials.js.map +1 -0
- package/dist/make/Example.d.ts +159 -0
- package/dist/make/Example.d.ts.map +1 -0
- package/dist/make/Example.js +94 -0
- package/dist/make/Example.js.map +1 -0
- package/dist/make/Execute.d.ts +151 -0
- package/dist/make/Execute.d.ts.map +1 -0
- package/dist/make/Execute.js +316 -0
- package/dist/make/Execute.js.map +1 -0
- package/dist/make/Http.d.ts +17 -0
- package/dist/make/Http.d.ts.map +1 -0
- package/dist/make/Http.js +63 -0
- package/dist/make/Http.js.map +1 -0
- package/dist/make/Lifecycle.d.ts +167 -0
- package/dist/make/Lifecycle.d.ts.map +1 -0
- package/dist/make/Lifecycle.js +580 -0
- package/dist/make/Lifecycle.js.map +1 -0
- package/dist/make/Manifest.d.ts +61 -0
- package/dist/make/Manifest.d.ts.map +1 -0
- package/dist/make/Manifest.js +792 -0
- package/dist/make/Manifest.js.map +1 -0
- package/dist/make/Repair.d.ts +111 -0
- package/dist/make/Repair.d.ts.map +1 -0
- package/dist/make/Repair.js +236 -0
- package/dist/make/Repair.js.map +1 -0
- package/dist/make/Runtime.d.ts +144 -0
- package/dist/make/Runtime.d.ts.map +1 -0
- package/dist/make/Runtime.js +309 -0
- package/dist/make/Runtime.js.map +1 -0
- package/dist/make/Session.d.ts +19 -0
- package/dist/make/Session.d.ts.map +1 -0
- package/dist/make/Session.js +27 -0
- package/dist/make/Session.js.map +1 -0
- package/dist/make/SqlGuard.d.ts +48 -0
- package/dist/make/SqlGuard.d.ts.map +1 -0
- package/dist/make/SqlGuard.js +333 -0
- package/dist/make/SqlGuard.js.map +1 -0
- package/dist/make/Subscribe.d.ts +18 -0
- package/dist/make/Subscribe.d.ts.map +1 -0
- package/dist/make/Subscribe.js +175 -0
- package/dist/make/Subscribe.js.map +1 -0
- package/dist/make/Validate.d.ts +47 -0
- package/dist/make/Validate.d.ts.map +1 -0
- package/dist/make/Validate.js +222 -0
- package/dist/make/Validate.js.map +1 -0
- package/dist/make/ViewStep.d.ts +27 -0
- package/dist/make/ViewStep.d.ts.map +1 -0
- package/dist/make/ViewStep.js +43 -0
- package/dist/make/ViewStep.js.map +1 -0
- package/dist/make/module.d.ts +808 -0
- package/dist/make/module.d.ts.map +1 -0
- package/dist/make/module.js +232 -0
- package/dist/make/module.js.map +1 -0
- package/dist/notifications/Decide.d.ts +29 -0
- package/dist/notifications/Decide.d.ts.map +1 -0
- package/dist/notifications/Decide.js +395 -0
- package/dist/notifications/Decide.js.map +1 -0
- package/dist/notifications/Providers.d.ts +110 -0
- package/dist/notifications/Providers.d.ts.map +1 -0
- package/dist/notifications/Providers.js +404 -0
- package/dist/notifications/Providers.js.map +1 -0
- package/dist/notifications/Push.d.ts +189 -0
- package/dist/notifications/Push.d.ts.map +1 -0
- package/dist/notifications/Push.js +457 -0
- package/dist/notifications/Push.js.map +1 -0
- package/dist/notifications/Smtp.d.ts +74 -0
- package/dist/notifications/Smtp.d.ts.map +1 -0
- package/dist/notifications/Smtp.js +344 -0
- package/dist/notifications/Smtp.js.map +1 -0
- package/dist/policy/CedarSchema.d.ts +47 -0
- package/dist/policy/CedarSchema.d.ts.map +1 -0
- package/dist/policy/CedarSchema.js +115 -0
- package/dist/policy/CedarSchema.js.map +1 -0
- package/dist/policy/Compiler.d.ts +364 -0
- package/dist/policy/Compiler.d.ts.map +1 -0
- package/dist/policy/Compiler.js +1311 -0
- package/dist/policy/Compiler.js.map +1 -0
- package/dist/policy/Policy.d.ts +70 -0
- package/dist/policy/Policy.d.ts.map +1 -0
- package/dist/policy/Policy.js +114 -0
- package/dist/policy/Policy.js.map +1 -0
- package/dist/policy/Rls.d.ts +110 -0
- package/dist/policy/Rls.d.ts.map +1 -0
- package/dist/policy/Rls.js +314 -0
- package/dist/policy/Rls.js.map +1 -0
- package/dist/policy/Row.d.ts +17 -0
- package/dist/policy/Row.d.ts.map +1 -0
- package/dist/policy/Row.js +3 -0
- package/dist/policy/Row.js.map +1 -0
- package/dist/privacy/Flow.d.ts +20 -0
- package/dist/privacy/Flow.d.ts.map +1 -0
- package/dist/privacy/Flow.js +193 -0
- package/dist/privacy/Flow.js.map +1 -0
- package/dist/privacy/Inventory.d.ts +110 -0
- package/dist/privacy/Inventory.d.ts.map +1 -0
- package/dist/privacy/Inventory.js +1704 -0
- package/dist/privacy/Inventory.js.map +1 -0
- package/dist/privacy/Sources.d.ts +86 -0
- package/dist/privacy/Sources.d.ts.map +1 -0
- package/dist/privacy/Sources.js +598 -0
- package/dist/privacy/Sources.js.map +1 -0
- package/dist/privacy/Visits.d.ts +21 -0
- package/dist/privacy/Visits.d.ts.map +1 -0
- package/dist/privacy/Visits.js +279 -0
- package/dist/privacy/Visits.js.map +1 -0
- package/dist/privacy/ZeroCvr.d.ts +15 -0
- package/dist/privacy/ZeroCvr.d.ts.map +1 -0
- package/dist/privacy/ZeroCvr.js +63 -0
- package/dist/privacy/ZeroCvr.js.map +1 -0
- package/dist/privacy/module.d.ts +2505 -0
- package/dist/privacy/module.d.ts.map +1 -0
- package/dist/privacy/module.js +228 -0
- package/dist/privacy/module.js.map +1 -0
- package/dist/progress/module.d.ts +1572 -0
- package/dist/progress/module.d.ts.map +1 -0
- package/dist/progress/module.js +139 -0
- package/dist/progress/module.js.map +1 -0
- package/dist/proposals/module.d.ts +275 -0
- package/dist/proposals/module.d.ts.map +1 -0
- package/dist/proposals/module.js +269 -0
- package/dist/proposals/module.js.map +1 -0
- package/dist/query/module.d.ts +91 -0
- package/dist/query/module.d.ts.map +1 -0
- package/dist/query/module.js +50 -0
- package/dist/query/module.js.map +1 -0
- package/dist/records/Access.d.ts +26 -0
- package/dist/records/Access.d.ts.map +1 -0
- package/dist/records/Access.js +43 -0
- package/dist/records/Access.js.map +1 -0
- package/dist/records/References.d.ts +18 -0
- package/dist/records/References.d.ts.map +1 -0
- package/dist/records/References.js +47 -0
- package/dist/records/References.js.map +1 -0
- package/dist/runtime/bun.d.ts +29 -0
- package/dist/runtime/bun.d.ts.map +1 -0
- package/dist/runtime/bun.js +71 -0
- package/dist/runtime/bun.js.map +1 -0
- package/dist/runtime/idle.d.ts +5 -0
- package/dist/runtime/idle.d.ts.map +1 -0
- package/dist/runtime/idle.js +61 -0
- package/dist/runtime/idle.js.map +1 -0
- package/dist/runtime/node.d.ts +36 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +86 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/runtime/resolve.d.ts +8 -0
- package/dist/runtime/resolve.d.ts.map +1 -0
- package/dist/runtime/resolve.js +136 -0
- package/dist/runtime/resolve.js.map +1 -0
- package/dist/sandbox/Sandbox.d.ts +86 -0
- package/dist/sandbox/Sandbox.d.ts.map +1 -0
- package/dist/sandbox/Sandbox.js +246 -0
- package/dist/sandbox/Sandbox.js.map +1 -0
- package/dist/sandbox/worker.d.ts +93 -0
- package/dist/sandbox/worker.d.ts.map +1 -0
- package/dist/sandbox/worker.js +503 -0
- package/dist/sandbox/worker.js.map +1 -0
- package/dist/scheduler/Automations.d.ts +99 -0
- package/dist/scheduler/Automations.d.ts.map +1 -0
- package/dist/scheduler/Automations.js +247 -0
- package/dist/scheduler/Automations.js.map +1 -0
- package/dist/scheduler/History.d.ts +61 -0
- package/dist/scheduler/History.d.ts.map +1 -0
- package/dist/scheduler/History.js +154 -0
- package/dist/scheduler/History.js.map +1 -0
- package/dist/scheduler/module.d.ts +2365 -0
- package/dist/scheduler/module.d.ts.map +1 -0
- package/dist/scheduler/module.js +370 -0
- package/dist/scheduler/module.js.map +1 -0
- package/dist/search/RecordLock.d.ts +22 -0
- package/dist/search/RecordLock.d.ts.map +1 -0
- package/dist/search/RecordLock.js +21 -0
- package/dist/search/RecordLock.js.map +1 -0
- package/dist/search/Search.d.ts +63 -0
- package/dist/search/Search.d.ts.map +1 -0
- package/dist/search/Search.js +424 -0
- package/dist/search/Search.js.map +1 -0
- package/dist/search/Sources.d.ts +56 -0
- package/dist/search/Sources.d.ts.map +1 -0
- package/dist/search/Sources.js +121 -0
- package/dist/search/Sources.js.map +1 -0
- package/dist/search/module.d.ts +72 -0
- package/dist/search/module.d.ts.map +1 -0
- package/dist/search/module.js +44 -0
- package/dist/search/module.js.map +1 -0
- package/dist/settings/module.d.ts +677 -0
- package/dist/settings/module.d.ts.map +1 -0
- package/dist/settings/module.js +103 -0
- package/dist/settings/module.js.map +1 -0
- package/dist/sharing/module.d.ts +1105 -0
- package/dist/sharing/module.d.ts.map +1 -0
- package/dist/sharing/module.js +295 -0
- package/dist/sharing/module.js.map +1 -0
- package/dist/spaces/module.d.ts +1787 -0
- package/dist/spaces/module.d.ts.map +1 -0
- package/dist/spaces/module.js +248 -0
- package/dist/spaces/module.js.map +1 -0
- package/dist/surfaces/Agent.d.ts +89 -0
- package/dist/surfaces/Agent.d.ts.map +1 -0
- package/dist/surfaces/Agent.js +112 -0
- package/dist/surfaces/Agent.js.map +1 -0
- package/dist/surfaces/CookieGuard.d.ts +77 -0
- package/dist/surfaces/CookieGuard.d.ts.map +1 -0
- package/dist/surfaces/CookieGuard.js +373 -0
- package/dist/surfaces/CookieGuard.js.map +1 -0
- package/dist/surfaces/Http.d.ts +15 -0
- package/dist/surfaces/Http.d.ts.map +1 -0
- package/dist/surfaces/Http.js +250 -0
- package/dist/surfaces/Http.js.map +1 -0
- package/dist/surfaces/Mcp.d.ts +90 -0
- package/dist/surfaces/Mcp.d.ts.map +1 -0
- package/dist/surfaces/Mcp.js +443 -0
- package/dist/surfaces/Mcp.js.map +1 -0
- package/dist/surfaces/Rpc.d.ts +15 -0
- package/dist/surfaces/Rpc.d.ts.map +1 -0
- package/dist/surfaces/Rpc.js +68 -0
- package/dist/surfaces/Rpc.js.map +1 -0
- package/dist/surfaces/headers.d.ts +9 -0
- package/dist/surfaces/headers.d.ts.map +1 -0
- package/dist/surfaces/headers.js +15 -0
- package/dist/surfaces/headers.js.map +1 -0
- package/dist/surfaces/request.d.ts +68 -0
- package/dist/surfaces/request.d.ts.map +1 -0
- package/dist/surfaces/request.js +130 -0
- package/dist/surfaces/request.js.map +1 -0
- package/dist/telemetry/module.d.ts +74 -0
- package/dist/telemetry/module.d.ts.map +1 -0
- package/dist/telemetry/module.js +77 -0
- package/dist/telemetry/module.js.map +1 -0
- package/dist/versioning/module.d.ts +231 -0
- package/dist/versioning/module.d.ts.map +1 -0
- package/dist/versioning/module.js +151 -0
- package/dist/versioning/module.js.map +1 -0
- package/package.json +71 -3
- package/src/AccountMail.ts +218 -0
- package/src/AppConfig.ts +148 -0
- package/src/Approvals.ts +555 -0
- package/src/Audit.ts +381 -0
- package/src/AuthSeam.ts +136 -0
- package/src/Authority.ts +577 -0
- package/src/Avatars.ts +172 -0
- package/src/Base64url.ts +23 -0
- package/src/BasePath.ts +80 -0
- package/src/CallActed.ts +10 -0
- package/src/Config.ts +857 -0
- package/src/DeliveryPolicy.ts +52 -0
- package/src/DesktopSignIn.ts +181 -0
- package/src/Directory.ts +1792 -0
- package/src/Flags.ts +281 -0
- package/src/Gate.ts +159 -0
- package/src/Hash.ts +14 -0
- package/src/Identity.ts +1811 -0
- package/src/IntervalJob.ts +96 -0
- package/src/Invocation.ts +2387 -0
- package/src/KernelHandlers.ts +29 -0
- package/src/KernelModule.ts +165 -0
- package/src/MemberRoutes.ts +146 -0
- package/src/Module.ts +573 -0
- package/src/ModuleIdentity.ts +134 -0
- package/src/Notifications.ts +665 -0
- package/src/Outbox.ts +761 -0
- package/src/Privacy.ts +265 -0
- package/src/Progress.ts +360 -0
- package/src/QuerySurface.ts +559 -0
- package/src/QueryViews.ts +165 -0
- package/src/Readiness.ts +284 -0
- package/src/Redact.ts +22 -0
- package/src/Registry.ts +399 -0
- package/src/Release.ts +1197 -0
- package/src/Retention.ts +167 -0
- package/src/Scheduler.ts +657 -0
- package/src/Server.ts +1838 -0
- package/src/Sessions.ts +56 -0
- package/src/Settings.ts +312 -0
- package/src/Sharing.ts +525 -0
- package/src/Sync.ts +1478 -0
- package/src/Telemetry.ts +754 -0
- package/src/Versioning.ts +588 -0
- package/src/WorkItems.ts +367 -0
- package/src/Workflows.ts +746 -0
- package/src/agent/Admission.ts +37 -0
- package/src/agent/Channels.ts +58 -0
- package/src/agent/Context.ts +430 -0
- package/src/agent/Http.ts +523 -0
- package/src/agent/Metering.ts +625 -0
- package/src/agent/ModelSetup.ts +414 -0
- package/src/agent/Models.ts +850 -0
- package/src/agent/Processors.ts +156 -0
- package/src/agent/Queue.ts +97 -0
- package/src/agent/Receipts.ts +192 -0
- package/src/agent/Resources.ts +376 -0
- package/src/agent/Run.ts +3762 -0
- package/src/agent/Runtime.ts +635 -0
- package/src/agent/Settings.ts +171 -0
- package/src/agent/Skills.ts +118 -0
- package/src/agent/Store.ts +73 -0
- package/src/agent/ToolSearch.ts +152 -0
- package/src/agent/index.ts +68 -0
- package/src/agent/migrations/agent/0000_agent.sql +162 -0
- package/src/agent/migrations/agent/0001_model_call.sql +33 -0
- package/src/agent/migrations/agent/0002_device.sql +2 -0
- package/src/agent/migrations/agent/0003_authority.sql +1 -0
- package/src/agent/migrations/agent/0004_budget_alert.sql +2 -0
- package/src/agent/migrations/agent/0005_feedback.sql +13 -0
- package/src/agent/migrations/agent/0095_run_options.sql +3 -0
- package/src/agent/migrations/agent/0096_conversation_meta.sql +7 -0
- package/src/agent/migrations/agent/0097_submission.sql +26 -0
- package/src/agent/migrations/agent/0098_threads.sql +21 -0
- package/src/agent/migrations/agent/0099_submission_refused.sql +4 -0
- package/src/agent/migrations/agent/0142_teams.sql +19 -0
- package/src/agent/module.ts +1793 -0
- package/src/appState/Sweep.ts +66 -0
- package/src/appState/migrations/0000_app_state.sql +35 -0
- package/src/appState/module.ts +418 -0
- package/src/audit/migrations/README.md +1 -0
- package/src/audit/module.ts +95 -0
- package/src/auth/AuthProvider.ts +293 -0
- package/src/auth/BetterAuthProvider.ts +476 -0
- package/src/auth/Methods.ts +7 -0
- package/src/auth/SessionTokens.ts +156 -0
- package/src/collab/Collab.ts +708 -0
- package/src/collab/Housekeeping.ts +193 -0
- package/src/collab/LiveCopy.ts +98 -0
- package/src/collab/Socket.ts +380 -0
- package/src/collab/Store.ts +105 -0
- package/src/collab/Ydoc.ts +337 -0
- package/src/collab/derive/bundle.gen.ts +2 -0
- package/src/collab/derive/entry.ts +34 -0
- package/src/collab/derive/polyfill.ts +15 -0
- package/src/collab/migrations/.gitkeep +0 -0
- package/src/collab/module.ts +237 -0
- package/src/connections/Connections.ts +2315 -0
- package/src/connections/Connector.ts +304 -0
- package/src/connections/Crypto.ts +134 -0
- package/src/connections/Destinations.ts +351 -0
- package/src/connections/Discovery.ts +251 -0
- package/src/connections/EffectKinds.ts +30 -0
- package/src/connections/Effects.ts +541 -0
- package/src/connections/Metering.ts +205 -0
- package/src/connections/ProviderApi.ts +137 -0
- package/src/connections/Secrets.ts +581 -0
- package/src/connections/Sync.ts +318 -0
- package/src/connections/migrations/.gitkeep +0 -0
- package/src/connections/module.ts +584 -0
- package/src/data/Corpus.ts +434 -0
- package/src/data/Datasets.ts +479 -0
- package/src/data/Programs.ts +285 -0
- package/src/data/migrations/README.md +1 -0
- package/src/data/module.ts +177 -0
- package/src/db/Bootstrap.ts +2832 -0
- package/src/db/Catalog.ts +10 -0
- package/src/db/Conflicts.ts +42 -0
- package/src/db/DirectoryLock.ts +19 -0
- package/src/db/HandlerGate.ts +107 -0
- package/src/db/Host.ts +250 -0
- package/src/db/KernelSchema.ts +4422 -0
- package/src/db/MigrationCheck.ts +221 -0
- package/src/db/QueryViewCheck.ts +1035 -0
- package/src/db/ReadOnly.ts +23 -0
- package/src/db/Scram.ts +20 -0
- package/src/db/SqlState.ts +77 -0
- package/src/db/Startup.ts +25 -0
- package/src/db/ZeroDdl.ts +272 -0
- package/src/db/ZeroPush.ts +128 -0
- package/src/db/schema.snapshot.json +13831 -0
- package/src/devices/Devices.ts +1219 -0
- package/src/devices/Flow.ts +198 -0
- package/src/devices/Http.ts +212 -0
- package/src/devices/migrations/0000_devices.sql +53 -0
- package/src/devices/migrations/0001_parent_run.sql +2 -0
- package/src/devices/migrations/0002_authority.sql +1 -0
- package/src/devices/migrations/0003_follow_up.sql +4 -0
- package/src/devices/migrations/0004_commands.sql +30 -0
- package/src/devices/migrations/0005_command_cancel.sql +7 -0
- package/src/devices/module.ts +313 -0
- package/src/durable/Cluster.ts +90 -0
- package/src/durable/Definition.ts +244 -0
- package/src/durable/Schedule.ts +155 -0
- package/src/durable/Trust.ts +149 -0
- package/src/enterprise/Routes.ts +501 -0
- package/src/enterprise/WorkOs.ts +133 -0
- package/src/files/FileTable.ts +84 -0
- package/src/files/Files.ts +1652 -0
- package/src/files/Http.ts +46 -0
- package/src/files/LocalStorage.ts +348 -0
- package/src/files/Providers.ts +356 -0
- package/src/files/S3Storage.ts +403 -0
- package/src/files/SigV4.ts +222 -0
- package/src/files/Sniff.ts +218 -0
- package/src/files/Storage.ts +143 -0
- package/src/files/migrations/README.md +1 -0
- package/src/files/module.ts +282 -0
- package/src/flags/migrations/0000_flags.sql +20 -0
- package/src/flags/module.ts +178 -0
- package/src/inbox/Flow.ts +548 -0
- package/src/inbox/System.ts +33 -0
- package/src/inbox/approvals.ts +335 -0
- package/src/inbox/consent.ts +331 -0
- package/src/inbox/index.ts +24 -0
- package/src/inbox/migrations/approvals/0000_approvals.sql +36 -0
- package/src/inbox/migrations/approvals/0001_provenance.sql +1 -0
- package/src/inbox/migrations/approvals/0002_withdrawn.sql +3 -0
- package/src/inbox/migrations/approvals/0003_title.sql +11 -0
- package/src/inbox/migrations/consent/0000_consent.sql +31 -0
- package/src/inbox/migrations/consent/0001_consent_revoked.sql +3 -0
- package/src/inbox/migrations/consent/0002_permission_request.sql +1 -0
- package/src/inbox/migrations/consent/0003_title.sql +11 -0
- package/src/inbox/migrations/inbox/0000_work_items.sql +31 -0
- package/src/inbox/migrations/notifications/0000_notifications.sql +66 -0
- package/src/inbox/notifications.ts +471 -0
- package/src/inbox/tables.ts +163 -0
- package/src/inbox/workItems.ts +199 -0
- package/src/index.ts +229 -0
- package/src/ingestion/Chunk.ts +49 -0
- package/src/ingestion/Extract.ts +387 -0
- package/src/ingestion/ExtractChild.ts +67 -0
- package/src/ingestion/ExtractPool.ts +270 -0
- package/src/ingestion/Ingestion.ts +929 -0
- package/src/ingestion/Isolated.ts +26 -0
- package/src/ingestion/Markup.ts +117 -0
- package/src/ingestion/Pdf.ts +167 -0
- package/src/ingestion/Runs.ts +192 -0
- package/src/ingestion/Scrub.ts +22 -0
- package/src/ingestion/Zip.ts +87 -0
- package/src/ingestion/migrations/README.md +1 -0
- package/src/ingestion/module.ts +65 -0
- package/src/ingress/Definition.ts +158 -0
- package/src/ingress/Ingress.ts +1220 -0
- package/src/ingress/Verifiers.ts +166 -0
- package/src/machine/MachineIdentity.ts +310 -0
- package/src/machine/Managed.ts +228 -0
- package/src/machine/OAuth.ts +1140 -0
- package/src/machine/Pages.ts +139 -0
- package/src/machine/Tokens.ts +75 -0
- package/src/make/Credentials.ts +36 -0
- package/src/make/Example.ts +104 -0
- package/src/make/Execute.ts +534 -0
- package/src/make/Http.ts +71 -0
- package/src/make/Lifecycle.ts +911 -0
- package/src/make/Manifest.ts +884 -0
- package/src/make/Repair.ts +262 -0
- package/src/make/Runtime.ts +494 -0
- package/src/make/Session.ts +33 -0
- package/src/make/SqlGuard.ts +362 -0
- package/src/make/Subscribe.ts +282 -0
- package/src/make/Validate.ts +247 -0
- package/src/make/ViewStep.ts +64 -0
- package/src/make/migrations/README.md +1 -0
- package/src/make/module.ts +261 -0
- package/src/notifications/Decide.ts +483 -0
- package/src/notifications/Providers.ts +532 -0
- package/src/notifications/Push.ts +594 -0
- package/src/notifications/Smtp.ts +379 -0
- package/src/policy/CedarSchema.ts +156 -0
- package/src/policy/Compiler.ts +1627 -0
- package/src/policy/Policy.ts +178 -0
- package/src/policy/Rls.ts +460 -0
- package/src/policy/Row.ts +15 -0
- package/src/privacy/Flow.ts +283 -0
- package/src/privacy/Inventory.ts +2414 -0
- package/src/privacy/Sources.ts +831 -0
- package/src/privacy/Visits.ts +339 -0
- package/src/privacy/ZeroCvr.ts +66 -0
- package/src/privacy/migrations/0000_privacy.sql +48 -0
- package/src/privacy/module.ts +280 -0
- package/src/progress/migrations/0000_progress.sql +27 -0
- package/src/progress/migrations/0001_notify.sql +1 -0
- package/src/progress/module.ts +161 -0
- package/src/proposals/migrations/README.md +1 -0
- package/src/proposals/module.ts +338 -0
- package/src/query/migrations/README.md +1 -0
- package/src/query/module.ts +66 -0
- package/src/records/Access.ts +97 -0
- package/src/records/References.ts +65 -0
- package/src/runtime/bun.ts +131 -0
- package/src/runtime/idle.ts +88 -0
- package/src/runtime/node.ts +140 -0
- package/src/runtime/resolve.ts +141 -0
- package/src/sandbox/Sandbox.ts +330 -0
- package/src/sandbox/worker.ts +577 -0
- package/src/scheduler/Automations.ts +319 -0
- package/src/scheduler/History.ts +231 -0
- package/src/scheduler/migrations/0000_schedules.sql +11 -0
- package/src/scheduler/migrations/0001_resumed_at.sql +1 -0
- package/src/scheduler/migrations/0002_origin.sql +3 -0
- package/src/scheduler/migrations/0003_authority.sql +1 -0
- package/src/scheduler/migrations/0004_operate.sql +18 -0
- package/src/scheduler/module.ts +445 -0
- package/src/search/RecordLock.ts +25 -0
- package/src/search/Search.ts +563 -0
- package/src/search/Sources.ts +157 -0
- package/src/search/migrations/README.md +1 -0
- package/src/search/module.ts +49 -0
- package/src/settings/migrations/0000_settings.sql +15 -0
- package/src/settings/module.ts +126 -0
- package/src/sharing/migrations/0000_access_requests.sql +17 -0
- package/src/sharing/module.ts +351 -0
- package/src/spaces/migrations/0000_spaces.sql +35 -0
- package/src/spaces/module.ts +287 -0
- package/src/surfaces/Agent.ts +224 -0
- package/src/surfaces/CookieGuard.ts +433 -0
- package/src/surfaces/Http.ts +341 -0
- package/src/surfaces/Mcp.ts +585 -0
- package/src/surfaces/Rpc.ts +101 -0
- package/src/surfaces/headers.ts +16 -0
- package/src/surfaces/request.ts +173 -0
- package/src/telemetry/migrations/.gitkeep +0 -0
- package/src/telemetry/module.ts +94 -0
- package/src/versioning/migrations/.gitkeep +0 -0
- package/src/versioning/module.ts +194 -0
package/dist/Server.js
ADDED
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition: one HTTP server hosting every surface, the auth routes and the
|
|
3
|
+
* sync endpoint, over the kernel services. Platform-neutral; `runtime/node`
|
|
4
|
+
* and `runtime/bun` provide the HTTP server for each runtime.
|
|
5
|
+
*/
|
|
6
|
+
import { moduleSchemaProblems, ownerLoginMethodVerdict, zeroSchemaProblems } from "./ModuleIdentity.js";
|
|
7
|
+
import { ByteSize, Cause, Effect, Layer, Option, Redacted } from "effect";
|
|
8
|
+
import { QUERY_ACTION, QUERY_VIEWS_ACTION } from "@eloxiv/contracts";
|
|
9
|
+
import { HttpIncomingMessage, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
10
|
+
import { PgClient } from "@effect/sql-pg";
|
|
11
|
+
import { approvalRuleShapeProblems, CLIENT_VERSION_HEADER, Forbidden, HEALTH_PATH, manifestProblems, MigrationFailed, MY_ORGANIZATIONS_PATH, ORG_MEMBERS_PATH, DIRECTORY_OPERATIONS_PATH, READY_PATH, RELEASE_PATH, MCP_IDENTITY_PATH, mcpServerName, WEBMCP_PATHS, } from "@eloxiv/contracts";
|
|
12
|
+
import { hostname } from "node:os";
|
|
13
|
+
import { SqlClient } from "effect/sql";
|
|
14
|
+
import { AgentServices, appSkillProblems } from "./agent/index.js";
|
|
15
|
+
import { CookieGuard } from "./surfaces/CookieGuard.js";
|
|
16
|
+
import { agentSendPrecheck } from "./agent/Admission.js";
|
|
17
|
+
import { AgentRoutes } from "./agent/Http.js";
|
|
18
|
+
import { AppStateSweeper } from "./appState/Sweep.js";
|
|
19
|
+
import { ModelProviders } from "./agent/Models.js";
|
|
20
|
+
import { MemberRoutes } from "./MemberRoutes.js";
|
|
21
|
+
import { ModelSetupRoutes } from "./agent/ModelSetup.js";
|
|
22
|
+
import { agentReactions, agentRunWorkflow, wakeRunForTurn } from "./agent/Run.js";
|
|
23
|
+
import { AGENT_MODULE } from "./agent/Store.js";
|
|
24
|
+
import { Approvals } from "./Approvals.js";
|
|
25
|
+
import { approvalWorkflows, inboxReactions } from "./inbox/Flow.js";
|
|
26
|
+
import { Devices, deviceSettings } from "./devices/Devices.js";
|
|
27
|
+
import { deviceReactions, deviceWorkflows } from "./devices/Flow.js";
|
|
28
|
+
import { DeviceRoutes } from "./devices/Http.js";
|
|
29
|
+
import { APPROVALS_MODULE, CONSENT_MODULE, INBOX_MODULE, NOTIFICATIONS_MODULE, consentModule, notificationsModule, } from "./inbox/index.js";
|
|
30
|
+
import { consentReads } from "./inbox/consent.js";
|
|
31
|
+
import { DecideRoute } from "./notifications/Decide.js";
|
|
32
|
+
import { installationHandlers } from "./notifications/Push.js";
|
|
33
|
+
import { Notifications, NotificationChannels, UNSUBSCRIBE_PATH, } from "./Notifications.js";
|
|
34
|
+
import { WorkItems } from "./WorkItems.js";
|
|
35
|
+
import { Audit } from "./Audit.js";
|
|
36
|
+
import { durableConfig, filesConfig, httpConfig, KernelConfig, machineConfig } from "./Config.js";
|
|
37
|
+
import { adminUrlFor, bootstrapCluster, bootstrapDatabase, connectOwner, parseDatabaseUrl, passwordlessOwnerRules, PgLayer, recordedKernelState, REVOKED_CATALOG_FUNCTIONS, untrustedSetupObjects, withClient, } from "./db/Bootstrap.js";
|
|
38
|
+
import { degradedProtections, detectHost, hostDifferences, hostRequirementProblems } from "./db/Host.js";
|
|
39
|
+
import { deliveryPolicyProblems } from "./DeliveryPolicy.js";
|
|
40
|
+
import { AvatarRoutes } from "./Avatars.js";
|
|
41
|
+
import { DesktopSignInRoutes } from "./DesktopSignIn.js";
|
|
42
|
+
import { EnterpriseRoutes } from "./enterprise/Routes.js";
|
|
43
|
+
import { AuthProvider } from "./auth/AuthProvider.js";
|
|
44
|
+
import { betterAuthProvider } from "./auth/BetterAuthProvider.js";
|
|
45
|
+
import { Directory, DIRECTORY_ADMIN_OPERATIONS, DomainRecords } from "./Directory.js";
|
|
46
|
+
import { AuthUnavailable, Identity, TWO_FACTOR_CHALLENGE_HEADER } from "./Identity.js";
|
|
47
|
+
import { ActionPrechecks, Invocation, InvocationHooks } from "./Invocation.js";
|
|
48
|
+
import { ClusterLayer } from "./durable/Cluster.js";
|
|
49
|
+
import { KERNEL_WORKFLOW_PREFIX, } from "./durable/Definition.js";
|
|
50
|
+
import { isKernelWorkflow } from "./durable/Trust.js";
|
|
51
|
+
import { DispatcherHeartbeat, EventTriggers, KernelReactions, Outbox, OutboxDispatcher, SubscriberApis, } from "./Outbox.js";
|
|
52
|
+
import { Readiness } from "./Readiness.js";
|
|
53
|
+
import { scheduledActionWorkflow, Scheduler } from "./Scheduler.js";
|
|
54
|
+
import { Retention } from "./Retention.js";
|
|
55
|
+
import { automationReactions, eventAutomationWorkflow, eventRecordProblems } from "./scheduler/Automations.js";
|
|
56
|
+
import { schedulerReads } from "./scheduler/History.js";
|
|
57
|
+
import { schedulerModule } from "./scheduler/module.js";
|
|
58
|
+
import { Workflows } from "./Workflows.js";
|
|
59
|
+
import { Policy, PolicySet } from "./policy/Policy.js";
|
|
60
|
+
import { assertKernelState, hostRefusal, KERNEL_MODULE, KERNEL_VERSION, migrateAndHarden, recordHistory, Release, ReleaseSettings, withLease, } from "./Release.js";
|
|
61
|
+
import { InvalidManifest, moduleDurableProblems, Registry, toolGroupProblems } from "./Registry.js";
|
|
62
|
+
import { Authority, credentialLinks } from "./Authority.js";
|
|
63
|
+
import { Ingress, IngressRoutes, IngressSecrets, ingressWorkflow } from "./ingress/Ingress.js";
|
|
64
|
+
import { MachineIdentity } from "./machine/MachineIdentity.js";
|
|
65
|
+
import { managedRoute } from "./machine/Managed.js";
|
|
66
|
+
import { OAuthRoutes } from "./machine/OAuth.js";
|
|
67
|
+
import { defaultPages } from "./machine/Pages.js";
|
|
68
|
+
import { Sharing } from "./Sharing.js";
|
|
69
|
+
import { FlagProviders, Flags, flagProviderProblems } from "./Flags.js";
|
|
70
|
+
import { flagsModule } from "./flags/module.js";
|
|
71
|
+
import { KernelActionHandlers } from "./KernelHandlers.js";
|
|
72
|
+
import { queryModule } from "./query/module.js";
|
|
73
|
+
import { QuerySurface } from "./QuerySurface.js";
|
|
74
|
+
import { Settings, settingsConfigProblems } from "./Settings.js";
|
|
75
|
+
import { settingsModule } from "./settings/module.js";
|
|
76
|
+
import { sharingModule } from "./sharing/module.js";
|
|
77
|
+
import { ConnectionRoutes, Connections, Connectors, TokenCustody } from "./connections/Connections.js";
|
|
78
|
+
import { KeyEncryption } from "./connections/Crypto.js";
|
|
79
|
+
import { ConnectionMetering } from "./connections/Metering.js";
|
|
80
|
+
import { CONNECTIONS_MODULE } from "./connections/module.js";
|
|
81
|
+
import { SecretRequirements, Secrets, SecretsRoutes } from "./connections/Secrets.js";
|
|
82
|
+
import { ConnectionSync, ConnectionSyncHooks, connectionSyncWorkflow, } from "./connections/Sync.js";
|
|
83
|
+
import { connectionEffectWorkflow, effectReactions, operationOf } from "./connections/Effects.js";
|
|
84
|
+
import { isKernelModule, kernelModuleProblems } from "./KernelModule.js";
|
|
85
|
+
import { HttpSurface } from "./surfaces/Http.js";
|
|
86
|
+
import { McpSurface } from "./surfaces/Mcp.js";
|
|
87
|
+
import { boundedWebRequest, clientAddress, proxyHops, refusalResponse } from "./surfaces/request.js";
|
|
88
|
+
import { RpcSurface } from "./surfaces/Rpc.js";
|
|
89
|
+
import { SyncEndpoint, SyncMutateEndpoint } from "./Sync.js";
|
|
90
|
+
import { FILES_MODULE, FileScannersLayer, fileFinalizeWorkflow, FilesLayer, filesReactions, FilesSweeper, } from "./files/Files.js";
|
|
91
|
+
import { FileRoutes } from "./files/Http.js";
|
|
92
|
+
import { LocalStorageLayer } from "./files/LocalStorage.js";
|
|
93
|
+
import { S3StorageLayer } from "./files/S3Storage.js";
|
|
94
|
+
import { noStorage, StorageBackend } from "./files/Storage.js";
|
|
95
|
+
import { RoutedStorageLayer, StorageProviders } from "./files/Providers.js";
|
|
96
|
+
import { Extractors } from "./ingestion/Extract.js";
|
|
97
|
+
import { IngestionHooks, ingestionReactions, IngestionLayer, ingestWorkflow } from "./ingestion/Ingestion.js";
|
|
98
|
+
import { corpusReactions, corpusWorkflow } from "./data/Corpus.js";
|
|
99
|
+
import { ExtractionPoolLayer } from "./ingestion/ExtractPool.js";
|
|
100
|
+
import { SearchEmbeddingLoop, SearchEmbeddings, SearchLayer } from "./search/Search.js";
|
|
101
|
+
import { Privacy, PrivacySources } from "./Privacy.js";
|
|
102
|
+
import { privacyReactions, privacyRequestWorkflow } from "./privacy/Flow.js";
|
|
103
|
+
import { PRIVACY_MODULE, privacyModule } from "./privacy/module.js";
|
|
104
|
+
import { VisitRoutes } from "./privacy/Visits.js";
|
|
105
|
+
import { telemetryHandlers, telemetryModule } from "./telemetry/module.js";
|
|
106
|
+
import { Progress } from "./Progress.js";
|
|
107
|
+
import { PROGRESS_MODULE, progressModule } from "./progress/module.js";
|
|
108
|
+
import { Analytics, clientEventProblems, ErrorCapture, TelemetryTracing, } from "./Telemetry.js";
|
|
109
|
+
import { Versioning } from "./Versioning.js";
|
|
110
|
+
import { Collab } from "./collab/Collab.js";
|
|
111
|
+
import { Housekeeping } from "./collab/Housekeeping.js";
|
|
112
|
+
import { COLLAB_MODULE } from "./collab/module.js";
|
|
113
|
+
import { CollabRoutes, CollabSettings } from "./collab/Socket.js";
|
|
114
|
+
import { dataSubjectCoverageProblems } from "@eloxiv/contracts";
|
|
115
|
+
import { makeRoleKeyOf, makeRolePassword } from "./make/Credentials.js";
|
|
116
|
+
import { holdMakeRoleLocks, MakeHooks, MakeLifecycle } from "./make/Lifecycle.js";
|
|
117
|
+
import { buildMakeModule } from "./make/Manifest.js";
|
|
118
|
+
import { makeModule } from "./make/module.js";
|
|
119
|
+
import { MakeRoutes } from "./make/Http.js";
|
|
120
|
+
import { MakeRuntime } from "./make/Runtime.js";
|
|
121
|
+
import { MakeSubscriptionsLive } from "./make/Subscribe.js";
|
|
122
|
+
import { makeModuleProblems } from "./make/Validate.js";
|
|
123
|
+
export { KERNEL_VERSION };
|
|
124
|
+
import { basePathOf, BasePathMiddleware } from "./BasePath.js";
|
|
125
|
+
import { AppConfig } from "./AppConfig.js";
|
|
126
|
+
const SHARING_MODULE = sharingModule.contract.name;
|
|
127
|
+
/** Is the kernel's Files module installed in this app? */
|
|
128
|
+
export const hasFiles = (app) => app.modules.some((module) => module.contract.name === FILES_MODULE);
|
|
129
|
+
/**
|
|
130
|
+
* The deployment's storage backend from configuration (`KernelConfig.storage`). Without one: a local directory
|
|
131
|
+
* (`.eloxiv/storage`) in development when Files is installed, a refusal in production; and when Files is not
|
|
132
|
+
* installed, a backend that answers every call with StorageUnavailable.
|
|
133
|
+
*/
|
|
134
|
+
const StorageFromConfig = (app) => Layer.unwrap(Effect.gen(function* () {
|
|
135
|
+
const config = yield* KernelConfig;
|
|
136
|
+
const storage = config.storage;
|
|
137
|
+
if (storage?.kind === "local")
|
|
138
|
+
return LocalStorageLayer(storage.root);
|
|
139
|
+
if (storage?.kind === "s3")
|
|
140
|
+
return S3StorageLayer(storage);
|
|
141
|
+
if (!hasFiles(app))
|
|
142
|
+
return Layer.succeed(StorageBackend, StorageBackend.of(noStorage));
|
|
143
|
+
if (config.environment === "production") {
|
|
144
|
+
return yield* Effect.die(new Error("Files is installed but no storage backend is configured (ELOXIV_STORAGE)"));
|
|
145
|
+
}
|
|
146
|
+
yield* Effect.logWarning("No storage backend is configured (ELOXIV_STORAGE): files are kept in .eloxiv/storage");
|
|
147
|
+
return LocalStorageLayer(".eloxiv/storage");
|
|
148
|
+
}));
|
|
149
|
+
/** The extraction pool (Ingestion), sized and limited by `KernelConfig.files`; its processes start on first use. */
|
|
150
|
+
const ExtractionPoolFromConfig = Layer.unwrap(Effect.gen(function* () {
|
|
151
|
+
const files = filesConfig(yield* KernelConfig);
|
|
152
|
+
return ExtractionPoolLayer({
|
|
153
|
+
size: files.extractConcurrency,
|
|
154
|
+
timeoutMs: files.extractTimeoutMs,
|
|
155
|
+
memoryMb: files.extractMemoryMb,
|
|
156
|
+
});
|
|
157
|
+
}));
|
|
158
|
+
/** Is the kernel's privacy module installed (data-subject requests, consent)? */
|
|
159
|
+
export const hasPrivacy = (app) => app.modules.includes(privacyModule);
|
|
160
|
+
/** Is the kernel's collab module installed (collaborative documents and their transport)? */
|
|
161
|
+
export const hasCollab = (app) => app.modules.some((module) => module.contract.name === COLLAB_MODULE);
|
|
162
|
+
/** Is the kernel's agent installed in this app (its `agent` module)? */
|
|
163
|
+
export const hasAgent = (app) => app.modules.some((module) => module.contract.name === AGENT_MODULE);
|
|
164
|
+
/**
|
|
165
|
+
* Every inbound webhook source of an app: its own, named as given, and its modules', namespaced by the
|
|
166
|
+
* module (`<module>.<name>`, like jobs and triggers).
|
|
167
|
+
*/
|
|
168
|
+
export const ingressSources = (app) => [
|
|
169
|
+
...(app.ingress ?? []),
|
|
170
|
+
...app.modules.flatMap((module) => module.ingress.map((source) => ({ ...source, name: `${module.contract.name}.${source.name}` }))),
|
|
171
|
+
];
|
|
172
|
+
/**
|
|
173
|
+
* Every Connection sync of an app: its own, named as given, and its modules', namespaced by the module
|
|
174
|
+
* (`<module>.<name>`, like ingress sources). A module's sync applies pages with one of its own actions.
|
|
175
|
+
*/
|
|
176
|
+
export const connectionSyncDefinitions = (app) => [
|
|
177
|
+
...(app.connectionSyncs ?? []),
|
|
178
|
+
...app.modules.flatMap((module) => (module.connectionSyncs ?? []).map((sync) => Object.assign({}, sync, { name: `${module.contract.name}.${sync.name}` }))),
|
|
179
|
+
];
|
|
180
|
+
/** Every workflow definition of an app: the kernel's built-ins, the app's own, and its modules'. */
|
|
181
|
+
export const workflowDefinitions = (app) => {
|
|
182
|
+
const defined = [
|
|
183
|
+
scheduledActionWorkflow,
|
|
184
|
+
...approvalWorkflows,
|
|
185
|
+
...(hasAgent(app) ? [agentRunWorkflow] : []),
|
|
186
|
+
...deviceWorkflows,
|
|
187
|
+
fileFinalizeWorkflow,
|
|
188
|
+
ingestWorkflow,
|
|
189
|
+
corpusWorkflow,
|
|
190
|
+
...(hasPrivacy(app) ? [privacyRequestWorkflow] : []),
|
|
191
|
+
...(app.modules.includes(schedulerModule) ? [eventAutomationWorkflow] : []),
|
|
192
|
+
...(app.workflows ?? []),
|
|
193
|
+
...app.modules.flatMap((module) => module.workflows),
|
|
194
|
+
];
|
|
195
|
+
return [
|
|
196
|
+
...defined,
|
|
197
|
+
ingressWorkflow(ingressSources(app), defined),
|
|
198
|
+
connectionSyncWorkflow(connectionSyncDefinitions(app)),
|
|
199
|
+
connectionEffectWorkflow,
|
|
200
|
+
];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Every event trigger of an app: its own, with their ids as given, and its modules', with their ids
|
|
204
|
+
* namespaced by the module (`<module>.<id>`, like jobs). A trigger's deliveries are recorded and its
|
|
205
|
+
* executions keyed by its id, so ids must be unique across the app; each trigger must start a workflow
|
|
206
|
+
* the app defines, on an event type an installed module declares (`appProblems` checks both).
|
|
207
|
+
*/
|
|
208
|
+
/** What members can automate: every module action, the schedulable workflows, every declared event type. */
|
|
209
|
+
const automationCatalog = (app) => ({
|
|
210
|
+
actions: app.modules.flatMap((module) => Object.values(module.contract.actions).map((action) => ({
|
|
211
|
+
name: action.name,
|
|
212
|
+
description: action.description,
|
|
213
|
+
module: module.contract.name,
|
|
214
|
+
}))),
|
|
215
|
+
workflows: workflowDefinitions(app)
|
|
216
|
+
.filter((definition) => definition.schedulable)
|
|
217
|
+
.map((definition) => ({ name: definition.name })),
|
|
218
|
+
events: app.modules.flatMap((module) => Object.values(module.contract.events).map((event) => ({
|
|
219
|
+
type: event.type,
|
|
220
|
+
module: module.contract.name,
|
|
221
|
+
automatable: event.record !== undefined,
|
|
222
|
+
}))),
|
|
223
|
+
});
|
|
224
|
+
export const eventTriggers = (app) => [
|
|
225
|
+
...(app.triggers ?? []),
|
|
226
|
+
...app.modules.flatMap((module) => module.triggers.map((trigger) => ({
|
|
227
|
+
...trigger,
|
|
228
|
+
id: `${module.contract.name}.${trigger.id}`,
|
|
229
|
+
module: module.contract.name,
|
|
230
|
+
}))),
|
|
231
|
+
];
|
|
232
|
+
/** The module each module workflow belongs to (`appProblems` checks it is named `<module>.*`). */
|
|
233
|
+
export const workflowOwners = (app) => new Map(app.modules.flatMap((module) => module.workflows.map((definition) => [definition.name, module.contract.name])));
|
|
234
|
+
/** Every approval rule of an app: the app's own first (ids as given), then its modules' (namespaced ids). */
|
|
235
|
+
export const approvalRules = (app) => [
|
|
236
|
+
...Object.entries(app.approvalRules ?? {}).map(([id, rule]) => ({ id, rule })),
|
|
237
|
+
...app.modules.flatMap((module) => Object.entries((module.contract.approvalRules ?? {})).map(([id, rule]) => ({
|
|
238
|
+
id,
|
|
239
|
+
rule,
|
|
240
|
+
}))),
|
|
241
|
+
];
|
|
242
|
+
/**
|
|
243
|
+
* What the approval stage needs installed: the inbox modules when there are approval rules or actions marked
|
|
244
|
+
* `consent`; rules may not apply to the decisions themselves (approve, reject, consent).
|
|
245
|
+
*/
|
|
246
|
+
const approvalProblems = (app) => {
|
|
247
|
+
const problems = [];
|
|
248
|
+
const installed = new Set(app.modules.map((module) => module.contract.name));
|
|
249
|
+
const actions = new Map(app.modules.flatMap((module) => Object.values(module.contract.actions).map((action) => [action.name, action])));
|
|
250
|
+
const rules = approvalRules(app);
|
|
251
|
+
for (const [id, rule] of Object.entries(app.approvalRules ?? {})) {
|
|
252
|
+
for (const shape of approvalRuleShapeProblems(rule))
|
|
253
|
+
problems.push(`approval rule ${id} ${shape}`);
|
|
254
|
+
if (!actions.has(rule.action))
|
|
255
|
+
problems.push(`approval rule ${id} applies to unknown action ${rule.action}`);
|
|
256
|
+
}
|
|
257
|
+
for (const { id, rule } of rules) {
|
|
258
|
+
const module = rule.action.slice(0, rule.action.indexOf("."));
|
|
259
|
+
if (module === APPROVALS_MODULE || module === CONSENT_MODULE) {
|
|
260
|
+
problems.push(`approval rule ${id} applies to ${rule.action}, a decision itself`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const needs = (what, modules) => {
|
|
264
|
+
const missing = modules.filter((m) => !installed.has(m));
|
|
265
|
+
if (missing.length > 0)
|
|
266
|
+
problems.push(`${what} need the kernel's ${missing.join(", ")} modules (inboxModules)`);
|
|
267
|
+
};
|
|
268
|
+
if (rules.length > 0)
|
|
269
|
+
needs("Approval rules", [APPROVALS_MODULE, INBOX_MODULE, NOTIFICATIONS_MODULE]);
|
|
270
|
+
// Access requests reach managers as work items and notifications.
|
|
271
|
+
if (installed.has(SHARING_MODULE))
|
|
272
|
+
needs("The sharing module", [INBOX_MODULE, NOTIFICATIONS_MODULE]);
|
|
273
|
+
// The kernel-provided scheduler's actions are consent-marked (they run actions later), but an app may install
|
|
274
|
+
// it without the inbox: an agent's call to them is then refused outright (Invocation), never run unasked. The
|
|
275
|
+
// same holds for the connections module's (a remote tool call, an API write).
|
|
276
|
+
const kernelProvided = new Set([
|
|
277
|
+
schedulerModule.contract.name,
|
|
278
|
+
FILES_MODULE,
|
|
279
|
+
COLLAB_MODULE,
|
|
280
|
+
CONNECTIONS_MODULE,
|
|
281
|
+
]);
|
|
282
|
+
const consentActions = [...actions.values()].filter((action) => action.consent && !kernelProvided.has(action.name.slice(0, action.name.indexOf("."))));
|
|
283
|
+
if (consentActions.length > 0) {
|
|
284
|
+
needs(`Actions marked consent (${consentActions.map((a) => a.name).join(", ")})`, [
|
|
285
|
+
CONSENT_MODULE,
|
|
286
|
+
INBOX_MODULE,
|
|
287
|
+
NOTIFICATIONS_MODULE,
|
|
288
|
+
]);
|
|
289
|
+
}
|
|
290
|
+
return problems;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Everything wrong with an app's manifests, listed together: the modules' declarations and jobs
|
|
294
|
+
* (`manifestProblems`), the ids durable work is recorded under (`moduleDurableProblems`: modules,
|
|
295
|
+
* subscribers, jobs), workflows with one name, and event triggers that share an id, start an unknown
|
|
296
|
+
* workflow or listen for an unknown event.
|
|
297
|
+
*/
|
|
298
|
+
export const appProblems = (app) => {
|
|
299
|
+
const problems = [
|
|
300
|
+
...manifestProblems(app.modules.map((module) => module.contract)),
|
|
301
|
+
...moduleSchemaProblems(app.modules),
|
|
302
|
+
...moduleDurableProblems(app.modules),
|
|
303
|
+
...eventRecordProblems(app.modules),
|
|
304
|
+
...approvalProblems(app),
|
|
305
|
+
...settingsConfigProblems(app.modules.map((module) => module.contract), app.settings),
|
|
306
|
+
...flagProviderProblems(app.flagProviders ?? [], new Set(app.modules.flatMap((module) => Object.keys(module.contract.flags ?? {})))),
|
|
307
|
+
...(app.agent !== undefined && !hasAgent(app)
|
|
308
|
+
? ["The app configures an agent (KernelApp.agent) but does not install the kernel's agent module (agentModule)"]
|
|
309
|
+
: []),
|
|
310
|
+
...kernelModuleProblems(app.modules),
|
|
311
|
+
...appSkillProblems(app.skills ?? []),
|
|
312
|
+
...toolGroupProblems(app.modules.map((module) => module.contract), app.agentTools?.disabledGroups ?? []),
|
|
313
|
+
...clientEventProblems(app.analytics?.events),
|
|
314
|
+
// The Privacy contract: no entity holding user ids may be left out of exports and erasures.
|
|
315
|
+
...(hasPrivacy(app)
|
|
316
|
+
? [
|
|
317
|
+
...dataSubjectCoverageProblems(app.modules.map((module) => module.contract)),
|
|
318
|
+
...(app.modules.includes(progressModule)
|
|
319
|
+
? []
|
|
320
|
+
: [
|
|
321
|
+
`The privacy module reports its requests through Progress: install ${PROGRESS_MODULE} (progressModule) beside ${PRIVACY_MODULE}`,
|
|
322
|
+
]),
|
|
323
|
+
]
|
|
324
|
+
: []),
|
|
325
|
+
];
|
|
326
|
+
// A module's workflows are its own (`<module>.*`), and its triggers and ingress sources start only them: a
|
|
327
|
+
// module's work reports progress, and is journalled, as its module.
|
|
328
|
+
for (const module of app.modules) {
|
|
329
|
+
const name = module.contract.name;
|
|
330
|
+
const own = new Set(module.workflows.map((definition) => definition.name).filter((workflow) => workflow.startsWith(`${name}.`)));
|
|
331
|
+
for (const definition of module.workflows) {
|
|
332
|
+
if (!definition.name.startsWith(`${name}.`)) {
|
|
333
|
+
problems.push(`Workflow ${definition.name} of module ${name} must be named ${name}.<name>`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
for (const trigger of module.triggers) {
|
|
337
|
+
if (!own.has(trigger.workflow)) {
|
|
338
|
+
problems.push(`Event trigger ${name}.${trigger.id} starts ${trigger.workflow}, which is not a workflow of ${name}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
for (const source of module.ingress) {
|
|
342
|
+
if (source.handler.kind === "workflow" && !own.has(source.handler.workflow)) {
|
|
343
|
+
problems.push(`Ingress source ${name}.${source.name} hands deliveries to ${source.handler.workflow}, which is not a workflow of ${name}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
// The kernel's workflow names are its own: an app or module workflow may not claim one (or pass off a kernel
|
|
348
|
+
// definition as its own).
|
|
349
|
+
for (const definition of [...(app.workflows ?? []), ...app.modules.flatMap((module) => module.workflows)]) {
|
|
350
|
+
if (definition.name.startsWith(KERNEL_WORKFLOW_PREFIX) || isKernelWorkflow(definition)) {
|
|
351
|
+
problems.push(`Workflow ${definition.name} claims the kernel's own namespace (${KERNEL_WORKFLOW_PREFIX}*); app and module workflows may not`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const workflows = new Set();
|
|
355
|
+
for (const definition of workflowDefinitions(app)) {
|
|
356
|
+
if (workflows.has(definition.name))
|
|
357
|
+
problems.push(`Workflow ${definition.name} is defined twice`);
|
|
358
|
+
workflows.add(definition.name);
|
|
359
|
+
}
|
|
360
|
+
const events = new Set(app.modules.flatMap((module) => Object.values(module.contract.events).map((event) => event.type)));
|
|
361
|
+
const ids = new Set();
|
|
362
|
+
for (const trigger of eventTriggers(app)) {
|
|
363
|
+
if (trigger.id.length === 0) {
|
|
364
|
+
problems.push(`An event trigger on ${trigger.event} has no id`);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (ids.has(trigger.id))
|
|
368
|
+
problems.push(`Event trigger ${trigger.id} is defined twice`);
|
|
369
|
+
ids.add(trigger.id);
|
|
370
|
+
problems.push(...deliveryPolicyProblems(`Event trigger ${trigger.id}`, trigger.delivery));
|
|
371
|
+
if (!workflows.has(trigger.workflow)) {
|
|
372
|
+
problems.push(`Event trigger ${trigger.id} starts unknown workflow ${trigger.workflow}`);
|
|
373
|
+
}
|
|
374
|
+
if (!events.has(trigger.event)) {
|
|
375
|
+
problems.push(`Event trigger ${trigger.id} listens for unknown event ${trigger.event}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const actions = new Set(app.modules.flatMap((module) => Object.values(module.contract.actions).map((a) => a.name)));
|
|
379
|
+
const connectors = app.connectors ?? [];
|
|
380
|
+
const connectorNames = new Set();
|
|
381
|
+
for (const connector of connectors) {
|
|
382
|
+
if (connectorNames.has(connector.name))
|
|
383
|
+
problems.push(`Connector ${connector.name} is installed twice`);
|
|
384
|
+
connectorNames.add(connector.name);
|
|
385
|
+
}
|
|
386
|
+
const connectionsModule = app.modules.find((module) => module.contract.name === CONNECTIONS_MODULE);
|
|
387
|
+
if (connectors.length > 0 && (connectionsModule === undefined || !isKernelModule(connectionsModule))) {
|
|
388
|
+
problems.push(`Connectors need the kernel's connectionsModule among the app's modules`);
|
|
389
|
+
}
|
|
390
|
+
const syncNames = new Set();
|
|
391
|
+
for (const module of app.modules) {
|
|
392
|
+
for (const sync of module.connectionSyncs ?? []) {
|
|
393
|
+
if (!sync.action.startsWith(`${module.contract.name}.`)) {
|
|
394
|
+
problems.push(`Connection sync ${module.contract.name}.${sync.name} applies pages with ${sync.action}, not an action of its own module`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
for (const sync of connectionSyncDefinitions(app)) {
|
|
399
|
+
if (syncNames.has(sync.name))
|
|
400
|
+
problems.push(`Connection sync ${sync.name} is defined twice`);
|
|
401
|
+
syncNames.add(sync.name);
|
|
402
|
+
if (!actions.has(sync.action))
|
|
403
|
+
problems.push(`Connection sync ${sync.name} applies pages with unknown action ${sync.action}`);
|
|
404
|
+
}
|
|
405
|
+
// Capability operations an action declares (`connections`): they exist, and one others see (external) is
|
|
406
|
+
// declared only by an action that needs the person's consent when an agent calls it.
|
|
407
|
+
for (const module of app.modules) {
|
|
408
|
+
for (const action of Object.values(module.contract.actions)) {
|
|
409
|
+
for (const [capability, operations] of Object.entries(action.connections ?? {})) {
|
|
410
|
+
for (const operation of operations) {
|
|
411
|
+
const found = operationOf(capability, operation);
|
|
412
|
+
if (found === undefined) {
|
|
413
|
+
problems.push(`${action.name} declares ${capability}.${operation}, which no capability contract defines`);
|
|
414
|
+
}
|
|
415
|
+
else if (found.effect === "external" && !action.consent) {
|
|
416
|
+
problems.push(`${action.name} declares ${capability}.${operation}, which others see: the action must need consent (consent: true or "each-call")`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
// An app's own sync needs a connector for its capability. A module's is inert until the app installs one (a
|
|
423
|
+
// People module works without a directory Connection): no Connection is ever enrolled for it.
|
|
424
|
+
for (const sync of app.connectionSyncs ?? []) {
|
|
425
|
+
if (!connectors.some((c) => c.capabilities[sync.capability] !== undefined)) {
|
|
426
|
+
problems.push(`Connection sync ${sync.name}: no installed connector provides ${sync.capability}`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const sources = new Set();
|
|
430
|
+
for (const source of ingressSources(app)) {
|
|
431
|
+
if (!/^[a-z0-9][a-z0-9._-]{0,99}$/u.test(source.name)) {
|
|
432
|
+
problems.push(`Ingress source ${source.name} must be lower case letters, digits, '.', '_' and '-'`);
|
|
433
|
+
}
|
|
434
|
+
if (sources.has(source.name))
|
|
435
|
+
problems.push(`Ingress source ${source.name} is defined twice`);
|
|
436
|
+
sources.add(source.name);
|
|
437
|
+
if (source.handler.kind === "action" && !actions.has(source.handler.action)) {
|
|
438
|
+
problems.push(`Ingress source ${source.name} handles deliveries with unknown action ${source.handler.action}`);
|
|
439
|
+
}
|
|
440
|
+
if (source.handler.kind === "workflow" && !workflows.has(source.handler.workflow)) {
|
|
441
|
+
problems.push(`Ingress source ${source.name} handles deliveries with unknown workflow ${source.handler.workflow}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return problems;
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* Refuse, before anything starts (setup or services), an app with any of `appProblems`: one
|
|
448
|
+
* `InvalidManifest` lists them all. The registry then checks what needs the module files (handlers, skill
|
|
449
|
+
* files, policies).
|
|
450
|
+
*/
|
|
451
|
+
export const checkApp = (app) => {
|
|
452
|
+
const problems = appProblems(app);
|
|
453
|
+
if (problems.length > 0)
|
|
454
|
+
throw new InvalidManifest(problems);
|
|
455
|
+
};
|
|
456
|
+
/** Durable work over the invocation path: the cluster, `Workflows`, `Scheduler` and event triggers. */
|
|
457
|
+
const DurableWork = (app, mode, schedulerLoop) => {
|
|
458
|
+
const definitions = workflowDefinitions(app);
|
|
459
|
+
const triggers = eventTriggers(app);
|
|
460
|
+
const WithWorkflows = Workflows.layer(definitions, { run: mode === "runner", owners: workflowOwners(app) }).pipe(Layer.provideMerge(ClusterLayer(mode)));
|
|
461
|
+
const Triggers = Layer.effect(EventTriggers, Effect.gen(function* () {
|
|
462
|
+
const workflows = yield* Workflows;
|
|
463
|
+
return EventTriggers.of({
|
|
464
|
+
triggers,
|
|
465
|
+
start: (id, event) => {
|
|
466
|
+
// Matched on the trigger and the event type: an event never starts another trigger's workflow.
|
|
467
|
+
const trigger = triggers.find((t) => t.id === id && t.event === event.type);
|
|
468
|
+
if (trigger === undefined) {
|
|
469
|
+
return Effect.die(new Error(`No event trigger ${id} for events of type ${event.type}`));
|
|
470
|
+
}
|
|
471
|
+
return workflows
|
|
472
|
+
.start({
|
|
473
|
+
workflow: trigger.workflow,
|
|
474
|
+
key: `event:${trigger.id}:${event.id}`,
|
|
475
|
+
identity: { kind: "system", orgId: event.orgId },
|
|
476
|
+
input: { eventId: event.id, type: event.type, payload: event.payload },
|
|
477
|
+
// Only the emitting module's own triggers continue the emitting call's Progress tasks.
|
|
478
|
+
event: {
|
|
479
|
+
id: event.id,
|
|
480
|
+
handedOff: trigger.module !== undefined && trigger.module === event.module ? event.invocationId : null,
|
|
481
|
+
},
|
|
482
|
+
})
|
|
483
|
+
.pipe(Effect.asVoid);
|
|
484
|
+
},
|
|
485
|
+
});
|
|
486
|
+
}));
|
|
487
|
+
const Reactions = Layer.effect(KernelReactions, Effect.gen(function* () {
|
|
488
|
+
const workflows = yield* Workflows;
|
|
489
|
+
const notifications = yield* Notifications;
|
|
490
|
+
const sql = yield* SqlClient.SqlClient;
|
|
491
|
+
const devices = yield* deviceSettings.pipe(Effect.orDie);
|
|
492
|
+
return KernelReactions.of({
|
|
493
|
+
reactions: [
|
|
494
|
+
...inboxReactions(workflows, notifications),
|
|
495
|
+
...(hasPrivacy(app) ? privacyReactions(workflows) : []),
|
|
496
|
+
...(hasAgent(app) ? agentReactions(workflows, sql) : []),
|
|
497
|
+
// A device turn an agent run sent wakes the run when it settles.
|
|
498
|
+
...deviceReactions(workflows, devices.queueTtlMs, hasAgent(app) ? wakeRunForTurn(workflows, sql) : undefined),
|
|
499
|
+
...filesReactions(workflows),
|
|
500
|
+
...ingestionReactions(workflows),
|
|
501
|
+
...corpusReactions(workflows),
|
|
502
|
+
...effectReactions(workflows),
|
|
503
|
+
// Members' event automations, on every event type that names its record.
|
|
504
|
+
...(app.modules.includes(schedulerModule) ? automationReactions(app.modules, workflows, sql) : []),
|
|
505
|
+
],
|
|
506
|
+
});
|
|
507
|
+
}));
|
|
508
|
+
const WithScheduler = Layer.mergeAll(Scheduler.layer, Retention.layer, Triggers, Reactions).pipe(Layer.provideMerge(WithWorkflows));
|
|
509
|
+
// The kernel's maintenance runs beside its scheduler: on a runner, unless a test sweeps itself.
|
|
510
|
+
return mode === "runner" && schedulerLoop
|
|
511
|
+
? Layer.mergeAll(WithScheduler, Scheduler.loop.pipe(Layer.provide(WithScheduler)), Retention.loop.pipe(Layer.provide(WithScheduler)))
|
|
512
|
+
: WithScheduler;
|
|
513
|
+
};
|
|
514
|
+
/** The same database URL, naming another database. */
|
|
515
|
+
const withDatabase = (url, database) => {
|
|
516
|
+
const parsed = new URL(Redacted.value(url));
|
|
517
|
+
parsed.pathname = `/${encodeURIComponent(database)}`;
|
|
518
|
+
return Redacted.make(parsed.toString());
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* MAKE (an app with the kernel's make module): the runtime (installed modules for the invocation path) and the
|
|
522
|
+
* lifecycle, whose installs, rollbacks and previews run this same `setup`, in this process, with the deployment's
|
|
523
|
+
* configuration (for a preview, naming the preview's own database).
|
|
524
|
+
*/
|
|
525
|
+
const MakeServices = (app) => Layer.unwrap(Effect.gen(function* () {
|
|
526
|
+
const config = yield* KernelConfig;
|
|
527
|
+
const context = yield* Effect.context();
|
|
528
|
+
const run = (effect, kernelConfig) => effect.pipe(Effect.provideService(KernelConfig, kernelConfig), Effect.provide(context),
|
|
529
|
+
// Whatever setup refused (a defect for an invalid manifest) is the install's failure, never the kernel's.
|
|
530
|
+
Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.fail(Cause.squash(cause))), Effect.asVoid);
|
|
531
|
+
return MakeLifecycle.layer(app.modules, {
|
|
532
|
+
install: (modules, roleLockHeld) => run(setup(app, {
|
|
533
|
+
make: { modules },
|
|
534
|
+
owner: `${hostname()}:${process.pid}:make`,
|
|
535
|
+
makeRoleLocksHeld: [roleLockHeld],
|
|
536
|
+
}), config),
|
|
537
|
+
preview: (database, module) => run(setup({ name: `${app.name}-make-preview`, modules: [] }, {
|
|
538
|
+
make: { modules: [module] },
|
|
539
|
+
owner: `${hostname()}:${process.pid}:make-preview`,
|
|
540
|
+
makeRoleLocksHeld: [module.contract.name],
|
|
541
|
+
}), { ...config, databaseUrl: withDatabase(config.databaseUrl, database) }),
|
|
542
|
+
});
|
|
543
|
+
})).pipe(
|
|
544
|
+
// MAKE modules' subscribers, for the outbox dispatcher.
|
|
545
|
+
Layer.merge(MakeSubscriptionsLive), Layer.provideMerge(MakeRuntime.layer));
|
|
546
|
+
/**
|
|
547
|
+
* What the invocation path checks before it holds a call for consent or approval: a MAKE install request that cannot
|
|
548
|
+
* run (refused before an administrator is asked), and an `agent.send` the agent is not ready for (no model ready for
|
|
549
|
+
* the organisation, or attachments without file storage: refused before the message is stored).
|
|
550
|
+
*/
|
|
551
|
+
const Prechecks = (app) => Layer.effect(ActionPrechecks, Effect.gen(function* () {
|
|
552
|
+
const lifecycle = yield* Effect.serviceOption(MakeLifecycle);
|
|
553
|
+
const models = yield* ModelProviders;
|
|
554
|
+
const checks = new Map();
|
|
555
|
+
if (Option.isSome(lifecycle)) {
|
|
556
|
+
const make = lifecycle.value;
|
|
557
|
+
checks.set("make.install", (actor, input) => make.precheckInstall(actor, input));
|
|
558
|
+
}
|
|
559
|
+
if (app.agent !== undefined && hasAgent(app))
|
|
560
|
+
checks.set("agent.send", agentSendPrecheck(models, hasFiles(app)));
|
|
561
|
+
return ActionPrechecks.of({ checks });
|
|
562
|
+
}));
|
|
563
|
+
/** Kernel services over a database: everything except the HTTP routes. */
|
|
564
|
+
/** The app's auth provider, or Better Auth's. */
|
|
565
|
+
const authProviderLayer = (app) => Layer.succeed(AuthProvider, app.auth ?? betterAuthProvider);
|
|
566
|
+
export const KernelServices = (app, options = {}) => {
|
|
567
|
+
checkApp(app);
|
|
568
|
+
const ReleaseSettingsLayer = Layer.effect(ReleaseSettings, Effect.gen(function* () {
|
|
569
|
+
const config = yield* KernelConfig;
|
|
570
|
+
return ReleaseSettings.of({
|
|
571
|
+
appVersion: config.appVersion ?? app.release?.version,
|
|
572
|
+
minClientVersion: config.minClientVersion ?? app.release?.minClientVersion,
|
|
573
|
+
});
|
|
574
|
+
}));
|
|
575
|
+
// Telemetry first: every service below, and every request, runs under its tracer, metrics and error capture.
|
|
576
|
+
const TelemetryBase = Layer.unwrap(Effect.gen(function* () {
|
|
577
|
+
const config = yield* KernelConfig;
|
|
578
|
+
const errors = options.errorAdapter !== undefined
|
|
579
|
+
? ErrorCapture.layer(options.errorAdapter, {
|
|
580
|
+
environment: config.environment ?? "development",
|
|
581
|
+
release: config.telemetry?.release ?? config.appVersion ?? app.release?.version ?? null,
|
|
582
|
+
})
|
|
583
|
+
: ErrorCapture.fromConfig(config.telemetry, config.environment ?? "development", config.appVersion ?? app.release?.version ?? null);
|
|
584
|
+
// What span names and attributes may name: the app's registered actions, modules and workflows.
|
|
585
|
+
const contracts = app.modules.map((module) => module.contract);
|
|
586
|
+
const vocabulary = {
|
|
587
|
+
actions: new Set(contracts.flatMap((c) => Object.values(c.actions).map((a) => a.name))),
|
|
588
|
+
modules: new Set(contracts.map((c) => c.name)),
|
|
589
|
+
workflows: new Set(workflowDefinitions(app).map((definition) => definition.name)),
|
|
590
|
+
};
|
|
591
|
+
return Layer.merge(TelemetryTracing(config.telemetry, KERNEL_VERSION, vocabulary), errors);
|
|
592
|
+
}));
|
|
593
|
+
const Base = Layer.mergeAll(Registry.layer(app.modules, { disabledToolGroups: app.agentTools?.disabledGroups }), ReleaseSettingsLayer).pipe(Layer.provideMerge(TelemetryBase));
|
|
594
|
+
// Identity, and the one way deferred work acts (Authority).
|
|
595
|
+
const WithIdentity = Layer.mergeAll(Identity.layer, Authority.layer).pipe(Layer.provideMerge(authProviderLayer(app)), Layer.provideMerge(Base));
|
|
596
|
+
// The policy set every filter is compiled from: the registry's, or one that changes at runtime (keyed on its version).
|
|
597
|
+
const PolicyLayer = options.policySet === undefined
|
|
598
|
+
? Policy.layer
|
|
599
|
+
: Policy.layerWithPolicySet.pipe(Layer.provideMerge(options.policySet));
|
|
600
|
+
const WithPolicy = PolicyLayer.pipe(Layer.provideMerge(WithIdentity));
|
|
601
|
+
const WithOutbox = Layer.mergeAll(Audit.layer, Outbox.layer, Sharing.layer).pipe(Layer.provideMerge(WithPolicy));
|
|
602
|
+
// The inbox: work items and notifications (with their channels), which handlers, subscribers, the approval
|
|
603
|
+
// stage and the approval workflows all feed the same way.
|
|
604
|
+
const InboxServices = Layer.mergeAll(WorkItems.layer, Notifications.layer(app.emailTemplates ?? [])).pipe(Layer.provideMerge(NotificationChannels.layer(options.channels ?? [])), Layer.provideMerge(WithOutbox));
|
|
605
|
+
const WithInbox = Layer.effect(SubscriberApis, Effect.gen(function* () {
|
|
606
|
+
const workItems = yield* WorkItems;
|
|
607
|
+
const notifications = yield* Notifications;
|
|
608
|
+
return SubscriberApis.of({
|
|
609
|
+
forDelivery: (module, orgId) => {
|
|
610
|
+
const items = workItems.buffer(module, orgId);
|
|
611
|
+
const notify = notifications.buffer(orgId);
|
|
612
|
+
return {
|
|
613
|
+
workItems: items.api,
|
|
614
|
+
notify: notify.api,
|
|
615
|
+
apply: Effect.all([items.apply, notify.apply], { discard: true }),
|
|
616
|
+
};
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
})).pipe(Layer.provideMerge(InboxServices));
|
|
620
|
+
// Secrets, Metering and Connections, before the invocation path: the kernel's connections module's handlers
|
|
621
|
+
// and the connection sync workflow use them.
|
|
622
|
+
const WithSecrets = Secrets.layer.pipe(Layer.provideMerge(Layer.succeed(SecretRequirements, app.secrets ?? [])), Layer.provideMerge(options.keyEncryption ?? KeyEncryption.fromConfig), Layer.provideMerge(WithInbox));
|
|
623
|
+
const WithConnections = Connections.layer.pipe(Layer.provideMerge(Layer.mergeAll(ConnectionMetering.layer, Connectors.layer(app.connectors ?? []), AppConfig.layer(app.config), Layer.succeed(ConnectionSyncHooks, options.connectionSyncHooks ?? ConnectionSyncHooks.defaultValue()), Layer.succeed(DomainRecords, options.domainRecords ?? DomainRecords.defaultValue()))), Layer.provideMerge(options.custody ?? TokenCustody.secrets), Layer.provideMerge(WithSecrets));
|
|
624
|
+
// Files, Search and Ingestion, before the invocation path: their kernel modules' handlers, `ctx.files` and
|
|
625
|
+
// `ctx.ingestion` use them.
|
|
626
|
+
const WithIngestion = IngestionLayer.pipe(Layer.provideMerge(Layer.mergeAll(
|
|
627
|
+
// Each organisation's and person's own stores, and the deployment's: a file's key says which holds it.
|
|
628
|
+
RoutedStorageLayer(options.storage ?? StorageFromConfig(app)).pipe(Layer.provideMerge(StorageProviders.layer)), Layer.succeed(Extractors, options.extractors ?? []), Layer.succeed(IngestionHooks, options.ingestionHooks ?? IngestionHooks.defaultValue()), Layer.succeed(MakeHooks, options.makeHooks ?? MakeHooks.defaultValue()), Layer.succeed(InvocationHooks, options.invocationHooks ?? InvocationHooks.defaultValue()), ExtractionPoolFromConfig)), Layer.provideMerge(WithConnections));
|
|
629
|
+
const embeddings = app.search?.embeddings;
|
|
630
|
+
const SearchWithEmbeddings = embeddings === undefined
|
|
631
|
+
? SearchLayer
|
|
632
|
+
: SearchLayer.pipe(Layer.provide(SearchEmbeddings.layer(embeddings, app.agent)));
|
|
633
|
+
const WithFiles = Layer.mergeAll(FilesLayer, SearchWithEmbeddings).pipe(Layer.provideMerge(FileScannersLayer(options.fileScanner)), Layer.provideMerge(WithIngestion));
|
|
634
|
+
const WithApprovals = (options.approvals ?? Approvals.layer(approvalRules(app))).pipe(Layer.provideMerge(WithFiles));
|
|
635
|
+
// The query surface, settings and flags: they serve the kernel modules' actions and handlers' ctx.settings and
|
|
636
|
+
// ctx.flags, so they come before the invocation path.
|
|
637
|
+
const KernelData = Layer.mergeAll(QuerySurface.layer, Settings.layer(app.settings), Flags.layer.pipe(Layer.provide(Layer.succeed(FlagProviders, app.flagProviders ?? []))), Progress.layer, Versioning.layer, Collab.layer, Housekeeping.layer(hasCollab(app)), Privacy.layer(app.privacy)).pipe(Layer.provide(Layer.succeed(PrivacySources, options.privacySources ?? [])), Layer.provideMerge(Layer.succeed(CollabSettings, collabSettingsOf(options))), Layer.provideMerge(WithApprovals));
|
|
638
|
+
// Product analytics, gated by Privacy consent, before the invocation path that queues events.
|
|
639
|
+
const WithAnalytics = Layer.unwrap(Effect.gen(function* () {
|
|
640
|
+
const config = yield* KernelConfig;
|
|
641
|
+
return Analytics.fromConfig(config.telemetry, config.authSecret, app.analytics?.events, options.analyticsAdapter);
|
|
642
|
+
})).pipe(Layer.provideMerge(KernelData));
|
|
643
|
+
const WithKernelHandlers = Layer.effect(KernelActionHandlers, Effect.gen(function* () {
|
|
644
|
+
const surface = yield* QuerySurface;
|
|
645
|
+
const settings = yield* Settings;
|
|
646
|
+
const flags = yield* Flags;
|
|
647
|
+
const progress = yield* Progress;
|
|
648
|
+
const privacy = yield* Privacy;
|
|
649
|
+
const errors = yield* ErrorCapture;
|
|
650
|
+
const kernelSql = yield* SqlClient.SqlClient;
|
|
651
|
+
const schedulerConfig = durableConfig(yield* KernelConfig);
|
|
652
|
+
const query = {
|
|
653
|
+
[QUERY_ACTION]: (input, ctx, kernel) => surface.run({ asserted: kernel.asserted, actor: ctx.actor, sql: input.sql, limit: input.limit }).pipe(Effect.tap((outcome) => kernel.auditDetail(outcome.detail)), Effect.map((outcome) => outcome.result), Effect.catch((refused) => kernel.auditDetail(refused.detail).pipe(Effect.andThen(Effect.fail(refused.error))))),
|
|
654
|
+
[QUERY_VIEWS_ACTION]: () => surface.describe,
|
|
655
|
+
};
|
|
656
|
+
return KernelActionHandlers.of_([
|
|
657
|
+
[queryModule, query],
|
|
658
|
+
[settingsModule, settings.handlers],
|
|
659
|
+
[flagsModule, flags.handlers],
|
|
660
|
+
[progressModule, progress.handlers],
|
|
661
|
+
[privacyModule, privacy.handlers],
|
|
662
|
+
[telemetryModule, telemetryHandlers(errors)],
|
|
663
|
+
[schedulerModule, schedulerReads(kernelSql, schedulerConfig, automationCatalog(app))],
|
|
664
|
+
[notificationsModule, installationHandlers(kernelSql)],
|
|
665
|
+
[consentModule, consentReads(new Set(app.modules.map((module) => module.contract.name)))],
|
|
666
|
+
]);
|
|
667
|
+
})).pipe(Layer.provideMerge(app.modules.includes(makeModule) ? MakeServices(app).pipe(Layer.provideMerge(WithAnalytics)) : WithAnalytics));
|
|
668
|
+
// The organisation's model providers: one instance, which the agent's services and the send precheck share.
|
|
669
|
+
const Models = ModelProviders.layer(app.agent ?? { providers: [] });
|
|
670
|
+
const WithPrechecks = Prechecks(app).pipe(Layer.provide(Models), Layer.provideMerge(WithKernelHandlers));
|
|
671
|
+
const WithInvocation = Invocation.layer.pipe(Layer.provideMerge(WithPrechecks));
|
|
672
|
+
// The agent's services are in the kernel's context before durable work, so its run workflow can use them.
|
|
673
|
+
const WithAgent = AgentServices(app.agent, app.skills ?? [], Models).pipe(Layer.provideMerge(WithInvocation));
|
|
674
|
+
const WithDurable = DurableWork(app, options.durable ?? "runner", options.schedulerLoop ?? true).pipe(Layer.provideMerge(WithAgent));
|
|
675
|
+
const WithIngress = Ingress.layer(ingressSources(app)).pipe(Layer.provideMerge(IngressSecrets.fromConfig), Layer.provideMerge(WithDurable));
|
|
676
|
+
const IngressOnly = (options.durable ?? "runner") === "runner" && (options.ingressLoop ?? true)
|
|
677
|
+
? Layer.merge(WithIngress, Ingress.loop.pipe(Layer.provide(WithIngress)))
|
|
678
|
+
: WithIngress;
|
|
679
|
+
const WithSync = ConnectionSync.layer(connectionSyncDefinitions(app)).pipe(Layer.provideMerge(IngressOnly));
|
|
680
|
+
const IngressWork = (options.durable ?? "runner") === "runner" && (options.connectionSyncLoop ?? true)
|
|
681
|
+
? Layer.merge(WithSync, ConnectionSync.loop.pipe(Layer.provide(WithSync)))
|
|
682
|
+
: WithSync;
|
|
683
|
+
const WithRelease = Layer.mergeAll(Directory.layer, MachineIdentity.layer, Devices.layer, Release.layer(app.modules, KERNEL_VERSION), DispatcherHeartbeat.layer).pipe(Layer.provideMerge(IngressWork));
|
|
684
|
+
const Services = Readiness.layer({
|
|
685
|
+
durable: options.durable ?? "runner",
|
|
686
|
+
dispatcher: options.dispatcher !== false,
|
|
687
|
+
}).pipe(Layer.provideMerge(WithRelease));
|
|
688
|
+
// Expired sharing grants are deleted as they expire, which reaches connected replicas live.
|
|
689
|
+
const Shared = options.sharingSweep === false ? Services : Layer.merge(Services, Sharing.sweeper().pipe(Layer.provide(Services)));
|
|
690
|
+
// Abandoned uploads, staged files and deleted files' bytes, on runners of apps that install Files.
|
|
691
|
+
const Swept = hasFiles(app) && (options.durable ?? "runner") === "runner" && options.filesSweep !== false
|
|
692
|
+
? Layer.merge(Shared, FilesSweeper.pipe(Layer.provide(Services)))
|
|
693
|
+
: Shared;
|
|
694
|
+
// Collaborative documents due for compaction, on runners of apps that install the collab module.
|
|
695
|
+
const Compacted = hasCollab(app) && (options.durable ?? "runner") === "runner" && options.collab?.sweep !== false
|
|
696
|
+
? Layer.merge(Swept, Housekeeping.sweeper(collabSettingsOf(options).sweepMs).pipe(Layer.provide(Services)))
|
|
697
|
+
: Swept;
|
|
698
|
+
// The search index's embeddings, on runners of apps that configure them.
|
|
699
|
+
const Embedded = embeddings !== undefined && (options.durable ?? "runner") === "runner" && options.searchEmbeddingLoop !== false
|
|
700
|
+
? Layer.merge(Compacted, SearchEmbeddingLoop().pipe(Layer.provide(Services)))
|
|
701
|
+
: Compacted;
|
|
702
|
+
// Removed app-state entries and acknowledged commands past their retention, on runners of apps that install it.
|
|
703
|
+
const Retained = app.modules.some((m) => m.contract.name === "app_state") &&
|
|
704
|
+
(options.durable ?? "runner") === "runner" &&
|
|
705
|
+
options.appStateSweep !== false
|
|
706
|
+
? Layer.merge(Embedded, AppStateSweeper().pipe(Layer.provide(Services)))
|
|
707
|
+
: Embedded;
|
|
708
|
+
return options.dispatcher === false ? Retained : Layer.merge(Retained, OutboxDispatcher.pipe(Layer.provide(Services)));
|
|
709
|
+
};
|
|
710
|
+
const collabSettingsOf = (options) => ({
|
|
711
|
+
reauthMs: options.collab?.reauthMs ?? 15_000,
|
|
712
|
+
sweepMs: options.collab?.sweepMs ?? 10_000,
|
|
713
|
+
});
|
|
714
|
+
/**
|
|
715
|
+
* Better Auth's routes. Its handler is given the body already read within the kernel's limits, and the client
|
|
716
|
+
* address its rate limiter keys on, stated by the kernel (`x-eloxiv-client-address`).
|
|
717
|
+
*/
|
|
718
|
+
const AuthRoutes = Layer.unwrap(Effect.gen(function* () {
|
|
719
|
+
const config = yield* KernelConfig;
|
|
720
|
+
const limits = httpConfig(config);
|
|
721
|
+
const hops = proxyHops(machineConfig(config));
|
|
722
|
+
return HttpRouter.add("*", "/auth/*", (request) => Effect.gen(function* () {
|
|
723
|
+
const identity = yield* Identity;
|
|
724
|
+
const web = yield* boundedWebRequest(request, { maxBytes: limits.maxBodyBytes, timeoutMs: limits.bodyTimeoutMs }, clientAddress(request, hops),
|
|
725
|
+
// Better Auth routes by the public path (its base URL's): the base path the edge took off goes back on.
|
|
726
|
+
basePathOf(config.baseUrl));
|
|
727
|
+
if (web._tag !== "Request")
|
|
728
|
+
return refusalResponse(web);
|
|
729
|
+
// The kernel in front of Better Auth and underneath it, and sign-out its own: `Identity.handleAuth`.
|
|
730
|
+
return HttpServerResponse.fromWeb(yield* identity.handleAuth(web.request));
|
|
731
|
+
}));
|
|
732
|
+
}));
|
|
733
|
+
/**
|
|
734
|
+
* Every request body read on any route (Effect's HTTP API, RPC, MCP) stops at `http.maxBodyBytes`, counted as
|
|
735
|
+
* it arrives; routes that read bodies themselves set smaller limits and a deadline (`surfaces/request.ts`). Every
|
|
736
|
+
* read, here or in them, must finish within `http.bodyTimeoutMs`: the runtime's server enforces it (`runtime/idle.ts`).
|
|
737
|
+
*/
|
|
738
|
+
const BodyLimit = Layer.unwrap(Effect.gen(function* () {
|
|
739
|
+
const limits = httpConfig(yield* KernelConfig);
|
|
740
|
+
return HttpRouter.middleware((httpEffect) => Effect.provideService(httpEffect, HttpIncomingMessage.MaxBodySize, ByteSize.bytes(limits.maxBodyBytes)), { global: true });
|
|
741
|
+
}));
|
|
742
|
+
/**
|
|
743
|
+
* A person's session that could not be looked up (`AuthUnavailable`: the lookups' connections all taken past the
|
|
744
|
+
* bound, or the database failing) is `503` on every route, whatever the route makes of other failures: never a
|
|
745
|
+
* `401` a client would take for a sign-out.
|
|
746
|
+
*/
|
|
747
|
+
const AuthUnavailableAnswer = HttpRouter.middleware((httpEffect) => httpEffect.pipe(Effect.catchCause((cause) => Cause.squash(cause) instanceof AuthUnavailable
|
|
748
|
+
? Effect.succeed(HttpServerResponse.text(JSON.stringify({
|
|
749
|
+
_tag: "Unavailable",
|
|
750
|
+
message: "The session could not be looked up just now: try again",
|
|
751
|
+
}), { status: 503, contentType: "application/json" }))
|
|
752
|
+
: Effect.failCause(cause))), { global: true });
|
|
753
|
+
/** Liveness (the Readiness contract): the process answers. */
|
|
754
|
+
const Health = HttpRouter.add("GET", HEALTH_PATH, HttpServerResponse.json({ status: "ok", version: KERNEL_VERSION }));
|
|
755
|
+
/** Readiness: every check with its reason; 503 while any check is not ready (degraded still serves). */
|
|
756
|
+
const Ready = HttpRouter.add("GET", READY_PATH, Effect.gen(function* () {
|
|
757
|
+
const readiness = yield* Readiness;
|
|
758
|
+
const report = yield* readiness.check;
|
|
759
|
+
return yield* HttpServerResponse.json(report, { status: report.status === "not-ready" ? 503 : 200 });
|
|
760
|
+
}).pipe(Effect.orDie));
|
|
761
|
+
/** The signed-in caller's organisations (Directory `listMyOrganizations`), for an organisation switcher. */
|
|
762
|
+
const MyOrganizations = HttpRouter.add("GET", MY_ORGANIZATIONS_PATH, (request) => Effect.gen(function* () {
|
|
763
|
+
const directory = yield* Directory;
|
|
764
|
+
const headers = new Headers();
|
|
765
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
766
|
+
if (typeof value === "string")
|
|
767
|
+
headers.set(name, value);
|
|
768
|
+
return yield* directory
|
|
769
|
+
.as(headers)
|
|
770
|
+
.listMyOrganizations({})
|
|
771
|
+
.pipe(Effect.flatMap((organizations) => HttpServerResponse.json(organizations)), Effect.catchTag("Unauthenticated", (error) => HttpServerResponse.json(error, { status: 401 })));
|
|
772
|
+
}).pipe(Effect.orDie));
|
|
773
|
+
/**
|
|
774
|
+
* The members of the organisation the caller acts in, for a settings screen: a person's own session only (an API
|
|
775
|
+
* token, scoped or not, an OAuth grant, an agent session or a device is refused), in the organisation `x-eloxiv-org`
|
|
776
|
+
* names. It reads on the person's behalf, so like the agent's routes it runs under their chain, asserted (Authority:
|
|
777
|
+
* a membership removed is refused), and the read is made in the assertion's own transaction, with the membership's
|
|
778
|
+
* row locked (`Directory.membersFor`, which takes the capability): a removal either waits for it or commits first
|
|
779
|
+
* and is seen.
|
|
780
|
+
*/
|
|
781
|
+
const OrgMembers = HttpRouter.add("GET", ORG_MEMBERS_PATH, (request) => Effect.gen(function* () {
|
|
782
|
+
const identity = yield* Identity;
|
|
783
|
+
const authority = yield* Authority;
|
|
784
|
+
const directory = yield* Directory;
|
|
785
|
+
const headers = new Headers();
|
|
786
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
787
|
+
if (typeof value === "string")
|
|
788
|
+
headers.set(name, value);
|
|
789
|
+
return yield* identity.authenticateCall(headers, "http").pipe(Effect.flatMap((resolved) => resolved.credential.kind !== "session" || resolved.session.agent
|
|
790
|
+
? Effect.fail(new Forbidden({
|
|
791
|
+
action: "eloxiv.directory.listMembers",
|
|
792
|
+
message: "Only a person's own signed-in session may list the organisation's members",
|
|
793
|
+
}))
|
|
794
|
+
: authority.within({ chain: credentialLinks(resolved.credential), who: resolved.actor, scope: resolved.credential.scope }, (asserted) => directory.membersFor(asserted))), Effect.flatMap((members) => HttpServerResponse.json(members)), Effect.catchTags({
|
|
795
|
+
Unauthenticated: (error) => HttpServerResponse.json(error, { status: 401 }),
|
|
796
|
+
Forbidden: (error) => HttpServerResponse.json(error, { status: 403 }),
|
|
797
|
+
}));
|
|
798
|
+
}).pipe(Effect.orDie));
|
|
799
|
+
/**
|
|
800
|
+
* WebMCP's agent sessions (`WEBMCP_PATHS`): a person's own signed-in session (no API token, OAuth grant, agent session
|
|
801
|
+
* or device) gets a fifteen-minute agent session for the browser agent working in their page, in the organisation it
|
|
802
|
+
* acts in. Every call with it is the agent's (ActionConsent holds what needs consent; tool groups disabled for agents
|
|
803
|
+
* and person-only actions are refused); `revoke`, with the agent session itself, ends it.
|
|
804
|
+
*/
|
|
805
|
+
const WEBMCP_SESSION_MS = 15 * 60 * 1000;
|
|
806
|
+
const WebMcpSessionRoutes = Layer.mergeAll(HttpRouter.add("POST", WEBMCP_PATHS.session, (request) => Effect.gen(function* () {
|
|
807
|
+
const identity = yield* Identity;
|
|
808
|
+
const headers = new Headers();
|
|
809
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
810
|
+
if (typeof value === "string")
|
|
811
|
+
headers.set(name, value);
|
|
812
|
+
return yield* identity.authenticateCall(headers, "http").pipe(Effect.flatMap((resolved) => resolved.credential.kind !== "session" || resolved.session.agent
|
|
813
|
+
? Effect.fail(new Forbidden({
|
|
814
|
+
action: "webmcp.session",
|
|
815
|
+
message: "Only a person's own signed-in session may start a browser agent's session",
|
|
816
|
+
}))
|
|
817
|
+
: identity.issueAgentSession({
|
|
818
|
+
userId: resolved.actor.userId,
|
|
819
|
+
orgId: resolved.actor.orgId,
|
|
820
|
+
label: "browser agent (WebMCP)",
|
|
821
|
+
ttlMs: WEBMCP_SESSION_MS,
|
|
822
|
+
authority: { scope: null, chain: credentialLinks(resolved.credential) },
|
|
823
|
+
})), Effect.flatMap((issued) => HttpServerResponse.json({ id: issued.id, token: issued.token, expiresAt: issued.expiresAt }, { headers: { "cache-control": "no-store" } })), Effect.catchTags({
|
|
824
|
+
Unauthenticated: (error) => HttpServerResponse.json(error, { status: 401 }),
|
|
825
|
+
Forbidden: (error) => HttpServerResponse.json(error, { status: 403 }),
|
|
826
|
+
}));
|
|
827
|
+
}).pipe(Effect.orDie)), HttpRouter.add("POST", WEBMCP_PATHS.revoke, (request) => Effect.gen(function* () {
|
|
828
|
+
const identity = yield* Identity;
|
|
829
|
+
const headers = new Headers();
|
|
830
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
831
|
+
if (typeof value === "string")
|
|
832
|
+
headers.set(name, value);
|
|
833
|
+
return yield* identity.authenticateCall(headers, "http").pipe(Effect.flatMap((resolved) => resolved.session.agentSessionId === undefined
|
|
834
|
+
? Effect.fail(new Forbidden({ action: "webmcp.revoke", message: "Not an agent session" }))
|
|
835
|
+
: identity.revokeAgentSession(resolved.session.agentSessionId)), Effect.flatMap(() => HttpServerResponse.json({ revoked: true })), Effect.catchTags({
|
|
836
|
+
Unauthenticated: (error) => HttpServerResponse.json(error, { status: 401 }),
|
|
837
|
+
Forbidden: (error) => HttpServerResponse.json(error, { status: 403 }),
|
|
838
|
+
}));
|
|
839
|
+
}).pipe(Effect.orDie)));
|
|
840
|
+
/** The MCP server's identity (`MCP_IDENTITY_PATH`): the canonical name and endpoints every connect flow uses. */
|
|
841
|
+
const McpIdentityRoute = (app) => HttpRouter.add("GET", MCP_IDENTITY_PATH, Effect.gen(function* () {
|
|
842
|
+
const config = yield* KernelConfig;
|
|
843
|
+
const base = config.baseUrl.replace(/\/+$/u, "");
|
|
844
|
+
return yield* HttpServerResponse.json({
|
|
845
|
+
name: mcpServerName(app.name),
|
|
846
|
+
title: app.name,
|
|
847
|
+
version: KERNEL_VERSION,
|
|
848
|
+
endpoint: `${base}/mcp`,
|
|
849
|
+
resource: `${base}/mcp`,
|
|
850
|
+
resourceMetadata: `${base}/.well-known/oauth-protected-resource/mcp`,
|
|
851
|
+
transport: "streamable-http",
|
|
852
|
+
});
|
|
853
|
+
}).pipe(Effect.orDie));
|
|
854
|
+
/** The release the kernel advertises (the Release contract), so clients can tell they are out of date. */
|
|
855
|
+
const ReleaseRoute = HttpRouter.add("GET", RELEASE_PATH, Effect.gen(function* () {
|
|
856
|
+
const release = yield* Release;
|
|
857
|
+
return yield* HttpServerResponse.json(yield* release.info);
|
|
858
|
+
}).pipe(Effect.orDie));
|
|
859
|
+
/**
|
|
860
|
+
* The unsubscribe link every system email carries (`GET`, and RFC 8058 one-click `POST`): the signed token
|
|
861
|
+
* names the organisation, the person and the category. No session is needed; the change is audited.
|
|
862
|
+
*/
|
|
863
|
+
const unsubscribe = (request) => Effect.gen(function* () {
|
|
864
|
+
const notifications = yield* Notifications;
|
|
865
|
+
const token = new URL(request.url, "http://localhost").searchParams.get("token") ?? "";
|
|
866
|
+
const result = yield* notifications.unsubscribe(token).pipe(Effect.result);
|
|
867
|
+
return result._tag === "Success"
|
|
868
|
+
? HttpServerResponse.text(`You will no longer receive ${result.success.category} emails.`)
|
|
869
|
+
: HttpServerResponse.text("This unsubscribe link is not valid.", { status: 400 });
|
|
870
|
+
});
|
|
871
|
+
const UnsubscribeRoutes = Layer.mergeAll(HttpRouter.add("GET", UNSUBSCRIBE_PATH, unsubscribe), HttpRouter.add("POST", UNSUBSCRIBE_PATH, unsubscribe));
|
|
872
|
+
/**
|
|
873
|
+
* The Directory's management operations over HTTP: `POST /kernel/directory/<operation>` (a person's own signed-in
|
|
874
|
+
* session, in the organisation `x-eloxiv-org` names; the person's own operations in none).
|
|
875
|
+
*/
|
|
876
|
+
const DirectoryRoutes = Layer.unwrap(Effect.gen(function* () {
|
|
877
|
+
const directory = yield* Directory;
|
|
878
|
+
const operations = Object.fromEntries(DIRECTORY_ADMIN_OPERATIONS.map((name) => [
|
|
879
|
+
name,
|
|
880
|
+
(headers, raw) => directory.as(headers)[name](raw),
|
|
881
|
+
]));
|
|
882
|
+
return HttpRouter.add("POST", `${DIRECTORY_OPERATIONS_PATH}/*`, managedRoute(operations));
|
|
883
|
+
}));
|
|
884
|
+
/** MachineIdentity management over HTTP: `POST /kernel/machine-identity/<operation>` (a signed-in session). */
|
|
885
|
+
const MachineIdentityRoutes = Layer.unwrap(Effect.gen(function* () {
|
|
886
|
+
const machine = yield* MachineIdentity;
|
|
887
|
+
return HttpRouter.add("POST", "/kernel/machine-identity/*", managedRoute(machine.operations));
|
|
888
|
+
}));
|
|
889
|
+
/** All HTTP routes: auth, RPC, HTTP actions, MCP, sync and health. */
|
|
890
|
+
export const KernelRoutes = (app) => Effect.gen(function* () {
|
|
891
|
+
const config = yield* KernelConfig;
|
|
892
|
+
const contracts = app.modules.map((m) => m.contract);
|
|
893
|
+
return Layer.mergeAll(BodyLimit, AuthUnavailableAnswer,
|
|
894
|
+
// Before every route: a state-changing request with the session cookie must come from the kernel's own or a
|
|
895
|
+
// trusted origin, with a body the route takes (surfaces/CookieGuard.ts).
|
|
896
|
+
CookieGuard({
|
|
897
|
+
kernel: new URL(config.baseUrl).origin,
|
|
898
|
+
trusted: config.trustedOrigins,
|
|
899
|
+
proxyHops: proxyHops(machineConfig(config)),
|
|
900
|
+
}), AuthRoutes, Health, UnsubscribeRoutes, Ready, ReleaseRoute, MyOrganizations, OrgMembers, MemberRoutes, WebMcpSessionRoutes, McpIdentityRoute(app), RpcSurface(contracts), HttpSurface(contracts), McpSurface(contracts, KERNEL_VERSION, app.mcp), OAuthRoutes({ ...defaultPages, ...app.oauthPages }), MachineIdentityRoutes, DirectoryRoutes, AvatarRoutes, DesktopSignInRoutes, DecideRoute, EnterpriseRoutes, DeviceRoutes, IngressRoutes, hasAgent(app) ? Layer.mergeAll(AgentRoutes, ModelSetupRoutes) : Layer.empty, app.modules.includes(makeModule) ? MakeRoutes : Layer.empty, hasCollab(app) ? CollabRoutes : Layer.empty, ConnectionRoutes, SecretsRoutes, FileRoutes, VisitRoutes, app.sync ? Layer.mergeAll(SyncEndpoint(app.sync), SyncMutateEndpoint) : Layer.empty, HttpRouter.cors({
|
|
901
|
+
allowedOrigins: [...config.trustedOrigins],
|
|
902
|
+
credentials: true,
|
|
903
|
+
allowedHeaders: [
|
|
904
|
+
"authorization",
|
|
905
|
+
"content-type",
|
|
906
|
+
"idempotency-key",
|
|
907
|
+
"x-eloxiv-org",
|
|
908
|
+
"x-eloxiv-surface",
|
|
909
|
+
TWO_FACTOR_CHALLENGE_HEADER,
|
|
910
|
+
"last-event-id",
|
|
911
|
+
CLIENT_VERSION_HEADER,
|
|
912
|
+
"mcp-session-id",
|
|
913
|
+
"mcp-protocol-version",
|
|
914
|
+
"traceparent",
|
|
915
|
+
"tracestate",
|
|
916
|
+
"b3",
|
|
917
|
+
],
|
|
918
|
+
exposedHeaders: ["set-auth-token", "mcp-session-id", "www-authenticate"],
|
|
919
|
+
})).pipe(Layer.provideMerge(BasePathMiddleware));
|
|
920
|
+
}).pipe(Layer.unwrap);
|
|
921
|
+
/**
|
|
922
|
+
* The kernel's HTTP application on a platform `HttpServer`. The server layer is
|
|
923
|
+
* provided innermost, so it is built (and starts listening) only after the
|
|
924
|
+
* database pool and every kernel service are ready: a request can never reach
|
|
925
|
+
* a listening port whose handlers are still being built. (On Node, a request
|
|
926
|
+
* accepted before the handlers are attached is never answered; see
|
|
927
|
+
* `runtime/node`.)
|
|
928
|
+
*/
|
|
929
|
+
export const KernelHttp = (app,
|
|
930
|
+
/** The platform server layer (`HttpServer` and the platform services it brings). */
|
|
931
|
+
server, options = {}) => HttpRouter.serve(KernelRoutes(app)).pipe(Layer.provide(server), Layer.provide(KernelServices(app, options)), Layer.provide(PgFromConfig));
|
|
932
|
+
/** The kernel role's connection pool, from `KernelConfig`. */
|
|
933
|
+
export const PgFromConfig = Layer.unwrap(Effect.gen(function* () {
|
|
934
|
+
const config = yield* KernelConfig;
|
|
935
|
+
return PgLayer(config.databaseUrl);
|
|
936
|
+
}));
|
|
937
|
+
/** The MAKE modules installed in the app's database, at the versions they run now (none before its first setup). */
|
|
938
|
+
const installedMakeModules = (adminUrl, database) => withClient(adminUrlFor(adminUrl, database), (sql) => Effect.gen(function* () {
|
|
939
|
+
const [present] = yield* sql `
|
|
940
|
+
SELECT pg_catalog.to_regclass('eloxiv.make_installation') IS NOT NULL AS present`;
|
|
941
|
+
if (present?.present !== true)
|
|
942
|
+
return [];
|
|
943
|
+
return yield* sql `
|
|
944
|
+
SELECT i.module, i.org_id AS "orgId", i.version, v.hash, v.source
|
|
945
|
+
FROM eloxiv.make_installation i JOIN eloxiv.make_version v ON v.module = i.module AND v.version = i.version
|
|
946
|
+
ORDER BY i.module`;
|
|
947
|
+
})).pipe(
|
|
948
|
+
// A database that does not exist yet has nothing installed.
|
|
949
|
+
Effect.catch((error) => error.reason.cause?.code === "3D000"
|
|
950
|
+
? Effect.succeed([])
|
|
951
|
+
: Effect.fail(error)), Effect.map((rows) => rows.map((row) => buildMakeModule(row.source, { orgId: row.orgId, version: row.version, hash: row.hash }))));
|
|
952
|
+
/**
|
|
953
|
+
* One-shot setup (the Release contract): bootstrap roles and the database as superuser, then, holding the
|
|
954
|
+
* migration lease, migrate Better Auth and apply the kernel's, Effect cluster's and every module's migrations
|
|
955
|
+
* with the hardening after them in one transaction, record schema snapshots and the setup's history. Fails
|
|
956
|
+
* with `ReleaseLeaseHeld` or `MigrationFailed`; a failure leaves the previous state intact.
|
|
957
|
+
*/
|
|
958
|
+
/**
|
|
959
|
+
* Before setup lets `owner` log in: the `pg_hba.conf` rules that would let any process in as it without its
|
|
960
|
+
* password during that moment. In production they are refused; in development (where local clusters trust local
|
|
961
|
+
* connections) they are a warning, once per process.
|
|
962
|
+
*/
|
|
963
|
+
let ownerRulesWarned = false;
|
|
964
|
+
const ownerLoginRules = (adminUrl, database, owner, environment) => Effect.gen(function* () {
|
|
965
|
+
if (environment !== "production" && ownerRulesWarned)
|
|
966
|
+
return;
|
|
967
|
+
const rules = yield* withClient(adminUrl, (sql) => passwordlessOwnerRules(sql, database, owner));
|
|
968
|
+
const refused = rules.filter((r) => ownerLoginMethodVerdict(r.method) === "refuse").map((r) => r.rule);
|
|
969
|
+
const weak = rules.filter((r) => ownerLoginMethodVerdict(r.method) === "warn").map((r) => r.rule);
|
|
970
|
+
if (weak.length > 0 && !ownerRulesWarned) {
|
|
971
|
+
yield* Effect.logWarning(`pg_hba.conf lets ${owner} (a module's owner role) log in to ${database} with a weaker password method ` +
|
|
972
|
+
`(${weak.join("; ")}): use scram-sha-256`);
|
|
973
|
+
}
|
|
974
|
+
if (refused.length === 0) {
|
|
975
|
+
ownerRulesWarned = true;
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const message = `pg_hba.conf lets ${owner} (a module's owner role) log in to ${database} by something other than its password ` +
|
|
979
|
+
`(${refused.join("; ")}): while setup lets it log in, any process that can connect that way could log in as ` +
|
|
980
|
+
`it. Make owner roles authenticate by password (scram-sha-256) for this database`;
|
|
981
|
+
if (environment === "production")
|
|
982
|
+
return yield* Effect.fail(new Error(`${message}; setup refuses to run otherwise`));
|
|
983
|
+
ownerRulesWarned = true;
|
|
984
|
+
yield* Effect.logWarning(`${message} (allowed outside production, ELOXIV_ENV)`);
|
|
985
|
+
});
|
|
986
|
+
export const setup = (app, options = {}) => Effect.scoped(Effect.gen(function* () {
|
|
987
|
+
yield* Effect.try({ try: () => checkApp(app), catch: (e) => e }).pipe(Effect.orDie);
|
|
988
|
+
const config = yield* KernelConfig;
|
|
989
|
+
// zero-cache's schemas, for the app id it runs with, are not a module's either.
|
|
990
|
+
const zeroProblems = zeroSchemaProblems(app.modules, config.zeroAppId ?? "zero");
|
|
991
|
+
if (zeroProblems.length > 0)
|
|
992
|
+
return yield* Effect.die(new InvalidManifest(zeroProblems));
|
|
993
|
+
const rebaseline = options.rebaselineKernelState ?? process.env["ELOXIV_SETUP_REBASELINE"] === "1";
|
|
994
|
+
const target = parseDatabaseUrl(config.databaseUrl);
|
|
995
|
+
// MAKE modules: the ones the MAKE runtime gives (checked), or the ones installed now (checked here like the app's).
|
|
996
|
+
const makeModules = options.make?.modules ??
|
|
997
|
+
(app.modules.includes(makeModule)
|
|
998
|
+
? yield* installedMakeModules(config.adminDatabaseUrl, target.database).pipe(Effect.orDie)
|
|
999
|
+
: []);
|
|
1000
|
+
if (options.make === undefined && makeModules.length > 0) {
|
|
1001
|
+
const problems = makeModuleProblems(app.modules, makeModules);
|
|
1002
|
+
if (problems.length > 0)
|
|
1003
|
+
return yield* Effect.die(new InvalidManifest(problems));
|
|
1004
|
+
}
|
|
1005
|
+
const modules = [...app.modules, ...makeModules];
|
|
1006
|
+
// What the database host allows (db/Host.ts), before anything changes: what setup needs and cannot replace is
|
|
1007
|
+
// required, and setup refuses to start without it; every protection the host allows is applied.
|
|
1008
|
+
const host = yield* withClient(config.adminDatabaseUrl, (sql) => Effect.gen(function* () {
|
|
1009
|
+
const missing = yield* hostRequirementProblems(sql);
|
|
1010
|
+
if (missing.length > 0) {
|
|
1011
|
+
return yield* Effect.die(new Error(`Setup refuses to run: the role in ELOXIV_ADMIN_DATABASE_URL is no superuser and lacks what setup needs: ${missing.join("; ")}`));
|
|
1012
|
+
}
|
|
1013
|
+
return yield* detectHost(sql, REVOKED_CATALOG_FUNCTIONS, config.rolePasswords);
|
|
1014
|
+
})).pipe(Effect.orDie);
|
|
1015
|
+
// Before any role or password changes: the host is held to the profile the last setup recorded (a database
|
|
1016
|
+
// moved to a host that allows less, or to another setup role, is refused here, before `bootstrapCluster` could
|
|
1017
|
+
// send a MAKE role's password in plain text). The comparison under the lease repeats it with the rest.
|
|
1018
|
+
const recordedHost = yield* withClient(adminUrlFor(config.adminDatabaseUrl, target.database), recordedKernelState).pipe(Effect.map((recorded) => (recorded.kind === "recorded" ? recorded.host : undefined)),
|
|
1019
|
+
// A database that does not exist yet has recorded nothing.
|
|
1020
|
+
Effect.catch((error) => error.reason.cause?.code === "3D000"
|
|
1021
|
+
? Effect.succeed(undefined)
|
|
1022
|
+
: Effect.fail(error)), Effect.orDie);
|
|
1023
|
+
const hosted = hostDifferences(recordedHost, host);
|
|
1024
|
+
if (hosted.length > 0) {
|
|
1025
|
+
if (!rebaseline)
|
|
1026
|
+
return yield* new MigrationFailed({ module: KERNEL_MODULE, migration: null, message: hostRefusal(hosted) });
|
|
1027
|
+
yield* Effect.logWarning(`Re-baselining the database host's profile as it is now: ${hosted.join("; ")}`);
|
|
1028
|
+
}
|
|
1029
|
+
const degraded = degradedProtections(host);
|
|
1030
|
+
if (degraded.length > 0) {
|
|
1031
|
+
yield* Effect.logInfo(`The database host does not allow ${degraded.join(", ")}: setup applies what replaces each (docs/contracts/release.md, "Database hosts")`);
|
|
1032
|
+
}
|
|
1033
|
+
// A MAKE module's roles are the cluster's, and a preview elsewhere drops them when it ends unless its database
|
|
1034
|
+
// installed the module: its role lock is held from creating them here until this setup has referenced them (its
|
|
1035
|
+
// end), so none is dropped in between (contracts/sandbox.md; backlog 49).
|
|
1036
|
+
yield* holdMakeRoleLocks(config.adminDatabaseUrl, makeModules.map((m) => m.contract.name).filter((name) => !(options.makeRoleLocksHeld ?? []).includes(name)), options.waitMs ?? 120_000).pipe(Effect.orDie);
|
|
1037
|
+
const cluster = yield* bootstrapCluster({
|
|
1038
|
+
adminUrl: config.adminDatabaseUrl,
|
|
1039
|
+
target,
|
|
1040
|
+
modules,
|
|
1041
|
+
host,
|
|
1042
|
+
comment: config.databaseComment,
|
|
1043
|
+
makePassword: (role) => makeRolePassword(makeRoleKeyOf(config), role),
|
|
1044
|
+
});
|
|
1045
|
+
const registry = yield* Effect.provide(Registry.asEffectOf(), Registry.layer(app.modules, { disabledToolGroups: app.agentTools?.disabledGroups }));
|
|
1046
|
+
const owner = options.owner ?? `${hostname()}:${process.pid}`;
|
|
1047
|
+
const databaseUrl = adminUrlFor(config.adminDatabaseUrl, target.database);
|
|
1048
|
+
const lease = {
|
|
1049
|
+
owner,
|
|
1050
|
+
waitMs: options.waitMs ?? 120_000,
|
|
1051
|
+
ttlMs: options.leaseTtlMs ?? 30_000,
|
|
1052
|
+
kernelRole: target.role,
|
|
1053
|
+
};
|
|
1054
|
+
// Everything below runs on the one session that holds the lease (losing it stops the work), except each
|
|
1055
|
+
// module's migrations, which run on a session logged in as the module's owner role (Release.ts).
|
|
1056
|
+
return yield* withLease(databaseUrl, lease, (sql, leasePid) => Effect.gen(function* () {
|
|
1057
|
+
const [clock] = yield* sql `SELECT clock_timestamp() AS now`.pipe(Effect.orDie);
|
|
1058
|
+
const startedAt = clock.now;
|
|
1059
|
+
const exit = yield* Effect.exit(Effect.gen(function* () {
|
|
1060
|
+
// The kernel's schemas as the last setup left them, before anything here changes them.
|
|
1061
|
+
yield* assertKernelState(sql, host, rebaseline);
|
|
1062
|
+
// What acts with the setup role's privileges, or holds the kernel's recorded state, is a trusted owner's.
|
|
1063
|
+
const untrusted = yield* untrustedSetupObjects(sql).pipe(Effect.orDie);
|
|
1064
|
+
if (untrusted.length > 0) {
|
|
1065
|
+
return yield* new MigrationFailed({
|
|
1066
|
+
module: KERNEL_MODULE,
|
|
1067
|
+
migration: null,
|
|
1068
|
+
message: `Setup refuses to run: ${untrusted.join("; ")}, neither a superuser nor the role setup runs as ` +
|
|
1069
|
+
`(${host.setupRole}). Give them back to it (ALTER ... OWNER TO), then run setup again.`,
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
yield* bootstrapDatabase(sql, target, host).pipe(Effect.orDie);
|
|
1073
|
+
// Better Auth's pending migrations, read through its own pool (nothing is written there) and applied
|
|
1074
|
+
// in the setup's transaction.
|
|
1075
|
+
const authMigrations = yield* Effect.gen(function* () {
|
|
1076
|
+
const identity = yield* Identity;
|
|
1077
|
+
return yield* identity.pendingMigrations;
|
|
1078
|
+
}).pipe(Effect.provide(Identity.forMigration.pipe(Layer.provideMerge(authProviderLayer(app)), Layer.provideMerge(PgLayer(config.databaseUrl)))));
|
|
1079
|
+
return yield* migrateAndHarden(sql, {
|
|
1080
|
+
modules,
|
|
1081
|
+
// A MAKE module's row-level security comes from its own policy alone.
|
|
1082
|
+
policies: (module) => (module.make !== undefined ? module.policy : registry.policies),
|
|
1083
|
+
kernelRole: target.role,
|
|
1084
|
+
authMigrations,
|
|
1085
|
+
leasePid,
|
|
1086
|
+
ownerSession: (role) => Effect.andThen(
|
|
1087
|
+
// The rules where setup can read them; elsewhere connectOwner tests the login window instead.
|
|
1088
|
+
host.hbaRules
|
|
1089
|
+
? ownerLoginRules(config.adminDatabaseUrl, target.database, role, config.environment ?? "development")
|
|
1090
|
+
: Effect.void, connectOwner(config.adminDatabaseUrl, target.database, role, {
|
|
1091
|
+
host,
|
|
1092
|
+
hbaProbe: config.environment === "production" ? "refuse" : "warn",
|
|
1093
|
+
})),
|
|
1094
|
+
host,
|
|
1095
|
+
rolesRepaired: cluster.rolesRepaired,
|
|
1096
|
+
kernelVersion: KERNEL_VERSION,
|
|
1097
|
+
adminSession: (f) => withClient(databaseUrl, f),
|
|
1098
|
+
});
|
|
1099
|
+
}));
|
|
1100
|
+
yield* recordHistory(sql, { owner, startedAt, exit });
|
|
1101
|
+
const report = yield* exit;
|
|
1102
|
+
return { owner, ...report };
|
|
1103
|
+
}));
|
|
1104
|
+
}));
|
|
1105
|
+
export { PgClient, Redacted };
|
|
1106
|
+
//# sourceMappingURL=Server.js.map
|