@db3.ai/app 0.1.0-beta.1 → 0.1.0-beta.4
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/README.md +68 -9
- package/agent-instructions.md +76 -0
- package/dist/ai/AIErrors.d.ts +7 -1
- package/dist/ai/AIErrors.js +8 -1
- package/dist/ai/AIFailover.d.ts +10 -0
- package/dist/ai/AIFailover.js +3 -2
- package/dist/ai/AIProviderAdmission.d.ts +101 -0
- package/dist/ai/AIProviderAdmission.js +336 -0
- package/dist/ai/AIRateLimiter.d.ts +11 -2
- package/dist/ai/AIRateLimiter.js +125 -10
- package/dist/ai/AIRequestTrackingError.d.ts +22 -0
- package/dist/ai/AIRequestTrackingError.js +33 -0
- package/dist/ai/Agent.d.ts +7 -7
- package/dist/ai/Agent.js +84 -56
- package/dist/ai/Ai.d.ts +11 -3
- package/dist/ai/Ai.js +94 -44
- package/dist/ai/OpenAIProviderError.js +1 -1
- package/dist/ai/ProviderSseObserver.d.ts +19 -0
- package/dist/ai/ProviderSseObserver.js +98 -0
- package/dist/ai/aiServiceTier.d.ts +5 -0
- package/dist/ai/aiServiceTier.js +14 -0
- package/dist/ai/chunkEmbeddingText.d.ts +14 -0
- package/dist/ai/chunkEmbeddingText.js +147 -0
- package/dist/ai/contracts/AI.d.ts +16 -0
- package/dist/ai/contracts/AIRequestErrorDiagnostics.d.ts +12 -0
- package/dist/ai/contracts/AIRequestErrorDiagnostics.js +1 -0
- package/dist/ai/contracts/AIServiceTier.d.ts +2 -0
- package/dist/ai/contracts/AIServiceTier.js +1 -0
- package/dist/ai/contracts/Agent.d.ts +3 -0
- package/dist/ai/contracts/EmbeddingTextChunk.d.ts +25 -0
- package/dist/ai/contracts/EmbeddingTextChunk.js +1 -0
- package/dist/ai/contracts/Pricing.d.ts +7 -1
- package/dist/ai/contracts/Providers.d.ts +2 -0
- package/dist/ai/contracts/index.d.ts +2 -0
- package/dist/ai/contracts/index.js +1 -0
- package/dist/ai/index.d.ts +8 -2
- package/dist/ai/index.js +5 -2
- package/dist/ai/{Models.d.ts → modelPricing.d.ts} +2 -2
- package/dist/ai/{Models.js → modelPricing.js} +38 -4
- package/dist/apps/AppInstallation.d.ts +21 -0
- package/dist/apps/AppInstallation.js +16 -0
- package/dist/apps/AppRouteError.d.ts +6 -0
- package/dist/apps/AppRouteError.js +10 -0
- package/dist/apps/AppService.d.ts +24 -0
- package/dist/apps/AppService.js +21 -0
- package/dist/apps/Apps.d.ts +59 -0
- package/dist/apps/Apps.js +566 -0
- package/dist/apps/appsPlugin.d.ts +3 -0
- package/dist/apps/appsPlugin.js +36 -0
- package/dist/apps/commands/disableApp.d.ts +2 -0
- package/dist/apps/commands/disableApp.js +5 -0
- package/dist/apps/commands/enableApp.d.ts +2 -0
- package/dist/apps/commands/enableApp.js +5 -0
- package/dist/apps/commands/index.d.ts +10 -0
- package/dist/apps/commands/index.js +27 -0
- package/dist/apps/commands/installApp.d.ts +2 -0
- package/dist/apps/commands/installApp.js +5 -0
- package/dist/apps/commands/listApps.d.ts +2 -0
- package/dist/apps/commands/listApps.js +5 -0
- package/dist/apps/commands/makeAppMigration.d.ts +2 -0
- package/dist/apps/commands/makeAppMigration.js +9 -0
- package/dist/apps/commands/rollbackApp.d.ts +2 -0
- package/dist/apps/commands/rollbackApp.js +5 -0
- package/dist/apps/commands/uninstallApp.d.ts +2 -0
- package/dist/apps/commands/uninstallApp.js +5 -0
- package/dist/apps/contracts/AppAction.d.ts +2 -0
- package/dist/apps/contracts/AppAction.js +1 -0
- package/dist/apps/contracts/AppDefinition.d.ts +45 -0
- package/dist/apps/contracts/AppDefinition.js +1 -0
- package/dist/apps/contracts/AppDescription.d.ts +32 -0
- package/dist/apps/contracts/AppDescription.js +1 -0
- package/dist/apps/contracts/AppManifest.d.ts +30 -0
- package/dist/apps/contracts/AppManifest.js +1 -0
- package/dist/apps/contracts/AppNavigation.d.ts +9 -0
- package/dist/apps/contracts/AppNavigation.js +1 -0
- package/dist/apps/contracts/AppNavigationBadge.d.ts +6 -0
- package/dist/apps/contracts/AppNavigationBadge.js +1 -0
- package/dist/apps/contracts/AppNavigationContext.d.ts +8 -0
- package/dist/apps/contracts/AppNavigationContext.js +1 -0
- package/dist/apps/contracts/AppNavigationResult.d.ts +12 -0
- package/dist/apps/contracts/AppNavigationResult.js +1 -0
- package/dist/apps/contracts/AppRoute.d.ts +19 -0
- package/dist/apps/contracts/AppRoute.js +1 -0
- package/dist/apps/contracts/DiscoveredApp.d.ts +10 -0
- package/dist/apps/contracts/DiscoveredApp.js +1 -0
- package/dist/apps/contracts/InstalledApps.d.ts +3 -0
- package/dist/apps/contracts/InstalledApps.js +1 -0
- package/dist/apps/contracts/index.d.ts +11 -0
- package/dist/apps/contracts/index.js +1 -0
- package/dist/apps/defineApp.d.ts +7 -0
- package/dist/apps/defineApp.js +8 -0
- package/dist/apps/discoverApps.d.ts +3 -0
- package/dist/apps/discoverApps.js +62 -0
- package/dist/apps/fastify.d.ts +1 -0
- package/dist/apps/fastify.js +1 -0
- package/dist/apps/index.d.ts +7 -0
- package/dist/apps/index.js +7 -0
- package/dist/apps/normalizeAppNavigation.d.ts +3 -0
- package/dist/apps/normalizeAppNavigation.js +30 -0
- package/dist/apps/registerAppRoutes.d.ts +6 -0
- package/dist/apps/registerAppRoutes.js +52 -0
- package/dist/apps/validateAppDefinitions.d.ts +3 -0
- package/dist/apps/validateAppDefinitions.js +65 -0
- package/dist/apps/vite.d.ts +1 -0
- package/dist/apps/vite.js +1 -0
- package/dist/apps/writeAppTypes.d.ts +2 -0
- package/dist/apps/writeAppTypes.js +13 -0
- package/dist/auth/Auth.d.ts +18 -0
- package/dist/auth/Auth.js +89 -13
- package/dist/auth/PasswordLoginAttempt.d.ts +50 -0
- package/dist/auth/PasswordLoginAttempt.js +60 -0
- package/dist/auth/PasswordSuspendedError.d.ts +10 -0
- package/dist/auth/PasswordSuspendedError.js +13 -0
- package/dist/auth/contracts/PasswordAuthProviderOptions.d.ts +26 -0
- package/dist/auth/contracts/PasswordAuthProviderOptions.js +1 -0
- package/dist/auth/contracts/PasswordSuspension.d.ts +7 -0
- package/dist/auth/contracts/PasswordSuspension.js +1 -0
- package/dist/auth/contracts/PasswordSuspensionOptions.d.ts +10 -0
- package/dist/auth/contracts/PasswordSuspensionOptions.js +1 -0
- package/dist/auth/contracts/index.d.ts +3 -0
- package/dist/auth/contracts/index.js +3 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/providers/PasswordAuthProvider.d.ts +19 -23
- package/dist/auth/providers/PasswordAuthProvider.js +96 -8
- package/dist/auth/providers/resolveAuthProviders.js +1 -0
- package/dist/cli/Cli.d.ts +2 -0
- package/dist/cli/Cli.js +8 -0
- package/dist/cli/commands/repl.js +2 -1
- package/dist/cli/contracts/CliCommand.d.ts +2 -0
- package/dist/cli/contracts/CliCommandInfo.d.ts +12 -0
- package/dist/cli/contracts/CliCommandInfo.js +1 -0
- package/dist/cli/contracts/index.d.ts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/listDb3Commands.d.ts +8 -0
- package/dist/cli/listDb3Commands.js +10 -0
- package/dist/cli/runDb3.d.ts +3 -6
- package/dist/cli/runDb3.js +5 -59
- package/dist/cli/withDb3Cli.d.ts +4 -0
- package/dist/cli/withDb3Cli.js +60 -0
- package/dist/db/ActiveQueryBuilder.d.ts +8 -0
- package/dist/db/ActiveQueryBuilder.js +11 -0
- package/dist/db/ActiveRecord.d.ts +6 -0
- package/dist/db/ActiveRecord.js +8 -0
- package/dist/db/connection.js +14 -2
- package/dist/db/fields/TimestampField.d.ts +1 -1
- package/dist/db/fields/TimestampField.js +7 -12
- package/dist/db/migrations/DatabaseMigrationManager.d.ts +3 -1
- package/dist/db/migrations/DatabaseMigrationManager.js +9 -3
- package/dist/db/migrations/contracts/DatabaseMigration.d.ts +7 -0
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +1 -1
- package/dist/db/migrations/{KnexMigrationRenderer.d.ts → renderKnexMigration.d.ts} +4 -3
- package/dist/db/migrations/{KnexMigrationRenderer.js → renderKnexMigration.js} +7 -6
- package/dist/flows/FlowCompiler.js +1 -1
- package/dist/flows/Flows.js +1 -1
- package/dist/flows/index.d.ts +1 -1
- package/dist/flows/index.js +1 -1
- package/dist/health/Health.d.ts +41 -0
- package/dist/health/Health.js +153 -0
- package/dist/health/contracts/Health.d.ts +36 -0
- package/dist/health/contracts/Health.js +1 -0
- package/dist/health/contracts/HealthHttp.d.ts +15 -0
- package/dist/health/contracts/HealthHttp.js +1 -0
- package/dist/health/contracts/index.d.ts +2 -0
- package/dist/health/contracts/index.js +1 -0
- package/dist/health/databaseHealthCheck.d.ts +15 -0
- package/dist/health/databaseHealthCheck.js +18 -0
- package/dist/health/fastify.d.ts +13 -0
- package/dist/health/fastify.js +44 -0
- package/dist/health/index.d.ts +3 -0
- package/dist/health/index.js +2 -0
- package/dist/in-app/InApp.d.ts +33 -0
- package/dist/in-app/InApp.js +191 -0
- package/dist/in-app/InAppError.d.ts +6 -0
- package/dist/in-app/InAppError.js +10 -0
- package/dist/in-app/InAppRecord.d.ts +36 -0
- package/dist/in-app/InAppRecord.js +24 -0
- package/dist/in-app/contracts/InAppInbox.d.ts +45 -0
- package/dist/in-app/contracts/InAppInbox.js +1 -0
- package/dist/in-app/contracts/InAppMessage.d.ts +22 -0
- package/dist/in-app/contracts/InAppMessage.js +1 -0
- package/dist/in-app/contracts/InAppScope.d.ts +17 -0
- package/dist/in-app/contracts/InAppScope.js +1 -0
- package/dist/in-app/contracts/index.d.ts +3 -0
- package/dist/in-app/contracts/index.js +3 -0
- package/dist/in-app/index.d.ts +4 -0
- package/dist/in-app/index.js +4 -0
- package/dist/in-app/validation.d.ts +21 -0
- package/dist/in-app/validation.js +50 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.js +2 -5
- package/dist/logging/DevelopmentConsole.d.ts +42 -0
- package/dist/logging/DevelopmentConsole.js +162 -0
- package/dist/logging/Log.d.ts +3 -1
- package/dist/logging/Log.js +5 -2
- package/dist/logging/PrettyLogFormatter.d.ts +16 -0
- package/dist/logging/PrettyLogFormatter.js +151 -0
- package/dist/logging/acquireDevelopmentConsole.d.ts +6 -0
- package/dist/logging/acquireDevelopmentConsole.js +21 -0
- package/dist/logging/contracts/DevelopmentConsoleOptions.d.ts +16 -0
- package/dist/logging/contracts/DevelopmentConsoleOptions.js +1 -0
- package/dist/logging/contracts/EmailLogOptions.d.ts +8 -0
- package/dist/logging/contracts/EmailLogOptions.js +1 -0
- package/dist/logging/contracts/HttpExchangeMonitorOptions.d.ts +12 -0
- package/dist/logging/contracts/HttpExchangeMonitorOptions.js +1 -0
- package/dist/logging/contracts/LogTransportOptions.d.ts +19 -0
- package/dist/logging/contracts/LogTransportOptions.js +1 -0
- package/dist/logging/contracts/LoggingOptions.d.ts +12 -1
- package/dist/logging/contracts/index.d.ts +4 -0
- package/dist/logging/contracts/index.js +4 -0
- package/dist/logging/drivers/PinoLoggerDriver.d.ts +3 -1
- package/dist/logging/drivers/PinoLoggerDriver.js +75 -16
- package/dist/logging/formatLogEmail.d.ts +4 -0
- package/dist/logging/formatLogEmail.js +21 -0
- package/dist/logging/highlightQueueMessage.d.ts +11 -0
- package/dist/logging/highlightQueueMessage.js +36 -0
- package/dist/logging/httpBodyCapture.d.ts +24 -0
- package/dist/logging/httpBodyCapture.js +321 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/redactLogEmail.d.ts +2 -0
- package/dist/logging/redactLogEmail.js +12 -0
- package/dist/logging/registerHttpExchangeMonitor.d.ts +10 -0
- package/dist/logging/registerHttpExchangeMonitor.js +43 -0
- package/dist/logging/transports/EmailLogTransport.d.ts +18 -0
- package/dist/logging/transports/EmailLogTransport.js +47 -0
- package/dist/mail/Mail.d.ts +2 -0
- package/dist/mail/Mail.js +3 -0
- package/dist/mail/MailDeliveryError.d.ts +9 -0
- package/dist/mail/MailDeliveryError.js +16 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.js +1 -0
- package/dist/mail/transports/MailgunTransport.js +2 -0
- package/dist/mail/transports/ResendTransport.d.ts +3 -2
- package/dist/mail/transports/ResendTransport.js +22 -14
- package/dist/media/MediaManager.d.ts +4 -2
- package/dist/media/MediaManager.js +40 -8
- package/dist/network/BlockedUrlError.d.ts +16 -0
- package/dist/network/BlockedUrlError.js +19 -0
- package/dist/network/assertPublicUrl.d.ts +22 -0
- package/dist/network/assertPublicUrl.js +67 -0
- package/dist/network/contracts/GuardedFetch.d.ts +35 -0
- package/dist/network/contracts/GuardedFetch.js +1 -0
- package/dist/network/contracts/PublicUrlOptions.d.ts +17 -0
- package/dist/network/contracts/PublicUrlOptions.js +1 -0
- package/dist/network/contracts/index.d.ts +2 -0
- package/dist/network/contracts/index.js +2 -0
- package/dist/network/guardedFetch.d.ts +29 -0
- package/dist/network/guardedFetch.js +133 -0
- package/dist/network/index.d.ts +6 -0
- package/dist/network/index.js +6 -0
- package/dist/network/playwright/GuardedBrowserProxy.d.ts +32 -0
- package/dist/network/playwright/GuardedBrowserProxy.js +172 -0
- package/dist/network/playwright/contracts/GuardedBrowserContextOptions.d.ts +37 -0
- package/dist/network/playwright/contracts/GuardedBrowserContextOptions.js +1 -0
- package/dist/network/playwright/contracts/index.d.ts +1 -0
- package/dist/network/playwright/contracts/index.js +1 -0
- package/dist/network/playwright/index.d.ts +2 -0
- package/dist/network/playwright/index.js +2 -0
- package/dist/network/playwright/newGuardedBrowserContext.d.ts +21 -0
- package/dist/network/playwright/newGuardedBrowserContext.js +86 -0
- package/dist/network/privateNetworkAddresses.d.ts +44 -0
- package/dist/network/privateNetworkAddresses.js +157 -0
- package/dist/network/publicAddressLookup.d.ts +26 -0
- package/dist/network/publicAddressLookup.js +42 -0
- package/dist/notifications/Notifications.d.ts +27 -0
- package/dist/notifications/Notifications.js +99 -0
- package/dist/notifications/contracts/Notification.d.ts +56 -0
- package/dist/notifications/contracts/Notification.js +1 -0
- package/dist/notifications/contracts/NotificationDelivery.d.ts +11 -0
- package/dist/notifications/contracts/NotificationDelivery.js +1 -0
- package/dist/notifications/contracts/index.d.ts +2 -0
- package/dist/notifications/contracts/index.js +2 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +2 -0
- package/dist/queue/JobRunAttempt.d.ts +16 -0
- package/dist/queue/JobRunAttempt.js +17 -0
- package/dist/queue/JobRunEvent.d.ts +15 -0
- package/dist/queue/JobRunEvent.js +16 -0
- package/dist/queue/JobRunStoppedError.d.ts +6 -0
- package/dist/queue/JobRunStoppedError.js +10 -0
- package/dist/queue/Queue.d.ts +19 -4
- package/dist/queue/Queue.js +122 -9
- package/dist/queue/QueueTerminalError.d.ts +9 -0
- package/dist/queue/QueueTerminalError.js +12 -0
- package/dist/queue/QueueWorker.d.ts +12 -5
- package/dist/queue/QueueWorker.js +94 -9
- package/dist/queue/QueueWorkerReporter.d.ts +17 -0
- package/dist/queue/QueueWorkerReporter.js +71 -0
- package/dist/queue/QueueableJob.d.ts +2 -2
- package/dist/queue/RunnableJob.d.ts +78 -0
- package/dist/queue/RunnableJob.js +284 -0
- package/dist/queue/console.d.ts +8 -0
- package/dist/queue/console.js +53 -19
- package/dist/queue/contracts/QueueDriver.d.ts +8 -0
- package/dist/queue/contracts/QueueJobRunner.d.ts +4 -0
- package/dist/queue/contracts/QueueJobRunner.js +1 -0
- package/dist/queue/contracts/QueuePayload.d.ts +1 -1
- package/dist/queue/contracts/QueueSelection.d.ts +11 -0
- package/dist/queue/contracts/QueueSelection.js +1 -0
- package/dist/queue/contracts/QueueService.d.ts +18 -4
- package/dist/queue/contracts/QueueWorkerLifecycle.d.ts +2 -2
- package/dist/queue/contracts/QueueWorkerSnapshot.d.ts +14 -0
- package/dist/queue/contracts/QueueWorkerSnapshot.js +1 -0
- package/dist/queue/contracts/QueueableJob.d.ts +7 -3
- package/dist/queue/contracts/QueueableJobContract.d.ts +12 -0
- package/dist/queue/contracts/QueueableJobContract.js +1 -0
- package/dist/queue/contracts/index.d.ts +4 -0
- package/dist/queue/contracts/index.js +2 -0
- package/dist/queue/drivers/DatabaseQueueDriver.d.ts +4 -0
- package/dist/queue/drivers/DatabaseQueueDriver.js +27 -3
- package/dist/queue/drivers/RedisQueueDriver.d.ts +7 -0
- package/dist/queue/drivers/RedisQueueDriver.js +37 -0
- package/dist/queue/index.d.ts +5 -0
- package/dist/queue/index.js +5 -0
- package/dist/queue/jobEnvelopeHasPrefix.d.ts +3 -0
- package/dist/queue/jobEnvelopeHasPrefix.js +4 -0
- package/dist/scheduler/ScheduledEvent.d.ts +8 -4
- package/dist/scheduler/ScheduledEvent.js +17 -3
- package/dist/scheduler/ScheduledJob.d.ts +1 -1
- package/dist/scheduler/Scheduler.d.ts +5 -0
- package/dist/scheduler/Scheduler.js +92 -28
- package/dist/scheduler/SchedulerCheckpointRecord.d.ts +16 -0
- package/dist/scheduler/SchedulerCheckpointRecord.js +53 -0
- package/dist/scheduler/SchedulerWorker.d.ts +3 -5
- package/dist/scheduler/SchedulerWorker.js +58 -14
- package/dist/scheduler/console.js +3 -1
- package/dist/scheduler/contracts/Schedule.d.ts +19 -0
- package/dist/scheduler/contracts/Schedule.js +1 -0
- package/dist/scheduler/contracts/Scheduler.d.ts +18 -6
- package/dist/scheduler/contracts/SchedulerCheckpoint.d.ts +23 -0
- package/dist/scheduler/contracts/SchedulerCheckpoint.js +1 -0
- package/dist/scheduler/contracts/SchedulerConsole.d.ts +5 -0
- package/dist/scheduler/contracts/SchedulerWorker.d.ts +6 -1
- package/dist/scheduler/contracts/index.d.ts +2 -0
- package/dist/scheduler/contracts/index.js +2 -0
- package/dist/scheduler/index.d.ts +1 -0
- package/dist/scheduler/index.js +1 -0
- package/dist/server/App.d.ts +36 -4
- package/dist/server/App.js +57 -7
- package/dist/server/contracts/HttpErrorHandlerOptions.d.ts +29 -0
- package/dist/server/contracts/HttpErrorHandlerOptions.js +1 -0
- package/dist/server/contracts/index.d.ts +1 -0
- package/dist/server/contracts/index.js +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +4 -0
- package/dist/server/publicServerErrorMessage.d.ts +11 -0
- package/dist/server/publicServerErrorMessage.js +16 -0
- package/dist/server/registerBrowserJsonFormatting.d.ts +16 -0
- package/dist/server/registerBrowserJsonFormatting.js +100 -0
- package/dist/server/registerHttpErrorHandler.d.ts +20 -0
- package/dist/server/registerHttpErrorHandler.js +93 -0
- package/dist/ssr/vite/contracts/ViteSsrOptions.d.ts +2 -0
- package/dist/ssr/vite/fastifyViteSsr.js +4 -3
- package/dist/storage/drivers/FlystorageDisk.js +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/websocket/WebSocketChannels.d.ts +18 -0
- package/dist/websocket/WebSocketChannels.js +129 -0
- package/dist/websocket/WebSocketConnection.d.ts +25 -0
- package/dist/websocket/WebSocketConnection.js +244 -0
- package/dist/websocket/WebSockets.d.ts +41 -0
- package/dist/websocket/WebSockets.js +194 -0
- package/dist/websocket/client/WebSocketClient.d.ts +21 -0
- package/dist/websocket/client/WebSocketClient.js +230 -0
- package/dist/websocket/client/index.d.ts +3 -0
- package/dist/websocket/client/index.js +1 -0
- package/dist/websocket/contracts/WebSocketChannel.d.ts +20 -0
- package/dist/websocket/contracts/WebSocketChannel.js +1 -0
- package/dist/websocket/contracts/WebSocketClient.d.ts +45 -0
- package/dist/websocket/contracts/WebSocketClient.js +1 -0
- package/dist/websocket/contracts/WebSocketEndpoint.d.ts +43 -0
- package/dist/websocket/contracts/WebSocketEndpoint.js +1 -0
- package/dist/websocket/contracts/WebSocketOptions.d.ts +48 -0
- package/dist/websocket/contracts/WebSocketOptions.js +1 -0
- package/dist/websocket/contracts/WebSocketPresence.d.ts +6 -0
- package/dist/websocket/contracts/WebSocketPresence.js +1 -0
- package/dist/websocket/contracts/WebSocketServiceOptions.d.ts +12 -0
- package/dist/websocket/contracts/WebSocketServiceOptions.js +1 -0
- package/dist/websocket/contracts/index.d.ts +6 -0
- package/dist/websocket/contracts/index.js +1 -0
- package/dist/websocket/defineChannel.d.ts +8 -0
- package/dist/websocket/defineChannel.js +13 -0
- package/dist/websocket/defineWebSocket.d.ts +14 -0
- package/dist/websocket/defineWebSocket.js +4 -0
- package/dist/websocket/fastify.d.ts +11 -0
- package/dist/websocket/fastify.js +38 -0
- package/dist/websocket/index.d.ts +5 -0
- package/dist/websocket/index.js +4 -0
- package/package.json +108 -7
- package/src/ai/AIErrors.ts +10 -0
- package/src/ai/AIFailover.ts +3 -2
- package/src/ai/AIProviderAdmission.ts +329 -0
- package/src/ai/AIRateLimiter.ts +134 -10
- package/src/ai/AIRequestTrackingError.ts +37 -0
- package/src/ai/Agent.ts +85 -71
- package/src/ai/Ai.ts +104 -48
- package/src/ai/OpenAIProviderError.ts +1 -1
- package/src/ai/ProviderSseObserver.ts +89 -0
- package/src/ai/README.md +216 -11
- package/src/ai/aiServiceTier.ts +14 -0
- package/src/ai/chunkEmbeddingText.ts +137 -0
- package/src/ai/contracts/AI.ts +17 -0
- package/src/ai/contracts/AIRequestErrorDiagnostics.ts +12 -0
- package/src/ai/contracts/AIServiceTier.ts +2 -0
- package/src/ai/contracts/Agent.ts +3 -0
- package/src/ai/contracts/EmbeddingTextChunk.ts +26 -0
- package/src/ai/contracts/Pricing.ts +7 -1
- package/src/ai/contracts/Providers.ts +2 -0
- package/src/ai/contracts/index.ts +2 -0
- package/src/ai/examples/prepareDocumentEmbeddings.ts +20 -0
- package/src/ai/index.ts +9 -2
- package/src/ai/{Models.ts → modelPricing.ts} +37 -4
- package/src/apps/AppInstallation.ts +25 -0
- package/src/apps/AppRouteError.ts +8 -0
- package/src/apps/AppService.ts +30 -0
- package/src/apps/Apps.ts +508 -0
- package/src/apps/README.md +354 -0
- package/src/apps/appsPlugin.ts +34 -0
- package/src/apps/commands/disableApp.ts +6 -0
- package/src/apps/commands/enableApp.ts +6 -0
- package/src/apps/commands/index.ts +29 -0
- package/src/apps/commands/installApp.ts +6 -0
- package/src/apps/commands/listApps.ts +6 -0
- package/src/apps/commands/makeAppMigration.ts +9 -0
- package/src/apps/commands/rollbackApp.ts +6 -0
- package/src/apps/commands/uninstallApp.ts +6 -0
- package/src/apps/contracts/AppAction.ts +2 -0
- package/src/apps/contracts/AppDefinition.ts +49 -0
- package/src/apps/contracts/AppDescription.ts +27 -0
- package/src/apps/contracts/AppManifest.ts +32 -0
- package/src/apps/contracts/AppNavigation.ts +10 -0
- package/src/apps/contracts/AppNavigationBadge.ts +6 -0
- package/src/apps/contracts/AppNavigationContext.ts +6 -0
- package/src/apps/contracts/AppNavigationResult.ts +9 -0
- package/src/apps/contracts/AppRoute.ts +18 -0
- package/src/apps/contracts/DiscoveredApp.ts +11 -0
- package/src/apps/contracts/InstalledApps.ts +2 -0
- package/src/apps/contracts/index.ts +11 -0
- package/src/apps/defineApp.ts +10 -0
- package/src/apps/discoverApps.ts +56 -0
- package/src/apps/fastify.ts +1 -0
- package/src/apps/index.ts +7 -0
- package/src/apps/normalizeAppNavigation.ts +29 -0
- package/src/apps/registerAppRoutes.ts +48 -0
- package/src/apps/validateAppDefinitions.ts +52 -0
- package/src/apps/vite.ts +1 -0
- package/src/apps/writeAppTypes.ts +14 -0
- package/src/auth/Auth.ts +89 -23
- package/src/auth/PasswordLoginAttempt.ts +72 -0
- package/src/auth/PasswordSuspendedError.ts +13 -0
- package/src/auth/README.md +94 -4
- package/src/auth/contracts/PasswordAuthProviderOptions.ts +30 -0
- package/src/auth/contracts/PasswordSuspension.ts +7 -0
- package/src/auth/contracts/PasswordSuspensionOptions.ts +10 -0
- package/src/auth/contracts/index.ts +3 -0
- package/src/auth/examples/runPasswordAuth.ts +6 -6
- package/src/auth/index.ts +2 -0
- package/src/auth/providers/PasswordAuthProvider.ts +96 -30
- package/src/auth/providers/resolveAuthProviders.ts +1 -0
- package/src/cli/Cli.ts +9 -0
- package/src/cli/README.md +19 -0
- package/src/cli/commands/repl.ts +2 -1
- package/src/cli/contracts/CliCommand.ts +2 -0
- package/src/cli/contracts/CliCommandInfo.ts +13 -0
- package/src/cli/contracts/index.ts +1 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/listDb3Commands.ts +12 -0
- package/src/cli/runDb3.ts +5 -51
- package/src/cli/withDb3Cli.ts +55 -0
- package/src/db/ActiveQueryBuilder.ts +12 -0
- package/src/db/ActiveRecord.ts +9 -0
- package/src/db/README.md +45 -1
- package/src/db/connection.ts +12 -1
- package/src/db/examples/FieldNote.ts +7 -13
- package/src/db/examples/KnowledgeNote.ts +7 -13
- package/src/db/examples/runNoteMigrations.ts +11 -11
- package/src/db/fields/TimestampField.ts +8 -17
- package/src/db/migrations/DatabaseMigrationManager.ts +12 -4
- package/src/db/migrations/contracts/DatabaseMigration.ts +9 -0
- package/src/db/migrations/index.ts +1 -1
- package/src/db/migrations/{KnexMigrationRenderer.ts → renderKnexMigration.ts} +8 -14
- package/src/flows/FlowCompiler.ts +1 -1
- package/src/flows/Flows.ts +1 -1
- package/src/flows/index.ts +1 -1
- package/src/health/Health.ts +163 -0
- package/src/health/README.md +46 -0
- package/src/health/contracts/Health.ts +47 -0
- package/src/health/contracts/HealthHttp.ts +19 -0
- package/src/health/contracts/index.ts +2 -0
- package/src/health/databaseHealthCheck.ts +21 -0
- package/src/health/fastify.ts +49 -0
- package/src/health/index.ts +3 -0
- package/src/in-app/InApp.ts +173 -0
- package/src/in-app/InAppError.ts +8 -0
- package/src/in-app/InAppRecord.ts +41 -0
- package/src/in-app/README.md +193 -0
- package/src/in-app/contracts/InAppInbox.ts +51 -0
- package/src/in-app/contracts/InAppMessage.ts +19 -0
- package/src/in-app/contracts/InAppScope.ts +12 -0
- package/src/in-app/contracts/index.ts +3 -0
- package/src/in-app/examples/sendReportReady.ts +14 -0
- package/src/in-app/index.ts +4 -0
- package/src/in-app/validation.ts +49 -0
- package/src/index.ts +2 -22
- package/src/logging/DevelopmentConsole.ts +154 -0
- package/src/logging/Log.ts +5 -2
- package/src/logging/PrettyLogFormatter.ts +165 -0
- package/src/logging/README.md +52 -109
- package/src/logging/acquireDevelopmentConsole.ts +19 -0
- package/src/logging/contracts/DevelopmentConsoleOptions.ts +13 -0
- package/src/logging/contracts/EmailLogOptions.ts +9 -0
- package/src/logging/contracts/HttpExchangeMonitorOptions.ts +13 -0
- package/src/logging/contracts/LogTransportOptions.ts +10 -0
- package/src/logging/contracts/LoggingOptions.ts +12 -1
- package/src/logging/contracts/index.ts +4 -0
- package/src/logging/development/README.md +88 -0
- package/src/logging/drivers/PinoLoggerDriver.ts +72 -20
- package/src/logging/examples/runDevelopmentLogs.ts +36 -0
- package/src/logging/formatLogEmail.ts +24 -0
- package/src/logging/highlightQueueMessage.ts +38 -0
- package/src/logging/httpBodyCapture.ts +393 -0
- package/src/logging/index.ts +2 -0
- package/src/logging/redactLogEmail.ts +12 -0
- package/src/logging/registerHttpExchangeMonitor.ts +45 -0
- package/src/logging/transports/EmailLogTransport.ts +46 -0
- package/src/mail/Mail.ts +5 -0
- package/src/mail/MailDeliveryError.ts +8 -0
- package/src/mail/README.md +11 -1
- package/src/mail/index.ts +1 -0
- package/src/mail/transports/MailgunTransport.ts +2 -0
- package/src/mail/transports/ResendTransport.ts +24 -22
- package/src/media/MediaManager.ts +31 -10
- package/src/media/README.md +4 -0
- package/src/media/examples/runPrivateFiles.ts +2 -2
- package/src/network/BlockedUrlError.ts +19 -0
- package/src/network/README.md +133 -0
- package/src/network/assertPublicUrl.ts +77 -0
- package/src/network/contracts/GuardedFetch.ts +40 -0
- package/src/network/contracts/PublicUrlOptions.ts +17 -0
- package/src/network/contracts/index.ts +2 -0
- package/src/network/examples/runGuardedFetch.ts +35 -0
- package/src/network/guardedFetch.ts +150 -0
- package/src/network/index.ts +6 -0
- package/src/network/playwright/GuardedBrowserProxy.ts +172 -0
- package/src/network/playwright/contracts/GuardedBrowserContextOptions.ts +43 -0
- package/src/network/playwright/contracts/index.ts +1 -0
- package/src/network/playwright/index.ts +2 -0
- package/src/network/playwright/newGuardedBrowserContext.ts +74 -0
- package/src/network/privateNetworkAddresses.ts +166 -0
- package/src/network/publicAddressLookup.ts +49 -0
- package/src/notifications/Notifications.ts +105 -0
- package/src/notifications/README.md +59 -0
- package/src/notifications/contracts/Notification.ts +65 -0
- package/src/notifications/contracts/NotificationDelivery.ts +11 -0
- package/src/notifications/contracts/index.ts +2 -0
- package/src/notifications/examples/ReportReadyNotification.ts +31 -0
- package/src/notifications/index.ts +2 -0
- package/src/queue/JobRunAttempt.ts +17 -0
- package/src/queue/JobRunEvent.ts +16 -0
- package/src/queue/JobRunStoppedError.ts +8 -0
- package/src/queue/Queue.ts +112 -11
- package/src/queue/QueueTerminalError.ts +12 -0
- package/src/queue/QueueWorker.ts +86 -7
- package/src/queue/QueueWorkerReporter.ts +59 -0
- package/src/queue/QueueableJob.ts +2 -2
- package/src/queue/README.md +142 -1
- package/src/queue/RunnableJob.ts +272 -0
- package/src/queue/console.ts +54 -21
- package/src/queue/contracts/QueueDriver.ts +9 -0
- package/src/queue/contracts/QueueJobRunner.ts +4 -0
- package/src/queue/contracts/QueuePayload.ts +1 -1
- package/src/queue/contracts/QueueSelection.ts +11 -0
- package/src/queue/contracts/QueueService.ts +19 -4
- package/src/queue/contracts/QueueWorkerLifecycle.ts +2 -2
- package/src/queue/contracts/QueueWorkerSnapshot.ts +15 -0
- package/src/queue/contracts/QueueableJob.ts +7 -3
- package/src/queue/contracts/QueueableJobContract.ts +13 -0
- package/src/queue/contracts/index.ts +6 -0
- package/src/queue/drivers/DatabaseQueueDriver.ts +25 -3
- package/src/queue/drivers/RedisQueueDriver.ts +36 -0
- package/src/queue/examples/runQueueSelection.ts +34 -0
- package/src/queue/index.ts +7 -0
- package/src/queue/jobEnvelopeHasPrefix.ts +6 -0
- package/src/scheduler/README.md +50 -9
- package/src/scheduler/ScheduledEvent.ts +20 -5
- package/src/scheduler/ScheduledJob.ts +1 -1
- package/src/scheduler/Scheduler.ts +73 -27
- package/src/scheduler/SchedulerCheckpointRecord.ts +51 -0
- package/src/scheduler/SchedulerWorker.ts +54 -19
- package/src/scheduler/console.ts +3 -1
- package/src/scheduler/contracts/Schedule.ts +22 -0
- package/src/scheduler/contracts/Scheduler.ts +21 -6
- package/src/scheduler/contracts/SchedulerCheckpoint.ts +23 -0
- package/src/scheduler/contracts/SchedulerConsole.ts +5 -0
- package/src/scheduler/contracts/SchedulerWorker.ts +6 -1
- package/src/scheduler/contracts/index.ts +2 -0
- package/src/scheduler/examples/runSchedulerWindow.ts +54 -0
- package/src/scheduler/index.ts +1 -0
- package/src/server/App.ts +73 -10
- package/src/server/README.md +95 -2
- package/src/server/contracts/HttpErrorHandlerOptions.ts +29 -0
- package/src/server/contracts/index.ts +1 -0
- package/src/server/examples/createFirstServer.ts +5 -3
- package/src/server/index.ts +4 -0
- package/src/server/publicServerErrorMessage.ts +17 -0
- package/src/server/registerBrowserJsonFormatting.ts +94 -0
- package/src/server/registerHttpErrorHandler.ts +96 -0
- package/src/ssr/README.md +6 -0
- package/src/ssr/vite/contracts/ViteSsrOptions.ts +2 -0
- package/src/ssr/vite/fastifyViteSsr.ts +4 -3
- package/src/storage/drivers/FlystorageDisk.ts +2 -2
- package/src/storage/index.ts +2 -2
- package/src/websocket/README.md +458 -0
- package/src/websocket/WebSocketChannels.ts +99 -0
- package/src/websocket/WebSocketConnection.ts +162 -0
- package/src/websocket/WebSockets.ts +157 -0
- package/src/websocket/client/WebSocketClient.ts +188 -0
- package/src/websocket/client/index.ts +3 -0
- package/src/websocket/contracts/WebSocketChannel.ts +23 -0
- package/src/websocket/contracts/WebSocketClient.ts +48 -0
- package/src/websocket/contracts/WebSocketEndpoint.ts +46 -0
- package/src/websocket/contracts/WebSocketOptions.ts +50 -0
- package/src/websocket/contracts/WebSocketPresence.ts +6 -0
- package/src/websocket/contracts/WebSocketServiceOptions.ts +12 -0
- package/src/websocket/contracts/index.ts +6 -0
- package/src/websocket/defineChannel.ts +14 -0
- package/src/websocket/defineWebSocket.ts +15 -0
- package/src/websocket/examples/board/LiveBoard.ts +97 -0
- package/src/websocket/examples/board/SummarizeBoardJob.ts +52 -0
- package/src/websocket/examples/board/boardSnapshot.ts +16 -0
- package/src/websocket/examples/board/createBoardClient.ts +43 -0
- package/src/websocket/examples/board/createBoardStore.ts +58 -0
- package/src/websocket/examples/board/registerBoardRoutes.ts +31 -0
- package/src/websocket/examples/createChannelSync.ts +66 -0
- package/src/websocket/examples/deploymentEndpoint.ts +13 -0
- package/src/websocket/examples/deploymentSnapshot.ts +36 -0
- package/src/websocket/examples/resourceChannels.ts +18 -0
- package/src/websocket/examples/userEndpoint.ts +27 -0
- package/src/websocket/fastify.ts +39 -0
- package/src/websocket/index.ts +5 -0
- package/templates/AGENTS.md +33 -2
- /package/dist/flows/{FlowValueValidator.d.ts → flowValueValidator.d.ts} +0 -0
- /package/dist/flows/{FlowValueValidator.js → flowValueValidator.js} +0 -0
- /package/dist/storage/{mime.d.ts → mimeTypeFromPath.d.ts} +0 -0
- /package/dist/storage/{mime.js → mimeTypeFromPath.js} +0 -0
- /package/dist/storage/{contents.d.ts → storageContentsToBuffer.d.ts} +0 -0
- /package/dist/storage/{contents.js → storageContentsToBuffer.js} +0 -0
- /package/src/flows/{FlowValueValidator.ts → flowValueValidator.ts} +0 -0
- /package/src/storage/{mime.ts → mimeTypeFromPath.ts} +0 -0
- /package/src/storage/{contents.ts → storageContentsToBuffer.ts} +0 -0
package/README.md
CHANGED
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Shared backend framework package for DB3 applications.
|
|
4
4
|
|
|
5
|
-
The framework is intended to support both code-first and visual application
|
|
6
|
-
development. Framework operations should expose reusable contracts so CLI,
|
|
7
|
-
GUI, programmatic, and collaborative AI clients can share the same behavior
|
|
8
|
-
rather than creating parallel implementations. Source-repository contributors
|
|
9
|
-
can read the product direction in `docs/framework-goals.md`; that repository-only
|
|
10
|
-
document is not part of the installed runtime package.
|
|
11
|
-
|
|
12
5
|
This package owns reusable runtime services and data-layer mechanics:
|
|
13
6
|
|
|
7
|
+
- `apps`: local feature apps, optional public services, owned migrations, lifecycle and inspectable navigation metadata. See [Apps](src/apps/README.md) for local folders and npm extraction.
|
|
8
|
+
|
|
14
9
|
- `config`: explicit config repositories and environment parsing helpers.
|
|
15
10
|
- `cli`: shared `db3` commands, interactive app REPL, service registration, help and app lifecycle.
|
|
16
11
|
- `cache`: named cache stores and driver-backed value lifecycles.
|
|
17
12
|
- `events`: synchronous and asynchronous in-process event dispatch.
|
|
13
|
+
- `health`: extensible application and component checks with a Fastify `/health` adapter.
|
|
14
|
+
- `websocket`: public/authenticated JSON endpoint actions, server-owned local channels, presence and a small browser client; see [WebSocket setup](./src/websocket/README.md).
|
|
18
15
|
- `logging`: structured application logging and development-tool delivery.
|
|
19
16
|
- `server`: `App`, service discovery, request context, and database wiring.
|
|
20
17
|
- `db`: ActiveRecord, FieldType, projections, schema installation, and SQL error helpers.
|
|
@@ -26,8 +23,11 @@ This package owns reusable runtime services and data-layer mechanics:
|
|
|
26
23
|
- `scheduler`: code-owned daily schedules, durable occurrence claims, queue correlation, and a dedicated worker.
|
|
27
24
|
- `flows`: code-backed graph definitions, queue orchestration, durable block observability, nested flows, and replay.
|
|
28
25
|
- `mail`: file, Mailgun, and Resend mail transports.
|
|
26
|
+
- `in-app`: durable recipient inboxes, scoped access, deduplication and independent read/dismiss/archive state.
|
|
27
|
+
- `notifications`: recipient-aware `via()`, `toInApp()` and `toMail()` definitions coordinated through framework delivery services.
|
|
29
28
|
- `storage`: named local and S3-compatible disks, streams, transfers and scoped file operations.
|
|
30
29
|
- `media`: scoped media libraries, managed file ULIDs, and browser-visible folder trees.
|
|
30
|
+
- `network`: outbound request guards that keep user-supplied URLs, redirects and headless-browser traffic off private networks; see [Network](./src/network/README.md).
|
|
31
31
|
- `security`: central key configuration and versioned authenticated encryption for application secrets.
|
|
32
32
|
- `ssr`: optional render contracts, document assembly, safe hydration state, and Fastify adaptation for public HTML.
|
|
33
33
|
- `url`: canonical base-URL configuration and standard URL resolution, without a named-route registry.
|
|
@@ -53,7 +53,7 @@ in `github.com/db3ai/framework`. The published packages are `@db3.ai/app`,
|
|
|
53
53
|
`@db3.ai/pure` and `@db3.ai/create`. Maintainers can publish a verified beta from
|
|
54
54
|
the repository root with `npm run framework:publish -- --version 0.1.0-beta.1`;
|
|
55
55
|
add `--dry-run` to inspect it without publishing. npm handles packaging, login
|
|
56
|
-
and upload. See `
|
|
56
|
+
and upload. See `packages/app/RELEASING.md` for release checks and the manual
|
|
57
57
|
bootstrap and trusted-publishing workflows.
|
|
58
58
|
|
|
59
59
|
The [installation guide](https://db3.ai/docs/installation) distinguishes the
|
|
@@ -107,14 +107,57 @@ Only canonical public GitHub URLs are accepted. In this explicit release mode,
|
|
|
107
107
|
the staged manifests include package-directory repository metadata and enable
|
|
108
108
|
`publishConfig.provenance`; neither command publishes a package.
|
|
109
109
|
|
|
110
|
+
## AI application guidance
|
|
111
|
+
|
|
112
|
+
Generated DB3 applications include a root `AGENTS.md` that tells AI coding
|
|
113
|
+
tools to resolve the installed framework instructions, use public package
|
|
114
|
+
exports, preserve application/framework ownership, and follow the framework's
|
|
115
|
+
file-naming conventions. In particular, class-owning TypeScript files and Vue
|
|
116
|
+
components use PascalCase and match their primary concept.
|
|
117
|
+
|
|
118
|
+
Existing applications can add the marked framework block without replacing
|
|
119
|
+
their product-specific instructions:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npx db3-agents --target AGENTS.md
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Refresh only that framework-owned block after upgrading `@db3.ai/app`:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
npx db3-agents --target AGENTS.md --update
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The scaffold directs AI tools to the installed
|
|
132
|
+
`@db3.ai/app/agent-instructions` export. Those installed instructions are the
|
|
133
|
+
consumer-facing source of truth for application layout, boundaries, naming,
|
|
134
|
+
and verification.
|
|
135
|
+
|
|
110
136
|
## Testing
|
|
111
137
|
|
|
138
|
+
In the source workspace, `npm test --workspace @db3.ai/app -- <optional test paths>`
|
|
139
|
+
runs the selected behaviour tests, then source/example type checks and available
|
|
140
|
+
workspace naming checks. All stages run after ordinary failures and a combined
|
|
141
|
+
summary reports the final result and the convention findings path.
|
|
142
|
+
The ordinary runner reuses Node's compiled dependencies, and Vitest persists
|
|
143
|
+
source transformations under the workspace's ignored `node_modules` directory.
|
|
144
|
+
Transformation directories are separate for each workspace and npm lockfile
|
|
145
|
+
snapshot, so a dependency update cannot clear another active run's cache.
|
|
146
|
+
Test files still run in separate runtimes and integration tests still own
|
|
147
|
+
disposable databases. Source, test configuration and dependency changes invalidate
|
|
148
|
+
the transformation cache. Coverage arguments disable the Node bytecode cache to
|
|
149
|
+
preserve V8's source-position accuracy. Set `NODE_DISABLE_COMPILE_CACHE=1` to
|
|
150
|
+
opt out; `--experimental.fsModuleCache=false` disables transformation caching.
|
|
151
|
+
`npm run quality --workspace @db3.ai/app` runs the same quality stages without
|
|
152
|
+
tests. The Platform naming gate is not included in the public source export;
|
|
153
|
+
the runner explicitly reports its absence there. The specialised service and
|
|
154
|
+
coverage commands below remain available for iteration and release workflows.
|
|
155
|
+
|
|
112
156
|
Framework tests live with the service they exercise under
|
|
113
157
|
`src/{service}/tests`. Run the complete package suite before considering a
|
|
114
158
|
framework change finished:
|
|
115
159
|
|
|
116
160
|
```sh
|
|
117
|
-
npm run check --workspace packages/app
|
|
118
161
|
npm test --workspace packages/app
|
|
119
162
|
```
|
|
120
163
|
|
|
@@ -239,3 +282,19 @@ at least one usable login method.
|
|
|
239
282
|
See [src/auth/README.md](./src/auth/README.md) for the account/provider mental
|
|
240
283
|
model, route and session examples, provider management, custom drivers, security
|
|
241
284
|
responsibilities, and complete password and Google setup instructions.
|
|
285
|
+
|
|
286
|
+
See [src/in-app/README.md](./src/in-app/README.md) for `app().inApp`, storage setup, authenticated inbox operations and the current delivery boundary.
|
|
287
|
+
|
|
288
|
+
See [src/notifications/README.md](./src/notifications/README.md) for notification classes, multi-channel sends and durable-job retry responsibilities.
|
|
289
|
+
|
|
290
|
+
## Canonical provider admission source dependency
|
|
291
|
+
|
|
292
|
+
This legacy workspace consumes the reviewed provider admission integration from
|
|
293
|
+
[`db3ai/framework@0bb30f3`](https://github.com/db3ai/framework/commit/0bb30f30ddffb5f78ae91f398ec5a9835d9fe49e).
|
|
294
|
+
`package.json.db3FrameworkSource` pins that source dependency. The integration
|
|
295
|
+
updates AI transport/admission, its option contract and terminal queue handling
|
|
296
|
+
in place; other deployed framework code and app policy remain owned by this
|
|
297
|
+
workspace until its consumer packaging migration. No sibling checkout imports
|
|
298
|
+
or npm publication are used. The canonical commit separately preserves deployed
|
|
299
|
+
bookkeeping/diagnostic fixes #77/#85 before adding admission. See the AI README
|
|
300
|
+
for policy, recovery and result retention.
|
package/agent-instructions.md
CHANGED
|
@@ -30,6 +30,36 @@ from `node_modules` into the application. If the installed declarations,
|
|
|
30
30
|
documentation and runtime disagree, treat that as a framework defect and record
|
|
31
31
|
the installed package version.
|
|
32
32
|
|
|
33
|
+
## Frontend development
|
|
34
|
+
|
|
35
|
+
Read these rules before creating or changing frontend behaviour. Existing large
|
|
36
|
+
components and starter examples are not exceptions or architectural precedent.
|
|
37
|
+
|
|
38
|
+
- Keep Vue components focused on templates, interaction wiring, accessibility and
|
|
39
|
+
styles. Keep trivial presentation state local, such as an open disclosure.
|
|
40
|
+
- Put substantial reactive state, form workflows, async orchestration and
|
|
41
|
+
lifecycle management in feature-owned `useSomething` composables, even when
|
|
42
|
+
only one component uses them. Keep composables beside the feature they own.
|
|
43
|
+
- Put calculations, normalization, validation and business decisions that do not
|
|
44
|
+
need Vue in plain TypeScript functions. Keep shared state in its owning store;
|
|
45
|
+
do not duplicate it in a composable. The server remains authoritative for
|
|
46
|
+
authorization, billing and persisted business rules.
|
|
47
|
+
- Expose a small, explicit set of reactive state and actions. Split by cohesive
|
|
48
|
+
responsibility, not an arbitrary line limit. Do not move a whole component
|
|
49
|
+
script into one oversized composable or create pass-through wrappers.
|
|
50
|
+
- Make logic independently exercisable without rendering the full page. Keep
|
|
51
|
+
network and browser side effects at explicit boundaries, preserve reactive
|
|
52
|
+
inputs, handle failures and stale responses, and clean up requests, watchers,
|
|
53
|
+
timers and subscriptions with their owning scope.
|
|
54
|
+
- Prioritize direct behavioural tests of functions, stores and composables for
|
|
55
|
+
important decisions and state transitions. Cover relevant failure, concurrency
|
|
56
|
+
and cleanup cases. Use a minimal lifecycle harness when required; retain
|
|
57
|
+
focused component tests for bindings, interactions and accessibility. Source
|
|
58
|
+
text assertions and screenshots do not establish logical correctness.
|
|
59
|
+
- For new work, identify the state and behaviour owner before building the UI.
|
|
60
|
+
For existing components, extract only the responsibilities involved in the
|
|
61
|
+
current task. Preserve behaviour and avoid unrelated refactoring.
|
|
62
|
+
|
|
33
63
|
## Application boundaries
|
|
34
64
|
|
|
35
65
|
- For new applications, use `client/` for browser code and `server/` for backend
|
|
@@ -43,12 +73,58 @@ the installed package version.
|
|
|
43
73
|
- Register service commands in `server/cli.config.ts` using the shared `db3` CLI.
|
|
44
74
|
Keep command implementations in their owning service and reuse its public operations.
|
|
45
75
|
- Keep product models, routes, jobs and policy in the consuming application.
|
|
76
|
+
- Define new models with `class ModelName extends ActiveRecord.define({ table,
|
|
77
|
+
fields: field => ({ id: field.ulid(), ... }) }) {}` imported from
|
|
78
|
+
`@db3.ai/app/db`. Put schema options in the definition and methods in the class
|
|
79
|
+
body. Do not repeat inferred fields with `declare` properties or widen the
|
|
80
|
+
factory return type. Use `field.json<Shape>()` for structured values and handle
|
|
81
|
+
inferred nullability; `required: true` is runtime validation. `create()` makes
|
|
82
|
+
an unsaved record; persist it with `save()`. Register models in the owning
|
|
83
|
+
migration registry and generate committed migrations when the schema changes.
|
|
46
84
|
- Use ActiveRecord logical field names and let fields own database mapping,
|
|
47
85
|
conversion, validation and JSON values.
|
|
48
86
|
- Resolve normal application services through the active `App` rather than
|
|
49
87
|
threading optional Knex connections through app code.
|
|
50
88
|
- Put reusable mechanics in the framework only when they are genuinely shared.
|
|
51
89
|
|
|
90
|
+
## Feature apps
|
|
91
|
+
|
|
92
|
+
For cohesive features start with apps/{id}/manifest.json and App.ts. The root
|
|
93
|
+
service extends AppService; shared/ is optional. Read src/apps/README.md before
|
|
94
|
+
changing discovery, install/uninstall, owned migrations or npm extraction. Use
|
|
95
|
+
app().social for an optional generated service type. Do not add per-app host
|
|
96
|
+
registration or mix feature models into the host snapshot. Marked npm dependencies
|
|
97
|
+
are discovered using their exported package.json. Migrations and down functions
|
|
98
|
+
belong to the app; npm lifecycle hooks must never mutate SQL. Starter ships
|
|
99
|
+
administrator controls for single-process hosts; multi-process maintenance
|
|
100
|
+
requires stopping all consumers before CLI actions.
|
|
101
|
+
|
|
102
|
+
## Application source naming
|
|
103
|
+
|
|
104
|
+
Name each file for the main concept it owns. Follow these conventions for new
|
|
105
|
+
files and files moved as part of an implementation:
|
|
106
|
+
|
|
107
|
+
- A file whose primary export is a class uses PascalCase and matches the class name exactly, for example `QueueWorker.ts`, `SendInvoiceJob.ts`, or `User.ts`.
|
|
108
|
+
- Vue component files use PascalCase, for example `AccountSettings.vue`.
|
|
109
|
+
- A file whose primary purpose is one exported public contract, interface, or type uses PascalCase and matches that concept, for example `PaymentResult.ts`.
|
|
110
|
+
- Function modules use camelCase on both server and client. When a file owns one exported function, match its name exactly: `invoiceDeliver.ts` exports `invoiceDeliver`, and `useInvoice.ts` exports `useInvoice`.
|
|
111
|
+
- Cohesive helper/utility modules and stores use camelCase names describing their purpose. Composables start with `use`.
|
|
112
|
+
- Feature directories use kebab-case. Framework-owned route parameters, route method suffixes, migrations, generated files, and required `index.ts` entry points keep the naming required by their owning system.
|
|
113
|
+
- Test filenames mirror the source concept or route they verify and end in `.test.ts`.
|
|
114
|
+
|
|
115
|
+
Keep one main concept per file. Do not copy an inconsistent neighbouring name
|
|
116
|
+
as precedent. When a task already changes or moves an inconsistent file, rename
|
|
117
|
+
it and update imports, tests, documentation, package exports, and dynamic
|
|
118
|
+
registries. Do not turn a focused task into an unrelated repository-wide rename.
|
|
119
|
+
|
|
120
|
+
Prefer behaviour on the service, model, or other domain object that owns it,
|
|
121
|
+
especially when it uses state, dependencies, or side effects. Pure functions
|
|
122
|
+
may be grouped into cohesive, purpose-named helper modules within the owning
|
|
123
|
+
service. Keep helpers local when only one implementation needs them. Avoid
|
|
124
|
+
unrelated utility buckets and one-off service classes created only to wrap a
|
|
125
|
+
function. Required route and command adapters delegate to the owning behaviour.
|
|
126
|
+
When migrating flat server/service files, establish ownership before renaming.
|
|
127
|
+
|
|
52
128
|
## AI workflows
|
|
53
129
|
|
|
54
130
|
For AI work, read `src/ai/README.md` and its examples first. Use `app().ai` and
|
package/dist/ai/AIErrors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AIRequestErrorDiagnostics } from './contracts/AIRequestErrorDiagnostics.js';
|
|
1
2
|
/**
|
|
2
3
|
* Raised when an AI operation needs provider credentials but none are configured.
|
|
3
4
|
*/
|
|
@@ -10,13 +11,18 @@ export declare class AIConfigurationError extends Error {
|
|
|
10
11
|
*/
|
|
11
12
|
export declare class AIRequestError extends Error {
|
|
12
13
|
readonly code: string | null;
|
|
14
|
+
/** HTTP response status; null when no provider response was received. */
|
|
15
|
+
readonly status: number | null;
|
|
16
|
+
/** Provider request identifier for support correlation, when supplied. */
|
|
17
|
+
readonly requestId: string | null;
|
|
13
18
|
/**
|
|
14
19
|
* Creates a provider request failure.
|
|
15
20
|
*
|
|
16
21
|
* @param message - Human-readable provider failure message.
|
|
17
22
|
* @param code - Stable provider error code, when supplied.
|
|
23
|
+
* @param diagnostics - Response status and support identifier without the payload.
|
|
18
24
|
*/
|
|
19
|
-
constructor(message?: string, code?: string | null);
|
|
25
|
+
constructor(message?: string, code?: string | null, diagnostics?: AIRequestErrorDiagnostics);
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Raised when the application allowance hook rejects an AI request.
|
package/dist/ai/AIErrors.js
CHANGED
|
@@ -13,16 +13,23 @@ export class AIConfigurationError extends Error {
|
|
|
13
13
|
*/
|
|
14
14
|
export class AIRequestError extends Error {
|
|
15
15
|
code;
|
|
16
|
+
/** HTTP response status; null when no provider response was received. */
|
|
17
|
+
status;
|
|
18
|
+
/** Provider request identifier for support correlation, when supplied. */
|
|
19
|
+
requestId;
|
|
16
20
|
/**
|
|
17
21
|
* Creates a provider request failure.
|
|
18
22
|
*
|
|
19
23
|
* @param message - Human-readable provider failure message.
|
|
20
24
|
* @param code - Stable provider error code, when supplied.
|
|
25
|
+
* @param diagnostics - Response status and support identifier without the payload.
|
|
21
26
|
*/
|
|
22
|
-
constructor(message = 'The AI provider did not return a valid response.', code = null) {
|
|
27
|
+
constructor(message = 'The AI provider did not return a valid response.', code = null, diagnostics = {}) {
|
|
23
28
|
super(message);
|
|
24
29
|
this.code = code;
|
|
25
30
|
this.name = 'AIRequestError';
|
|
31
|
+
this.status = diagnostics.status ?? null;
|
|
32
|
+
this.requestId = diagnostics.requestId ?? null;
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
/**
|
package/dist/ai/AIFailover.d.ts
CHANGED
|
@@ -23,3 +23,13 @@ export declare function isFailoverableResponse(status: number, payload: unknown)
|
|
|
23
23
|
* @returns True when the next provider in the chain should be attempted.
|
|
24
24
|
*/
|
|
25
25
|
export declare function isFailoverableFailure(error: unknown): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Detects network, DNS, and timeout failures from fetch and SDK clients.
|
|
28
|
+
*
|
|
29
|
+
* Undici wraps socket errors inside `TypeError: fetch failed` with the real
|
|
30
|
+
* failure on `cause`, so the check walks the cause chain.
|
|
31
|
+
*
|
|
32
|
+
* @param error - Unknown thrown value.
|
|
33
|
+
* @returns True when the failure happened before a provider response arrived.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isNetworkFailure(error: unknown, depth?: number): boolean;
|
package/dist/ai/AIFailover.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AIProviderDeferredError, AIProviderStoppedError } from './AIProviderAdmission.js';
|
|
1
2
|
import { AIRateLimitDeferredError } from './AIRateLimiter.js';
|
|
2
3
|
import { openAIProviderError, isOpenAIQuotaError } from './OpenAIProviderError.js';
|
|
3
4
|
const FAILOVERABLE_STATUS_CODES = new Set([408, 409, 429]);
|
|
@@ -62,7 +63,7 @@ export function isFailoverableResponse(status, payload) {
|
|
|
62
63
|
* @returns True when the next provider in the chain should be attempted.
|
|
63
64
|
*/
|
|
64
65
|
export function isFailoverableFailure(error) {
|
|
65
|
-
if (error instanceof AIRateLimitDeferredError)
|
|
66
|
+
if (error instanceof AIRateLimitDeferredError || error instanceof AIProviderDeferredError || error instanceof AIProviderStoppedError)
|
|
66
67
|
return true;
|
|
67
68
|
if (isNetworkFailure(error))
|
|
68
69
|
return true;
|
|
@@ -82,7 +83,7 @@ export function isFailoverableFailure(error) {
|
|
|
82
83
|
* @param error - Unknown thrown value.
|
|
83
84
|
* @returns True when the failure happened before a provider response arrived.
|
|
84
85
|
*/
|
|
85
|
-
function isNetworkFailure(error, depth = 0) {
|
|
86
|
+
export function isNetworkFailure(error, depth = 0) {
|
|
86
87
|
if ((!(error instanceof Error) && !(error instanceof DOMException)) || depth > 4)
|
|
87
88
|
return false;
|
|
88
89
|
if (NETWORK_ERROR_NAMES.has(error.name))
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { QueueTerminalError, QueueRetryLaterError } from '@db3.ai/app/queue';
|
|
2
|
+
import type { AIProviderAttempt } from './contracts/Providers.js';
|
|
3
|
+
/** Account outage policy, independent of model capacity and application billing. */
|
|
4
|
+
export interface AIProviderAdmissionOptions {
|
|
5
|
+
/** First transient cooldown; defaults to 30 seconds. */
|
|
6
|
+
initialSeconds?: number;
|
|
7
|
+
/** Maximum transient cooldown; defaults to five minutes. */
|
|
8
|
+
maxSeconds?: number;
|
|
9
|
+
/** Continuous failure episode deadline; defaults to fifteen minutes. */
|
|
10
|
+
failureWindowSeconds?: number;
|
|
11
|
+
/** Recovery ownership lifetime; must exceed the request timeout. Defaults to 90 seconds. */
|
|
12
|
+
recoveryLeaseSeconds?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Token fences a recovery completion against newer failures and expired leases. */
|
|
15
|
+
export interface AIProviderAdmissionLease {
|
|
16
|
+
bucketKey: string;
|
|
17
|
+
generation: string | null;
|
|
18
|
+
probe: string | null;
|
|
19
|
+
}
|
|
20
|
+
/** Queue backpressure that releases the job's reservation without spending a try. */
|
|
21
|
+
export declare class AIProviderDeferredError extends QueueRetryLaterError {
|
|
22
|
+
readonly retryAt: Date;
|
|
23
|
+
readonly retryUntil: Date;
|
|
24
|
+
/** True only for the request that observed the provider failure. */
|
|
25
|
+
providerStarted: boolean;
|
|
26
|
+
/** Recognized rejection diagnostics for the observing request; absent for blocked work. */
|
|
27
|
+
readonly providerCode: string | null;
|
|
28
|
+
readonly diagnostics: {
|
|
29
|
+
status: number | null;
|
|
30
|
+
requestId: string | null;
|
|
31
|
+
};
|
|
32
|
+
/** Creates an account cooldown without retaining provider payloads. */
|
|
33
|
+
constructor(retryAt: Date, retryUntil: Date, providerCode?: string | null, diagnostics?: {
|
|
34
|
+
status?: number | null;
|
|
35
|
+
requestId?: string | null;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Terminal admission failure; exhausted accounts require explicit operator recovery. */
|
|
39
|
+
export declare class AIProviderStoppedError extends QueueTerminalError {
|
|
40
|
+
readonly reason: 'quota' | 'outage';
|
|
41
|
+
/** Stable admission code; original provider code stays separate. */
|
|
42
|
+
readonly code = "ai_provider_stopped";
|
|
43
|
+
/** Recognized original rejection code; never an arbitrary provider message. */
|
|
44
|
+
readonly providerCode: string | null;
|
|
45
|
+
/** Actual rejection status and provider support identifier; absent for blocked work. */
|
|
46
|
+
readonly status: number | null;
|
|
47
|
+
readonly requestId: string | null;
|
|
48
|
+
/** Distinguishes account admission expiry from an individual run stopped to prevent replay. */
|
|
49
|
+
readonly stopStage: 'quota' | 'deadline' | 'stream-output';
|
|
50
|
+
/** True only for the request that observed the provider failure. */
|
|
51
|
+
providerStarted: boolean;
|
|
52
|
+
/** Creates a terminal failure without provider credentials or raw error messages. */
|
|
53
|
+
constructor(reason: 'quota' | 'outage', providerCode?: string | null, diagnostics?: {
|
|
54
|
+
status?: number | null;
|
|
55
|
+
requestId?: string | null;
|
|
56
|
+
stopStage?: 'stream-output';
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Coordinates account-wide outages using existing SQL bucket metadata.
|
|
61
|
+
* Closed accounts admit normally. Failed accounts admit one leased real request
|
|
62
|
+
* after cooldown. Exhaustion and expired episodes remain stopped across restarts;
|
|
63
|
+
* reset() is an explicit operator action and never executes or replays work.
|
|
64
|
+
*/
|
|
65
|
+
export declare class AIProviderAdmission {
|
|
66
|
+
#private;
|
|
67
|
+
/** Validates bounded outage policy; invalid values fail at boot. */
|
|
68
|
+
constructor(options?: AIProviderAdmissionOptions);
|
|
69
|
+
/**
|
|
70
|
+
* Admits normal work or exclusively leases a recovery request under a SQL lock.
|
|
71
|
+
* Account identity includes provider, origin and a one-way credential digest,
|
|
72
|
+
* never endpoint/model or website. Other accounts remain independent.
|
|
73
|
+
*/
|
|
74
|
+
acquire(attempt: AIProviderAttempt, now?: number, requestTimeoutMs?: number): Promise<AIProviderAdmissionLease>;
|
|
75
|
+
/**
|
|
76
|
+
* Records an actual provider failure before releasing external admission.
|
|
77
|
+
* Ordinary 429 capacity never trips an account outage. Late failures extend
|
|
78
|
+
* the same deadline; they cannot reopen quota or start a fresh episode.
|
|
79
|
+
*/
|
|
80
|
+
failure(attempt: AIProviderAttempt, lease: AIProviderAdmissionLease, error: unknown, now?: number): Promise<Error | null>;
|
|
81
|
+
/** Clears an episode only for its still-owned recovery request before deadline. */
|
|
82
|
+
success(attempt: AIProviderAttempt, lease: AIProviderAdmissionLease, now?: number): Promise<void>;
|
|
83
|
+
/** Explicit operator reset after repair; does not dispatch, probe or replay jobs. */
|
|
84
|
+
reset(attempt: AIProviderAttempt): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Wraps each real HTTP request, including SDK model turns and nested tools.
|
|
87
|
+
* JSON failures and streaming failures trip the same account state. Recovery
|
|
88
|
+
* is cleared only after body consumption, so header arrival is not recovery.
|
|
89
|
+
*/
|
|
90
|
+
transport(attempt: AIProviderAttempt, fetcher: typeof fetch, requestTimeoutMs?: number): typeof fetch;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the shared cooldown for a safe SDK retry of the current model request.
|
|
93
|
+
* The SDK vetoes emitted output and cancellation before consulting its policy.
|
|
94
|
+
* Retains the typed failure until transport actually starts the next attempt,
|
|
95
|
+
* because its stateful-request veto runs after policy evaluation. Every new
|
|
96
|
+
* attempt reacquires admission; terminal and cancellation decisions take priority.
|
|
97
|
+
*/
|
|
98
|
+
requestRetryDelay(attempt: AIProviderAttempt, fallback: unknown, now?: number): number | null;
|
|
99
|
+
/** Restores a typed HTTP/SSE admission failure after the SDK consumes its original event. */
|
|
100
|
+
requestFailure(attempt: AIProviderAttempt, fallback: unknown): unknown;
|
|
101
|
+
}
|