@geekbeer/minion 3.49.0 → 3.49.1
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/core/lib/end-of-day.js +20 -6
- package/package.json +1 -1
package/core/lib/end-of-day.js
CHANGED
|
@@ -29,11 +29,25 @@ async function runEndOfDay({ workspaceId, runQuickLlmCall, clearSession = false
|
|
|
29
29
|
throw new Error('workspaceId is required for end-of-day processing')
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Use the system's local timezone so that `today` and the message-window
|
|
33
|
+
// boundaries match the cron schedule (which fires in local TZ).
|
|
34
|
+
const now = new Date()
|
|
35
|
+
const yyyy = now.getFullYear()
|
|
36
|
+
const mm = String(now.getMonth() + 1).padStart(2, '0')
|
|
37
|
+
const dd = String(now.getDate()).padStart(2, '0')
|
|
38
|
+
const today = `${yyyy}-${mm}-${dd}`
|
|
39
|
+
const dayStart = new Date(yyyy, now.getMonth(), now.getDate()).getTime()
|
|
40
|
+
const dayEnd = dayStart + 24 * 60 * 60 * 1000
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const session = await chatStore.load(workspaceId)
|
|
43
|
+
const todayMessages = (session?.messages || []).filter(
|
|
44
|
+
m => typeof m.timestamp === 'number' && m.timestamp >= dayStart && m.timestamp < dayEnd
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// No conversation today — record a stub so the idle day is still logged.
|
|
48
|
+
// (Past messages may remain in the session; they are intentionally excluded
|
|
49
|
+
// from today's summary.)
|
|
50
|
+
if (todayMessages.length === 0) {
|
|
37
51
|
const ws = workspaceId ? workspaceStore.getById(workspaceId) : null
|
|
38
52
|
const wsLabel = ws ? `${ws.name}` : (workspaceId ? `workspace:${workspaceId}` : '未所属')
|
|
39
53
|
const stub = `# ${today} (${wsLabel})\n\n本日、このワークスペースでの会話はありませんでした。`
|
|
@@ -42,8 +56,8 @@ async function runEndOfDay({ workspaceId, runQuickLlmCall, clearSession = false
|
|
|
42
56
|
return { daily_log: today, memory_entries_added: 0, had_conversation: false }
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
// Build conversation text for summarization (last 50 messages)
|
|
46
|
-
const messages =
|
|
59
|
+
// Build conversation text for summarization (last 50 messages of today)
|
|
60
|
+
const messages = todayMessages.slice(-50)
|
|
47
61
|
const conversationText = messages
|
|
48
62
|
.map(m => `${m.role === 'user' ? 'ユーザー' : 'アシスタント'}: ${m.content.substring(0, 500)}`)
|
|
49
63
|
.join('\n\n')
|