libre-webui 0.21.2 → 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 +136 -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 +97 -34
- 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 +15 -4
- 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 +36 -18
- package/frontend/dist/js/{ArtifactContainer-C_UdeK4k.js → ArtifactContainer-BTEDhBnv.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-D3AuvuR5.js → ArtifactDemoPage-B0gN3YTl.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-BiXl9iGD.js → ArtifactSandboxFrame-CLBXQkZs.js} +3 -3
- package/frontend/dist/js/{ArtifactSlideOutPanel-CvgS3sfQ.js → ArtifactSlideOutPanel-CfqHPFdE.js} +1 -1
- package/frontend/dist/js/{Button-DcBM7gdH.js → Button-BV44cTnj.js} +1 -1
- package/frontend/dist/js/ChatPage-DIkAXZWA.js +23 -0
- package/frontend/dist/js/{FirstTimeSetup-B9742i3H.js → FirstTimeSetup-B8phXGNA.js} +1 -1
- package/frontend/dist/js/GalleryPage-W4uI043I.js +1 -0
- package/frontend/dist/js/HomePage-DlxehbyO.js +1 -0
- package/frontend/dist/js/{LibreClawPage-Ds6pqEyk.js → LibreClawPage-CgD0_G_F.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-BBNg2fxs.js → ModelManagerModals-D7jIT3v1.js} +1 -1
- package/frontend/dist/js/{ModelSelector-CJfJYwxh.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-CbQVv9OM.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-Uz2jvV64.js → SettingsToggle-WTa0rgvY.js} +1 -1
- package/frontend/dist/js/{SystemPage-CIBDZTWB.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-CV8L89A5.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-Lx6fK8Ug.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-Dx5reqmV.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-Bd5G8zQB.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-CUWSpffv.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-DLNXiOUi.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-YKxslwSt.js → typescript-CQ3x-Uni.js} +1 -1
- package/frontend/dist/js/{ui-Dw6jDKxN.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-t1quV8ce.js → useTranslation-C3ei3mJq.js} +1 -1
- package/frontend/dist/js/{utils-iKndEgla.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-LrQmhNxb.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-CN7wpzUO.js +0 -26
- package/frontend/dist/assets/index-Dqkx5o2y.css +0 -1
- package/frontend/dist/js/ChatPage-DBEi-FSO.js +0 -16
- package/frontend/dist/js/GalleryPage-BL0x_xl7.js +0 -1
- package/frontend/dist/js/HomePage-Ukn2Y-BG.js +0 -1
- package/frontend/dist/js/ModelsPage-CDPJM-LA.js +0 -2
- package/frontend/dist/js/NotesPage-DJ-_MSI1.js +0 -1
- package/frontend/dist/js/PluginUsagePage-D69rQvFl.js +0 -1
- package/frontend/dist/js/RichMessageContent-DfuCu6PB.js +0 -3
- package/frontend/dist/js/SettingsModal-D87lWSx4.js +0 -1
- package/frontend/dist/js/UserManagementPage-DzMnFKDG.js +0 -1
- package/frontend/dist/js/WorkPage-D84JNdjS.js +0 -6
- package/frontend/dist/js/api-DhmVEJr2.js +0 -14
- package/frontend/dist/js/appStore-BsqeY2tS.js +0 -2
- package/frontend/dist/js/ar-BgCHB9_9.js +0 -2
- package/frontend/dist/js/authStore-DanfaPdm.js +0 -4
- package/frontend/dist/js/bn-Cr8_opuR.js +0 -2
- package/frontend/dist/js/chatStore-C25ywAXQ.js +0 -3
- package/frontend/dist/js/cs-Bb9gXpfH.js +0 -2
- package/frontend/dist/js/da-JfdGHjAw.js +0 -2
- package/frontend/dist/js/de-CczkCOVx.js +0 -2
- package/frontend/dist/js/es-n_0cjhn7.js +0 -2
- package/frontend/dist/js/fr-Pno128cn.js +0 -2
- package/frontend/dist/js/hi-DBCdcL4p.js +0 -2
- package/frontend/dist/js/id-85QDk-wA.js +0 -2
- package/frontend/dist/js/is-9MuKmBft.js +0 -2
- package/frontend/dist/js/it-C5mz9I3H.js +0 -2
- package/frontend/dist/js/ja-Cu90QTBd.js +0 -2
- package/frontend/dist/js/ko-CSdgcMgq.js +0 -2
- package/frontend/dist/js/markdown-core-DHnR5Hw8.js +0 -16
- package/frontend/dist/js/ms-IQMi6HBU.js +0 -2
- package/frontend/dist/js/nl-BwpdTgvn.js +0 -2
- package/frontend/dist/js/pl-zq8ctKrQ.js +0 -2
- package/frontend/dist/js/pt-BIQu7dBu.js +0 -2
- package/frontend/dist/js/ru-BT5-Z0F9.js +0 -2
- package/frontend/dist/js/sv-B1_q6-Uj.js +0 -2
- package/frontend/dist/js/th-BiLLwq0A.js +0 -2
- package/frontend/dist/js/tr-NZbkkeKs.js +0 -2
- package/frontend/dist/js/ui-vendor-xUzKqAXI.js +0 -177
- package/frontend/dist/js/uk-CGu1pg-F.js +0 -2
- package/frontend/dist/js/vi-ClvH5JZg.js +0 -2
- package/frontend/dist/js/zh-Jgjy3uAG.js +0 -2
|
@@ -0,0 +1,1027 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Libre WebUI
|
|
3
|
+
* Copyright (C) 2025 Kroonen AI, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at:
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'crypto';
|
|
18
|
+
import storageService from '../storage.js';
|
|
19
|
+
import { getPersistence } from '../persistence/index.js';
|
|
20
|
+
import { PersistenceResourceDeletionReservedError } from '../persistence/resourceTypes.js';
|
|
21
|
+
import { createLogger } from '../utils/logger.js';
|
|
22
|
+
import { MAX_NOTES_PER_USER, MAX_NOTE_CONTENT_LENGTH, MAX_NOTE_TITLE_LENGTH, MAX_SESSION_FOLDERS_PER_USER, } from '../utils/resourceLimits.js';
|
|
23
|
+
import preferencesService from './preferencesService.js';
|
|
24
|
+
import { encryptionService } from './encryptionService.js';
|
|
25
|
+
const logger = createLogger('services:data-archive');
|
|
26
|
+
export const DATA_ARCHIVE_FORMAT = 'libre-webui-user-data';
|
|
27
|
+
export const DATA_ARCHIVE_VERSION = 3;
|
|
28
|
+
export const DATA_ARCHIVE_MAX_BYTES = 50 * 1024 * 1024;
|
|
29
|
+
export const DATA_ARCHIVE_CANONICALIZATION = 'libre-json-sort-v1';
|
|
30
|
+
const LEGACY_ARCHIVE_FORMAT = 'libre-webui-export';
|
|
31
|
+
const MAX_ARCHIVE_SESSIONS = 5000;
|
|
32
|
+
const MAX_ARCHIVE_MESSAGES = 100000;
|
|
33
|
+
const MAX_ARCHIVE_DOCUMENTS = 5000;
|
|
34
|
+
const MAX_ARCHIVE_CHUNKS = 100000;
|
|
35
|
+
const MAX_ARCHIVE_FOLDERS = MAX_SESSION_FOLDERS_PER_USER;
|
|
36
|
+
const MAX_ARCHIVE_NOTES = MAX_NOTES_PER_USER;
|
|
37
|
+
const MAX_ARCHIVE_COLLECTIONS = 5000;
|
|
38
|
+
const MAX_ID_LENGTH = 256;
|
|
39
|
+
const MAX_TITLE_LENGTH = 10000;
|
|
40
|
+
const MAX_CONTENT_LENGTH = 2000000;
|
|
41
|
+
export const DATA_ARCHIVE_EXCLUSIONS = [
|
|
42
|
+
{
|
|
43
|
+
key: 'accountAndAuthentication',
|
|
44
|
+
reason: 'Account records, passwords, OAuth state, and sessions are never portable.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: 'providerSecrets',
|
|
48
|
+
reason: 'Plugin credentials and encrypted plugin variables must be configured again.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'voiceProfiles',
|
|
52
|
+
reason: 'Voice-cloning reference audio is biometric data and requires separate consent-aware handling with its transcript.',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: 'personasAndMemory',
|
|
56
|
+
reason: 'Personas and persona memory are not part of archive version 3.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: 'generatedMedia',
|
|
60
|
+
reason: 'Generated image, audio, and video library files are not part of archive version 3.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: 'work',
|
|
64
|
+
reason: 'Work tasks, runs, sandboxes, and Docker or Kubernetes volumes require a system backup.',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: 'derivedEmbeddings',
|
|
68
|
+
reason: 'Document embeddings are derived data and can be regenerated after import.',
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
class DataArchiveValidationError extends Error {
|
|
72
|
+
constructor(message) {
|
|
73
|
+
super(message);
|
|
74
|
+
this.statusCode = 400;
|
|
75
|
+
this.name = 'DataArchiveValidationError';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function canonicalJson(value) {
|
|
79
|
+
if (value === null || typeof value !== 'object') {
|
|
80
|
+
return JSON.stringify(value);
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return `[${value.map(entry => canonicalJson(entry)).join(',')}]`;
|
|
84
|
+
}
|
|
85
|
+
return `{${Object.keys(value)
|
|
86
|
+
.sort()
|
|
87
|
+
.map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
88
|
+
.join(',')}}`;
|
|
89
|
+
}
|
|
90
|
+
function archivePayloadForIntegrity(value) {
|
|
91
|
+
const { integrity: _integrity, ...payload } = value;
|
|
92
|
+
return payload;
|
|
93
|
+
}
|
|
94
|
+
function computeArchiveDigest(value) {
|
|
95
|
+
const payload = archivePayloadForIntegrity(value);
|
|
96
|
+
const jsonSafe = JSON.parse(JSON.stringify(payload));
|
|
97
|
+
return createHash('sha256').update(canonicalJson(jsonSafe)).digest('hex');
|
|
98
|
+
}
|
|
99
|
+
function sealArchive(value) {
|
|
100
|
+
const payload = value;
|
|
101
|
+
return {
|
|
102
|
+
...value,
|
|
103
|
+
integrity: {
|
|
104
|
+
algorithm: 'sha256',
|
|
105
|
+
canonicalization: DATA_ARCHIVE_CANONICALIZATION,
|
|
106
|
+
digest: computeArchiveDigest(payload),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function verifyArchiveIntegrity(value) {
|
|
111
|
+
const integrity = requireRecord(value.integrity, 'integrity');
|
|
112
|
+
if (integrity.algorithm !== 'sha256') {
|
|
113
|
+
throw new DataArchiveValidationError('integrity.algorithm must be "sha256"');
|
|
114
|
+
}
|
|
115
|
+
if (integrity.canonicalization !== DATA_ARCHIVE_CANONICALIZATION) {
|
|
116
|
+
throw new DataArchiveValidationError(`integrity.canonicalization must be "${DATA_ARCHIVE_CANONICALIZATION}"`);
|
|
117
|
+
}
|
|
118
|
+
const digest = requireString(integrity.digest, 'integrity.digest', 64);
|
|
119
|
+
if (!/^[a-f0-9]{64}$/.test(digest)) {
|
|
120
|
+
throw new DataArchiveValidationError('integrity.digest must be a lowercase SHA-256 digest');
|
|
121
|
+
}
|
|
122
|
+
if (digest !== computeArchiveDigest(value)) {
|
|
123
|
+
throw new DataArchiveValidationError('Portable archive integrity check failed; the file is incomplete or was modified');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function isRecord(value) {
|
|
127
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
128
|
+
}
|
|
129
|
+
function requireRecord(value, path) {
|
|
130
|
+
if (!isRecord(value)) {
|
|
131
|
+
throw new DataArchiveValidationError(`${path} must be an object`);
|
|
132
|
+
}
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
function requireArray(value, path) {
|
|
136
|
+
if (!Array.isArray(value)) {
|
|
137
|
+
throw new DataArchiveValidationError(`${path} must be an array`);
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
function requireString(value, path, maxLength = MAX_CONTENT_LENGTH) {
|
|
142
|
+
if (typeof value !== 'string' || value.length > maxLength) {
|
|
143
|
+
throw new DataArchiveValidationError(`${path} must be a string no longer than ${maxLength} characters`);
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function requireNonEmptyString(value, path, maxLength = MAX_ID_LENGTH) {
|
|
148
|
+
const result = requireString(value, path, maxLength);
|
|
149
|
+
if (!result.trim()) {
|
|
150
|
+
throw new DataArchiveValidationError(`${path} must not be empty`);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
function optionalString(value, path, maxLength = MAX_CONTENT_LENGTH) {
|
|
155
|
+
return value === undefined || value === null
|
|
156
|
+
? undefined
|
|
157
|
+
: requireString(value, path, maxLength);
|
|
158
|
+
}
|
|
159
|
+
function requireTimestamp(value, path) {
|
|
160
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
|
|
161
|
+
throw new DataArchiveValidationError(`${path} must be a valid timestamp`);
|
|
162
|
+
}
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
function optionalBoolean(value, path) {
|
|
166
|
+
if (value === undefined || value === null)
|
|
167
|
+
return undefined;
|
|
168
|
+
if (typeof value !== 'boolean') {
|
|
169
|
+
throw new DataArchiveValidationError(`${path} must be a boolean`);
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
function copyJsonRecord(value, path) {
|
|
174
|
+
const record = requireRecord(value, path);
|
|
175
|
+
return JSON.parse(JSON.stringify(record));
|
|
176
|
+
}
|
|
177
|
+
const preferenceKeys = new Set([
|
|
178
|
+
'defaultModel',
|
|
179
|
+
'defaultProviderType',
|
|
180
|
+
'defaultProviderId',
|
|
181
|
+
'visionModel',
|
|
182
|
+
'visionProviderType',
|
|
183
|
+
'visionProviderId',
|
|
184
|
+
'theme',
|
|
185
|
+
'systemMessage',
|
|
186
|
+
'generationOptions',
|
|
187
|
+
'modelGenerationOptions',
|
|
188
|
+
'embeddingSettings',
|
|
189
|
+
'ttsSettings',
|
|
190
|
+
'imageGenSettings',
|
|
191
|
+
'titleSettings',
|
|
192
|
+
'showUsername',
|
|
193
|
+
'showFollowUpSuggestions',
|
|
194
|
+
'hapticFeedbackEnabled',
|
|
195
|
+
'workRemoteProviderDisclosureDismissed',
|
|
196
|
+
'backgroundSettings',
|
|
197
|
+
]);
|
|
198
|
+
const objectPreferenceKeys = new Set([
|
|
199
|
+
'theme',
|
|
200
|
+
'generationOptions',
|
|
201
|
+
'modelGenerationOptions',
|
|
202
|
+
'embeddingSettings',
|
|
203
|
+
'ttsSettings',
|
|
204
|
+
'imageGenSettings',
|
|
205
|
+
'titleSettings',
|
|
206
|
+
'backgroundSettings',
|
|
207
|
+
]);
|
|
208
|
+
const stringPreferenceKeys = new Set([
|
|
209
|
+
'defaultModel',
|
|
210
|
+
'visionModel',
|
|
211
|
+
'systemMessage',
|
|
212
|
+
]);
|
|
213
|
+
const nullableStringPreferenceKeys = new Set([
|
|
214
|
+
'defaultProviderId',
|
|
215
|
+
'visionProviderId',
|
|
216
|
+
]);
|
|
217
|
+
const booleanPreferenceKeys = new Set([
|
|
218
|
+
'showUsername',
|
|
219
|
+
'showFollowUpSuggestions',
|
|
220
|
+
'hapticFeedbackEnabled',
|
|
221
|
+
'workRemoteProviderDisclosureDismissed',
|
|
222
|
+
]);
|
|
223
|
+
const providerPreferenceKeys = new Set([
|
|
224
|
+
'defaultProviderType',
|
|
225
|
+
'visionProviderType',
|
|
226
|
+
]);
|
|
227
|
+
function normalizePreferences(value, warnings) {
|
|
228
|
+
const raw = requireRecord(value, 'preferences');
|
|
229
|
+
const preferences = {};
|
|
230
|
+
for (const [key, entry] of Object.entries(raw)) {
|
|
231
|
+
if (!preferenceKeys.has(key))
|
|
232
|
+
continue;
|
|
233
|
+
if (objectPreferenceKeys.has(key)) {
|
|
234
|
+
preferences[key] = copyJsonRecord(entry, `preferences.${key}`);
|
|
235
|
+
}
|
|
236
|
+
else if (stringPreferenceKeys.has(key)) {
|
|
237
|
+
preferences[key] = requireString(entry, `preferences.${key}`, MAX_CONTENT_LENGTH);
|
|
238
|
+
}
|
|
239
|
+
else if (nullableStringPreferenceKeys.has(key)) {
|
|
240
|
+
preferences[key] =
|
|
241
|
+
entry === null
|
|
242
|
+
? null
|
|
243
|
+
: requireString(entry, `preferences.${key}`, MAX_ID_LENGTH);
|
|
244
|
+
}
|
|
245
|
+
else if (booleanPreferenceKeys.has(key)) {
|
|
246
|
+
if (typeof entry !== 'boolean') {
|
|
247
|
+
throw new DataArchiveValidationError(`preferences.${key} must be a boolean`);
|
|
248
|
+
}
|
|
249
|
+
preferences[key] = entry;
|
|
250
|
+
}
|
|
251
|
+
else if (providerPreferenceKeys.has(key)) {
|
|
252
|
+
if (entry !== null &&
|
|
253
|
+
entry !== undefined &&
|
|
254
|
+
!['ollama', 'plugin', 'agent'].includes(String(entry))) {
|
|
255
|
+
throw new DataArchiveValidationError(`preferences.${key} is invalid`);
|
|
256
|
+
}
|
|
257
|
+
preferences[key] = entry;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
preferences[key] = JSON.parse(JSON.stringify(entry));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (isRecord(preferences.theme)) {
|
|
264
|
+
const mode = preferences.theme.mode;
|
|
265
|
+
if (mode !== undefined &&
|
|
266
|
+
mode !== 'dark' &&
|
|
267
|
+
mode !== 'light' &&
|
|
268
|
+
mode !== 'ophelia') {
|
|
269
|
+
throw new DataArchiveValidationError('preferences.theme.mode is invalid');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (isRecord(preferences.ttsSettings) &&
|
|
273
|
+
preferences.ttsSettings.voiceProfileId) {
|
|
274
|
+
delete preferences.ttsSettings.voiceProfileId;
|
|
275
|
+
warnings.push('The selected reusable voice was cleared because voice profiles are excluded.');
|
|
276
|
+
}
|
|
277
|
+
return preferences;
|
|
278
|
+
}
|
|
279
|
+
function normalizeFolder(value, index) {
|
|
280
|
+
const item = requireRecord(value, `sessionFolders[${index}]`);
|
|
281
|
+
return {
|
|
282
|
+
id: requireNonEmptyString(item.id, `sessionFolders[${index}].id`),
|
|
283
|
+
name: requireNonEmptyString(item.name, `sessionFolders[${index}].name`, 120),
|
|
284
|
+
createdAt: requireTimestamp(item.createdAt, `sessionFolders[${index}].createdAt`),
|
|
285
|
+
updatedAt: requireTimestamp(item.updatedAt, `sessionFolders[${index}].updatedAt`),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function normalizeNote(value, index) {
|
|
289
|
+
const path = `notes[${index}]`;
|
|
290
|
+
const item = requireRecord(value, path);
|
|
291
|
+
return {
|
|
292
|
+
id: requireNonEmptyString(item.id, `${path}.id`),
|
|
293
|
+
title: requireString(item.title, `${path}.title`, MAX_NOTE_TITLE_LENGTH),
|
|
294
|
+
content: requireString(item.content, `${path}.content`, MAX_NOTE_CONTENT_LENGTH),
|
|
295
|
+
createdAt: requireTimestamp(item.createdAt, `${path}.createdAt`),
|
|
296
|
+
updatedAt: requireTimestamp(item.updatedAt, `${path}.updatedAt`),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function normalizeCollection(value, index) {
|
|
300
|
+
const item = requireRecord(value, `knowledgeCollections[${index}]`);
|
|
301
|
+
return {
|
|
302
|
+
id: requireNonEmptyString(item.id, `knowledgeCollections[${index}].id`),
|
|
303
|
+
name: requireNonEmptyString(item.name, `knowledgeCollections[${index}].name`, 10000),
|
|
304
|
+
createdAt: requireTimestamp(item.createdAt, `knowledgeCollections[${index}].createdAt`),
|
|
305
|
+
updatedAt: requireTimestamp(item.updatedAt, `knowledgeCollections[${index}].updatedAt`),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function normalizeMessage(value, sessionIndex, messageIndex) {
|
|
309
|
+
const path = `sessions[${sessionIndex}].messages[${messageIndex}]`;
|
|
310
|
+
const item = requireRecord(value, path);
|
|
311
|
+
if (!['user', 'assistant', 'system'].includes(String(item.role))) {
|
|
312
|
+
throw new DataArchiveValidationError(`${path}.role is invalid`);
|
|
313
|
+
}
|
|
314
|
+
const message = {
|
|
315
|
+
id: requireNonEmptyString(item.id, `${path}.id`),
|
|
316
|
+
role: item.role,
|
|
317
|
+
content: requireString(item.content, `${path}.content`),
|
|
318
|
+
timestamp: requireTimestamp(item.timestamp, `${path}.timestamp`),
|
|
319
|
+
};
|
|
320
|
+
message.thinking = optionalString(item.thinking, `${path}.thinking`);
|
|
321
|
+
message.model = optionalString(item.model, `${path}.model`, MAX_TITLE_LENGTH);
|
|
322
|
+
message.parentId = optionalString(item.parentId, `${path}.parentId`, MAX_ID_LENGTH);
|
|
323
|
+
if (item.branchIndex !== undefined) {
|
|
324
|
+
if (!Number.isSafeInteger(item.branchIndex) ||
|
|
325
|
+
Number(item.branchIndex) < 0) {
|
|
326
|
+
throw new DataArchiveValidationError(`${path}.branchIndex is invalid`);
|
|
327
|
+
}
|
|
328
|
+
message.branchIndex = Number(item.branchIndex);
|
|
329
|
+
}
|
|
330
|
+
message.isActive = optionalBoolean(item.isActive, `${path}.isActive`);
|
|
331
|
+
if (item.rating !== undefined && item.rating !== null) {
|
|
332
|
+
if (item.rating !== 1 && item.rating !== -1) {
|
|
333
|
+
throw new DataArchiveValidationError(`${path}.rating is invalid`);
|
|
334
|
+
}
|
|
335
|
+
message.rating = item.rating;
|
|
336
|
+
}
|
|
337
|
+
if (item.providerMetadata !== undefined) {
|
|
338
|
+
message.providerMetadata = copyJsonRecord(item.providerMetadata, `${path}.providerMetadata`);
|
|
339
|
+
}
|
|
340
|
+
if (item.statistics !== undefined) {
|
|
341
|
+
message.statistics = copyJsonRecord(item.statistics, `${path}.statistics`);
|
|
342
|
+
}
|
|
343
|
+
if (item.images !== undefined) {
|
|
344
|
+
message.images = requireArray(item.images, `${path}.images`).map((image, imageIndex) => requireString(image, `${path}.images[${imageIndex}]`));
|
|
345
|
+
}
|
|
346
|
+
if (item.artifacts !== undefined) {
|
|
347
|
+
message.artifacts = requireArray(item.artifacts, `${path}.artifacts`).map((artifact, artifactIndex) => copyJsonRecord(artifact, `${path}.artifacts[${artifactIndex}]`));
|
|
348
|
+
}
|
|
349
|
+
return message;
|
|
350
|
+
}
|
|
351
|
+
function normalizeSession(value, index) {
|
|
352
|
+
const path = `sessions[${index}]`;
|
|
353
|
+
const item = requireRecord(value, path);
|
|
354
|
+
const providerType = optionalString(item.providerType, `${path}.providerType`, 20);
|
|
355
|
+
if (providerType !== undefined &&
|
|
356
|
+
!['ollama', 'plugin', 'agent'].includes(providerType)) {
|
|
357
|
+
throw new DataArchiveValidationError(`${path}.providerType is invalid`);
|
|
358
|
+
}
|
|
359
|
+
const messages = requireArray(item.messages, `${path}.messages`).map((message, messageIndex) => normalizeMessage(message, index, messageIndex));
|
|
360
|
+
const session = {
|
|
361
|
+
id: requireNonEmptyString(item.id, `${path}.id`),
|
|
362
|
+
title: requireString(item.title, `${path}.title`, MAX_TITLE_LENGTH),
|
|
363
|
+
model: requireNonEmptyString(item.model, `${path}.model`, MAX_TITLE_LENGTH),
|
|
364
|
+
messages,
|
|
365
|
+
createdAt: requireTimestamp(item.createdAt, `${path}.createdAt`),
|
|
366
|
+
updatedAt: requireTimestamp(item.updatedAt, `${path}.updatedAt`),
|
|
367
|
+
};
|
|
368
|
+
session.personaId = optionalString(item.personaId, `${path}.personaId`, MAX_ID_LENGTH);
|
|
369
|
+
session.providerType = providerType;
|
|
370
|
+
session.providerId = optionalString(item.providerId, `${path}.providerId`, MAX_ID_LENGTH);
|
|
371
|
+
session.archived = optionalBoolean(item.archived, `${path}.archived`);
|
|
372
|
+
session.pinned = optionalBoolean(item.pinned, `${path}.pinned`);
|
|
373
|
+
session.folderId = optionalString(item.folderId, `${path}.folderId`, MAX_ID_LENGTH);
|
|
374
|
+
if (item.settings !== undefined) {
|
|
375
|
+
const settings = copyJsonRecord(item.settings, `${path}.settings`);
|
|
376
|
+
if (settings.generationOptions !== undefined) {
|
|
377
|
+
settings.generationOptions = copyJsonRecord(settings.generationOptions, `${path}.settings.generationOptions`);
|
|
378
|
+
}
|
|
379
|
+
if (settings.knowledgeCollectionIds !== undefined) {
|
|
380
|
+
settings.knowledgeCollectionIds = requireArray(settings.knowledgeCollectionIds, `${path}.settings.knowledgeCollectionIds`).map((collectionId, collectionIndex) => requireNonEmptyString(collectionId, `${path}.settings.knowledgeCollectionIds[${collectionIndex}]`));
|
|
381
|
+
}
|
|
382
|
+
session.settings = settings;
|
|
383
|
+
}
|
|
384
|
+
return session;
|
|
385
|
+
}
|
|
386
|
+
function normalizeChunk(value, documentId, documentIndex, chunkIndex) {
|
|
387
|
+
const path = `documents[${documentIndex}].chunks[${chunkIndex}]`;
|
|
388
|
+
const item = requireRecord(value, path);
|
|
389
|
+
const startChar = Number(item.startChar ?? 0);
|
|
390
|
+
const endChar = Number(item.endChar ?? 0);
|
|
391
|
+
const index = Number(item.chunkIndex ?? chunkIndex);
|
|
392
|
+
if (!Number.isSafeInteger(startChar) ||
|
|
393
|
+
!Number.isSafeInteger(endChar) ||
|
|
394
|
+
!Number.isSafeInteger(index) ||
|
|
395
|
+
startChar < 0 ||
|
|
396
|
+
endChar < 0 ||
|
|
397
|
+
index < 0) {
|
|
398
|
+
throw new DataArchiveValidationError(`${path} has invalid offsets`);
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
id: requireNonEmptyString(item.id, `${path}.id`),
|
|
402
|
+
documentId,
|
|
403
|
+
content: requireString(item.content, `${path}.content`),
|
|
404
|
+
chunkIndex: index,
|
|
405
|
+
startChar,
|
|
406
|
+
endChar,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function normalizeDocument(value, index) {
|
|
410
|
+
const path = `documents[${index}]`;
|
|
411
|
+
const item = requireRecord(value, path);
|
|
412
|
+
const id = requireNonEmptyString(item.id, `${path}.id`);
|
|
413
|
+
const fileType = optionalString(item.fileType, `${path}.fileType`, 20);
|
|
414
|
+
if (fileType !== undefined && fileType !== 'pdf' && fileType !== 'txt') {
|
|
415
|
+
throw new DataArchiveValidationError(`${path}.fileType is invalid`);
|
|
416
|
+
}
|
|
417
|
+
const document = {
|
|
418
|
+
id,
|
|
419
|
+
filename: requireNonEmptyString(item.filename, `${path}.filename`, MAX_TITLE_LENGTH),
|
|
420
|
+
uploadedAt: requireTimestamp(item.uploadedAt, `${path}.uploadedAt`),
|
|
421
|
+
chunks: requireArray(item.chunks ?? [], `${path}.chunks`).map((chunk, chunkIndex) => normalizeChunk(chunk, id, index, chunkIndex)),
|
|
422
|
+
};
|
|
423
|
+
document.title = optionalString(item.title, `${path}.title`, MAX_TITLE_LENGTH);
|
|
424
|
+
document.content = optionalString(item.content, `${path}.content`);
|
|
425
|
+
document.fileType = fileType;
|
|
426
|
+
if (item.size !== undefined && item.size !== null) {
|
|
427
|
+
if (!Number.isSafeInteger(item.size) || Number(item.size) < 0) {
|
|
428
|
+
throw new DataArchiveValidationError(`${path}.size is invalid`);
|
|
429
|
+
}
|
|
430
|
+
document.size = Number(item.size);
|
|
431
|
+
}
|
|
432
|
+
document.sessionId = optionalString(item.sessionId, `${path}.sessionId`, MAX_ID_LENGTH);
|
|
433
|
+
document.collectionId = optionalString(item.collectionId, `${path}.collectionId`, MAX_ID_LENGTH);
|
|
434
|
+
if (item.createdAt !== undefined && item.createdAt !== null) {
|
|
435
|
+
document.createdAt = requireTimestamp(item.createdAt, `${path}.createdAt`);
|
|
436
|
+
}
|
|
437
|
+
if (item.metadata !== undefined) {
|
|
438
|
+
document.metadata = copyJsonRecord(item.metadata, `${path}.metadata`);
|
|
439
|
+
}
|
|
440
|
+
return document;
|
|
441
|
+
}
|
|
442
|
+
function assertUniqueIds(items, path) {
|
|
443
|
+
const ids = new Set();
|
|
444
|
+
for (const item of items) {
|
|
445
|
+
if (ids.has(item.id)) {
|
|
446
|
+
throw new DataArchiveValidationError(`${path} contains duplicate ID ${item.id}`);
|
|
447
|
+
}
|
|
448
|
+
ids.add(item.id);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function validateExclusions(value) {
|
|
452
|
+
const exclusions = requireArray(value, 'exclusions').map((entry, index) => {
|
|
453
|
+
const item = requireRecord(entry, `exclusions[${index}]`);
|
|
454
|
+
return {
|
|
455
|
+
id: requireNonEmptyString(item.key, `exclusions[${index}].key`),
|
|
456
|
+
reason: requireNonEmptyString(item.reason, `exclusions[${index}].reason`, MAX_TITLE_LENGTH),
|
|
457
|
+
};
|
|
458
|
+
});
|
|
459
|
+
assertUniqueIds(exclusions, 'exclusions');
|
|
460
|
+
const keys = new Set(exclusions.map(exclusion => exclusion.id));
|
|
461
|
+
for (const required of DATA_ARCHIVE_EXCLUSIONS) {
|
|
462
|
+
if (!keys.has(required.key)) {
|
|
463
|
+
throw new DataArchiveValidationError(`exclusions must declare ${required.key}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function validateRelationships(sessionFolders, sessions, knowledgeCollections, documents) {
|
|
468
|
+
const folderIds = new Set(sessionFolders.map(folder => folder.id));
|
|
469
|
+
const sessionIds = new Set(sessions.map(session => session.id));
|
|
470
|
+
const collectionIds = new Set(knowledgeCollections.map(collection => collection.id));
|
|
471
|
+
sessions.forEach((session, sessionIndex) => {
|
|
472
|
+
if (session.folderId && !folderIds.has(session.folderId)) {
|
|
473
|
+
throw new DataArchiveValidationError(`sessions[${sessionIndex}].folderId references missing session folder ${session.folderId}`);
|
|
474
|
+
}
|
|
475
|
+
session.settings?.knowledgeCollectionIds?.forEach((collectionId, collectionIndex) => {
|
|
476
|
+
if (!collectionIds.has(collectionId)) {
|
|
477
|
+
throw new DataArchiveValidationError(`sessions[${sessionIndex}].settings.knowledgeCollectionIds[${collectionIndex}] references missing knowledge collection ${collectionId}`);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
const messageIds = new Set(session.messages.map(message => message.id));
|
|
481
|
+
session.messages.forEach((message, messageIndex) => {
|
|
482
|
+
if (message.parentId && !messageIds.has(message.parentId)) {
|
|
483
|
+
throw new DataArchiveValidationError(`sessions[${sessionIndex}].messages[${messageIndex}].parentId must reference a message in the same session`);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
documents.forEach((document, documentIndex) => {
|
|
488
|
+
if (document.sessionId && !sessionIds.has(document.sessionId)) {
|
|
489
|
+
throw new DataArchiveValidationError(`documents[${documentIndex}].sessionId references missing session ${document.sessionId}`);
|
|
490
|
+
}
|
|
491
|
+
if (document.collectionId && !collectionIds.has(document.collectionId)) {
|
|
492
|
+
throw new DataArchiveValidationError(`documents[${documentIndex}].collectionId references missing knowledge collection ${document.collectionId}`);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
function normalizeArchive(value) {
|
|
497
|
+
const raw = requireRecord(value, 'archive');
|
|
498
|
+
const warnings = [];
|
|
499
|
+
let migratedFromVersion;
|
|
500
|
+
let source = raw;
|
|
501
|
+
if (raw.format === LEGACY_ARCHIVE_FORMAT) {
|
|
502
|
+
migratedFromVersion = String(raw.version ?? '1.0');
|
|
503
|
+
source = {
|
|
504
|
+
format: DATA_ARCHIVE_FORMAT,
|
|
505
|
+
version: DATA_ARCHIVE_VERSION,
|
|
506
|
+
exportedAt: raw.exportedAt,
|
|
507
|
+
preferences: raw.preferences,
|
|
508
|
+
sessionFolders: [],
|
|
509
|
+
sessions: raw.sessions ?? [],
|
|
510
|
+
notes: [],
|
|
511
|
+
knowledgeCollections: [],
|
|
512
|
+
documents: raw.documents ?? [],
|
|
513
|
+
};
|
|
514
|
+
warnings.push('Legacy archive migrated to version 3 without integrity verification. Legacy exports did not contain folders, Notes, collections, or document chunks.');
|
|
515
|
+
}
|
|
516
|
+
else if (raw.format === DATA_ARCHIVE_FORMAT && raw.version === 2) {
|
|
517
|
+
migratedFromVersion = '2';
|
|
518
|
+
source = {
|
|
519
|
+
...raw,
|
|
520
|
+
version: DATA_ARCHIVE_VERSION,
|
|
521
|
+
notes: [],
|
|
522
|
+
};
|
|
523
|
+
delete source.integrity;
|
|
524
|
+
warnings.push('Archive version 2 migrated to version 3 without integrity verification. Version 2 did not contain Notes or a checksum.');
|
|
525
|
+
}
|
|
526
|
+
if (source.format !== DATA_ARCHIVE_FORMAT) {
|
|
527
|
+
throw new DataArchiveValidationError('Unrecognized Libre WebUI archive format');
|
|
528
|
+
}
|
|
529
|
+
if (source.version !== DATA_ARCHIVE_VERSION) {
|
|
530
|
+
throw new DataArchiveValidationError(`Unsupported archive version ${String(source.version)}; expected ${DATA_ARCHIVE_VERSION}`);
|
|
531
|
+
}
|
|
532
|
+
if (!migratedFromVersion) {
|
|
533
|
+
verifyArchiveIntegrity(source);
|
|
534
|
+
validateExclusions(source.exclusions);
|
|
535
|
+
}
|
|
536
|
+
const exportedAt = requireString(source.exportedAt, 'exportedAt', 100);
|
|
537
|
+
if (Number.isNaN(Date.parse(exportedAt))) {
|
|
538
|
+
throw new DataArchiveValidationError('exportedAt must be an ISO date');
|
|
539
|
+
}
|
|
540
|
+
const preferences = normalizePreferences(source.preferences, warnings);
|
|
541
|
+
const sessionFolders = requireArray(source.sessionFolders, 'sessionFolders').map(normalizeFolder);
|
|
542
|
+
const sessions = requireArray(source.sessions, 'sessions').map(normalizeSession);
|
|
543
|
+
const notes = requireArray(source.notes, 'notes').map(normalizeNote);
|
|
544
|
+
const knowledgeCollections = requireArray(source.knowledgeCollections, 'knowledgeCollections').map(normalizeCollection);
|
|
545
|
+
const documents = requireArray(source.documents, 'documents').map(normalizeDocument);
|
|
546
|
+
const messageCount = sessions.reduce((count, session) => count + session.messages.length, 0);
|
|
547
|
+
const chunkCount = documents.reduce((count, document) => count + document.chunks.length, 0);
|
|
548
|
+
if (sessionFolders.length > MAX_ARCHIVE_FOLDERS) {
|
|
549
|
+
throw new DataArchiveValidationError(`Archive contains ${sessionFolders.length} session folders; the maximum is ${MAX_ARCHIVE_FOLDERS}`);
|
|
550
|
+
}
|
|
551
|
+
if (sessions.length > MAX_ARCHIVE_SESSIONS) {
|
|
552
|
+
throw new DataArchiveValidationError(`Archive contains ${sessions.length} sessions; the maximum is ${MAX_ARCHIVE_SESSIONS}`);
|
|
553
|
+
}
|
|
554
|
+
if (messageCount > MAX_ARCHIVE_MESSAGES) {
|
|
555
|
+
throw new DataArchiveValidationError(`Archive contains ${messageCount} messages; the maximum is ${MAX_ARCHIVE_MESSAGES}`);
|
|
556
|
+
}
|
|
557
|
+
if (notes.length > MAX_ARCHIVE_NOTES) {
|
|
558
|
+
throw new DataArchiveValidationError(`Archive contains ${notes.length} Notes; the maximum is ${MAX_ARCHIVE_NOTES}`);
|
|
559
|
+
}
|
|
560
|
+
if (knowledgeCollections.length > MAX_ARCHIVE_COLLECTIONS) {
|
|
561
|
+
throw new DataArchiveValidationError(`Archive contains ${knowledgeCollections.length} knowledge collections; the maximum is ${MAX_ARCHIVE_COLLECTIONS}`);
|
|
562
|
+
}
|
|
563
|
+
if (documents.length > MAX_ARCHIVE_DOCUMENTS) {
|
|
564
|
+
throw new DataArchiveValidationError(`Archive contains ${documents.length} documents; the maximum is ${MAX_ARCHIVE_DOCUMENTS}`);
|
|
565
|
+
}
|
|
566
|
+
if (chunkCount > MAX_ARCHIVE_CHUNKS) {
|
|
567
|
+
throw new DataArchiveValidationError(`Archive contains ${chunkCount} document chunks; the maximum is ${MAX_ARCHIVE_CHUNKS}`);
|
|
568
|
+
}
|
|
569
|
+
assertUniqueIds(sessionFolders, 'sessionFolders');
|
|
570
|
+
assertUniqueIds(sessions, 'sessions');
|
|
571
|
+
assertUniqueIds(notes, 'notes');
|
|
572
|
+
assertUniqueIds(knowledgeCollections, 'knowledgeCollections');
|
|
573
|
+
assertUniqueIds(documents, 'documents');
|
|
574
|
+
assertUniqueIds(sessions.flatMap(session => session.messages), 'messages');
|
|
575
|
+
assertUniqueIds(documents.flatMap(document => document.chunks), 'document chunks');
|
|
576
|
+
validateRelationships(sessionFolders, sessions, knowledgeCollections, documents);
|
|
577
|
+
return {
|
|
578
|
+
archive: sealArchive({
|
|
579
|
+
format: DATA_ARCHIVE_FORMAT,
|
|
580
|
+
version: DATA_ARCHIVE_VERSION,
|
|
581
|
+
exportedAt,
|
|
582
|
+
preferences,
|
|
583
|
+
sessionFolders,
|
|
584
|
+
sessions,
|
|
585
|
+
notes,
|
|
586
|
+
knowledgeCollections,
|
|
587
|
+
documents,
|
|
588
|
+
exclusions: DATA_ARCHIVE_EXCLUSIONS,
|
|
589
|
+
}),
|
|
590
|
+
migratedFromVersion,
|
|
591
|
+
warnings,
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function emptySection() {
|
|
595
|
+
return { imported: 0, overwritten: 0, skipped: 0 };
|
|
596
|
+
}
|
|
597
|
+
const archiveRepository = () => getPersistence(encryptionService).repositories.resources.archive;
|
|
598
|
+
async function scopedOwner(resource, id) {
|
|
599
|
+
return (await archiveRepository().ownerOf(resource, id)) ?? undefined;
|
|
600
|
+
}
|
|
601
|
+
function derivedId(userId, kind, originalId, attempt = 0) {
|
|
602
|
+
const digest = createHash('sha256')
|
|
603
|
+
.update(`${userId}\0${kind}\0${originalId}\0${attempt}`)
|
|
604
|
+
.digest('hex')
|
|
605
|
+
.slice(0, 32);
|
|
606
|
+
return `import-${kind}-${digest}`;
|
|
607
|
+
}
|
|
608
|
+
async function resolveScopedId(resource, kind, originalId, userId, signal) {
|
|
609
|
+
signal?.throwIfAborted();
|
|
610
|
+
const owner = await scopedOwner(resource, originalId);
|
|
611
|
+
signal?.throwIfAborted();
|
|
612
|
+
if (resource !== 'document' ||
|
|
613
|
+
(owner === userId &&
|
|
614
|
+
!(await archiveRepository().resourceDeletionReserved('document', originalId)))) {
|
|
615
|
+
if (!owner || owner === userId) {
|
|
616
|
+
return { id: originalId, remapped: false };
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
620
|
+
signal?.throwIfAborted();
|
|
621
|
+
const candidate = derivedId(userId, kind, originalId, attempt);
|
|
622
|
+
const candidateOwner = await scopedOwner(resource, candidate);
|
|
623
|
+
const reserved = resource === 'document'
|
|
624
|
+
? await archiveRepository().resourceDeletionReserved('document', candidate)
|
|
625
|
+
: false;
|
|
626
|
+
signal?.throwIfAborted();
|
|
627
|
+
if (!reserved && (!candidateOwner || candidateOwner === userId)) {
|
|
628
|
+
return { id: candidate, remapped: true };
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
throw new DataArchiveValidationError(`Could not safely remap ${kind} ID`);
|
|
632
|
+
}
|
|
633
|
+
function sectionDisposition(section, exists, strategy) {
|
|
634
|
+
if (!exists)
|
|
635
|
+
section.imported += 1;
|
|
636
|
+
else if (strategy === 'skip')
|
|
637
|
+
section.skipped += 1;
|
|
638
|
+
else
|
|
639
|
+
section.overwritten += 1;
|
|
640
|
+
}
|
|
641
|
+
async function currentUserOwns(resource, id, userId) {
|
|
642
|
+
return (await scopedOwner(resource, id)) === userId;
|
|
643
|
+
}
|
|
644
|
+
async function nestedOwner(resource, id) {
|
|
645
|
+
const owner = await archiveRepository().nestedOwnerOf(resource, id);
|
|
646
|
+
return owner
|
|
647
|
+
? { user_id: owner.userId, parent_id: owner.parentId }
|
|
648
|
+
: undefined;
|
|
649
|
+
}
|
|
650
|
+
async function resolveNestedId(resource, originalId, targetParentId, userId, kind, signal) {
|
|
651
|
+
signal?.throwIfAborted();
|
|
652
|
+
const existing = await nestedOwner(resource, originalId);
|
|
653
|
+
signal?.throwIfAborted();
|
|
654
|
+
if (!existing ||
|
|
655
|
+
(existing.user_id === userId && existing.parent_id === targetParentId)) {
|
|
656
|
+
return originalId;
|
|
657
|
+
}
|
|
658
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
659
|
+
signal?.throwIfAborted();
|
|
660
|
+
const candidate = derivedId(userId, kind, originalId, attempt);
|
|
661
|
+
const collision = await nestedOwner(resource, candidate);
|
|
662
|
+
signal?.throwIfAborted();
|
|
663
|
+
if (!collision ||
|
|
664
|
+
(collision.user_id === userId && collision.parent_id === targetParentId)) {
|
|
665
|
+
return candidate;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
throw new DataArchiveValidationError(`Could not safely remap ${kind} ID`);
|
|
669
|
+
}
|
|
670
|
+
async function buildPlan(normalized, strategy, userId, signal) {
|
|
671
|
+
signal?.throwIfAborted();
|
|
672
|
+
const { archive } = normalized;
|
|
673
|
+
const result = {
|
|
674
|
+
format: DATA_ARCHIVE_FORMAT,
|
|
675
|
+
version: DATA_ARCHIVE_VERSION,
|
|
676
|
+
migratedFromVersion: normalized.migratedFromVersion,
|
|
677
|
+
strategy,
|
|
678
|
+
preferences: {
|
|
679
|
+
imported: true,
|
|
680
|
+
mode: strategy === 'overwrite' ? 'replace' : 'merge',
|
|
681
|
+
},
|
|
682
|
+
sessionFolders: emptySection(),
|
|
683
|
+
sessions: emptySection(),
|
|
684
|
+
notes: emptySection(),
|
|
685
|
+
knowledgeCollections: emptySection(),
|
|
686
|
+
documents: emptySection(),
|
|
687
|
+
remappedIds: 0,
|
|
688
|
+
warnings: [...normalized.warnings],
|
|
689
|
+
exclusions: DATA_ARCHIVE_EXCLUSIONS,
|
|
690
|
+
};
|
|
691
|
+
const mapIds = async (values, resource, kind, section) => {
|
|
692
|
+
const mapping = new Map();
|
|
693
|
+
for (const value of values) {
|
|
694
|
+
signal?.throwIfAborted();
|
|
695
|
+
const resolved = await resolveScopedId(resource, kind, value.id, userId, signal);
|
|
696
|
+
mapping.set(value.id, resolved.id);
|
|
697
|
+
if (resolved.remapped)
|
|
698
|
+
result.remappedIds += 1;
|
|
699
|
+
sectionDisposition(section, await currentUserOwns(resource, resolved.id, userId), strategy);
|
|
700
|
+
signal?.throwIfAborted();
|
|
701
|
+
}
|
|
702
|
+
return mapping;
|
|
703
|
+
};
|
|
704
|
+
const folderIds = await mapIds(archive.sessionFolders, 'session-folder', 'folder', result.sessionFolders);
|
|
705
|
+
const existingFolderCount = (await storageService.getSessionFolders(userId))
|
|
706
|
+
.length;
|
|
707
|
+
signal?.throwIfAborted();
|
|
708
|
+
if (existingFolderCount + result.sessionFolders.imported >
|
|
709
|
+
MAX_SESSION_FOLDERS_PER_USER) {
|
|
710
|
+
throw new DataArchiveValidationError(`Import would exceed the per-user limit of ${MAX_SESSION_FOLDERS_PER_USER} session folders`);
|
|
711
|
+
}
|
|
712
|
+
const sessionIds = await mapIds(archive.sessions, 'session', 'session', result.sessions);
|
|
713
|
+
const noteIds = await mapIds(archive.notes, 'note', 'note', result.notes);
|
|
714
|
+
const existingNoteCount = (await storageService.getNotes(userId)).length;
|
|
715
|
+
signal?.throwIfAborted();
|
|
716
|
+
if (existingNoteCount + result.notes.imported > MAX_NOTES_PER_USER) {
|
|
717
|
+
throw new DataArchiveValidationError(`Import would exceed the per-user limit of ${MAX_NOTES_PER_USER} Notes`);
|
|
718
|
+
}
|
|
719
|
+
const collectionIds = await mapIds(archive.knowledgeCollections, 'knowledge-collection', 'collection', result.knowledgeCollections);
|
|
720
|
+
const documentIds = await mapIds(archive.documents, 'document', 'document', result.documents);
|
|
721
|
+
const messageIds = new Map();
|
|
722
|
+
for (const session of archive.sessions) {
|
|
723
|
+
signal?.throwIfAborted();
|
|
724
|
+
const targetSessionId = sessionIds.get(session.id);
|
|
725
|
+
for (const message of session.messages) {
|
|
726
|
+
signal?.throwIfAborted();
|
|
727
|
+
const targetMessageId = await resolveNestedId('session-message', message.id, targetSessionId, userId, 'message', signal);
|
|
728
|
+
messageIds.set(message.id, targetMessageId);
|
|
729
|
+
if (targetMessageId !== message.id)
|
|
730
|
+
result.remappedIds += 1;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
const chunkIds = new Map();
|
|
734
|
+
for (const document of archive.documents) {
|
|
735
|
+
signal?.throwIfAborted();
|
|
736
|
+
const targetDocumentId = documentIds.get(document.id);
|
|
737
|
+
for (const chunk of document.chunks) {
|
|
738
|
+
signal?.throwIfAborted();
|
|
739
|
+
const targetChunkId = await resolveNestedId('document-chunk', chunk.id, targetDocumentId, userId, 'chunk', signal);
|
|
740
|
+
chunkIds.set(chunk.id, targetChunkId);
|
|
741
|
+
if (targetChunkId !== chunk.id)
|
|
742
|
+
result.remappedIds += 1;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (result.remappedIds > 0) {
|
|
746
|
+
result.warnings.push(`${result.remappedIds} archive IDs were deterministically remapped to preserve ownership and deletion-incarnation safety.`);
|
|
747
|
+
}
|
|
748
|
+
for (const session of archive.sessions) {
|
|
749
|
+
signal?.throwIfAborted();
|
|
750
|
+
if (session.personaId &&
|
|
751
|
+
!(await currentUserOwns('persona', session.personaId, userId))) {
|
|
752
|
+
result.warnings.push(`Session ${session.id} will be detached from persona ${session.personaId} because personas are excluded and the target account does not already own it.`);
|
|
753
|
+
}
|
|
754
|
+
signal?.throwIfAborted();
|
|
755
|
+
}
|
|
756
|
+
return {
|
|
757
|
+
archive,
|
|
758
|
+
folderIds,
|
|
759
|
+
sessionIds,
|
|
760
|
+
messageIds,
|
|
761
|
+
noteIds,
|
|
762
|
+
collectionIds,
|
|
763
|
+
documentIds,
|
|
764
|
+
chunkIds,
|
|
765
|
+
result,
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
async function mapReference(originalId, mapping, resource, userId) {
|
|
769
|
+
if (!originalId)
|
|
770
|
+
return undefined;
|
|
771
|
+
return (mapping.get(originalId) ??
|
|
772
|
+
((await currentUserOwns(resource, originalId, userId))
|
|
773
|
+
? originalId
|
|
774
|
+
: undefined));
|
|
775
|
+
}
|
|
776
|
+
async function applyPlan(plan, strategy, userId, signal) {
|
|
777
|
+
signal?.throwIfAborted();
|
|
778
|
+
const timestamp = Date.now();
|
|
779
|
+
const sessions = [];
|
|
780
|
+
for (const archivedSession of plan.archive.sessions) {
|
|
781
|
+
signal?.throwIfAborted();
|
|
782
|
+
const targetId = plan.sessionIds.get(archivedSession.id);
|
|
783
|
+
const settings = archivedSession.settings
|
|
784
|
+
? { ...archivedSession.settings }
|
|
785
|
+
: undefined;
|
|
786
|
+
if (settings?.knowledgeCollectionIds) {
|
|
787
|
+
settings.knowledgeCollectionIds = (await Promise.all(settings.knowledgeCollectionIds.map(collectionId => mapReference(collectionId, plan.collectionIds, 'knowledge-collection', userId)))).filter((id) => Boolean(id));
|
|
788
|
+
signal?.throwIfAborted();
|
|
789
|
+
}
|
|
790
|
+
const personaId = await mapReference(archivedSession.personaId, new Map(), 'persona', userId);
|
|
791
|
+
signal?.throwIfAborted();
|
|
792
|
+
sessions.push({
|
|
793
|
+
session: {
|
|
794
|
+
id: targetId,
|
|
795
|
+
user_id: userId,
|
|
796
|
+
title: encryptionService.encrypt(archivedSession.title),
|
|
797
|
+
model: archivedSession.model,
|
|
798
|
+
persona_id: personaId ?? null,
|
|
799
|
+
provider_type: archivedSession.providerType ?? null,
|
|
800
|
+
provider_id: archivedSession.providerId ?? null,
|
|
801
|
+
created_at: archivedSession.createdAt,
|
|
802
|
+
updated_at: archivedSession.updatedAt,
|
|
803
|
+
archived: archivedSession.archived ? 1 : 0,
|
|
804
|
+
settings: settings
|
|
805
|
+
? encryptionService.encrypt(JSON.stringify(settings))
|
|
806
|
+
: null,
|
|
807
|
+
folder_id: (await mapReference(archivedSession.folderId, plan.folderIds, 'session-folder', userId)) ?? null,
|
|
808
|
+
pinned: archivedSession.pinned ? 1 : 0,
|
|
809
|
+
},
|
|
810
|
+
messages: archivedSession.messages.map((message, index) => ({
|
|
811
|
+
id: plan.messageIds.get(message.id),
|
|
812
|
+
session_id: targetId,
|
|
813
|
+
role: message.role,
|
|
814
|
+
content: encryptionService.encrypt(message.content),
|
|
815
|
+
thinking: message.thinking
|
|
816
|
+
? encryptionService.encrypt(message.thinking)
|
|
817
|
+
: null,
|
|
818
|
+
timestamp: message.timestamp,
|
|
819
|
+
message_index: index,
|
|
820
|
+
model: message.model ?? null,
|
|
821
|
+
provider_metadata: message.providerMetadata
|
|
822
|
+
? encryptionService.encrypt(JSON.stringify(message.providerMetadata))
|
|
823
|
+
: null,
|
|
824
|
+
images: message.images
|
|
825
|
+
? encryptionService.encrypt(JSON.stringify(message.images))
|
|
826
|
+
: null,
|
|
827
|
+
statistics: message.statistics
|
|
828
|
+
? encryptionService.encrypt(JSON.stringify(message.statistics))
|
|
829
|
+
: null,
|
|
830
|
+
artifacts: message.artifacts
|
|
831
|
+
? encryptionService.encrypt(JSON.stringify(message.artifacts))
|
|
832
|
+
: null,
|
|
833
|
+
parent_id: message.parentId
|
|
834
|
+
? plan.messageIds.get(message.parentId)
|
|
835
|
+
: null,
|
|
836
|
+
branch_index: message.branchIndex ?? 0,
|
|
837
|
+
is_active: message.isActive === false ? 0 : 1,
|
|
838
|
+
rating: message.rating ?? null,
|
|
839
|
+
})),
|
|
840
|
+
});
|
|
841
|
+
signal?.throwIfAborted();
|
|
842
|
+
}
|
|
843
|
+
signal?.throwIfAborted();
|
|
844
|
+
const atomicPlan = {
|
|
845
|
+
userId,
|
|
846
|
+
strategy,
|
|
847
|
+
timestamp,
|
|
848
|
+
maximumNotes: MAX_NOTES_PER_USER,
|
|
849
|
+
maximumSessionFolders: MAX_SESSION_FOLDERS_PER_USER,
|
|
850
|
+
assertCanCommit: () => signal?.throwIfAborted(),
|
|
851
|
+
preferences: current => storageService.transformStoredPreferences(current, preferences => preferencesService.prepareImportedPreferences(plan.archive.preferences, strategy === 'overwrite' ? 'replace' : 'merge', preferences)),
|
|
852
|
+
sessionFolders: plan.archive.sessionFolders.map(folder => ({
|
|
853
|
+
id: plan.folderIds.get(folder.id),
|
|
854
|
+
user_id: userId,
|
|
855
|
+
name: encryptionService.encrypt(folder.name),
|
|
856
|
+
created_at: folder.createdAt,
|
|
857
|
+
updated_at: folder.updatedAt,
|
|
858
|
+
})),
|
|
859
|
+
sessions,
|
|
860
|
+
notes: plan.archive.notes.map(note => ({
|
|
861
|
+
id: plan.noteIds.get(note.id),
|
|
862
|
+
user_id: userId,
|
|
863
|
+
title: encryptionService.encrypt(note.title),
|
|
864
|
+
content: encryptionService.encrypt(note.content),
|
|
865
|
+
created_at: note.createdAt,
|
|
866
|
+
updated_at: note.updatedAt,
|
|
867
|
+
})),
|
|
868
|
+
knowledgeCollections: plan.archive.knowledgeCollections.map(collection => ({
|
|
869
|
+
id: plan.collectionIds.get(collection.id),
|
|
870
|
+
user_id: userId,
|
|
871
|
+
name: encryptionService.encrypt(collection.name),
|
|
872
|
+
created_at: collection.createdAt,
|
|
873
|
+
updated_at: collection.updatedAt,
|
|
874
|
+
})),
|
|
875
|
+
documents: await Promise.all(plan.archive.documents.map(async (archivedDocument) => {
|
|
876
|
+
signal?.throwIfAborted();
|
|
877
|
+
const targetId = plan.documentIds.get(archivedDocument.id);
|
|
878
|
+
const document = {
|
|
879
|
+
document: {
|
|
880
|
+
id: targetId,
|
|
881
|
+
user_id: userId,
|
|
882
|
+
filename: archivedDocument.filename,
|
|
883
|
+
title: archivedDocument.title
|
|
884
|
+
? encryptionService.encrypt(archivedDocument.title)
|
|
885
|
+
: null,
|
|
886
|
+
content: archivedDocument.content
|
|
887
|
+
? encryptionService.encrypt(archivedDocument.content)
|
|
888
|
+
: null,
|
|
889
|
+
file_type: archivedDocument.fileType ?? null,
|
|
890
|
+
size: archivedDocument.size ?? null,
|
|
891
|
+
session_id: (await mapReference(archivedDocument.sessionId, plan.sessionIds, 'session', userId)) ?? null,
|
|
892
|
+
collection_id: (await mapReference(archivedDocument.collectionId, plan.collectionIds, 'knowledge-collection', userId)) ?? null,
|
|
893
|
+
metadata: archivedDocument.metadata
|
|
894
|
+
? encryptionService.encrypt(JSON.stringify(archivedDocument.metadata))
|
|
895
|
+
: null,
|
|
896
|
+
uploaded_at: archivedDocument.uploadedAt,
|
|
897
|
+
created_at: archivedDocument.createdAt ?? timestamp,
|
|
898
|
+
updated_at: timestamp,
|
|
899
|
+
},
|
|
900
|
+
chunks: archivedDocument.chunks.map(chunk => ({
|
|
901
|
+
id: plan.chunkIds.get(chunk.id),
|
|
902
|
+
document_id: targetId,
|
|
903
|
+
chunk_index: chunk.chunkIndex,
|
|
904
|
+
content: encryptionService.encrypt(chunk.content),
|
|
905
|
+
start_char: chunk.startChar ?? null,
|
|
906
|
+
end_char: chunk.endChar ?? null,
|
|
907
|
+
embedding: null,
|
|
908
|
+
created_at: timestamp,
|
|
909
|
+
})),
|
|
910
|
+
};
|
|
911
|
+
signal?.throwIfAborted();
|
|
912
|
+
return document;
|
|
913
|
+
})),
|
|
914
|
+
};
|
|
915
|
+
signal?.throwIfAborted();
|
|
916
|
+
await archiveRepository().applyImport(atomicPlan);
|
|
917
|
+
}
|
|
918
|
+
function assertExportIsRestorable(archive) {
|
|
919
|
+
// Run the exact importer schema and resource checks before returning a file.
|
|
920
|
+
// This prevents Libre from offering an export that its own preflight rejects.
|
|
921
|
+
normalizeArchive(archive);
|
|
922
|
+
const serializedBytes = Buffer.byteLength(JSON.stringify(archive, null, 2), 'utf8');
|
|
923
|
+
if (serializedBytes > DATA_ARCHIVE_MAX_BYTES) {
|
|
924
|
+
throw new DataArchiveValidationError(`Portable archive is ${serializedBytes} bytes; the import limit is ${DATA_ARCHIVE_MAX_BYTES} bytes`);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
async function assertStoredCountWithinExportLimit(resource, label, maximum, userId) {
|
|
928
|
+
const count = await archiveRepository().countByOwner(resource, userId);
|
|
929
|
+
if (count > maximum) {
|
|
930
|
+
throw new DataArchiveValidationError(`Account contains ${count} ${label}; the portable archive maximum is ${maximum}`);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
class DataArchiveService {
|
|
934
|
+
async exportUserData(userId) {
|
|
935
|
+
// These storage readers enforce UI limits with SQL LIMIT. Check the true
|
|
936
|
+
// row counts first so an inconsistent older database is never truncated.
|
|
937
|
+
await assertStoredCountWithinExportLimit('session-folder', 'session folders', MAX_ARCHIVE_FOLDERS, userId);
|
|
938
|
+
await assertStoredCountWithinExportLimit('note', 'Notes', MAX_ARCHIVE_NOTES, userId);
|
|
939
|
+
const preferences = JSON.parse(JSON.stringify(await preferencesService.getPreferences(userId)));
|
|
940
|
+
if (preferences.ttsSettings?.voiceProfileId) {
|
|
941
|
+
delete preferences.ttsSettings.voiceProfileId;
|
|
942
|
+
}
|
|
943
|
+
const documents = await Promise.all((await storageService.getAllDocuments(userId)).map(async (document) => ({
|
|
944
|
+
...document,
|
|
945
|
+
chunks: (await storageService.getDocumentChunks(document.id)).map(chunk => ({
|
|
946
|
+
id: chunk.id,
|
|
947
|
+
documentId: chunk.documentId,
|
|
948
|
+
content: chunk.content,
|
|
949
|
+
chunkIndex: chunk.chunkIndex,
|
|
950
|
+
startChar: chunk.startChar,
|
|
951
|
+
endChar: chunk.endChar,
|
|
952
|
+
})),
|
|
953
|
+
})));
|
|
954
|
+
const [sessionFolders, sessions, notes, knowledgeCollections] = await Promise.all([
|
|
955
|
+
storageService.getSessionFolders(userId),
|
|
956
|
+
storageService.getAllSessions(userId),
|
|
957
|
+
storageService.getNotes(userId),
|
|
958
|
+
storageService.getKnowledgeCollections(userId),
|
|
959
|
+
]);
|
|
960
|
+
const archive = sealArchive({
|
|
961
|
+
format: DATA_ARCHIVE_FORMAT,
|
|
962
|
+
version: DATA_ARCHIVE_VERSION,
|
|
963
|
+
exportedAt: new Date().toISOString(),
|
|
964
|
+
preferences,
|
|
965
|
+
sessionFolders,
|
|
966
|
+
sessions,
|
|
967
|
+
notes,
|
|
968
|
+
knowledgeCollections,
|
|
969
|
+
documents,
|
|
970
|
+
exclusions: DATA_ARCHIVE_EXCLUSIONS,
|
|
971
|
+
});
|
|
972
|
+
assertExportIsRestorable(archive);
|
|
973
|
+
return archive;
|
|
974
|
+
}
|
|
975
|
+
async preflight(value, strategy, userId, signal) {
|
|
976
|
+
signal?.throwIfAborted();
|
|
977
|
+
const normalized = normalizeArchive(value);
|
|
978
|
+
const plan = await buildPlan(normalized, strategy, userId, signal);
|
|
979
|
+
signal?.throwIfAborted();
|
|
980
|
+
const messageCount = normalized.archive.sessions.reduce((count, session) => count + session.messages.length, 0);
|
|
981
|
+
const chunkCount = normalized.archive.documents.reduce((count, document) => count + document.chunks.length, 0);
|
|
982
|
+
const { preferences: _preferences, ...result } = plan.result;
|
|
983
|
+
return {
|
|
984
|
+
valid: true,
|
|
985
|
+
format: DATA_ARCHIVE_FORMAT,
|
|
986
|
+
version: DATA_ARCHIVE_VERSION,
|
|
987
|
+
migratedFromVersion: normalized.migratedFromVersion,
|
|
988
|
+
strategy,
|
|
989
|
+
incoming: {
|
|
990
|
+
sessionFolders: normalized.archive.sessionFolders.length,
|
|
991
|
+
sessions: normalized.archive.sessions.length,
|
|
992
|
+
messages: messageCount,
|
|
993
|
+
notes: normalized.archive.notes.length,
|
|
994
|
+
knowledgeCollections: normalized.archive.knowledgeCollections.length,
|
|
995
|
+
documents: normalized.archive.documents.length,
|
|
996
|
+
documentChunks: chunkCount,
|
|
997
|
+
},
|
|
998
|
+
result,
|
|
999
|
+
warnings: plan.result.warnings,
|
|
1000
|
+
exclusions: DATA_ARCHIVE_EXCLUSIONS,
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
async importUserData(value, strategy, userId, signal) {
|
|
1004
|
+
signal?.throwIfAborted();
|
|
1005
|
+
const normalized = normalizeArchive(value);
|
|
1006
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
1007
|
+
const plan = await buildPlan(normalized, strategy, userId, signal);
|
|
1008
|
+
signal?.throwIfAborted();
|
|
1009
|
+
try {
|
|
1010
|
+
await applyPlan(plan, strategy, userId, signal);
|
|
1011
|
+
return plan.result;
|
|
1012
|
+
}
|
|
1013
|
+
catch (error) {
|
|
1014
|
+
if (error instanceof PersistenceResourceDeletionReservedError &&
|
|
1015
|
+
attempt < 4) {
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
logger.error('User data archive import rolled back:', error);
|
|
1019
|
+
throw error;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
throw new DataArchiveValidationError('Archive identifiers changed too frequently to import safely');
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
export { DataArchiveValidationError };
|
|
1026
|
+
export default new DataArchiveService();
|
|
1027
|
+
//# sourceMappingURL=dataArchiveService.js.map
|