@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
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ingress (docs/contracts/ingress.md): inbound webhooks at `POST /ingress/<source>`.
|
|
3
|
+
*
|
|
4
|
+
* 1. verify the source's verifier, with its secrets (`IngressSecrets`), in constant time
|
|
5
|
+
* 2. replay the signed timestamp within the tolerance window; the delivery id stored for the retention
|
|
6
|
+
* period (a redelivery with the same body joins; a different body under the same id is refused)
|
|
7
|
+
* 3. accept persist the raw delivery and answer 2xx only after the commit; then start (or join) the
|
|
8
|
+
* durable execution `eloxiv.ingress` keyed by (source, delivery id). A sweep starts any that
|
|
9
|
+
* a crash left unstarted
|
|
10
|
+
* 4. act in the execution: resolve the sender (a linked platform identity, or a declared service
|
|
11
|
+
* principal) and run the handler through the invocation path with surface `ingress`.
|
|
12
|
+
* Unlinked senders never act. A delivery carrying a link code completes the link instead
|
|
13
|
+
*
|
|
14
|
+
* Refusals are audited (`eloxiv.ingress.<source>`, surface `ingress`, outcome `denied`) by the body's hash,
|
|
15
|
+
* and logged without the payload or its signature.
|
|
16
|
+
*/
|
|
17
|
+
import { linkedIdentityLink } from "../Authority.ts"
|
|
18
|
+
import { asModuleCode } from "../KernelModule.ts"
|
|
19
|
+
import type { ExecutionIdentity, Surface } from "@eloxiv/contracts"
|
|
20
|
+
import {
|
|
21
|
+
AuthorityRecord,
|
|
22
|
+
Forbidden,
|
|
23
|
+
IngressContract,
|
|
24
|
+
InvalidInput,
|
|
25
|
+
InvalidSignature,
|
|
26
|
+
MACHINE_MANAGE,
|
|
27
|
+
PayloadTooLarge,
|
|
28
|
+
ReplayedDelivery,
|
|
29
|
+
StaleDelivery,
|
|
30
|
+
UnknownSource,
|
|
31
|
+
WorkflowFailed,
|
|
32
|
+
type IngressRefusal,
|
|
33
|
+
type InvocationError,
|
|
34
|
+
} from "@eloxiv/contracts"
|
|
35
|
+
import { createHash } from "node:crypto"
|
|
36
|
+
import { Context, Duration, Effect, Layer, Option, Redacted, Schedule, Schema } from "effect"
|
|
37
|
+
import { HttpRouter, HttpServerResponse } from "effect/http"
|
|
38
|
+
import { SqlClient } from "effect/sql"
|
|
39
|
+
import { Audit } from "../Audit.ts"
|
|
40
|
+
import { httpConfig, ingressConfig, ingressSecretVariable, KernelConfig } from "../Config.ts"
|
|
41
|
+
import {
|
|
42
|
+
MAX_INGRESS_REPLIES,
|
|
43
|
+
type AgentAnswer,
|
|
44
|
+
type AnyWorkflowDefinition,
|
|
45
|
+
type ChannelSend,
|
|
46
|
+
type IngressHandlerApi,
|
|
47
|
+
type IngressReplyOutcome,
|
|
48
|
+
type StepInvocation,
|
|
49
|
+
type WorkflowContext,
|
|
50
|
+
} from "../durable/Definition.ts"
|
|
51
|
+
import { defineKernelWorkflow, untrustedRequest, type KernelWorkflowContext } from "../durable/Trust.ts"
|
|
52
|
+
import { makeManaged, managedRoute, type ManageFailure } from "../machine/Managed.ts"
|
|
53
|
+
import { hashOf, secret } from "../machine/Tokens.ts"
|
|
54
|
+
import { toWebHeaders } from "../surfaces/headers.ts"
|
|
55
|
+
import { readBody, refusalMessage, refusalResponse, type BodyRead } from "../surfaces/request.ts"
|
|
56
|
+
import { stepKey, Workflows } from "../Workflows.ts"
|
|
57
|
+
import { AgentRuntime } from "../agent/Runtime.ts"
|
|
58
|
+
import { Authority } from "../Authority.ts"
|
|
59
|
+
import { channelSpend } from "../agent/Channels.ts"
|
|
60
|
+
import { CHANNEL_DEFAULTS, Connections } from "../connections/Connections.ts"
|
|
61
|
+
import type { IngressAnswer, IngressDelivery, IngressSourceDefinition } from "./Definition.ts"
|
|
62
|
+
|
|
63
|
+
export const INGRESS_WORKFLOW = "eloxiv.ingress"
|
|
64
|
+
export const INGRESS_PATH = "/ingress"
|
|
65
|
+
const LINK_CODE_TTL_S = 600
|
|
66
|
+
|
|
67
|
+
/** Where verifier secrets come from. Configuration for now; the Secrets contract will replace it. */
|
|
68
|
+
export class IngressSecrets extends Context.Service<
|
|
69
|
+
IngressSecrets,
|
|
70
|
+
{ readonly secretsFor: (source: string) => Effect.Effect<ReadonlyArray<string>> }
|
|
71
|
+
>()("@eloxiv/kernel/IngressSecrets") {
|
|
72
|
+
/** `ELOXIV_INGRESS_SECRET_<SOURCE>` (comma-separated during rotation), or `KernelConfig.ingress.secrets`. */
|
|
73
|
+
static readonly fromConfig = Layer.effect(
|
|
74
|
+
IngressSecrets,
|
|
75
|
+
Effect.gen(function* () {
|
|
76
|
+
const config = ingressConfig(yield* KernelConfig)
|
|
77
|
+
return IngressSecrets.of({
|
|
78
|
+
secretsFor: (source) =>
|
|
79
|
+
Effect.succeed(
|
|
80
|
+
(config.secrets[source] ?? config.secrets[ingressSecretVariable(source)] ?? []).map((s) =>
|
|
81
|
+
Redacted.value(s),
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
})
|
|
85
|
+
}),
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The headers stored with a delivery: `content-type` and those the source keeps (never its signature). */
|
|
90
|
+
const keptHeaders = (source: IngressSourceDefinition, headers: Headers) => {
|
|
91
|
+
const kept: Record<string, string> = {}
|
|
92
|
+
for (const name of ["content-type", ...(source.keepHeaders ?? [])]) {
|
|
93
|
+
const value = headers.get(name)
|
|
94
|
+
if (value !== null) kept[name.toLowerCase()] = value
|
|
95
|
+
}
|
|
96
|
+
return kept
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const iso = (value: unknown) => (value instanceof Date ? value.toISOString() : typeof value === "string" ? value : null)
|
|
100
|
+
|
|
101
|
+
interface DeliveryRow {
|
|
102
|
+
readonly source: string
|
|
103
|
+
readonly deliveryId: string
|
|
104
|
+
readonly body: Uint8Array
|
|
105
|
+
readonly bodyHash: string
|
|
106
|
+
readonly headers: Record<string, string>
|
|
107
|
+
readonly signedAt: unknown
|
|
108
|
+
readonly receivedAt: unknown
|
|
109
|
+
readonly state: string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const deliveryOf = (row: DeliveryRow): IngressDelivery => ({
|
|
113
|
+
source: row.source,
|
|
114
|
+
deliveryId: row.deliveryId,
|
|
115
|
+
body: Buffer.from(row.body).toString("utf8"),
|
|
116
|
+
headers: row.headers,
|
|
117
|
+
signedAt: iso(row.signedAt),
|
|
118
|
+
receivedAt: iso(row.receivedAt)!,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const Resolved = Schema.Union([
|
|
122
|
+
Schema.Struct({
|
|
123
|
+
kind: Schema.Literal("act"),
|
|
124
|
+
userId: Schema.String,
|
|
125
|
+
orgId: Schema.String,
|
|
126
|
+
/**
|
|
127
|
+
* What the delivery acts under (Authority): a linked sender's link, or nothing revocable for a declared service
|
|
128
|
+
* principal. Absent in an identity journalled before links were: the delivery is refused (it fails closed).
|
|
129
|
+
*/
|
|
130
|
+
authority: Schema.optionalKey(AuthorityRecord),
|
|
131
|
+
}),
|
|
132
|
+
Schema.Struct({ kind: Schema.Literal("done"), outcome: Schema.String }),
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
const ReplyOutcome = Schema.Struct({
|
|
136
|
+
state: Schema.Literals(["sent", "failed", "unknown"]),
|
|
137
|
+
messageId: Schema.NullOr(Schema.String),
|
|
138
|
+
error: Schema.NullOr(Schema.String),
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const Admitted = Schema.Union([
|
|
142
|
+
Schema.Struct({ kind: Schema.Literal("refused"), reason: Schema.Literals(["disabled", "budget"]) }),
|
|
143
|
+
Schema.Struct({
|
|
144
|
+
kind: Schema.Literal("send"),
|
|
145
|
+
reservationId: Schema.String,
|
|
146
|
+
connectionId: Schema.String,
|
|
147
|
+
channelId: Schema.String,
|
|
148
|
+
threadKey: Schema.NullOr(Schema.String),
|
|
149
|
+
conversationId: Schema.NullOr(Schema.String),
|
|
150
|
+
mode: Schema.Literals(["act", "plan"]),
|
|
151
|
+
}),
|
|
152
|
+
])
|
|
153
|
+
|
|
154
|
+
const Recorded = Schema.Struct({ runId: Schema.String, conversationId: Schema.String })
|
|
155
|
+
|
|
156
|
+
const Polled = Schema.Struct({
|
|
157
|
+
/** The run's status, or `gone` when it is not the actor's (or no longer readable as theirs). */
|
|
158
|
+
status: Schema.String,
|
|
159
|
+
result: Schema.NullOr(Schema.String),
|
|
160
|
+
/** When it was read (epoch ms): the deadline is judged on journalled times, so a replay decides the same. */
|
|
161
|
+
at: Schema.Number,
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
const FINAL = new Set(["succeeded", "stopped", "failed", "cancelled"])
|
|
165
|
+
const ANSWER_DEFAULT_MS = 5 * 60_000
|
|
166
|
+
const ANSWER_MAX_MS = 60 * 60_000
|
|
167
|
+
/** The longest wait between two looks at a run: short at first (most answers take seconds), then every 15 s. */
|
|
168
|
+
const ANSWER_POLL_MAX_MS = 15_000
|
|
169
|
+
const REPLY_MAX_CHARS = 40_000
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The durable execution that processes one accepted delivery (key `<source>:<delivery id>`). It reads the
|
|
173
|
+
* delivery and the kernel's link tables through the kernel's connection (provided by the engine), so it is
|
|
174
|
+
* built with the app's sources and workflows and registered like any workflow.
|
|
175
|
+
*/
|
|
176
|
+
export const ingressWorkflow = (
|
|
177
|
+
sources: ReadonlyArray<IngressSourceDefinition>,
|
|
178
|
+
workflows: ReadonlyArray<AnyWorkflowDefinition>,
|
|
179
|
+
) => {
|
|
180
|
+
const bySource = new Map(sources.map((source) => [source.name, source]))
|
|
181
|
+
const byWorkflow = new Map(workflows.map((workflow) => [workflow.name, workflow]))
|
|
182
|
+
// Kernel code (it reads and records deliveries in the kernel's tables): its body runs with the kernel's
|
|
183
|
+
// services; a module workflow it hands a delivery to runs without them.
|
|
184
|
+
return defineKernelWorkflow({
|
|
185
|
+
name: INGRESS_WORKFLOW,
|
|
186
|
+
input: Schema.Struct({ source: Schema.String, deliveryId: Schema.String }),
|
|
187
|
+
output: Schema.Struct({ outcome: Schema.String }),
|
|
188
|
+
run: (input, ctx) =>
|
|
189
|
+
Effect.gen(function* () {
|
|
190
|
+
const sql = yield* SqlClient.SqlClient
|
|
191
|
+
const authority = yield* Authority
|
|
192
|
+
const audit = yield* Audit
|
|
193
|
+
const connections = yield* Effect.serviceOption(Connections)
|
|
194
|
+
const runtime = yield* Effect.serviceOption(AgentRuntime)
|
|
195
|
+
const source = bySource.get(input.source)
|
|
196
|
+
if (source === undefined) return yield* new WorkflowFailed({ message: `No ingress source ${input.source}` })
|
|
197
|
+
const failed = (e: unknown) => new WorkflowFailed({ message: String(e) })
|
|
198
|
+
const [row] = yield* sql<DeliveryRow>`
|
|
199
|
+
SELECT source, delivery_id AS "deliveryId", body, body_hash AS "bodyHash", headers, signed_at AS "signedAt",
|
|
200
|
+
received_at AS "receivedAt", state
|
|
201
|
+
FROM eloxiv.ingress_delivery WHERE source = ${input.source} AND delivery_id = ${input.deliveryId}`.pipe(
|
|
202
|
+
Effect.mapError(failed),
|
|
203
|
+
)
|
|
204
|
+
if (row === undefined) return yield* new WorkflowFailed({ message: "The delivery is gone" })
|
|
205
|
+
const delivery = deliveryOf(row)
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Settle the delivery once: its state, its outcome, and for a refusal its audit record, in one
|
|
209
|
+
* transaction that only an accepted delivery passes (a step re-run after a crash changes nothing).
|
|
210
|
+
*/
|
|
211
|
+
const finish = (state: "processed" | "refused" | "failed", outcome: string, denial?: string) =>
|
|
212
|
+
sql
|
|
213
|
+
.withTransaction(
|
|
214
|
+
Effect.gen(function* () {
|
|
215
|
+
const settled = yield* sql`UPDATE eloxiv.ingress_delivery
|
|
216
|
+
SET state = ${state}, outcome = ${outcome}, finished_at = now()
|
|
217
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} AND state = 'accepted'
|
|
218
|
+
RETURNING 1 AS one`
|
|
219
|
+
if (settled.length > 0 && denial !== undefined) {
|
|
220
|
+
yield* sql`INSERT INTO eloxiv.audit_log
|
|
221
|
+
(id, invocation_id, action, surface, actor_user_id, org_id, outcome, input_hash, idempotency_key, error_tag)
|
|
222
|
+
VALUES (${crypto.randomUUID()}, ${ctx.executionId}, ${`eloxiv.ingress.${input.source}`}, 'ingress',
|
|
223
|
+
NULL, NULL, 'denied', ${row.bodyHash}, ${input.deliveryId}, ${denial})`
|
|
224
|
+
}
|
|
225
|
+
const [current] = yield* sql<{ outcome: string | null }>`
|
|
226
|
+
SELECT outcome FROM eloxiv.ingress_delivery WHERE source = ${input.source} AND delivery_id = ${input.deliveryId}`
|
|
227
|
+
return current?.outcome ?? outcome
|
|
228
|
+
}),
|
|
229
|
+
)
|
|
230
|
+
.pipe(Effect.mapError(failed))
|
|
231
|
+
|
|
232
|
+
// 1. Who the delivery acts as, or what it did instead (completed a link, refused an unlinked sender).
|
|
233
|
+
const resolved = yield* ctx.step("identity", Resolved, () =>
|
|
234
|
+
Effect.gen(function* () {
|
|
235
|
+
const identity = source.identity
|
|
236
|
+
if (identity.kind === "principal") {
|
|
237
|
+
const [principal] = yield* sql<{ id: string }>`
|
|
238
|
+
SELECT id FROM eloxiv.service_principal WHERE org_id = ${identity.org} AND name = ${identity.principal}`
|
|
239
|
+
if (principal === undefined) {
|
|
240
|
+
return { kind: "done" as const, outcome: yield* finish("refused", "no-principal", "Unauthenticated") }
|
|
241
|
+
}
|
|
242
|
+
// A declared service principal: its source names it; nothing revocable stands between.
|
|
243
|
+
return {
|
|
244
|
+
kind: "act" as const,
|
|
245
|
+
userId: principal.id,
|
|
246
|
+
orgId: identity.org,
|
|
247
|
+
authority: { scope: null, chain: [] },
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const sender = identity.sender(delivery)
|
|
251
|
+
if (sender === undefined || sender.externalId.length === 0) {
|
|
252
|
+
return { kind: "done" as const, outcome: yield* finish("refused", "unlinked", "Unauthenticated") }
|
|
253
|
+
}
|
|
254
|
+
// The organisations the delivery may act in: those with an active Connection to the account that
|
|
255
|
+
// received it, when the source names one (a shared channel's delivery is not the sender's org's).
|
|
256
|
+
let orgs: ReadonlyArray<string> | undefined
|
|
257
|
+
if (identity.receivedBy !== undefined) {
|
|
258
|
+
const account = identity.receivedBy(delivery)
|
|
259
|
+
orgs =
|
|
260
|
+
account === undefined || account.accountId.length === 0
|
|
261
|
+
? []
|
|
262
|
+
: (yield* sql<{ orgId: string }>`
|
|
263
|
+
SELECT DISTINCT org_id AS "orgId" FROM eloxiv.connection
|
|
264
|
+
WHERE provider = ${account.provider} AND account_id = ${account.accountId} AND status = 'active'`).map(
|
|
265
|
+
(row) => row.orgId,
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
const within = (orgId: string) => orgs === undefined || orgs.includes(orgId)
|
|
269
|
+
if (sender.linkCode !== undefined) {
|
|
270
|
+
// Completing a link: the code proves the Eloxiv side, the verified delivery the platform side.
|
|
271
|
+
const outcome = yield* sql.withTransaction(
|
|
272
|
+
Effect.gen(function* () {
|
|
273
|
+
// A code from an organisation the receiving account is not connected to stays unused.
|
|
274
|
+
const [code] = yield* sql<{ orgId: string; actorId: string }>`
|
|
275
|
+
UPDATE eloxiv.link_code SET used_at = now(), used_by = ${sender.externalId}
|
|
276
|
+
WHERE hash = ${hashOf(sender.linkCode!)} AND platform = ${identity.platform}
|
|
277
|
+
AND used_at IS NULL AND expires_at > now()
|
|
278
|
+
AND (${orgs === undefined} OR org_id IN ${sql.in(orgs ?? [""])})
|
|
279
|
+
RETURNING org_id AS "orgId", actor_id AS "actorId"`
|
|
280
|
+
if (code === undefined) return undefined
|
|
281
|
+
yield* sql`INSERT INTO eloxiv.linked_identity (platform, external_id, org_id, actor_id, linked_by)
|
|
282
|
+
VALUES (${identity.platform}, ${sender.externalId}, ${code.orgId}, ${code.actorId}, ${`delivery:${input.deliveryId}`})
|
|
283
|
+
ON CONFLICT (platform, external_id) DO UPDATE
|
|
284
|
+
SET org_id = EXCLUDED.org_id, actor_id = EXCLUDED.actor_id, linked_by = EXCLUDED.linked_by, created_at = now()`
|
|
285
|
+
return "linked"
|
|
286
|
+
}),
|
|
287
|
+
)
|
|
288
|
+
return {
|
|
289
|
+
kind: "done" as const,
|
|
290
|
+
outcome:
|
|
291
|
+
outcome === undefined
|
|
292
|
+
? yield* finish("refused", "link-refused", "Forbidden")
|
|
293
|
+
: yield* finish("processed", outcome),
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const [link] = yield* sql<{ orgId: string; actorId: string }>`
|
|
297
|
+
SELECT org_id AS "orgId", actor_id AS "actorId" FROM eloxiv.linked_identity
|
|
298
|
+
WHERE platform = ${identity.platform} AND external_id = ${sender.externalId}`
|
|
299
|
+
if (link === undefined || !within(link.orgId)) {
|
|
300
|
+
return { kind: "done" as const, outcome: yield* finish("refused", "unlinked", "Unauthenticated") }
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
kind: "act" as const,
|
|
304
|
+
userId: link.actorId,
|
|
305
|
+
orgId: link.orgId,
|
|
306
|
+
authority: { scope: null, chain: [linkedIdentityLink(identity.platform, sender.externalId)] },
|
|
307
|
+
}
|
|
308
|
+
}).pipe(Effect.mapError(failed)),
|
|
309
|
+
)
|
|
310
|
+
if (resolved.kind === "done") return { outcome: resolved.outcome }
|
|
311
|
+
|
|
312
|
+
// 2. The handler, as the actor, through the invocation path (identity and policy re-checked there).
|
|
313
|
+
// The handler acts only while the link it acts through stands (asserted, locked, in every call it makes): an
|
|
314
|
+
// unlink, or a link moved to someone else, refuses it.
|
|
315
|
+
const actor: ExecutionIdentity = {
|
|
316
|
+
kind: "user",
|
|
317
|
+
userId: resolved.userId,
|
|
318
|
+
orgId: resolved.orgId,
|
|
319
|
+
authority: resolved.authority ?? "unrecorded",
|
|
320
|
+
}
|
|
321
|
+
const sender = { userId: resolved.userId, orgId: resolved.orgId }
|
|
322
|
+
const senderChain = resolved.authority?.chain
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* One reply, posted in the delivery's own conversation through the Connection that received it (the source's
|
|
326
|
+
* `reply`): kernel code, run as a journalled step of this execution. The claim, committed before the platform
|
|
327
|
+
* is asked, asserts the sender's chain (their link) and the receiving Connection (its owner's, still active);
|
|
328
|
+
* a step found claimed already (the process died mid-call) is `unknown`, never posted again.
|
|
329
|
+
*/
|
|
330
|
+
const postReply = (step: string, text: string) =>
|
|
331
|
+
Effect.gen(function* () {
|
|
332
|
+
const key = `${input.source}:${input.deliveryId}:${step}`
|
|
333
|
+
/** The reply's audit record: the receiving Connection's owner, acting for this delivery and its sender. */
|
|
334
|
+
const audited = (record: {
|
|
335
|
+
readonly connectionId: string
|
|
336
|
+
readonly ownerId: string
|
|
337
|
+
readonly state: IngressReplyOutcome["state"]
|
|
338
|
+
readonly errorTag: string | null
|
|
339
|
+
}) =>
|
|
340
|
+
audit.record({
|
|
341
|
+
invocationId: ctx.executionId,
|
|
342
|
+
action: "eloxiv.ingress.reply",
|
|
343
|
+
surface: "ingress",
|
|
344
|
+
actorUserId: record.ownerId,
|
|
345
|
+
orgId: sender.orgId,
|
|
346
|
+
outcome: record.state === "sent" ? "succeeded" : "failed",
|
|
347
|
+
inputHash: createHash("sha256").update(text).digest("hex"),
|
|
348
|
+
idempotencyKey: key,
|
|
349
|
+
errorTag: record.errorTag,
|
|
350
|
+
affected: null,
|
|
351
|
+
requested: null,
|
|
352
|
+
completion: null,
|
|
353
|
+
detail: {
|
|
354
|
+
connectionId: record.connectionId,
|
|
355
|
+
source: input.source,
|
|
356
|
+
deliveryId: input.deliveryId,
|
|
357
|
+
sender: sender.userId,
|
|
358
|
+
channelId: conversation?.channelId ?? null,
|
|
359
|
+
threadId: conversation?.threadId ?? null,
|
|
360
|
+
state: record.state,
|
|
361
|
+
},
|
|
362
|
+
ownWork: true,
|
|
363
|
+
})
|
|
364
|
+
const ended = (outcome: IngressReplyOutcome) => Effect.succeed(outcome)
|
|
365
|
+
const conversation = source.reply?.conversation(delivery)
|
|
366
|
+
const account = source.identity.kind === "linked" ? source.identity.receivedBy?.(delivery) : undefined
|
|
367
|
+
if (conversation === undefined || account === undefined) {
|
|
368
|
+
return yield* ended({ state: "failed", messageId: null, error: "The delivery names no conversation" })
|
|
369
|
+
}
|
|
370
|
+
if (senderChain === undefined || Option.isNone(connections)) {
|
|
371
|
+
return yield* ended({ state: "failed", messageId: null, error: "Nothing can reply for this delivery" })
|
|
372
|
+
}
|
|
373
|
+
const claim = yield* sql
|
|
374
|
+
.withTransaction(
|
|
375
|
+
Effect.gen(function* () {
|
|
376
|
+
// The delivery's row, locked: its replies are claimed one at a time, so the count below holds. A step
|
|
377
|
+
// claimed already is settled from its own record first: recording what happened needs no authority to
|
|
378
|
+
// post again (the sender's link or the Connection may have gone since).
|
|
379
|
+
yield* sql`SELECT 1 FROM eloxiv.ingress_delivery
|
|
380
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} FOR UPDATE`
|
|
381
|
+
const [existing] = yield* sql<{
|
|
382
|
+
state: string
|
|
383
|
+
messageId: string | null
|
|
384
|
+
error: string | null
|
|
385
|
+
connectionId: string
|
|
386
|
+
connectionOwner: string
|
|
387
|
+
}>`
|
|
388
|
+
SELECT state, message_id AS "messageId", error, connection_id AS "connectionId",
|
|
389
|
+
connection_owner AS "connectionOwner"
|
|
390
|
+
FROM eloxiv.ingress_reply
|
|
391
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} AND step = ${step} FOR UPDATE`
|
|
392
|
+
if (existing !== undefined) {
|
|
393
|
+
if (existing.state !== "running") {
|
|
394
|
+
const { state, messageId, error } = existing
|
|
395
|
+
return { kind: "done" as const, outcome: { state, messageId, error } as IngressReplyOutcome }
|
|
396
|
+
}
|
|
397
|
+
// Interrupted after it was claimed (the process died during the post, or before its outcome was
|
|
398
|
+
// written): it may have been posted. Recorded unknown, with its audit record, together.
|
|
399
|
+
const error = "The reply was interrupted: it may have been posted. Not posted again"
|
|
400
|
+
yield* sql`UPDATE eloxiv.ingress_reply SET state = 'unknown', error = ${error}, finished_at = now()
|
|
401
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} AND step = ${step}`
|
|
402
|
+
yield* audited({
|
|
403
|
+
connectionId: existing.connectionId,
|
|
404
|
+
ownerId: existing.connectionOwner,
|
|
405
|
+
state: "unknown",
|
|
406
|
+
errorTag: "Interrupted",
|
|
407
|
+
})
|
|
408
|
+
return { kind: "done" as const, outcome: { state: "unknown" as const, messageId: null, error } }
|
|
409
|
+
}
|
|
410
|
+
// The sender: only while the link the delivery acts through still stands.
|
|
411
|
+
const senderHeld = yield* authority.assert({ chain: senderChain, who: sender, scope: null })
|
|
412
|
+
// The receiving Connection, in the sender's organisation: the first one made, still active.
|
|
413
|
+
const [receiving] = yield* sql<{ id: string; ownerId: string }>`
|
|
414
|
+
SELECT id, owner_id AS "ownerId" FROM eloxiv.connection
|
|
415
|
+
WHERE provider = ${account.provider} AND account_id = ${account.accountId}
|
|
416
|
+
AND org_id = ${sender.orgId} AND status = 'active'
|
|
417
|
+
ORDER BY created_at, id LIMIT 1`
|
|
418
|
+
if (receiving === undefined) {
|
|
419
|
+
return {
|
|
420
|
+
kind: "done" as const,
|
|
421
|
+
outcome: {
|
|
422
|
+
state: "failed" as const,
|
|
423
|
+
messageId: null,
|
|
424
|
+
error: "No active Connection received the delivery",
|
|
425
|
+
},
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// Its owner's Connection, acting for this delivery: it must hold for them too.
|
|
429
|
+
const connectionHeld = yield* authority.assert({
|
|
430
|
+
chain: [{ kind: "connection", id: receiving.id }],
|
|
431
|
+
who: { userId: receiving.ownerId, orgId: sender.orgId },
|
|
432
|
+
scope: null,
|
|
433
|
+
})
|
|
434
|
+
const [count] = yield* sql<{ n: number }>`SELECT count(*)::int AS n FROM eloxiv.ingress_reply
|
|
435
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId}`
|
|
436
|
+
if ((count?.n ?? 0) >= MAX_INGRESS_REPLIES) {
|
|
437
|
+
return {
|
|
438
|
+
kind: "done" as const,
|
|
439
|
+
outcome: {
|
|
440
|
+
state: "failed" as const,
|
|
441
|
+
messageId: null,
|
|
442
|
+
error: `A delivery is answered at most ${MAX_INGRESS_REPLIES} times`,
|
|
443
|
+
},
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
yield* sql`INSERT INTO eloxiv.ingress_reply (source, delivery_id, step, org_id, actor_id, connection_id,
|
|
447
|
+
connection_owner, channel_id, thread_id, state)
|
|
448
|
+
VALUES (${input.source}, ${input.deliveryId}, ${step}, ${sender.orgId}, ${sender.userId}, ${receiving.id},
|
|
449
|
+
${receiving.ownerId}, ${conversation.channelId}, ${conversation.threadId}, 'running')`
|
|
450
|
+
// The checks at commit, last: a link or Connection that lapsed while the claim ran commits no claim,
|
|
451
|
+
// so nothing is posted. (Like an external effect's claim, it is the claim that is checked: a
|
|
452
|
+
// revocation waits for it, and one after it commits meets the post already under way.)
|
|
453
|
+
yield* authority.confirm(senderHeld)
|
|
454
|
+
yield* authority.confirm(connectionHeld)
|
|
455
|
+
return { kind: "run" as const, connectionId: receiving.id, ownerId: receiving.ownerId }
|
|
456
|
+
}),
|
|
457
|
+
)
|
|
458
|
+
.pipe(
|
|
459
|
+
Effect.catchTags({
|
|
460
|
+
Unauthenticated: (e) =>
|
|
461
|
+
Effect.succeed({
|
|
462
|
+
kind: "done" as const,
|
|
463
|
+
outcome: { state: "failed" as const, messageId: null, error: `Refused: ${e.message}` },
|
|
464
|
+
}),
|
|
465
|
+
Forbidden: (e) =>
|
|
466
|
+
Effect.succeed({
|
|
467
|
+
kind: "done" as const,
|
|
468
|
+
outcome: { state: "failed" as const, messageId: null, error: `Refused: ${e.message}` },
|
|
469
|
+
}),
|
|
470
|
+
}),
|
|
471
|
+
)
|
|
472
|
+
if (claim.kind === "done") return claim.outcome
|
|
473
|
+
// Only Messaging's sendMessage, to this conversation, through this Connection, as its owner.
|
|
474
|
+
const sent = yield* Effect.result(
|
|
475
|
+
connections.value
|
|
476
|
+
.capability(claim.connectionId, "messaging", { userId: claim.ownerId, orgId: sender.orgId })
|
|
477
|
+
.pipe(
|
|
478
|
+
Effect.flatMap((bound) =>
|
|
479
|
+
bound.operations["sendMessage"]!({
|
|
480
|
+
channelId: conversation.channelId,
|
|
481
|
+
threadId: conversation.threadId,
|
|
482
|
+
text,
|
|
483
|
+
}),
|
|
484
|
+
),
|
|
485
|
+
),
|
|
486
|
+
)
|
|
487
|
+
const failure =
|
|
488
|
+
sent._tag === "Failure"
|
|
489
|
+
? (sent.failure as { readonly _tag?: string; readonly message?: string })
|
|
490
|
+
: undefined
|
|
491
|
+
const outcome: IngressReplyOutcome =
|
|
492
|
+
failure === undefined
|
|
493
|
+
? {
|
|
494
|
+
state: "sent",
|
|
495
|
+
// Messaging's sendMessage answers the posted message's id (a string, checked against the contract).
|
|
496
|
+
messageId: (sent as { readonly success: { readonly id: string } }).success.id,
|
|
497
|
+
error: null,
|
|
498
|
+
}
|
|
499
|
+
: {
|
|
500
|
+
// A refusal means nothing was posted; anything else may hide that it was.
|
|
501
|
+
state: failure._tag !== undefined && failure._tag !== "Unavailable" ? "failed" : "unknown",
|
|
502
|
+
messageId: null,
|
|
503
|
+
error: `${failure._tag ?? "Defect"}: ${failure.message ?? ""}`.slice(0, 2000),
|
|
504
|
+
}
|
|
505
|
+
// The outcome and its audit record, together: neither is written without the other.
|
|
506
|
+
yield* sql.withTransaction(
|
|
507
|
+
Effect.gen(function* () {
|
|
508
|
+
yield* sql`UPDATE eloxiv.ingress_reply SET state = ${outcome.state}, message_id = ${outcome.messageId},
|
|
509
|
+
error = ${outcome.error}, finished_at = now()
|
|
510
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} AND step = ${step}`
|
|
511
|
+
yield* audited({
|
|
512
|
+
connectionId: claim.connectionId,
|
|
513
|
+
ownerId: claim.ownerId,
|
|
514
|
+
state: outcome.state,
|
|
515
|
+
errorTag: failure?._tag ?? null,
|
|
516
|
+
})
|
|
517
|
+
}),
|
|
518
|
+
)
|
|
519
|
+
return outcome
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
/** One look at an agent run of the sender's, under their chain: its status and final text. */
|
|
523
|
+
const pollRun = (runId: string) =>
|
|
524
|
+
Effect.gen(function* () {
|
|
525
|
+
if (Option.isNone(runtime) || senderChain === undefined) {
|
|
526
|
+
return { status: "gone", result: null, at: Date.now() }
|
|
527
|
+
}
|
|
528
|
+
const run = yield* authority
|
|
529
|
+
.within({ chain: senderChain, who: sender, scope: null }, (asserted) =>
|
|
530
|
+
runtime.value.status(asserted, runId),
|
|
531
|
+
)
|
|
532
|
+
.pipe(Effect.option)
|
|
533
|
+
if (Option.isNone(run)) return { status: "gone", result: null, at: Date.now() }
|
|
534
|
+
return { status: run.value.status, result: run.value.result, at: Date.now() }
|
|
535
|
+
})
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* The run an `agent.send` step started: its output names it; a replay of the step (the send committed, its step
|
|
539
|
+
* was not journalled) answers a receipt instead, whose created records are the send's message, from which the
|
|
540
|
+
* run is read back as the sender (under their chain, so nothing of anyone else's is found).
|
|
541
|
+
*/
|
|
542
|
+
const runOfSent = (sent: StepInvocation) =>
|
|
543
|
+
Effect.gen(function* () {
|
|
544
|
+
const result = sent.result as {
|
|
545
|
+
readonly kind?: string
|
|
546
|
+
readonly output?: { readonly runId?: unknown }
|
|
547
|
+
readonly receipt?: { readonly action?: string; readonly created?: ReadonlyArray<string> }
|
|
548
|
+
} | null
|
|
549
|
+
if (result?.kind === "output" && typeof result.output?.runId === "string") return result.output.runId
|
|
550
|
+
if (
|
|
551
|
+
result?.kind === "replay" &&
|
|
552
|
+
result.receipt?.action === "agent.send" &&
|
|
553
|
+
Option.isSome(runtime) &&
|
|
554
|
+
senderChain !== undefined
|
|
555
|
+
) {
|
|
556
|
+
for (const messageId of result.receipt.created ?? []) {
|
|
557
|
+
const found = yield* authority
|
|
558
|
+
.within({ chain: senderChain, who: sender, scope: null }, (asserted) =>
|
|
559
|
+
runtime.value.runOfMessage(asserted, messageId),
|
|
560
|
+
)
|
|
561
|
+
.pipe(Effect.option)
|
|
562
|
+
if (Option.isSome(found)) return found.value
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return yield* new WorkflowFailed({ message: "The agent.send step names no run of the sender's" })
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
const handlerApi: IngressHandlerApi = {
|
|
569
|
+
reply: (step, reply) =>
|
|
570
|
+
Effect.gen(function* () {
|
|
571
|
+
// Only the text is the handler's: where it goes and through which Connection are the delivery's.
|
|
572
|
+
const keys = typeof reply === "object" && reply !== null ? Object.keys(reply) : []
|
|
573
|
+
const text = (reply as { readonly text?: unknown } | null)?.text
|
|
574
|
+
if (keys.length !== 1 || keys[0] !== "text" || typeof text !== "string") {
|
|
575
|
+
return yield* new WorkflowFailed({ message: "A reply is its text, and nothing else" })
|
|
576
|
+
}
|
|
577
|
+
if (text.trim() === "" || text.length > REPLY_MAX_CHARS) {
|
|
578
|
+
return yield* new WorkflowFailed({ message: `A reply is 1 to ${REPLY_MAX_CHARS} characters` })
|
|
579
|
+
}
|
|
580
|
+
if (source.reply === undefined) {
|
|
581
|
+
return yield* new WorkflowFailed({ message: `Ingress source ${source.name} does not reply` })
|
|
582
|
+
}
|
|
583
|
+
return yield* ctx.step(`handler/reply/${step}`, ReplyOutcome, () =>
|
|
584
|
+
postReply(step, text).pipe(Effect.mapError(failed)),
|
|
585
|
+
)
|
|
586
|
+
}),
|
|
587
|
+
sendToAgent: (step, request) =>
|
|
588
|
+
Effect.gen(function* () {
|
|
589
|
+
const name = `handler/agent/${step}`
|
|
590
|
+
// 1. Admitted by the channel's settings (as the receiving Connection's channel), with what it continues.
|
|
591
|
+
const admitted = yield* ctx.step(`${name}/admit`, Admitted, () =>
|
|
592
|
+
Effect.gen(function* () {
|
|
593
|
+
const conversation = source.reply?.conversation(delivery)
|
|
594
|
+
const account = source.identity.kind === "linked" ? source.identity.receivedBy?.(delivery) : undefined
|
|
595
|
+
if (conversation === undefined || account === undefined) {
|
|
596
|
+
return yield* new WorkflowFailed({ message: "The delivery names no channel to answer in" })
|
|
597
|
+
}
|
|
598
|
+
const [receiving] = yield* sql<{ id: string }>`
|
|
599
|
+
SELECT id FROM eloxiv.connection
|
|
600
|
+
WHERE provider = ${account.provider} AND account_id = ${account.accountId}
|
|
601
|
+
AND org_id = ${sender.orgId} AND status = 'active'
|
|
602
|
+
ORDER BY created_at, id LIMIT 1`.pipe(Effect.orDie)
|
|
603
|
+
if (receiving === undefined) {
|
|
604
|
+
return yield* new WorkflowFailed({ message: "No active Connection received the delivery" })
|
|
605
|
+
}
|
|
606
|
+
const [setting] = yield* sql<{
|
|
607
|
+
enabled: boolean
|
|
608
|
+
scope: "act" | "plan"
|
|
609
|
+
dailyTokens: number | null
|
|
610
|
+
memory: "thread" | "channel" | "none"
|
|
611
|
+
}>`SELECT enabled, scope, daily_tokens AS "dailyTokens", memory FROM eloxiv.channel_setting
|
|
612
|
+
WHERE connection_id = ${receiving.id} AND channel_id = ${conversation.channelId}`.pipe(Effect.orDie)
|
|
613
|
+
const channel = setting ?? CHANNEL_DEFAULTS
|
|
614
|
+
if (!channel.enabled) return { kind: "refused" as const, reason: "disabled" as const }
|
|
615
|
+
// The budget, one admission at a time per channel: what its messages spent today (their runs and
|
|
616
|
+
// delegates, settled or still running) and reserved, then this message's reservation, together. A
|
|
617
|
+
// message reserves the whole budget until its run is known, then the run's token limit (if any).
|
|
618
|
+
const reservationId = stepKey(ctx.executionId, `${name}/admit`)
|
|
619
|
+
const admittedNow = yield* sql
|
|
620
|
+
.withTransaction(
|
|
621
|
+
Effect.gen(function* () {
|
|
622
|
+
yield* sql`SELECT pg_advisory_xact_lock(hashtextextended(${`eloxiv.channel:${receiving.id}:${conversation.channelId}`}, 0))`
|
|
623
|
+
// Admitted already (this step ran before a crash, its reservation kept): admitted.
|
|
624
|
+
const [kept] = yield* sql`SELECT 1 AS one FROM eloxiv.channel_run WHERE id = ${reservationId}`
|
|
625
|
+
if (kept !== undefined) return true
|
|
626
|
+
if (channel.dailyTokens !== null) {
|
|
627
|
+
const used = yield* channelSpend(sql, sender.orgId, receiving.id, conversation.channelId)
|
|
628
|
+
if (used >= channel.dailyTokens) return false
|
|
629
|
+
}
|
|
630
|
+
yield* sql`INSERT INTO eloxiv.channel_run (id, connection_id, channel_id, org_id, user_id, reserved)
|
|
631
|
+
VALUES (${reservationId}, ${receiving.id}, ${conversation.channelId}, ${sender.orgId},
|
|
632
|
+
${sender.userId}, ${channel.dailyTokens ?? 0})
|
|
633
|
+
ON CONFLICT (id) DO NOTHING`
|
|
634
|
+
return true
|
|
635
|
+
}),
|
|
636
|
+
)
|
|
637
|
+
.pipe(Effect.orDie)
|
|
638
|
+
if (!admittedNow) return { kind: "refused" as const, reason: "budget" as const }
|
|
639
|
+
const threadKey =
|
|
640
|
+
channel.memory === "thread"
|
|
641
|
+
? (conversation.threadId ?? conversation.channelId)
|
|
642
|
+
: channel.memory === "channel"
|
|
643
|
+
? "*"
|
|
644
|
+
: null
|
|
645
|
+
const [kept] =
|
|
646
|
+
threadKey === null
|
|
647
|
+
? []
|
|
648
|
+
: yield* sql<{ conversationId: string }>`
|
|
649
|
+
SELECT conversation_id AS "conversationId" FROM eloxiv.channel_conversation
|
|
650
|
+
WHERE connection_id = ${receiving.id} AND channel_id = ${conversation.channelId}
|
|
651
|
+
AND thread_key = ${threadKey} AND user_id = ${sender.userId}`.pipe(Effect.orDie)
|
|
652
|
+
return {
|
|
653
|
+
kind: "send" as const,
|
|
654
|
+
reservationId,
|
|
655
|
+
connectionId: receiving.id,
|
|
656
|
+
channelId: conversation.channelId,
|
|
657
|
+
threadKey,
|
|
658
|
+
conversationId: kept?.conversationId ?? null,
|
|
659
|
+
mode: channel.scope,
|
|
660
|
+
}
|
|
661
|
+
}).pipe(Effect.mapError(failed)),
|
|
662
|
+
)
|
|
663
|
+
if (admitted.kind === "refused") return admitted satisfies ChannelSend
|
|
664
|
+
// 2. The send, as the sender: in the kept conversation; a new one only when agent.send refused it as gone
|
|
665
|
+
// or still busy. A send that may have committed (its answer lost) is retried once under its own key, so
|
|
666
|
+
// a committed one answers its receipt and never starts a second run.
|
|
667
|
+
const send = (stepName: string, conversationId: string | null, keyOf?: string) =>
|
|
668
|
+
ctx.invoke(stepName, {
|
|
669
|
+
action: "agent.send",
|
|
670
|
+
input: {
|
|
671
|
+
text: request.text,
|
|
672
|
+
mode: admitted.mode,
|
|
673
|
+
...(conversationId === null ? {} : { conversationId }),
|
|
674
|
+
},
|
|
675
|
+
identity: actor,
|
|
676
|
+
surface: "ingress",
|
|
677
|
+
...(keyOf === undefined ? {} : { keyOf }),
|
|
678
|
+
})
|
|
679
|
+
const uncertain = (e: { readonly _tag: string }) =>
|
|
680
|
+
e._tag === "ActionFailed" && (e as { readonly effect?: string }).effect === "unknown"
|
|
681
|
+
const conversationRefused = (e: { readonly _tag: string }) =>
|
|
682
|
+
e._tag === "InvalidInput" &&
|
|
683
|
+
/^No conversation |still working on run /u.test((e as { readonly message?: string }).message ?? "")
|
|
684
|
+
const attempt = (stepName: string, conversationId: string | null) =>
|
|
685
|
+
send(stepName, conversationId).pipe(
|
|
686
|
+
Effect.catchIf(uncertain, () => send(`${stepName}/again`, conversationId, stepName)),
|
|
687
|
+
)
|
|
688
|
+
let sent: StepInvocation
|
|
689
|
+
if (admitted.conversationId === null) {
|
|
690
|
+
sent = yield* attempt(`${name}/send`, null).pipe(Effect.mapError(failed))
|
|
691
|
+
} else {
|
|
692
|
+
const continued = yield* Effect.result(attempt(`${name}/send`, admitted.conversationId))
|
|
693
|
+
if (continued._tag === "Success") sent = continued.success
|
|
694
|
+
else if (conversationRefused(continued.failure)) {
|
|
695
|
+
sent = yield* attempt(`${name}/send-new`, null).pipe(Effect.mapError(failed))
|
|
696
|
+
} else return yield* Effect.fail(failed(continued.failure))
|
|
697
|
+
}
|
|
698
|
+
// 3. Recorded against the channel: its run (for the budget) and the conversation the thread continues.
|
|
699
|
+
const recorded = yield* ctx.step(`${name}/record`, Recorded, () =>
|
|
700
|
+
Effect.gen(function* () {
|
|
701
|
+
const runId = yield* runOfSent(sent)
|
|
702
|
+
if (Option.isNone(runtime) || senderChain === undefined) {
|
|
703
|
+
return yield* new WorkflowFailed({ message: "No agent runtime" })
|
|
704
|
+
}
|
|
705
|
+
const run = yield* authority
|
|
706
|
+
.within({ chain: senderChain, who: sender, scope: null }, (asserted) =>
|
|
707
|
+
runtime.value.status(asserted, runId),
|
|
708
|
+
)
|
|
709
|
+
.pipe(Effect.mapError(failed))
|
|
710
|
+
// The reservation becomes the run's: it holds the run's token limit (if any) until the run ends.
|
|
711
|
+
yield* sql`UPDATE eloxiv.channel_run SET run_id = ${runId},
|
|
712
|
+
reserved = coalesce(${run.limits?.maxTokens ?? null}::int, reserved)
|
|
713
|
+
WHERE id = ${admitted.reservationId}`.pipe(Effect.orDie)
|
|
714
|
+
if (admitted.threadKey !== null) {
|
|
715
|
+
yield* sql`INSERT INTO eloxiv.channel_conversation (connection_id, channel_id, thread_key, org_id,
|
|
716
|
+
user_id, conversation_id)
|
|
717
|
+
VALUES (${admitted.connectionId}, ${admitted.channelId}, ${admitted.threadKey}, ${sender.orgId},
|
|
718
|
+
${sender.userId}, ${run.conversationId})
|
|
719
|
+
ON CONFLICT (connection_id, channel_id, thread_key, user_id) DO UPDATE
|
|
720
|
+
SET conversation_id = EXCLUDED.conversation_id, updated_at = now()`.pipe(Effect.orDie)
|
|
721
|
+
}
|
|
722
|
+
return { runId, conversationId: run.conversationId }
|
|
723
|
+
}),
|
|
724
|
+
)
|
|
725
|
+
return { kind: "sent" as const, ...recorded } satisfies ChannelSend
|
|
726
|
+
}),
|
|
727
|
+
agentAnswer: (step, request) =>
|
|
728
|
+
Effect.gen(function* () {
|
|
729
|
+
const limit = Math.min(ANSWER_MAX_MS, Math.max(1_000, request.timeoutMs ?? ANSWER_DEFAULT_MS))
|
|
730
|
+
const name = `handler/answer/${step}`
|
|
731
|
+
// The run: as named, or the one the send step started (journalled, so a resumed execution keeps it).
|
|
732
|
+
const runId =
|
|
733
|
+
"runId" in request
|
|
734
|
+
? request.runId
|
|
735
|
+
: yield* ctx.step(`${name}/run`, Schema.String, () => runOfSent(request.sent))
|
|
736
|
+
// The first look's time starts the deadline (journalled, so a resumed execution keeps it).
|
|
737
|
+
let first = 0
|
|
738
|
+
for (let i = 0; ; i++) {
|
|
739
|
+
const seen = yield* ctx.step(`${name}/poll-${i}`, Polled, () => pollRun(runId))
|
|
740
|
+
if (seen.status === "gone") {
|
|
741
|
+
return yield* new WorkflowFailed({ message: `No agent run ${runId} of the sender's` })
|
|
742
|
+
}
|
|
743
|
+
if (FINAL.has(seen.status)) {
|
|
744
|
+
return {
|
|
745
|
+
runId: runId,
|
|
746
|
+
state: seen.status as AgentAnswer["state"],
|
|
747
|
+
answer: seen.status === "succeeded" || seen.status === "stopped" ? seen.result : null,
|
|
748
|
+
} satisfies AgentAnswer
|
|
749
|
+
}
|
|
750
|
+
if (i === 0) first = seen.at
|
|
751
|
+
const left = first + limit - seen.at
|
|
752
|
+
if (left <= 0) {
|
|
753
|
+
// Bounded: the run is stopped rather than left working for an answer no one will post.
|
|
754
|
+
yield* ctx
|
|
755
|
+
.invoke(`${name}/cancel`, {
|
|
756
|
+
action: "agent.cancel",
|
|
757
|
+
input: { runId: runId },
|
|
758
|
+
identity: actor,
|
|
759
|
+
surface: "ingress",
|
|
760
|
+
})
|
|
761
|
+
.pipe(Effect.ignore)
|
|
762
|
+
return { runId: runId, state: "timedOut", answer: null } satisfies AgentAnswer
|
|
763
|
+
}
|
|
764
|
+
yield* ctx.sleep(`${name}/wait-${i}`, Duration.millis(Math.min(left, ANSWER_POLL_MAX_MS, 500 * 2 ** i)))
|
|
765
|
+
}
|
|
766
|
+
}),
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const handler = source.handler
|
|
770
|
+
const handled = yield* Effect.gen(function* () {
|
|
771
|
+
if (handler.kind === "action") {
|
|
772
|
+
yield* ctx.invoke("handle", {
|
|
773
|
+
action: handler.action,
|
|
774
|
+
input: handler.input(delivery),
|
|
775
|
+
identity: actor,
|
|
776
|
+
surface: "ingress",
|
|
777
|
+
})
|
|
778
|
+
return "handled"
|
|
779
|
+
}
|
|
780
|
+
const workflow = byWorkflow.get(handler.workflow)
|
|
781
|
+
if (workflow === undefined) return yield* new WorkflowFailed({ message: `No workflow ${handler.workflow}` })
|
|
782
|
+
// The module workflow's input schema and body are module code.
|
|
783
|
+
const decoded = yield* asModuleCode(
|
|
784
|
+
Schema.decodeUnknownEffect(workflow.input as Schema.Codec<unknown, unknown>)(handler.input(delivery)),
|
|
785
|
+
).pipe(Effect.mapError(failed))
|
|
786
|
+
// A module workflow: module code, without the kernel's services, and acting only as the delivery's actor.
|
|
787
|
+
yield* ctx.confine(
|
|
788
|
+
Effect.suspend(() =>
|
|
789
|
+
workflow.run(decoded, asActor(ctx, actor, workflow.name.split(".")[0] ?? workflow.name, handlerApi)),
|
|
790
|
+
) as Effect.Effect<unknown, InvocationError | WorkflowFailed>,
|
|
791
|
+
)
|
|
792
|
+
return "handled"
|
|
793
|
+
}).pipe(Effect.catch((error: { readonly _tag: string }) => Effect.succeed(error._tag)))
|
|
794
|
+
const outcome = yield* ctx.step("finish", Schema.String, () =>
|
|
795
|
+
finish(handled === "handled" ? "processed" : "failed", handled),
|
|
796
|
+
)
|
|
797
|
+
return { outcome }
|
|
798
|
+
}) as Effect.Effect<{ readonly outcome: string }, WorkflowFailed>,
|
|
799
|
+
// An execution that fails (a step that failed after its retries, a defect) still settles its delivery.
|
|
800
|
+
onFailure: (input, failure) =>
|
|
801
|
+
Effect.gen(function* () {
|
|
802
|
+
const sql = yield* SqlClient.SqlClient
|
|
803
|
+
yield* sql`UPDATE eloxiv.ingress_delivery SET state = 'failed', outcome = ${failure.tag}, finished_at = now()
|
|
804
|
+
WHERE source = ${input.source} AND delivery_id = ${input.deliveryId} AND state = 'accepted'`
|
|
805
|
+
}) as Effect.Effect<void, unknown>,
|
|
806
|
+
})
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* A workflow handler's context: its steps are namespaced under `handler/` and act as the delivery's actor. The
|
|
811
|
+
* handler is module code, so it gets a module's context: no other identity, no approved request, no `confine`.
|
|
812
|
+
*/
|
|
813
|
+
const asActor = (
|
|
814
|
+
ctx: KernelWorkflowContext,
|
|
815
|
+
actor: ExecutionIdentity,
|
|
816
|
+
source: string,
|
|
817
|
+
ingress: IngressHandlerApi,
|
|
818
|
+
): WorkflowContext => ({
|
|
819
|
+
executionId: ctx.executionId,
|
|
820
|
+
key: ctx.key,
|
|
821
|
+
identity: actor,
|
|
822
|
+
progress: ctx.progressAs(actor, source),
|
|
823
|
+
invoke: (step, request) =>
|
|
824
|
+
untrustedRequest(request, actor).pipe(
|
|
825
|
+
Effect.flatMap((allowed) => ctx.invoke(`handler/${step}`, { ...allowed, surface: "ingress" })),
|
|
826
|
+
),
|
|
827
|
+
// The step bodies are the module's: module code, although this context is the kernel workflow's.
|
|
828
|
+
step: (name, success, body) =>
|
|
829
|
+
ctx.step(`handler/${name}`, success, (key) => ctx.confine(Effect.suspend(() => body(key)))),
|
|
830
|
+
sleep: (name, duration) => ctx.sleep(`handler/${name}`, duration),
|
|
831
|
+
waitForSignal: ctx.waitForSignal,
|
|
832
|
+
ingress,
|
|
833
|
+
noop: ctx.noop,
|
|
834
|
+
each: (name, operations, success, body) =>
|
|
835
|
+
ctx.each(`handler/${name}`, operations, success, (operation, key) =>
|
|
836
|
+
ctx.confine(Effect.suspend(() => body(operation, key))),
|
|
837
|
+
),
|
|
838
|
+
})
|
|
839
|
+
|
|
840
|
+
export interface AcceptResult {
|
|
841
|
+
readonly accepted: true
|
|
842
|
+
readonly deliveryId: string
|
|
843
|
+
readonly duplicate: boolean
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/** A verified handshake (Slack's `url_verification`), answered in the response and neither stored nor processed. */
|
|
847
|
+
export interface AnsweredResult {
|
|
848
|
+
readonly answered: IngressAnswer
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export interface IngressShape {
|
|
852
|
+
readonly sources: ReadonlyMap<string, IngressSourceDefinition>
|
|
853
|
+
/** Steps 1 to 3 for one request: verify, check for replay, persist, start (or join) the execution. */
|
|
854
|
+
readonly accept: (
|
|
855
|
+
source: string,
|
|
856
|
+
headers: Headers,
|
|
857
|
+
body: Uint8Array,
|
|
858
|
+
) => Effect.Effect<AcceptResult | AnsweredResult, IngressRefusal>
|
|
859
|
+
readonly status: (
|
|
860
|
+
source: string,
|
|
861
|
+
deliveryId: string,
|
|
862
|
+
) => Effect.Effect<typeof IngressContract.operations.status.output.Type | undefined>
|
|
863
|
+
/** Start executions for accepted deliveries that have none, and drop settled deliveries past retention. */
|
|
864
|
+
readonly sweep: Effect.Effect<number>
|
|
865
|
+
/** Link management, acting as the person these request headers authenticate. */
|
|
866
|
+
readonly operations: Readonly<
|
|
867
|
+
Record<string, (headers: Headers, raw: unknown, surface: Surface) => Effect.Effect<unknown, ManageFailure>>
|
|
868
|
+
>
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
export class Ingress extends Context.Service<Ingress, IngressShape>()("@eloxiv/kernel/Ingress") {
|
|
872
|
+
static readonly layer = (sources: ReadonlyArray<IngressSourceDefinition>) =>
|
|
873
|
+
Layer.effect(
|
|
874
|
+
Ingress,
|
|
875
|
+
Effect.gen(function* () {
|
|
876
|
+
const sql = yield* SqlClient.SqlClient
|
|
877
|
+
const audit = yield* Audit
|
|
878
|
+
const workflows = yield* Workflows
|
|
879
|
+
const secrets = yield* IngressSecrets
|
|
880
|
+
const settings = ingressConfig(yield* KernelConfig)
|
|
881
|
+
const managed = yield* makeManaged
|
|
882
|
+
const bySource = new Map(sources.map((source) => [source.name, source]))
|
|
883
|
+
const platforms = new Set(
|
|
884
|
+
sources.flatMap((source) => (source.identity.kind === "linked" ? [source.identity.platform] : [])),
|
|
885
|
+
)
|
|
886
|
+
|
|
887
|
+
// Deliveries accepted before migration 0019 have no signed hash, so a replay of one under another id
|
|
888
|
+
// would be new. For GitHub's scheme the signed payload is the body, so its hash is the body's: fill it in
|
|
889
|
+
// (one row per body, should replays have been accepted twice then), under a lock so kernels starting
|
|
890
|
+
// together do not collide. Other schemes sign their delivery id, which already refuses such replays.
|
|
891
|
+
const github = sources.filter((source) => source.verifier.scheme === "github").map((source) => source.name)
|
|
892
|
+
if (github.length > 0) {
|
|
893
|
+
yield* sql
|
|
894
|
+
.withTransaction(
|
|
895
|
+
Effect.gen(function* () {
|
|
896
|
+
yield* sql`SELECT pg_advisory_xact_lock(hashtext('eloxiv.ingress.signed-hash-backfill'))`
|
|
897
|
+
yield* sql`UPDATE eloxiv.ingress_delivery d SET signed_hash = d.body_hash
|
|
898
|
+
WHERE d.signed_hash IS NULL AND d.source IN ${sql.in(github)}
|
|
899
|
+
AND NOT EXISTS (SELECT 1 FROM eloxiv.ingress_delivery o
|
|
900
|
+
WHERE o.source = d.source AND o.signed_hash = d.body_hash)
|
|
901
|
+
AND d.delivery_id = (SELECT min(m.delivery_id) FROM eloxiv.ingress_delivery m
|
|
902
|
+
WHERE m.source = d.source AND m.body_hash = d.body_hash AND m.signed_hash IS NULL)`
|
|
903
|
+
}),
|
|
904
|
+
)
|
|
905
|
+
.pipe(Effect.catchCause((cause) => Effect.logWarning("Backfilling ingress signed hashes failed", cause)))
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
const refuse = (source: string, bodyHash: string, error: IngressRefusal, deliveryId?: string) =>
|
|
909
|
+
Effect.gen(function* () {
|
|
910
|
+
yield* audit.record({
|
|
911
|
+
invocationId: crypto.randomUUID(),
|
|
912
|
+
action: `eloxiv.ingress.${source}`,
|
|
913
|
+
surface: "ingress",
|
|
914
|
+
actorUserId: null,
|
|
915
|
+
orgId: null,
|
|
916
|
+
outcome: "denied",
|
|
917
|
+
inputHash: bodyHash,
|
|
918
|
+
idempotencyKey: deliveryId ?? null,
|
|
919
|
+
errorTag: error._tag,
|
|
920
|
+
affected: null,
|
|
921
|
+
requested: null,
|
|
922
|
+
completion: null,
|
|
923
|
+
})
|
|
924
|
+
// The reason and the body's hash only: never the payload or its signature.
|
|
925
|
+
yield* Effect.logWarning("Ingress refused a delivery").pipe(
|
|
926
|
+
Effect.annotateLogs({ source, reason: error._tag, bodyHash }),
|
|
927
|
+
)
|
|
928
|
+
return yield* Effect.fail(error)
|
|
929
|
+
})
|
|
930
|
+
|
|
931
|
+
const start = (source: IngressSourceDefinition, deliveryId: string) =>
|
|
932
|
+
Effect.gen(function* () {
|
|
933
|
+
const identity: ExecutionIdentity = {
|
|
934
|
+
kind: "system",
|
|
935
|
+
orgId: source.identity.kind === "principal" ? source.identity.org : "",
|
|
936
|
+
}
|
|
937
|
+
const { executionId } = yield* workflows.start({
|
|
938
|
+
workflow: INGRESS_WORKFLOW,
|
|
939
|
+
key: `${source.name}:${deliveryId}`,
|
|
940
|
+
identity,
|
|
941
|
+
input: { source: source.name, deliveryId },
|
|
942
|
+
})
|
|
943
|
+
yield* sql`UPDATE eloxiv.ingress_delivery SET started_at = coalesce(started_at, now()), execution_id = ${executionId}
|
|
944
|
+
WHERE source = ${source.name} AND delivery_id = ${deliveryId}`.pipe(Effect.orDie)
|
|
945
|
+
}).pipe(
|
|
946
|
+
// The delivery is durable already: if the start fails now, the sweep starts it.
|
|
947
|
+
Effect.catchCause((cause) =>
|
|
948
|
+
Effect.logWarning("Starting an ingress execution failed; the sweep will retry", cause),
|
|
949
|
+
),
|
|
950
|
+
)
|
|
951
|
+
|
|
952
|
+
const accept: IngressShape["accept"] = (name, headers, body) =>
|
|
953
|
+
Effect.gen(function* () {
|
|
954
|
+
const bodyHash = createHash("sha256").update(body).digest("hex")
|
|
955
|
+
const source = bySource.get(name)
|
|
956
|
+
if (source === undefined) return yield* new UnknownSource({ source: name })
|
|
957
|
+
const limit = source.maxBodyBytes ?? settings.maxBodyBytes
|
|
958
|
+
if (body.byteLength > limit) {
|
|
959
|
+
return yield* refuse(name, bodyHash, new PayloadTooLarge({ message: `At most ${limit} bytes` }))
|
|
960
|
+
}
|
|
961
|
+
const keys = yield* secrets.secretsFor(name)
|
|
962
|
+
if (keys.length === 0) {
|
|
963
|
+
yield* Effect.logError(`Ingress source ${name} has no secret configured (${ingressSecretVariable(name)})`)
|
|
964
|
+
}
|
|
965
|
+
const verified = source.verifier.verify({ headers, body, secrets: keys })
|
|
966
|
+
if (!verified.ok) {
|
|
967
|
+
return yield* refuse(name, bodyHash, new InvalidSignature({ message: verified.message }))
|
|
968
|
+
}
|
|
969
|
+
const tolerance = source.toleranceS ?? settings.toleranceS
|
|
970
|
+
if (source.verifier.signsTimestamp) {
|
|
971
|
+
const at = verified.timestamp
|
|
972
|
+
if (
|
|
973
|
+
at === undefined ||
|
|
974
|
+
Number.isNaN(at.getTime()) ||
|
|
975
|
+
Math.abs(Date.now() - at.getTime()) > tolerance * 1000
|
|
976
|
+
) {
|
|
977
|
+
return yield* refuse(
|
|
978
|
+
name,
|
|
979
|
+
bodyHash,
|
|
980
|
+
new StaleDelivery({ message: `The signed timestamp is more than ${tolerance} s away` }),
|
|
981
|
+
verified.deliveryId,
|
|
982
|
+
)
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
// A handshake the sender expects answered in-line (Slack's url_verification): only once the signature
|
|
986
|
+
// and the signed timestamp hold, and nothing is stored or run. A failing `answer` is no answer.
|
|
987
|
+
if (source.answer !== undefined) {
|
|
988
|
+
const answer = yield* Effect.try(() => source.answer!({ body: new TextDecoder().decode(body) })).pipe(
|
|
989
|
+
Effect.catch((e) =>
|
|
990
|
+
Effect.logWarning("An ingress source's handshake check failed").pipe(
|
|
991
|
+
Effect.annotateLogs({ source: name, error: String(e) }),
|
|
992
|
+
Effect.as(undefined),
|
|
993
|
+
),
|
|
994
|
+
),
|
|
995
|
+
)
|
|
996
|
+
if (answer !== undefined) return { answered: answer } satisfies AnsweredResult
|
|
997
|
+
}
|
|
998
|
+
// One row per delivery id and one per signed payload: either conflict means this was seen before.
|
|
999
|
+
const inserted =
|
|
1000
|
+
yield* sql`INSERT INTO eloxiv.ingress_delivery (source, delivery_id, body, body_hash, signed_hash, headers, signed_at)
|
|
1001
|
+
VALUES (${name}, ${verified.deliveryId}, ${Buffer.from(body)}, ${bodyHash}, ${verified.signedHash},
|
|
1002
|
+
${JSON.stringify(keptHeaders(source, headers))}::jsonb, ${verified.timestamp ?? null})
|
|
1003
|
+
ON CONFLICT DO NOTHING RETURNING 1 AS one`.pipe(Effect.orDie)
|
|
1004
|
+
let deliveryId = verified.deliveryId
|
|
1005
|
+
if (inserted.length === 0) {
|
|
1006
|
+
const [existing] = yield* sql<{ deliveryId: string; bodyHash: string }>`
|
|
1007
|
+
SELECT delivery_id AS "deliveryId", body_hash AS "bodyHash" FROM eloxiv.ingress_delivery
|
|
1008
|
+
WHERE source = ${name} AND (delivery_id = ${verified.deliveryId} OR signed_hash = ${verified.signedHash})
|
|
1009
|
+
ORDER BY delivery_id = ${verified.deliveryId} DESC LIMIT 1`.pipe(Effect.orDie)
|
|
1010
|
+
// Gone in between (past retention): accept it as new.
|
|
1011
|
+
if (existing === undefined) return yield* accept(name, headers, body)
|
|
1012
|
+
if (existing.deliveryId === verified.deliveryId && existing.bodyHash !== bodyHash) {
|
|
1013
|
+
return yield* refuse(
|
|
1014
|
+
name,
|
|
1015
|
+
bodyHash,
|
|
1016
|
+
new ReplayedDelivery({ message: "This delivery id was already accepted with another body" }),
|
|
1017
|
+
verified.deliveryId,
|
|
1018
|
+
)
|
|
1019
|
+
}
|
|
1020
|
+
if (existing.deliveryId !== verified.deliveryId) {
|
|
1021
|
+
// The same signed bytes under another delivery id: the id is not what the sender signed, so
|
|
1022
|
+
// this is the delivery already accepted, not a new one. It joins that one and never acts again.
|
|
1023
|
+
yield* Effect.logWarning("Ingress joined a signed payload presented under another delivery id").pipe(
|
|
1024
|
+
Effect.annotateLogs({
|
|
1025
|
+
source: name,
|
|
1026
|
+
deliveryId: existing.deliveryId,
|
|
1027
|
+
presentedId: verified.deliveryId,
|
|
1028
|
+
}),
|
|
1029
|
+
)
|
|
1030
|
+
}
|
|
1031
|
+
deliveryId = existing.deliveryId
|
|
1032
|
+
}
|
|
1033
|
+
// Committed: the delivery survives anything that happens from here. Start (or join) its execution.
|
|
1034
|
+
yield* start(source, deliveryId)
|
|
1035
|
+
return { accepted: true, deliveryId, duplicate: inserted.length === 0 } satisfies AcceptResult
|
|
1036
|
+
})
|
|
1037
|
+
|
|
1038
|
+
const status = (source: string, deliveryId: string) =>
|
|
1039
|
+
sql<{
|
|
1040
|
+
state: "accepted" | "processed" | "refused" | "failed"
|
|
1041
|
+
outcome: string | null
|
|
1042
|
+
executionId: string | null
|
|
1043
|
+
receivedAt: unknown
|
|
1044
|
+
}>`
|
|
1045
|
+
SELECT state, outcome, execution_id AS "executionId", received_at AS "receivedAt"
|
|
1046
|
+
FROM eloxiv.ingress_delivery WHERE source = ${source} AND delivery_id = ${deliveryId}`.pipe(
|
|
1047
|
+
Effect.orDie,
|
|
1048
|
+
Effect.map(([row]) =>
|
|
1049
|
+
row === undefined ? undefined : { source, deliveryId, ...row, receivedAt: iso(row.receivedAt)! },
|
|
1050
|
+
),
|
|
1051
|
+
)
|
|
1052
|
+
|
|
1053
|
+
const sweep = Effect.gen(function* () {
|
|
1054
|
+
const pending = yield* sql<{ source: string; deliveryId: string }>`
|
|
1055
|
+
SELECT source, delivery_id AS "deliveryId" FROM eloxiv.ingress_delivery
|
|
1056
|
+
WHERE started_at IS NULL AND received_at < now() - interval '1 second' ORDER BY received_at LIMIT 100`.pipe(
|
|
1057
|
+
Effect.orDie,
|
|
1058
|
+
)
|
|
1059
|
+
for (const delivery of pending) {
|
|
1060
|
+
const source = bySource.get(delivery.source)
|
|
1061
|
+
if (source !== undefined) yield* start(source, delivery.deliveryId)
|
|
1062
|
+
}
|
|
1063
|
+
yield* sql`DELETE FROM eloxiv.ingress_delivery
|
|
1064
|
+
WHERE state <> 'accepted' AND received_at < now() - make_interval(secs => ${settings.retentionS})`.pipe(
|
|
1065
|
+
Effect.orDie,
|
|
1066
|
+
)
|
|
1067
|
+
// A reply's record goes with its delivery.
|
|
1068
|
+
yield* sql`DELETE FROM eloxiv.ingress_reply r WHERE NOT EXISTS (SELECT 1 FROM eloxiv.ingress_delivery d
|
|
1069
|
+
WHERE d.source = r.source AND d.delivery_id = r.delivery_id)`.pipe(Effect.orDie)
|
|
1070
|
+
yield* sql`DELETE FROM eloxiv.link_code WHERE expires_at < now() - interval '1 day'`.pipe(Effect.orDie)
|
|
1071
|
+
return pending.length
|
|
1072
|
+
})
|
|
1073
|
+
|
|
1074
|
+
type Ops = (typeof IngressContract)["operations"]
|
|
1075
|
+
const op = <K extends "createLinkCode" | "listLinks" | "unlink">(
|
|
1076
|
+
name: K,
|
|
1077
|
+
kind: "read" | "write",
|
|
1078
|
+
body: Parameters<typeof managed.run<Ops[K]["input"]["Type"], Ops[K]["output"]["Type"]>>[4],
|
|
1079
|
+
) => managed.run("eloxiv.ingress", name, kind, IngressContract.operations[name].input, body)
|
|
1080
|
+
|
|
1081
|
+
const operations = {
|
|
1082
|
+
createLinkCode: op("createLinkCode", "write", (input, ctx) =>
|
|
1083
|
+
Effect.gen(function* () {
|
|
1084
|
+
if (!platforms.has(input.platform)) {
|
|
1085
|
+
return yield* new InvalidInput({ message: `No ingress source links identities on ${input.platform}` })
|
|
1086
|
+
}
|
|
1087
|
+
const code = secret("elxl_").slice(0, 21)
|
|
1088
|
+
const [row] = yield* sql<{ expiresAt: unknown }>`
|
|
1089
|
+
INSERT INTO eloxiv.link_code (hash, platform, org_id, actor_id, expires_at)
|
|
1090
|
+
VALUES (${hashOf(code)}, ${input.platform}, ${ctx.actor.orgId}, ${ctx.actor.userId},
|
|
1091
|
+
now() + make_interval(secs => ${LINK_CODE_TTL_S}))
|
|
1092
|
+
RETURNING expires_at AS "expiresAt"`.pipe(Effect.orDie)
|
|
1093
|
+
return { code, expiresAt: iso(row!.expiresAt)! }
|
|
1094
|
+
}),
|
|
1095
|
+
),
|
|
1096
|
+
listLinks: op("listLinks", "read", (_input, ctx) =>
|
|
1097
|
+
sql<{
|
|
1098
|
+
platform: string
|
|
1099
|
+
externalId: string
|
|
1100
|
+
orgId: string
|
|
1101
|
+
actorId: string
|
|
1102
|
+
linkedBy: string
|
|
1103
|
+
createdAt: unknown
|
|
1104
|
+
}>`
|
|
1105
|
+
SELECT platform, external_id AS "externalId", org_id AS "orgId", actor_id AS "actorId",
|
|
1106
|
+
linked_by AS "linkedBy", created_at AS "createdAt"
|
|
1107
|
+
FROM eloxiv.linked_identity WHERE org_id = ${ctx.actor.orgId} AND actor_id = ${ctx.actor.userId}
|
|
1108
|
+
ORDER BY platform, external_id`.pipe(
|
|
1109
|
+
Effect.orDie,
|
|
1110
|
+
Effect.map((rows) => rows.map((r) => ({ ...r, createdAt: iso(r.createdAt)! }))),
|
|
1111
|
+
),
|
|
1112
|
+
),
|
|
1113
|
+
unlink: op("unlink", "write", (input, ctx) =>
|
|
1114
|
+
Effect.gen(function* () {
|
|
1115
|
+
const [link] = yield* sql<{ actorId: string }>`
|
|
1116
|
+
SELECT actor_id AS "actorId" FROM eloxiv.linked_identity
|
|
1117
|
+
WHERE platform = ${input.platform} AND external_id = ${input.externalId} AND org_id = ${ctx.actor.orgId}`.pipe(
|
|
1118
|
+
Effect.orDie,
|
|
1119
|
+
)
|
|
1120
|
+
if (link === undefined) return yield* new InvalidInput({ message: "No such linked identity" })
|
|
1121
|
+
if (link.actorId !== ctx.actor.userId && !(yield* ctx.holds(MACHINE_MANAGE))) {
|
|
1122
|
+
return yield* new Forbidden({
|
|
1123
|
+
action: "eloxiv.ingress.unlink",
|
|
1124
|
+
message: `Removing another member's link needs the ${MACHINE_MANAGE} permission`,
|
|
1125
|
+
})
|
|
1126
|
+
}
|
|
1127
|
+
yield* sql`DELETE FROM eloxiv.linked_identity WHERE platform = ${input.platform} AND external_id = ${input.externalId}`.pipe(
|
|
1128
|
+
Effect.orDie,
|
|
1129
|
+
)
|
|
1130
|
+
return {}
|
|
1131
|
+
}),
|
|
1132
|
+
),
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
return Ingress.of({
|
|
1136
|
+
sources: bySource,
|
|
1137
|
+
accept,
|
|
1138
|
+
status,
|
|
1139
|
+
sweep,
|
|
1140
|
+
operations: operations,
|
|
1141
|
+
})
|
|
1142
|
+
}),
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1145
|
+
/** The sweep loop, on runners. */
|
|
1146
|
+
static readonly loop = Layer.effectDiscard(
|
|
1147
|
+
Effect.gen(function* () {
|
|
1148
|
+
const ingress = yield* Ingress
|
|
1149
|
+
const settings = ingressConfig(yield* KernelConfig)
|
|
1150
|
+
yield* ingress.sweep.pipe(
|
|
1151
|
+
Effect.catchCause((cause) => Effect.logWarning("Ingress sweep failed", cause)),
|
|
1152
|
+
Effect.repeat(Schedule.spaced(Duration.millis(settings.sweepMs))),
|
|
1153
|
+
Effect.forkScoped,
|
|
1154
|
+
)
|
|
1155
|
+
}),
|
|
1156
|
+
)
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const STATUS: Record<string, number> = {
|
|
1160
|
+
InvalidSignature: 401,
|
|
1161
|
+
StaleDelivery: 401,
|
|
1162
|
+
ReplayedDelivery: 409,
|
|
1163
|
+
UnknownSource: 404,
|
|
1164
|
+
PayloadTooLarge: 413,
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/** `POST /ingress/<source>` and the link management routes `POST /kernel/ingress/<operation>`. */
|
|
1168
|
+
export const IngressRoutes = Layer.unwrap(
|
|
1169
|
+
Effect.gen(function* () {
|
|
1170
|
+
const ingress = yield* Ingress
|
|
1171
|
+
const config = yield* KernelConfig
|
|
1172
|
+
const settings = ingressConfig(config)
|
|
1173
|
+
const limits = httpConfig(config)
|
|
1174
|
+
return Layer.mergeAll(
|
|
1175
|
+
HttpRouter.add("POST", `${INGRESS_PATH}/:source`, (request) =>
|
|
1176
|
+
Effect.gen(function* () {
|
|
1177
|
+
const name = decodeURIComponent(new URL(request.url, "http://kernel").pathname.slice(INGRESS_PATH.length + 1))
|
|
1178
|
+
// The body is counted as it arrives: a declared length over the limit is refused before anything is
|
|
1179
|
+
// read, and a body without one (chunked) at the first byte past the limit, before the sender finishes.
|
|
1180
|
+
// Neither is audited: there is no whole body to hash. An unknown source's body is not read at all.
|
|
1181
|
+
const source = ingress.sources.get(name)
|
|
1182
|
+
const read: BodyRead =
|
|
1183
|
+
source === undefined
|
|
1184
|
+
? { _tag: "Read", bytes: new Uint8Array(0) }
|
|
1185
|
+
: yield* readBody(request, {
|
|
1186
|
+
maxBytes: source.maxBodyBytes ?? settings.maxBodyBytes,
|
|
1187
|
+
timeoutMs: limits.bodyTimeoutMs,
|
|
1188
|
+
})
|
|
1189
|
+
if (read._tag !== "Read") {
|
|
1190
|
+
yield* Effect.logWarning("Ingress refused a delivery").pipe(
|
|
1191
|
+
Effect.annotateLogs({ source: name, reason: refusalMessage(read) }),
|
|
1192
|
+
)
|
|
1193
|
+
return refusalResponse(read)
|
|
1194
|
+
}
|
|
1195
|
+
const exit = yield* ingress.accept(name, toWebHeaders(request.headers), read.bytes).pipe(Effect.exit)
|
|
1196
|
+
if (exit._tag === "Success") {
|
|
1197
|
+
const value = exit.value
|
|
1198
|
+
return HttpServerResponse.fromWeb(
|
|
1199
|
+
"answered" in value
|
|
1200
|
+
? new Response(value.answered.body, { headers: { "content-type": value.answered.contentType } })
|
|
1201
|
+
: Response.json(value),
|
|
1202
|
+
)
|
|
1203
|
+
}
|
|
1204
|
+
const failure = exit.cause.reasons.find((reason) => reason._tag === "Fail")
|
|
1205
|
+
if (failure === undefined || failure._tag !== "Fail") return yield* Effect.failCause(exit.cause)
|
|
1206
|
+
const error = failure.error
|
|
1207
|
+
return HttpServerResponse.fromWeb(
|
|
1208
|
+
Response.json(
|
|
1209
|
+
{ _tag: error._tag, ...("message" in error ? { message: error.message } : {}) },
|
|
1210
|
+
{
|
|
1211
|
+
status: STATUS[error._tag] ?? 400,
|
|
1212
|
+
},
|
|
1213
|
+
),
|
|
1214
|
+
)
|
|
1215
|
+
}),
|
|
1216
|
+
),
|
|
1217
|
+
HttpRouter.add("POST", "/kernel/ingress/*", managedRoute(ingress.operations)),
|
|
1218
|
+
)
|
|
1219
|
+
}),
|
|
1220
|
+
)
|