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,1017 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Libre WebUI
|
|
3
|
+
* Copyright (C) 2025 Kroonen AI, Inc.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
*/
|
|
6
|
+
import { resourceDeletionToken } from './resourceDeletionLifecycle.js';
|
|
7
|
+
const resourceTable = (resourceType) => {
|
|
8
|
+
switch (resourceType) {
|
|
9
|
+
case 'document':
|
|
10
|
+
return 'documents';
|
|
11
|
+
case 'generated-media':
|
|
12
|
+
return 'platform_generated_media';
|
|
13
|
+
case 'persona':
|
|
14
|
+
return 'personas';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const lockResourceIdentifier = async (executor, resourceType, resourceId) => {
|
|
18
|
+
await executor.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [JSON.stringify(['libre-resource-v1', resourceType, resourceId])]);
|
|
19
|
+
};
|
|
20
|
+
const assertResourceIdentifierAvailable = async (executor, resourceType, resourceId) => {
|
|
21
|
+
await lockResourceIdentifier(executor, resourceType, resourceId);
|
|
22
|
+
const reserved = await executor.query(`SELECT 1 FROM platform_resource_deletion_tombstones
|
|
23
|
+
WHERE resource_type = $1 AND resource_id = $2`, [resourceType, resourceId]);
|
|
24
|
+
if (reserved.rowCount) {
|
|
25
|
+
throw new Error('Resource identifier is permanently reserved by deletion');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const recordResourceDeletion = async (executor, input) => {
|
|
29
|
+
await assertResourceIdentifierAvailable(executor, input.resourceType, input.resourceId);
|
|
30
|
+
const deletionIncarnation = 1;
|
|
31
|
+
const deletionToken = resourceDeletionToken({
|
|
32
|
+
...input,
|
|
33
|
+
deletionIncarnation,
|
|
34
|
+
});
|
|
35
|
+
await executor.query(`INSERT INTO platform_resource_deletion_tombstones
|
|
36
|
+
(resource_type, resource_id, owner_user_id, deletion_incarnation,
|
|
37
|
+
deletion_token, deleted_at, completed_at)
|
|
38
|
+
VALUES ($1, $2, $3, $4, $5, $6, NULL)`, [
|
|
39
|
+
input.resourceType,
|
|
40
|
+
input.resourceId,
|
|
41
|
+
input.ownerUserId,
|
|
42
|
+
deletionIncarnation,
|
|
43
|
+
deletionToken,
|
|
44
|
+
Date.now(),
|
|
45
|
+
]);
|
|
46
|
+
return { ...input, deletionIncarnation, deletionToken };
|
|
47
|
+
};
|
|
48
|
+
const safeInteger = (value, field) => {
|
|
49
|
+
const parsed = Number(value);
|
|
50
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
51
|
+
throw new Error(`PostgreSQL returned an invalid ${field}`);
|
|
52
|
+
}
|
|
53
|
+
return parsed;
|
|
54
|
+
};
|
|
55
|
+
const decryptOptional = (cipher, value) => value === null ? undefined : cipher.decryptAuthenticated(value);
|
|
56
|
+
const decryptJson = (cipher, value) => {
|
|
57
|
+
const plaintext = decryptOptional(cipher, value);
|
|
58
|
+
return plaintext === undefined ? undefined : JSON.parse(plaintext);
|
|
59
|
+
};
|
|
60
|
+
class PostgresDocumentRepository {
|
|
61
|
+
constructor(database, cipher) {
|
|
62
|
+
this.database = database;
|
|
63
|
+
this.cipher = cipher;
|
|
64
|
+
}
|
|
65
|
+
map(row) {
|
|
66
|
+
return {
|
|
67
|
+
id: row.id,
|
|
68
|
+
filename: row.filename,
|
|
69
|
+
...(row.title
|
|
70
|
+
? { title: this.cipher.decryptAuthenticated(row.title) }
|
|
71
|
+
: {}),
|
|
72
|
+
...(row.content
|
|
73
|
+
? { content: this.cipher.decryptAuthenticated(row.content) }
|
|
74
|
+
: {}),
|
|
75
|
+
...(row.file_type ? { fileType: row.file_type } : {}),
|
|
76
|
+
...(row.size === null
|
|
77
|
+
? {}
|
|
78
|
+
: { size: safeInteger(row.size, 'document size') }),
|
|
79
|
+
...(row.session_id ? { sessionId: row.session_id } : {}),
|
|
80
|
+
...(row.collection_id ? { collectionId: row.collection_id } : {}),
|
|
81
|
+
uploadedAt: safeInteger(row.uploaded_at, 'document upload time'),
|
|
82
|
+
createdAt: safeInteger(row.created_at, 'document creation time'),
|
|
83
|
+
...(row.metadata
|
|
84
|
+
? {
|
|
85
|
+
metadata: decryptJson(this.cipher, row.metadata),
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async listByOwner(userId) {
|
|
91
|
+
const result = await this.database.query('SELECT * FROM documents WHERE user_id = $1 ORDER BY uploaded_at DESC, id ASC', [userId]);
|
|
92
|
+
return result.rows.map(row => this.map(row));
|
|
93
|
+
}
|
|
94
|
+
async findByOwner(documentId, userId) {
|
|
95
|
+
const result = await this.database.query('SELECT * FROM documents WHERE id = $1 AND user_id = $2', [documentId, userId]);
|
|
96
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
97
|
+
}
|
|
98
|
+
async upsert(document, userId) {
|
|
99
|
+
await this.database.transaction(async (client) => {
|
|
100
|
+
await assertResourceIdentifierAvailable(client, 'document', document.id);
|
|
101
|
+
const result = await this.upsertUsing(client, document, userId);
|
|
102
|
+
if (result.rowCount === 0) {
|
|
103
|
+
throw new Error('Document identifier belongs to another owner');
|
|
104
|
+
}
|
|
105
|
+
}, { isolationLevel: 'serializable' });
|
|
106
|
+
}
|
|
107
|
+
upsertUsing(executor, document, userId) {
|
|
108
|
+
const now = Date.now();
|
|
109
|
+
return executor.query(`INSERT INTO documents
|
|
110
|
+
(id, user_id, filename, title, content, file_type, size, session_id,
|
|
111
|
+
collection_id, metadata, uploaded_at, created_at, updated_at)
|
|
112
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
|
113
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
114
|
+
filename = EXCLUDED.filename, title = EXCLUDED.title,
|
|
115
|
+
content = EXCLUDED.content, file_type = EXCLUDED.file_type,
|
|
116
|
+
size = EXCLUDED.size, session_id = EXCLUDED.session_id,
|
|
117
|
+
collection_id = EXCLUDED.collection_id, metadata = EXCLUDED.metadata,
|
|
118
|
+
uploaded_at = EXCLUDED.uploaded_at, updated_at = EXCLUDED.updated_at
|
|
119
|
+
WHERE documents.user_id = EXCLUDED.user_id`, [
|
|
120
|
+
document.id,
|
|
121
|
+
userId,
|
|
122
|
+
document.filename,
|
|
123
|
+
document.title ? this.cipher.encrypt(document.title) : null,
|
|
124
|
+
document.content ? this.cipher.encrypt(document.content) : null,
|
|
125
|
+
document.fileType || null,
|
|
126
|
+
document.size ?? null,
|
|
127
|
+
document.sessionId || null,
|
|
128
|
+
document.collectionId || null,
|
|
129
|
+
document.metadata
|
|
130
|
+
? this.cipher.encrypt(JSON.stringify(document.metadata))
|
|
131
|
+
: null,
|
|
132
|
+
document.uploadedAt,
|
|
133
|
+
document.createdAt || now,
|
|
134
|
+
now,
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
async upsertWithBlobAndEnqueue(document, userId, reference, enqueuer) {
|
|
138
|
+
if (reference.ownerUserId !== userId ||
|
|
139
|
+
reference.resourceType !== 'document' ||
|
|
140
|
+
reference.resourceId !== document.id ||
|
|
141
|
+
reference.purpose !== 'document.source') {
|
|
142
|
+
throw new Error('Document ingestion blob reference is inconsistent');
|
|
143
|
+
}
|
|
144
|
+
await this.database.transaction(async (client) => {
|
|
145
|
+
await assertResourceIdentifierAvailable(client, 'document', document.id);
|
|
146
|
+
const result = await this.upsertUsing(client, document, userId);
|
|
147
|
+
if (result.rowCount === 0) {
|
|
148
|
+
throw new Error('Document identifier belongs to another owner');
|
|
149
|
+
}
|
|
150
|
+
await client.query(`INSERT INTO platform_blob_references
|
|
151
|
+
(blob_id, owner_user_id, resource_type, resource_id, purpose, created_at)
|
|
152
|
+
VALUES ($1, $2, $3, $4, $5, $6)`, [
|
|
153
|
+
reference.blobId,
|
|
154
|
+
reference.ownerUserId,
|
|
155
|
+
reference.resourceType,
|
|
156
|
+
reference.resourceId,
|
|
157
|
+
reference.purpose,
|
|
158
|
+
reference.createdAt,
|
|
159
|
+
]);
|
|
160
|
+
await enqueuer.enqueuePostgres(client, {
|
|
161
|
+
documentId: document.id,
|
|
162
|
+
ownerUserId: userId,
|
|
163
|
+
});
|
|
164
|
+
}, { isolationLevel: 'serializable' });
|
|
165
|
+
}
|
|
166
|
+
async completeIngestion(document, userId, chunks) {
|
|
167
|
+
return this.database.transaction(async (client) => {
|
|
168
|
+
const updated = await client.query(`UPDATE documents SET filename = $1, title = $2, content = $3,
|
|
169
|
+
file_type = $4, size = $5, session_id = $6,
|
|
170
|
+
collection_id = $7, metadata = $8, uploaded_at = $9,
|
|
171
|
+
updated_at = $10
|
|
172
|
+
WHERE id = $11 AND user_id = $12`, [
|
|
173
|
+
document.filename,
|
|
174
|
+
document.title ? this.cipher.encrypt(document.title) : null,
|
|
175
|
+
document.content ? this.cipher.encrypt(document.content) : null,
|
|
176
|
+
document.fileType || null,
|
|
177
|
+
document.size ?? null,
|
|
178
|
+
document.sessionId || null,
|
|
179
|
+
document.collectionId || null,
|
|
180
|
+
document.metadata
|
|
181
|
+
? this.cipher.encrypt(JSON.stringify(document.metadata))
|
|
182
|
+
: null,
|
|
183
|
+
document.uploadedAt,
|
|
184
|
+
Date.now(),
|
|
185
|
+
document.id,
|
|
186
|
+
userId,
|
|
187
|
+
]);
|
|
188
|
+
if (updated.rowCount !== 1)
|
|
189
|
+
return false;
|
|
190
|
+
await this.replaceChunksUsing(client, document.id, chunks);
|
|
191
|
+
return true;
|
|
192
|
+
}, { isolationLevel: 'serializable' });
|
|
193
|
+
}
|
|
194
|
+
async publishEmbeddingIndex(documentId, userId, expectedSource, embeddingIndex, chunks) {
|
|
195
|
+
if (!embeddingIndex ||
|
|
196
|
+
typeof embeddingIndex !== 'object' ||
|
|
197
|
+
Array.isArray(embeddingIndex)) {
|
|
198
|
+
throw new Error('Document embedding index metadata is invalid');
|
|
199
|
+
}
|
|
200
|
+
return this.database.transaction(async (client) => {
|
|
201
|
+
const current = await client.query(`SELECT content, file_type, metadata FROM documents
|
|
202
|
+
WHERE id = $1 AND user_id = $2
|
|
203
|
+
FOR UPDATE`, [documentId, userId]);
|
|
204
|
+
const row = current.rows[0];
|
|
205
|
+
if (!row)
|
|
206
|
+
return false;
|
|
207
|
+
const currentContent = row.content
|
|
208
|
+
? this.cipher.decryptAuthenticated(row.content)
|
|
209
|
+
: null;
|
|
210
|
+
if (currentContent !== expectedSource.content ||
|
|
211
|
+
row.file_type !== expectedSource.fileType) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const currentMetadata = decryptJson(this.cipher, row.metadata) ?? {};
|
|
215
|
+
const updated = await client.query(`UPDATE documents SET metadata = $1, updated_at = $2
|
|
216
|
+
WHERE id = $3 AND user_id = $4`, [
|
|
217
|
+
this.cipher.encrypt(JSON.stringify({
|
|
218
|
+
...currentMetadata,
|
|
219
|
+
embeddingIndex,
|
|
220
|
+
})),
|
|
221
|
+
Date.now(),
|
|
222
|
+
documentId,
|
|
223
|
+
userId,
|
|
224
|
+
]);
|
|
225
|
+
if (updated.rowCount !== 1)
|
|
226
|
+
return false;
|
|
227
|
+
await this.replaceChunksUsing(client, documentId, chunks);
|
|
228
|
+
return true;
|
|
229
|
+
}, { isolationLevel: 'serializable' });
|
|
230
|
+
}
|
|
231
|
+
async deleteByOwner(documentId, userId) {
|
|
232
|
+
const result = await this.database.query('DELETE FROM documents WHERE id = $1 AND user_id = $2', [documentId, userId]);
|
|
233
|
+
return result.rowCount === 1;
|
|
234
|
+
}
|
|
235
|
+
async deleteAndEnqueue(documentId, userId, enqueuer) {
|
|
236
|
+
return this.database.transaction(async (client) => {
|
|
237
|
+
await lockResourceIdentifier(client, 'document', documentId);
|
|
238
|
+
const existing = await client.query('SELECT 1 FROM documents WHERE id = $1 AND user_id = $2 FOR UPDATE', [documentId, userId]);
|
|
239
|
+
if (existing.rowCount !== 1)
|
|
240
|
+
return false;
|
|
241
|
+
const deletion = await recordResourceDeletion(client, {
|
|
242
|
+
resourceType: 'document',
|
|
243
|
+
resourceId: documentId,
|
|
244
|
+
ownerUserId: userId,
|
|
245
|
+
});
|
|
246
|
+
const deleted = await client.query('DELETE FROM documents WHERE id = $1 AND user_id = $2', [documentId, userId]);
|
|
247
|
+
if (deleted.rowCount !== 1) {
|
|
248
|
+
throw new Error('Document disappeared during deletion');
|
|
249
|
+
}
|
|
250
|
+
await enqueuer.enqueuePostgres(client, deletion);
|
|
251
|
+
return true;
|
|
252
|
+
}, { isolationLevel: 'serializable' });
|
|
253
|
+
}
|
|
254
|
+
async setCollection(documentId, collectionId, userId) {
|
|
255
|
+
const result = await this.database.query(`UPDATE documents SET collection_id = $1, updated_at = $2
|
|
256
|
+
WHERE id = $3 AND user_id = $4`, [collectionId, Date.now(), documentId, userId]);
|
|
257
|
+
return result.rowCount === 1;
|
|
258
|
+
}
|
|
259
|
+
async inspectLegacyChunkEmbeddings(_documentId, _userId) {
|
|
260
|
+
// Team-mode chunks deliberately do not expose inline vectors. Any legacy
|
|
261
|
+
// SQLite source must pass the provenance gate before PostgreSQL import.
|
|
262
|
+
return { present: false, authenticated: false };
|
|
263
|
+
}
|
|
264
|
+
async listChunks(documentId) {
|
|
265
|
+
const result = await this.database.query(`SELECT id, document_id, chunk_index, content, start_char, end_char
|
|
266
|
+
FROM document_chunks WHERE document_id = $1
|
|
267
|
+
ORDER BY chunk_index ASC, id ASC`, [documentId]);
|
|
268
|
+
return result.rows.map(row => ({
|
|
269
|
+
id: row.id,
|
|
270
|
+
documentId: row.document_id,
|
|
271
|
+
chunkIndex: row.chunk_index,
|
|
272
|
+
content: this.cipher.decryptAuthenticated(row.content),
|
|
273
|
+
startChar: row.start_char ?? 0,
|
|
274
|
+
endChar: row.end_char ?? 0,
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
async replaceChunks(documentId, chunks) {
|
|
278
|
+
await this.database.transaction(async (client) => {
|
|
279
|
+
await this.replaceChunksUsing(client, documentId, chunks);
|
|
280
|
+
}, { isolationLevel: 'serializable' });
|
|
281
|
+
}
|
|
282
|
+
async replaceChunksUsing(executor, documentId, chunks) {
|
|
283
|
+
await executor.query('DELETE FROM document_chunks WHERE document_id = $1', [
|
|
284
|
+
documentId,
|
|
285
|
+
]);
|
|
286
|
+
const now = Date.now();
|
|
287
|
+
for (const chunk of chunks) {
|
|
288
|
+
await executor.query(`INSERT INTO document_chunks
|
|
289
|
+
(id, document_id, chunk_index, content, start_char, end_char,
|
|
290
|
+
embedding, created_at)
|
|
291
|
+
VALUES ($1, $2, $3, $4, $5, $6, NULL, $7)`, [
|
|
292
|
+
chunk.id,
|
|
293
|
+
documentId,
|
|
294
|
+
chunk.chunkIndex,
|
|
295
|
+
this.cipher.encrypt(chunk.content),
|
|
296
|
+
chunk.startChar ?? null,
|
|
297
|
+
chunk.endChar ?? null,
|
|
298
|
+
now,
|
|
299
|
+
]);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async deleteChunks(documentId) {
|
|
303
|
+
const result = await this.database.query('DELETE FROM document_chunks WHERE document_id = $1', [documentId]);
|
|
304
|
+
return (result.rowCount ?? 0) > 0;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
class PostgresGalleryMetadataRepository {
|
|
308
|
+
constructor(database, cipher) {
|
|
309
|
+
this.database = database;
|
|
310
|
+
this.cipher = cipher;
|
|
311
|
+
}
|
|
312
|
+
map(row) {
|
|
313
|
+
return {
|
|
314
|
+
id: row.id,
|
|
315
|
+
userId: row.user_id,
|
|
316
|
+
kind: row.kind,
|
|
317
|
+
prompt: this.cipher.decryptAuthenticated(row.encrypted_prompt),
|
|
318
|
+
model: row.model,
|
|
319
|
+
...(row.plugin_id ? { pluginId: row.plugin_id } : {}),
|
|
320
|
+
mimeType: row.mime_type,
|
|
321
|
+
...(row.size_label ? { size: row.size_label } : {}),
|
|
322
|
+
...(row.quality ? { quality: row.quality } : {}),
|
|
323
|
+
...(row.encrypted_metadata
|
|
324
|
+
? {
|
|
325
|
+
metadata: decryptJson(this.cipher, row.encrypted_metadata),
|
|
326
|
+
}
|
|
327
|
+
: {}),
|
|
328
|
+
createdAt: safeInteger(row.created_at, 'gallery creation time'),
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
async insert(record, reference) {
|
|
332
|
+
await this.database.transaction(async (client) => {
|
|
333
|
+
await assertResourceIdentifierAvailable(client, 'generated-media', record.id);
|
|
334
|
+
await client.query(`INSERT INTO platform_generated_media
|
|
335
|
+
(id, user_id, kind, encrypted_prompt, model, plugin_id, blob_id,
|
|
336
|
+
mime_type, size_label, quality, encrypted_metadata, created_at)
|
|
337
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`, [
|
|
338
|
+
record.id,
|
|
339
|
+
record.userId,
|
|
340
|
+
record.kind,
|
|
341
|
+
this.cipher.encrypt(record.prompt),
|
|
342
|
+
record.model,
|
|
343
|
+
record.pluginId || null,
|
|
344
|
+
reference.blobId,
|
|
345
|
+
record.mimeType,
|
|
346
|
+
record.size || null,
|
|
347
|
+
record.quality || null,
|
|
348
|
+
record.metadata
|
|
349
|
+
? this.cipher.encrypt(JSON.stringify(record.metadata))
|
|
350
|
+
: null,
|
|
351
|
+
record.createdAt,
|
|
352
|
+
]);
|
|
353
|
+
await client.query(`INSERT INTO platform_blob_references
|
|
354
|
+
(blob_id, owner_user_id, resource_type, resource_id, purpose, created_at)
|
|
355
|
+
VALUES ($1, $2, $3, $4, $5, $6)`, [
|
|
356
|
+
reference.blobId,
|
|
357
|
+
reference.ownerUserId,
|
|
358
|
+
reference.resourceType,
|
|
359
|
+
reference.resourceId,
|
|
360
|
+
reference.purpose,
|
|
361
|
+
reference.createdAt,
|
|
362
|
+
]);
|
|
363
|
+
}, { isolationLevel: 'serializable' });
|
|
364
|
+
}
|
|
365
|
+
async findByOwner(mediaId, userId) {
|
|
366
|
+
const result = await this.database.query('SELECT * FROM platform_generated_media WHERE id = $1 AND user_id = $2', [mediaId, userId]);
|
|
367
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
368
|
+
}
|
|
369
|
+
async listByOwner(userId, options) {
|
|
370
|
+
const parameters = [userId];
|
|
371
|
+
let predicate = 'user_id = $1';
|
|
372
|
+
if (options.kind) {
|
|
373
|
+
parameters.push(options.kind);
|
|
374
|
+
predicate += ' AND kind = $2';
|
|
375
|
+
}
|
|
376
|
+
const count = await this.database.query(`SELECT COUNT(*)::text AS count FROM platform_generated_media WHERE ${predicate}`, parameters);
|
|
377
|
+
const offsetIndex = parameters.length + 1;
|
|
378
|
+
parameters.push(options.limit, options.offset);
|
|
379
|
+
const result = await this.database.query(`SELECT * FROM platform_generated_media WHERE ${predicate}
|
|
380
|
+
ORDER BY created_at DESC, id ASC LIMIT $${offsetIndex} OFFSET $${offsetIndex + 1}`, parameters);
|
|
381
|
+
return {
|
|
382
|
+
records: result.rows.map(row => this.map(row)),
|
|
383
|
+
total: safeInteger(count.rows[0]?.count ?? 0, 'gallery count'),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
async adoptLegacyBlob() {
|
|
387
|
+
throw new Error('PostgreSQL gallery has no inline legacy blob format');
|
|
388
|
+
}
|
|
389
|
+
async deleteByOwner(mediaId, userId) {
|
|
390
|
+
return this.database.transaction(async (client) => {
|
|
391
|
+
const reference = await client.query(`SELECT blob_id, owner_user_id, resource_type, resource_id, purpose,
|
|
392
|
+
created_at
|
|
393
|
+
FROM platform_blob_references
|
|
394
|
+
WHERE resource_type = 'generated-media' AND resource_id = $1
|
|
395
|
+
AND purpose = 'gallery.media' AND owner_user_id = $2 FOR UPDATE`, [mediaId, userId]);
|
|
396
|
+
const deleted = await client.query('DELETE FROM platform_generated_media WHERE id = $1 AND user_id = $2', [mediaId, userId]);
|
|
397
|
+
if (deleted.rowCount !== 1)
|
|
398
|
+
return undefined;
|
|
399
|
+
await client.query(`DELETE FROM platform_blob_references
|
|
400
|
+
WHERE resource_type = 'generated-media' AND resource_id = $1
|
|
401
|
+
AND purpose = 'gallery.media' AND owner_user_id = $2`, [mediaId, userId]);
|
|
402
|
+
const row = reference.rows[0];
|
|
403
|
+
return row
|
|
404
|
+
? {
|
|
405
|
+
blobId: row.blob_id,
|
|
406
|
+
ownerUserId: row.owner_user_id,
|
|
407
|
+
resourceType: row.resource_type,
|
|
408
|
+
resourceId: row.resource_id,
|
|
409
|
+
purpose: row.purpose,
|
|
410
|
+
createdAt: safeInteger(row.created_at, 'blob reference creation time'),
|
|
411
|
+
}
|
|
412
|
+
: undefined;
|
|
413
|
+
}, { isolationLevel: 'serializable' });
|
|
414
|
+
}
|
|
415
|
+
async deleteAndEnqueue(mediaId, userId, enqueuer) {
|
|
416
|
+
return this.database.transaction(async (client) => {
|
|
417
|
+
await lockResourceIdentifier(client, 'generated-media', mediaId);
|
|
418
|
+
const existing = await client.query(`SELECT 1 FROM platform_generated_media
|
|
419
|
+
WHERE id = $1 AND user_id = $2 FOR UPDATE`, [mediaId, userId]);
|
|
420
|
+
if (existing.rowCount !== 1)
|
|
421
|
+
return false;
|
|
422
|
+
const deletion = await recordResourceDeletion(client, {
|
|
423
|
+
resourceType: 'generated-media',
|
|
424
|
+
resourceId: mediaId,
|
|
425
|
+
ownerUserId: userId,
|
|
426
|
+
});
|
|
427
|
+
await client.query(`UPDATE platform_media_generation_jobs
|
|
428
|
+
SET status = 'failed',
|
|
429
|
+
encrypted_error = $1,
|
|
430
|
+
updated_at = $2
|
|
431
|
+
WHERE id = $3 AND user_id = $4
|
|
432
|
+
AND status IN ('pending', 'in_progress')`, [
|
|
433
|
+
this.cipher.encrypt('Generated media was deleted'),
|
|
434
|
+
Date.now(),
|
|
435
|
+
mediaId,
|
|
436
|
+
userId,
|
|
437
|
+
]);
|
|
438
|
+
const deleted = await client.query('DELETE FROM platform_generated_media WHERE id = $1 AND user_id = $2', [mediaId, userId]);
|
|
439
|
+
if (deleted.rowCount !== 1) {
|
|
440
|
+
throw new Error('Generated media disappeared during deletion');
|
|
441
|
+
}
|
|
442
|
+
await enqueuer.enqueuePostgres(client, deletion);
|
|
443
|
+
return true;
|
|
444
|
+
}, { isolationLevel: 'serializable' });
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
class PostgresMediaGenerationJobRepository {
|
|
448
|
+
constructor(database, cipher) {
|
|
449
|
+
this.database = database;
|
|
450
|
+
this.cipher = cipher;
|
|
451
|
+
}
|
|
452
|
+
map(row) {
|
|
453
|
+
return {
|
|
454
|
+
id: row.id,
|
|
455
|
+
userId: row.user_id,
|
|
456
|
+
providerJobId: row.provider_job_id,
|
|
457
|
+
pluginId: row.plugin_id,
|
|
458
|
+
model: row.model,
|
|
459
|
+
prompt: this.cipher.decryptAuthenticated(row.encrypted_prompt),
|
|
460
|
+
status: row.status,
|
|
461
|
+
options: decryptJson(this.cipher, row.encrypted_options) || {},
|
|
462
|
+
...(row.gallery_id ? { galleryId: row.gallery_id } : {}),
|
|
463
|
+
...(row.encrypted_error
|
|
464
|
+
? { error: this.cipher.decryptAuthenticated(row.encrypted_error) }
|
|
465
|
+
: {}),
|
|
466
|
+
createdAt: safeInteger(row.created_at, 'media job creation time'),
|
|
467
|
+
updatedAt: safeInteger(row.updated_at, 'media job update time'),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
async insert(executor, record) {
|
|
471
|
+
await executor.query(`INSERT INTO platform_media_generation_jobs
|
|
472
|
+
(id, user_id, provider_job_id, plugin_id, model, encrypted_prompt,
|
|
473
|
+
status, encrypted_options, gallery_id, encrypted_error, created_at,
|
|
474
|
+
updated_at)
|
|
475
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`, [
|
|
476
|
+
record.id,
|
|
477
|
+
record.userId,
|
|
478
|
+
record.providerJobId,
|
|
479
|
+
record.pluginId,
|
|
480
|
+
record.model,
|
|
481
|
+
this.cipher.encrypt(record.prompt),
|
|
482
|
+
record.status,
|
|
483
|
+
this.cipher.encrypt(JSON.stringify(record.options)),
|
|
484
|
+
record.galleryId || null,
|
|
485
|
+
record.error ? this.cipher.encrypt(record.error) : null,
|
|
486
|
+
record.createdAt,
|
|
487
|
+
record.updatedAt,
|
|
488
|
+
]);
|
|
489
|
+
}
|
|
490
|
+
async create(record) {
|
|
491
|
+
await this.insert(this.database, record);
|
|
492
|
+
}
|
|
493
|
+
async createPreparedAndEnqueue(record, enqueuer) {
|
|
494
|
+
await this.database.transaction(async (executor) => {
|
|
495
|
+
await this.insert(executor, record);
|
|
496
|
+
await enqueuer.enqueuePostgres(executor, {
|
|
497
|
+
mediaJobId: record.id,
|
|
498
|
+
ownerUserId: record.userId,
|
|
499
|
+
});
|
|
500
|
+
}, { isolationLevel: 'serializable' });
|
|
501
|
+
}
|
|
502
|
+
async acceptProviderAndEnqueueResume(id, userId, providerJobId, updatedAt, preparedProviderJobId, enqueuer) {
|
|
503
|
+
return this.database.transaction(async (executor) => {
|
|
504
|
+
const current = await executor.query(`SELECT provider_job_id FROM platform_media_generation_jobs
|
|
505
|
+
WHERE id = $1 AND user_id = $2 FOR UPDATE`, [id, userId]);
|
|
506
|
+
const existing = current.rows[0]?.provider_job_id;
|
|
507
|
+
if (!existing)
|
|
508
|
+
return false;
|
|
509
|
+
if (existing !== preparedProviderJobId && existing !== providerJobId) {
|
|
510
|
+
throw new Error('Media provider reconciliation returned a new job ID');
|
|
511
|
+
}
|
|
512
|
+
await executor.query(`UPDATE platform_media_generation_jobs
|
|
513
|
+
SET provider_job_id = $1, status = 'pending', updated_at = $2
|
|
514
|
+
WHERE id = $3 AND user_id = $4`, [providerJobId, updatedAt, id, userId]);
|
|
515
|
+
await enqueuer.enqueuePostgres(executor, {
|
|
516
|
+
mediaJobId: id,
|
|
517
|
+
ownerUserId: userId,
|
|
518
|
+
});
|
|
519
|
+
return true;
|
|
520
|
+
}, { isolationLevel: 'serializable' });
|
|
521
|
+
}
|
|
522
|
+
async findByOwner(id, userId) {
|
|
523
|
+
const result = await this.database.query('SELECT * FROM platform_media_generation_jobs WHERE id = $1 AND user_id = $2', [id, userId]);
|
|
524
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
525
|
+
}
|
|
526
|
+
async listByOwner(userId, options) {
|
|
527
|
+
const result = await this.database.query(`SELECT * FROM platform_media_generation_jobs WHERE user_id = $1
|
|
528
|
+
${options.activeOnly ? "AND status IN ('pending', 'in_progress')" : ''}
|
|
529
|
+
ORDER BY updated_at DESC, id ASC LIMIT $2`, [userId, options.limit]);
|
|
530
|
+
return result.rows.map(row => this.map(row));
|
|
531
|
+
}
|
|
532
|
+
async deleteByOwner(id, userId) {
|
|
533
|
+
const result = await this.database.query('DELETE FROM platform_media_generation_jobs WHERE id = $1 AND user_id = $2', [id, userId]);
|
|
534
|
+
return result.rowCount === 1;
|
|
535
|
+
}
|
|
536
|
+
async updateStatus(id, userId, status, fields, updatedAt) {
|
|
537
|
+
const result = await this.database.query(`UPDATE platform_media_generation_jobs
|
|
538
|
+
SET status = $1, gallery_id = COALESCE($2, gallery_id),
|
|
539
|
+
encrypted_error = COALESCE($3, encrypted_error), updated_at = $4
|
|
540
|
+
WHERE id = $5 AND user_id = $6`, [
|
|
541
|
+
status,
|
|
542
|
+
fields.galleryId || null,
|
|
543
|
+
fields.error ? this.cipher.encrypt(fields.error) : null,
|
|
544
|
+
updatedAt,
|
|
545
|
+
id,
|
|
546
|
+
userId,
|
|
547
|
+
]);
|
|
548
|
+
return result.rowCount === 1;
|
|
549
|
+
}
|
|
550
|
+
async completeIfUnclaimed(id, userId, galleryId, updatedAt) {
|
|
551
|
+
const result = await this.database.query(`UPDATE platform_media_generation_jobs
|
|
552
|
+
SET status = 'completed', gallery_id = $1, encrypted_error = NULL,
|
|
553
|
+
updated_at = $2
|
|
554
|
+
WHERE id = $3 AND user_id = $4 AND gallery_id IS NULL`, [galleryId, updatedAt, id, userId]);
|
|
555
|
+
return result.rowCount === 1;
|
|
556
|
+
}
|
|
557
|
+
async deleteTerminalBefore(cutoff) {
|
|
558
|
+
const result = await this.database.query(`DELETE FROM platform_media_generation_jobs
|
|
559
|
+
WHERE status IN ('completed', 'failed') AND updated_at < $1`, [cutoff]);
|
|
560
|
+
return result.rowCount ?? 0;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
class PostgresPersonaMemoryRepository {
|
|
564
|
+
constructor(database, cipher) {
|
|
565
|
+
this.database = database;
|
|
566
|
+
this.cipher = cipher;
|
|
567
|
+
}
|
|
568
|
+
map(row) {
|
|
569
|
+
return {
|
|
570
|
+
id: row.id,
|
|
571
|
+
userId: row.user_id,
|
|
572
|
+
personaId: row.persona_id,
|
|
573
|
+
content: this.cipher.decryptAuthenticated(row.encrypted_content),
|
|
574
|
+
timestamp: safeInteger(row.timestamp, 'memory timestamp'),
|
|
575
|
+
...(row.encrypted_context
|
|
576
|
+
? { context: this.cipher.decryptAuthenticated(row.encrypted_context) }
|
|
577
|
+
: {}),
|
|
578
|
+
importanceScore: Number(row.importance_score),
|
|
579
|
+
memoryType: row.memory_type,
|
|
580
|
+
accessCount: safeInteger(row.access_count, 'memory access count'),
|
|
581
|
+
...(row.last_accessed === null
|
|
582
|
+
? {}
|
|
583
|
+
: {
|
|
584
|
+
lastAccessed: safeInteger(row.last_accessed, 'memory access time'),
|
|
585
|
+
}),
|
|
586
|
+
decayFactor: Number(row.decay_factor),
|
|
587
|
+
...(row.encrypted_consolidated_from
|
|
588
|
+
? {
|
|
589
|
+
consolidatedFrom: decryptJson(this.cipher, row.encrypted_consolidated_from),
|
|
590
|
+
}
|
|
591
|
+
: {}),
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
async insert(record) {
|
|
595
|
+
await this.database.query(`INSERT INTO platform_persona_memories
|
|
596
|
+
(id, user_id, persona_id, encrypted_content, timestamp,
|
|
597
|
+
encrypted_context, importance_score, memory_type, access_count,
|
|
598
|
+
last_accessed, decay_factor, encrypted_consolidated_from)
|
|
599
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`, [
|
|
600
|
+
record.id,
|
|
601
|
+
record.userId,
|
|
602
|
+
record.personaId,
|
|
603
|
+
this.cipher.encrypt(record.content),
|
|
604
|
+
record.timestamp,
|
|
605
|
+
record.context ? this.cipher.encrypt(record.context) : null,
|
|
606
|
+
record.importanceScore,
|
|
607
|
+
record.memoryType,
|
|
608
|
+
record.accessCount,
|
|
609
|
+
record.lastAccessed || null,
|
|
610
|
+
record.decayFactor,
|
|
611
|
+
record.consolidatedFrom
|
|
612
|
+
? this.cipher.encrypt(JSON.stringify(record.consolidatedFrom))
|
|
613
|
+
: null,
|
|
614
|
+
]);
|
|
615
|
+
}
|
|
616
|
+
async findByOwner(memoryId, userId, personaId) {
|
|
617
|
+
const result = await this.database.query(`SELECT * FROM platform_persona_memories
|
|
618
|
+
WHERE id = $1 AND user_id = $2 AND persona_id = $3`, [memoryId, userId, personaId]);
|
|
619
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
620
|
+
}
|
|
621
|
+
async listByOwner(userId, personaId, options = {}) {
|
|
622
|
+
const parameters = [userId, personaId];
|
|
623
|
+
let predicate = 'user_id = $1 AND persona_id = $2';
|
|
624
|
+
if (options.types?.length) {
|
|
625
|
+
parameters.push([...options.types]);
|
|
626
|
+
predicate += ` AND memory_type = ANY($${parameters.length}::text[])`;
|
|
627
|
+
}
|
|
628
|
+
if (options.minimumImportance !== undefined) {
|
|
629
|
+
parameters.push(options.minimumImportance);
|
|
630
|
+
predicate += ` AND importance_score >= $${parameters.length}`;
|
|
631
|
+
}
|
|
632
|
+
const limit = Math.min(Math.max(options.limit ?? 100, 1), 10000);
|
|
633
|
+
const offset = Math.max(options.offset ?? 0, 0);
|
|
634
|
+
parameters.push(limit, offset);
|
|
635
|
+
const result = await this.database.query(`SELECT * FROM platform_persona_memories WHERE ${predicate}
|
|
636
|
+
ORDER BY timestamp DESC, id ASC
|
|
637
|
+
LIMIT $${parameters.length - 1} OFFSET $${parameters.length}`, parameters);
|
|
638
|
+
return result.rows.map(row => this.map(row));
|
|
639
|
+
}
|
|
640
|
+
async countByOwner(userId, personaId) {
|
|
641
|
+
const result = await this.database.query(`SELECT COUNT(*)::text AS count FROM platform_persona_memories
|
|
642
|
+
WHERE user_id = $1 AND persona_id = $2`, [userId, personaId]);
|
|
643
|
+
return safeInteger(result.rows[0]?.count ?? 0, 'memory count');
|
|
644
|
+
}
|
|
645
|
+
async reinforce(memoryId, userId, personaId, accessedAt) {
|
|
646
|
+
const result = await this.database.query(`UPDATE platform_persona_memories
|
|
647
|
+
SET access_count = access_count + 1, last_accessed = $1,
|
|
648
|
+
importance_score = LEAST(1.0, importance_score + 0.05)
|
|
649
|
+
WHERE id = $2 AND user_id = $3 AND persona_id = $4`, [accessedAt, memoryId, userId, personaId]);
|
|
650
|
+
return result.rowCount === 1;
|
|
651
|
+
}
|
|
652
|
+
async markAccessed(ids, userId, personaId, accessedAt) {
|
|
653
|
+
if (ids.length === 0)
|
|
654
|
+
return 0;
|
|
655
|
+
const result = await this.database.query(`UPDATE platform_persona_memories
|
|
656
|
+
SET access_count = access_count + 1, last_accessed = $1
|
|
657
|
+
WHERE user_id = $2 AND persona_id = $3 AND id = ANY($4::text[])`, [accessedAt, userId, personaId, [...ids]]);
|
|
658
|
+
return result.rowCount ?? 0;
|
|
659
|
+
}
|
|
660
|
+
async updateImportance(memoryId, userId, personaId, importanceScore, decayFactor) {
|
|
661
|
+
const result = await this.database.query(`UPDATE platform_persona_memories
|
|
662
|
+
SET importance_score = $1, decay_factor = COALESCE($2, decay_factor)
|
|
663
|
+
WHERE id = $3 AND user_id = $4 AND persona_id = $5`, [importanceScore, decayFactor ?? null, memoryId, userId, personaId]);
|
|
664
|
+
return result.rowCount === 1;
|
|
665
|
+
}
|
|
666
|
+
async deleteIds(ids, userId, personaId) {
|
|
667
|
+
if (ids.length === 0)
|
|
668
|
+
return 0;
|
|
669
|
+
const result = await this.database.query(`DELETE FROM platform_persona_memories
|
|
670
|
+
WHERE user_id = $1 AND persona_id = $2 AND id = ANY($3::text[])`, [userId, personaId, [...ids]]);
|
|
671
|
+
return result.rowCount ?? 0;
|
|
672
|
+
}
|
|
673
|
+
async deleteAllByOwner(userId, personaId) {
|
|
674
|
+
const result = await this.database.query('DELETE FROM platform_persona_memories WHERE user_id = $1 AND persona_id = $2', [userId, personaId]);
|
|
675
|
+
return result.rowCount ?? 0;
|
|
676
|
+
}
|
|
677
|
+
async findOldLowImportanceIds(userId, personaId, cutoff, maximumImportance) {
|
|
678
|
+
const result = await this.database.query(`SELECT id FROM platform_persona_memories
|
|
679
|
+
WHERE user_id = $1 AND persona_id = $2 AND timestamp < $3
|
|
680
|
+
AND importance_score < $4
|
|
681
|
+
ORDER BY timestamp, id`, [userId, personaId, cutoff, maximumImportance]);
|
|
682
|
+
return result.rows.map(row => row.id);
|
|
683
|
+
}
|
|
684
|
+
async deleteOldLowImportance(userId, personaId, cutoff, maximumImportance) {
|
|
685
|
+
const result = await this.database.query(`DELETE FROM platform_persona_memories
|
|
686
|
+
WHERE user_id = $1 AND persona_id = $2 AND timestamp < $3
|
|
687
|
+
AND importance_score < $4 RETURNING id`, [userId, personaId, cutoff, maximumImportance]);
|
|
688
|
+
return result.rows.map(row => row.id);
|
|
689
|
+
}
|
|
690
|
+
async statistics(userId, personaId) {
|
|
691
|
+
const types = await this.database.query(`SELECT memory_type, COUNT(*)::text AS count
|
|
692
|
+
FROM platform_persona_memories
|
|
693
|
+
WHERE user_id = $1 AND persona_id = $2 GROUP BY memory_type`, [userId, personaId]);
|
|
694
|
+
const aggregate = await this.database.query(`SELECT COUNT(*)::text AS total_count,
|
|
695
|
+
AVG(importance_score)::text AS avg_importance,
|
|
696
|
+
MIN(timestamp) AS oldest_memory, MAX(timestamp) AS newest_memory,
|
|
697
|
+
COALESCE(SUM(access_count), 0)::text AS total_accesses
|
|
698
|
+
FROM platform_persona_memories
|
|
699
|
+
WHERE user_id = $1 AND persona_id = $2`, [userId, personaId]);
|
|
700
|
+
const row = aggregate.rows[0];
|
|
701
|
+
return {
|
|
702
|
+
totalCount: safeInteger(row?.total_count ?? 0, 'memory count'),
|
|
703
|
+
byType: Object.fromEntries(types.rows.map(item => [
|
|
704
|
+
item.memory_type,
|
|
705
|
+
safeInteger(item.count, 'memory type count'),
|
|
706
|
+
])),
|
|
707
|
+
averageImportance: row?.avg_importance ? Number(row.avg_importance) : 0.5,
|
|
708
|
+
oldestMemory: row?.oldest_memory === null || row?.oldest_memory === undefined
|
|
709
|
+
? null
|
|
710
|
+
: safeInteger(row.oldest_memory, 'oldest memory'),
|
|
711
|
+
newestMemory: row?.newest_memory === null || row?.newest_memory === undefined
|
|
712
|
+
? null
|
|
713
|
+
: safeInteger(row.newest_memory, 'newest memory'),
|
|
714
|
+
totalAccesses: safeInteger(row?.total_accesses ?? 0, 'memory accesses'),
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
class PostgresPersonaRepository {
|
|
719
|
+
constructor(database, cipher) {
|
|
720
|
+
this.database = database;
|
|
721
|
+
this.cipher = cipher;
|
|
722
|
+
}
|
|
723
|
+
map(row) {
|
|
724
|
+
const parse = (value) => value
|
|
725
|
+
? JSON.parse(this.cipher.decryptAuthenticated(value))
|
|
726
|
+
: undefined;
|
|
727
|
+
return {
|
|
728
|
+
id: row.id,
|
|
729
|
+
user_id: row.user_id,
|
|
730
|
+
name: this.cipher.decryptAuthenticated(row.name),
|
|
731
|
+
...(row.description
|
|
732
|
+
? { description: this.cipher.decryptAuthenticated(row.description) }
|
|
733
|
+
: {}),
|
|
734
|
+
model: row.model,
|
|
735
|
+
parameters: parse(row.parameters) || {},
|
|
736
|
+
...(row.avatar
|
|
737
|
+
? { avatar: this.cipher.decryptAuthenticated(row.avatar) }
|
|
738
|
+
: {}),
|
|
739
|
+
...(row.background
|
|
740
|
+
? { background: this.cipher.decryptAuthenticated(row.background) }
|
|
741
|
+
: {}),
|
|
742
|
+
...(row.embedding_model ? { embedding_model: row.embedding_model } : {}),
|
|
743
|
+
...(row.memory_settings
|
|
744
|
+
? {
|
|
745
|
+
memory_settings: parse(row.memory_settings),
|
|
746
|
+
}
|
|
747
|
+
: {}),
|
|
748
|
+
...(row.mutation_settings
|
|
749
|
+
? {
|
|
750
|
+
mutation_settings: parse(row.mutation_settings),
|
|
751
|
+
}
|
|
752
|
+
: {}),
|
|
753
|
+
created_at: safeInteger(row.created_at, 'persona creation time'),
|
|
754
|
+
updated_at: safeInteger(row.updated_at, 'persona update time'),
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
async listByOwner(userId) {
|
|
758
|
+
const result = await this.database.query('SELECT * FROM personas WHERE user_id = $1 ORDER BY updated_at DESC, id ASC', [userId]);
|
|
759
|
+
return result.rows.map(row => this.map(row));
|
|
760
|
+
}
|
|
761
|
+
async findByOwner(id, userId) {
|
|
762
|
+
const result = await this.database.query('SELECT * FROM personas WHERE id = $1 AND user_id = $2', [id, userId]);
|
|
763
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
764
|
+
}
|
|
765
|
+
async insert(persona) {
|
|
766
|
+
await this.database.transaction(async (client) => {
|
|
767
|
+
await assertResourceIdentifierAvailable(client, 'persona', persona.id);
|
|
768
|
+
await client.query(`INSERT INTO personas
|
|
769
|
+
(id, user_id, name, description, model, parameters, avatar,
|
|
770
|
+
background, embedding_model, memory_settings, mutation_settings,
|
|
771
|
+
created_at, updated_at)
|
|
772
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`, [
|
|
773
|
+
persona.id,
|
|
774
|
+
persona.user_id,
|
|
775
|
+
this.cipher.encrypt(persona.name),
|
|
776
|
+
persona.description
|
|
777
|
+
? this.cipher.encrypt(persona.description)
|
|
778
|
+
: null,
|
|
779
|
+
persona.model,
|
|
780
|
+
this.cipher.encrypt(JSON.stringify(persona.parameters)),
|
|
781
|
+
persona.avatar ? this.cipher.encrypt(persona.avatar) : null,
|
|
782
|
+
persona.background ? this.cipher.encrypt(persona.background) : null,
|
|
783
|
+
persona.embedding_model || null,
|
|
784
|
+
persona.memory_settings
|
|
785
|
+
? this.cipher.encrypt(JSON.stringify(persona.memory_settings))
|
|
786
|
+
: null,
|
|
787
|
+
persona.mutation_settings
|
|
788
|
+
? this.cipher.encrypt(JSON.stringify(persona.mutation_settings))
|
|
789
|
+
: null,
|
|
790
|
+
persona.created_at,
|
|
791
|
+
persona.updated_at,
|
|
792
|
+
]);
|
|
793
|
+
}, { isolationLevel: 'serializable' });
|
|
794
|
+
}
|
|
795
|
+
async replace(persona) {
|
|
796
|
+
const result = await this.database.query(`UPDATE personas SET name = $1, description = $2, model = $3,
|
|
797
|
+
parameters = $4, avatar = $5, background = $6,
|
|
798
|
+
embedding_model = $7, memory_settings = $8,
|
|
799
|
+
mutation_settings = $9, updated_at = $10
|
|
800
|
+
WHERE id = $11 AND user_id = $12`, [
|
|
801
|
+
this.cipher.encrypt(persona.name),
|
|
802
|
+
persona.description ? this.cipher.encrypt(persona.description) : null,
|
|
803
|
+
persona.model,
|
|
804
|
+
this.cipher.encrypt(JSON.stringify(persona.parameters)),
|
|
805
|
+
persona.avatar ? this.cipher.encrypt(persona.avatar) : null,
|
|
806
|
+
persona.background ? this.cipher.encrypt(persona.background) : null,
|
|
807
|
+
persona.embedding_model || null,
|
|
808
|
+
persona.memory_settings
|
|
809
|
+
? this.cipher.encrypt(JSON.stringify(persona.memory_settings))
|
|
810
|
+
: null,
|
|
811
|
+
persona.mutation_settings
|
|
812
|
+
? this.cipher.encrypt(JSON.stringify(persona.mutation_settings))
|
|
813
|
+
: null,
|
|
814
|
+
persona.updated_at,
|
|
815
|
+
persona.id,
|
|
816
|
+
persona.user_id,
|
|
817
|
+
]);
|
|
818
|
+
return result.rowCount === 1;
|
|
819
|
+
}
|
|
820
|
+
async patchByOwner(id, userId, patch) {
|
|
821
|
+
const assignments = [];
|
|
822
|
+
const values = [];
|
|
823
|
+
const assign = (column, value) => {
|
|
824
|
+
values.push(value);
|
|
825
|
+
assignments.push(`${column} = $${values.length}`);
|
|
826
|
+
};
|
|
827
|
+
if (patch.name !== undefined) {
|
|
828
|
+
assign('name', this.cipher.encrypt(patch.name));
|
|
829
|
+
}
|
|
830
|
+
if (patch.description !== undefined) {
|
|
831
|
+
assign('description', patch.description === null
|
|
832
|
+
? null
|
|
833
|
+
: this.cipher.encrypt(patch.description));
|
|
834
|
+
}
|
|
835
|
+
if (patch.model !== undefined)
|
|
836
|
+
assign('model', patch.model);
|
|
837
|
+
if (patch.parameters !== undefined) {
|
|
838
|
+
assign('parameters', this.cipher.encrypt(JSON.stringify(patch.parameters)));
|
|
839
|
+
}
|
|
840
|
+
if (patch.avatar !== undefined) {
|
|
841
|
+
assign('avatar', patch.avatar === null ? null : this.cipher.encrypt(patch.avatar));
|
|
842
|
+
}
|
|
843
|
+
if (patch.background !== undefined) {
|
|
844
|
+
assign('background', patch.background === null ? null : this.cipher.encrypt(patch.background));
|
|
845
|
+
}
|
|
846
|
+
if (patch.embedding_model !== undefined) {
|
|
847
|
+
assign('embedding_model', patch.embedding_model);
|
|
848
|
+
}
|
|
849
|
+
if (patch.memory_settings !== undefined) {
|
|
850
|
+
assign('memory_settings', patch.memory_settings === null
|
|
851
|
+
? null
|
|
852
|
+
: this.cipher.encrypt(JSON.stringify(patch.memory_settings)));
|
|
853
|
+
}
|
|
854
|
+
if (patch.mutation_settings !== undefined) {
|
|
855
|
+
assign('mutation_settings', patch.mutation_settings === null
|
|
856
|
+
? null
|
|
857
|
+
: this.cipher.encrypt(JSON.stringify(patch.mutation_settings)));
|
|
858
|
+
}
|
|
859
|
+
assign('updated_at', patch.updated_at);
|
|
860
|
+
values.push(id, userId);
|
|
861
|
+
const result = await this.database.query(`UPDATE personas SET ${assignments.join(', ')}
|
|
862
|
+
WHERE id = $${values.length - 1} AND user_id = $${values.length}
|
|
863
|
+
RETURNING *`, values);
|
|
864
|
+
return result.rows[0] ? this.map(result.rows[0]) : undefined;
|
|
865
|
+
}
|
|
866
|
+
async deleteByOwner(id, userId) {
|
|
867
|
+
const result = await this.database.query('DELETE FROM personas WHERE id = $1 AND user_id = $2', [id, userId]);
|
|
868
|
+
return result.rowCount === 1;
|
|
869
|
+
}
|
|
870
|
+
async deleteAndEnqueue(id, userId, enqueuer) {
|
|
871
|
+
return this.database.transaction(async (client) => {
|
|
872
|
+
await lockResourceIdentifier(client, 'persona', id);
|
|
873
|
+
const existing = await client.query('SELECT 1 FROM personas WHERE id = $1 AND user_id = $2 FOR UPDATE', [id, userId]);
|
|
874
|
+
if (existing.rowCount !== 1)
|
|
875
|
+
return false;
|
|
876
|
+
const deletion = await recordResourceDeletion(client, {
|
|
877
|
+
resourceType: 'persona',
|
|
878
|
+
resourceId: id,
|
|
879
|
+
ownerUserId: userId,
|
|
880
|
+
});
|
|
881
|
+
const deleted = await client.query('DELETE FROM personas WHERE id = $1 AND user_id = $2', [id, userId]);
|
|
882
|
+
if (deleted.rowCount !== 1) {
|
|
883
|
+
throw new Error('Persona disappeared during deletion');
|
|
884
|
+
}
|
|
885
|
+
await enqueuer.enqueuePostgres(client, deletion);
|
|
886
|
+
return true;
|
|
887
|
+
}, { isolationLevel: 'serializable' });
|
|
888
|
+
}
|
|
889
|
+
async countByOwner(userId) {
|
|
890
|
+
const result = await this.database.query('SELECT COUNT(*)::text AS count FROM personas WHERE user_id = $1', [
|
|
891
|
+
userId,
|
|
892
|
+
]);
|
|
893
|
+
return safeInteger(result.rows[0]?.count ?? 0, 'persona count');
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
class PostgresPersonaStateRepository {
|
|
897
|
+
constructor(database, cipher) {
|
|
898
|
+
this.database = database;
|
|
899
|
+
this.cipher = cipher;
|
|
900
|
+
}
|
|
901
|
+
async findByOwner(personaId, userId) {
|
|
902
|
+
const result = await this.database.query(`SELECT * FROM platform_persona_states
|
|
903
|
+
WHERE persona_id = $1 AND user_id = $2`, [personaId, userId]);
|
|
904
|
+
const row = result.rows[0];
|
|
905
|
+
if (!row)
|
|
906
|
+
return undefined;
|
|
907
|
+
return {
|
|
908
|
+
persona_id: row.persona_id,
|
|
909
|
+
user_id: row.user_id,
|
|
910
|
+
runtime_state: JSON.parse(this.cipher.decryptAuthenticated(row.encrypted_runtime_state)),
|
|
911
|
+
mutation_log: JSON.parse(this.cipher.decryptAuthenticated(row.encrypted_mutation_log)),
|
|
912
|
+
last_updated: safeInteger(row.last_updated, 'persona state update time'),
|
|
913
|
+
version: row.version,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
async upsert(state) {
|
|
917
|
+
const result = await this.database.query(`INSERT INTO platform_persona_states
|
|
918
|
+
(persona_id, user_id, encrypted_runtime_state,
|
|
919
|
+
encrypted_mutation_log, last_updated, version)
|
|
920
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
921
|
+
ON CONFLICT(persona_id) DO UPDATE SET
|
|
922
|
+
encrypted_runtime_state = EXCLUDED.encrypted_runtime_state,
|
|
923
|
+
encrypted_mutation_log = EXCLUDED.encrypted_mutation_log,
|
|
924
|
+
last_updated = EXCLUDED.last_updated,
|
|
925
|
+
version = EXCLUDED.version
|
|
926
|
+
WHERE platform_persona_states.user_id = EXCLUDED.user_id`, [
|
|
927
|
+
state.persona_id,
|
|
928
|
+
state.user_id,
|
|
929
|
+
this.cipher.encrypt(JSON.stringify(state.runtime_state)),
|
|
930
|
+
this.cipher.encrypt(JSON.stringify(state.mutation_log)),
|
|
931
|
+
state.last_updated,
|
|
932
|
+
state.version,
|
|
933
|
+
]);
|
|
934
|
+
if (result.rowCount === 0) {
|
|
935
|
+
throw new Error('Persona state identifier belongs to another owner');
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
async deleteByOwner(personaId, userId) {
|
|
939
|
+
const result = await this.database.query(`DELETE FROM platform_persona_states
|
|
940
|
+
WHERE persona_id = $1 AND user_id = $2`, [personaId, userId]);
|
|
941
|
+
return result.rowCount === 1;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
class PostgresResourceDeletionLifecycleRepository {
|
|
945
|
+
constructor(database) {
|
|
946
|
+
this.database = database;
|
|
947
|
+
}
|
|
948
|
+
async cleanupAuthorizedUsing(executor, input) {
|
|
949
|
+
const table = resourceTable(input.resourceType);
|
|
950
|
+
const result = await executor.query(`SELECT 1
|
|
951
|
+
FROM platform_resource_deletion_tombstones tombstone
|
|
952
|
+
WHERE tombstone.resource_type = $1
|
|
953
|
+
AND tombstone.resource_id = $2
|
|
954
|
+
AND tombstone.owner_user_id = $3
|
|
955
|
+
AND tombstone.deletion_incarnation = $4
|
|
956
|
+
AND tombstone.deletion_token = $5
|
|
957
|
+
AND NOT EXISTS (
|
|
958
|
+
SELECT 1 FROM ${table} resource
|
|
959
|
+
WHERE resource.id = tombstone.resource_id
|
|
960
|
+
AND resource.user_id = tombstone.owner_user_id
|
|
961
|
+
)`, [
|
|
962
|
+
input.resourceType,
|
|
963
|
+
input.resourceId,
|
|
964
|
+
input.ownerUserId,
|
|
965
|
+
input.deletionIncarnation,
|
|
966
|
+
input.deletionToken,
|
|
967
|
+
]);
|
|
968
|
+
return result.rowCount === 1;
|
|
969
|
+
}
|
|
970
|
+
async withAuthorizedCleanup(input, operation) {
|
|
971
|
+
return this.database.transaction(async (client) => {
|
|
972
|
+
await lockResourceIdentifier(client, input.resourceType, input.resourceId);
|
|
973
|
+
if (!(await this.cleanupAuthorizedUsing(client, input))) {
|
|
974
|
+
return { authorized: false };
|
|
975
|
+
}
|
|
976
|
+
return { authorized: true, value: await operation() };
|
|
977
|
+
}, { isolationLevel: 'serializable' });
|
|
978
|
+
}
|
|
979
|
+
async isReserved(resourceType, resourceId) {
|
|
980
|
+
const result = await this.database.query(`SELECT 1 FROM platform_resource_deletion_tombstones
|
|
981
|
+
WHERE resource_type = $1 AND resource_id = $2`, [resourceType, resourceId]);
|
|
982
|
+
return result.rowCount === 1;
|
|
983
|
+
}
|
|
984
|
+
async isCleanupAuthorized(input) {
|
|
985
|
+
return this.cleanupAuthorizedUsing(this.database, input);
|
|
986
|
+
}
|
|
987
|
+
async markCleanupCompleted(input) {
|
|
988
|
+
const table = resourceTable(input.resourceType);
|
|
989
|
+
const result = await this.database.query(`UPDATE platform_resource_deletion_tombstones
|
|
990
|
+
SET completed_at = COALESCE(completed_at, $1)
|
|
991
|
+
WHERE resource_type = $2 AND resource_id = $3 AND owner_user_id = $4
|
|
992
|
+
AND deletion_incarnation = $5 AND deletion_token = $6
|
|
993
|
+
AND NOT EXISTS (
|
|
994
|
+
SELECT 1 FROM ${table} resource
|
|
995
|
+
WHERE resource.id = platform_resource_deletion_tombstones.resource_id
|
|
996
|
+
AND resource.user_id = platform_resource_deletion_tombstones.owner_user_id
|
|
997
|
+
)`, [
|
|
998
|
+
Date.now(),
|
|
999
|
+
input.resourceType,
|
|
1000
|
+
input.resourceId,
|
|
1001
|
+
input.ownerUserId,
|
|
1002
|
+
input.deletionIncarnation,
|
|
1003
|
+
input.deletionToken,
|
|
1004
|
+
]);
|
|
1005
|
+
return result.rowCount === 1;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
export const createPostgresPlatformDomainRepositories = (database, cipher) => ({
|
|
1009
|
+
documents: new PostgresDocumentRepository(database, cipher),
|
|
1010
|
+
gallery: new PostgresGalleryMetadataRepository(database, cipher),
|
|
1011
|
+
mediaJobs: new PostgresMediaGenerationJobRepository(database, cipher),
|
|
1012
|
+
memories: new PostgresPersonaMemoryRepository(database, cipher),
|
|
1013
|
+
personas: new PostgresPersonaRepository(database, cipher),
|
|
1014
|
+
personaStates: new PostgresPersonaStateRepository(database, cipher),
|
|
1015
|
+
resourceDeletions: new PostgresResourceDeletionLifecycleRepository(database),
|
|
1016
|
+
});
|
|
1017
|
+
//# sourceMappingURL=postgresPlatformDomainRepositories.js.map
|