@yeaft/webchat-agent 1.0.650 → 1.0.651

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.650",
3
+ "version": "1.0.651",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@ export function validateScheduleTimestamp(value, name = 'scheduledFor') {
13
13
  export function normalizeRecurrence(value) {
14
14
  if (value == null) return null;
15
15
  if (typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid recurrence');
16
- const allowed = ['frequency', 'timeZone', 'time', 'weekdays', 'dayOfMonth', 'endsAt', 'maxRuns'];
16
+ const allowed = ['frequency', 'timeZone', 'time', 'weekdays', 'dayOfMonth', 'daysOfMonth', 'endsAt', 'maxRuns'];
17
17
  if (Object.keys(value).some(key => !allowed.includes(key))) throw new Error('Unknown recurrence field');
18
18
  if (!['daily', 'weekdays', 'weekly', 'monthly'].includes(value.frequency)) throw new Error('Invalid recurrence frequency');
19
19
  if (typeof value.timeZone !== 'string' || value.timeZone.length > 100 || /^[+-]/.test(value.timeZone)) throw new Error('Invalid recurrence timeZone');
@@ -24,12 +24,17 @@ export function normalizeRecurrence(value) {
24
24
  || new Set(value.weekdays).size !== value.weekdays.length)) throw new Error('Invalid recurrence weekdays');
25
25
  if (value.frequency === 'weekly' && !value.weekdays?.length) throw new Error('Weekly recurrence requires weekdays');
26
26
  if (value.dayOfMonth !== undefined && (!Number.isInteger(value.dayOfMonth) || value.dayOfMonth < 1 || value.dayOfMonth > 31)) throw new Error('Invalid recurrence dayOfMonth');
27
- if (value.frequency === 'monthly' && value.dayOfMonth === undefined) throw new Error('Monthly recurrence requires dayOfMonth');
27
+ if (value.daysOfMonth !== undefined && (!Array.isArray(value.daysOfMonth) || !value.daysOfMonth.length || value.daysOfMonth.length > 31
28
+ || [...value.daysOfMonth].some(day => !Number.isInteger(day) || day < 1 || day > 31)
29
+ || new Set(value.daysOfMonth).size !== value.daysOfMonth.length)) throw new Error('Invalid recurrence daysOfMonth');
30
+ if (value.dayOfMonth !== undefined && value.daysOfMonth !== undefined) throw new Error('Recurrence cannot contain both dayOfMonth and daysOfMonth');
31
+ if (value.frequency === 'monthly' && value.dayOfMonth === undefined && value.daysOfMonth === undefined) throw new Error('Monthly recurrence requires dayOfMonth or daysOfMonth');
28
32
  if (value.endsAt != null) validateScheduleTimestamp(value.endsAt, 'endsAt');
29
33
  if (value.maxRuns != null && (!Number.isInteger(value.maxRuns) || value.maxRuns < 1 || value.maxRuns > 1000)) throw new Error('Invalid recurrence maxRuns');
30
34
  return { frequency: value.frequency, timeZone: value.timeZone, time: value.time,
31
35
  ...(value.weekdays !== undefined ? { weekdays: [...value.weekdays].sort() } : {}),
32
36
  ...(value.dayOfMonth !== undefined ? { dayOfMonth: value.dayOfMonth } : {}),
37
+ ...(value.daysOfMonth !== undefined ? { daysOfMonth: [...value.daysOfMonth].sort((a, b) => a - b) } : {}),
33
38
  endsAt: value.endsAt ?? null, maxRuns: value.maxRuns ?? null };
34
39
  }
35
40
 
@@ -66,7 +71,8 @@ function matchesDate(date, recurrence) {
66
71
  if (recurrence.frequency === 'weekly') return recurrence.weekdays.includes(weekday);
67
72
  if (recurrence.frequency === 'monthly') {
68
73
  const last = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 0)).getUTCDate();
69
- return d.getUTCDate() === Math.min(recurrence.dayOfMonth, last);
74
+ // Match each civil date once even when several selected days clamp to month-end.
75
+ return (recurrence.daysOfMonth ?? [recurrence.dayOfMonth]).some(day => d.getUTCDate() === Math.min(day, last));
70
76
  }
71
77
  return true;
72
78
  }