@librechat/data-schemas 0.0.18 → 0.0.20

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/dist/index.cjs CHANGED
@@ -219,6 +219,10 @@ const agentCategorySchema = new mongoose.Schema({
219
219
  default: true,
220
220
  index: true,
221
221
  },
222
+ custom: {
223
+ type: Boolean,
224
+ default: false,
225
+ },
222
226
  }, {
223
227
  timestamps: true,
224
228
  });
@@ -1356,6 +1360,7 @@ const groupSchema = new mongoose.Schema({
1356
1360
  memberIds: [
1357
1361
  {
1358
1362
  type: String,
1363
+ required: false,
1359
1364
  },
1360
1365
  ],
1361
1366
  source: {
@@ -1810,7 +1815,7 @@ const transports$1 = [
1810
1815
  zippedArchive: true,
1811
1816
  maxSize: '20m',
1812
1817
  maxFiles: '14d',
1813
- format: fileFormat$1,
1818
+ format: winston.format.combine(fileFormat$1, winston.format.json()),
1814
1819
  }),
1815
1820
  ];
1816
1821
  if (useDebugLogging$1) {
@@ -3544,6 +3549,7 @@ function createAgentCategoryMethods(mongoose) {
3544
3549
  description: category.description || '',
3545
3550
  order: category.order || index,
3546
3551
  isActive: true,
3552
+ custom: category.custom || false,
3547
3553
  },
3548
3554
  },
3549
3555
  upsert: true,
@@ -3608,60 +3614,96 @@ function createAgentCategoryMethods(mongoose) {
3608
3614
  return await AgentCategory.find({}).sort({ order: 1, label: 1 }).lean();
3609
3615
  }
3610
3616
  /**
3611
- * Ensure default categories exist, seed them if none are present
3612
- * @returns Promise<boolean> - true if categories were seeded, false if they already existed
3617
+ * Ensure default categories exist and update them if they don't have localization keys
3618
+ * @returns Promise<boolean> - true if categories were created/updated, false if no changes
3613
3619
  */
3614
3620
  async function ensureDefaultCategories() {
3615
- const existingCategories = await getAllCategories();
3616
- if (existingCategories.length > 0) {
3617
- return false; // Categories already exist
3618
- }
3621
+ const AgentCategory = mongoose.models.AgentCategory;
3619
3622
  const defaultCategories = [
3620
3623
  {
3621
3624
  value: 'general',
3622
- label: 'General',
3623
- description: 'General purpose agents for common tasks and inquiries',
3625
+ label: 'com_agents_category_general',
3626
+ description: 'com_agents_category_general_description',
3624
3627
  order: 0,
3625
3628
  },
3626
3629
  {
3627
3630
  value: 'hr',
3628
- label: 'Human Resources',
3629
- description: 'Agents specialized in HR processes, policies, and employee support',
3631
+ label: 'com_agents_category_hr',
3632
+ description: 'com_agents_category_hr_description',
3630
3633
  order: 1,
3631
3634
  },
3632
3635
  {
3633
3636
  value: 'rd',
3634
- label: 'Research & Development',
3635
- description: 'Agents focused on R&D processes, innovation, and technical research',
3637
+ label: 'com_agents_category_rd',
3638
+ description: 'com_agents_category_rd_description',
3636
3639
  order: 2,
3637
3640
  },
3638
3641
  {
3639
3642
  value: 'finance',
3640
- label: 'Finance',
3641
- description: 'Agents specialized in financial analysis, budgeting, and accounting',
3643
+ label: 'com_agents_category_finance',
3644
+ description: 'com_agents_category_finance_description',
3642
3645
  order: 3,
3643
3646
  },
3644
3647
  {
3645
3648
  value: 'it',
3646
- label: 'IT',
3647
- description: 'Agents for IT support, technical troubleshooting, and system administration',
3649
+ label: 'com_agents_category_it',
3650
+ description: 'com_agents_category_it_description',
3648
3651
  order: 4,
3649
3652
  },
3650
3653
  {
3651
3654
  value: 'sales',
3652
- label: 'Sales',
3653
- description: 'Agents focused on sales processes, customer relations.',
3655
+ label: 'com_agents_category_sales',
3656
+ description: 'com_agents_category_sales_description',
3654
3657
  order: 5,
3655
3658
  },
3656
3659
  {
3657
3660
  value: 'aftersales',
3658
- label: 'After Sales',
3659
- description: 'Agents specialized in post-sale support, maintenance, and customer service',
3661
+ label: 'com_agents_category_aftersales',
3662
+ description: 'com_agents_category_aftersales_description',
3660
3663
  order: 6,
3661
3664
  },
3662
3665
  ];
3663
- await seedCategories(defaultCategories);
3664
- return true; // Categories were seeded
3666
+ const existingCategories = await getAllCategories();
3667
+ const existingCategoryMap = new Map(existingCategories.map((cat) => [cat.value, cat]));
3668
+ const updates = [];
3669
+ let created = 0;
3670
+ for (const defaultCategory of defaultCategories) {
3671
+ const existingCategory = existingCategoryMap.get(defaultCategory.value);
3672
+ if (existingCategory) {
3673
+ const isNotCustom = !existingCategory.custom;
3674
+ const needsLocalization = !existingCategory.label.startsWith('com_');
3675
+ if (isNotCustom && needsLocalization) {
3676
+ updates.push({
3677
+ value: defaultCategory.value,
3678
+ label: defaultCategory.label,
3679
+ description: defaultCategory.description,
3680
+ });
3681
+ }
3682
+ }
3683
+ else {
3684
+ await createCategory({
3685
+ ...defaultCategory,
3686
+ isActive: true,
3687
+ custom: false,
3688
+ });
3689
+ created++;
3690
+ }
3691
+ }
3692
+ if (updates.length > 0) {
3693
+ const bulkOps = updates.map((update) => ({
3694
+ updateOne: {
3695
+ filter: { value: update.value, custom: { $ne: true } },
3696
+ update: {
3697
+ $set: {
3698
+ label: update.label,
3699
+ description: update.description,
3700
+ },
3701
+ },
3702
+ },
3703
+ }));
3704
+ await AgentCategory.bulkWrite(bulkOps, { ordered: false });
3705
+ }
3706
+ return updates.length > 0 || created > 0;
3665
3707
  }
3666
3708
  return {
3667
3709
  getActiveCategories,