@librechat/data-schemas 0.0.19 → 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
  });
@@ -1811,7 +1815,7 @@ const transports$1 = [
1811
1815
  zippedArchive: true,
1812
1816
  maxSize: '20m',
1813
1817
  maxFiles: '14d',
1814
- format: fileFormat$1,
1818
+ format: winston.format.combine(fileFormat$1, winston.format.json()),
1815
1819
  }),
1816
1820
  ];
1817
1821
  if (useDebugLogging$1) {
@@ -3545,6 +3549,7 @@ function createAgentCategoryMethods(mongoose) {
3545
3549
  description: category.description || '',
3546
3550
  order: category.order || index,
3547
3551
  isActive: true,
3552
+ custom: category.custom || false,
3548
3553
  },
3549
3554
  },
3550
3555
  upsert: true,
@@ -3609,60 +3614,96 @@ function createAgentCategoryMethods(mongoose) {
3609
3614
  return await AgentCategory.find({}).sort({ order: 1, label: 1 }).lean();
3610
3615
  }
3611
3616
  /**
3612
- * Ensure default categories exist, seed them if none are present
3613
- * @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
3614
3619
  */
3615
3620
  async function ensureDefaultCategories() {
3616
- const existingCategories = await getAllCategories();
3617
- if (existingCategories.length > 0) {
3618
- return false; // Categories already exist
3619
- }
3621
+ const AgentCategory = mongoose.models.AgentCategory;
3620
3622
  const defaultCategories = [
3621
3623
  {
3622
3624
  value: 'general',
3623
- label: 'General',
3624
- description: 'General purpose agents for common tasks and inquiries',
3625
+ label: 'com_agents_category_general',
3626
+ description: 'com_agents_category_general_description',
3625
3627
  order: 0,
3626
3628
  },
3627
3629
  {
3628
3630
  value: 'hr',
3629
- label: 'Human Resources',
3630
- description: 'Agents specialized in HR processes, policies, and employee support',
3631
+ label: 'com_agents_category_hr',
3632
+ description: 'com_agents_category_hr_description',
3631
3633
  order: 1,
3632
3634
  },
3633
3635
  {
3634
3636
  value: 'rd',
3635
- label: 'Research & Development',
3636
- description: 'Agents focused on R&D processes, innovation, and technical research',
3637
+ label: 'com_agents_category_rd',
3638
+ description: 'com_agents_category_rd_description',
3637
3639
  order: 2,
3638
3640
  },
3639
3641
  {
3640
3642
  value: 'finance',
3641
- label: 'Finance',
3642
- description: 'Agents specialized in financial analysis, budgeting, and accounting',
3643
+ label: 'com_agents_category_finance',
3644
+ description: 'com_agents_category_finance_description',
3643
3645
  order: 3,
3644
3646
  },
3645
3647
  {
3646
3648
  value: 'it',
3647
- label: 'IT',
3648
- description: 'Agents for IT support, technical troubleshooting, and system administration',
3649
+ label: 'com_agents_category_it',
3650
+ description: 'com_agents_category_it_description',
3649
3651
  order: 4,
3650
3652
  },
3651
3653
  {
3652
3654
  value: 'sales',
3653
- label: 'Sales',
3654
- description: 'Agents focused on sales processes, customer relations.',
3655
+ label: 'com_agents_category_sales',
3656
+ description: 'com_agents_category_sales_description',
3655
3657
  order: 5,
3656
3658
  },
3657
3659
  {
3658
3660
  value: 'aftersales',
3659
- label: 'After Sales',
3660
- description: 'Agents specialized in post-sale support, maintenance, and customer service',
3661
+ label: 'com_agents_category_aftersales',
3662
+ description: 'com_agents_category_aftersales_description',
3661
3663
  order: 6,
3662
3664
  },
3663
3665
  ];
3664
- await seedCategories(defaultCategories);
3665
- 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;
3666
3707
  }
3667
3708
  return {
3668
3709
  getActiveCategories,