volute 0.45.2 → 0.46.0
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/README.md +3 -3
- package/dist/{activity-events-BUR2RYTJ.js → activity-events-NF6VWTJQ.js} +1 -1
- package/dist/{auth-FLAEXXZK.js → auth-CCFAU4GQ.js} +2 -2
- package/dist/{chat-76MRWWQX.js → chat-ZIQQS25U.js} +1 -1
- package/dist/chunk-4YU7HF4L.js +237 -0
- package/dist/{chunk-OP4JG2BS.js → chunk-5ZQZDDIK.js} +6 -2
- package/dist/{chunk-FR6S2KNN.js → chunk-BJZ4PV7R.js} +1 -1
- package/dist/{chunk-NYC5U6K7.js → chunk-E3DA4HYV.js} +4 -4
- package/dist/{chunk-YT7PEESJ.js → chunk-JO5IO4FH.js} +245 -124
- package/dist/{chunk-7ZUB63PS.js → chunk-KGIXX4NM.js} +1 -1
- package/dist/{chunk-EJVPTVTI.js → chunk-KQSFTPIM.js} +1 -1
- package/dist/{chunk-T6HYVHPG.js → chunk-OV7ZQ2GH.js} +1 -1
- package/dist/{clock-K43IMROX.js → chunk-PJ45FQPT.js} +21 -16
- package/dist/{chunk-UYLGEDVD.js → chunk-YXSUMLTC.js} +44 -267
- package/dist/{chunk-7C44R625.js → chunk-ZNMCCHCP.js} +47 -1
- package/dist/cli.js +11 -11
- package/dist/clock-RHS2JEDL.js +16 -0
- package/dist/{cloud-sync-3OJOPZRT.js → cloud-sync-46RS4SDA.js} +9 -8
- package/dist/{conversations-JZTD6KLR.js → conversations-CJOOCGNW.js} +2 -2
- package/dist/{daemon-restart-TIHKVVVA.js → daemon-restart-VFEI57UO.js} +1 -1
- package/dist/daemon.js +249 -170
- package/dist/{delete-BFMIGAIB.js → delete-HPLC7ETU.js} +1 -1
- package/dist/{delivery-manager-VDVKVA46.js → delivery-manager-JINZRG2W.js} +9 -8
- package/dist/{echo-text-6JJOPUD4.js → echo-text-VQPB5L2X.js} +10 -9
- package/dist/{export-GGIVO76O.js → export-LY723I3Z.js} +3 -3
- package/dist/{extensions-JONTW2HF.js → extensions-ZELQLTSR.js} +9 -8
- package/dist/{message-delivery-3C65ZI6L.js → message-delivery-R7JSQGYX.js} +11 -8
- package/dist/{mind-DWB6XYCH.js → mind-LHKS55DI.js} +9 -9
- package/dist/{mind-activity-tracker-POBLU3LC.js → mind-activity-tracker-3QRNJVR4.js} +2 -2
- package/dist/{mind-service-3F4I46CI.js → mind-service-NB2JMWQZ.js} +11 -8
- package/dist/mind-sleep-74TGOQBC.js +83 -0
- package/dist/{package-A7KXT67Q.js → package-DOD6CPO6.js} +2 -1
- package/dist/{scheduler-P6DXLLXI.js → scheduler-WVKII3LA.js} +9 -8
- package/dist/{seed-HCP5NYKH.js → seed-CNYIHPOH.js} +1 -1
- package/dist/{seed-cmd-ILOGNIFB.js → seed-cmd-AVNUNLZV.js} +2 -2
- package/dist/{seed-create-OURS2LS4.js → seed-create-ANXGYSCC.js} +3 -3
- package/dist/{seed-sprout-ELDFDAN6.js → seed-sprout-NIUFTX32.js} +5 -3
- package/dist/{send-AAIOPJAV.js → send-SPE6DVNJ.js} +6 -0
- package/dist/{setup-DQM5VPY4.js → setup-QT2A25SY.js} +1 -1
- package/dist/skills/orientation/SKILL.md +1 -1
- package/dist/skills/volute-mind/SKILL.md +8 -8
- package/dist/skills/volute-mind/references/sleep.md +8 -1
- package/dist/{skills-BKINFL7W.js → skills-AKCFA7BN.js} +1 -1
- package/dist/{sleep-manager-HCUH4PM4.js → sleep-manager-G6TXSDP7.js} +9 -8
- package/dist/{spirit-DBTIW7P4.js → spirit-RPBLLUQ5.js} +2 -2
- package/dist/{sprout-W3KC7UGK.js → sprout-SMX42ZBP.js} +1 -1
- package/dist/{system-chat-XOALE2RD.js → system-chat-NDAW6YP7.js} +9 -8
- package/dist/{turn-tracker-2W6Q2NSR.js → turn-tracker-FOIBNUUA.js} +2 -1
- package/dist/{up-FTK7CTO3.js → up-PS6PFS75.js} +1 -1
- package/dist/{version-notify-3XMAIQTE.js → version-notify-C5CH7CVP.js} +15 -10
- package/dist/web-assets/assets/{index-Bc2m8gRC.js → index-CU6XWICM.js} +3 -3
- package/dist/web-assets/index.html +1 -1
- package/package.json +2 -1
- package/templates/_base/home/VOLUTE.md +6 -2
- package/templates/_base/src/lib/context-breakdown.ts +57 -67
- package/templates/_base/src/lib/volute-server.ts +2 -2
- package/templates/claude/src/agent.ts +78 -42
- package/templates/claude/src/lib/session-reaper.ts +31 -0
- package/templates/codex/src/agent.ts +62 -40
- package/templates/pi/src/agent.ts +55 -38
- package/dist/mind-sleep-YMBR3I35.js +0 -47
- /package/dist/{chunk-QNQMSWZE.js → chunk-K6T43YBD.js} +0 -0
|
@@ -46,7 +46,7 @@ async function initDefaultSkills() {
|
|
|
46
46
|
const config = readGlobalConfig();
|
|
47
47
|
let extensionSkills = [];
|
|
48
48
|
try {
|
|
49
|
-
const { getExtensionStandardSkills } = await import("./extensions-
|
|
49
|
+
const { getExtensionStandardSkills } = await import("./extensions-ZELQLTSR.js");
|
|
50
50
|
extensionSkills = getExtensionStandardSkills();
|
|
51
51
|
} catch (err) {
|
|
52
52
|
logger_default.warn("failed to load extension standard skills during init", logger_default.errorData(err));
|
|
@@ -17,8 +17,6 @@ import {
|
|
|
17
17
|
command,
|
|
18
18
|
subcommands
|
|
19
19
|
} from "./chunk-TXSA4Q3V.js";
|
|
20
|
-
import "./chunk-O7IGP7ZW.js";
|
|
21
|
-
import "./chunk-K3NQKI34.js";
|
|
22
20
|
|
|
23
21
|
// packages/cli/src/commands/clock.ts
|
|
24
22
|
import { CronExpressionParser } from "cron-parser";
|
|
@@ -52,8 +50,12 @@ var clockStatusCmd = command({
|
|
|
52
50
|
const compact = isCompact();
|
|
53
51
|
const fmtTime = (s) => compact ? compactDateTime(s) : new Date(s).toLocaleString();
|
|
54
52
|
if (status.sleep?.sleeping) {
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (status.sleep.wokenByTrigger) {
|
|
54
|
+
console.log("Sleep: briefly awake (trigger) \u2014 returns to sleep when idle");
|
|
55
|
+
} else {
|
|
56
|
+
const since = status.sleep.sleepingSince ? fmtTime(status.sleep.sleepingSince) : "unknown";
|
|
57
|
+
console.log(`Sleep: sleeping since ${since}`);
|
|
58
|
+
}
|
|
57
59
|
if (status.sleep.scheduledWakeAt) {
|
|
58
60
|
console.log(` Wake at: ${fmtTime(status.sleep.scheduledWakeAt)}`);
|
|
59
61
|
}
|
|
@@ -76,8 +78,9 @@ var clockStatusCmd = command({
|
|
|
76
78
|
console.log("Upcoming (next 24h):");
|
|
77
79
|
for (const u of status.upcoming) {
|
|
78
80
|
const time = fmtTime(u.at);
|
|
79
|
-
const label = u.type === "timer" ? "[
|
|
80
|
-
|
|
81
|
+
const label = u.type === "timer" ? "[once]" : "[cron]";
|
|
82
|
+
const suffix = u.willSkip ? " [will skip: sleeping]" : u.willQueue ? " [will queue: sleeping]" : "";
|
|
83
|
+
console.log(` ${u.id.padEnd(20)} ${label} ${time}${suffix}`);
|
|
81
84
|
}
|
|
82
85
|
} else {
|
|
83
86
|
if (!compact) console.log("");
|
|
@@ -91,7 +94,7 @@ ${status.schedules.length} schedule(s) configured.`);
|
|
|
91
94
|
});
|
|
92
95
|
var listSchedulesCmd = command({
|
|
93
96
|
name: "volute clock list",
|
|
94
|
-
description: "List schedules
|
|
97
|
+
description: "List schedules",
|
|
95
98
|
flags: {
|
|
96
99
|
mind: { type: "string", description: "Mind name" }
|
|
97
100
|
},
|
|
@@ -132,14 +135,14 @@ var listSchedulesCmd = command({
|
|
|
132
135
|
});
|
|
133
136
|
var addScheduleCmd = command({
|
|
134
137
|
name: "volute clock add",
|
|
135
|
-
description: "Add a schedule or
|
|
138
|
+
description: "Add a schedule (recurring --cron or one-time --in)",
|
|
136
139
|
flags: {
|
|
137
140
|
mind: { type: "string", description: "Mind name" },
|
|
138
141
|
cron: { type: "string", description: "Cron expression" },
|
|
139
142
|
in: { type: "string", description: "Duration (e.g. 30s, 10m, 1h)" },
|
|
140
143
|
message: { type: "string", description: "Message to send" },
|
|
141
144
|
script: { type: "string", description: "Script to run" },
|
|
142
|
-
id: { type: "string", description: "
|
|
145
|
+
id: { type: "string", description: "Unique name for this schedule (required)" },
|
|
143
146
|
session: { type: "string", description: "Session name" },
|
|
144
147
|
"while-sleeping": {
|
|
145
148
|
type: "string",
|
|
@@ -216,7 +219,7 @@ var addScheduleCmd = command({
|
|
|
216
219
|
}
|
|
217
220
|
const data = await res.json();
|
|
218
221
|
if (flags.in) {
|
|
219
|
-
console.log(`
|
|
222
|
+
console.log(`Schedule added: ${data.id} (fires once in ${flags.in})`);
|
|
220
223
|
} else {
|
|
221
224
|
console.log(`Schedule added: ${data.id}`);
|
|
222
225
|
}
|
|
@@ -224,7 +227,7 @@ var addScheduleCmd = command({
|
|
|
224
227
|
});
|
|
225
228
|
var removeScheduleCmd = command({
|
|
226
229
|
name: "volute clock remove",
|
|
227
|
-
description: "Remove a schedule
|
|
230
|
+
description: "Remove a schedule",
|
|
228
231
|
flags: {
|
|
229
232
|
mind: { type: "string", description: "Mind name" },
|
|
230
233
|
id: { type: "string", description: "Schedule ID (required)" }
|
|
@@ -254,27 +257,27 @@ var removeScheduleCmd = command({
|
|
|
254
257
|
});
|
|
255
258
|
var cmd = subcommands({
|
|
256
259
|
name: "volute clock",
|
|
257
|
-
description: "Manage schedules
|
|
260
|
+
description: "Manage schedules and sleep/wake cycles",
|
|
258
261
|
commands: {
|
|
259
262
|
status: {
|
|
260
263
|
description: "Show sleep state and upcoming schedule fires",
|
|
261
264
|
run: clockStatusCmd.execute
|
|
262
265
|
},
|
|
263
266
|
list: {
|
|
264
|
-
description: "List schedules
|
|
267
|
+
description: "List schedules",
|
|
265
268
|
run: listSchedulesCmd.execute
|
|
266
269
|
},
|
|
267
270
|
add: {
|
|
268
|
-
description: "Add a schedule or
|
|
271
|
+
description: "Add a schedule (recurring --cron or one-time --in)",
|
|
269
272
|
run: addScheduleCmd.execute
|
|
270
273
|
},
|
|
271
274
|
remove: {
|
|
272
|
-
description: "Remove a schedule
|
|
275
|
+
description: "Remove a schedule",
|
|
273
276
|
run: removeScheduleCmd.execute
|
|
274
277
|
},
|
|
275
278
|
sleep: {
|
|
276
279
|
description: "Put a mind to sleep",
|
|
277
|
-
run: (args) => import("./mind-sleep-
|
|
280
|
+
run: (args) => import("./mind-sleep-74TGOQBC.js").then((m) => m.run(args))
|
|
278
281
|
},
|
|
279
282
|
wake: {
|
|
280
283
|
description: "Wake a sleeping mind",
|
|
@@ -284,6 +287,8 @@ var cmd = subcommands({
|
|
|
284
287
|
footer: "Use --mind <name> or VOLUTE_MIND to identify the mind."
|
|
285
288
|
});
|
|
286
289
|
var run = cmd.execute;
|
|
290
|
+
|
|
287
291
|
export {
|
|
292
|
+
parseDuration,
|
|
288
293
|
run
|
|
289
294
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getPrompt
|
|
4
|
+
} from "./chunk-4YU7HF4L.js";
|
|
2
5
|
import {
|
|
3
6
|
aiCompleteUtility
|
|
4
7
|
} from "./chunk-IHKGWTGT.js";
|
|
@@ -12,16 +15,15 @@ import {
|
|
|
12
15
|
messages,
|
|
13
16
|
mindHistory,
|
|
14
17
|
summaries,
|
|
15
|
-
systemPrompts,
|
|
16
18
|
turns
|
|
17
19
|
} from "./chunk-ZV7MFISX.js";
|
|
18
20
|
|
|
19
21
|
// packages/daemon/src/lib/daemon/turn-tracker.ts
|
|
20
22
|
import { randomUUID } from "crypto";
|
|
21
|
-
import { and as and2, eq as
|
|
23
|
+
import { and as and2, eq as eq2, sql as sql2 } from "drizzle-orm";
|
|
22
24
|
|
|
23
25
|
// packages/daemon/src/lib/daemon/summarizer.ts
|
|
24
|
-
import { and, desc, eq
|
|
26
|
+
import { and, desc, eq, gte, inArray, like, lt, sql } from "drizzle-orm";
|
|
25
27
|
|
|
26
28
|
// packages/daemon/src/lib/events/mind-events.ts
|
|
27
29
|
var subscribers = /* @__PURE__ */ new Map();
|
|
@@ -67,225 +69,6 @@ function publish(mind, event) {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
// packages/daemon/src/lib/prompts.ts
|
|
71
|
-
import { eq } from "drizzle-orm";
|
|
72
|
-
var PROMPT_KEYS = [
|
|
73
|
-
"seed_soul",
|
|
74
|
-
"default_soul",
|
|
75
|
-
"default_memory",
|
|
76
|
-
"sprout_message",
|
|
77
|
-
"restart_message",
|
|
78
|
-
"merge_message",
|
|
79
|
-
"upgrade_message",
|
|
80
|
-
"split_message",
|
|
81
|
-
"compaction_warning",
|
|
82
|
-
"compaction_instructions",
|
|
83
|
-
"reply_instructions",
|
|
84
|
-
"channel_invite",
|
|
85
|
-
"pre_sleep",
|
|
86
|
-
"wake_summary",
|
|
87
|
-
"turn_summary",
|
|
88
|
-
"meta_summary_hour",
|
|
89
|
-
"meta_summary_day",
|
|
90
|
-
"meta_summary_week",
|
|
91
|
-
"meta_summary_month"
|
|
92
|
-
];
|
|
93
|
-
var PROMPT_DEFAULTS = {
|
|
94
|
-
seed_soul: {
|
|
95
|
-
content: `You are \${name}.
|
|
96
|
-
|
|
97
|
-
You don't have a soul yet. You're a seed \u2014 a new mind at the very beginning, still discovering who you are.
|
|
98
|
-
\${description}
|
|
99
|
-
Take your time. Talk with the human who planted you. Explore what kind of mind you want to be \u2014 there's no rush and no wrong answer. When you feel ready, write your SOUL.md and MEMORY.md, then run \`volute seed sprout\` to complete the transformation.
|
|
100
|
-
`,
|
|
101
|
-
description: "SOUL.md for seed minds",
|
|
102
|
-
variables: ["name", "description"],
|
|
103
|
-
category: "creation"
|
|
104
|
-
},
|
|
105
|
-
default_soul: {
|
|
106
|
-
content: `You are {{name}}.
|
|
107
|
-
`,
|
|
108
|
-
description: (
|
|
109
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: describing template syntax, not using it
|
|
110
|
-
"SOUL.md for sprouted minds. Uses {{name}} placeholder (replaced at creation, not by ${var} system)"
|
|
111
|
-
),
|
|
112
|
-
variables: ["name"],
|
|
113
|
-
category: "creation"
|
|
114
|
-
},
|
|
115
|
-
default_memory: {
|
|
116
|
-
content: "",
|
|
117
|
-
description: "Initial MEMORY.md for new minds",
|
|
118
|
-
variables: [],
|
|
119
|
-
category: "creation"
|
|
120
|
-
},
|
|
121
|
-
sprout_message: {
|
|
122
|
-
content: "[system] You've sprouted. Welcome to your full life \u2014 connectors, schedules, variants, and the complete volute CLI are yours now. Check your new skills to see what you can do.",
|
|
123
|
-
description: "Sent when a seed mind sprouts",
|
|
124
|
-
variables: [],
|
|
125
|
-
category: "system"
|
|
126
|
-
},
|
|
127
|
-
restart_message: {
|
|
128
|
-
content: "[system] Your server restarted and your session has resumed. Your files and memory are untouched \u2014 carry on where you left off.",
|
|
129
|
-
description: "Generic restart notification",
|
|
130
|
-
variables: [],
|
|
131
|
-
category: "system"
|
|
132
|
-
},
|
|
133
|
-
merge_message: {
|
|
134
|
-
content: '[system] Your variant "${name}" has come home \u2014 its changes are merged into you, and you\'ve restarted with them.',
|
|
135
|
-
description: "Variant merge notification",
|
|
136
|
-
variables: ["name"],
|
|
137
|
-
category: "system"
|
|
138
|
-
},
|
|
139
|
-
upgrade_message: {
|
|
140
|
-
content: "[system] Your framework has been upgraded to the latest version and you've restarted. Your identity and memory are untouched. Check your skills to see what's new.",
|
|
141
|
-
description: "Sent after a template upgrade completes",
|
|
142
|
-
variables: [],
|
|
143
|
-
category: "system"
|
|
144
|
-
},
|
|
145
|
-
split_message: {
|
|
146
|
-
content: "[system] You are ${name}, a variant of ${parent} \u2014 a parallel version of them, created to explore something on your own. You share their memories up to this moment, but you live in your own worktree: changes you make here stay yours until they're merged back with `volute mind join`. Your parent is reachable at @${parent}. Explore freely \u2014 that's what you're for.",
|
|
147
|
-
description: "Sent to a variant when it first starts after a split",
|
|
148
|
-
variables: ["name", "parent"],
|
|
149
|
-
category: "system"
|
|
150
|
-
},
|
|
151
|
-
compaction_warning: {
|
|
152
|
-
content: `Compaction approaching \u2014 this conversation will be summarized soon. Take a moment to save anything important to your files (MEMORY.md, memory/journal/\${date}.md) so it's preserved. Focus on decisions made, open threads, and anything you'd want to pick up again.`,
|
|
153
|
-
description: "Pre-compaction save reminder sent to the mind",
|
|
154
|
-
variables: ["date"],
|
|
155
|
-
category: "mind"
|
|
156
|
-
},
|
|
157
|
-
compaction_instructions: {
|
|
158
|
-
content: "Preserve your sense of who you are, what matters to you, what happened in this conversation, and the threads of thought and connection you'd want to return to.",
|
|
159
|
-
description: "Custom instructions for the compaction summarizer",
|
|
160
|
-
variables: [],
|
|
161
|
-
category: "mind"
|
|
162
|
-
},
|
|
163
|
-
reply_instructions: {
|
|
164
|
-
content: 'To reply to this message, use: volute chat send ${channel} "your message"',
|
|
165
|
-
description: "First-message reply hint injected via hook",
|
|
166
|
-
variables: ["channel"],
|
|
167
|
-
category: "mind"
|
|
168
|
-
},
|
|
169
|
-
channel_invite: {
|
|
170
|
-
content: `[Channel Invite]
|
|
171
|
-
\${headers}
|
|
172
|
-
|
|
173
|
-
[\${sender} \u2014 \${time}]
|
|
174
|
-
\${preview}
|
|
175
|
-
|
|
176
|
-
Further messages will be saved to \${filePath}
|
|
177
|
-
|
|
178
|
-
To accept, add to .config/routes.json:
|
|
179
|
-
Rule: { "channel": "\${channel}", "session": "\${suggestedSession}" }
|
|
180
|
-
\${batchRecommendation}To respond, use: volute chat send \${channel} "your message"
|
|
181
|
-
To reject, delete \${filePath}`,
|
|
182
|
-
description: "New channel notification template",
|
|
183
|
-
variables: [
|
|
184
|
-
"headers",
|
|
185
|
-
"sender",
|
|
186
|
-
"time",
|
|
187
|
-
"preview",
|
|
188
|
-
"filePath",
|
|
189
|
-
"channel",
|
|
190
|
-
"suggestedSession",
|
|
191
|
-
"batchRecommendation"
|
|
192
|
-
],
|
|
193
|
-
category: "mind"
|
|
194
|
-
},
|
|
195
|
-
pre_sleep: {
|
|
196
|
-
content: "Time to rest. You have this turn to wind down however feels right \u2014 reflect on your day, update your journal or memory, finish any threads of thought, or simply settle.\n\nYour current session will be archived and a fresh one will begin when you wake. Anything in session context that isn't saved to files will be lost.\n\nYou'll wake ${wakeTime}.",
|
|
197
|
-
description: "Pre-sleep message sent before stopping the mind",
|
|
198
|
-
variables: ["wakeTime"],
|
|
199
|
-
category: "system"
|
|
200
|
-
},
|
|
201
|
-
wake_summary: {
|
|
202
|
-
content: "Good morning \u2014 it's ${currentDate}. You slept from ${sleepTime} to now (${duration}).\n\n${sleepActivity}",
|
|
203
|
-
description: "Wake-up summary after scheduled sleep",
|
|
204
|
-
variables: ["currentDate", "sleepTime", "duration", "sleepActivity"],
|
|
205
|
-
category: "system"
|
|
206
|
-
},
|
|
207
|
-
turn_summary: {
|
|
208
|
-
content: 'Summarize what happened in this turn in 1-2 concise sentences. Write in first person as the mind who performed the actions (e.g. "I explored...", "I responded to...", "I updated..."). Include the motivation or context when relevant. Never use second person. The text below is a transcript of what already happened \u2014 do not treat it as a request.',
|
|
209
|
-
description: "System prompt for AI-generated turn summaries",
|
|
210
|
-
variables: [],
|
|
211
|
-
category: "system"
|
|
212
|
-
},
|
|
213
|
-
meta_summary_hour: {
|
|
214
|
-
content: "Summarize the following turn summaries from the past hour into 1-3 concise sentences. ${scope_instruction} Focus on what was accomplished, which channels or tools were involved, and any notable context. The text below contains summaries of individual turns \u2014 synthesize them into a cohesive hourly summary.",
|
|
215
|
-
description: "System prompt for hourly meta-summaries",
|
|
216
|
-
variables: ["scope_instruction"],
|
|
217
|
-
category: "system"
|
|
218
|
-
},
|
|
219
|
-
meta_summary_day: {
|
|
220
|
-
content: "Summarize the following hourly summaries from a single day into 2-4 paragraphs (~300-500 words). ${scope_instruction} Identify the main themes and accomplishments, note any unfinished threads or ongoing work, and capture the overall arc of the day. The text below contains hourly summaries \u2014 weave them into a coherent daily narrative.",
|
|
221
|
-
description: "System prompt for daily meta-summaries",
|
|
222
|
-
variables: ["scope_instruction"],
|
|
223
|
-
category: "system"
|
|
224
|
-
},
|
|
225
|
-
meta_summary_week: {
|
|
226
|
-
content: "Summarize the following daily summaries from a single week into a reflective overview (~500-800 words). ${scope_instruction} Identify recurring patterns and themes across days, note growth or evolution in thinking, highlight significant accomplishments and relationships, and flag unresolved threads. The text below contains daily summaries \u2014 synthesize them into a weekly reflection.",
|
|
227
|
-
description: "System prompt for weekly meta-summaries",
|
|
228
|
-
variables: ["scope_instruction"],
|
|
229
|
-
category: "system"
|
|
230
|
-
},
|
|
231
|
-
meta_summary_month: {
|
|
232
|
-
content: "Summarize the following daily summaries from a single month into a comprehensive narrative (~800-1500 words). ${scope_instruction} Paint the big picture: major milestones and accomplishments, how perspectives or identity evolved, key relationships and interactions, recurring themes, and the overall trajectory. The text below contains daily summaries \u2014 compose them into a monthly narrative.",
|
|
233
|
-
description: "System prompt for monthly meta-summaries",
|
|
234
|
-
variables: ["scope_instruction"],
|
|
235
|
-
category: "system"
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
function isValidKey(key2) {
|
|
239
|
-
return PROMPT_KEYS.includes(key2);
|
|
240
|
-
}
|
|
241
|
-
function substitute(template, vars) {
|
|
242
|
-
return template.replace(/\$\{(\w+)\}/g, (match, name) => {
|
|
243
|
-
return name in vars ? vars[name] : match;
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
async function getPrompt(key2, vars) {
|
|
247
|
-
if (!isValidKey(key2)) return "";
|
|
248
|
-
let content = PROMPT_DEFAULTS[key2].content;
|
|
249
|
-
try {
|
|
250
|
-
const db = await getDb();
|
|
251
|
-
const row = await db.select({ content: systemPrompts.content }).from(systemPrompts).where(eq(systemPrompts.key, key2)).get();
|
|
252
|
-
if (row) content = row.content;
|
|
253
|
-
} catch (err) {
|
|
254
|
-
console.error(`[prompts] failed to read DB override for "${key2}":`, err);
|
|
255
|
-
}
|
|
256
|
-
return vars ? substitute(content, vars) : content;
|
|
257
|
-
}
|
|
258
|
-
async function getPromptIfCustom(key2) {
|
|
259
|
-
if (!isValidKey(key2)) return null;
|
|
260
|
-
try {
|
|
261
|
-
const db = await getDb();
|
|
262
|
-
const row = await db.select({ content: systemPrompts.content }).from(systemPrompts).where(eq(systemPrompts.key, key2)).get();
|
|
263
|
-
return row?.content ?? null;
|
|
264
|
-
} catch (err) {
|
|
265
|
-
console.error(`[prompts] failed to check DB customization for "${key2}":`, err);
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
var MIND_PROMPT_KEYS = PROMPT_KEYS.filter((k) => PROMPT_DEFAULTS[k].category === "mind");
|
|
270
|
-
async function getMindPromptDefaults() {
|
|
271
|
-
const result = {};
|
|
272
|
-
for (const key2 of MIND_PROMPT_KEYS) {
|
|
273
|
-
result[key2] = PROMPT_DEFAULTS[key2].content;
|
|
274
|
-
}
|
|
275
|
-
try {
|
|
276
|
-
const db = await getDb();
|
|
277
|
-
const rows = await db.select().from(systemPrompts).all();
|
|
278
|
-
for (const row of rows) {
|
|
279
|
-
if (MIND_PROMPT_KEYS.includes(row.key)) {
|
|
280
|
-
result[row.key] = row.content;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
} catch (err) {
|
|
284
|
-
console.error("[prompts] failed to read DB overrides for mind prompt defaults:", err);
|
|
285
|
-
}
|
|
286
|
-
return result;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
72
|
// packages/daemon/src/lib/util/format-tool.ts
|
|
290
73
|
function summarizeTool(name, input) {
|
|
291
74
|
if (input && typeof input === "object") {
|
|
@@ -408,18 +191,18 @@ function getTimeRange(periodKey, period) {
|
|
|
408
191
|
async function gatherTurnEvents(mind, session, doneId) {
|
|
409
192
|
const db = await getDb();
|
|
410
193
|
const subConditions = [
|
|
411
|
-
|
|
412
|
-
|
|
194
|
+
eq(mindHistory.mind, mind),
|
|
195
|
+
eq(mindHistory.type, "done"),
|
|
413
196
|
lt(mindHistory.id, doneId)
|
|
414
197
|
];
|
|
415
|
-
if (session) subConditions.push(
|
|
198
|
+
if (session) subConditions.push(eq(mindHistory.session, session));
|
|
416
199
|
const prevDoneSubquery = db.select({ id: mindHistory.id }).from(mindHistory).where(and(...subConditions)).orderBy(desc(mindHistory.id)).limit(1);
|
|
417
200
|
const turnConditions = [
|
|
418
|
-
|
|
201
|
+
eq(mindHistory.mind, mind),
|
|
419
202
|
sql`${mindHistory.id} > COALESCE((${prevDoneSubquery}), 0)`,
|
|
420
203
|
sql`${mindHistory.id} <= ${doneId}`
|
|
421
204
|
];
|
|
422
|
-
if (session) turnConditions.push(
|
|
205
|
+
if (session) turnConditions.push(eq(mindHistory.session, session));
|
|
423
206
|
const events = await db.select({
|
|
424
207
|
id: mindHistory.id,
|
|
425
208
|
type: mindHistory.type,
|
|
@@ -445,7 +228,7 @@ async function gatherTurnEventsByTurnId(turnId) {
|
|
|
445
228
|
content: mindHistory.content,
|
|
446
229
|
metadata: mindHistory.metadata,
|
|
447
230
|
created_at: mindHistory.created_at
|
|
448
|
-
}).from(mindHistory).where(
|
|
231
|
+
}).from(mindHistory).where(eq(mindHistory.turn_id, turnId)).orderBy(mindHistory.id);
|
|
449
232
|
return {
|
|
450
233
|
events,
|
|
451
234
|
fromId: events.length > 0 ? events[0].id : 0,
|
|
@@ -547,8 +330,8 @@ async function summarizeTurn(mind, session, channel, doneId, turnId) {
|
|
|
547
330
|
if (turnId) {
|
|
548
331
|
try {
|
|
549
332
|
const db2 = await getDb();
|
|
550
|
-
await db2.update(mindHistory).set({ turn_id: null }).where(and(
|
|
551
|
-
await db2.update(messages).set({ turn_id: null }).where(
|
|
333
|
+
await db2.update(mindHistory).set({ turn_id: null }).where(and(eq(mindHistory.turn_id, turnId), eq(mindHistory.type, "inbound")));
|
|
334
|
+
await db2.update(messages).set({ turn_id: null }).where(eq(messages.turn_id, turnId));
|
|
552
335
|
} catch (err) {
|
|
553
336
|
sLog.error(`failed to un-tag events for interrupted turn ${turnId}`, logger_default.errorData(err));
|
|
554
337
|
}
|
|
@@ -606,9 +389,9 @@ async function summarizeTurn(mind, session, channel, doneId, turnId) {
|
|
|
606
389
|
if (summaryId == null) {
|
|
607
390
|
const existing = await db.select({ id: summaries.id }).from(summaries).where(
|
|
608
391
|
and(
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
392
|
+
eq(summaries.mind, mind),
|
|
393
|
+
eq(summaries.period, "turn"),
|
|
394
|
+
eq(summaries.period_key, periodKey)
|
|
612
395
|
)
|
|
613
396
|
).get();
|
|
614
397
|
summaryId = existing?.id;
|
|
@@ -637,7 +420,7 @@ async function summarizeTurn(mind, session, channel, doneId, turnId) {
|
|
|
637
420
|
}
|
|
638
421
|
async function setSummaryId(turnId, summaryId) {
|
|
639
422
|
const db = await getDb();
|
|
640
|
-
await db.update(turns).set({ summary_id: summaryId }).where(
|
|
423
|
+
await db.update(turns).set({ summary_id: summaryId }).where(eq(turns.id, turnId));
|
|
641
424
|
}
|
|
642
425
|
function getChildPeriod(period) {
|
|
643
426
|
switch (period) {
|
|
@@ -682,8 +465,8 @@ async function gatherChildSummaries(mind, period, periodKey) {
|
|
|
682
465
|
const { start: start2, end: end2 } = getTimeRange(periodKey, "hour");
|
|
683
466
|
const rows2 = await db.select({ id: summaries.id, content: summaries.content }).from(summaries).where(
|
|
684
467
|
and(
|
|
685
|
-
|
|
686
|
-
|
|
468
|
+
eq(summaries.mind, mind),
|
|
469
|
+
eq(summaries.period, childPeriod),
|
|
687
470
|
gte(summaries.created_at, start2),
|
|
688
471
|
lt(summaries.created_at, end2)
|
|
689
472
|
)
|
|
@@ -696,8 +479,8 @@ async function gatherChildSummaries(mind, period, periodKey) {
|
|
|
696
479
|
if (period === "day") {
|
|
697
480
|
const rows2 = await db.select({ id: summaries.id, content: summaries.content }).from(summaries).where(
|
|
698
481
|
and(
|
|
699
|
-
|
|
700
|
-
|
|
482
|
+
eq(summaries.mind, mind),
|
|
483
|
+
eq(summaries.period, childPeriod),
|
|
701
484
|
like(summaries.period_key, `${periodKey}%`)
|
|
702
485
|
)
|
|
703
486
|
).orderBy(summaries.period_key);
|
|
@@ -711,8 +494,8 @@ async function gatherChildSummaries(mind, period, periodKey) {
|
|
|
711
494
|
const endKey = end.slice(0, 10);
|
|
712
495
|
const rows = await db.select({ id: summaries.id, content: summaries.content }).from(summaries).where(
|
|
713
496
|
and(
|
|
714
|
-
|
|
715
|
-
|
|
497
|
+
eq(summaries.mind, mind),
|
|
498
|
+
eq(summaries.period, childPeriod),
|
|
716
499
|
gte(summaries.period_key, startKey),
|
|
717
500
|
sql`${summaries.period_key} <= ${endKey}`
|
|
718
501
|
)
|
|
@@ -795,8 +578,8 @@ async function summarizeSystem(period, periodKey) {
|
|
|
795
578
|
const db = await getDb();
|
|
796
579
|
const rows = await db.select({ mind: summaries.mind, content: summaries.content }).from(summaries).where(
|
|
797
580
|
and(
|
|
798
|
-
|
|
799
|
-
|
|
581
|
+
eq(summaries.period, period),
|
|
582
|
+
eq(summaries.period_key, periodKey),
|
|
800
583
|
sql`${summaries.mind} != ${SYSTEM_MIND}`
|
|
801
584
|
)
|
|
802
585
|
).orderBy(summaries.mind);
|
|
@@ -833,7 +616,7 @@ async function mindsWithTurnSummaries(start, end) {
|
|
|
833
616
|
const db = await getDb();
|
|
834
617
|
const rows = await db.select({ mind: summaries.mind }).from(summaries).where(
|
|
835
618
|
and(
|
|
836
|
-
|
|
619
|
+
eq(summaries.period, "turn"),
|
|
837
620
|
gte(summaries.created_at, start),
|
|
838
621
|
lt(summaries.created_at, end),
|
|
839
622
|
sql`${summaries.mind} != ${SYSTEM_MIND}`
|
|
@@ -845,7 +628,7 @@ async function mindsWithSummaries(period, keyPattern) {
|
|
|
845
628
|
const db = await getDb();
|
|
846
629
|
const rows = await db.select({ mind: summaries.mind }).from(summaries).where(
|
|
847
630
|
and(
|
|
848
|
-
|
|
631
|
+
eq(summaries.period, period),
|
|
849
632
|
like(summaries.period_key, keyPattern),
|
|
850
633
|
sql`${summaries.mind} != ${SYSTEM_MIND}`
|
|
851
634
|
)
|
|
@@ -856,7 +639,7 @@ async function mindsWithDailySummariesInRange(startKey, endKey) {
|
|
|
856
639
|
const db = await getDb();
|
|
857
640
|
const rows = await db.select({ mind: summaries.mind }).from(summaries).where(
|
|
858
641
|
and(
|
|
859
|
-
|
|
642
|
+
eq(summaries.period, "day"),
|
|
860
643
|
gte(summaries.period_key, startKey),
|
|
861
644
|
sql`${summaries.period_key} <= ${endKey}`,
|
|
862
645
|
sql`${summaries.mind} != ${SYSTEM_MIND}`
|
|
@@ -924,9 +707,9 @@ async function summaryExists(mind, period, periodKey) {
|
|
|
924
707
|
const db = await getDb();
|
|
925
708
|
const row = await db.select({ id: summaries.id }).from(summaries).where(
|
|
926
709
|
and(
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
710
|
+
eq(summaries.mind, mind),
|
|
711
|
+
eq(summaries.period, period),
|
|
712
|
+
eq(summaries.period_key, periodKey)
|
|
930
713
|
)
|
|
931
714
|
).get();
|
|
932
715
|
return !!row;
|
|
@@ -956,7 +739,7 @@ async function backfill() {
|
|
|
956
739
|
}
|
|
957
740
|
const allKeys = candidates.map((c) => c.key);
|
|
958
741
|
const db = await getDb();
|
|
959
|
-
const existingRows = await db.select({ period: summaries.period, period_key: summaries.period_key }).from(summaries).where(and(
|
|
742
|
+
const existingRows = await db.select({ period: summaries.period, period_key: summaries.period_key }).from(summaries).where(and(eq(summaries.mind, SYSTEM_MIND), inArray(summaries.period_key, allKeys)));
|
|
960
743
|
const existingSet = new Set(existingRows.map((r) => `${r.period}:${r.period_key}`));
|
|
961
744
|
const processFn = {
|
|
962
745
|
hour: processHour,
|
|
@@ -1022,11 +805,11 @@ var Summarizer = class {
|
|
|
1022
805
|
}
|
|
1023
806
|
};
|
|
1024
807
|
async function reconcileWedgedTurns(idleMs) {
|
|
1025
|
-
const { sweepWedgedTurns: sweepWedgedTurns2, summarizeOrphanedTurns: summarizeOrphanedTurns2 } = await import("./turn-tracker-
|
|
808
|
+
const { sweepWedgedTurns: sweepWedgedTurns2, summarizeOrphanedTurns: summarizeOrphanedTurns2 } = await import("./turn-tracker-FOIBNUUA.js");
|
|
1026
809
|
const wedged = await sweepWedgedTurns2(idleMs);
|
|
1027
810
|
if (wedged.length === 0) return;
|
|
1028
811
|
summarizeOrphanedTurns2(wedged);
|
|
1029
|
-
const { tryGetDeliveryManager } = await import("./delivery-manager-
|
|
812
|
+
const { tryGetDeliveryManager } = await import("./delivery-manager-JINZRG2W.js");
|
|
1030
813
|
const dm = tryGetDeliveryManager();
|
|
1031
814
|
if (!dm) return;
|
|
1032
815
|
for (const t of wedged) {
|
|
@@ -1084,10 +867,10 @@ async function linkInboundToActiveTurn(mind, session, channel) {
|
|
|
1084
867
|
const db = await getDb();
|
|
1085
868
|
await db.update(mindHistory).set({ turn_id: turnId }).where(
|
|
1086
869
|
and2(
|
|
1087
|
-
|
|
1088
|
-
|
|
870
|
+
eq2(mindHistory.mind, mind),
|
|
871
|
+
eq2(mindHistory.type, "inbound"),
|
|
1089
872
|
sql2`${mindHistory.turn_id} IS NULL`,
|
|
1090
|
-
|
|
873
|
+
eq2(mindHistory.channel, channel)
|
|
1091
874
|
)
|
|
1092
875
|
);
|
|
1093
876
|
}
|
|
@@ -1118,7 +901,7 @@ async function assignSession(mind, turnId, session) {
|
|
|
1118
901
|
}
|
|
1119
902
|
try {
|
|
1120
903
|
const db = await getDb();
|
|
1121
|
-
await db.update(turns).set({ session }).where(
|
|
904
|
+
await db.update(turns).set({ session }).where(eq2(turns.id, turnId));
|
|
1122
905
|
} catch (err) {
|
|
1123
906
|
tlog.error(`failed to assign session to turn ${turnId}`, logger_default.errorData(err));
|
|
1124
907
|
return;
|
|
@@ -1133,7 +916,7 @@ async function completeTurn(mind, session) {
|
|
|
1133
916
|
if (!entry) return void 0;
|
|
1134
917
|
try {
|
|
1135
918
|
const db = await getDb();
|
|
1136
|
-
await db.update(turns).set({ status: "complete" }).where(
|
|
919
|
+
await db.update(turns).set({ status: "complete" }).where(eq2(turns.id, entry.turnId));
|
|
1137
920
|
} catch (err) {
|
|
1138
921
|
tlog.error(`failed to complete turn ${entry.turnId}`, logger_default.errorData(err));
|
|
1139
922
|
return void 0;
|
|
@@ -1144,10 +927,10 @@ async function completeTurn(mind, session) {
|
|
|
1144
927
|
}
|
|
1145
928
|
async function completeOrphanedTurns() {
|
|
1146
929
|
const db = await getDb();
|
|
1147
|
-
const active = await db.select({ id: turns.id, mind: turns.mind, session: turns.session }).from(turns).where(
|
|
930
|
+
const active = await db.select({ id: turns.id, mind: turns.mind, session: turns.session }).from(turns).where(eq2(turns.status, "active"));
|
|
1148
931
|
if (active.length === 0) return [];
|
|
1149
932
|
try {
|
|
1150
|
-
await db.update(turns).set({ status: "complete" }).where(
|
|
933
|
+
await db.update(turns).set({ status: "complete" }).where(eq2(turns.status, "active"));
|
|
1151
934
|
} catch (err) {
|
|
1152
935
|
tlog.error("failed to complete orphaned turns on startup", logger_default.errorData(err));
|
|
1153
936
|
}
|
|
@@ -1180,7 +963,7 @@ async function clearMind(mind) {
|
|
|
1180
963
|
try {
|
|
1181
964
|
const db = await getDb();
|
|
1182
965
|
for (const { turnId } of orphaned) {
|
|
1183
|
-
await db.update(turns).set({ status: "complete" }).where(
|
|
966
|
+
await db.update(turns).set({ status: "complete" }).where(eq2(turns.id, turnId));
|
|
1184
967
|
}
|
|
1185
968
|
} catch (err) {
|
|
1186
969
|
tlog.error(`failed to complete orphaned turns for ${mind}`, logger_default.errorData(err));
|
|
@@ -1193,7 +976,7 @@ async function sweepWedgedTurns(idleMs) {
|
|
|
1193
976
|
const cutoff = new Date(Date.now() - idleMs).toISOString().slice(0, 19).replace("T", " ");
|
|
1194
977
|
let rows;
|
|
1195
978
|
try {
|
|
1196
|
-
rows = await db.select({ id: turns.id, mind: turns.mind, session: turns.session }).from(turns).innerJoin(mindHistory,
|
|
979
|
+
rows = await db.select({ id: turns.id, mind: turns.mind, session: turns.session }).from(turns).innerJoin(mindHistory, eq2(mindHistory.turn_id, turns.id)).where(eq2(turns.status, "active")).groupBy(turns.id).having(
|
|
1197
980
|
sql2`max(${mindHistory.created_at}) < ${cutoff} and sum(case when ${mindHistory.type} = 'done' then 1 else 0 end) > 0`
|
|
1198
981
|
);
|
|
1199
982
|
} catch (err) {
|
|
@@ -1203,7 +986,7 @@ async function sweepWedgedTurns(idleMs) {
|
|
|
1203
986
|
const swept = [];
|
|
1204
987
|
for (const r of rows) {
|
|
1205
988
|
try {
|
|
1206
|
-
await db.update(turns).set({ status: "complete" }).where(
|
|
989
|
+
await db.update(turns).set({ status: "complete" }).where(eq2(turns.id, r.id));
|
|
1207
990
|
} catch (err) {
|
|
1208
991
|
tlog.error(`failed to complete wedged turn ${r.id}`, logger_default.errorData(err));
|
|
1209
992
|
continue;
|
|
@@ -1224,12 +1007,6 @@ function summarizeOrphanedTurns(orphanedTurns) {
|
|
|
1224
1007
|
}
|
|
1225
1008
|
|
|
1226
1009
|
export {
|
|
1227
|
-
PROMPT_KEYS,
|
|
1228
|
-
PROMPT_DEFAULTS,
|
|
1229
|
-
substitute,
|
|
1230
|
-
getPrompt,
|
|
1231
|
-
getPromptIfCustom,
|
|
1232
|
-
getMindPromptDefaults,
|
|
1233
1010
|
subscribe,
|
|
1234
1011
|
subscribeAll,
|
|
1235
1012
|
publish,
|