@icaruk/zai-peak-hours 0.0.8 → 0.0.9
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.js +32 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,71 +33,54 @@ function loadConfig() {
|
|
|
33
33
|
configCache = DEFAULT_CONFIG;
|
|
34
34
|
return configCache;
|
|
35
35
|
}
|
|
36
|
-
async function showPeakHoursToast(client) {
|
|
37
|
-
const config = loadConfig();
|
|
38
|
-
if (!config.enabled) {
|
|
39
|
-
await client.tui.showToast({
|
|
40
|
-
body: {
|
|
41
|
-
message: 'Peak Hours plugin is disabled in config'
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const status = getPeakHoursStatus();
|
|
47
|
-
const message = formatPeakHoursMessage(status);
|
|
48
|
-
await client.tui.showToast({
|
|
49
|
-
body: {
|
|
50
|
-
message
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async function showDiagnostics(client) {
|
|
55
|
-
const config = loadConfig();
|
|
56
|
-
const status = getPeakHoursStatus();
|
|
57
|
-
const currentTime = new Date().toISOString();
|
|
58
|
-
const diagnostics = `=== Peak Hours Plugin Diagnostics ===
|
|
59
|
-
Plugin enabled: ${config.enabled}
|
|
60
|
-
Update interval: ${config.updateIntervalMinutes} minutes
|
|
61
|
-
Current time: ${currentTime}
|
|
62
|
-
In peak hours: ${status.inPeakHours}
|
|
63
|
-
Time until ${status.transitionType}: ${status.timeUntilTransition}
|
|
64
|
-
===================================`;
|
|
65
|
-
await client.tui.showToast({
|
|
66
|
-
body: {
|
|
67
|
-
message: diagnostics
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
36
|
export const PeakHours = async ({ client }) => {
|
|
72
37
|
const config = loadConfig();
|
|
73
38
|
return {
|
|
74
|
-
config: async (input) => {
|
|
75
|
-
input.command ?? (input.command = {});
|
|
76
|
-
input.command['peak_hours'] = {
|
|
77
|
-
template: '/peak_hours',
|
|
78
|
-
description: 'Display current peak hours status'
|
|
79
|
-
};
|
|
80
|
-
input.command['peak_hours_status'] = {
|
|
81
|
-
template: '/peak_hours_status',
|
|
82
|
-
description: 'Display peak hours plugin diagnostics'
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
39
|
'tool.execute.after': async (input) => {
|
|
86
40
|
if (!config.enabled) {
|
|
87
41
|
return;
|
|
88
42
|
}
|
|
89
43
|
if (input.tool === 'peak_hours') {
|
|
90
|
-
|
|
44
|
+
const status = getPeakHoursStatus();
|
|
45
|
+
const message = formatPeakHoursMessage(status);
|
|
46
|
+
await client.tui.showToast({
|
|
47
|
+
body: {
|
|
48
|
+
message,
|
|
49
|
+
variant: status.inPeakHours ? 'warning' : 'info'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
91
52
|
}
|
|
92
53
|
else if (input.tool === 'peak_hours_status') {
|
|
93
|
-
|
|
54
|
+
const config = loadConfig();
|
|
55
|
+
const status = getPeakHoursStatus();
|
|
56
|
+
const currentTime = new Date().toISOString();
|
|
57
|
+
const diagnostics = `=== Peak Hours Plugin Diagnostics ===
|
|
58
|
+
Plugin enabled: ${config.enabled}
|
|
59
|
+
Update interval: ${config.updateIntervalMinutes} minutes
|
|
60
|
+
Current time: ${currentTime}
|
|
61
|
+
In peak hours: ${status.inPeakHours}
|
|
62
|
+
Time until ${status.transitionType}: ${status.timeUntilTransition}
|
|
63
|
+
===================================`;
|
|
64
|
+
await client.tui.showToast({
|
|
65
|
+
body: {
|
|
66
|
+
message: diagnostics,
|
|
67
|
+
variant: 'info'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
94
70
|
}
|
|
95
71
|
},
|
|
96
72
|
'session.created': async () => {
|
|
97
73
|
if (!config.enabled) {
|
|
98
74
|
return;
|
|
99
75
|
}
|
|
100
|
-
|
|
76
|
+
const status = getPeakHoursStatus();
|
|
77
|
+
const message = formatPeakHoursMessage(status);
|
|
78
|
+
await client.tui.showToast({
|
|
79
|
+
body: {
|
|
80
|
+
message,
|
|
81
|
+
variant: status.inPeakHours ? 'warning' : 'info'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
101
84
|
},
|
|
102
85
|
tool: {
|
|
103
86
|
'peak_hours': tool({
|