@rubytech/taskmaster 1.13.2 → 1.13.3

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.13.2",
3
- "commit": "88d6bba938408c30d11292a357207ac4013341e1",
4
- "builtAt": "2026-03-03T16:52:03.788Z"
2
+ "version": "1.13.3",
3
+ "commit": "75bd5b9c88a61e9af0298b0c7a3299cc047a6a37",
4
+ "builtAt": "2026-03-03T17:22:53.401Z"
5
5
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Checks the combined gate: is the public agent currently able to respond?
3
+ *
4
+ * publicAgentEnabled only applies when opening hours are enabled — it is an
5
+ * override within the opening hours context. When opening hours are disabled,
6
+ * publicAgentEnabled is ignored (the Setup page controls agent behaviour).
7
+ */
8
+ export function isPublicAgentActive(business, now = new Date()) {
9
+ const oh = business?.openingHours;
10
+ if (!oh?.enabled) {
11
+ return isWithinOpeningHours(oh, now);
12
+ }
13
+ // Opening hours are enabled — check the per-schedule agent toggle.
14
+ if (business?.publicAgentEnabled === false) {
15
+ return { open: false, reason: "public agent paused" };
16
+ }
17
+ return isWithinOpeningHours(oh, now);
18
+ }
19
+ /**
20
+ * Pure function: checks whether the current time falls within business opening hours.
21
+ * Returns { open, reason } — reason is for logging only, never shown to customers.
22
+ */
23
+ export function isWithinOpeningHours(config, now = new Date()) {
24
+ if (!config || !config.enabled) {
25
+ return { open: true, reason: "opening hours disabled" };
26
+ }
27
+ // Resolve current date/time in the configured timezone (falls back to system tz).
28
+ const tz = config.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
29
+ const formatter = new Intl.DateTimeFormat("en-GB", {
30
+ timeZone: tz,
31
+ year: "numeric",
32
+ month: "2-digit",
33
+ day: "2-digit",
34
+ hour: "2-digit",
35
+ minute: "2-digit",
36
+ hour12: false,
37
+ weekday: "long",
38
+ });
39
+ const parts = Object.fromEntries(formatter.formatToParts(now).map((p) => [p.type, p.value]));
40
+ const isoDate = `${parts.year}-${parts.month}-${parts.day}`;
41
+ const currentTime = `${parts.hour}:${parts.minute}`;
42
+ const weekday = parts.weekday.toLowerCase();
43
+ // 1. Check closed dates.
44
+ if (config.closedDates?.includes(isoDate)) {
45
+ return { open: false, reason: `closed date: ${isoDate}` };
46
+ }
47
+ // 2. Check weekly schedule.
48
+ const daySchedule = config.schedule[weekday];
49
+ if (daySchedule === null || daySchedule === undefined) {
50
+ return { open: false, reason: `closed on ${weekday}s` };
51
+ }
52
+ // 3. Check time window (start inclusive, end exclusive).
53
+ if (currentTime < daySchedule.start) {
54
+ return { open: false, reason: `opens at ${daySchedule.start}` };
55
+ }
56
+ if (currentTime >= daySchedule.end) {
57
+ return { open: false, reason: `closed after ${daySchedule.end}` };
58
+ }
59
+ return { open: true, reason: "within opening hours" };
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/taskmaster",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "description": "AI-powered business assistant for small businesses",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,6 +75,7 @@
75
75
  "dist/whatsapp/**",
76
76
  "dist/records/**",
77
77
  "dist/filler/**",
78
+ "dist/business/**",
78
79
  "dist/license/**",
79
80
  "dist/suggestions/**"
80
81
  ],