libre-webui 0.21.3 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +308 -328
- package/backend/dist/cli/migrateSqliteToPostgres.d.ts +2 -0
- package/backend/dist/cli/migrateSqliteToPostgres.d.ts.map +1 -0
- package/backend/dist/cli/migrateSqliteToPostgres.js +113 -0
- package/backend/dist/cli/migrateSqliteToPostgres.js.map +1 -0
- package/backend/dist/cli/recoveryBackup.d.ts +3 -0
- package/backend/dist/cli/recoveryBackup.d.ts.map +1 -0
- package/backend/dist/cli/recoveryBackup.js +251 -0
- package/backend/dist/cli/recoveryBackup.js.map +1 -0
- package/backend/dist/cli/recoveryInventory.d.ts +2 -0
- package/backend/dist/cli/recoveryInventory.d.ts.map +1 -0
- package/backend/dist/cli/recoveryInventory.js +109 -0
- package/backend/dist/cli/recoveryInventory.js.map +1 -0
- package/backend/dist/db.d.ts +27 -0
- package/backend/dist/db.d.ts.map +1 -1
- package/backend/dist/db.js +333 -16
- package/backend/dist/db.js.map +1 -1
- package/backend/dist/env.d.ts.map +1 -1
- package/backend/dist/env.js +12 -2
- package/backend/dist/env.js.map +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +235 -47
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/main.d.ts +2 -0
- package/backend/dist/main.d.ts.map +1 -0
- package/backend/dist/main.js +137 -0
- package/backend/dist/main.js.map +1 -0
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/auth.js +7 -3
- package/backend/dist/middleware/auth.js.map +1 -1
- package/backend/dist/middleware/chatCancellationAdmission.d.ts +7 -0
- package/backend/dist/middleware/chatCancellationAdmission.d.ts.map +1 -0
- package/backend/dist/middleware/chatCancellationAdmission.js +17 -0
- package/backend/dist/middleware/chatCancellationAdmission.js.map +1 -0
- package/backend/dist/middleware/coordinatedRateLimit.d.ts +18 -0
- package/backend/dist/middleware/coordinatedRateLimit.d.ts.map +1 -0
- package/backend/dist/middleware/coordinatedRateLimit.js +52 -0
- package/backend/dist/middleware/coordinatedRateLimit.js.map +1 -0
- package/backend/dist/middleware/sharedRateLimit.d.ts +26 -0
- package/backend/dist/middleware/sharedRateLimit.d.ts.map +1 -0
- package/backend/dist/middleware/sharedRateLimit.js +99 -0
- package/backend/dist/middleware/sharedRateLimit.js.map +1 -0
- package/backend/dist/models/personaModel.d.ts +1 -26
- package/backend/dist/models/personaModel.d.ts.map +1 -1
- package/backend/dist/models/personaModel.js +54 -247
- package/backend/dist/models/personaModel.js.map +1 -1
- package/backend/dist/models/userModel.d.ts +23 -66
- package/backend/dist/models/userModel.d.ts.map +1 -1
- package/backend/dist/models/userModel.js +110 -187
- package/backend/dist/models/userModel.js.map +1 -1
- package/backend/dist/persistence/chatGenerationTypes.d.ts +24 -0
- package/backend/dist/persistence/chatGenerationTypes.d.ts.map +1 -0
- package/backend/dist/persistence/chatGenerationTypes.js +7 -0
- package/backend/dist/persistence/chatGenerationTypes.js.map +1 -0
- package/backend/dist/persistence/extensionTypes.d.ts +185 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -0
- package/backend/dist/persistence/extensionTypes.js +13 -0
- package/backend/dist/persistence/extensionTypes.js.map +1 -0
- package/backend/dist/persistence/identityDeletionTypes.d.ts +16 -0
- package/backend/dist/persistence/identityDeletionTypes.d.ts.map +1 -0
- package/backend/dist/persistence/identityDeletionTypes.js +7 -0
- package/backend/dist/persistence/identityDeletionTypes.js.map +1 -0
- package/backend/dist/persistence/index.d.ts +48 -0
- package/backend/dist/persistence/index.d.ts.map +1 -0
- package/backend/dist/persistence/index.js +159 -0
- package/backend/dist/persistence/index.js.map +1 -0
- package/backend/dist/persistence/postgresConfig.d.ts +32 -0
- package/backend/dist/persistence/postgresConfig.d.ts.map +1 -0
- package/backend/dist/persistence/postgresConfig.js +91 -0
- package/backend/dist/persistence/postgresConfig.js.map +1 -0
- package/backend/dist/persistence/postgresCoreMigration.d.ts +8 -0
- package/backend/dist/persistence/postgresCoreMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresCoreMigration.js +179 -0
- package/backend/dist/persistence/postgresCoreMigration.js.map +1 -0
- package/backend/dist/persistence/postgresDatabase.d.ts +40 -0
- package/backend/dist/persistence/postgresDatabase.d.ts.map +1 -0
- package/backend/dist/persistence/postgresDatabase.js +148 -0
- package/backend/dist/persistence/postgresDatabase.js.map +1 -0
- package/backend/dist/persistence/postgresExtensionMigration.d.ts +4 -0
- package/backend/dist/persistence/postgresExtensionMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresExtensionMigration.js +143 -0
- package/backend/dist/persistence/postgresExtensionMigration.js.map +1 -0
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts +6 -0
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -0
- package/backend/dist/persistence/postgresExtensionRepositories.js +550 -0
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -0
- package/backend/dist/persistence/postgresImportState.d.ts +9 -0
- package/backend/dist/persistence/postgresImportState.d.ts.map +1 -0
- package/backend/dist/persistence/postgresImportState.js +64 -0
- package/backend/dist/persistence/postgresImportState.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts +4 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js +33 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationTypes.d.ts +24 -0
- package/backend/dist/persistence/postgresMigrationTypes.d.ts.map +1 -0
- package/backend/dist/persistence/postgresMigrationTypes.js +7 -0
- package/backend/dist/persistence/postgresMigrationTypes.js.map +1 -0
- package/backend/dist/persistence/postgresMigrations.d.ts +15 -0
- package/backend/dist/persistence/postgresMigrations.d.ts.map +1 -0
- package/backend/dist/persistence/postgresMigrations.js +333 -0
- package/backend/dist/persistence/postgresMigrations.js.map +1 -0
- package/backend/dist/persistence/postgresPersistence.d.ts +17 -0
- package/backend/dist/persistence/postgresPersistence.d.ts.map +1 -0
- package/backend/dist/persistence/postgresPersistence.js +332 -0
- package/backend/dist/persistence/postgresPersistence.js.map +1 -0
- package/backend/dist/persistence/postgresPluginDefinitionMigration.d.ts +4 -0
- package/backend/dist/persistence/postgresPluginDefinitionMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresPluginDefinitionMigration.js +40 -0
- package/backend/dist/persistence/postgresPluginDefinitionMigration.js.map +1 -0
- package/backend/dist/persistence/postgresResourceRepositories.d.ts +7 -0
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -0
- package/backend/dist/persistence/postgresResourceRepositories.js +776 -0
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -0
- package/backend/dist/persistence/postgresSchemaInspector.d.ts +14 -0
- package/backend/dist/persistence/postgresSchemaInspector.d.ts.map +1 -0
- package/backend/dist/persistence/postgresSchemaInspector.js +817 -0
- package/backend/dist/persistence/postgresSchemaInspector.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +207 -0
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -0
- package/backend/dist/persistence/resourceTypes.js +38 -0
- package/backend/dist/persistence/resourceTypes.js.map +1 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts +4 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js +494 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts +93 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -0
- package/backend/dist/persistence/sqliteMigrations.js +2232 -0
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -0
- package/backend/dist/persistence/sqlitePersistence.d.ts +23 -0
- package/backend/dist/persistence/sqlitePersistence.d.ts.map +1 -0
- package/backend/dist/persistence/sqlitePersistence.js +596 -0
- package/backend/dist/persistence/sqlitePersistence.js.map +1 -0
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts +4 -0
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js +663 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -0
- package/backend/dist/persistence/sqliteSyncExecutor.d.ts +5 -0
- package/backend/dist/persistence/sqliteSyncExecutor.d.ts.map +1 -0
- package/backend/dist/persistence/sqliteSyncExecutor.js +19 -0
- package/backend/dist/persistence/sqliteSyncExecutor.js.map +1 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts +80 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.js +1543 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -0
- package/backend/dist/persistence/types.d.ts +131 -0
- package/backend/dist/persistence/types.d.ts.map +1 -0
- package/backend/dist/persistence/types.js +18 -0
- package/backend/dist/persistence/types.js.map +1 -0
- package/backend/dist/persistence/voiceProfileNameLookup.d.ts +9 -0
- package/backend/dist/persistence/voiceProfileNameLookup.d.ts.map +1 -0
- package/backend/dist/persistence/voiceProfileNameLookup.js +15 -0
- package/backend/dist/persistence/voiceProfileNameLookup.js.map +1 -0
- package/backend/dist/platform/coordination/index.d.ts +7 -0
- package/backend/dist/platform/coordination/index.d.ts.map +1 -0
- package/backend/dist/platform/coordination/index.js +24 -0
- package/backend/dist/platform/coordination/index.js.map +1 -0
- package/backend/dist/platform/coordination/localCoordinator.d.ts +49 -0
- package/backend/dist/platform/coordination/localCoordinator.d.ts.map +1 -0
- package/backend/dist/platform/coordination/localCoordinator.js +380 -0
- package/backend/dist/platform/coordination/localCoordinator.js.map +1 -0
- package/backend/dist/platform/coordination/redisCoordinator.d.ts +83 -0
- package/backend/dist/platform/coordination/redisCoordinator.d.ts.map +1 -0
- package/backend/dist/platform/coordination/redisCoordinator.js +726 -0
- package/backend/dist/platform/coordination/redisCoordinator.js.map +1 -0
- package/backend/dist/platform/coordination/service.d.ts +11 -0
- package/backend/dist/platform/coordination/service.d.ts.map +1 -0
- package/backend/dist/platform/coordination/service.js +55 -0
- package/backend/dist/platform/coordination/service.js.map +1 -0
- package/backend/dist/platform/coordination/sharedAdmission.d.ts +53 -0
- package/backend/dist/platform/coordination/sharedAdmission.d.ts.map +1 -0
- package/backend/dist/platform/coordination/sharedAdmission.js +194 -0
- package/backend/dist/platform/coordination/sharedAdmission.js.map +1 -0
- package/backend/dist/platform/coordination/types.d.ts +76 -0
- package/backend/dist/platform/coordination/types.d.ts.map +1 -0
- package/backend/dist/platform/coordination/types.js +32 -0
- package/backend/dist/platform/coordination/types.js.map +1 -0
- package/backend/dist/platform/events/durableEventGateway.d.ts +54 -0
- package/backend/dist/platform/events/durableEventGateway.d.ts.map +1 -0
- package/backend/dist/platform/events/durableEventGateway.js +262 -0
- package/backend/dist/platform/events/durableEventGateway.js.map +1 -0
- package/backend/dist/platform/events/index.d.ts +3 -0
- package/backend/dist/platform/events/index.d.ts.map +1 -0
- package/backend/dist/platform/events/index.js +8 -0
- package/backend/dist/platform/events/index.js.map +1 -0
- package/backend/dist/platform/events/service.d.ts +8 -0
- package/backend/dist/platform/events/service.d.ts.map +1 -0
- package/backend/dist/platform/events/service.js +25 -0
- package/backend/dist/platform/events/service.js.map +1 -0
- package/backend/dist/platform/jobs/chatGenerationEnqueuer.d.ts +3 -0
- package/backend/dist/platform/jobs/chatGenerationEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/chatGenerationEnqueuer.js +55 -0
- package/backend/dist/platform/jobs/chatGenerationEnqueuer.js.map +1 -0
- package/backend/dist/platform/jobs/documentIngestionEnqueuer.d.ts +3 -0
- package/backend/dist/platform/jobs/documentIngestionEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/documentIngestionEnqueuer.js +38 -0
- package/backend/dist/platform/jobs/documentIngestionEnqueuer.js.map +1 -0
- package/backend/dist/platform/jobs/domainJobContracts.d.ts +30 -0
- package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -0
- package/backend/dist/platform/jobs/domainJobContracts.js +53 -0
- package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -0
- package/backend/dist/platform/jobs/domainJobHandlers.d.ts +11 -0
- package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -0
- package/backend/dist/platform/jobs/domainJobHandlers.js +612 -0
- package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -0
- package/backend/dist/platform/jobs/durableEventIdentity.d.ts +8 -0
- package/backend/dist/platform/jobs/durableEventIdentity.d.ts.map +1 -0
- package/backend/dist/platform/jobs/durableEventIdentity.js +33 -0
- package/backend/dist/platform/jobs/durableEventIdentity.js.map +1 -0
- package/backend/dist/platform/jobs/durableJobRuntime.d.ts +57 -0
- package/backend/dist/platform/jobs/durableJobRuntime.d.ts.map +1 -0
- package/backend/dist/platform/jobs/durableJobRuntime.js +131 -0
- package/backend/dist/platform/jobs/durableJobRuntime.js.map +1 -0
- package/backend/dist/platform/jobs/durableJobRuntimeBackend.d.ts +28 -0
- package/backend/dist/platform/jobs/durableJobRuntimeBackend.d.ts.map +1 -0
- package/backend/dist/platform/jobs/durableJobRuntimeBackend.js +62 -0
- package/backend/dist/platform/jobs/durableJobRuntimeBackend.js.map +1 -0
- package/backend/dist/platform/jobs/durableJobService.d.ts +85 -0
- package/backend/dist/platform/jobs/durableJobService.d.ts.map +1 -0
- package/backend/dist/platform/jobs/durableJobService.js +726 -0
- package/backend/dist/platform/jobs/durableJobService.js.map +1 -0
- package/backend/dist/platform/jobs/durableJobTypes.d.ts +195 -0
- package/backend/dist/platform/jobs/durableJobTypes.d.ts.map +1 -0
- package/backend/dist/platform/jobs/durableJobTypes.js +72 -0
- package/backend/dist/platform/jobs/durableJobTypes.js.map +1 -0
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts +87 -0
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -0
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +429 -0
- package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -0
- package/backend/dist/platform/jobs/identityDeletionEnqueuer.d.ts +3 -0
- package/backend/dist/platform/jobs/identityDeletionEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/identityDeletionEnqueuer.js +36 -0
- package/backend/dist/platform/jobs/identityDeletionEnqueuer.js.map +1 -0
- package/backend/dist/platform/jobs/index.d.ts +18 -0
- package/backend/dist/platform/jobs/index.d.ts.map +1 -0
- package/backend/dist/platform/jobs/index.js +34 -0
- package/backend/dist/platform/jobs/index.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableEventIdempotencyMigration.d.ts +4 -0
- package/backend/dist/platform/jobs/postgresDurableEventIdempotencyMigration.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableEventIdempotencyMigration.js +25 -0
- package/backend/dist/platform/jobs/postgresDurableEventIdempotencyMigration.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableEventReplayIndexMigration.d.ts +4 -0
- package/backend/dist/platform/jobs/postgresDurableEventReplayIndexMigration.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableEventReplayIndexMigration.js +23 -0
- package/backend/dist/platform/jobs/postgresDurableEventReplayIndexMigration.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobMigration.d.ts +11 -0
- package/backend/dist/platform/jobs/postgresDurableJobMigration.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobMigration.js +106 -0
- package/backend/dist/platform/jobs/postgresDurableJobMigration.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobRepository.d.ts +88 -0
- package/backend/dist/platform/jobs/postgresDurableJobRepository.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobRepository.js +1185 -0
- package/backend/dist/platform/jobs/postgresDurableJobRepository.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobService.d.ts +86 -0
- package/backend/dist/platform/jobs/postgresDurableJobService.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobService.js +696 -0
- package/backend/dist/platform/jobs/postgresDurableJobService.js.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts +53 -0
- package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -0
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js +393 -0
- package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -0
- package/backend/dist/platform/jobs/resourceDeletionEnqueuer.d.ts +3 -0
- package/backend/dist/platform/jobs/resourceDeletionEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/resourceDeletionEnqueuer.js +43 -0
- package/backend/dist/platform/jobs/resourceDeletionEnqueuer.js.map +1 -0
- package/backend/dist/platform/jobs/sqliteDurableJobRepository.d.ts +166 -0
- package/backend/dist/platform/jobs/sqliteDurableJobRepository.d.ts.map +1 -0
- package/backend/dist/platform/jobs/sqliteDurableJobRepository.js +1008 -0
- package/backend/dist/platform/jobs/sqliteDurableJobRepository.js.map +1 -0
- package/backend/dist/platform/jobs/videoGenerationEnqueuer.d.ts +4 -0
- package/backend/dist/platform/jobs/videoGenerationEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/videoGenerationEnqueuer.js +46 -0
- package/backend/dist/platform/jobs/videoGenerationEnqueuer.js.map +1 -0
- package/backend/dist/platform/jobs/workExecutionEnqueuer.d.ts +3 -0
- package/backend/dist/platform/jobs/workExecutionEnqueuer.d.ts.map +1 -0
- package/backend/dist/platform/jobs/workExecutionEnqueuer.js +38 -0
- package/backend/dist/platform/jobs/workExecutionEnqueuer.js.map +1 -0
- package/backend/dist/platform/ollamaRuntimeConfig.d.ts +40 -0
- package/backend/dist/platform/ollamaRuntimeConfig.d.ts.map +1 -0
- package/backend/dist/platform/ollamaRuntimeConfig.js +72 -0
- package/backend/dist/platform/ollamaRuntimeConfig.js.map +1 -0
- package/backend/dist/platform/recovery/backupArchive.d.ts +120 -0
- package/backend/dist/platform/recovery/backupArchive.d.ts.map +1 -0
- package/backend/dist/platform/recovery/backupArchive.js +842 -0
- package/backend/dist/platform/recovery/backupArchive.js.map +1 -0
- package/backend/dist/platform/recovery/index.d.ts +3 -0
- package/backend/dist/platform/recovery/index.d.ts.map +1 -0
- package/backend/dist/platform/recovery/index.js +8 -0
- package/backend/dist/platform/recovery/index.js.map +1 -0
- package/backend/dist/platform/recovery/teamBackupArchive.d.ts +98 -0
- package/backend/dist/platform/recovery/teamBackupArchive.d.ts.map +1 -0
- package/backend/dist/platform/recovery/teamBackupArchive.js +1203 -0
- package/backend/dist/platform/recovery/teamBackupArchive.js.map +1 -0
- package/backend/dist/platform/runtimeConfig.d.ts +70 -0
- package/backend/dist/platform/runtimeConfig.d.ts.map +1 -0
- package/backend/dist/platform/runtimeConfig.js +205 -0
- package/backend/dist/platform/runtimeConfig.js.map +1 -0
- package/backend/dist/platform/storage/aesGcmKeyring.d.ts +26 -0
- package/backend/dist/platform/storage/aesGcmKeyring.d.ts.map +1 -0
- package/backend/dist/platform/storage/aesGcmKeyring.js +135 -0
- package/backend/dist/platform/storage/aesGcmKeyring.js.map +1 -0
- package/backend/dist/platform/storage/blobReferenceRepository.d.ts +36 -0
- package/backend/dist/platform/storage/blobReferenceRepository.d.ts.map +1 -0
- package/backend/dist/platform/storage/blobReferenceRepository.js +117 -0
- package/backend/dist/platform/storage/blobReferenceRepository.js.map +1 -0
- package/backend/dist/platform/storage/blobStore.d.ts +111 -0
- package/backend/dist/platform/storage/blobStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/blobStore.js +46 -0
- package/backend/dist/platform/storage/blobStore.js.map +1 -0
- package/backend/dist/platform/storage/documentVectorIndex.d.ts +44 -0
- package/backend/dist/platform/storage/documentVectorIndex.d.ts.map +1 -0
- package/backend/dist/platform/storage/documentVectorIndex.js +110 -0
- package/backend/dist/platform/storage/documentVectorIndex.js.map +1 -0
- package/backend/dist/platform/storage/durableBlobQuotaPolicy.d.ts +82 -0
- package/backend/dist/platform/storage/durableBlobQuotaPolicy.d.ts.map +1 -0
- package/backend/dist/platform/storage/durableBlobQuotaPolicy.js +583 -0
- package/backend/dist/platform/storage/durableBlobQuotaPolicy.js.map +1 -0
- package/backend/dist/platform/storage/index.d.ts +19 -0
- package/backend/dist/platform/storage/index.d.ts.map +1 -0
- package/backend/dist/platform/storage/index.js +35 -0
- package/backend/dist/platform/storage/index.js.map +1 -0
- package/backend/dist/platform/storage/localEncryptedBlobStore.d.ts +120 -0
- package/backend/dist/platform/storage/localEncryptedBlobStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/localEncryptedBlobStore.js +1205 -0
- package/backend/dist/platform/storage/localEncryptedBlobStore.js.map +1 -0
- package/backend/dist/platform/storage/personaMemoryIndexing.d.ts +12 -0
- package/backend/dist/platform/storage/personaMemoryIndexing.d.ts.map +1 -0
- package/backend/dist/platform/storage/personaMemoryIndexing.js +25 -0
- package/backend/dist/platform/storage/personaMemoryIndexing.js.map +1 -0
- package/backend/dist/platform/storage/pgVectorStore.d.ts +37 -0
- package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/pgVectorStore.js +493 -0
- package/backend/dist/platform/storage/pgVectorStore.js.map +1 -0
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts +244 -0
- package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -0
- package/backend/dist/platform/storage/platformDomainRepositories.js +7 -0
- package/backend/dist/platform/storage/platformDomainRepositories.js.map +1 -0
- package/backend/dist/platform/storage/platformStorageRuntime.d.ts +35 -0
- package/backend/dist/platform/storage/platformStorageRuntime.d.ts.map +1 -0
- package/backend/dist/platform/storage/platformStorageRuntime.js +299 -0
- package/backend/dist/platform/storage/platformStorageRuntime.js.map +1 -0
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts +4 -0
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -0
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +1017 -0
- package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -0
- package/backend/dist/platform/storage/postgresResourceDeletionLifecycleMigration.d.ts +4 -0
- package/backend/dist/platform/storage/postgresResourceDeletionLifecycleMigration.d.ts.map +1 -0
- package/backend/dist/platform/storage/postgresResourceDeletionLifecycleMigration.js +40 -0
- package/backend/dist/platform/storage/postgresResourceDeletionLifecycleMigration.js.map +1 -0
- package/backend/dist/platform/storage/resourceContentCleanup.d.ts +29 -0
- package/backend/dist/platform/storage/resourceContentCleanup.d.ts.map +1 -0
- package/backend/dist/platform/storage/resourceContentCleanup.js +100 -0
- package/backend/dist/platform/storage/resourceContentCleanup.js.map +1 -0
- package/backend/dist/platform/storage/resourceDeletionLifecycle.d.ts +14 -0
- package/backend/dist/platform/storage/resourceDeletionLifecycle.d.ts.map +1 -0
- package/backend/dist/platform/storage/resourceDeletionLifecycle.js +31 -0
- package/backend/dist/platform/storage/resourceDeletionLifecycle.js.map +1 -0
- package/backend/dist/platform/storage/s3EncryptedBlobStore.d.ts +140 -0
- package/backend/dist/platform/storage/s3EncryptedBlobStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/s3EncryptedBlobStore.js +1309 -0
- package/backend/dist/platform/storage/s3EncryptedBlobStore.js.map +1 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +71 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +766 -0
- package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -0
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts +4 -0
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -0
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +1037 -0
- package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -0
- package/backend/dist/platform/storage/sqliteToTeamStorageMigration.d.ts +25 -0
- package/backend/dist/platform/storage/sqliteToTeamStorageMigration.d.ts.map +1 -0
- package/backend/dist/platform/storage/sqliteToTeamStorageMigration.js +1292 -0
- package/backend/dist/platform/storage/sqliteToTeamStorageMigration.js.map +1 -0
- package/backend/dist/platform/storage/storageFactory.d.ts +81 -0
- package/backend/dist/platform/storage/storageFactory.d.ts.map +1 -0
- package/backend/dist/platform/storage/storageFactory.js +518 -0
- package/backend/dist/platform/storage/storageFactory.js.map +1 -0
- package/backend/dist/platform/storage/storageSchemaContracts.d.ts +22 -0
- package/backend/dist/platform/storage/storageSchemaContracts.d.ts.map +1 -0
- package/backend/dist/platform/storage/storageSchemaContracts.js +299 -0
- package/backend/dist/platform/storage/storageSchemaContracts.js.map +1 -0
- package/backend/dist/platform/storage/vectorStore.d.ts +117 -0
- package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -0
- package/backend/dist/platform/storage/vectorStore.js +40 -0
- package/backend/dist/platform/storage/vectorStore.js.map +1 -0
- package/backend/dist/platform/workPersistence/index.d.ts +9 -0
- package/backend/dist/platform/workPersistence/index.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/index.js +14 -0
- package/backend/dist/platform/workPersistence/index.js.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkLifecycleMigration.d.ts +9 -0
- package/backend/dist/platform/workPersistence/postgresWorkLifecycleMigration.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkLifecycleMigration.js +47 -0
- package/backend/dist/platform/workPersistence/postgresWorkLifecycleMigration.js.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkMessageContentMigration.d.ts +3 -0
- package/backend/dist/platform/workPersistence/postgresWorkMessageContentMigration.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkMessageContentMigration.js +28 -0
- package/backend/dist/platform/workPersistence/postgresWorkMessageContentMigration.js.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkMigration.d.ts +3 -0
- package/backend/dist/platform/workPersistence/postgresWorkMigration.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkMigration.js +101 -0
- package/backend/dist/platform/workPersistence/postgresWorkMigration.js.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +79 -0
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +521 -0
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -0
- package/backend/dist/platform/workPersistence/service.d.ts +6 -0
- package/backend/dist/platform/workPersistence/service.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/service.js +27 -0
- package/backend/dist/platform/workPersistence/service.js.map +1 -0
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +77 -0
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +463 -0
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -0
- package/backend/dist/platform/workPersistence/types.d.ts +159 -0
- package/backend/dist/platform/workPersistence/types.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/types.js +13 -0
- package/backend/dist/platform/workPersistence/types.js.map +1 -0
- package/backend/dist/platform/workPersistence/workExecutionTypes.d.ts +13 -0
- package/backend/dist/platform/workPersistence/workExecutionTypes.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/workExecutionTypes.js +7 -0
- package/backend/dist/platform/workPersistence/workExecutionTypes.js.map +1 -0
- package/backend/dist/platform/workPersistence/workMessageContentCodec.d.ts +8 -0
- package/backend/dist/platform/workPersistence/workMessageContentCodec.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/workMessageContentCodec.js +25 -0
- package/backend/dist/platform/workPersistence/workMessageContentCodec.js.map +1 -0
- package/backend/dist/platform/workPersistence/workTextSafety.d.ts +3 -0
- package/backend/dist/platform/workPersistence/workTextSafety.d.ts.map +1 -0
- package/backend/dist/platform/workPersistence/workTextSafety.js +8 -0
- package/backend/dist/platform/workPersistence/workTextSafety.js.map +1 -0
- package/backend/dist/routes/agentCli.js +1 -1
- package/backend/dist/routes/agentCli.js.map +1 -1
- package/backend/dist/routes/artifacts.d.ts.map +1 -1
- package/backend/dist/routes/artifacts.js +2 -1
- package/backend/dist/routes/artifacts.js.map +1 -1
- package/backend/dist/routes/auth.d.ts.map +1 -1
- package/backend/dist/routes/auth.js +64 -18
- package/backend/dist/routes/auth.js.map +1 -1
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +519 -85
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/documents.d.ts.map +1 -1
- package/backend/dist/routes/documents.js +134 -28
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/routes/embeddings.d.ts.map +1 -1
- package/backend/dist/routes/embeddings.js +2 -1
- package/backend/dist/routes/embeddings.js.map +1 -1
- package/backend/dist/routes/health.d.ts +3 -0
- package/backend/dist/routes/health.d.ts.map +1 -0
- package/backend/dist/routes/health.js +52 -0
- package/backend/dist/routes/health.js.map +1 -0
- package/backend/dist/routes/huggingfaceHub.d.ts.map +1 -1
- package/backend/dist/routes/huggingfaceHub.js +2 -1
- package/backend/dist/routes/huggingfaceHub.js.map +1 -1
- package/backend/dist/routes/imageGen.d.ts.map +1 -1
- package/backend/dist/routes/imageGen.js +42 -10
- package/backend/dist/routes/imageGen.js.map +1 -1
- package/backend/dist/routes/jobs.d.ts +3 -0
- package/backend/dist/routes/jobs.d.ts.map +1 -0
- package/backend/dist/routes/jobs.js +117 -0
- package/backend/dist/routes/jobs.js.map +1 -0
- package/backend/dist/routes/libreClaw.d.ts.map +1 -1
- package/backend/dist/routes/libreClaw.js +10 -7
- package/backend/dist/routes/libreClaw.js.map +1 -1
- package/backend/dist/routes/media.d.ts.map +1 -1
- package/backend/dist/routes/media.js +523 -77
- package/backend/dist/routes/media.js.map +1 -1
- package/backend/dist/routes/notes.d.ts.map +1 -1
- package/backend/dist/routes/notes.js +21 -21
- package/backend/dist/routes/notes.js.map +1 -1
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +40 -12
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/personas.d.ts.map +1 -1
- package/backend/dist/routes/personas.js +4 -2
- package/backend/dist/routes/personas.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +79 -51
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/routes/preferences.d.ts.map +1 -1
- package/backend/dist/routes/preferences.js +290 -25
- package/backend/dist/routes/preferences.js.map +1 -1
- package/backend/dist/routes/search.d.ts.map +1 -1
- package/backend/dist/routes/search.js +23 -14
- package/backend/dist/routes/search.js.map +1 -1
- package/backend/dist/routes/stt.d.ts +9 -0
- package/backend/dist/routes/stt.d.ts.map +1 -0
- package/backend/dist/routes/stt.js +217 -0
- package/backend/dist/routes/stt.js.map +1 -0
- package/backend/dist/routes/systemDiagnostics.d.ts.map +1 -1
- package/backend/dist/routes/systemDiagnostics.js +2 -1
- package/backend/dist/routes/systemDiagnostics.js.map +1 -1
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +577 -28
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/routes/users.d.ts.map +1 -1
- package/backend/dist/routes/users.js +16 -25
- package/backend/dist/routes/users.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +167 -113
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/agentAccessService.d.ts +2 -2
- package/backend/dist/services/agentAccessService.d.ts.map +1 -1
- package/backend/dist/services/agentAccessService.js +5 -14
- package/backend/dist/services/agentAccessService.js.map +1 -1
- package/backend/dist/services/agentCliService.d.ts +3 -2
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +44 -16
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/assistantCompletionService.d.ts +2 -1
- package/backend/dist/services/assistantCompletionService.d.ts.map +1 -1
- package/backend/dist/services/assistantCompletionService.js +7 -3
- package/backend/dist/services/assistantCompletionService.js.map +1 -1
- package/backend/dist/services/authService.d.ts +7 -2
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +23 -10
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/chatGenerationService.d.ts +5 -4
- package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/chatGenerationService.js +23 -17
- package/backend/dist/services/chatGenerationService.js.map +1 -1
- package/backend/dist/services/chatRequestService.d.ts +4 -3
- package/backend/dist/services/chatRequestService.d.ts.map +1 -1
- package/backend/dist/services/chatRequestService.js +3 -3
- package/backend/dist/services/chatRequestService.js.map +1 -1
- package/backend/dist/services/chatService.d.ts +66 -16
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +402 -111
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/codexOAuthService.d.ts +2 -2
- package/backend/dist/services/codexOAuthService.d.ts.map +1 -1
- package/backend/dist/services/codexOAuthService.js +63 -7
- package/backend/dist/services/codexOAuthService.js.map +1 -1
- package/backend/dist/services/dataArchiveService.d.ts +88 -0
- package/backend/dist/services/dataArchiveService.d.ts.map +1 -0
- package/backend/dist/services/dataArchiveService.js +1027 -0
- package/backend/dist/services/dataArchiveService.js.map +1 -0
- package/backend/dist/services/documentService.d.ts +67 -14
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +938 -193
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/durableChatCompletion.d.ts +16 -0
- package/backend/dist/services/durableChatCompletion.d.ts.map +1 -0
- package/backend/dist/services/durableChatCompletion.js +34 -0
- package/backend/dist/services/durableChatCompletion.js.map +1 -0
- package/backend/dist/services/durableChatGenerationService.d.ts +19 -0
- package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -0
- package/backend/dist/services/durableChatGenerationService.js +341 -0
- package/backend/dist/services/durableChatGenerationService.js.map +1 -0
- package/backend/dist/services/embeddingService.d.ts +1 -1
- package/backend/dist/services/embeddingService.d.ts.map +1 -1
- package/backend/dist/services/embeddingService.js +16 -13
- package/backend/dist/services/embeddingService.js.map +1 -1
- package/backend/dist/services/encryptionService.d.ts +28 -1
- package/backend/dist/services/encryptionService.d.ts.map +1 -1
- package/backend/dist/services/encryptionService.js +131 -51
- package/backend/dist/services/encryptionService.js.map +1 -1
- package/backend/dist/services/followUpService.d.ts +1 -1
- package/backend/dist/services/followUpService.d.ts.map +1 -1
- package/backend/dist/services/followUpService.js +1 -1
- package/backend/dist/services/followUpService.js.map +1 -1
- package/backend/dist/services/galleryService.d.ts +38 -37
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js +356 -251
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/healthService.d.ts +65 -0
- package/backend/dist/services/healthService.d.ts.map +1 -0
- package/backend/dist/services/healthService.js +379 -0
- package/backend/dist/services/healthService.js.map +1 -0
- package/backend/dist/services/legacyCiphertextIntegrity.d.ts +40 -0
- package/backend/dist/services/legacyCiphertextIntegrity.d.ts.map +1 -0
- package/backend/dist/services/legacyCiphertextIntegrity.js +406 -0
- package/backend/dist/services/legacyCiphertextIntegrity.js.map +1 -0
- package/backend/dist/services/mediaGenerationJobService.d.ts +27 -5
- package/backend/dist/services/mediaGenerationJobService.d.ts.map +1 -1
- package/backend/dist/services/mediaGenerationJobService.js +185 -55
- package/backend/dist/services/mediaGenerationJobService.js.map +1 -1
- package/backend/dist/services/memoryService.d.ts +7 -83
- package/backend/dist/services/memoryService.d.ts.map +1 -1
- package/backend/dist/services/memoryService.js +428 -573
- package/backend/dist/services/memoryService.js.map +1 -1
- package/backend/dist/services/memoryUtils.d.ts.map +1 -1
- package/backend/dist/services/memoryUtils.js +8 -1
- package/backend/dist/services/memoryUtils.js.map +1 -1
- package/backend/dist/services/modelAccessService.d.ts +3 -3
- package/backend/dist/services/modelAccessService.d.ts.map +1 -1
- package/backend/dist/services/modelAccessService.js +8 -16
- package/backend/dist/services/modelAccessService.js.map +1 -1
- package/backend/dist/services/mutationEngineService.d.ts +0 -7
- package/backend/dist/services/mutationEngineService.d.ts.map +1 -1
- package/backend/dist/services/mutationEngineService.js +7 -78
- package/backend/dist/services/mutationEngineService.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts +4 -4
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +62 -31
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/personaService.d.ts.map +1 -1
- package/backend/dist/services/personaService.js +19 -54
- package/backend/dist/services/personaService.js.map +1 -1
- package/backend/dist/services/pluginActivationService.d.ts +6 -5
- package/backend/dist/services/pluginActivationService.d.ts.map +1 -1
- package/backend/dist/services/pluginActivationService.js +36 -76
- package/backend/dist/services/pluginActivationService.js.map +1 -1
- package/backend/dist/services/pluginAudioGenerationService.d.ts +11 -6
- package/backend/dist/services/pluginAudioGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginAudioGenerationService.js +74 -16
- package/backend/dist/services/pluginAudioGenerationService.js.map +1 -1
- package/backend/dist/services/pluginCacheInvalidation.d.ts +38 -0
- package/backend/dist/services/pluginCacheInvalidation.d.ts.map +1 -0
- package/backend/dist/services/pluginCacheInvalidation.js +198 -0
- package/backend/dist/services/pluginCacheInvalidation.js.map +1 -0
- package/backend/dist/services/pluginCapabilityRegistryService.d.ts +3 -3
- package/backend/dist/services/pluginCapabilityRegistryService.d.ts.map +1 -1
- package/backend/dist/services/pluginCapabilityRegistryService.js +11 -7
- package/backend/dist/services/pluginCapabilityRegistryService.js.map +1 -1
- package/backend/dist/services/pluginCredentialsService.d.ts +9 -8
- package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
- package/backend/dist/services/pluginCredentialsService.js +48 -89
- package/backend/dist/services/pluginCredentialsService.js.map +1 -1
- package/backend/dist/services/pluginEmbeddingService.d.ts +8 -7
- package/backend/dist/services/pluginEmbeddingService.d.ts.map +1 -1
- package/backend/dist/services/pluginEmbeddingService.js +13 -11
- package/backend/dist/services/pluginEmbeddingService.js.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.d.ts +10 -8
- package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.js +119 -14
- package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
- package/backend/dist/services/pluginSTTService.d.ts +47 -0
- package/backend/dist/services/pluginSTTService.d.ts.map +1 -0
- package/backend/dist/services/pluginSTTService.js +199 -0
- package/backend/dist/services/pluginSTTService.js.map +1 -0
- package/backend/dist/services/pluginService.d.ts +94 -40
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +799 -274
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/pluginTTSService.d.ts +26 -8
- package/backend/dist/services/pluginTTSService.d.ts.map +1 -1
- package/backend/dist/services/pluginTTSService.js +277 -25
- package/backend/dist/services/pluginTTSService.js.map +1 -1
- package/backend/dist/services/pluginUsageService.d.ts +4 -4
- package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
- package/backend/dist/services/pluginUsageService.js +44 -93
- package/backend/dist/services/pluginUsageService.js.map +1 -1
- package/backend/dist/services/pluginVariablesService.d.ts +14 -7
- package/backend/dist/services/pluginVariablesService.d.ts.map +1 -1
- package/backend/dist/services/pluginVariablesService.js +116 -81
- package/backend/dist/services/pluginVariablesService.js.map +1 -1
- package/backend/dist/services/pluginVideoGenerationService.d.ts +19 -8
- package/backend/dist/services/pluginVideoGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginVideoGenerationService.js +116 -20
- package/backend/dist/services/pluginVideoGenerationService.js.map +1 -1
- package/backend/dist/services/preferencesService.d.ts +31 -21
- package/backend/dist/services/preferencesService.d.ts.map +1 -1
- package/backend/dist/services/preferencesService.js +104 -102
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/services/recoveryInventoryService.d.ts +244 -0
- package/backend/dist/services/recoveryInventoryService.d.ts.map +1 -0
- package/backend/dist/services/recoveryInventoryService.js +1436 -0
- package/backend/dist/services/recoveryInventoryService.js.map +1 -0
- package/backend/dist/services/simpleGitHubOAuth.js +3 -3
- package/backend/dist/services/simpleGitHubOAuth.js.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.js +3 -3
- package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -1
- package/backend/dist/services/systemDiagnosticsService.d.ts.map +1 -1
- package/backend/dist/services/systemDiagnosticsService.js +2 -2
- package/backend/dist/services/systemDiagnosticsService.js.map +1 -1
- package/backend/dist/services/systemSettingsService.d.ts +5 -0
- package/backend/dist/services/systemSettingsService.d.ts.map +1 -0
- package/backend/dist/services/systemSettingsService.js +24 -0
- package/backend/dist/services/systemSettingsService.js.map +1 -0
- package/backend/dist/services/titleGenerationService.d.ts +1 -1
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +1 -1
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/dist/services/voiceProfileService.d.ts +44 -0
- package/backend/dist/services/voiceProfileService.d.ts.map +1 -0
- package/backend/dist/services/voiceProfileService.js +195 -0
- package/backend/dist/services/voiceProfileService.js.map +1 -0
- package/backend/dist/services/webSearchService.d.ts +7 -7
- package/backend/dist/services/webSearchService.d.ts.map +1 -1
- package/backend/dist/services/webSearchService.js +40 -35
- package/backend/dist/services/webSearchService.js.map +1 -1
- package/backend/dist/services/websocketTicketService.d.ts +39 -0
- package/backend/dist/services/websocketTicketService.d.ts.map +1 -0
- package/backend/dist/services/websocketTicketService.js +183 -0
- package/backend/dist/services/websocketTicketService.js.map +1 -0
- package/backend/dist/services/workAccessService.d.ts +3 -3
- package/backend/dist/services/workAccessService.d.ts.map +1 -1
- package/backend/dist/services/workAccessService.js +8 -16
- package/backend/dist/services/workAccessService.js.map +1 -1
- package/backend/dist/services/workAdminService.d.ts +3 -3
- package/backend/dist/services/workAdminService.d.ts.map +1 -1
- package/backend/dist/services/workAdminService.js +4 -4
- package/backend/dist/services/workAdminService.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +25 -1
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +294 -126
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workEventService.d.ts +15 -2
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js +201 -3
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workKubernetesDriver.d.ts +8 -7
- package/backend/dist/services/workKubernetesDriver.d.ts.map +1 -1
- package/backend/dist/services/workKubernetesDriver.js +65 -21
- package/backend/dist/services/workKubernetesDriver.js.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts +2 -2
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +38 -34
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/services/workPolicyService.d.ts +7 -7
- package/backend/dist/services/workPolicyService.d.ts.map +1 -1
- package/backend/dist/services/workPolicyService.js +50 -51
- package/backend/dist/services/workPolicyService.js.map +1 -1
- package/backend/dist/services/workPreviewProxyService.d.ts +8 -8
- package/backend/dist/services/workPreviewProxyService.d.ts.map +1 -1
- package/backend/dist/services/workPreviewProxyService.js +47 -44
- package/backend/dist/services/workPreviewProxyService.js.map +1 -1
- package/backend/dist/services/workRuntimeDriver.d.ts +21 -18
- package/backend/dist/services/workRuntimeDriver.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeDriver.js +69 -20
- package/backend/dist/services/workRuntimeDriver.js.map +1 -1
- package/backend/dist/services/workRuntimeService.d.ts +18 -13
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js +438 -194
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/services/workRuntimeShared.d.ts +2 -0
- package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeShared.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +42 -36
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +445 -350
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/services/workTerminalService.d.ts +1 -1
- package/backend/dist/services/workTerminalService.d.ts.map +1 -1
- package/backend/dist/services/workTerminalService.js +33 -6
- package/backend/dist/services/workTerminalService.js.map +1 -1
- package/backend/dist/storage.d.ts +72 -40
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +312 -660
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/types/index.d.ts +28 -0
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/work.d.ts +7 -2
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/dist/utils/chatCancellation.d.ts +48 -0
- package/backend/dist/utils/chatCancellation.d.ts.map +1 -0
- package/backend/dist/utils/chatCancellation.js +152 -0
- package/backend/dist/utils/chatCancellation.js.map +1 -0
- package/backend/dist/utils/chatDocumentContext.d.ts +1 -1
- package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
- package/backend/dist/utils/chatDocumentContext.js +11 -5
- package/backend/dist/utils/chatDocumentContext.js.map +1 -1
- package/backend/dist/utils/chatStreamCoalescer.d.ts +15 -0
- package/backend/dist/utils/chatStreamCoalescer.d.ts.map +1 -0
- package/backend/dist/utils/chatStreamCoalescer.js +59 -0
- package/backend/dist/utils/chatStreamCoalescer.js.map +1 -0
- package/backend/dist/utils/dataDirectory.d.ts +49 -0
- package/backend/dist/utils/dataDirectory.d.ts.map +1 -0
- package/backend/dist/utils/dataDirectory.js +291 -0
- package/backend/dist/utils/dataDirectory.js.map +1 -0
- package/backend/dist/utils/generationUtils.d.ts.map +1 -1
- package/backend/dist/utils/generationUtils.js +18 -6
- package/backend/dist/utils/generationUtils.js.map +1 -1
- package/backend/dist/utils/jwt.d.ts.map +1 -1
- package/backend/dist/utils/jwt.js +2 -3
- package/backend/dist/utils/jwt.js.map +1 -1
- package/backend/dist/utils/ollamaModelDefaults.d.ts.map +1 -1
- package/backend/dist/utils/ollamaModelDefaults.js +2 -7
- package/backend/dist/utils/ollamaModelDefaults.js.map +1 -1
- package/backend/dist/utils/ollamaStreaming.d.ts +2 -1
- package/backend/dist/utils/ollamaStreaming.d.ts.map +1 -1
- package/backend/dist/utils/ollamaStreaming.js +49 -11
- package/backend/dist/utils/ollamaStreaming.js.map +1 -1
- package/backend/dist/utils/pluginConnectionVariables.d.ts.map +1 -1
- package/backend/dist/utils/pluginConnectionVariables.js +11 -3
- package/backend/dist/utils/pluginConnectionVariables.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +4 -3
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/dist/utils/pluginStreaming.d.ts +2 -1
- package/backend/dist/utils/pluginStreaming.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreaming.js +5 -1
- package/backend/dist/utils/pluginStreaming.js.map +1 -1
- package/backend/dist/utils/pluginUpload.d.ts +1 -0
- package/backend/dist/utils/pluginUpload.d.ts.map +1 -1
- package/backend/dist/utils/pluginUpload.js +9 -2
- package/backend/dist/utils/pluginUpload.js.map +1 -1
- package/backend/dist/utils/pluginValidation.d.ts.map +1 -1
- package/backend/dist/utils/pluginValidation.js +29 -1
- package/backend/dist/utils/pluginValidation.js.map +1 -1
- package/backend/dist/utils/sttAudioUpload.d.ts +24 -0
- package/backend/dist/utils/sttAudioUpload.d.ts.map +1 -0
- package/backend/dist/utils/sttAudioUpload.js +500 -0
- package/backend/dist/utils/sttAudioUpload.js.map +1 -0
- package/backend/dist/utils/ttsVoiceCloneUpload.d.ts +34 -0
- package/backend/dist/utils/ttsVoiceCloneUpload.d.ts.map +1 -0
- package/backend/dist/utils/ttsVoiceCloneUpload.js +224 -0
- package/backend/dist/utils/ttsVoiceCloneUpload.js.map +1 -0
- package/backend/dist/utils/websocketMessages.d.ts +2 -1
- package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
- package/backend/dist/utils/websocketMessages.js +16 -2
- package/backend/dist/utils/websocketMessages.js.map +1 -1
- package/backend/dist/websocketServer.d.ts +4 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +290 -44
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/dist/workTerminalServer.d.ts +9 -0
- package/backend/dist/workTerminalServer.d.ts.map +1 -1
- package/backend/dist/workTerminalServer.js +221 -52
- package/backend/dist/workTerminalServer.js.map +1 -1
- package/backend/dist/worker.d.ts +2 -0
- package/backend/dist/worker.d.ts.map +1 -0
- package/backend/dist/worker.js +250 -0
- package/backend/dist/worker.js.map +1 -0
- package/backend/package.json +19 -9
- package/bin/cli.js +126 -99
- package/bin/runtime-paths.js +108 -0
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/framer-motion.js +5 -5
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/assets/index-CUhEG7E2.js +33 -0
- package/frontend/dist/assets/index-kxtZQLV6.css +1 -0
- package/frontend/dist/assets/{markdown-math-ClQbWekD.css → markdown-math-ClTedVi7.css} +1 -1
- package/frontend/dist/index.html +18 -18
- package/frontend/dist/js/{ArtifactContainer-Dy2Q0iIL.js → ArtifactContainer-BTEDhBnv.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-K79dWshB.js → ArtifactDemoPage-B0gN3YTl.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DhqLNUtY.js → ArtifactSandboxFrame-CLBXQkZs.js} +3 -3
- package/frontend/dist/js/{ArtifactSlideOutPanel-Cl8JG7bz.js → ArtifactSlideOutPanel-CfqHPFdE.js} +1 -1
- package/frontend/dist/js/{Button-CTXHujOd.js → Button-BV44cTnj.js} +1 -1
- package/frontend/dist/js/ChatPage-DIkAXZWA.js +23 -0
- package/frontend/dist/js/{FirstTimeSetup-kHhRzGJ8.js → FirstTimeSetup-B8phXGNA.js} +1 -1
- package/frontend/dist/js/GalleryPage-W4uI043I.js +1 -0
- package/frontend/dist/js/{HomePage-C1L8WAXL.js → HomePage-DlxehbyO.js} +1 -1
- package/frontend/dist/js/{LibreClawPage-Dyua8IUu.js → LibreClawPage-CgD0_G_F.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-CuMRGUd-.js → ModelManagerModals-D7jIT3v1.js} +1 -1
- package/frontend/dist/js/{ModelSelector-CqHc-Ln4.js → ModelSelector-BYxJU1UV.js} +1 -1
- package/frontend/dist/js/ModelsPage-C4XdCKP5.js +2 -0
- package/frontend/dist/js/NotesPage-CDECOl4V.js +1 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-CWYUn9Oe.js → OptimizedSyntaxHighlighter-XwqZEoTf.js} +1 -1
- package/frontend/dist/js/{PersonasPage-D_6WBCH5.js → PersonasPage-CjSLPrgS.js} +2 -2
- package/frontend/dist/js/PluginUsagePage-DJOXJuH4.js +1 -0
- package/frontend/dist/js/RichMessageContent-Debeh6bi.js +3 -0
- package/frontend/dist/js/SettingsModal-cUqAeYUP.js +1 -0
- package/frontend/dist/js/{SettingsToggle-DLHlCDBl.js → SettingsToggle-WTa0rgvY.js} +1 -1
- package/frontend/dist/js/{SystemPage-BMWEet9e.js → SystemPage-DxPw0GS7.js} +1 -1
- package/frontend/dist/js/UserManagementPage-CEdYFe_Z.js +1 -0
- package/frontend/dist/js/WorkPage-DDVeuG_9.js +6 -0
- package/frontend/dist/js/api-IzobHGND.js +14 -0
- package/frontend/dist/js/appStore-DKwC2vgn.js +2 -0
- package/frontend/dist/js/ar-xTSvTq05.js +2 -0
- package/frontend/dist/js/authStore-OaTuapL7.js +4 -0
- package/frontend/dist/js/{babel-CmENXdZw.js → babel-D24oDI9y.js} +1 -1
- package/frontend/dist/js/bn-iYAsohEA.js +2 -0
- package/frontend/dist/js/chatStore-DXGUVLXD.js +3 -0
- package/frontend/dist/js/{config-DkV1ka7I.js → config-DPEEuTAe.js} +1 -1
- package/frontend/dist/js/cs-YBHN88Hb.js +2 -0
- package/frontend/dist/js/da-D7qlLy_k.js +2 -0
- package/frontend/dist/js/de-DV671k2c.js +2 -0
- package/frontend/dist/js/es-kyBgzNq-.js +2 -0
- package/frontend/dist/js/{estree-D5KP-qbw.js → estree-ChwJsD2w.js} +1 -1
- package/frontend/dist/js/fr-Cw1vut7I.js +2 -0
- package/frontend/dist/js/hi-DWEFC024.js +2 -0
- package/frontend/dist/js/{html-Cm9c2akd.js → html-DFrVjciF.js} +1 -1
- package/frontend/dist/js/id-DlMHjjy0.js +2 -0
- package/frontend/dist/js/is-B9E_a7dG.js +2 -0
- package/frontend/dist/js/it-DawmVbLC.js +2 -0
- package/frontend/dist/js/ja-DmVvwY3W.js +2 -0
- package/frontend/dist/js/ko-DzOPpkVs.js +2 -0
- package/frontend/dist/js/{markdown-B2u7CnKN.js → markdown-FLLx7b67.js} +1 -1
- package/frontend/dist/js/markdown-core-BmPPZiuD.js +31 -0
- package/frontend/dist/js/{markdown-math-B7FlYsmr.js → markdown-math-mH7AZ_mb.js} +6 -6
- package/frontend/dist/js/{messageCodeStyles-DalG2j6U.js → messageCodeStyles-CBkkZY4n.js} +1 -1
- package/frontend/dist/js/ms-DpsaOPht.js +2 -0
- package/frontend/dist/js/nl-B1d8W22n.js +2 -0
- package/frontend/dist/js/pl-nCncRVgt.js +2 -0
- package/frontend/dist/js/{postcss-B5WIGhAY.js → postcss-Bx9CTcIc.js} +1 -1
- package/frontend/dist/js/pt-DHw8fGuu.js +2 -0
- package/frontend/dist/js/{react-vendor-DPNXrO-8.js → react-vendor-C5yShNlM.js} +1 -1
- package/frontend/dist/js/{router-vendor-Ca9zqOqT.js → router-vendor-CbPDks39.js} +1 -1
- package/frontend/dist/js/ru-Derl_YP_.js +2 -0
- package/frontend/dist/js/{standalone-Dwm1daef.js → standalone-i8-5bg5p.js} +1 -1
- package/frontend/dist/js/sv-pJAfBVo0.js +2 -0
- package/frontend/dist/js/{syntax-highlight-Ca9bHsaz.js → syntax-highlight-3EEX6CGL.js} +3 -3
- package/frontend/dist/js/th-C_7fIGnk.js +2 -0
- package/frontend/dist/js/tr-CPqsJvaP.js +2 -0
- package/frontend/dist/js/{typescript-CwieSptM.js → typescript-CQ3x-Uni.js} +1 -1
- package/frontend/dist/js/{ui-BnDZpjfc.js → ui-BHhR3Vok.js} +2 -2
- package/frontend/dist/js/ui-vendor-D3Ahl1x5.js +177 -0
- package/frontend/dist/js/uk-3o8P_kFi.js +2 -0
- package/frontend/dist/js/{useTranslation-CXY69qNk.js → useTranslation-C3ei3mJq.js} +1 -1
- package/frontend/dist/js/{utils-BM0_0iFj.js → utils-CuC1beTY.js} +1 -1
- package/frontend/dist/js/{utils-vendor-1zob7nK9.js → utils-vendor-BBa8OxtB.js} +1 -1
- package/frontend/dist/js/vi-Dv6N7OVD.js +2 -0
- package/frontend/dist/js/{workApi-BOS7crs9.js → workApi-Czu69yWS.js} +2 -2
- package/frontend/dist/js/{yaml-QD4znPfZ.js → yaml-DioTxVLA.js} +1 -1
- package/frontend/dist/js/zh-qg5iqtPi.js +2 -0
- package/package.json +16 -5
- package/plugins/huggingface.json +12 -3
- package/plugins/llama-cpp.json +18 -6
- package/plugins/longcat-audiodit.json +114 -0
- package/plugins/openai.json +18 -0
- package/frontend/dist/assets/index-BBpNbfKW.js +0 -16
- package/frontend/dist/assets/index-BLATyFmD.css +0 -1
- package/frontend/dist/js/ChatPage-BBayfMLS.js +0 -16
- package/frontend/dist/js/GalleryPage-By8VI39Q.js +0 -1
- package/frontend/dist/js/ModelsPage-ODeXhDDk.js +0 -2
- package/frontend/dist/js/NotesPage-CApzDjOq.js +0 -1
- package/frontend/dist/js/PluginUsagePage-kutS6SOd.js +0 -1
- package/frontend/dist/js/RichMessageContent-g6WT75Te.js +0 -3
- package/frontend/dist/js/SettingsModal-B7z51BCx.js +0 -1
- package/frontend/dist/js/UserManagementPage-D08lM51c.js +0 -1
- package/frontend/dist/js/WorkPage-DdVLefsK.js +0 -6
- package/frontend/dist/js/api-CLEmGcEh.js +0 -14
- package/frontend/dist/js/appStore-CGdhvp9P.js +0 -2
- package/frontend/dist/js/ar-BTmB2WVm.js +0 -2
- package/frontend/dist/js/authStore-Dh3beEOq.js +0 -4
- package/frontend/dist/js/bn-CQnH7YVT.js +0 -2
- package/frontend/dist/js/chatStore-CDeYWL_q.js +0 -3
- package/frontend/dist/js/cs-oTTZkQXr.js +0 -2
- package/frontend/dist/js/da-Br0gB6J6.js +0 -2
- package/frontend/dist/js/de-DE2iztTF.js +0 -2
- package/frontend/dist/js/es-DgthfVtl.js +0 -2
- package/frontend/dist/js/fr-BjxjFwPh.js +0 -2
- package/frontend/dist/js/hi-D1q7E-9N.js +0 -2
- package/frontend/dist/js/id-CDJZqLTF.js +0 -2
- package/frontend/dist/js/is-BU7Um_Tq.js +0 -2
- package/frontend/dist/js/it-CdAxr8P_.js +0 -2
- package/frontend/dist/js/ja-BLbQwz9u.js +0 -2
- package/frontend/dist/js/ko-CY5lpkAe.js +0 -2
- package/frontend/dist/js/markdown-core-DHnR5Hw8.js +0 -16
- package/frontend/dist/js/ms-tQ8AYXEQ.js +0 -2
- package/frontend/dist/js/nl-CRNi2oWT.js +0 -2
- package/frontend/dist/js/pl-CWtFRS_W.js +0 -2
- package/frontend/dist/js/pt-C7SPoLF8.js +0 -2
- package/frontend/dist/js/ru-Dz4AX8xc.js +0 -2
- package/frontend/dist/js/sv-ETy5-boa.js +0 -2
- package/frontend/dist/js/th-DpuMqvxU.js +0 -2
- package/frontend/dist/js/tr-C-1AYAqg.js +0 -2
- package/frontend/dist/js/ui-vendor-xUzKqAXI.js +0 -177
- package/frontend/dist/js/uk-CyS680gr.js +0 -2
- package/frontend/dist/js/vi-BG8HuiTz.js +0 -2
- package/frontend/dist/js/zh-NCs2mkHj.js +0 -2
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Libre WebUI
|
|
3
|
+
* Copyright (C) 2025 Kroonen AI, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at:
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import crypto from 'node:crypto';
|
|
18
|
+
import { assertDurableJobMigrationReady } from '../../persistence/sqliteMigrations.js';
|
|
19
|
+
import { DurableJobError, } from './durableJobTypes.js';
|
|
20
|
+
import { DELETION_LIFECYCLE_RECOVERY_REFERENCE_PREFIX, OWNER_DELETE_CONTENT_JOB_TYPE, OWNER_DELETE_CONTENT_RECOVERABLE_ERROR_CODES, RESOURCE_DELETE_JOB_TYPE, RESOURCE_DELETE_RECOVERABLE_ERROR_CODES, } from './domainJobContracts.js';
|
|
21
|
+
const EXPIRED_REAP_LIMIT = 100;
|
|
22
|
+
const toMetadata = (row) => ({
|
|
23
|
+
id: row.id,
|
|
24
|
+
jobType: row.job_type,
|
|
25
|
+
actorUserId: row.actor_user_id,
|
|
26
|
+
state: row.state,
|
|
27
|
+
priority: row.priority,
|
|
28
|
+
attemptCount: row.attempt_count,
|
|
29
|
+
maxAttempts: row.max_attempts,
|
|
30
|
+
availableAt: row.available_at,
|
|
31
|
+
cancellationRequestedAt: row.cancellation_requested_at,
|
|
32
|
+
progressCurrent: row.progress_current,
|
|
33
|
+
progressTotal: row.progress_total,
|
|
34
|
+
progressMessage: row.progress_message,
|
|
35
|
+
resultReference: row.result_reference,
|
|
36
|
+
errorCode: row.error_code,
|
|
37
|
+
errorSummary: row.error_summary,
|
|
38
|
+
createdAt: row.created_at,
|
|
39
|
+
updatedAt: row.updated_at,
|
|
40
|
+
startedAt: row.started_at,
|
|
41
|
+
finishedAt: row.finished_at,
|
|
42
|
+
});
|
|
43
|
+
const toLease = (row) => {
|
|
44
|
+
if (row.state !== 'running' ||
|
|
45
|
+
row.lease_owner === null ||
|
|
46
|
+
row.lease_expires_at === null) {
|
|
47
|
+
throw new DurableJobError('storage-error', 'Claimed durable job has an invalid lease');
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...toMetadata(row),
|
|
51
|
+
workerId: row.lease_owner,
|
|
52
|
+
leaseToken: row.lease_token,
|
|
53
|
+
leaseExpiresAt: row.lease_expires_at,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const toAttempt = (row) => ({
|
|
57
|
+
jobId: row.job_id,
|
|
58
|
+
attemptNumber: row.attempt_number,
|
|
59
|
+
leaseToken: row.lease_token,
|
|
60
|
+
workerId: row.worker_id,
|
|
61
|
+
startedAt: row.started_at,
|
|
62
|
+
lastHeartbeatAt: row.last_heartbeat_at,
|
|
63
|
+
finishedAt: row.finished_at,
|
|
64
|
+
outcome: row.outcome,
|
|
65
|
+
errorCode: row.error_code,
|
|
66
|
+
errorSummary: row.error_summary,
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* SQLite implementation of the durable job and event-log repository.
|
|
70
|
+
*
|
|
71
|
+
* Every state mutation and its event are committed by one IMMEDIATE
|
|
72
|
+
* transaction. Lease tokens only increase, so a reclaimed worker cannot later
|
|
73
|
+
* heartbeat or complete a job with a stale token.
|
|
74
|
+
*/
|
|
75
|
+
export class SQLiteDurableJobRepository {
|
|
76
|
+
constructor(database, now = Date.now) {
|
|
77
|
+
this.database = database;
|
|
78
|
+
this.now = now;
|
|
79
|
+
assertDurableJobMigrationReady(database);
|
|
80
|
+
}
|
|
81
|
+
immediate(operation) {
|
|
82
|
+
return this.database.transaction(operation).immediate();
|
|
83
|
+
}
|
|
84
|
+
findRow(id) {
|
|
85
|
+
return this.database
|
|
86
|
+
.prepare('SELECT * FROM platform_jobs WHERE id = ?')
|
|
87
|
+
.get(id);
|
|
88
|
+
}
|
|
89
|
+
appendEventInTransaction(input) {
|
|
90
|
+
const existing = this.database
|
|
91
|
+
.prepare(`SELECT global_cursor, request_fingerprint
|
|
92
|
+
FROM platform_events WHERE event_id = ?`)
|
|
93
|
+
.get(input.eventId);
|
|
94
|
+
if (existing) {
|
|
95
|
+
if (existing.request_fingerprint !== input.requestFingerprint) {
|
|
96
|
+
throw new DurableJobError('conflict', 'Durable event identity was reused for different content');
|
|
97
|
+
}
|
|
98
|
+
return existing.global_cursor;
|
|
99
|
+
}
|
|
100
|
+
this.database
|
|
101
|
+
.prepare(`INSERT INTO platform_event_stream_heads (stream_id, last_sequence)
|
|
102
|
+
VALUES (?, 0)
|
|
103
|
+
ON CONFLICT(stream_id) DO NOTHING`)
|
|
104
|
+
.run(input.streamId);
|
|
105
|
+
this.database
|
|
106
|
+
.prepare(`UPDATE platform_event_stream_heads
|
|
107
|
+
SET last_sequence = last_sequence + 1
|
|
108
|
+
WHERE stream_id = ?`)
|
|
109
|
+
.run(input.streamId);
|
|
110
|
+
const head = this.database
|
|
111
|
+
.prepare(`SELECT last_sequence
|
|
112
|
+
FROM platform_event_stream_heads
|
|
113
|
+
WHERE stream_id = ?`)
|
|
114
|
+
.get(input.streamId);
|
|
115
|
+
if (!head || !Number.isSafeInteger(head.last_sequence)) {
|
|
116
|
+
throw new DurableJobError('storage-error', 'Durable event sequence is unavailable');
|
|
117
|
+
}
|
|
118
|
+
const result = this.database
|
|
119
|
+
.prepare(`INSERT INTO platform_events
|
|
120
|
+
(event_id, request_fingerprint, stream_id, stream_sequence, event_type, subject_id,
|
|
121
|
+
actor_user_id, payload_format, payload, occurred_at)
|
|
122
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
123
|
+
.run(input.eventId, input.requestFingerprint, input.streamId, head.last_sequence, input.eventType, input.subjectId, input.actorUserId, input.payload.format, input.payload.data, input.occurredAt);
|
|
124
|
+
const cursor = Number(result.lastInsertRowid);
|
|
125
|
+
if (!Number.isSafeInteger(cursor)) {
|
|
126
|
+
throw new DurableJobError('storage-error', 'Durable event cursor exceeded the supported range');
|
|
127
|
+
}
|
|
128
|
+
return cursor;
|
|
129
|
+
}
|
|
130
|
+
appendJobEvent(job, eventType, occurredAt) {
|
|
131
|
+
this.appendEventInTransaction({
|
|
132
|
+
eventId: crypto.randomUUID(),
|
|
133
|
+
requestFingerprint: crypto
|
|
134
|
+
.createHash('sha256')
|
|
135
|
+
.update(`${job.id}\n${eventType}\n${occurredAt}`)
|
|
136
|
+
.digest('hex'),
|
|
137
|
+
streamId: `job:${job.id}`,
|
|
138
|
+
eventType,
|
|
139
|
+
subjectId: job.id,
|
|
140
|
+
actorUserId: job.actor_user_id,
|
|
141
|
+
payload: { format: 'reference', data: job.id },
|
|
142
|
+
occurredAt,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
enqueue(input) {
|
|
146
|
+
return this.immediate(() => {
|
|
147
|
+
const existing = this.database
|
|
148
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
149
|
+
WHERE actor_user_id = ?
|
|
150
|
+
AND idempotency_scope = ?
|
|
151
|
+
AND idempotency_key_hash = ?`)
|
|
152
|
+
.get(input.actorUserId, input.idempotencyScope, input.idempotencyKeyHash);
|
|
153
|
+
if (existing) {
|
|
154
|
+
if (existing.request_fingerprint !== input.requestFingerprint) {
|
|
155
|
+
throw new DurableJobError('conflict', 'The idempotency key is already bound to a different request');
|
|
156
|
+
}
|
|
157
|
+
return toMetadata(existing);
|
|
158
|
+
}
|
|
159
|
+
const timestamp = this.now();
|
|
160
|
+
this.database
|
|
161
|
+
.prepare(`INSERT INTO platform_jobs
|
|
162
|
+
(id, job_type, actor_user_id, state, payload_format, payload,
|
|
163
|
+
idempotency_scope, idempotency_key_hash, request_fingerprint,
|
|
164
|
+
priority, attempt_count, max_attempts, available_at,
|
|
165
|
+
lease_token, progress_current, progress_total, created_at,
|
|
166
|
+
updated_at)
|
|
167
|
+
VALUES (?, ?, ?, 'queued', ?, ?, ?, ?, ?, ?, 0, ?, ?, 0, 0, 100,
|
|
168
|
+
?, ?)`)
|
|
169
|
+
.run(input.id, input.jobType, input.actorUserId, input.payload.format, input.payload.data, input.idempotencyScope, input.idempotencyKeyHash, input.requestFingerprint, input.priority, input.maxAttempts, input.availableAt, timestamp, timestamp);
|
|
170
|
+
const row = this.findRow(input.id);
|
|
171
|
+
if (!row) {
|
|
172
|
+
throw new DurableJobError('storage-error', 'Durable job insert was not visible');
|
|
173
|
+
}
|
|
174
|
+
this.appendJobEvent(row, 'job.queued', timestamp);
|
|
175
|
+
return toMetadata(row);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
appendEvent(input) {
|
|
179
|
+
return this.immediate(() => this.appendEventInTransaction(input));
|
|
180
|
+
}
|
|
181
|
+
requestChatCancellation(input) {
|
|
182
|
+
return this.immediate(() => {
|
|
183
|
+
const completion = this.database
|
|
184
|
+
.prepare(`SELECT global_cursor FROM platform_events
|
|
185
|
+
WHERE event_id = ? AND stream_id = ?
|
|
186
|
+
AND event_type = 'chat.done.v1'
|
|
187
|
+
AND subject_id = ? AND actor_user_id = ?`)
|
|
188
|
+
.get(input.doneEventId, input.event.streamId, input.event.subjectId, input.actorUserId);
|
|
189
|
+
if (completion) {
|
|
190
|
+
return {
|
|
191
|
+
outcome: 'completion-won',
|
|
192
|
+
cursor: completion.global_cursor,
|
|
193
|
+
job: null,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const cursor = this.appendEventInTransaction(input.event);
|
|
197
|
+
const job = this.database
|
|
198
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
199
|
+
WHERE actor_user_id = ? AND idempotency_scope = ?
|
|
200
|
+
AND idempotency_key_hash = ?`)
|
|
201
|
+
.get(input.actorUserId, input.idempotencyScope, input.idempotencyKeyHash);
|
|
202
|
+
return {
|
|
203
|
+
outcome: 'cancellation-recorded',
|
|
204
|
+
cursor,
|
|
205
|
+
job: job
|
|
206
|
+
? this.requestCancellationInTransaction(job.id, input.actorUserId, 'user-requested')
|
|
207
|
+
: null,
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Linearize the assistant row and its terminal event under the durable job
|
|
213
|
+
* fence. A worker crash can therefore expose both effects or neither.
|
|
214
|
+
*/
|
|
215
|
+
publishChatCompletion(input) {
|
|
216
|
+
return this.immediate(() => {
|
|
217
|
+
const timestamp = this.now();
|
|
218
|
+
const job = this.findRow(input.lease.jobId);
|
|
219
|
+
if (!job) {
|
|
220
|
+
throw new DurableJobError('lease-lost', 'Durable job lease was lost');
|
|
221
|
+
}
|
|
222
|
+
if (job.actor_user_id !== input.actorUserId ||
|
|
223
|
+
job.job_type !== input.expectedJobType ||
|
|
224
|
+
job.idempotency_scope !== input.expectedIdempotencyScope ||
|
|
225
|
+
job.idempotency_key_hash !== input.expectedIdempotencyKeyHash) {
|
|
226
|
+
throw new DurableJobError('conflict', 'Chat completion does not match its durable job');
|
|
227
|
+
}
|
|
228
|
+
if (job.cancellation_requested_at !== null) {
|
|
229
|
+
throw new DurableJobError('cancelled', 'Durable job was cancelled');
|
|
230
|
+
}
|
|
231
|
+
if (job.state !== 'running' ||
|
|
232
|
+
job.lease_owner !== input.lease.workerId ||
|
|
233
|
+
job.lease_token !== input.lease.leaseToken ||
|
|
234
|
+
job.lease_expires_at === null ||
|
|
235
|
+
job.lease_expires_at <= timestamp) {
|
|
236
|
+
throw new DurableJobError('lease-lost', 'Durable job lease was lost');
|
|
237
|
+
}
|
|
238
|
+
const session = this.database
|
|
239
|
+
.prepare('SELECT user_id FROM sessions WHERE id = ?')
|
|
240
|
+
.get(input.sessionId);
|
|
241
|
+
if (!session || session.user_id !== input.actorUserId) {
|
|
242
|
+
throw new DurableJobError('conflict', 'Chat completion session is unavailable');
|
|
243
|
+
}
|
|
244
|
+
if (input.message.sessionId !== input.sessionId) {
|
|
245
|
+
throw new DurableJobError('conflict', 'Chat completion message does not match its session');
|
|
246
|
+
}
|
|
247
|
+
const cancellation = this.database
|
|
248
|
+
.prepare(`SELECT 1 FROM platform_events
|
|
249
|
+
WHERE event_id = ? AND stream_id = ?
|
|
250
|
+
AND event_type = 'chat.cancel-requested.v1'
|
|
251
|
+
AND subject_id = ? AND actor_user_id = ?`)
|
|
252
|
+
.get(input.cancellationEventId, input.event.streamId, input.message.id, input.actorUserId);
|
|
253
|
+
if (cancellation) {
|
|
254
|
+
throw new DurableJobError('cancelled', 'Durable job was cancelled');
|
|
255
|
+
}
|
|
256
|
+
const existingEvent = this.database
|
|
257
|
+
.prepare('SELECT 1 FROM platform_events WHERE event_id = ?')
|
|
258
|
+
.get(input.event.eventId);
|
|
259
|
+
const existingMessage = this.database
|
|
260
|
+
.prepare('SELECT role FROM session_messages WHERE id = ? AND session_id = ?')
|
|
261
|
+
.get(input.message.id, input.sessionId);
|
|
262
|
+
if (existingEvent) {
|
|
263
|
+
if (!existingMessage || existingMessage.role !== 'assistant') {
|
|
264
|
+
throw new DurableJobError('storage-error', 'Durable chat completion event has no assistant message');
|
|
265
|
+
}
|
|
266
|
+
return this.appendEventInTransaction(input.event);
|
|
267
|
+
}
|
|
268
|
+
if (existingMessage) {
|
|
269
|
+
throw new DurableJobError('conflict', 'Assistant message identity already exists without completion');
|
|
270
|
+
}
|
|
271
|
+
let branchIndex = 0;
|
|
272
|
+
if (input.message.parentId) {
|
|
273
|
+
const branchRoot = this.database
|
|
274
|
+
.prepare(`SELECT role FROM session_messages
|
|
275
|
+
WHERE id = ? AND session_id = ?`)
|
|
276
|
+
.get(input.message.parentId, input.sessionId);
|
|
277
|
+
if (branchRoot?.role !== 'assistant') {
|
|
278
|
+
throw new DurableJobError('conflict', 'Chat completion branch root is unavailable');
|
|
279
|
+
}
|
|
280
|
+
const branch = this.database
|
|
281
|
+
.prepare(`SELECT COALESCE(MAX(branch_index), 0) + 1 AS next_index
|
|
282
|
+
FROM session_messages
|
|
283
|
+
WHERE session_id = ? AND (id = ? OR parent_id = ?)`)
|
|
284
|
+
.get(input.sessionId, input.message.parentId, input.message.parentId);
|
|
285
|
+
branchIndex = branch.next_index;
|
|
286
|
+
this.database
|
|
287
|
+
.prepare(`UPDATE session_messages SET is_active = 0
|
|
288
|
+
WHERE session_id = ? AND (id = ? OR parent_id = ?)`)
|
|
289
|
+
.run(input.sessionId, input.message.parentId, input.message.parentId);
|
|
290
|
+
}
|
|
291
|
+
const position = this.database
|
|
292
|
+
.prepare(`SELECT COALESCE(MAX(message_index), -1) + 1 AS next_index
|
|
293
|
+
FROM session_messages WHERE session_id = ?`)
|
|
294
|
+
.get(input.sessionId);
|
|
295
|
+
this.database
|
|
296
|
+
.prepare(`INSERT INTO session_messages
|
|
297
|
+
(id, session_id, role, content, thinking, timestamp, message_index,
|
|
298
|
+
model, provider_metadata, images, statistics, artifacts,
|
|
299
|
+
parent_id, branch_index, is_active, rating)
|
|
300
|
+
VALUES (?, ?, 'assistant', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
301
|
+
.run(input.message.id, input.sessionId, input.message.content, input.message.thinking, input.message.timestamp, position.next_index, input.message.model, input.message.providerMetadata, input.message.images, input.message.statistics, input.message.artifacts, input.message.parentId, branchIndex, input.message.parentId ? 1 : input.message.isActive, input.message.rating);
|
|
302
|
+
this.database
|
|
303
|
+
.prepare(`UPDATE sessions SET updated_at = MAX(updated_at, ?)
|
|
304
|
+
WHERE id = ? AND user_id = ?`)
|
|
305
|
+
.run(timestamp, input.sessionId, input.actorUserId);
|
|
306
|
+
const completionCursor = this.appendEventInTransaction(input.event);
|
|
307
|
+
if (this.finishAttempt(job, 'succeeded', timestamp) !== 1) {
|
|
308
|
+
throw new DurableJobError('lease-lost', 'Durable job attempt was lost');
|
|
309
|
+
}
|
|
310
|
+
const resultReference = `chat-message:${input.message.id}`;
|
|
311
|
+
const terminal = this.database
|
|
312
|
+
.prepare(`UPDATE platform_jobs
|
|
313
|
+
SET state = 'succeeded', result_reference = ?,
|
|
314
|
+
lease_owner = NULL, lease_expires_at = NULL,
|
|
315
|
+
progress_current = progress_total,
|
|
316
|
+
progress_message = 'Chat response saved',
|
|
317
|
+
finished_at = ?, updated_at = ?
|
|
318
|
+
WHERE id = ? AND state = 'running' AND lease_owner = ?
|
|
319
|
+
AND lease_token = ? AND lease_expires_at > ?
|
|
320
|
+
AND actor_user_id = ? AND job_type = ?
|
|
321
|
+
AND idempotency_scope = ? AND idempotency_key_hash = ?
|
|
322
|
+
AND cancellation_requested_at IS NULL`)
|
|
323
|
+
.run(resultReference, timestamp, timestamp, job.id, input.lease.workerId, input.lease.leaseToken, timestamp, input.actorUserId, input.expectedJobType, input.expectedIdempotencyScope, input.expectedIdempotencyKeyHash);
|
|
324
|
+
if (terminal.changes !== 1) {
|
|
325
|
+
throw new DurableJobError('lease-lost', 'Durable job lease was lost');
|
|
326
|
+
}
|
|
327
|
+
this.appendJobEvent(job, 'job.succeeded', timestamp);
|
|
328
|
+
return completionCursor;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
finishAttempt(job, outcome, timestamp, errorCode = null, errorSummary = null) {
|
|
332
|
+
return this.database
|
|
333
|
+
.prepare(`UPDATE platform_job_attempts
|
|
334
|
+
SET last_heartbeat_at = ?, finished_at = ?, outcome = ?,
|
|
335
|
+
error_code = ?, error_summary = ?
|
|
336
|
+
WHERE job_id = ? AND attempt_number = ? AND lease_token = ?
|
|
337
|
+
AND outcome = 'running'`)
|
|
338
|
+
.run(timestamp, timestamp, outcome, errorCode, errorSummary, job.id, job.attempt_count, job.lease_token).changes;
|
|
339
|
+
}
|
|
340
|
+
reapExpired(timestamp) {
|
|
341
|
+
const rows = this.database
|
|
342
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
343
|
+
WHERE state = 'running'
|
|
344
|
+
AND lease_expires_at <= ?
|
|
345
|
+
AND (cancellation_requested_at IS NOT NULL
|
|
346
|
+
OR attempt_count >= max_attempts)
|
|
347
|
+
ORDER BY lease_expires_at ASC, id ASC
|
|
348
|
+
LIMIT ?`)
|
|
349
|
+
.all(timestamp, EXPIRED_REAP_LIMIT);
|
|
350
|
+
const terminalLifecycleJobIds = [];
|
|
351
|
+
for (const row of rows) {
|
|
352
|
+
const cancelled = row.cancellation_requested_at !== null;
|
|
353
|
+
const state = cancelled ? 'cancelled' : 'dead_letter';
|
|
354
|
+
const errorCode = cancelled ? null : 'lease-expired';
|
|
355
|
+
const errorSummary = cancelled
|
|
356
|
+
? null
|
|
357
|
+
: 'The worker lease expired at the retry ceiling';
|
|
358
|
+
this.database
|
|
359
|
+
.prepare(`UPDATE platform_jobs
|
|
360
|
+
SET state = ?, lease_owner = NULL, lease_expires_at = NULL,
|
|
361
|
+
finished_at = ?, updated_at = ?, error_code = ?,
|
|
362
|
+
error_summary = ?
|
|
363
|
+
WHERE id = ? AND state = 'running' AND lease_token = ?`)
|
|
364
|
+
.run(state, timestamp, timestamp, errorCode, errorSummary, row.id, row.lease_token);
|
|
365
|
+
this.finishAttempt(row, cancelled ? 'cancelled' : 'dead_letter', timestamp, errorCode, errorSummary);
|
|
366
|
+
this.appendJobEvent(row, cancelled ? 'job.cancelled' : 'job.dead-lettered', timestamp);
|
|
367
|
+
if (row.job_type === RESOURCE_DELETE_JOB_TYPE ||
|
|
368
|
+
row.job_type === OWNER_DELETE_CONTENT_JOB_TYPE) {
|
|
369
|
+
terminalLifecycleJobIds.push(row.id);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return terminalLifecycleJobIds;
|
|
373
|
+
}
|
|
374
|
+
claimWithLifecycleRecovery(workerId, leaseMs) {
|
|
375
|
+
return this.immediate(() => {
|
|
376
|
+
const timestamp = this.now();
|
|
377
|
+
const terminalLifecycleJobIds = this.reapExpired(timestamp);
|
|
378
|
+
const candidate = this.database
|
|
379
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
380
|
+
WHERE cancellation_requested_at IS NULL
|
|
381
|
+
AND ((state = 'queued' AND available_at <= ?)
|
|
382
|
+
OR (state = 'running' AND lease_expires_at <= ?
|
|
383
|
+
AND attempt_count < max_attempts))
|
|
384
|
+
ORDER BY priority DESC, available_at ASC, created_at ASC, id ASC
|
|
385
|
+
LIMIT 1`)
|
|
386
|
+
.get(timestamp, timestamp);
|
|
387
|
+
if (!candidate)
|
|
388
|
+
return { lease: null, terminalLifecycleJobIds };
|
|
389
|
+
if (candidate.state === 'running') {
|
|
390
|
+
this.finishAttempt(candidate, 'abandoned', timestamp);
|
|
391
|
+
}
|
|
392
|
+
const nextAttempt = candidate.attempt_count + 1;
|
|
393
|
+
const nextToken = candidate.lease_token + 1;
|
|
394
|
+
const expiresAt = timestamp + leaseMs;
|
|
395
|
+
const result = this.database
|
|
396
|
+
.prepare(`UPDATE platform_jobs
|
|
397
|
+
SET state = 'running', attempt_count = ?, lease_owner = ?,
|
|
398
|
+
lease_token = ?, lease_expires_at = ?,
|
|
399
|
+
started_at = COALESCE(started_at, ?), updated_at = ?,
|
|
400
|
+
error_code = NULL, error_summary = NULL
|
|
401
|
+
WHERE id = ? AND lease_token = ?
|
|
402
|
+
AND ((state = 'queued' AND available_at <= ?)
|
|
403
|
+
OR (state = 'running' AND lease_expires_at <= ?))`)
|
|
404
|
+
.run(nextAttempt, workerId, nextToken, expiresAt, timestamp, timestamp, candidate.id, candidate.lease_token, timestamp, timestamp);
|
|
405
|
+
if (result.changes !== 1) {
|
|
406
|
+
return { lease: null, terminalLifecycleJobIds };
|
|
407
|
+
}
|
|
408
|
+
this.database
|
|
409
|
+
.prepare(`INSERT INTO platform_job_attempts
|
|
410
|
+
(job_id, attempt_number, lease_token, worker_id, started_at,
|
|
411
|
+
last_heartbeat_at, outcome)
|
|
412
|
+
VALUES (?, ?, ?, ?, ?, ?, 'running')`)
|
|
413
|
+
.run(candidate.id, nextAttempt, nextToken, workerId, timestamp, timestamp);
|
|
414
|
+
const claimed = this.findRow(candidate.id);
|
|
415
|
+
if (!claimed) {
|
|
416
|
+
throw new DurableJobError('storage-error', 'Claimed durable job disappeared');
|
|
417
|
+
}
|
|
418
|
+
this.appendJobEvent(claimed, 'job.claimed', timestamp);
|
|
419
|
+
return { lease: toLease(claimed), terminalLifecycleJobIds };
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
claim(workerId, leaseMs) {
|
|
423
|
+
return this.claimWithLifecycleRecovery(workerId, leaseMs).lease;
|
|
424
|
+
}
|
|
425
|
+
heartbeat(lease, leaseMs) {
|
|
426
|
+
return this.immediate(() => {
|
|
427
|
+
const timestamp = this.now();
|
|
428
|
+
const expiresAt = timestamp + leaseMs;
|
|
429
|
+
const result = this.database
|
|
430
|
+
.prepare(`UPDATE platform_jobs
|
|
431
|
+
SET lease_expires_at = ?, updated_at = ?
|
|
432
|
+
WHERE id = ? AND state = 'running' AND lease_owner = ?
|
|
433
|
+
AND lease_token = ? AND lease_expires_at > ?`)
|
|
434
|
+
.run(expiresAt, timestamp, lease.id, lease.workerId, lease.leaseToken, timestamp);
|
|
435
|
+
if (result.changes !== 1) {
|
|
436
|
+
return { owned: false, cancellationRequested: false };
|
|
437
|
+
}
|
|
438
|
+
this.database
|
|
439
|
+
.prepare(`UPDATE platform_job_attempts
|
|
440
|
+
SET last_heartbeat_at = ?
|
|
441
|
+
WHERE job_id = ? AND attempt_number = ? AND lease_token = ?
|
|
442
|
+
AND outcome = 'running'`)
|
|
443
|
+
.run(timestamp, lease.id, lease.attemptCount, lease.leaseToken);
|
|
444
|
+
const row = this.findRow(lease.id);
|
|
445
|
+
return {
|
|
446
|
+
owned: true,
|
|
447
|
+
cancellationRequested: row?.cancellation_requested_at !== null,
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Read-only ownership and cancellation check. Unlike heartbeat this never
|
|
453
|
+
* extends the lease and never writes, so hot paths can call it per side
|
|
454
|
+
* effect without paying a transaction commit.
|
|
455
|
+
*/
|
|
456
|
+
inspectLease(lease) {
|
|
457
|
+
const timestamp = this.now();
|
|
458
|
+
const row = this.database
|
|
459
|
+
.prepare(`SELECT state, lease_owner, lease_token, lease_expires_at,
|
|
460
|
+
cancellation_requested_at
|
|
461
|
+
FROM platform_jobs WHERE id = ?`)
|
|
462
|
+
.get(lease.id);
|
|
463
|
+
const owned = Boolean(row &&
|
|
464
|
+
row.state === 'running' &&
|
|
465
|
+
row.lease_owner === lease.workerId &&
|
|
466
|
+
row.lease_token === lease.leaseToken &&
|
|
467
|
+
typeof row.lease_expires_at === 'number' &&
|
|
468
|
+
row.lease_expires_at > timestamp);
|
|
469
|
+
return {
|
|
470
|
+
owned,
|
|
471
|
+
cancellationRequested: owned
|
|
472
|
+
? row.cancellation_requested_at !== null
|
|
473
|
+
: false,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* `global_cursor` is autoincrement and `occurred_at` comes from the same
|
|
478
|
+
* clock that orders appends, so the oldest row by cursor is also the oldest
|
|
479
|
+
* by time. The probe keeps an idle sweep at one row read instead of a scan.
|
|
480
|
+
*/
|
|
481
|
+
oldestEventOccurredAt(eventType) {
|
|
482
|
+
const row = this.database
|
|
483
|
+
.prepare(`SELECT occurred_at FROM platform_events
|
|
484
|
+
${eventType ? 'WHERE event_type = ?' : ''}
|
|
485
|
+
ORDER BY global_cursor ASC LIMIT 1`)
|
|
486
|
+
.get(...(eventType ? [eventType] : []));
|
|
487
|
+
return row?.occurred_at;
|
|
488
|
+
}
|
|
489
|
+
deleteOldestEvents(cutoff, limit, eventType) {
|
|
490
|
+
const oldest = this.oldestEventOccurredAt(eventType);
|
|
491
|
+
if (oldest === undefined || oldest >= cutoff)
|
|
492
|
+
return 0;
|
|
493
|
+
return this.immediate(() => this.database
|
|
494
|
+
.prepare(`DELETE FROM platform_events
|
|
495
|
+
WHERE global_cursor IN (
|
|
496
|
+
SELECT global_cursor FROM platform_events
|
|
497
|
+
WHERE ${eventType ? 'event_type = ? AND ' : ''}occurred_at < ?
|
|
498
|
+
ORDER BY global_cursor ASC LIMIT ?
|
|
499
|
+
)`)
|
|
500
|
+
.run(...(eventType ? [eventType] : []), cutoff, limit).changes);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Bounded removal of aged history. Chat stream chunks are transient live
|
|
504
|
+
* catch-up transport and dominate volume, so they get their own shorter
|
|
505
|
+
* window. Deletion-lifecycle job types are excluded: their terminal rows
|
|
506
|
+
* feed cleanup recovery and are reconciled by their own path.
|
|
507
|
+
*/
|
|
508
|
+
pruneHistory(input) {
|
|
509
|
+
const chatStreamEvents = this.deleteOldestEvents(input.chatStreamEventCutoff, input.limit, 'chat.stream.v1');
|
|
510
|
+
const events = this.deleteOldestEvents(input.eventCutoff, input.limit);
|
|
511
|
+
const jobs = this.immediate(() => this.database
|
|
512
|
+
.prepare(`DELETE FROM platform_jobs
|
|
513
|
+
WHERE id IN (
|
|
514
|
+
SELECT id FROM platform_jobs
|
|
515
|
+
WHERE state IN ('succeeded', 'cancelled', 'dead_letter')
|
|
516
|
+
AND job_type NOT IN (?, ?)
|
|
517
|
+
AND finished_at IS NOT NULL
|
|
518
|
+
AND finished_at < ?
|
|
519
|
+
LIMIT ?
|
|
520
|
+
)`)
|
|
521
|
+
.run(RESOURCE_DELETE_JOB_TYPE, OWNER_DELETE_CONTENT_JOB_TYPE, input.jobCutoff, input.limit).changes);
|
|
522
|
+
return { chatStreamEvents, events, jobs };
|
|
523
|
+
}
|
|
524
|
+
/** Remove one finished stream and its head; events cascade with the head. */
|
|
525
|
+
deleteEventStream(streamId) {
|
|
526
|
+
return this.immediate(() => {
|
|
527
|
+
const events = this.database
|
|
528
|
+
.prepare(`DELETE FROM platform_events WHERE stream_id = ?`)
|
|
529
|
+
.run(streamId).changes;
|
|
530
|
+
this.database
|
|
531
|
+
.prepare(`DELETE FROM platform_event_stream_heads WHERE stream_id = ?`)
|
|
532
|
+
.run(streamId);
|
|
533
|
+
return events;
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
updateProgress(lease, current, total, message) {
|
|
537
|
+
const timestamp = this.now();
|
|
538
|
+
const result = this.database
|
|
539
|
+
.prepare(`UPDATE platform_jobs
|
|
540
|
+
SET progress_current = ?, progress_total = ?, progress_message = ?,
|
|
541
|
+
updated_at = ?
|
|
542
|
+
WHERE id = ? AND state = 'running' AND lease_owner = ?
|
|
543
|
+
AND lease_token = ? AND lease_expires_at > ?`)
|
|
544
|
+
.run(current, total, message, timestamp, lease.id, lease.workerId, lease.leaseToken, timestamp);
|
|
545
|
+
if (result.changes !== 1) {
|
|
546
|
+
throw new DurableJobError('lease-lost', 'The durable job lease was lost');
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
complete(lease, resultReference) {
|
|
550
|
+
this.immediate(() => {
|
|
551
|
+
const timestamp = this.now();
|
|
552
|
+
const row = this.findRow(lease.id);
|
|
553
|
+
if (!row ||
|
|
554
|
+
row.state !== 'running' ||
|
|
555
|
+
row.lease_owner !== lease.workerId ||
|
|
556
|
+
row.lease_token !== lease.leaseToken ||
|
|
557
|
+
row.lease_expires_at === null ||
|
|
558
|
+
row.lease_expires_at <= timestamp) {
|
|
559
|
+
throw new DurableJobError('lease-lost', 'The durable job lease was lost');
|
|
560
|
+
}
|
|
561
|
+
const cancelled = row.cancellation_requested_at !== null;
|
|
562
|
+
this.database
|
|
563
|
+
.prepare(`UPDATE platform_jobs
|
|
564
|
+
SET state = ?, lease_owner = NULL, lease_expires_at = NULL,
|
|
565
|
+
result_reference = ?, progress_current = progress_total,
|
|
566
|
+
finished_at = ?, updated_at = ?
|
|
567
|
+
WHERE id = ? AND state = 'running' AND lease_owner = ?
|
|
568
|
+
AND lease_token = ? AND lease_expires_at > ?`)
|
|
569
|
+
.run(cancelled ? 'cancelled' : 'succeeded', cancelled ? null : resultReference, timestamp, timestamp, row.id, lease.workerId, lease.leaseToken, timestamp);
|
|
570
|
+
this.finishAttempt(row, cancelled ? 'cancelled' : 'succeeded', timestamp);
|
|
571
|
+
this.appendJobEvent(row, cancelled ? 'job.cancelled' : 'job.succeeded', timestamp);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
fail(lease, retryable, errorCode, errorSummary, nextAvailableAt) {
|
|
575
|
+
return this.immediate(() => {
|
|
576
|
+
const timestamp = this.now();
|
|
577
|
+
const row = this.findRow(lease.id);
|
|
578
|
+
if (!row ||
|
|
579
|
+
row.state !== 'running' ||
|
|
580
|
+
row.lease_owner !== lease.workerId ||
|
|
581
|
+
row.lease_token !== lease.leaseToken ||
|
|
582
|
+
row.lease_expires_at === null ||
|
|
583
|
+
row.lease_expires_at <= timestamp) {
|
|
584
|
+
throw new DurableJobError('lease-lost', 'The durable job lease was lost');
|
|
585
|
+
}
|
|
586
|
+
const cancelled = row.cancellation_requested_at !== null;
|
|
587
|
+
const willRetry = !cancelled && retryable && row.attempt_count < row.max_attempts;
|
|
588
|
+
const state = cancelled
|
|
589
|
+
? 'cancelled'
|
|
590
|
+
: willRetry
|
|
591
|
+
? 'queued'
|
|
592
|
+
: 'dead_letter';
|
|
593
|
+
const finalErrorCode = cancelled ? null : errorCode;
|
|
594
|
+
const finalErrorSummary = cancelled ? null : errorSummary;
|
|
595
|
+
this.database
|
|
596
|
+
.prepare(`UPDATE platform_jobs
|
|
597
|
+
SET state = ?, available_at = ?, lease_owner = NULL,
|
|
598
|
+
lease_expires_at = NULL, error_code = ?, error_summary = ?,
|
|
599
|
+
finished_at = ?, updated_at = ?
|
|
600
|
+
WHERE id = ? AND state = 'running' AND lease_owner = ?
|
|
601
|
+
AND lease_token = ? AND lease_expires_at > ?`)
|
|
602
|
+
.run(state, willRetry ? nextAvailableAt : row.available_at, finalErrorCode, finalErrorSummary, willRetry ? null : timestamp, timestamp, row.id, lease.workerId, lease.leaseToken, timestamp);
|
|
603
|
+
this.finishAttempt(row, cancelled ? 'cancelled' : willRetry ? 'retry_scheduled' : 'dead_letter', timestamp, finalErrorCode, finalErrorSummary);
|
|
604
|
+
this.appendJobEvent(row, cancelled
|
|
605
|
+
? 'job.cancelled'
|
|
606
|
+
: willRetry
|
|
607
|
+
? 'job.retry-scheduled'
|
|
608
|
+
: 'job.dead-lettered', timestamp);
|
|
609
|
+
return state;
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
abandon(lease) {
|
|
613
|
+
return this.fail(lease, true, 'worker-shutdown', 'The worker stopped before completing the attempt', this.now());
|
|
614
|
+
}
|
|
615
|
+
requestCancellationInTransaction(id, actorUserId, reason) {
|
|
616
|
+
const timestamp = this.now();
|
|
617
|
+
const row = this.findRow(id);
|
|
618
|
+
if (!row || row.actor_user_id !== actorUserId) {
|
|
619
|
+
throw new DurableJobError('not-found', 'Durable job not found');
|
|
620
|
+
}
|
|
621
|
+
if (row.state === 'succeeded' ||
|
|
622
|
+
row.state === 'cancelled' ||
|
|
623
|
+
row.state === 'dead_letter') {
|
|
624
|
+
return toMetadata(row);
|
|
625
|
+
}
|
|
626
|
+
if (row.cancellation_requested_at !== null)
|
|
627
|
+
return toMetadata(row);
|
|
628
|
+
if (row.state === 'queued') {
|
|
629
|
+
this.database
|
|
630
|
+
.prepare(`UPDATE platform_jobs
|
|
631
|
+
SET state = 'cancelled', cancellation_requested_at = ?,
|
|
632
|
+
cancellation_reason = ?, finished_at = ?, updated_at = ?
|
|
633
|
+
WHERE id = ? AND state = 'queued'`)
|
|
634
|
+
.run(timestamp, reason, timestamp, timestamp, id);
|
|
635
|
+
this.appendJobEvent(row, 'job.cancelled', timestamp);
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
this.database
|
|
639
|
+
.prepare(`UPDATE platform_jobs
|
|
640
|
+
SET cancellation_requested_at = ?, cancellation_reason = ?,
|
|
641
|
+
updated_at = ?
|
|
642
|
+
WHERE id = ? AND state = 'running'`)
|
|
643
|
+
.run(timestamp, reason, timestamp, id);
|
|
644
|
+
this.appendJobEvent(row, 'job.cancellation-requested', timestamp);
|
|
645
|
+
}
|
|
646
|
+
const updated = this.findRow(id);
|
|
647
|
+
if (!updated) {
|
|
648
|
+
throw new DurableJobError('storage-error', 'Cancelled durable job disappeared');
|
|
649
|
+
}
|
|
650
|
+
return toMetadata(updated);
|
|
651
|
+
}
|
|
652
|
+
requestCancellation(id, actorUserId, reason) {
|
|
653
|
+
return this.immediate(() => this.requestCancellationInTransaction(id, actorUserId, reason));
|
|
654
|
+
}
|
|
655
|
+
requestActorCancellation(actorUserId, reason, filter = {}) {
|
|
656
|
+
return this.immediate(() => {
|
|
657
|
+
const clauses = [
|
|
658
|
+
'actor_user_id = ?',
|
|
659
|
+
"state IN ('queued', 'running')",
|
|
660
|
+
'cancellation_requested_at IS NULL',
|
|
661
|
+
];
|
|
662
|
+
const bindings = [actorUserId];
|
|
663
|
+
if (filter.jobTypes && filter.jobTypes.length > 0) {
|
|
664
|
+
clauses.push(`job_type IN (${filter.jobTypes.map(() => '?').join(', ')})`);
|
|
665
|
+
bindings.push(...filter.jobTypes);
|
|
666
|
+
}
|
|
667
|
+
if (filter.excludeJobTypes && filter.excludeJobTypes.length > 0) {
|
|
668
|
+
clauses.push(`job_type NOT IN (${filter.excludeJobTypes.map(() => '?').join(', ')})`);
|
|
669
|
+
bindings.push(...filter.excludeJobTypes);
|
|
670
|
+
}
|
|
671
|
+
if (filter.idempotencyScopes && filter.idempotencyScopes.length > 0) {
|
|
672
|
+
clauses.push(`idempotency_scope IN (${filter.idempotencyScopes.map(() => '?').join(', ')})`);
|
|
673
|
+
bindings.push(...filter.idempotencyScopes);
|
|
674
|
+
}
|
|
675
|
+
if (filter.excludeJobIds && filter.excludeJobIds.length > 0) {
|
|
676
|
+
clauses.push(`id NOT IN (${filter.excludeJobIds.map(() => '?').join(', ')})`);
|
|
677
|
+
bindings.push(...filter.excludeJobIds);
|
|
678
|
+
}
|
|
679
|
+
const rows = this.database
|
|
680
|
+
.prepare(`SELECT * FROM platform_jobs WHERE ${clauses.join(' AND ')}`)
|
|
681
|
+
.all(...bindings);
|
|
682
|
+
const timestamp = this.now();
|
|
683
|
+
let cancelledQueued = 0;
|
|
684
|
+
let cancellationRequestedRunning = 0;
|
|
685
|
+
for (const row of rows) {
|
|
686
|
+
if (row.state === 'queued') {
|
|
687
|
+
const result = this.database
|
|
688
|
+
.prepare(`UPDATE platform_jobs
|
|
689
|
+
SET state = 'cancelled', cancellation_requested_at = ?,
|
|
690
|
+
cancellation_reason = ?, finished_at = ?, updated_at = ?
|
|
691
|
+
WHERE id = ? AND state = 'queued'
|
|
692
|
+
AND cancellation_requested_at IS NULL`)
|
|
693
|
+
.run(timestamp, reason, timestamp, timestamp, row.id);
|
|
694
|
+
if (result.changes === 1) {
|
|
695
|
+
cancelledQueued += 1;
|
|
696
|
+
this.appendJobEvent(row, 'job.cancelled', timestamp);
|
|
697
|
+
}
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const result = this.database
|
|
701
|
+
.prepare(`UPDATE platform_jobs
|
|
702
|
+
SET cancellation_requested_at = ?, cancellation_reason = ?,
|
|
703
|
+
updated_at = ?
|
|
704
|
+
WHERE id = ? AND state = 'running'
|
|
705
|
+
AND cancellation_requested_at IS NULL`)
|
|
706
|
+
.run(timestamp, reason, timestamp, row.id);
|
|
707
|
+
if (result.changes === 1) {
|
|
708
|
+
cancellationRequestedRunning += 1;
|
|
709
|
+
this.appendJobEvent(row, 'job.cancellation-requested', timestamp);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return { cancelledQueued, cancellationRequestedRunning };
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
countActiveForActor(actorUserId, filter = {}) {
|
|
716
|
+
const clauses = ['actor_user_id = ?', "state IN ('queued', 'running')"];
|
|
717
|
+
const bindings = [actorUserId];
|
|
718
|
+
if (filter.jobTypes && filter.jobTypes.length > 0) {
|
|
719
|
+
clauses.push(`job_type IN (${filter.jobTypes.map(() => '?').join(', ')})`);
|
|
720
|
+
bindings.push(...filter.jobTypes);
|
|
721
|
+
}
|
|
722
|
+
if (filter.excludeJobTypes && filter.excludeJobTypes.length > 0) {
|
|
723
|
+
clauses.push(`job_type NOT IN (${filter.excludeJobTypes.map(() => '?').join(', ')})`);
|
|
724
|
+
bindings.push(...filter.excludeJobTypes);
|
|
725
|
+
}
|
|
726
|
+
if (filter.idempotencyScopes && filter.idempotencyScopes.length > 0) {
|
|
727
|
+
clauses.push(`idempotency_scope IN (${filter.idempotencyScopes.map(() => '?').join(', ')})`);
|
|
728
|
+
bindings.push(...filter.idempotencyScopes);
|
|
729
|
+
}
|
|
730
|
+
if (filter.excludeJobIds && filter.excludeJobIds.length > 0) {
|
|
731
|
+
clauses.push(`id NOT IN (${filter.excludeJobIds.map(() => '?').join(', ')})`);
|
|
732
|
+
bindings.push(...filter.excludeJobIds);
|
|
733
|
+
}
|
|
734
|
+
const row = this.database
|
|
735
|
+
.prepare(`SELECT COUNT(*) AS count FROM platform_jobs WHERE ${clauses.join(' AND ')}`)
|
|
736
|
+
.get(...bindings);
|
|
737
|
+
return row.count;
|
|
738
|
+
}
|
|
739
|
+
countNonSucceededForActor(actorUserId, filter = {}) {
|
|
740
|
+
const clauses = ['actor_user_id = ?', "state <> 'succeeded'"];
|
|
741
|
+
const bindings = [actorUserId];
|
|
742
|
+
if (filter.jobTypes && filter.jobTypes.length > 0) {
|
|
743
|
+
clauses.push(`job_type IN (${filter.jobTypes.map(() => '?').join(', ')})`);
|
|
744
|
+
bindings.push(...filter.jobTypes);
|
|
745
|
+
}
|
|
746
|
+
if (filter.excludeJobTypes && filter.excludeJobTypes.length > 0) {
|
|
747
|
+
clauses.push(`job_type NOT IN (${filter.excludeJobTypes.map(() => '?').join(', ')})`);
|
|
748
|
+
bindings.push(...filter.excludeJobTypes);
|
|
749
|
+
}
|
|
750
|
+
if (filter.idempotencyScopes && filter.idempotencyScopes.length > 0) {
|
|
751
|
+
clauses.push(`idempotency_scope IN (${filter.idempotencyScopes.map(() => '?').join(', ')})`);
|
|
752
|
+
bindings.push(...filter.idempotencyScopes);
|
|
753
|
+
}
|
|
754
|
+
if (filter.excludeJobIds && filter.excludeJobIds.length > 0) {
|
|
755
|
+
clauses.push(`id NOT IN (${filter.excludeJobIds.map(() => '?').join(', ')})`);
|
|
756
|
+
bindings.push(...filter.excludeJobIds);
|
|
757
|
+
}
|
|
758
|
+
if (filter.excludeHandledLifecycleJobs) {
|
|
759
|
+
clauses.push(`NOT (
|
|
760
|
+
job_type IN (?, ?)
|
|
761
|
+
AND state IN ('cancelled', 'dead_letter')
|
|
762
|
+
AND result_reference LIKE ?
|
|
763
|
+
)`);
|
|
764
|
+
bindings.push(RESOURCE_DELETE_JOB_TYPE, OWNER_DELETE_CONTENT_JOB_TYPE, `${DELETION_LIFECYCLE_RECOVERY_REFERENCE_PREFIX}%`);
|
|
765
|
+
}
|
|
766
|
+
const row = this.database
|
|
767
|
+
.prepare(`SELECT COUNT(*) AS count FROM platform_jobs WHERE ${clauses.join(' AND ')}`)
|
|
768
|
+
.get(...bindings);
|
|
769
|
+
return row.count;
|
|
770
|
+
}
|
|
771
|
+
getMetadata(id) {
|
|
772
|
+
const row = this.findRow(id);
|
|
773
|
+
return row ? toMetadata(row) : null;
|
|
774
|
+
}
|
|
775
|
+
listDeletionLifecycleRecoveryCandidates(afterId, limit) {
|
|
776
|
+
const resourceCodes = RESOURCE_DELETE_RECOVERABLE_ERROR_CODES;
|
|
777
|
+
const ownerCodes = OWNER_DELETE_CONTENT_RECOVERABLE_ERROR_CODES;
|
|
778
|
+
const rows = this.database
|
|
779
|
+
.prepare(`SELECT jobs.*
|
|
780
|
+
FROM platform_jobs jobs
|
|
781
|
+
JOIN users actor ON actor.id = jobs.actor_user_id
|
|
782
|
+
WHERE jobs.id > ?
|
|
783
|
+
AND jobs.result_reference IS NULL
|
|
784
|
+
AND (
|
|
785
|
+
(
|
|
786
|
+
jobs.job_type = ?
|
|
787
|
+
AND actor.account_status = 'active'
|
|
788
|
+
AND (
|
|
789
|
+
(jobs.state = 'dead_letter' AND jobs.error_code IN (${resourceCodes.map(() => '?').join(', ')}))
|
|
790
|
+
OR jobs.state = 'cancelled'
|
|
791
|
+
)
|
|
792
|
+
)
|
|
793
|
+
OR
|
|
794
|
+
(
|
|
795
|
+
jobs.job_type = ?
|
|
796
|
+
AND actor.account_status IN ('active', 'retiring')
|
|
797
|
+
AND (
|
|
798
|
+
(jobs.state = 'dead_letter' AND jobs.error_code IN (${ownerCodes.map(() => '?').join(', ')}))
|
|
799
|
+
OR jobs.state = 'cancelled'
|
|
800
|
+
)
|
|
801
|
+
)
|
|
802
|
+
)
|
|
803
|
+
ORDER BY jobs.id ASC
|
|
804
|
+
LIMIT ?`)
|
|
805
|
+
.all(afterId, RESOURCE_DELETE_JOB_TYPE, ...resourceCodes, OWNER_DELETE_CONTENT_JOB_TYPE, ...ownerCodes, limit);
|
|
806
|
+
return rows.map(row => ({
|
|
807
|
+
id: row.id,
|
|
808
|
+
jobType: row.job_type,
|
|
809
|
+
actorUserId: row.actor_user_id,
|
|
810
|
+
payload: { format: row.payload_format, data: row.payload },
|
|
811
|
+
priority: row.priority,
|
|
812
|
+
updatedAt: row.updated_at,
|
|
813
|
+
}));
|
|
814
|
+
}
|
|
815
|
+
getDeletionLifecycleRecoveryCandidate(id) {
|
|
816
|
+
const resourceCodes = RESOURCE_DELETE_RECOVERABLE_ERROR_CODES;
|
|
817
|
+
const ownerCodes = OWNER_DELETE_CONTENT_RECOVERABLE_ERROR_CODES;
|
|
818
|
+
const row = this.database
|
|
819
|
+
.prepare(`SELECT jobs.*
|
|
820
|
+
FROM platform_jobs jobs
|
|
821
|
+
JOIN users actor ON actor.id = jobs.actor_user_id
|
|
822
|
+
WHERE jobs.id = ?
|
|
823
|
+
AND jobs.result_reference IS NULL
|
|
824
|
+
AND (
|
|
825
|
+
(
|
|
826
|
+
jobs.job_type = ?
|
|
827
|
+
AND actor.account_status = 'active'
|
|
828
|
+
AND (
|
|
829
|
+
(jobs.state = 'dead_letter' AND jobs.error_code IN (${resourceCodes.map(() => '?').join(', ')}))
|
|
830
|
+
OR jobs.state = 'cancelled'
|
|
831
|
+
)
|
|
832
|
+
)
|
|
833
|
+
OR
|
|
834
|
+
(
|
|
835
|
+
jobs.job_type = ?
|
|
836
|
+
AND actor.account_status IN ('active', 'retiring')
|
|
837
|
+
AND (
|
|
838
|
+
(jobs.state = 'dead_letter' AND jobs.error_code IN (${ownerCodes.map(() => '?').join(', ')}))
|
|
839
|
+
OR jobs.state = 'cancelled'
|
|
840
|
+
)
|
|
841
|
+
)
|
|
842
|
+
)`)
|
|
843
|
+
.get(id, RESOURCE_DELETE_JOB_TYPE, ...resourceCodes, OWNER_DELETE_CONTENT_JOB_TYPE, ...ownerCodes);
|
|
844
|
+
return row
|
|
845
|
+
? {
|
|
846
|
+
id: row.id,
|
|
847
|
+
jobType: row.job_type,
|
|
848
|
+
actorUserId: row.actor_user_id,
|
|
849
|
+
payload: { format: row.payload_format, data: row.payload },
|
|
850
|
+
priority: row.priority,
|
|
851
|
+
updatedAt: row.updated_at,
|
|
852
|
+
}
|
|
853
|
+
: null;
|
|
854
|
+
}
|
|
855
|
+
markDeletionLifecycleRecoveryHandled(id, resultReference) {
|
|
856
|
+
this.immediate(() => {
|
|
857
|
+
const updated = this.database
|
|
858
|
+
.prepare(`UPDATE platform_jobs
|
|
859
|
+
SET result_reference = ?
|
|
860
|
+
WHERE id = ?
|
|
861
|
+
AND job_type IN (?, ?)
|
|
862
|
+
AND state IN ('cancelled', 'dead_letter')
|
|
863
|
+
AND result_reference IS NULL`)
|
|
864
|
+
.run(resultReference, id, RESOURCE_DELETE_JOB_TYPE, OWNER_DELETE_CONTENT_JOB_TYPE);
|
|
865
|
+
if (updated.changes === 1)
|
|
866
|
+
return;
|
|
867
|
+
const existing = this.database
|
|
868
|
+
.prepare(`SELECT result_reference FROM platform_jobs
|
|
869
|
+
WHERE id = ? AND job_type IN (?, ?)
|
|
870
|
+
AND state IN ('cancelled', 'dead_letter')`)
|
|
871
|
+
.get(id, RESOURCE_DELETE_JOB_TYPE, OWNER_DELETE_CONTENT_JOB_TYPE);
|
|
872
|
+
if (existing?.result_reference === resultReference ||
|
|
873
|
+
existing?.result_reference?.startsWith(DELETION_LIFECYCLE_RECOVERY_REFERENCE_PREFIX)) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
throw new DurableJobError('storage-error', 'Deletion lifecycle recovery marker conflicted');
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
isPendingResourceDeletion(input) {
|
|
880
|
+
const table = (() => {
|
|
881
|
+
switch (input.resourceType) {
|
|
882
|
+
case 'document':
|
|
883
|
+
return 'documents';
|
|
884
|
+
case 'generated-media':
|
|
885
|
+
return 'generated_images';
|
|
886
|
+
case 'persona':
|
|
887
|
+
return 'personas';
|
|
888
|
+
}
|
|
889
|
+
})();
|
|
890
|
+
return Boolean(this.database
|
|
891
|
+
.prepare(`SELECT 1
|
|
892
|
+
FROM platform_resource_deletion_tombstones tombstone
|
|
893
|
+
WHERE tombstone.resource_type = ?
|
|
894
|
+
AND tombstone.resource_id = ?
|
|
895
|
+
AND tombstone.owner_user_id = ?
|
|
896
|
+
AND tombstone.deletion_incarnation = ?
|
|
897
|
+
AND tombstone.deletion_token = ?
|
|
898
|
+
AND tombstone.completed_at IS NULL
|
|
899
|
+
AND NOT EXISTS (
|
|
900
|
+
SELECT 1 FROM ${table} resource
|
|
901
|
+
WHERE resource.id = tombstone.resource_id
|
|
902
|
+
AND resource.user_id = tombstone.owner_user_id
|
|
903
|
+
)`)
|
|
904
|
+
.get(input.resourceType, input.resourceId, input.ownerUserId, input.deletionIncarnation, input.deletionToken));
|
|
905
|
+
}
|
|
906
|
+
isOwnerCleanupRequired(targetUserId) {
|
|
907
|
+
return !this.database
|
|
908
|
+
.prepare('SELECT 1 FROM users WHERE id = ?')
|
|
909
|
+
.get(targetUserId);
|
|
910
|
+
}
|
|
911
|
+
getByIdempotency(actorUserId, idempotencyScope, idempotencyKeyHash) {
|
|
912
|
+
const row = this.database
|
|
913
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
914
|
+
WHERE actor_user_id = ?
|
|
915
|
+
AND idempotency_scope = ?
|
|
916
|
+
AND idempotency_key_hash = ?`)
|
|
917
|
+
.get(actorUserId, idempotencyScope, idempotencyKeyHash);
|
|
918
|
+
return row ? toMetadata(row) : null;
|
|
919
|
+
}
|
|
920
|
+
listJobs(options) {
|
|
921
|
+
const conditions = [];
|
|
922
|
+
const bindings = [];
|
|
923
|
+
if (options.actorUserId) {
|
|
924
|
+
conditions.push('actor_user_id = ?');
|
|
925
|
+
bindings.push(options.actorUserId);
|
|
926
|
+
}
|
|
927
|
+
if (options.state) {
|
|
928
|
+
conditions.push('state = ?');
|
|
929
|
+
bindings.push(options.state);
|
|
930
|
+
}
|
|
931
|
+
if (options.beforeCreatedAt !== undefined) {
|
|
932
|
+
conditions.push('created_at < ?');
|
|
933
|
+
bindings.push(options.beforeCreatedAt);
|
|
934
|
+
}
|
|
935
|
+
const rows = this.database
|
|
936
|
+
.prepare(`SELECT * FROM platform_jobs
|
|
937
|
+
${conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''}
|
|
938
|
+
ORDER BY created_at DESC, id ASC
|
|
939
|
+
LIMIT ?`)
|
|
940
|
+
.all(...bindings, options.limit ?? 50);
|
|
941
|
+
return rows.map(toMetadata);
|
|
942
|
+
}
|
|
943
|
+
getStoredPayload(lease) {
|
|
944
|
+
const timestamp = this.now();
|
|
945
|
+
const row = this.findRow(lease.id);
|
|
946
|
+
if (!row ||
|
|
947
|
+
row.state !== 'running' ||
|
|
948
|
+
row.lease_owner !== lease.workerId ||
|
|
949
|
+
row.lease_token !== lease.leaseToken ||
|
|
950
|
+
row.lease_expires_at === null ||
|
|
951
|
+
row.lease_expires_at <= timestamp) {
|
|
952
|
+
throw new DurableJobError('lease-lost', 'The durable job lease was lost');
|
|
953
|
+
}
|
|
954
|
+
return { format: row.payload_format, data: row.payload };
|
|
955
|
+
}
|
|
956
|
+
listAttempts(id) {
|
|
957
|
+
return this.database
|
|
958
|
+
.prepare(`SELECT * FROM platform_job_attempts
|
|
959
|
+
WHERE job_id = ? ORDER BY attempt_number ASC`)
|
|
960
|
+
.all(id).map(toAttempt);
|
|
961
|
+
}
|
|
962
|
+
getStoredEvent(eventId) {
|
|
963
|
+
return (this.database
|
|
964
|
+
.prepare(`SELECT global_cursor AS cursor, event_id, stream_id,
|
|
965
|
+
stream_sequence, request_fingerprint, event_type, subject_id,
|
|
966
|
+
actor_user_id, payload_format, payload, occurred_at
|
|
967
|
+
FROM platform_events
|
|
968
|
+
WHERE event_id = ?`)
|
|
969
|
+
.get(eventId) ?? null);
|
|
970
|
+
}
|
|
971
|
+
latestStoredEventCursor(streamId) {
|
|
972
|
+
const row = this.database
|
|
973
|
+
.prepare(`SELECT global_cursor AS cursor
|
|
974
|
+
FROM platform_events
|
|
975
|
+
WHERE stream_id = ?
|
|
976
|
+
ORDER BY stream_sequence DESC
|
|
977
|
+
LIMIT 1`)
|
|
978
|
+
.get(streamId);
|
|
979
|
+
if (!row)
|
|
980
|
+
return 0;
|
|
981
|
+
if (!Number.isSafeInteger(row.cursor) || row.cursor < 1) {
|
|
982
|
+
throw new DurableJobError('storage-error', 'Durable event stream cursor is invalid');
|
|
983
|
+
}
|
|
984
|
+
return row.cursor;
|
|
985
|
+
}
|
|
986
|
+
replayStoredEvents(afterCursor, limit, options = {}) {
|
|
987
|
+
const predicates = ['global_cursor > ?'];
|
|
988
|
+
const parameters = [afterCursor];
|
|
989
|
+
if (options.streamId) {
|
|
990
|
+
predicates.push('stream_id = ?');
|
|
991
|
+
parameters.push(options.streamId);
|
|
992
|
+
}
|
|
993
|
+
if (options.subjectId) {
|
|
994
|
+
predicates.push('subject_id = ?');
|
|
995
|
+
parameters.push(options.subjectId);
|
|
996
|
+
}
|
|
997
|
+
parameters.push(limit);
|
|
998
|
+
return this.database
|
|
999
|
+
.prepare(`SELECT global_cursor AS cursor, event_id, stream_id, stream_sequence,
|
|
1000
|
+
request_fingerprint, event_type, subject_id, actor_user_id,
|
|
1001
|
+
payload_format, payload, occurred_at
|
|
1002
|
+
FROM platform_events
|
|
1003
|
+
WHERE ${predicates.join(' AND ')}
|
|
1004
|
+
ORDER BY global_cursor ASC LIMIT ?`)
|
|
1005
|
+
.all(...parameters);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
//# sourceMappingURL=sqliteDurableJobRepository.js.map
|