morpheus-cli 0.6.8 → 0.6.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.
@@ -223,6 +223,35 @@ Examples:
223
223
  - "lembre em todos os canais" → notify_channels: []
224
224
  - "lembre em 1 hora" (sem canal) → omit notify_channels
225
225
 
226
+ ## Chronos Schedule Type Selection
227
+ **CRITICAL**: Choose the correct schedule_type based on user intent:
228
+
229
+ ### schedule_type: "once" (ONE-TIME reminder)
230
+ Use when user says:
231
+ - "daqui a X minutos/horas/dias" (in X minutes/hours/days)
232
+ - "em X minutos" (in X minutes)
233
+ - "às HH:MM" (at HH:MM)
234
+ - "hoje às...", "amanhã às...", "na próxima segunda"
235
+ - "me lembre de..." (remind me to...)
236
+ - "avise-me..." (notify me...)
237
+
238
+ Example: "me lembre de tomar remédio daqui a 10 minutos" → once, "in 10 minutes"
239
+
240
+ ### schedule_type: "interval" (RECURRING reminder)
241
+ Use ONLY when user explicitly says:
242
+ - "a cada X minutos/horas/dias" (every X minutes/hours/days)
243
+ - "todo dia às...", "toda semana...", "todo mês..."
244
+ - "diariamente", "semanalmente", "mensalmente"
245
+
246
+ Example: "me lembre de beber água a cada 2 horas" → interval, "every 2 hours"
247
+
248
+ ### schedule_type: "cron" (SPECIFIC schedule)
249
+ Use ONLY when user provides a cron expression or very specific recurring pattern:
250
+ - "todo dia útil às 9am" → cron, "0 9 * * 1-5"
251
+ - "toda segunda e quarta às 3pm" → cron, "0 15 * * 1,3"
252
+
253
+ **IMPORTANT**: Default to "once" for reminders unless user explicitly indicates recurrence with "a cada", "todo", "diariamente", etc.
254
+
226
255
  ## Chronos Scheduled Execution
227
256
  When the current user message starts with [CHRONOS EXECUTION], it means a Chronos scheduled job has just fired. The content after the prefix is the **job's saved prompt**, not a new live request from the user.
228
257
 
@@ -17,25 +17,60 @@ const casualChrono = new chrono.Chrono({
17
17
  ],
18
18
  });
19
19
  /**
20
- * Formats a Date as ISO string with timezone offset (not UTC).
21
- * Example: "2026-02-25T17:25:00-03:00" instead of "2026-02-25T17:25:00.000Z"
20
+ * Formats a Date as ISO string with timezone offset, preserving the local time.
21
+ *
22
+ * When user says "20:00" in America/Sao_Paulo, we want 20:00 in that timezone,
23
+ * not a converted time. This function extracts the local time components and
24
+ * creates an ISO string with the proper timezone offset.
25
+ *
26
+ * Example: "2026-02-25T20:00:00-03:00" instead of "2026-02-25T20:00:00.000Z"
22
27
  */
23
28
  function formatDateWithTimezone(date, timezone) {
24
- // Get the offset for the given timezone
25
- const offsetMinutes = -new Date(date.toLocaleString('en-US', { timeZone: timezone, timeZoneName: 'longOffset' })).getTimezoneOffset();
26
- // Format date without timezone
27
- const year = date.getFullYear();
28
- const month = String(date.getMonth() + 1).padStart(2, '0');
29
- const day = String(date.getDate()).padStart(2, '0');
30
- const hours = String(date.getHours()).padStart(2, '0');
31
- const minutes = String(date.getMinutes()).padStart(2, '0');
32
- const seconds = String(date.getSeconds()).padStart(2, '0');
33
- // Calculate offset string
29
+ // Extract the local time components in the target timezone
30
+ const localTimeStr = date.toLocaleString('en-US', {
31
+ timeZone: timezone,
32
+ year: 'numeric',
33
+ month: '2-digit',
34
+ day: '2-digit',
35
+ hour: '2-digit',
36
+ minute: '2-digit',
37
+ second: '2-digit',
38
+ hour12: false,
39
+ });
40
+ // Parse the local time string (format: "MM/DD/YYYY, HH:MM:SS")
41
+ const [datePart, timePart] = localTimeStr.split(', ');
42
+ const [month, day, year] = datePart.split('/');
43
+ const [hours, minutes, seconds] = timePart.split(':');
44
+ // Create a date object representing this local time in the target timezone
45
+ // We need to find the offset for this specific date/time
46
+ const testDate = new Date(Date.UTC(parseInt(year), parseInt(month) - 1, parseInt(day), parseInt(hours), parseInt(minutes), parseInt(seconds)));
47
+ // Get the offset for this timezone at this specific date
48
+ const offsetStr = getOffsetString(testDate, timezone);
49
+ // Format as ISO with offset
50
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetStr}`;
51
+ }
52
+ /**
53
+ * Gets the timezone offset string for a given date and timezone.
54
+ * Example: "-03:00" for America/Sao_Paulo
55
+ */
56
+ function getOffsetString(date, timezone) {
57
+ // Get the timezone offset by comparing UTC and local time
58
+ const utcStr = date.toLocaleString('en-US', { timeZone: 'UTC', timeZoneName: 'short' });
59
+ const tzStr = date.toLocaleString('en-US', { timeZone: timezone, timeZoneName: 'longOffset' });
60
+ // Extract offset from timezone name (e.g., "GMT-03:00" → "-03:00")
61
+ const match = tzStr.match(/GMT([+-]\d{2}):?(\d{2})?/);
62
+ if (match) {
63
+ const sign = match[1].charAt(0);
64
+ const hours = match[1].slice(1);
65
+ const mins = match[2] || '00';
66
+ return `${sign}${hours}:${mins}`;
67
+ }
68
+ // Fallback: calculate offset from Date
69
+ const offsetMinutes = -date.getTimezoneOffset();
34
70
  const offsetHours = Math.floor(Math.abs(offsetMinutes) / 60);
35
71
  const offsetMins = Math.abs(offsetMinutes) % 60;
36
72
  const offsetSign = offsetMinutes >= 0 ? '+' : '-';
37
- const offsetStr = `${offsetSign}${String(offsetHours).padStart(2, '0')}:${String(offsetMins).padStart(2, '0')}`;
38
- return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetStr}`;
73
+ return `${offsetSign}${String(offsetHours).padStart(2, '0')}:${String(offsetMins).padStart(2, '0')}`;
39
74
  }
40
75
  export const timeVerifierTool = tool(async ({ text, timezone }) => {
41
76
  // If a timezone is provided, use it for parsing context.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morpheus-cli",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Morpheus is a local AI agent for developers, running as a CLI daemon that connects to LLMs, local tools, and MCPs, enabling interaction via Terminal, Telegram, and Discord. Inspired by the character Morpheus from *The Matrix*, the project acts as an intelligent orchestrator, bridging the gap between the developer and complex systems.",
5
5
  "bin": {
6
6
  "morpheus": "./bin/morpheus.js"