@eloxiv/kernel 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,1793 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kernel-provided `agent` module: the agent's records, owned by a module like any other (its own schema,
|
|
3
|
+
* role, Cedar policy and row-level security), so they sync to people's replicas through policy and every
|
|
4
|
+
* change made through its actions is audited.
|
|
5
|
+
*
|
|
6
|
+
* - Conversations, messages, runs, run events and context inventories are their owner's, in the organisation
|
|
7
|
+
* they act in: a person syncs only their own (AgentRuntime, ContextAccounting).
|
|
8
|
+
* - Memory entries (Memory) and resources (AgentResources) are a person's own or the organisation's; the
|
|
9
|
+
* organisation's are written by members with `eloxiv.agent.manage` and read by every member.
|
|
10
|
+
* - Budgets and usage (Metering) and the organisation's model choice (ModelProvider).
|
|
11
|
+
*
|
|
12
|
+
* The runtime (`Run.ts`) writes run records as the organisation's system actor, under the same row-level
|
|
13
|
+
* security. People (and organisation jobs) start runs with `agent.send`; agents cannot (no agent-to-agent
|
|
14
|
+
* protocol).
|
|
15
|
+
*/
|
|
16
|
+
import {
|
|
17
|
+
AgentLoopPolicy,
|
|
18
|
+
AgentResource,
|
|
19
|
+
AgentToolPolicy,
|
|
20
|
+
TEAM_LEADS_SUFFIX,
|
|
21
|
+
Attachment,
|
|
22
|
+
ConversationResource,
|
|
23
|
+
RunMode,
|
|
24
|
+
RunDevice,
|
|
25
|
+
ScreenSnapshot,
|
|
26
|
+
BudgetPeriod,
|
|
27
|
+
ContextDirective,
|
|
28
|
+
defineAction,
|
|
29
|
+
ExportResourcesInput,
|
|
30
|
+
ImportResourcesInput,
|
|
31
|
+
ImportResourcesOutput,
|
|
32
|
+
type PackedResource,
|
|
33
|
+
RESOURCE_PACK_FORMAT,
|
|
34
|
+
RESOURCE_PACK_MAX_BYTES,
|
|
35
|
+
resourcePackBytes,
|
|
36
|
+
RESOURCE_PACK_MAX_RESOURCES,
|
|
37
|
+
RESOURCE_PACK_VERSION,
|
|
38
|
+
ResourcePack,
|
|
39
|
+
defineEvent,
|
|
40
|
+
defineModuleContract,
|
|
41
|
+
Forbidden,
|
|
42
|
+
GiveFeedback,
|
|
43
|
+
InvalidInput,
|
|
44
|
+
Meter,
|
|
45
|
+
MemoryScope,
|
|
46
|
+
ResourceKind,
|
|
47
|
+
SentMessage,
|
|
48
|
+
deleteRecordsAbout,
|
|
49
|
+
} from "@eloxiv/contracts"
|
|
50
|
+
import { defineEntity } from "@eloxiv/contracts/drizzle"
|
|
51
|
+
import { relations } from "drizzle-orm"
|
|
52
|
+
import { bigint, boolean, doublePrecision, integer, jsonb, pgSchema, text, timestamp } from "drizzle-orm/pg-core"
|
|
53
|
+
import { Effect, Schema } from "effect"
|
|
54
|
+
import { bindDeferred } from "../Authority.ts"
|
|
55
|
+
import { KERNEL_VERSION } from "../Release.ts"
|
|
56
|
+
import { defineModule, type HandlerContext } from "../Module.ts"
|
|
57
|
+
import { provideKernelModule } from "../KernelModule.ts"
|
|
58
|
+
|
|
59
|
+
export const AGENT_MANAGE = "eloxiv.agent.manage"
|
|
60
|
+
/** The organisation's agent loop policy (Settings): limits that replace the deployment's, under its ceiling. */
|
|
61
|
+
export const LOOP_SETTING = "agent.loop"
|
|
62
|
+
/** How the organisation's agent is offered its tools (Settings): all, or by search. */
|
|
63
|
+
export const TOOLS_SETTING = "agent.tools"
|
|
64
|
+
|
|
65
|
+
// --- Tables (Drizzle): the only declaration of the module's fields; its migrations create them ----------------
|
|
66
|
+
|
|
67
|
+
const agentSchema = pgSchema("eloxiv_agent")
|
|
68
|
+
const ts = (name: string) => timestamp(name, { withTimezone: true, mode: "string" })
|
|
69
|
+
/** The columns every owned record has: its id, organisation and owner. */
|
|
70
|
+
const ownedColumns = () => ({
|
|
71
|
+
id: text("id").primaryKey(),
|
|
72
|
+
orgId: text("org_id").notNull(),
|
|
73
|
+
userId: text("user_id").notNull(),
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export const conversationTable = agentSchema.table("conversation", {
|
|
77
|
+
...ownedColumns(),
|
|
78
|
+
title: text("title").notNull(),
|
|
79
|
+
agentSessionId: text("agent_session_id"),
|
|
80
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
81
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
82
|
+
/** The person's own marks (`agent.updateConversation`): listed first, out of the way, or out of their lists. */
|
|
83
|
+
pinned: boolean("pinned").notNull().default(false),
|
|
84
|
+
archived: boolean("archived").notNull().default(false),
|
|
85
|
+
hidden: boolean("hidden").notNull().default(false),
|
|
86
|
+
/**
|
|
87
|
+
* The record the conversation is about (`agent.send`'s `resource`, a thread on that record): a reference only, as
|
|
88
|
+
* the person gave it, never trusted for authorisation (the agent reads the record through tools, under policy).
|
|
89
|
+
*/
|
|
90
|
+
resourceModule: text("resource_module"),
|
|
91
|
+
resourceEntity: text("resource_entity"),
|
|
92
|
+
resourceId: text("resource_id"),
|
|
93
|
+
/** The team the conversation is bound to (its owner's choice): its runs work in that team's agent context. */
|
|
94
|
+
team: text("team"),
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A saved point of a conversation (`agent.saveCheckpoint`): the messages up to `upTo` (their sequence). Restoring it
|
|
99
|
+
* (`agent.restoreCheckpoint`) takes everything after out of the conversation, kept and marked (`covered_by =
|
|
100
|
+
* restore:<checkpoint>`), so the agent and the transcript continue from that point.
|
|
101
|
+
*/
|
|
102
|
+
export const checkpointTable = agentSchema.table("checkpoint", {
|
|
103
|
+
...ownedColumns(),
|
|
104
|
+
conversationId: text("conversation_id").notNull(),
|
|
105
|
+
label: text("label").notNull(),
|
|
106
|
+
upTo: bigint("up_to", { mode: "number" }).notNull(),
|
|
107
|
+
messages: integer("messages").notNull(),
|
|
108
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
109
|
+
restoredAt: ts("restored_at"),
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
export const messageTable = agentSchema.table("message", {
|
|
113
|
+
...ownedColumns(),
|
|
114
|
+
conversationId: text("conversation_id").notNull(),
|
|
115
|
+
runId: text("run_id"),
|
|
116
|
+
seq: bigint("seq", { mode: "number" }).notNull(),
|
|
117
|
+
role: text("role", { enum: ["user", "assistant", "tool", "summary"] }).notNull(),
|
|
118
|
+
content: jsonb("content").notNull(),
|
|
119
|
+
text: text("text").notNull().default(""),
|
|
120
|
+
coveredBy: text("covered_by"),
|
|
121
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
export const runTable = agentSchema.table("run", {
|
|
125
|
+
...ownedColumns(),
|
|
126
|
+
conversationId: text("conversation_id").notNull(),
|
|
127
|
+
parentRunId: text("parent_run_id"),
|
|
128
|
+
kind: text("kind", { enum: ["turn", "subagent", "job"] }).notNull(),
|
|
129
|
+
status: text("status", {
|
|
130
|
+
enum: ["queued", "running", "waiting", "succeeded", "stopped", "failed", "cancelled"],
|
|
131
|
+
}).notNull(),
|
|
132
|
+
stopReason: text("stop_reason"),
|
|
133
|
+
task: text("task"),
|
|
134
|
+
limits: jsonb("limits"),
|
|
135
|
+
tools: jsonb("tools"),
|
|
136
|
+
inputTokens: integer("input_tokens").notNull().default(0),
|
|
137
|
+
outputTokens: integer("output_tokens").notNull().default(0),
|
|
138
|
+
steps: integer("steps").notNull().default(0),
|
|
139
|
+
result: text("result"),
|
|
140
|
+
error: text("error"),
|
|
141
|
+
wait: jsonb("wait"),
|
|
142
|
+
cancelRequestedAt: ts("cancel_requested_at"),
|
|
143
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
144
|
+
startedAt: ts("started_at"),
|
|
145
|
+
finishedAt: ts("finished_at"),
|
|
146
|
+
/** Where the run executes, when it runs on one of the person's paired devices (`agent.send`'s `device`). */
|
|
147
|
+
device: jsonb("device"),
|
|
148
|
+
/**
|
|
149
|
+
* How the run acts, recorded when it is queued: its mode (`act` or `plan`), its tool policy (`agent.tools`) and
|
|
150
|
+
* its delegation depth and profile (a sub-agent's). Read by the run at every step; never changed after.
|
|
151
|
+
*/
|
|
152
|
+
options: jsonb("options"),
|
|
153
|
+
/** What the final-answer check found (`RunVerification`), once the run answered after writing. */
|
|
154
|
+
verification: jsonb("verification"),
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A message sent while its conversation's run was still active, with `queue: true`: held, with everything the send
|
|
159
|
+
* carried (its settings, attachments, screen, device and authority), until that run ends; then it becomes the
|
|
160
|
+
* conversation's next message and run (`promoted`, under the ids it was given when queued). It can be cancelled
|
|
161
|
+
* while queued, and expires if its turn has not come by `expiresAt`.
|
|
162
|
+
*/
|
|
163
|
+
export const submissionTable = agentSchema.table("submission", {
|
|
164
|
+
...ownedColumns(),
|
|
165
|
+
conversationId: text("conversation_id").notNull(),
|
|
166
|
+
/** The run and message it becomes when promoted (known from the start, so a client follows them). */
|
|
167
|
+
runId: text("run_id").notNull(),
|
|
168
|
+
messageId: text("message_id").notNull(),
|
|
169
|
+
seq: bigint("seq", { mode: "number" }).notNull(),
|
|
170
|
+
kind: text("kind", { enum: ["turn", "job"] }).notNull(),
|
|
171
|
+
status: text("status", { enum: ["queued", "promoted", "cancelled", "expired", "refused"] }).notNull(),
|
|
172
|
+
text: text("text").notNull(),
|
|
173
|
+
content: jsonb("content").notNull(),
|
|
174
|
+
device: jsonb("device"),
|
|
175
|
+
limits: jsonb("limits"),
|
|
176
|
+
options: jsonb("options").notNull(),
|
|
177
|
+
authority: jsonb("authority").notNull(),
|
|
178
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
179
|
+
expiresAt: ts("expires_at").notNull(),
|
|
180
|
+
settledAt: ts("settled_at"),
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
export const runEventTable = agentSchema.table("run_event", {
|
|
184
|
+
...ownedColumns(),
|
|
185
|
+
runId: text("run_id").notNull(),
|
|
186
|
+
seq: integer("seq").notNull(),
|
|
187
|
+
type: text("type").notNull(),
|
|
188
|
+
data: jsonb("data").notNull(),
|
|
189
|
+
at: ts("at").notNull().defaultNow(),
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
export const inventoryTable = agentSchema.table("inventory", {
|
|
193
|
+
...ownedColumns(),
|
|
194
|
+
runId: text("run_id").notNull(),
|
|
195
|
+
step: integer("step").notNull(),
|
|
196
|
+
data: jsonb("data").notNull(),
|
|
197
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
export const directiveTable = agentSchema.table("directive", {
|
|
201
|
+
...ownedColumns(),
|
|
202
|
+
conversationId: text("conversation_id").notNull(),
|
|
203
|
+
ref: text("ref").notNull(),
|
|
204
|
+
directive: text("directive", { enum: ["pin", "evict", "restore"] }).notNull(),
|
|
205
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
export const usageTable = agentSchema.table("usage", {
|
|
209
|
+
...ownedColumns(),
|
|
210
|
+
runId: text("run_id"),
|
|
211
|
+
provider: text("provider").notNull(),
|
|
212
|
+
model: text("model").notNull(),
|
|
213
|
+
inputTokens: integer("input_tokens").notNull(),
|
|
214
|
+
outputTokens: integer("output_tokens").notNull(),
|
|
215
|
+
costMicros: doublePrecision("cost_micros").notNull(),
|
|
216
|
+
at: ts("at").notNull().defaultNow(),
|
|
217
|
+
/** The model call it records (`modelCall`), when it records one. */
|
|
218
|
+
callId: text("call_id"),
|
|
219
|
+
/** A call whose answer was lost (a crash): recorded at what it reserved, its worst case. */
|
|
220
|
+
estimated: boolean("estimated").notNull().default(false),
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* A model call (Metering): recorded as `started`, with its reservation (the counted input and the most it may
|
|
225
|
+
* write, and their cost), before the provider is asked; then `settled` (with its usage record), `released` (it
|
|
226
|
+
* failed) or `abandoned` (its answer was lost to a crash: its usage is recorded at what it reserved).
|
|
227
|
+
*/
|
|
228
|
+
export const modelCallTable = agentSchema.table("model_call", {
|
|
229
|
+
...ownedColumns(),
|
|
230
|
+
runId: text("run_id"),
|
|
231
|
+
step: integer("step"),
|
|
232
|
+
kind: text("kind", { enum: ["run", "compaction", "completion"] }).notNull(),
|
|
233
|
+
provider: text("provider").notNull(),
|
|
234
|
+
model: text("model").notNull(),
|
|
235
|
+
reservedInputTokens: integer("reserved_input_tokens").notNull(),
|
|
236
|
+
reservedOutputTokens: integer("reserved_output_tokens").notNull(),
|
|
237
|
+
reservedCostMicros: doublePrecision("reserved_cost_micros").notNull(),
|
|
238
|
+
status: text("status", { enum: ["started", "settled", "released", "abandoned"] }).notNull(),
|
|
239
|
+
startedAt: ts("started_at").notNull().defaultNow(),
|
|
240
|
+
finishedAt: ts("finished_at"),
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
/** A person's (`user`) or the organisation's (`org`) memory entry; `userId` is its owner or author. */
|
|
244
|
+
export const memoryTable = agentSchema.table("memory", {
|
|
245
|
+
id: text("id").primaryKey(),
|
|
246
|
+
orgId: text("org_id").notNull(),
|
|
247
|
+
scope: text("scope", { enum: ["user", "team", "org"] }).notNull(),
|
|
248
|
+
userId: text("user_id").notNull(),
|
|
249
|
+
/** A team's memory: the team (its members read it) and its lead group (they write it). */
|
|
250
|
+
team: text("team"),
|
|
251
|
+
teamLeads: text("team_leads"),
|
|
252
|
+
key: text("key").notNull(),
|
|
253
|
+
content: text("content").notNull(),
|
|
254
|
+
source: jsonb("source").notNull(),
|
|
255
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
256
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
/** A personal or organisation resource (instructions, a skill, a file); app resources come from the registry. */
|
|
260
|
+
export const resourceTable = agentSchema.table("resource", {
|
|
261
|
+
id: text("id").primaryKey(),
|
|
262
|
+
orgId: text("org_id").notNull(),
|
|
263
|
+
scope: text("scope", { enum: ["personal", "team", "org"] }).notNull(),
|
|
264
|
+
userId: text("user_id").notNull(),
|
|
265
|
+
/** A team's resource: the team (its members read it) and its lead group (they write it). */
|
|
266
|
+
team: text("team"),
|
|
267
|
+
teamLeads: text("team_leads"),
|
|
268
|
+
kind: text("kind", { enum: ["instructions", "skill", "file"] }).notNull(),
|
|
269
|
+
path: text("path").notNull(),
|
|
270
|
+
description: text("description").notNull(),
|
|
271
|
+
content: text("content").notNull(),
|
|
272
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
/** A budget (Metering); `userId` is the member it limits, or `*` (every member, or the organisation as a whole). */
|
|
276
|
+
export const budgetTable = agentSchema.table("budget", {
|
|
277
|
+
id: text("id").primaryKey(),
|
|
278
|
+
orgId: text("org_id").notNull(),
|
|
279
|
+
scope: text("scope", { enum: ["user", "org"] }).notNull(),
|
|
280
|
+
userId: text("user_id").notNull(),
|
|
281
|
+
meter: text("meter", { enum: ["agent.tokens", "agent.cost"] }).notNull(),
|
|
282
|
+
period: text("period", { enum: ["day", "month", "total"] }).notNull(),
|
|
283
|
+
limit: doublePrecision("limit_value"),
|
|
284
|
+
/** A soft threshold in percent of the limit: its people are notified once per period when usage reaches it. */
|
|
285
|
+
alertAt: integer("alert_at"),
|
|
286
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
/** A person's feedback on one of their runs (id `<runId>:<userId>`: one per person and run). */
|
|
290
|
+
export const feedbackTable = agentSchema.table("feedback", {
|
|
291
|
+
...ownedColumns(),
|
|
292
|
+
runId: text("run_id").notNull(),
|
|
293
|
+
rating: text("rating", { enum: ["up", "down"] }).notNull(),
|
|
294
|
+
comment: text("comment"),
|
|
295
|
+
tags: jsonb("tags").notNull().default([]),
|
|
296
|
+
createdAt: ts("created_at").notNull().defaultNow(),
|
|
297
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
/** The organisation's model choice (one row per organisation, id = the organisation's id). */
|
|
301
|
+
export const modelConfigTable = agentSchema.table("model_config", {
|
|
302
|
+
id: text("id").primaryKey(),
|
|
303
|
+
orgId: text("org_id").notNull(),
|
|
304
|
+
userId: text("user_id").notNull(),
|
|
305
|
+
provider: text("provider").notNull(),
|
|
306
|
+
model: text("model").notNull(),
|
|
307
|
+
updatedAt: ts("updated_at").notNull().defaultNow(),
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
// --- Entities ------------------------------------------------------------------------------------------------
|
|
311
|
+
|
|
312
|
+
/** The policy attributes of a record its owner reads, in the organisation they act in. */
|
|
313
|
+
const ownedBy = <O, U>(table: { readonly orgId: O; readonly userId: U }) => ({
|
|
314
|
+
org: { column: table.orgId, entity: "Eloxiv::Org" },
|
|
315
|
+
owner: { column: table.userId, entity: "Eloxiv::User" },
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
/** A message's and a run's conversation: the reference their read and send policies follow to a shared conversation. */
|
|
319
|
+
export const messageRelations = relations(messageTable, ({ one }) => ({
|
|
320
|
+
conversation: one(conversationTable, { fields: [messageTable.conversationId], references: [conversationTable.id] }),
|
|
321
|
+
}))
|
|
322
|
+
export const runRelations = relations(runTable, ({ one }) => ({
|
|
323
|
+
conversation: one(conversationTable, { fields: [runTable.conversationId], references: [conversationTable.id] }),
|
|
324
|
+
}))
|
|
325
|
+
|
|
326
|
+
export const conversation = defineEntity(conversationTable, {
|
|
327
|
+
name: "conversation",
|
|
328
|
+
cedarType: "Agent::Conversation",
|
|
329
|
+
// Shared with named people, a group or the organisation (the Sharing contract): to read it, or to reply in it.
|
|
330
|
+
policyAttributes: {
|
|
331
|
+
...ownedBy(conversationTable),
|
|
332
|
+
readers: { sharing: "read" },
|
|
333
|
+
repliers: { sharing: "reply" },
|
|
334
|
+
},
|
|
335
|
+
sync: { name: "agentConversation", omit: [conversationTable.agentSessionId] },
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
export const checkpoint = defineEntity(checkpointTable, {
|
|
339
|
+
name: "checkpoint",
|
|
340
|
+
cedarType: "Agent::Checkpoint",
|
|
341
|
+
policyAttributes: ownedBy(checkpointTable),
|
|
342
|
+
sync: { name: "agentCheckpoint" },
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
export const message = defineEntity(messageTable, {
|
|
346
|
+
name: "message",
|
|
347
|
+
cedarType: "Agent::Message",
|
|
348
|
+
policyAttributes: {
|
|
349
|
+
...ownedBy(messageTable),
|
|
350
|
+
conversation: { column: messageTable.conversationId, entity: "Agent::Conversation" },
|
|
351
|
+
role: { column: messageTable.role },
|
|
352
|
+
},
|
|
353
|
+
relations: messageRelations,
|
|
354
|
+
// A message's public form is its `text` (a person's words, an agent's answer). Its `content` (attachments' text, tool
|
|
355
|
+
// calls and their input, tool results) is its run's working state: it never syncs, so neither its owner's replica
|
|
356
|
+
// nor anyone a conversation is shared with holds it.
|
|
357
|
+
sync: { name: "agentMessage", omit: [messageTable.content] },
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
export const run = defineEntity(runTable, {
|
|
361
|
+
name: "run",
|
|
362
|
+
cedarType: "Agent::Run",
|
|
363
|
+
policyAttributes: {
|
|
364
|
+
...ownedBy(runTable),
|
|
365
|
+
conversation: { column: runTable.conversationId, entity: "Agent::Conversation" },
|
|
366
|
+
},
|
|
367
|
+
relations: runRelations,
|
|
368
|
+
// The run's working state (its task, limits, tools, what it waits on, its device) stays on the server.
|
|
369
|
+
sync: {
|
|
370
|
+
name: "agentRun",
|
|
371
|
+
omit: [
|
|
372
|
+
runTable.task,
|
|
373
|
+
runTable.limits,
|
|
374
|
+
runTable.tools,
|
|
375
|
+
runTable.wait,
|
|
376
|
+
runTable.cancelRequestedAt,
|
|
377
|
+
runTable.startedAt,
|
|
378
|
+
runTable.device,
|
|
379
|
+
runTable.options,
|
|
380
|
+
runTable.verification,
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
export const submission = defineEntity(submissionTable, {
|
|
386
|
+
name: "submission",
|
|
387
|
+
cedarType: "Agent::Submission",
|
|
388
|
+
policyAttributes: ownedBy(submissionTable),
|
|
389
|
+
// What it will run under stays on the server.
|
|
390
|
+
sync: {
|
|
391
|
+
name: "agentSubmission",
|
|
392
|
+
omit: [
|
|
393
|
+
submissionTable.content,
|
|
394
|
+
submissionTable.device,
|
|
395
|
+
submissionTable.limits,
|
|
396
|
+
submissionTable.options,
|
|
397
|
+
submissionTable.authority,
|
|
398
|
+
],
|
|
399
|
+
},
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
export const runEvent = defineEntity(runEventTable, {
|
|
403
|
+
name: "runEvent",
|
|
404
|
+
cedarType: "Agent::RunEvent",
|
|
405
|
+
policyAttributes: ownedBy(runEventTable),
|
|
406
|
+
sync: false,
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
export const inventory = defineEntity(inventoryTable, {
|
|
410
|
+
name: "inventory",
|
|
411
|
+
cedarType: "Agent::Inventory",
|
|
412
|
+
policyAttributes: ownedBy(inventoryTable),
|
|
413
|
+
sync: false,
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
export const directive = defineEntity(directiveTable, {
|
|
417
|
+
name: "directive",
|
|
418
|
+
cedarType: "Agent::Directive",
|
|
419
|
+
policyAttributes: ownedBy(directiveTable),
|
|
420
|
+
sync: false,
|
|
421
|
+
})
|
|
422
|
+
|
|
423
|
+
export const usage = defineEntity(usageTable, {
|
|
424
|
+
name: "usage",
|
|
425
|
+
cedarType: "Agent::Usage",
|
|
426
|
+
policyAttributes: ownedBy(usageTable),
|
|
427
|
+
sync: false,
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
export const modelCall = defineEntity(modelCallTable, {
|
|
431
|
+
name: "modelCall",
|
|
432
|
+
cedarType: "Agent::ModelCall",
|
|
433
|
+
policyAttributes: ownedBy(modelCallTable),
|
|
434
|
+
sync: false,
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
export const memory = defineEntity(memoryTable, {
|
|
438
|
+
name: "memory",
|
|
439
|
+
cedarType: "Agent::Memory",
|
|
440
|
+
policyAttributes: {
|
|
441
|
+
...ownedBy(memoryTable),
|
|
442
|
+
scope: { column: memoryTable.scope },
|
|
443
|
+
team: { column: memoryTable.team, entity: "Eloxiv::Group" },
|
|
444
|
+
teamLeads: { column: memoryTable.teamLeads, entity: "Eloxiv::Group" },
|
|
445
|
+
},
|
|
446
|
+
sync: false,
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
export const resource = defineEntity(resourceTable, {
|
|
450
|
+
name: "resource",
|
|
451
|
+
cedarType: "Agent::Resource",
|
|
452
|
+
policyAttributes: {
|
|
453
|
+
...ownedBy(resourceTable),
|
|
454
|
+
scope: { column: resourceTable.scope },
|
|
455
|
+
team: { column: resourceTable.team, entity: "Eloxiv::Group" },
|
|
456
|
+
teamLeads: { column: resourceTable.teamLeads, entity: "Eloxiv::Group" },
|
|
457
|
+
},
|
|
458
|
+
// A file resource's bytes (an image, a PDF, a spreadsheet) are a file attached to it through the Files contract:
|
|
459
|
+
// attached by whoever may write its scope, read by whoever may read the resource, deleted with it.
|
|
460
|
+
files: { maxBytes: 25 * 1024 * 1024 },
|
|
461
|
+
sync: false,
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
export const feedback = defineEntity(feedbackTable, {
|
|
465
|
+
name: "feedback",
|
|
466
|
+
cedarType: "Agent::Feedback",
|
|
467
|
+
policyAttributes: ownedBy(feedbackTable),
|
|
468
|
+
sync: false,
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
export const budget = defineEntity(budgetTable, {
|
|
472
|
+
name: "budget",
|
|
473
|
+
cedarType: "Agent::Budget",
|
|
474
|
+
policyAttributes: { org: { column: budgetTable.orgId, entity: "Eloxiv::Org" } },
|
|
475
|
+
sync: false,
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
export const modelConfig = defineEntity(modelConfigTable, {
|
|
479
|
+
name: "modelConfig",
|
|
480
|
+
cedarType: "Agent::ModelConfig",
|
|
481
|
+
policyAttributes: { org: { column: modelConfigTable.orgId, entity: "Eloxiv::Org" } },
|
|
482
|
+
sync: false,
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
// --- Actions -------------------------------------------------------------------------------------------------
|
|
486
|
+
|
|
487
|
+
/** A team's id (a Directory group id). */
|
|
488
|
+
const TeamId = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9_-]{0,62}$/u))
|
|
489
|
+
/** A team's lead group (Directory `TEAM_LEADS_SUFFIX`): its members write the team's agent context. */
|
|
490
|
+
const teamLeadsOf = (team: string) => `${team}${TEAM_LEADS_SUFFIX}`
|
|
491
|
+
|
|
492
|
+
export const send = defineAction({
|
|
493
|
+
name: "agent.send",
|
|
494
|
+
title: "Message your agent",
|
|
495
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
496
|
+
exposure: { agent: false, mcp: false },
|
|
497
|
+
description:
|
|
498
|
+
"Send a message to your agent: it is added to your conversation (a new one unless conversationId is given) and the agent starts working on it. Returns the run to follow. Only people and the organisation's jobs can send; an agent cannot. With device, the run executes on one of your paired devices (a local harness on your own subscription) instead of the deployment's model.",
|
|
499
|
+
input: Schema.Struct({
|
|
500
|
+
conversationId: Schema.optionalKey(Schema.String),
|
|
501
|
+
text: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(100_000)),
|
|
502
|
+
attachments: Schema.optionalKey(Schema.Array(Attachment)),
|
|
503
|
+
device: Schema.optionalKey(RunDevice),
|
|
504
|
+
/**
|
|
505
|
+
* What the person is looking at (the ScreenContext contract): references only, after the shell's privacy
|
|
506
|
+
* rules. Shown to the model with the message; never trusted for authorisation (tools run under policy).
|
|
507
|
+
*/
|
|
508
|
+
screen: Schema.optionalKey(ScreenSnapshot),
|
|
509
|
+
/**
|
|
510
|
+
* `plan`: the run reads and plans but changes nothing (only read-only actions and its own read tools; any other
|
|
511
|
+
* action is refused before it is called). Default `act`.
|
|
512
|
+
*/
|
|
513
|
+
mode: Schema.optionalKey(RunMode),
|
|
514
|
+
/**
|
|
515
|
+
* For a new conversation: the record it is about (a thread on that record; `GET /agent/conversations?about=`
|
|
516
|
+
* lists them). A reference only: the agent reads the record through its tools, under policy.
|
|
517
|
+
*/
|
|
518
|
+
resource: Schema.optionalKey(ConversationResource),
|
|
519
|
+
/**
|
|
520
|
+
* When the conversation's run is still active: queue the message instead of refusing it. It starts, as the
|
|
521
|
+
* conversation's next run, when the runs before it end; until then it can be cancelled (`agent.cancelQueued`).
|
|
522
|
+
*/
|
|
523
|
+
queue: Schema.optionalKey(Schema.Boolean),
|
|
524
|
+
/** How long a queued message may wait for its turn before it expires (default an hour, at most a day). */
|
|
525
|
+
queueTtlMs: Schema.optionalKey(
|
|
526
|
+
Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 1_000, maximum: 24 * 60 * 60 * 1000 })),
|
|
527
|
+
),
|
|
528
|
+
}),
|
|
529
|
+
output: SentMessage,
|
|
530
|
+
writes: "message",
|
|
531
|
+
actsOn: ["conversation", "run", "runEvent", "submission"],
|
|
532
|
+
})
|
|
533
|
+
|
|
534
|
+
export const giveFeedback = defineAction({
|
|
535
|
+
name: "agent.feedback",
|
|
536
|
+
title: "Rate an agent run",
|
|
537
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
538
|
+
exposure: { agent: false, mcp: false },
|
|
539
|
+
description:
|
|
540
|
+
"Rate one of your agent's runs up or down, with an optional comment and tags (lower-case labels such as wrong-tool): one rating per run, replaced by the next. Yours to give; your agent cannot.",
|
|
541
|
+
input: GiveFeedback,
|
|
542
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
543
|
+
writes: "feedback",
|
|
544
|
+
hints: { idempotent: true },
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
export const cancel = defineAction({
|
|
548
|
+
name: "agent.cancel",
|
|
549
|
+
title: "Cancel an agent run",
|
|
550
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
551
|
+
exposure: { agent: false, mcp: false },
|
|
552
|
+
description:
|
|
553
|
+
"Cancel one of your agent's runs: it stops before its next step and ends cancelled. A run that already finished is refused.",
|
|
554
|
+
input: Schema.Struct({ runId: Schema.String }),
|
|
555
|
+
output: Schema.Struct({ runId: Schema.String }),
|
|
556
|
+
writes: "run",
|
|
557
|
+
target: { entity: "run", field: "runId" },
|
|
558
|
+
hints: { idempotent: true },
|
|
559
|
+
})
|
|
560
|
+
|
|
561
|
+
export const continueTurn = defineAction({
|
|
562
|
+
name: "agent.continue",
|
|
563
|
+
title: "Continue an agent turn",
|
|
564
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
565
|
+
exposure: { agent: false, mcp: false },
|
|
566
|
+
description:
|
|
567
|
+
"Continue a turn your agent did not finish (it stopped at a limit, failed or was cancelled): a new run takes up the same request where the interrupted one left it, after reconciling what that run did. Only the conversation's latest turn, and only while nothing runs in it.",
|
|
568
|
+
input: Schema.Struct({ runId: Schema.String }),
|
|
569
|
+
output: Schema.Struct({ id: Schema.String, conversationId: Schema.String }),
|
|
570
|
+
writes: "run",
|
|
571
|
+
actsOn: ["conversation", "runEvent"],
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
export const cancelQueued = defineAction({
|
|
575
|
+
name: "agent.cancelQueued",
|
|
576
|
+
title: "Cancel a queued message",
|
|
577
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
578
|
+
exposure: { agent: false, mcp: false },
|
|
579
|
+
description: "Cancel a message you queued for your agent that has not started yet.",
|
|
580
|
+
input: Schema.Struct({ id: Schema.String }),
|
|
581
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
582
|
+
writes: "submission",
|
|
583
|
+
target: { entity: "submission", field: "id" },
|
|
584
|
+
hints: { idempotent: true },
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
export const recordTurn = defineAction({
|
|
588
|
+
name: "agent.recordTurn",
|
|
589
|
+
title: "Record a finished turn",
|
|
590
|
+
// A person's to call, not the app's agent's: left out of agent tools and WebMCP (MCP still offers it).
|
|
591
|
+
exposure: { agent: false },
|
|
592
|
+
description:
|
|
593
|
+
"Record a turn that was finished elsewhere (by one of your devices, or by an external agent working for you) in one of your conversations with your agent, or a new one: the prompt and the answer join the conversation as they were, so your agent sees them in its next turns. Nothing runs.",
|
|
594
|
+
input: Schema.Struct({
|
|
595
|
+
conversationId: Schema.optionalKey(Schema.String),
|
|
596
|
+
prompt: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(100_000)),
|
|
597
|
+
answer: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(100_000)),
|
|
598
|
+
source: Schema.Struct({
|
|
599
|
+
kind: Schema.Literals(["device", "external"]),
|
|
600
|
+
name: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
|
|
601
|
+
}),
|
|
602
|
+
resource: Schema.optionalKey(ConversationResource),
|
|
603
|
+
}),
|
|
604
|
+
output: Schema.Struct({ conversationId: Schema.String, messageIds: Schema.Array(Schema.String) }),
|
|
605
|
+
writes: "message",
|
|
606
|
+
actsOn: ["conversation"],
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
export const saveCheckpoint = defineAction({
|
|
610
|
+
name: "agent.saveCheckpoint",
|
|
611
|
+
title: "Save a checkpoint",
|
|
612
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
613
|
+
exposure: { agent: false, mcp: false },
|
|
614
|
+
description: "Save the current point of one of your conversations with your agent, to restore it later.",
|
|
615
|
+
input: Schema.Struct({
|
|
616
|
+
conversationId: Schema.String,
|
|
617
|
+
label: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
|
|
618
|
+
}),
|
|
619
|
+
output: Schema.Struct({ id: Schema.String, upTo: Schema.Number, messages: Schema.Number }),
|
|
620
|
+
writes: "checkpoint",
|
|
621
|
+
actsOn: ["conversation"],
|
|
622
|
+
})
|
|
623
|
+
|
|
624
|
+
export const restoreCheckpoint = defineAction({
|
|
625
|
+
name: "agent.restoreCheckpoint",
|
|
626
|
+
title: "Restore a checkpoint",
|
|
627
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
628
|
+
exposure: { agent: false, mcp: false },
|
|
629
|
+
description:
|
|
630
|
+
"Take one of your conversations back to a saved checkpoint: what came after it leaves the conversation (kept, not deleted), and the agent continues from that point.",
|
|
631
|
+
input: Schema.Struct({ id: Schema.String }),
|
|
632
|
+
output: Schema.Struct({ id: Schema.String, removed: Schema.Number }),
|
|
633
|
+
writes: "checkpoint",
|
|
634
|
+
target: { entity: "checkpoint", field: "id" },
|
|
635
|
+
actsOn: ["message", "conversation"],
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
export const updateConversation = defineAction({
|
|
639
|
+
name: "agent.updateConversation",
|
|
640
|
+
title: "Update a conversation",
|
|
641
|
+
// Refused to every agent-originated call (agent tools, MCP, an agent session): not listed where it is refused.
|
|
642
|
+
exposure: { agent: false, mcp: false },
|
|
643
|
+
description:
|
|
644
|
+
"Rename one of your conversations with your agent, or pin, archive or hide it (a hidden one is left out of your conversation lists unless asked for). Only the fields given change.",
|
|
645
|
+
input: Schema.Struct({
|
|
646
|
+
conversationId: Schema.String,
|
|
647
|
+
title: Schema.optionalKey(Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200))),
|
|
648
|
+
pinned: Schema.optionalKey(Schema.Boolean),
|
|
649
|
+
archived: Schema.optionalKey(Schema.Boolean),
|
|
650
|
+
hidden: Schema.optionalKey(Schema.Boolean),
|
|
651
|
+
/** Bind it to a team you are in (its runs work in that team's agent context), or unbind it (null). */
|
|
652
|
+
team: Schema.optionalKey(Schema.NullOr(TeamId)),
|
|
653
|
+
}),
|
|
654
|
+
output: Schema.Struct({
|
|
655
|
+
id: Schema.String,
|
|
656
|
+
title: Schema.String,
|
|
657
|
+
pinned: Schema.Boolean,
|
|
658
|
+
archived: Schema.Boolean,
|
|
659
|
+
hidden: Schema.Boolean,
|
|
660
|
+
team: Schema.NullOr(Schema.String),
|
|
661
|
+
}),
|
|
662
|
+
writes: "conversation",
|
|
663
|
+
target: { entity: "conversation", field: "conversationId" },
|
|
664
|
+
hints: { idempotent: true },
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
export const remember = defineAction({
|
|
668
|
+
name: "agent.remember",
|
|
669
|
+
title: "Remember something",
|
|
670
|
+
description:
|
|
671
|
+
"Remember something durably: in your own memory (scope user) or the organisation's (scope org, for members who manage the agent). Writing a key again replaces the entry. Remembered entries are given to the agent in every conversation.",
|
|
672
|
+
input: Schema.Struct({
|
|
673
|
+
scope: MemoryScope,
|
|
674
|
+
/** The team, for scope `team` (a Directory team the caller leads, or any with eloxiv.agent.manage). */
|
|
675
|
+
team: Schema.optionalKey(TeamId),
|
|
676
|
+
key: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
|
|
677
|
+
content: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(10_000)),
|
|
678
|
+
}),
|
|
679
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
680
|
+
writes: "memory",
|
|
681
|
+
})
|
|
682
|
+
|
|
683
|
+
export const forget = defineAction({
|
|
684
|
+
name: "agent.forget",
|
|
685
|
+
title: "Forget a memory",
|
|
686
|
+
description: "Forget a memory entry (by id) you may write.",
|
|
687
|
+
input: Schema.Struct({ id: Schema.String }),
|
|
688
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
689
|
+
writes: "memory",
|
|
690
|
+
target: { entity: "memory", field: "id" },
|
|
691
|
+
consent: false,
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
export const putResource = defineAction({
|
|
695
|
+
name: "agent.putResource",
|
|
696
|
+
title: "Save an agent resource",
|
|
697
|
+
description:
|
|
698
|
+
"Create or replace an agent resource (instructions, a skill or a file) in your personal scope, a team's (for its leads, or members who manage the agent), or the organisation's (for members who manage the agent). A personal resource overrides a team's, the organisation's and the app's with the same kind and path; a team's overrides the organisation's.",
|
|
699
|
+
input: Schema.Struct({
|
|
700
|
+
scope: Schema.Literals(["personal", "team", "org"]),
|
|
701
|
+
/** The team, for scope `team` (a Directory team the caller leads, or any with eloxiv.agent.manage). */
|
|
702
|
+
team: Schema.optionalKey(TeamId),
|
|
703
|
+
kind: ResourceKind,
|
|
704
|
+
path: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(300)),
|
|
705
|
+
description: Schema.String.check(Schema.isMaxLength(1_000)),
|
|
706
|
+
content: Schema.String.check(Schema.isMaxLength(200_000)),
|
|
707
|
+
}),
|
|
708
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
709
|
+
writes: "resource",
|
|
710
|
+
})
|
|
711
|
+
|
|
712
|
+
/** A folder of resources: a path and everything under it (`<path>/...`). */
|
|
713
|
+
const Folder = Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(300))
|
|
714
|
+
const FolderEntry = Schema.Struct({ kind: ResourceKind, path: Schema.String })
|
|
715
|
+
|
|
716
|
+
export const moveResources = defineAction({
|
|
717
|
+
name: "agent.moveResources",
|
|
718
|
+
title: "Move agent resources",
|
|
719
|
+
description:
|
|
720
|
+
"Move (rename) a folder of agent resources in your personal scope or the organisation's: the resource at `from` and everything under `from/` get the path with `to` in its place. All or nothing: refused if any new path is taken.",
|
|
721
|
+
input: Schema.Struct({ scope: Schema.Literals(["personal", "org"]), from: Folder, to: Folder }),
|
|
722
|
+
output: Schema.Struct({
|
|
723
|
+
moved: Schema.Array(Schema.Struct({ kind: ResourceKind, from: Schema.String, to: Schema.String })),
|
|
724
|
+
}),
|
|
725
|
+
writes: "resource",
|
|
726
|
+
// Where a resource sits decides what overrides what: an agent's move waits for its person's consent.
|
|
727
|
+
consent: true,
|
|
728
|
+
})
|
|
729
|
+
|
|
730
|
+
export const removeResources = defineAction({
|
|
731
|
+
name: "agent.removeResources",
|
|
732
|
+
title: "Delete agent resources",
|
|
733
|
+
description:
|
|
734
|
+
"Remove agent resources (with their files) by id, all or nothing: every one must be yours to remove (a personal resource of yours, or the organisation's if you manage the agent). To remove a folder, name every resource in it.",
|
|
735
|
+
input: Schema.Struct({ ids: Schema.Array(Schema.String).check(Schema.isMinLength(1), Schema.isMaxLength(500)) }),
|
|
736
|
+
output: Schema.Struct({ removed: Schema.Array(FolderEntry) }),
|
|
737
|
+
writes: "resource",
|
|
738
|
+
target: { entity: "resource", field: "ids" },
|
|
739
|
+
hints: { destructive: true },
|
|
740
|
+
})
|
|
741
|
+
|
|
742
|
+
export const removeResource = defineAction({
|
|
743
|
+
name: "agent.removeResource",
|
|
744
|
+
title: "Delete an agent resource",
|
|
745
|
+
description: "Remove a personal or organisation agent resource (by id) you may write.",
|
|
746
|
+
input: Schema.Struct({ id: Schema.String }),
|
|
747
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
748
|
+
writes: "resource",
|
|
749
|
+
target: { entity: "resource", field: "id" },
|
|
750
|
+
consent: false,
|
|
751
|
+
})
|
|
752
|
+
|
|
753
|
+
export const exportResources = defineAction({
|
|
754
|
+
name: "agent.exportResources",
|
|
755
|
+
title: "Export agent resources",
|
|
756
|
+
description:
|
|
757
|
+
"Export your personal agent resources, or the organisation's, as a resource pack (JSON) to import into another scope or installation.",
|
|
758
|
+
input: ExportResourcesInput,
|
|
759
|
+
output: ResourcePack,
|
|
760
|
+
hints: { readOnly: true, idempotent: true },
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
export const importResources = defineAction({
|
|
764
|
+
name: "agent.importResources",
|
|
765
|
+
title: "Import agent resources",
|
|
766
|
+
description:
|
|
767
|
+
"Import a resource pack into your personal scope, or the organisation's (for members who manage the agent), all or nothing. A resource whose kind and path is already there with other content refuses the import unless onConflict is skip or replace.",
|
|
768
|
+
input: ImportResourcesInput,
|
|
769
|
+
output: ImportResourcesOutput,
|
|
770
|
+
writes: "resource",
|
|
771
|
+
// What the agent is told comes from these resources: an agent's import waits for its person's consent.
|
|
772
|
+
consent: true,
|
|
773
|
+
})
|
|
774
|
+
|
|
775
|
+
export const directContext = defineAction({
|
|
776
|
+
name: "agent.directContext",
|
|
777
|
+
title: "Pin or remove context",
|
|
778
|
+
// A person's to call, not the app's agent's: left out of agent tools and WebMCP (MCP still offers it).
|
|
779
|
+
exposure: { agent: false },
|
|
780
|
+
description:
|
|
781
|
+
"Pin, evict or restore one item of a conversation's context (as the context x-ray names it): pinned items are always sent, evicted ones never, until restored.",
|
|
782
|
+
input: Schema.Struct({ conversationId: Schema.String, ref: Schema.String, directive: ContextDirective }),
|
|
783
|
+
output: Schema.Struct({ ref: Schema.String, directive: ContextDirective }),
|
|
784
|
+
writes: "directive",
|
|
785
|
+
})
|
|
786
|
+
|
|
787
|
+
export const setBudget = defineAction({
|
|
788
|
+
name: "agent.setBudget",
|
|
789
|
+
title: "Set the agent's budget",
|
|
790
|
+
// A person's decision only: its handler refuses every agent-originated call (agent tools, MCP, an agent session).
|
|
791
|
+
exposure: { agent: false, mcp: false },
|
|
792
|
+
description:
|
|
793
|
+
"Set or clear (limit null) a token or cost budget for the agent: the organisation's, one member's, or a default for every member (scope user without userId). For members who manage the agent.",
|
|
794
|
+
input: Schema.Struct({
|
|
795
|
+
scope: Schema.Literals(["user", "org"]),
|
|
796
|
+
userId: Schema.optionalKey(Schema.String),
|
|
797
|
+
meter: Meter,
|
|
798
|
+
period: BudgetPeriod,
|
|
799
|
+
limit: Schema.NullOr(Schema.Number.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
800
|
+
/** Notify at this percent of the limit (1 to 100), once per period; null clears it, absent keeps it. */
|
|
801
|
+
alertAt: Schema.optionalKey(Schema.NullOr(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })))),
|
|
802
|
+
}),
|
|
803
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
804
|
+
writes: "budget",
|
|
805
|
+
})
|
|
806
|
+
|
|
807
|
+
export const configureModel = defineAction({
|
|
808
|
+
name: "agent.configureModel",
|
|
809
|
+
title: "Choose the agent's model",
|
|
810
|
+
// A person's decision only: its handler refuses every agent-originated call (agent tools, MCP, an agent session).
|
|
811
|
+
exposure: { agent: false, mcp: false },
|
|
812
|
+
description:
|
|
813
|
+
"Choose the model provider and model the organisation's agent uses (one the deployment offers). For members who manage the agent.",
|
|
814
|
+
input: Schema.Struct({ provider: Schema.String, model: Schema.String }),
|
|
815
|
+
output: Schema.Struct({ provider: Schema.String, model: Schema.String }),
|
|
816
|
+
writes: "modelConfig",
|
|
817
|
+
})
|
|
818
|
+
|
|
819
|
+
/** Emitted by `agent.send` (and by delegation): the kernel starts the run's durable execution. */
|
|
820
|
+
export const runRequested = defineEvent("agent.runRequested", Schema.Struct({ runId: Schema.String }))
|
|
821
|
+
/** Emitted by `agent.cancel`: the kernel wakes the run if it is waiting, so it stops. */
|
|
822
|
+
export const cancelRequested = defineEvent("agent.cancelRequested", Schema.Struct({ runId: Schema.String }))
|
|
823
|
+
|
|
824
|
+
export const agent = defineModuleContract({
|
|
825
|
+
name: "agent",
|
|
826
|
+
version: "1.2.0",
|
|
827
|
+
cedarNamespace: "Agent",
|
|
828
|
+
entities: {
|
|
829
|
+
conversation,
|
|
830
|
+
checkpoint,
|
|
831
|
+
message,
|
|
832
|
+
run,
|
|
833
|
+
submission,
|
|
834
|
+
runEvent,
|
|
835
|
+
inventory,
|
|
836
|
+
directive,
|
|
837
|
+
usage,
|
|
838
|
+
modelCall,
|
|
839
|
+
memory,
|
|
840
|
+
resource,
|
|
841
|
+
feedback,
|
|
842
|
+
budget,
|
|
843
|
+
modelConfig,
|
|
844
|
+
},
|
|
845
|
+
dataSubjects: {
|
|
846
|
+
...deleteRecordsAbout({
|
|
847
|
+
conversation,
|
|
848
|
+
checkpoint,
|
|
849
|
+
message,
|
|
850
|
+
run,
|
|
851
|
+
submission,
|
|
852
|
+
runEvent,
|
|
853
|
+
inventory,
|
|
854
|
+
directive,
|
|
855
|
+
usage,
|
|
856
|
+
modelCall,
|
|
857
|
+
memory,
|
|
858
|
+
resource,
|
|
859
|
+
feedback,
|
|
860
|
+
}),
|
|
861
|
+
// A member's own budget and model choice (organisation-wide rows have an empty user id).
|
|
862
|
+
budget: { fields: ["userId"], erase: { kind: "delete" } },
|
|
863
|
+
modelConfig: { fields: ["userId"], erase: { kind: "delete" } },
|
|
864
|
+
},
|
|
865
|
+
actions: {
|
|
866
|
+
send,
|
|
867
|
+
cancel,
|
|
868
|
+
continueTurn,
|
|
869
|
+
cancelQueued,
|
|
870
|
+
updateConversation,
|
|
871
|
+
recordTurn,
|
|
872
|
+
saveCheckpoint,
|
|
873
|
+
restoreCheckpoint,
|
|
874
|
+
feedback: giveFeedback,
|
|
875
|
+
remember,
|
|
876
|
+
forget,
|
|
877
|
+
putResource,
|
|
878
|
+
removeResource,
|
|
879
|
+
moveResources,
|
|
880
|
+
removeResources,
|
|
881
|
+
exportResources,
|
|
882
|
+
importResources,
|
|
883
|
+
directContext,
|
|
884
|
+
setBudget,
|
|
885
|
+
configureModel,
|
|
886
|
+
},
|
|
887
|
+
events: { runRequested, cancelRequested },
|
|
888
|
+
settings: {
|
|
889
|
+
[LOOP_SETTING]: {
|
|
890
|
+
description:
|
|
891
|
+
"The organisation's agent loop limits (model calls, tokens, wall time per run): each one given replaces the deployment's, capped at the deployment's ceiling.",
|
|
892
|
+
scope: "org",
|
|
893
|
+
schema: AgentLoopPolicy,
|
|
894
|
+
default: {},
|
|
895
|
+
},
|
|
896
|
+
[TOOLS_SETTING]: {
|
|
897
|
+
description:
|
|
898
|
+
"How the organisation's agent is offered its tools: all of them on every call, or a compact index with tool_search to find and load the ones it needs.",
|
|
899
|
+
scope: "org",
|
|
900
|
+
schema: AgentToolPolicy,
|
|
901
|
+
default: { discovery: "all" },
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
views: {
|
|
905
|
+
"agent.conversation": {
|
|
906
|
+
title: "Conversation",
|
|
907
|
+
description: "A conversation with your agent.",
|
|
908
|
+
route: "/agent/conversation",
|
|
909
|
+
shows: { entity: "conversation" },
|
|
910
|
+
},
|
|
911
|
+
},
|
|
912
|
+
})
|
|
913
|
+
|
|
914
|
+
const ownedRule = (id: string, actions: ReadonlyArray<string>, type: string) => `
|
|
915
|
+
@id("${id}")
|
|
916
|
+
permit (principal, action in [${actions.map((a) => `Agent::Action::"${a}"`).join(", ")}], resource is Agent::${type})
|
|
917
|
+
when { resource.org == principal.org && resource.owner == principal };`
|
|
918
|
+
|
|
919
|
+
const scopedRule = (id: string, actions: ReadonlyArray<string>, type: string, personal: string) => `
|
|
920
|
+
@id("${id}")
|
|
921
|
+
permit (principal, action in [${actions.map((a) => `Agent::Action::"${a}"`).join(", ")}], resource is Agent::${type})
|
|
922
|
+
when { resource.org == principal.org && ((resource.scope == "${personal}" && resource.owner == principal) || (resource.scope == "org" && principal.permissions.contains("${AGENT_MANAGE}")) || (resource.scope == "team" && resource has team && principal in resource.team && ((resource has teamLeads && principal in resource.teamLeads) || principal.permissions.contains("${AGENT_MANAGE}")))) };`
|
|
923
|
+
|
|
924
|
+
export const agentPolicy = [
|
|
925
|
+
...["Conversation", "Message", "Run", "Submission", "RunEvent", "Inventory", "Directive", "Usage", "ModelCall"].map(
|
|
926
|
+
(type) => ownedRule(`agent.read.${type.toLowerCase()}`, ["read"], type),
|
|
927
|
+
),
|
|
928
|
+
...["Conversation", "Message", "Run", "RunEvent", "Submission"].map((type) =>
|
|
929
|
+
ownedRule(`agent.send.${type.toLowerCase()}`, ["send"], type),
|
|
930
|
+
),
|
|
931
|
+
// A shared conversation (the Sharing contract): its readers and repliers read it, and the people's words in it and
|
|
932
|
+
// their agents' answers, never another person's tool results or summaries (what that person's agent read with their
|
|
933
|
+
// permissions). Repliers send to it: their own run, as themselves. Only its owner shares it.
|
|
934
|
+
`
|
|
935
|
+
@id("agent.read.conversation.shared")
|
|
936
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Conversation)
|
|
937
|
+
when { resource.org == principal.org && (resource.readers.contains(principal) || resource.repliers.contains(principal)) };
|
|
938
|
+
|
|
939
|
+
@id("agent.read.message.shared")
|
|
940
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Message)
|
|
941
|
+
when { resource.org == principal.org && resource.role != "tool" && resource.role != "summary" &&
|
|
942
|
+
(resource.conversation.owner == principal || resource.conversation.readers.contains(principal) ||
|
|
943
|
+
resource.conversation.repliers.contains(principal)) };
|
|
944
|
+
|
|
945
|
+
@id("agent.send.conversation.shared")
|
|
946
|
+
permit (principal, action == Agent::Action::"send", resource is Agent::Conversation)
|
|
947
|
+
when { resource.org == principal.org && resource.repliers.contains(principal) };
|
|
948
|
+
|
|
949
|
+
@id("agent.send.run.shared")
|
|
950
|
+
permit (principal, action == Agent::Action::"send", resource is Agent::Run)
|
|
951
|
+
when { resource.org == principal.org && (resource.conversation.owner == principal ||
|
|
952
|
+
resource.conversation.repliers.contains(principal)) };
|
|
953
|
+
|
|
954
|
+
@id("agent.continue.conversation.shared")
|
|
955
|
+
permit (principal, action == Agent::Action::"continue", resource is Agent::Conversation)
|
|
956
|
+
when { resource.org == principal.org && resource.repliers.contains(principal) };
|
|
957
|
+
|
|
958
|
+
@id("agent.continue.run.shared")
|
|
959
|
+
permit (principal, action == Agent::Action::"continue", resource is Agent::Run)
|
|
960
|
+
when { resource.org == principal.org && (resource.conversation.owner == principal ||
|
|
961
|
+
resource.conversation.repliers.contains(principal)) };
|
|
962
|
+
|
|
963
|
+
@id("agent.share.conversation")
|
|
964
|
+
permit (principal, action == Agent::Action::"share", resource is Agent::Conversation)
|
|
965
|
+
when { resource.org == principal.org && resource.owner == principal };`,
|
|
966
|
+
ownedRule("agent.cancel", ["cancel"], "Run"),
|
|
967
|
+
ownedRule("agent.updateConversation", ["updateConversation"], "Conversation"),
|
|
968
|
+
...["Conversation", "Message"].map((type) =>
|
|
969
|
+
ownedRule(`agent.recordTurn.${type.toLowerCase()}`, ["recordTurn"], type),
|
|
970
|
+
),
|
|
971
|
+
...["Conversation", "Checkpoint"].map((type) =>
|
|
972
|
+
ownedRule(`agent.saveCheckpoint.${type.toLowerCase()}`, ["saveCheckpoint"], type),
|
|
973
|
+
),
|
|
974
|
+
...["Conversation", "Checkpoint", "Message"].map((type) =>
|
|
975
|
+
ownedRule(`agent.restoreCheckpoint.${type.toLowerCase()}`, ["restoreCheckpoint"], type),
|
|
976
|
+
),
|
|
977
|
+
ownedRule("agent.cancelQueued", ["cancelQueued"], "Submission"),
|
|
978
|
+
...["Run", "Conversation", "RunEvent"].map((type) =>
|
|
979
|
+
ownedRule(`agent.continue.${type.toLowerCase()}`, ["continue"], type),
|
|
980
|
+
),
|
|
981
|
+
ownedRule("agent.read.feedback", ["read"], "Feedback"),
|
|
982
|
+
ownedRule("agent.feedback", ["feedback"], "Feedback"),
|
|
983
|
+
ownedRule("agent.directContext", ["directContext"], "Directive"),
|
|
984
|
+
`
|
|
985
|
+
@id("agent.usage.admin")
|
|
986
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Usage)
|
|
987
|
+
when { resource.org == principal.org && principal.permissions.contains("${AGENT_MANAGE}") };
|
|
988
|
+
|
|
989
|
+
@id("agent.feedback.admin")
|
|
990
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Feedback)
|
|
991
|
+
when { resource.org == principal.org && principal.permissions.contains("${AGENT_MANAGE}") };
|
|
992
|
+
|
|
993
|
+
@id("agent.modelCall.admin")
|
|
994
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::ModelCall)
|
|
995
|
+
when { resource.org == principal.org && principal.permissions.contains("${AGENT_MANAGE}") };`,
|
|
996
|
+
`
|
|
997
|
+
@id("agent.read.memory")
|
|
998
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Memory)
|
|
999
|
+
when { resource.org == principal.org && ((resource.scope == "user" && resource.owner == principal) || resource.scope == "org" || (resource.scope == "team" && resource has team && principal in resource.team)) };`,
|
|
1000
|
+
scopedRule("agent.write.memory", ["remember", "forget"], "Memory", "user"),
|
|
1001
|
+
`
|
|
1002
|
+
@id("agent.read.resource")
|
|
1003
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Resource)
|
|
1004
|
+
when { resource.org == principal.org && ((resource.scope == "personal" && resource.owner == principal) || resource.scope == "org" || (resource.scope == "team" && resource has team && principal in resource.team)) };`,
|
|
1005
|
+
scopedRule(
|
|
1006
|
+
"agent.write.resource",
|
|
1007
|
+
["putResource", "removeResource", "importResources", "moveResources", "removeResources", "attach"],
|
|
1008
|
+
"Resource",
|
|
1009
|
+
"personal",
|
|
1010
|
+
),
|
|
1011
|
+
`
|
|
1012
|
+
@id("agent.exportResources")
|
|
1013
|
+
permit (principal, action == Agent::Action::"exportResources", resource);`,
|
|
1014
|
+
`
|
|
1015
|
+
@id("agent.read.budget")
|
|
1016
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::Budget)
|
|
1017
|
+
when { resource.org == principal.org };
|
|
1018
|
+
|
|
1019
|
+
@id("agent.setBudget")
|
|
1020
|
+
permit (principal, action == Agent::Action::"setBudget", resource is Agent::Budget)
|
|
1021
|
+
when { resource.org == principal.org && principal.permissions.contains("${AGENT_MANAGE}") };
|
|
1022
|
+
|
|
1023
|
+
@id("agent.read.modelConfig")
|
|
1024
|
+
permit (principal, action == Agent::Action::"read", resource is Agent::ModelConfig)
|
|
1025
|
+
when { resource.org == principal.org };
|
|
1026
|
+
|
|
1027
|
+
@id("agent.configureModel")
|
|
1028
|
+
permit (principal, action == Agent::Action::"configureModel", resource is Agent::ModelConfig)
|
|
1029
|
+
when { resource.org == principal.org && principal.permissions.contains("${AGENT_MANAGE}") };`,
|
|
1030
|
+
].join("\n")
|
|
1031
|
+
|
|
1032
|
+
/** Whether a statement failed because row-level security refused it (SQLSTATE 42501), anywhere in its causes. */
|
|
1033
|
+
const refusedByPolicy = (error: unknown): boolean => {
|
|
1034
|
+
for (let e: unknown = error, depth = 0; e != null && depth < 5; depth++) {
|
|
1035
|
+
const { code, message, cause } = e as {
|
|
1036
|
+
readonly code?: unknown
|
|
1037
|
+
readonly message?: unknown
|
|
1038
|
+
readonly cause?: unknown
|
|
1039
|
+
}
|
|
1040
|
+
if (code === "42501" || (typeof message === "string" && message.includes("row-level security"))) return true
|
|
1041
|
+
e = cause
|
|
1042
|
+
}
|
|
1043
|
+
return false
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Serialise the calls that put paths into one scope (put, import, move) for the rest of the transaction: a path that
|
|
1048
|
+
* does not exist yet cannot be row-locked, so without this a put racing a move into the same path would leave two
|
|
1049
|
+
* resources at one scope, kind and path. The scope is the organisation's, or one person's own.
|
|
1050
|
+
*/
|
|
1051
|
+
const lockScope = (ctx: HandlerContext, scope: "personal" | "team" | "org", team?: string) =>
|
|
1052
|
+
ctx.sql`SELECT pg_advisory_xact_lock(hashtextextended(${`eloxiv.agent.resource:${ctx.actor.orgId}:${scope}:${
|
|
1053
|
+
scope === "personal" ? ctx.actor.userId : scope === "team" ? (team ?? "") : ""
|
|
1054
|
+
}`}, 0))`.pipe(Effect.orDie, Effect.asVoid)
|
|
1055
|
+
|
|
1056
|
+
/** Setting the agent's budgets and model is a person's decision: an agent calling for a person is refused. */
|
|
1057
|
+
const notAnAgentsSetting = (action: string, ctx: HandlerContext) =>
|
|
1058
|
+
ctx.origin === "agent"
|
|
1059
|
+
? Effect.fail(
|
|
1060
|
+
new Forbidden({ action, message: "An agent cannot change the agent's budget or model; the person must" }),
|
|
1061
|
+
)
|
|
1062
|
+
: Effect.void
|
|
1063
|
+
|
|
1064
|
+
/** Starting and cancelling runs is for people and jobs: an agent calling for a person is refused. */
|
|
1065
|
+
const notAnAgent = (action: string, ctx: HandlerContext) =>
|
|
1066
|
+
ctx.origin === "agent"
|
|
1067
|
+
? Effect.fail(new Forbidden({ action, message: "An agent cannot start or steer agent runs; the person must" }))
|
|
1068
|
+
: Effect.void
|
|
1069
|
+
|
|
1070
|
+
/** Microseconds since the epoch, from the database clock: the order of messages in a conversation. */
|
|
1071
|
+
const nextSeq = (ctx: HandlerContext) =>
|
|
1072
|
+
ctx.sql<{ seq: string }>`SELECT (extract(epoch FROM clock_timestamp()) * 1000000)::bigint::text AS seq`.pipe(
|
|
1073
|
+
Effect.orDie,
|
|
1074
|
+
Effect.map(([row]) => Number(row!.seq)),
|
|
1075
|
+
)
|
|
1076
|
+
|
|
1077
|
+
const ACTIVE = ["queued", "running", "waiting"]
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* What a send's run is admitted with, read when it is sent (or queued): the message's content, the run's kind, the
|
|
1081
|
+
* organisation's policies as they stand (its loop limits, merged at the run's start over the deployment's under its
|
|
1082
|
+
* ceiling, and how its tools are offered), its mode, and the authority of the call.
|
|
1083
|
+
*/
|
|
1084
|
+
const admission = (
|
|
1085
|
+
input: {
|
|
1086
|
+
readonly text: string
|
|
1087
|
+
readonly attachments?: ReadonlyArray<unknown>
|
|
1088
|
+
readonly screen?: unknown
|
|
1089
|
+
readonly mode?: "act" | "plan"
|
|
1090
|
+
readonly device?: unknown
|
|
1091
|
+
},
|
|
1092
|
+
ctx: HandlerContext,
|
|
1093
|
+
) =>
|
|
1094
|
+
Effect.gen(function* () {
|
|
1095
|
+
// A device's harness runs its own tools: plan mode cannot be enforced there.
|
|
1096
|
+
if (input.mode === "plan" && input.device !== undefined) {
|
|
1097
|
+
return yield* new InvalidInput({
|
|
1098
|
+
message: "Plan mode is not available for a run on a device: its harness runs its own tools",
|
|
1099
|
+
})
|
|
1100
|
+
}
|
|
1101
|
+
const loop = yield* ctx.settings.get<AgentLoopPolicy>(LOOP_SETTING)
|
|
1102
|
+
const tools = yield* ctx.settings.get<AgentToolPolicy>(TOOLS_SETTING)
|
|
1103
|
+
return {
|
|
1104
|
+
content: {
|
|
1105
|
+
text: input.text,
|
|
1106
|
+
attachments: input.attachments ?? [],
|
|
1107
|
+
...(input.screen === undefined ? {} : { screen: input.screen }),
|
|
1108
|
+
},
|
|
1109
|
+
kind: ctx.origin === "system" ? ("job" as const) : ("turn" as const),
|
|
1110
|
+
limits: Object.keys(loop).length === 0 ? null : loop,
|
|
1111
|
+
options: {
|
|
1112
|
+
mode: input.mode ?? "act",
|
|
1113
|
+
tools,
|
|
1114
|
+
depth: 0,
|
|
1115
|
+
...((input.attachments?.length ?? 0) > 0 ? { attachments: input.attachments!.length } : {}),
|
|
1116
|
+
},
|
|
1117
|
+
authority: bindDeferred(ctx.authority, "once"),
|
|
1118
|
+
}
|
|
1119
|
+
})
|
|
1120
|
+
|
|
1121
|
+
export const agentModule = provideKernelModule(
|
|
1122
|
+
defineModule(agent, {
|
|
1123
|
+
schema: "eloxiv_agent",
|
|
1124
|
+
policy: agentPolicy,
|
|
1125
|
+
migrationsDir: new URL("../../src/agent/migrations/agent/", import.meta.url),
|
|
1126
|
+
handlers: {
|
|
1127
|
+
send: (input, ctx) =>
|
|
1128
|
+
Effect.gen(function* () {
|
|
1129
|
+
yield* notAnAgent(send.name, ctx)
|
|
1130
|
+
const { orgId, userId } = ctx.actor
|
|
1131
|
+
let conversationId = input.conversationId
|
|
1132
|
+
if (conversationId !== undefined) {
|
|
1133
|
+
// Lock the conversation first: a second send to it waits here until this one commits, then sees its run.
|
|
1134
|
+
// (Its owner's, or a conversation shared with the caller to reply in: the action's policy decides.)
|
|
1135
|
+
const [found] = yield* ctx.sql<{ id: string }>`
|
|
1136
|
+
UPDATE eloxiv_agent.conversation SET updated_at = now()
|
|
1137
|
+
WHERE id = ${conversationId} RETURNING id`.pipe(Effect.orDie)
|
|
1138
|
+
if (found === undefined) return yield* new InvalidInput({ message: `No conversation ${conversationId}` })
|
|
1139
|
+
const [busy] = yield* ctx.sql<{ id: string }>`
|
|
1140
|
+
SELECT id FROM eloxiv_agent.run WHERE conversation_id = ${conversationId}
|
|
1141
|
+
AND parent_run_id IS NULL AND status = ANY(${ACTIVE}::text[]) LIMIT 1`.pipe(Effect.orDie)
|
|
1142
|
+
if (busy !== undefined) {
|
|
1143
|
+
if (input.queue !== true) {
|
|
1144
|
+
return yield* new InvalidInput({
|
|
1145
|
+
message: `The agent is still working on run ${busy.id} in this conversation; wait for it, cancel it, or queue this message`,
|
|
1146
|
+
})
|
|
1147
|
+
}
|
|
1148
|
+
// Queued: held with everything this send carries, under the ids its run and message will have. The run that
|
|
1149
|
+
// ends before it promotes it holding this conversation's row (locked above), so a queued message is
|
|
1150
|
+
// never left behind by a run that ended while it was being queued.
|
|
1151
|
+
const queued = yield* admission(input, ctx)
|
|
1152
|
+
const submissionId = crypto.randomUUID()
|
|
1153
|
+
const runId = crypto.randomUUID()
|
|
1154
|
+
const messageId = crypto.randomUUID()
|
|
1155
|
+
const seq = yield* nextSeq(ctx)
|
|
1156
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.submission (id, org_id, user_id, conversation_id, run_id, message_id, seq,
|
|
1157
|
+
kind, status, text, content, device, limits, options, authority, expires_at)
|
|
1158
|
+
VALUES (${submissionId}, ${orgId}, ${userId}, ${conversationId}, ${runId}, ${messageId}, ${seq},
|
|
1159
|
+
${queued.kind}, 'queued', ${input.text}, ${JSON.stringify(queued.content)}::jsonb,
|
|
1160
|
+
${input.device === undefined ? null : JSON.stringify(input.device)}::jsonb,
|
|
1161
|
+
${queued.limits === null ? null : JSON.stringify(queued.limits)}::jsonb, ${JSON.stringify(queued.options)}::jsonb,
|
|
1162
|
+
${JSON.stringify(queued.authority)}::jsonb,
|
|
1163
|
+
now() + make_interval(secs => ${(input.queueTtlMs ?? 60 * 60 * 1000) / 1000}))`.pipe(Effect.orDie)
|
|
1164
|
+
return { conversationId, messageId, runId, queued: { submissionId } }
|
|
1165
|
+
}
|
|
1166
|
+
} else {
|
|
1167
|
+
conversationId = crypto.randomUUID()
|
|
1168
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.conversation (id, org_id, user_id, title, resource_module,
|
|
1169
|
+
resource_entity, resource_id)
|
|
1170
|
+
VALUES (${conversationId}, ${orgId}, ${userId}, ${input.text.slice(0, 80)}, ${input.resource?.module ?? null},
|
|
1171
|
+
${input.resource?.entity ?? null}, ${input.resource?.id ?? null})`.pipe(Effect.orDie)
|
|
1172
|
+
}
|
|
1173
|
+
const runId = crypto.randomUUID()
|
|
1174
|
+
const messageId = crypto.randomUUID()
|
|
1175
|
+
const seq = yield* nextSeq(ctx)
|
|
1176
|
+
const { content, kind, limits, options, authority } = yield* admission(input, ctx)
|
|
1177
|
+
// The run carries the authority of this call: every tool call, read and write of it, its delegates and the
|
|
1178
|
+
// work it queues stay within its scope and assert its chain (with the conversation's agent session).
|
|
1179
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.run
|
|
1180
|
+
(id, org_id, user_id, conversation_id, kind, status, device, authority, limits, options)
|
|
1181
|
+
VALUES (${runId}, ${orgId}, ${userId}, ${conversationId}, ${kind}, 'queued',
|
|
1182
|
+
${input.device === undefined ? null : JSON.stringify(input.device)}::jsonb,
|
|
1183
|
+
${JSON.stringify(authority)}::jsonb,
|
|
1184
|
+
${limits === null ? null : JSON.stringify(limits)}::jsonb,
|
|
1185
|
+
${JSON.stringify({ ...options, editGroup: { conversationId, messageId } })}::jsonb)`.pipe(Effect.orDie)
|
|
1186
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.message (id, org_id, user_id, conversation_id, run_id, seq, role, content, text)
|
|
1187
|
+
VALUES (${messageId}, ${orgId}, ${userId}, ${conversationId}, ${runId}, ${seq}, 'user',
|
|
1188
|
+
${JSON.stringify(content)}::jsonb, ${input.text})`.pipe(Effect.orDie)
|
|
1189
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.run_event (id, org_id, user_id, run_id, seq, type, data)
|
|
1190
|
+
VALUES (${`${runId}:0`}, ${orgId}, ${userId}, ${runId}, 0, 'run-started',
|
|
1191
|
+
${JSON.stringify({ conversationId, messageId })}::jsonb)`.pipe(Effect.orDie)
|
|
1192
|
+
yield* ctx.emit(runRequested, { runId })
|
|
1193
|
+
return { conversationId, messageId, runId }
|
|
1194
|
+
}),
|
|
1195
|
+
continueTurn: (input, ctx) =>
|
|
1196
|
+
Effect.gen(function* () {
|
|
1197
|
+
yield* notAnAgent(continueTurn.name, ctx)
|
|
1198
|
+
const { orgId, userId } = ctx.actor
|
|
1199
|
+
const [previous] = yield* ctx.sql<{
|
|
1200
|
+
conversationId: string
|
|
1201
|
+
parentRunId: string | null
|
|
1202
|
+
status: string
|
|
1203
|
+
finished: boolean
|
|
1204
|
+
device: unknown
|
|
1205
|
+
options: { readonly continuation?: { readonly of: string; readonly attempt: number } } | null
|
|
1206
|
+
createdAt: string
|
|
1207
|
+
}>`SELECT conversation_id AS "conversationId", parent_run_id AS "parentRunId", status,
|
|
1208
|
+
finished_at IS NOT NULL AS finished, device, options, created_at::text AS "createdAt"
|
|
1209
|
+
FROM eloxiv_agent.run WHERE id = ${input.runId} AND user_id = ${userId}`.pipe(Effect.orDie)
|
|
1210
|
+
if (previous === undefined || previous.parentRunId !== null) {
|
|
1211
|
+
return yield* new InvalidInput({ message: `No turn ${input.runId} of yours to continue` })
|
|
1212
|
+
}
|
|
1213
|
+
if (!previous.finished || !["stopped", "failed", "cancelled"].includes(previous.status)) {
|
|
1214
|
+
return yield* new InvalidInput({
|
|
1215
|
+
message: `Run ${input.runId} is ${previous.status}: only a turn that stopped, failed or was cancelled continues`,
|
|
1216
|
+
})
|
|
1217
|
+
}
|
|
1218
|
+
if (previous.device !== null) {
|
|
1219
|
+
return yield* new InvalidInput({ message: "A turn on a device runs whole on the device: send it again" })
|
|
1220
|
+
}
|
|
1221
|
+
// Locked, as a send locks it: its owner's, or a conversation shared with the caller to reply in (the action's
|
|
1222
|
+
// policy decides; a revoked replier locks nothing and is refused). Then the conversation's latest turn only, with
|
|
1223
|
+
// nothing running in it, whoever's (the policy lets the caller see every participant's runs of it).
|
|
1224
|
+
const [locked] = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.conversation SET updated_at = now()
|
|
1225
|
+
WHERE id = ${previous.conversationId} RETURNING id`.pipe(Effect.orDie)
|
|
1226
|
+
if (locked === undefined) {
|
|
1227
|
+
return yield* new InvalidInput({
|
|
1228
|
+
message: `You may no longer reply in the conversation of run ${input.runId}`,
|
|
1229
|
+
})
|
|
1230
|
+
}
|
|
1231
|
+
const [later] = yield* ctx.sql<{ id: string; status: string }>`SELECT id, status FROM eloxiv_agent.run
|
|
1232
|
+
WHERE conversation_id = ${previous.conversationId} AND parent_run_id IS NULL AND id <> ${input.runId}
|
|
1233
|
+
AND (status = ANY(${ACTIVE}::text[]) OR created_at > ${previous.createdAt}::timestamptz) LIMIT 1`.pipe(
|
|
1234
|
+
Effect.orDie,
|
|
1235
|
+
)
|
|
1236
|
+
if (later !== undefined) {
|
|
1237
|
+
return yield* new InvalidInput({
|
|
1238
|
+
message: ACTIVE.includes(later.status)
|
|
1239
|
+
? `The agent is working on run ${later.id} in this conversation`
|
|
1240
|
+
: `A later turn (${later.id}) was sent in this conversation: only the latest continues`,
|
|
1241
|
+
})
|
|
1242
|
+
}
|
|
1243
|
+
const loop = yield* ctx.settings.get<AgentLoopPolicy>(LOOP_SETTING)
|
|
1244
|
+
const tools = yield* ctx.settings.get<AgentToolPolicy>(TOOLS_SETTING)
|
|
1245
|
+
const before = previous.options ?? {}
|
|
1246
|
+
const options = {
|
|
1247
|
+
...before,
|
|
1248
|
+
tools,
|
|
1249
|
+
depth: 0,
|
|
1250
|
+
continuation: {
|
|
1251
|
+
of: before.continuation?.of ?? input.runId,
|
|
1252
|
+
previous: input.runId,
|
|
1253
|
+
attempt: (before.continuation?.attempt ?? 0) + 1,
|
|
1254
|
+
automatic: false,
|
|
1255
|
+
},
|
|
1256
|
+
}
|
|
1257
|
+
const id = crypto.randomUUID()
|
|
1258
|
+
// Under the authority of this call: the person's own request to go on.
|
|
1259
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.run
|
|
1260
|
+
(id, org_id, user_id, conversation_id, kind, status, authority, limits, options)
|
|
1261
|
+
VALUES (${id}, ${orgId}, ${userId}, ${previous.conversationId}, 'turn', 'queued',
|
|
1262
|
+
${JSON.stringify(bindDeferred(ctx.authority, "once"))}::jsonb,
|
|
1263
|
+
${Object.keys(loop).length === 0 ? null : JSON.stringify(loop)}::jsonb, ${JSON.stringify(options)}::jsonb)`.pipe(
|
|
1264
|
+
Effect.orDie,
|
|
1265
|
+
)
|
|
1266
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.run_event (id, org_id, user_id, run_id, seq, type, data)
|
|
1267
|
+
VALUES (${`${id}:0`}, ${orgId}, ${userId}, ${id}, 0, 'run-started',
|
|
1268
|
+
${JSON.stringify({ conversationId: previous.conversationId, continues: input.runId })}::jsonb)`.pipe(
|
|
1269
|
+
Effect.orDie,
|
|
1270
|
+
)
|
|
1271
|
+
yield* ctx.emit(runRequested, { runId: id })
|
|
1272
|
+
return { id, conversationId: previous.conversationId }
|
|
1273
|
+
}),
|
|
1274
|
+
cancelQueued: (input, ctx) =>
|
|
1275
|
+
Effect.gen(function* () {
|
|
1276
|
+
yield* notAnAgent(cancelQueued.name, ctx)
|
|
1277
|
+
// Its row, locked: the run that promotes it locks it too, so it is either cancelled or started, never both.
|
|
1278
|
+
const [row] = yield* ctx.sql<{ status: string }>`SELECT status FROM eloxiv_agent.submission
|
|
1279
|
+
WHERE id = ${input.id} FOR UPDATE`.pipe(Effect.orDie)
|
|
1280
|
+
if (row?.status !== "queued" && row?.status !== "cancelled") {
|
|
1281
|
+
return yield* new InvalidInput({
|
|
1282
|
+
message: `The queued message ${input.id} ${row?.status === "promoted" ? "has already started" : `is ${row?.status ?? "unknown"}`}`,
|
|
1283
|
+
})
|
|
1284
|
+
}
|
|
1285
|
+
yield* ctx.sql`UPDATE eloxiv_agent.submission SET status = 'cancelled', settled_at = coalesce(settled_at, now())
|
|
1286
|
+
WHERE id = ${input.id}`.pipe(Effect.orDie)
|
|
1287
|
+
return { id: input.id }
|
|
1288
|
+
}),
|
|
1289
|
+
cancel: (input, ctx) =>
|
|
1290
|
+
Effect.gen(function* () {
|
|
1291
|
+
yield* notAnAgent(cancel.name, ctx)
|
|
1292
|
+
// The run's row, locked: the run records its outcome under the same lock, so a run that finished first
|
|
1293
|
+
// keeps its outcome (and the cancellation is refused), and one that finishes after ends cancelled. A run
|
|
1294
|
+
// that ended cancelled is cancelled again, which changes nothing.
|
|
1295
|
+
const [run] = yield* ctx.sql<{ status: string; finished: boolean }>`
|
|
1296
|
+
SELECT status, finished_at IS NOT NULL AS finished FROM eloxiv_agent.run WHERE id = ${input.runId}
|
|
1297
|
+
FOR UPDATE`.pipe(Effect.orDie)
|
|
1298
|
+
if (run?.finished === true && run.status !== "cancelled") {
|
|
1299
|
+
return yield* new InvalidInput({
|
|
1300
|
+
message: `Run ${input.runId} already finished (${run.status}); it was not cancelled`,
|
|
1301
|
+
})
|
|
1302
|
+
}
|
|
1303
|
+
// Its sub-agents are cancelled with it: each reads its parent's flag (holding the parent's row) wherever it
|
|
1304
|
+
// reads its own, and the kernel's reaction records it on them and wakes them.
|
|
1305
|
+
yield* ctx.sql`UPDATE eloxiv_agent.run SET cancel_requested_at = coalesce(cancel_requested_at, now())
|
|
1306
|
+
WHERE id = ${input.runId}`.pipe(Effect.orDie)
|
|
1307
|
+
yield* ctx.emit(cancelRequested, { runId: input.runId })
|
|
1308
|
+
return { runId: input.runId }
|
|
1309
|
+
}),
|
|
1310
|
+
recordTurn: (input, ctx) =>
|
|
1311
|
+
Effect.gen(function* () {
|
|
1312
|
+
const { orgId, userId } = ctx.actor
|
|
1313
|
+
let conversationId = input.conversationId
|
|
1314
|
+
if (conversationId !== undefined) {
|
|
1315
|
+
// Locked, as a send locks it: a turn is recorded only between runs, never into one in progress.
|
|
1316
|
+
const [found] = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.conversation SET updated_at = now()
|
|
1317
|
+
WHERE id = ${conversationId} AND user_id = ${userId} RETURNING id`.pipe(Effect.orDie)
|
|
1318
|
+
if (found === undefined) return yield* new InvalidInput({ message: `No conversation ${conversationId}` })
|
|
1319
|
+
const [busy] = yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.run
|
|
1320
|
+
WHERE conversation_id = ${conversationId} AND status = ANY(${ACTIVE}::text[]) LIMIT 1`.pipe(Effect.orDie)
|
|
1321
|
+
if (busy !== undefined) {
|
|
1322
|
+
return yield* new InvalidInput({ message: `The agent is working on run ${busy.id} in this conversation` })
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
conversationId = crypto.randomUUID()
|
|
1326
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.conversation (id, org_id, user_id, title, resource_module,
|
|
1327
|
+
resource_entity, resource_id)
|
|
1328
|
+
VALUES (${conversationId}, ${orgId}, ${userId}, ${input.prompt.slice(0, 80)}, ${input.resource?.module ?? null},
|
|
1329
|
+
${input.resource?.entity ?? null}, ${input.resource?.id ?? null})`.pipe(Effect.orDie)
|
|
1330
|
+
}
|
|
1331
|
+
// Who finished it, and through which surface it was recorded (an external agent's own call is agent-originated).
|
|
1332
|
+
const external = { ...input.source, recordedBy: ctx.origin, invocationId: ctx.invocationId }
|
|
1333
|
+
const ids = [crypto.randomUUID(), crypto.randomUUID()]
|
|
1334
|
+
const promptSeq = yield* nextSeq(ctx)
|
|
1335
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.message (id, org_id, user_id, conversation_id, run_id, seq, role, content, text)
|
|
1336
|
+
VALUES (${ids[0]!}, ${orgId}, ${userId}, ${conversationId}, NULL, ${promptSeq}, 'user',
|
|
1337
|
+
${JSON.stringify({ text: input.prompt, attachments: [], external })}::jsonb, ${input.prompt})`.pipe(
|
|
1338
|
+
Effect.orDie,
|
|
1339
|
+
)
|
|
1340
|
+
const answerSeq = Math.max(yield* nextSeq(ctx), promptSeq + 1)
|
|
1341
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.message (id, org_id, user_id, conversation_id, run_id, seq, role, content, text)
|
|
1342
|
+
VALUES (${ids[1]!}, ${orgId}, ${userId}, ${conversationId}, NULL, ${answerSeq}, 'assistant',
|
|
1343
|
+
${JSON.stringify({ text: input.answer, toolCalls: [], external })}::jsonb, ${input.answer})`.pipe(
|
|
1344
|
+
Effect.orDie,
|
|
1345
|
+
)
|
|
1346
|
+
return { conversationId, messageIds: ids }
|
|
1347
|
+
}),
|
|
1348
|
+
saveCheckpoint: (input, ctx) =>
|
|
1349
|
+
Effect.gen(function* () {
|
|
1350
|
+
yield* notAnAgent(saveCheckpoint.name, ctx)
|
|
1351
|
+
const { orgId, userId } = ctx.actor
|
|
1352
|
+
const [owned] = yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.conversation
|
|
1353
|
+
WHERE id = ${input.conversationId} AND user_id = ${userId}`.pipe(Effect.orDie)
|
|
1354
|
+
if (owned === undefined)
|
|
1355
|
+
return yield* new InvalidInput({ message: `No conversation ${input.conversationId}` })
|
|
1356
|
+
// The conversation as it stands: every message in it now (compacted ones are in it through their summary).
|
|
1357
|
+
const [state] = yield* ctx.sql<{ upTo: string | null; messages: number }>`SELECT max(seq)::text AS "upTo",
|
|
1358
|
+
count(*)::int AS messages FROM eloxiv_agent.message
|
|
1359
|
+
WHERE conversation_id = ${input.conversationId} AND (covered_by IS NULL OR covered_by NOT LIKE 'restore:%')`.pipe(
|
|
1360
|
+
Effect.orDie,
|
|
1361
|
+
)
|
|
1362
|
+
const id = crypto.randomUUID()
|
|
1363
|
+
const upTo = Number(state?.upTo ?? 0)
|
|
1364
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.checkpoint (id, org_id, user_id, conversation_id, label, up_to, messages)
|
|
1365
|
+
VALUES (${id}, ${orgId}, ${userId}, ${input.conversationId}, ${input.label}, ${upTo}, ${state?.messages ?? 0})`.pipe(
|
|
1366
|
+
Effect.orDie,
|
|
1367
|
+
)
|
|
1368
|
+
return { id, upTo, messages: state?.messages ?? 0 }
|
|
1369
|
+
}),
|
|
1370
|
+
restoreCheckpoint: (input, ctx) =>
|
|
1371
|
+
Effect.gen(function* () {
|
|
1372
|
+
yield* notAnAgent(restoreCheckpoint.name, ctx)
|
|
1373
|
+
const [saved] = yield* ctx.sql<{ conversationId: string; upTo: string; createdAt: string }>`
|
|
1374
|
+
SELECT conversation_id AS "conversationId", up_to::text AS "upTo", created_at::text AS "createdAt"
|
|
1375
|
+
FROM eloxiv_agent.checkpoint WHERE id = ${input.id}`.pipe(Effect.orDie)
|
|
1376
|
+
if (saved === undefined) return yield* new InvalidInput({ message: `No checkpoint ${input.id}` })
|
|
1377
|
+
// Locked, as a send locks it: never while the agent works in it.
|
|
1378
|
+
yield* ctx.sql`UPDATE eloxiv_agent.conversation SET updated_at = now() WHERE id = ${saved.conversationId}`.pipe(
|
|
1379
|
+
Effect.orDie,
|
|
1380
|
+
)
|
|
1381
|
+
const [busy] = yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.run
|
|
1382
|
+
WHERE conversation_id = ${saved.conversationId} AND status = ANY(${ACTIVE}::text[]) LIMIT 1`.pipe(
|
|
1383
|
+
Effect.orDie,
|
|
1384
|
+
)
|
|
1385
|
+
if (busy !== undefined) {
|
|
1386
|
+
return yield* new InvalidInput({ message: `The agent is working on run ${busy.id} in this conversation` })
|
|
1387
|
+
}
|
|
1388
|
+
const marker = `restore:${input.id}:${crypto.randomUUID()}`
|
|
1389
|
+
// Every fold written after the checkpoint goes, at every tier (an observation and the reflection over it):
|
|
1390
|
+
// it may hold what came after. What they covered from before comes back into the conversation: the raw
|
|
1391
|
+
// messages up to the checkpoint and the folds it already had (those after go with the rest).
|
|
1392
|
+
const summaries = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.message SET covered_by = ${marker}
|
|
1393
|
+
WHERE conversation_id = ${saved.conversationId} AND role = 'summary'
|
|
1394
|
+
AND (covered_by IS NULL OR covered_by NOT LIKE 'restore:%')
|
|
1395
|
+
AND created_at > ${saved.createdAt}::timestamptz RETURNING id`.pipe(Effect.orDie)
|
|
1396
|
+
if (summaries.length > 0) {
|
|
1397
|
+
const ids = summaries.map((m) => m.id)
|
|
1398
|
+
yield* ctx.sql`UPDATE eloxiv_agent.message SET covered_by = NULL
|
|
1399
|
+
WHERE conversation_id = ${saved.conversationId} AND covered_by = ANY(${ids}::text[])
|
|
1400
|
+
AND (CASE WHEN role = 'summary' THEN created_at <= ${saved.createdAt}::timestamptz
|
|
1401
|
+
ELSE seq <= ${saved.upTo}::bigint END)`.pipe(Effect.orDie)
|
|
1402
|
+
}
|
|
1403
|
+
const removed = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.message SET covered_by = ${marker}
|
|
1404
|
+
WHERE conversation_id = ${saved.conversationId} AND seq > ${saved.upTo}::bigint
|
|
1405
|
+
AND (covered_by IS NULL OR covered_by NOT LIKE 'restore:%') AND role <> 'summary' RETURNING id`.pipe(
|
|
1406
|
+
Effect.orDie,
|
|
1407
|
+
)
|
|
1408
|
+
yield* ctx.sql`UPDATE eloxiv_agent.checkpoint SET restored_at = now() WHERE id = ${input.id}`.pipe(
|
|
1409
|
+
Effect.orDie,
|
|
1410
|
+
)
|
|
1411
|
+
return { id: input.id, removed: removed.length }
|
|
1412
|
+
}),
|
|
1413
|
+
updateConversation: (input, ctx) =>
|
|
1414
|
+
Effect.gen(function* () {
|
|
1415
|
+
yield* notAnAgent(updateConversation.name, ctx)
|
|
1416
|
+
// A team only the person is in (the live directory, as policies read it).
|
|
1417
|
+
if (typeof input.team === "string") {
|
|
1418
|
+
const [inTeam] = yield* ctx.sql<{
|
|
1419
|
+
member: boolean
|
|
1420
|
+
}>`SELECT eloxiv_ctx.in_group(${input.team}) AS member`.pipe(Effect.orDie)
|
|
1421
|
+
if (inTeam?.member !== true) {
|
|
1422
|
+
return yield* new InvalidInput({ message: `You are not in the team ${input.team}` })
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
const [row] = yield* ctx.sql<{
|
|
1426
|
+
id: string
|
|
1427
|
+
title: string
|
|
1428
|
+
pinned: boolean
|
|
1429
|
+
archived: boolean
|
|
1430
|
+
hidden: boolean
|
|
1431
|
+
team: string | null
|
|
1432
|
+
}>`
|
|
1433
|
+
UPDATE eloxiv_agent.conversation SET
|
|
1434
|
+
title = coalesce(${input.title ?? null}, title),
|
|
1435
|
+
pinned = coalesce(${input.pinned ?? null}::boolean, pinned),
|
|
1436
|
+
archived = coalesce(${input.archived ?? null}::boolean, archived),
|
|
1437
|
+
hidden = coalesce(${input.hidden ?? null}::boolean, hidden),
|
|
1438
|
+
team = CASE WHEN ${input.team !== undefined} THEN ${input.team ?? null} ELSE team END
|
|
1439
|
+
WHERE id = ${input.conversationId} AND user_id = ${ctx.actor.userId}
|
|
1440
|
+
RETURNING id, title, pinned, archived, hidden, team`.pipe(Effect.orDie)
|
|
1441
|
+
if (row === undefined) return yield* new InvalidInput({ message: `No conversation ${input.conversationId}` })
|
|
1442
|
+
return row
|
|
1443
|
+
}),
|
|
1444
|
+
feedback: (input, ctx) =>
|
|
1445
|
+
Effect.gen(function* () {
|
|
1446
|
+
if (ctx.origin === "agent") {
|
|
1447
|
+
return yield* new Forbidden({
|
|
1448
|
+
action: giveFeedback.name,
|
|
1449
|
+
message: "Feedback on a run is the person's to give",
|
|
1450
|
+
})
|
|
1451
|
+
}
|
|
1452
|
+
const { orgId, userId } = ctx.actor
|
|
1453
|
+
// The run must be the person's own (its read policy: its owner, in the organisation they act in).
|
|
1454
|
+
const [run] = yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.run
|
|
1455
|
+
WHERE id = ${input.runId} AND user_id = ${userId}`.pipe(Effect.orDie)
|
|
1456
|
+
if (run === undefined) return yield* new InvalidInput({ message: `No run ${input.runId} of yours` })
|
|
1457
|
+
const id = `${input.runId}:${userId}`
|
|
1458
|
+
const tags = JSON.stringify([...new Set(input.tags ?? [])])
|
|
1459
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.feedback (id, org_id, user_id, run_id, rating, comment, tags)
|
|
1460
|
+
VALUES (${id}, ${orgId}, ${userId}, ${input.runId}, ${input.rating}, ${input.comment ?? null}, ${tags}::jsonb)
|
|
1461
|
+
ON CONFLICT (id) DO UPDATE SET rating = EXCLUDED.rating, comment = EXCLUDED.comment, tags = EXCLUDED.tags,
|
|
1462
|
+
updated_at = now()`.pipe(Effect.orDie)
|
|
1463
|
+
return { id }
|
|
1464
|
+
}),
|
|
1465
|
+
remember: (input, ctx) =>
|
|
1466
|
+
Effect.gen(function* () {
|
|
1467
|
+
const { orgId, userId } = ctx.actor
|
|
1468
|
+
const source = { kind: ctx.origin, invocationId: ctx.invocationId }
|
|
1469
|
+
const team = input.scope === "team" ? input.team : undefined
|
|
1470
|
+
if (input.scope === "team" && team === undefined) {
|
|
1471
|
+
return yield* new InvalidInput({ message: "A team's memory names the team" })
|
|
1472
|
+
}
|
|
1473
|
+
const [existing] =
|
|
1474
|
+
input.scope === "user"
|
|
1475
|
+
? yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.memory
|
|
1476
|
+
WHERE scope = 'user' AND user_id = ${userId} AND key = ${input.key}`.pipe(Effect.orDie)
|
|
1477
|
+
: input.scope === "team"
|
|
1478
|
+
? yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.memory
|
|
1479
|
+
WHERE scope = 'team' AND team = ${team!} AND key = ${input.key}`.pipe(Effect.orDie)
|
|
1480
|
+
: yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.memory
|
|
1481
|
+
WHERE scope = 'org' AND key = ${input.key}`.pipe(Effect.orDie)
|
|
1482
|
+
if (existing !== undefined) {
|
|
1483
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.memory
|
|
1484
|
+
SET content = ${input.content}, source = ${JSON.stringify(source)}::jsonb, user_id = ${userId}, updated_at = now()
|
|
1485
|
+
WHERE id = ${existing.id} RETURNING id`.pipe(Effect.orDie)
|
|
1486
|
+
if (updated.length === 0) {
|
|
1487
|
+
return yield* new Forbidden({ action: remember.name, message: "You may not change this memory entry" })
|
|
1488
|
+
}
|
|
1489
|
+
return { id: existing.id }
|
|
1490
|
+
}
|
|
1491
|
+
const id = crypto.randomUUID()
|
|
1492
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.memory (id, org_id, scope, user_id, team, team_leads, key, content, source)
|
|
1493
|
+
VALUES (${id}, ${orgId}, ${input.scope}, ${userId}, ${team ?? null}, ${team === undefined ? null : teamLeadsOf(team)},
|
|
1494
|
+
${input.key}, ${input.content}, ${JSON.stringify(source)}::jsonb)`.pipe(Effect.orDie)
|
|
1495
|
+
return { id }
|
|
1496
|
+
}),
|
|
1497
|
+
forget: (input, ctx) =>
|
|
1498
|
+
ctx.sql`DELETE FROM eloxiv_agent.memory WHERE id = ${input.id}`.pipe(Effect.orDie, Effect.as({ id: input.id })),
|
|
1499
|
+
putResource: (input, ctx) =>
|
|
1500
|
+
Effect.gen(function* () {
|
|
1501
|
+
const { orgId, userId } = ctx.actor
|
|
1502
|
+
const team = input.scope === "team" ? input.team : undefined
|
|
1503
|
+
if (input.scope === "team" && team === undefined) {
|
|
1504
|
+
return yield* new InvalidInput({ message: "A team's resource names the team" })
|
|
1505
|
+
}
|
|
1506
|
+
yield* lockScope(ctx, input.scope, team)
|
|
1507
|
+
const [existing] =
|
|
1508
|
+
input.scope === "personal"
|
|
1509
|
+
? yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.resource
|
|
1510
|
+
WHERE scope = 'personal' AND user_id = ${userId} AND kind = ${input.kind} AND path = ${input.path}`.pipe(
|
|
1511
|
+
Effect.orDie,
|
|
1512
|
+
)
|
|
1513
|
+
: input.scope === "team"
|
|
1514
|
+
? yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.resource
|
|
1515
|
+
WHERE scope = 'team' AND team = ${team!} AND kind = ${input.kind} AND path = ${input.path}`.pipe(
|
|
1516
|
+
Effect.orDie,
|
|
1517
|
+
)
|
|
1518
|
+
: yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.resource
|
|
1519
|
+
WHERE scope = 'org' AND kind = ${input.kind} AND path = ${input.path}`.pipe(Effect.orDie)
|
|
1520
|
+
if (existing !== undefined) {
|
|
1521
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.resource
|
|
1522
|
+
SET description = ${input.description}, content = ${input.content}, user_id = ${userId}, updated_at = now()
|
|
1523
|
+
WHERE id = ${existing.id} RETURNING id`.pipe(Effect.orDie)
|
|
1524
|
+
if (updated.length === 0) {
|
|
1525
|
+
return yield* new Forbidden({ action: putResource.name, message: "You may not change this resource" })
|
|
1526
|
+
}
|
|
1527
|
+
return { id: existing.id }
|
|
1528
|
+
}
|
|
1529
|
+
const id = crypto.randomUUID()
|
|
1530
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.resource
|
|
1531
|
+
(id, org_id, scope, user_id, team, team_leads, kind, path, description, content)
|
|
1532
|
+
VALUES (${id}, ${orgId}, ${input.scope}, ${userId}, ${team ?? null}, ${team === undefined ? null : teamLeadsOf(team)},
|
|
1533
|
+
${input.kind}, ${input.path}, ${input.description}, ${input.content})`.pipe(Effect.orDie)
|
|
1534
|
+
return { id }
|
|
1535
|
+
}),
|
|
1536
|
+
exportResources: (input, ctx) =>
|
|
1537
|
+
Effect.gen(function* () {
|
|
1538
|
+
// The resources the caller reads in that scope (row-level security: their own personal ones, or the
|
|
1539
|
+
// organisation's), never another person's.
|
|
1540
|
+
const rows = yield* ctx.sql<PackedResource>`
|
|
1541
|
+
SELECT kind, path, description, content FROM eloxiv_agent.resource
|
|
1542
|
+
WHERE org_id = ${ctx.actor.orgId} AND scope = ${input.scope}
|
|
1543
|
+
AND (scope = 'org' OR user_id = ${ctx.actor.userId})
|
|
1544
|
+
ORDER BY kind, path`.pipe(Effect.orDie)
|
|
1545
|
+
if (rows.length > RESOURCE_PACK_MAX_RESOURCES) {
|
|
1546
|
+
return yield* new InvalidInput({
|
|
1547
|
+
message: `This scope has ${rows.length} resources; a pack holds at most ${RESOURCE_PACK_MAX_RESOURCES}`,
|
|
1548
|
+
})
|
|
1549
|
+
}
|
|
1550
|
+
// The same limit import applies: a pack exported here can always be imported back.
|
|
1551
|
+
const resources = rows.map((r) => ({
|
|
1552
|
+
kind: r.kind,
|
|
1553
|
+
path: r.path,
|
|
1554
|
+
description: r.description,
|
|
1555
|
+
content: r.content,
|
|
1556
|
+
}))
|
|
1557
|
+
const bytes = resourcePackBytes(resources)
|
|
1558
|
+
if (bytes > RESOURCE_PACK_MAX_BYTES) {
|
|
1559
|
+
return yield* new InvalidInput({
|
|
1560
|
+
message: `This scope's resources come to ${bytes} bytes; a pack holds at most ${RESOURCE_PACK_MAX_BYTES}`,
|
|
1561
|
+
})
|
|
1562
|
+
}
|
|
1563
|
+
const [now] = yield* ctx.sql<{ at: Date }>`SELECT now() AS at`.pipe(Effect.orDie)
|
|
1564
|
+
return {
|
|
1565
|
+
format: RESOURCE_PACK_FORMAT,
|
|
1566
|
+
version: RESOURCE_PACK_VERSION,
|
|
1567
|
+
source: { scope: input.scope, kernelVersion: KERNEL_VERSION, exportedAt: new Date(now!.at).toISOString() },
|
|
1568
|
+
resources,
|
|
1569
|
+
}
|
|
1570
|
+
}),
|
|
1571
|
+
importResources: (input, ctx) =>
|
|
1572
|
+
Effect.gen(function* () {
|
|
1573
|
+
const { orgId, userId } = ctx.actor
|
|
1574
|
+
yield* lockScope(ctx, input.scope)
|
|
1575
|
+
const resources = input.pack.resources
|
|
1576
|
+
const seen = new Set<string>()
|
|
1577
|
+
for (const r of resources) {
|
|
1578
|
+
const key = `${r.kind}:${r.path}`
|
|
1579
|
+
if (seen.has(key)) return yield* new InvalidInput({ message: `The pack has ${key} twice` })
|
|
1580
|
+
seen.add(key)
|
|
1581
|
+
}
|
|
1582
|
+
if (resourcePackBytes(resources) > RESOURCE_PACK_MAX_BYTES) {
|
|
1583
|
+
return yield* new InvalidInput({
|
|
1584
|
+
message: `The pack's resources come to more than ${RESOURCE_PACK_MAX_BYTES} bytes`,
|
|
1585
|
+
})
|
|
1586
|
+
}
|
|
1587
|
+
type Row = { id: string; kind: string; path: string; description: string; content: string }
|
|
1588
|
+
const existing = yield* (
|
|
1589
|
+
input.scope === "personal"
|
|
1590
|
+
? ctx.sql<Row>`SELECT id, kind, path, description, content FROM eloxiv_agent.resource
|
|
1591
|
+
WHERE org_id = ${orgId} AND scope = 'personal' AND user_id = ${userId} FOR UPDATE`
|
|
1592
|
+
: ctx.sql<Row>`SELECT id, kind, path, description, content FROM eloxiv_agent.resource
|
|
1593
|
+
WHERE org_id = ${orgId} AND scope = 'org' FOR UPDATE`
|
|
1594
|
+
).pipe(Effect.orDie)
|
|
1595
|
+
const byKey = new Map(existing.map((r) => [`${r.kind}:${r.path}`, r]))
|
|
1596
|
+
const onConflict = input.onConflict ?? "fail"
|
|
1597
|
+
const differs = (r: PackedResource, found: Row) =>
|
|
1598
|
+
found.content !== r.content || found.description !== r.description
|
|
1599
|
+
const conflicts = resources.filter((r) => {
|
|
1600
|
+
const found = byKey.get(`${r.kind}:${r.path}`)
|
|
1601
|
+
return found !== undefined && differs(r, found)
|
|
1602
|
+
})
|
|
1603
|
+
if (conflicts.length > 0 && onConflict === "fail") {
|
|
1604
|
+
const named = conflicts.slice(0, 20).map((r) => `${r.kind}:${r.path}`)
|
|
1605
|
+
return yield* new InvalidInput({
|
|
1606
|
+
message: `Already in this scope with other content: ${named.join(", ")}${conflicts.length > 20 ? ", ..." : ""}; import with onConflict skip or replace`,
|
|
1607
|
+
})
|
|
1608
|
+
}
|
|
1609
|
+
type Entry = { readonly kind: PackedResource["kind"]; readonly path: string }
|
|
1610
|
+
const created: Array<Entry> = []
|
|
1611
|
+
const replaced: Array<Entry> = []
|
|
1612
|
+
const unchanged: Array<Entry> = []
|
|
1613
|
+
const skipped: Array<Entry> = []
|
|
1614
|
+
const refused = new Forbidden({ action: importResources.name, message: "You may not write this scope" })
|
|
1615
|
+
for (const r of resources) {
|
|
1616
|
+
const entry = { kind: r.kind, path: r.path }
|
|
1617
|
+
const found = byKey.get(`${r.kind}:${r.path}`)
|
|
1618
|
+
if (found === undefined) {
|
|
1619
|
+
// Row-level security checks the scope: only administrators insert organisation resources.
|
|
1620
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.resource (id, org_id, scope, user_id, kind, path, description, content)
|
|
1621
|
+
VALUES (${crypto.randomUUID()}, ${orgId}, ${input.scope}, ${userId}, ${r.kind}, ${r.path},
|
|
1622
|
+
${r.description}, ${r.content})`.pipe(
|
|
1623
|
+
Effect.catchTag("SqlError", (e) =>
|
|
1624
|
+
// Row-level security refusing the scope is a refusal; anything else the database will not store
|
|
1625
|
+
// (a NUL character in text) is the pack's. Either way the whole import rolls back.
|
|
1626
|
+
Effect.fail(
|
|
1627
|
+
refusedByPolicy(e)
|
|
1628
|
+
? refused
|
|
1629
|
+
: new InvalidInput({ message: `The pack's ${r.kind} ${r.path} cannot be stored` }),
|
|
1630
|
+
),
|
|
1631
|
+
),
|
|
1632
|
+
)
|
|
1633
|
+
created.push(entry)
|
|
1634
|
+
} else if (!differs(r, found)) unchanged.push(entry)
|
|
1635
|
+
else if (onConflict === "skip") skipped.push(entry)
|
|
1636
|
+
else {
|
|
1637
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.resource
|
|
1638
|
+
SET description = ${r.description}, content = ${r.content}, user_id = ${userId}, updated_at = now()
|
|
1639
|
+
WHERE id = ${found.id} RETURNING id`.pipe(Effect.orDie)
|
|
1640
|
+
if (updated.length === 0) return yield* refused
|
|
1641
|
+
replaced.push(entry)
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return { created, replaced, unchanged, skipped }
|
|
1645
|
+
}),
|
|
1646
|
+
moveResources: (input, ctx) =>
|
|
1647
|
+
Effect.gen(function* () {
|
|
1648
|
+
const { orgId, userId } = ctx.actor
|
|
1649
|
+
// The organisation's resources are its administrators' (row-level security would only filter them out).
|
|
1650
|
+
if (input.scope === "org" && !ctx.actor.permissions.includes(AGENT_MANAGE)) {
|
|
1651
|
+
return yield* new Forbidden({
|
|
1652
|
+
action: moveResources.name,
|
|
1653
|
+
message: "You may not change the organisation's resources",
|
|
1654
|
+
})
|
|
1655
|
+
}
|
|
1656
|
+
yield* lockScope(ctx, input.scope)
|
|
1657
|
+
const from = input.from.replace(/\/+$/u, "")
|
|
1658
|
+
const to = input.to.replace(/\/+$/u, "")
|
|
1659
|
+
if (from === "" || to === "" || to === from || to.startsWith(`${from}/`)) {
|
|
1660
|
+
return yield* new InvalidInput({ message: "Move a folder to another path, not into itself" })
|
|
1661
|
+
}
|
|
1662
|
+
type Row = { id: string; kind: string; path: string }
|
|
1663
|
+
const rows = yield* (
|
|
1664
|
+
input.scope === "personal"
|
|
1665
|
+
? ctx.sql<Row>`SELECT id, kind, path FROM eloxiv_agent.resource
|
|
1666
|
+
WHERE org_id = ${orgId} AND scope = 'personal' AND user_id = ${userId} FOR UPDATE`
|
|
1667
|
+
: ctx.sql<Row>`SELECT id, kind, path FROM eloxiv_agent.resource
|
|
1668
|
+
WHERE org_id = ${orgId} AND scope = 'org' FOR UPDATE`
|
|
1669
|
+
).pipe(Effect.orDie)
|
|
1670
|
+
const inFolder = (path: string) => path === from || path.startsWith(`${from}/`)
|
|
1671
|
+
const moving = rows.filter((r) => inFolder(r.path))
|
|
1672
|
+
const taken = new Set(rows.filter((r) => !inFolder(r.path)).map((r) => `${r.kind}:${r.path}`))
|
|
1673
|
+
const moved = moving.map((r) => ({
|
|
1674
|
+
id: r.id,
|
|
1675
|
+
kind: r.kind,
|
|
1676
|
+
from: r.path,
|
|
1677
|
+
to: `${to}${r.path.slice(from.length)}`,
|
|
1678
|
+
}))
|
|
1679
|
+
const clash = moved.filter((m) => taken.has(`${m.kind}:${m.to}`) || m.to.length > 300)
|
|
1680
|
+
if (clash.length > 0) {
|
|
1681
|
+
return yield* new InvalidInput({
|
|
1682
|
+
message: `Already in this scope (or too long): ${clash
|
|
1683
|
+
.slice(0, 20)
|
|
1684
|
+
.map((m) => `${m.kind}:${m.to}`)
|
|
1685
|
+
.join(", ")}; nothing was moved`,
|
|
1686
|
+
})
|
|
1687
|
+
}
|
|
1688
|
+
for (const m of moved) {
|
|
1689
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.resource
|
|
1690
|
+
SET path = ${m.to}, updated_at = now() WHERE id = ${m.id} RETURNING id`.pipe(Effect.orDie)
|
|
1691
|
+
if (updated.length === 0) {
|
|
1692
|
+
return yield* new Forbidden({ action: moveResources.name, message: "You may not change this scope" })
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
return {
|
|
1696
|
+
moved: moved.map((m) => ({ kind: m.kind as typeof ResourceKind.Type, from: m.from, to: m.to })),
|
|
1697
|
+
}
|
|
1698
|
+
}),
|
|
1699
|
+
removeResources: (input, ctx) =>
|
|
1700
|
+
// The kernel locked and authorised every id (the declared targets) before this runs, and refuses the call
|
|
1701
|
+
// unless each is removed.
|
|
1702
|
+
ctx.sql<{ kind: typeof ResourceKind.Type; path: string }>`DELETE FROM eloxiv_agent.resource
|
|
1703
|
+
WHERE id = ANY(${input.ids}) RETURNING kind, path`.pipe(
|
|
1704
|
+
Effect.orDie,
|
|
1705
|
+
Effect.map((rows) => ({ removed: rows.map((r) => ({ kind: r.kind, path: r.path })) })),
|
|
1706
|
+
),
|
|
1707
|
+
removeResource: (input, ctx) =>
|
|
1708
|
+
ctx.sql`DELETE FROM eloxiv_agent.resource WHERE id = ${input.id}`.pipe(
|
|
1709
|
+
Effect.orDie,
|
|
1710
|
+
Effect.as({ id: input.id }),
|
|
1711
|
+
),
|
|
1712
|
+
directContext: (input, ctx) =>
|
|
1713
|
+
Effect.gen(function* () {
|
|
1714
|
+
const { orgId, userId } = ctx.actor
|
|
1715
|
+
const [owned] = yield* ctx.sql<{ id: string }>`SELECT id FROM eloxiv_agent.conversation
|
|
1716
|
+
WHERE id = ${input.conversationId} AND user_id = ${userId}`.pipe(Effect.orDie)
|
|
1717
|
+
if (owned === undefined)
|
|
1718
|
+
return yield* new InvalidInput({ message: `No conversation ${input.conversationId}` })
|
|
1719
|
+
const id = `${input.conversationId}:${input.ref}`
|
|
1720
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.directive
|
|
1721
|
+
SET directive = ${input.directive}, updated_at = now() WHERE id = ${id} RETURNING id`.pipe(Effect.orDie)
|
|
1722
|
+
if (updated.length === 0) {
|
|
1723
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.directive (id, org_id, user_id, conversation_id, ref, directive)
|
|
1724
|
+
VALUES (${id}, ${orgId}, ${userId}, ${input.conversationId}, ${input.ref}, ${input.directive})`.pipe(
|
|
1725
|
+
Effect.orDie,
|
|
1726
|
+
)
|
|
1727
|
+
}
|
|
1728
|
+
return { ref: input.ref, directive: input.directive }
|
|
1729
|
+
}),
|
|
1730
|
+
setBudget: (input, ctx) =>
|
|
1731
|
+
Effect.gen(function* () {
|
|
1732
|
+
yield* notAnAgentsSetting("agent.setBudget", ctx)
|
|
1733
|
+
const subject = input.scope === "org" ? "*" : (input.userId ?? "*")
|
|
1734
|
+
const id = `${ctx.actor.orgId}:${input.scope}:${subject}:${input.meter}:${input.period}`
|
|
1735
|
+
const alertAt = input.alertAt === undefined ? undefined : input.alertAt
|
|
1736
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.budget
|
|
1737
|
+
SET limit_value = ${input.limit}, updated_at = now(),
|
|
1738
|
+
alert_at = CASE WHEN ${alertAt !== undefined} THEN ${alertAt ?? null}::int ELSE alert_at END
|
|
1739
|
+
WHERE id = ${id} RETURNING id`.pipe(Effect.orDie)
|
|
1740
|
+
if (updated.length === 0) {
|
|
1741
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.budget (id, org_id, scope, user_id, meter, period, limit_value, alert_at)
|
|
1742
|
+
VALUES (${id}, ${ctx.actor.orgId}, ${input.scope}, ${subject}, ${input.meter}, ${input.period}, ${input.limit},
|
|
1743
|
+
${alertAt ?? null}::int)`.pipe(Effect.orDie)
|
|
1744
|
+
}
|
|
1745
|
+
return { id }
|
|
1746
|
+
}),
|
|
1747
|
+
configureModel: (input, ctx) =>
|
|
1748
|
+
Effect.gen(function* () {
|
|
1749
|
+
yield* notAnAgentsSetting("agent.configureModel", ctx)
|
|
1750
|
+
const id = ctx.actor.orgId
|
|
1751
|
+
const updated = yield* ctx.sql<{ id: string }>`UPDATE eloxiv_agent.model_config
|
|
1752
|
+
SET provider = ${input.provider}, model = ${input.model}, user_id = ${ctx.actor.userId}, updated_at = now()
|
|
1753
|
+
WHERE id = ${id} RETURNING id`.pipe(Effect.orDie)
|
|
1754
|
+
if (updated.length === 0) {
|
|
1755
|
+
yield* ctx.sql`INSERT INTO eloxiv_agent.model_config (id, org_id, user_id, provider, model)
|
|
1756
|
+
VALUES (${id}, ${id}, ${ctx.actor.userId}, ${input.provider}, ${input.model})`.pipe(Effect.orDie)
|
|
1757
|
+
}
|
|
1758
|
+
return { provider: input.provider, model: input.model }
|
|
1759
|
+
}),
|
|
1760
|
+
},
|
|
1761
|
+
}),
|
|
1762
|
+
)
|
|
1763
|
+
|
|
1764
|
+
/**
|
|
1765
|
+
* Actions that are a person's to call. Each declares `exposure.agent: false`, so neither the app's agent nor a browser
|
|
1766
|
+
* agent (WebMCP) lists it; those whose handler refuses every agent-originated call (MCP's included) also declare
|
|
1767
|
+
* `exposure.mcp: false`. A call by name is refused as before.
|
|
1768
|
+
*/
|
|
1769
|
+
export const PERSON_ONLY_ACTIONS: ReadonlySet<string> = new Set([
|
|
1770
|
+
send.name,
|
|
1771
|
+
cancel.name,
|
|
1772
|
+
continueTurn.name,
|
|
1773
|
+
cancelQueued.name,
|
|
1774
|
+
updateConversation.name,
|
|
1775
|
+
recordTurn.name,
|
|
1776
|
+
saveCheckpoint.name,
|
|
1777
|
+
restoreCheckpoint.name,
|
|
1778
|
+
giveFeedback.name,
|
|
1779
|
+
directContext.name,
|
|
1780
|
+
setBudget.name,
|
|
1781
|
+
configureModel.name,
|
|
1782
|
+
"consent.approve",
|
|
1783
|
+
"consent.reject",
|
|
1784
|
+
"consent.rejectPending",
|
|
1785
|
+
"consent.revoke",
|
|
1786
|
+
"consent.get",
|
|
1787
|
+
"approvals.approve",
|
|
1788
|
+
"proposals.decide",
|
|
1789
|
+
"notifications.registerInstallation",
|
|
1790
|
+
"notifications.unregisterInstallation",
|
|
1791
|
+
])
|
|
1792
|
+
|
|
1793
|
+
export type { AgentResource }
|