zubo 0.1.21 → 0.1.22
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/migrations/024_personal_features.sql +96 -0
- package/package.json +1 -1
- package/site/docs/index.html +11 -0
- package/site/docs/skills.html +107 -0
- package/site/index.html +9 -1
- package/src/agent/context.ts +3 -3
- package/src/agent/loop.ts +1 -1
- package/src/agent/prompts.ts +42 -1
- package/src/channels/dashboard.html.ts +2 -2
- package/src/channels/webchat.ts +51 -27
- package/src/start.ts +12 -0
- package/src/tools/builtin/follow-ups.ts +189 -0
- package/src/tools/builtin/notes.ts +207 -0
- package/src/tools/builtin/preferences.ts +173 -0
- package/src/tools/builtin/todos.ts +270 -0
- package/src/tools/builtin/topics.ts +166 -0
- package/src/tools/permissions.ts +7 -0
- package/tests/agent/session.test.ts +43 -45
- package/tests/mcp-registry.test.ts +32 -35
- package/tests/personal-features.test.ts +1251 -0
- package/tests/skill-registry.test.ts +1 -7
- package/tests/db/export.test.ts +0 -219
- package/tests/session.test.ts +0 -58
- package/tests/tools/executor.test.ts +0 -150
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
-- Personal agent features: todos, notes, preferences, topics, follow-ups
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS todos (
|
|
4
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
title TEXT NOT NULL,
|
|
6
|
+
description TEXT,
|
|
7
|
+
priority TEXT NOT NULL DEFAULT 'medium' CHECK(priority IN ('low', 'medium', 'high', 'urgent')),
|
|
8
|
+
status TEXT NOT NULL DEFAULT 'pending' CHECK(status IN ('pending', 'in_progress', 'done')),
|
|
9
|
+
due_date TEXT,
|
|
10
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
11
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
12
|
+
completed_at TEXT
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_todos_status ON todos(status);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_todos_priority ON todos(priority);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_todos_due ON todos(due_date);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE IF NOT EXISTS notes (
|
|
20
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
21
|
+
title TEXT NOT NULL,
|
|
22
|
+
content TEXT NOT NULL,
|
|
23
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
24
|
+
pinned INTEGER NOT NULL DEFAULT 0,
|
|
25
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
26
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS notes_fts USING fts5(
|
|
30
|
+
title,
|
|
31
|
+
content,
|
|
32
|
+
tags,
|
|
33
|
+
content='notes',
|
|
34
|
+
content_rowid='id'
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE TRIGGER IF NOT EXISTS notes_ai AFTER INSERT ON notes BEGIN
|
|
38
|
+
INSERT INTO notes_fts(rowid, title, content, tags)
|
|
39
|
+
VALUES (new.id, new.title, new.content, new.tags);
|
|
40
|
+
END;
|
|
41
|
+
|
|
42
|
+
CREATE TRIGGER IF NOT EXISTS notes_ad AFTER DELETE ON notes BEGIN
|
|
43
|
+
INSERT INTO notes_fts(notes_fts, rowid, title, content, tags)
|
|
44
|
+
VALUES ('delete', old.id, old.title, old.content, old.tags);
|
|
45
|
+
END;
|
|
46
|
+
|
|
47
|
+
CREATE TRIGGER IF NOT EXISTS notes_au AFTER UPDATE ON notes BEGIN
|
|
48
|
+
INSERT INTO notes_fts(notes_fts, rowid, title, content, tags)
|
|
49
|
+
VALUES ('delete', old.id, old.title, old.content, old.tags);
|
|
50
|
+
INSERT INTO notes_fts(rowid, title, content, tags)
|
|
51
|
+
VALUES (new.id, new.title, new.content, new.tags);
|
|
52
|
+
END;
|
|
53
|
+
|
|
54
|
+
-- Upgrade user_preferences from migration 008 (simple key/value)
|
|
55
|
+
-- to the expanded schema with category, confidence, source
|
|
56
|
+
CREATE TABLE IF NOT EXISTS _user_preferences_new (
|
|
57
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
58
|
+
category TEXT NOT NULL DEFAULT 'general',
|
|
59
|
+
key TEXT NOT NULL,
|
|
60
|
+
value TEXT NOT NULL,
|
|
61
|
+
confidence REAL NOT NULL DEFAULT 0.8,
|
|
62
|
+
source TEXT NOT NULL DEFAULT 'inferred',
|
|
63
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
64
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
65
|
+
UNIQUE(category, key)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
INSERT OR IGNORE INTO _user_preferences_new (key, value, updated_at)
|
|
69
|
+
SELECT key, value, updated_at FROM user_preferences;
|
|
70
|
+
|
|
71
|
+
DROP TABLE IF EXISTS user_preferences;
|
|
72
|
+
|
|
73
|
+
ALTER TABLE _user_preferences_new RENAME TO user_preferences;
|
|
74
|
+
|
|
75
|
+
CREATE INDEX IF NOT EXISTS idx_prefs_category ON user_preferences(category);
|
|
76
|
+
|
|
77
|
+
CREATE TABLE IF NOT EXISTS conversation_topics (
|
|
78
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
79
|
+
name TEXT NOT NULL UNIQUE,
|
|
80
|
+
description TEXT,
|
|
81
|
+
status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'archived')),
|
|
82
|
+
last_message_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
83
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
CREATE TABLE IF NOT EXISTS follow_ups (
|
|
87
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
88
|
+
context TEXT NOT NULL,
|
|
89
|
+
message TEXT NOT NULL,
|
|
90
|
+
follow_up_at TEXT NOT NULL,
|
|
91
|
+
status TEXT NOT NULL DEFAULT 'pending' CHECK(status IN ('pending', 'sent', 'cancelled')),
|
|
92
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
CREATE INDEX IF NOT EXISTS idx_followups_status ON follow_ups(status);
|
|
96
|
+
CREATE INDEX IF NOT EXISTS idx_followups_time ON follow_ups(follow_up_at);
|
package/package.json
CHANGED
package/site/docs/index.html
CHANGED
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
<a href="/docs/agents">Agents & Workflows</a>
|
|
62
62
|
<a href="/docs/memory">Memory System</a>
|
|
63
63
|
<a href="/docs/skills">Skills</a>
|
|
64
|
+
<a href="/docs/skills#personal-features">Personal Features</a>
|
|
64
65
|
</div>
|
|
65
66
|
</div>
|
|
66
67
|
<div class="docs-sidebar-section">
|
|
@@ -154,6 +155,15 @@
|
|
|
154
155
|
<li><strong>Skill sandboxing</strong> — user-installed skills run in isolated subprocesses with configurable timeouts, preventing runaway code from affecting the main process.</li>
|
|
155
156
|
</ul>
|
|
156
157
|
|
|
158
|
+
<h3>Personal Features</h3>
|
|
159
|
+
<ul>
|
|
160
|
+
<li><strong>Todos</strong> — add, list, complete, update, and remove tasks with priorities (<code>low</code> / <code>medium</code> / <code>high</code>), due dates, and tags. A full task manager inside your agent.</li>
|
|
161
|
+
<li><strong>Notes</strong> — save, search (FTS5), list, update, delete, and pin notes with tags. Fast full-text search across all your notes.</li>
|
|
162
|
+
<li><strong>Preferences</strong> — store user preferences as category/key/value pairs. Preferences are automatically injected into the system prompt so the agent always respects your settings.</li>
|
|
163
|
+
<li><strong>Topics</strong> — create, switch, list, and archive conversation topics. Each topic scopes a separate session, keeping context focused when you juggle multiple projects.</li>
|
|
164
|
+
<li><strong>Follow-ups</strong> — schedule proactive follow-up messages at a specific time or delay. Uses one-shot cron jobs that fire once and auto-delete.</li>
|
|
165
|
+
</ul>
|
|
166
|
+
|
|
157
167
|
<h3>Agents</h3>
|
|
158
168
|
<ul>
|
|
159
169
|
<li><strong>Custom sub-agents</strong> with focused system prompts, restricted tool access, and specialized behavior. Define a “code-reviewer” agent that only has access to file and git tools, or a “researcher” agent that only has web search.</li>
|
|
@@ -640,6 +650,7 @@ zubo start --daemon</code></pre>
|
|
|
640
650
|
<li><a href="/docs/agents"><strong>Agents & Workflows</strong></a> — learn how to create custom sub-agents with focused system prompts and restricted tools, and build multi-agent pipelines with dependency resolution and parallel execution.</li>
|
|
641
651
|
<li><a href="/docs/memory"><strong>Memory System</strong></a> — understand how semantic memory works, how to ingest documents, search your knowledge base, and tune the hybrid search weights.</li>
|
|
642
652
|
<li><a href="/docs/skills"><strong>Skills</strong></a> — write, install, and share single-file TypeScript skills. Learn the skill manifest format, the sandbox environment, and the community registry.</li>
|
|
653
|
+
<li><a href="/docs/skills#personal-features"><strong>Personal Features</strong></a> — built-in tools for todos, notes, preferences, conversation topics, and scheduled follow-ups. Your personal productivity layer, stored locally.</li>
|
|
643
654
|
<li><a href="/docs/channels"><strong>Channel Setup</strong></a> — step-by-step guides for configuring each channel: creating bots, obtaining tokens, setting up webhooks, and configuring allow-lists.</li>
|
|
644
655
|
<li><a href="/docs/conversations"><strong>Conversation History</strong></a> — unified cross-channel history with FTS5 search, dashboard browsing, and API access for searching and analyzing past conversations across all channels.</li>
|
|
645
656
|
<li><a href="/docs/webhooks"><strong>Webhooks</strong></a> — create webhook endpoints for GitHub, Stripe, CI/CD, and any external service. HMAC signature verification, prompt templates with <code>{{payload}}</code> substitution, and dashboard management.</li>
|
package/site/docs/skills.html
CHANGED
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
<a href="/docs/agents">Agents & Workflows</a>
|
|
66
66
|
<a href="/docs/memory">Memory System</a>
|
|
67
67
|
<a href="/docs/skills" class="active">Skills</a>
|
|
68
|
+
<a href="/docs/skills#personal-features">Personal Features</a>
|
|
68
69
|
</div>
|
|
69
70
|
</div>
|
|
70
71
|
<div class="docs-sidebar-section">
|
|
@@ -295,10 +296,116 @@ zubo publish my_skill # Publish your skill to the registry</code></pre>
|
|
|
295
296
|
<tr><td><code>image_generate</code></td><td>Generate images using AI (DALL-E, etc.)</td><td>auto</td></tr>
|
|
296
297
|
<tr><td><code>webhook_manage</code></td><td>Create, list, or remove incoming webhooks</td><td>auto</td></tr>
|
|
297
298
|
<tr><td><code>oauth_manage</code></td><td>Manage OAuth provider connections</td><td>auto</td></tr>
|
|
299
|
+
<tr><td><code>todos</code></td><td>Add, list, complete, update, and remove tasks with priorities, due dates, and tags</td><td>auto</td></tr>
|
|
300
|
+
<tr><td><code>notes</code></td><td>Save, search (FTS5), list, update, delete, and pin notes with tags</td><td>auto</td></tr>
|
|
301
|
+
<tr><td><code>preferences</code></td><td>Set, get, list, and remove user preferences (injected into system prompt)</td><td>auto</td></tr>
|
|
302
|
+
<tr><td><code>topics</code></td><td>Create, switch, list, and archive conversation topics</td><td>auto</td></tr>
|
|
303
|
+
<tr><td><code>follow_ups</code></td><td>Schedule, list, and cancel proactive follow-up messages</td><td>auto</td></tr>
|
|
298
304
|
</tbody>
|
|
299
305
|
</table>
|
|
300
306
|
<p>Tools marked <strong>confirm</strong> require user confirmation before execution. Tools marked <strong>auto</strong> run immediately without prompting.</p>
|
|
301
307
|
|
|
308
|
+
<h2 id="personal-features">Personal Features</h2>
|
|
309
|
+
<p>Built-in tools for personal productivity — todos, notes, preferences, conversation topics, and scheduled follow-ups. These run in the main process (not sandboxed) and store data in your local SQLite database.</p>
|
|
310
|
+
|
|
311
|
+
<h3><code>todos</code></h3>
|
|
312
|
+
<p>A full task manager built into your agent. Add tasks, set priorities and due dates, tag them for organization, and check them off when done.</p>
|
|
313
|
+
<table>
|
|
314
|
+
<thead>
|
|
315
|
+
<tr><th>Action</th><th>Description</th></tr>
|
|
316
|
+
</thead>
|
|
317
|
+
<tbody>
|
|
318
|
+
<tr><td><code>add</code></td><td>Create a new task with an optional priority (<code>low</code>, <code>medium</code>, <code>high</code>), due date, and tags.</td></tr>
|
|
319
|
+
<tr><td><code>list</code></td><td>List tasks, optionally filtered by status, priority, tag, or due date.</td></tr>
|
|
320
|
+
<tr><td><code>complete</code></td><td>Mark a task as done by ID.</td></tr>
|
|
321
|
+
<tr><td><code>update</code></td><td>Update a task's text, priority, due date, or tags.</td></tr>
|
|
322
|
+
<tr><td><code>remove</code></td><td>Delete a task by ID.</td></tr>
|
|
323
|
+
</tbody>
|
|
324
|
+
</table>
|
|
325
|
+
<p><strong>Key parameters:</strong> <code>text</code> (string), <code>priority</code> (<code>"low"</code> | <code>"medium"</code> | <code>"high"</code>), <code>due</code> (date string), <code>tags</code> (comma-separated), <code>id</code> (task ID for update/complete/remove).</p>
|
|
326
|
+
<p><strong>Example:</strong></p>
|
|
327
|
+
<pre><code>"Add a todo: finish the API docs, high priority, due Friday, tag: work"
|
|
328
|
+
"Show my todos tagged work"
|
|
329
|
+
"Complete todo #3"</code></pre>
|
|
330
|
+
|
|
331
|
+
<h3><code>notes</code></h3>
|
|
332
|
+
<p>Save, search, and organize notes with full-text search (FTS5). Pin important notes so they surface first.</p>
|
|
333
|
+
<table>
|
|
334
|
+
<thead>
|
|
335
|
+
<tr><th>Action</th><th>Description</th></tr>
|
|
336
|
+
</thead>
|
|
337
|
+
<tbody>
|
|
338
|
+
<tr><td><code>save</code></td><td>Create a new note with optional title, tags, and pinned status.</td></tr>
|
|
339
|
+
<tr><td><code>search</code></td><td>Full-text search across all notes using FTS5.</td></tr>
|
|
340
|
+
<tr><td><code>list</code></td><td>List all notes, optionally filtered by tag or pinned status.</td></tr>
|
|
341
|
+
<tr><td><code>update</code></td><td>Update a note's content, title, tags, or pinned status.</td></tr>
|
|
342
|
+
<tr><td><code>delete</code></td><td>Delete a note by ID.</td></tr>
|
|
343
|
+
<tr><td><code>pin</code></td><td>Toggle the pinned status of a note.</td></tr>
|
|
344
|
+
</tbody>
|
|
345
|
+
</table>
|
|
346
|
+
<p><strong>Key parameters:</strong> <code>title</code> (string), <code>content</code> (string), <code>tags</code> (comma-separated), <code>pinned</code> (boolean), <code>query</code> (search string), <code>id</code> (note ID).</p>
|
|
347
|
+
<p><strong>Example:</strong></p>
|
|
348
|
+
<pre><code>"Save a note: meeting with design team moved to Thursday 2pm, tag: meetings"
|
|
349
|
+
"Search my notes for API design"
|
|
350
|
+
"Pin note #5"</code></pre>
|
|
351
|
+
|
|
352
|
+
<h3><code>preferences</code></h3>
|
|
353
|
+
<p>Store user preferences as category/key/value pairs. Preferences are automatically injected into the system prompt so the agent always knows your settings.</p>
|
|
354
|
+
<table>
|
|
355
|
+
<thead>
|
|
356
|
+
<tr><th>Action</th><th>Description</th></tr>
|
|
357
|
+
</thead>
|
|
358
|
+
<tbody>
|
|
359
|
+
<tr><td><code>set</code></td><td>Set a preference value for a given category and key.</td></tr>
|
|
360
|
+
<tr><td><code>get</code></td><td>Retrieve a specific preference by category and key.</td></tr>
|
|
361
|
+
<tr><td><code>list</code></td><td>List all preferences, optionally filtered by category.</td></tr>
|
|
362
|
+
<tr><td><code>remove</code></td><td>Delete a preference by category and key.</td></tr>
|
|
363
|
+
</tbody>
|
|
364
|
+
</table>
|
|
365
|
+
<p><strong>Key parameters:</strong> <code>category</code> (string, e.g. <code>"display"</code>, <code>"communication"</code>, <code>"coding"</code>), <code>key</code> (string), <code>value</code> (string).</p>
|
|
366
|
+
<p><strong>Example:</strong></p>
|
|
367
|
+
<pre><code>"Set my preference: coding/language = TypeScript"
|
|
368
|
+
"What are my communication preferences?"
|
|
369
|
+
"Remove preference coding/editor"</code></pre>
|
|
370
|
+
|
|
371
|
+
<h3><code>topics</code></h3>
|
|
372
|
+
<p>Organize conversations into named topics. Each topic scopes a separate session, so context stays focused and you can switch between projects easily.</p>
|
|
373
|
+
<table>
|
|
374
|
+
<thead>
|
|
375
|
+
<tr><th>Action</th><th>Description</th></tr>
|
|
376
|
+
</thead>
|
|
377
|
+
<tbody>
|
|
378
|
+
<tr><td><code>create</code></td><td>Create a new topic with a name and optional description.</td></tr>
|
|
379
|
+
<tr><td><code>switch</code></td><td>Switch the active conversation to a different topic.</td></tr>
|
|
380
|
+
<tr><td><code>list</code></td><td>List all topics, including archived ones.</td></tr>
|
|
381
|
+
<tr><td><code>archive</code></td><td>Archive a topic to keep things tidy without deleting history.</td></tr>
|
|
382
|
+
</tbody>
|
|
383
|
+
</table>
|
|
384
|
+
<p><strong>Key parameters:</strong> <code>name</code> (string), <code>description</code> (string), <code>id</code> (topic ID for switch/archive).</p>
|
|
385
|
+
<p><strong>Example:</strong></p>
|
|
386
|
+
<pre><code>"Create a topic called 'Website Redesign'"
|
|
387
|
+
"Switch to the API project topic"
|
|
388
|
+
"List my topics"
|
|
389
|
+
"Archive the old marketing topic"</code></pre>
|
|
390
|
+
|
|
391
|
+
<h3><code>follow_ups</code></h3>
|
|
392
|
+
<p>Schedule proactive follow-up messages that Zubo sends to you at a specified time. Uses one-shot cron jobs under the hood — the job fires once and auto-deletes.</p>
|
|
393
|
+
<table>
|
|
394
|
+
<thead>
|
|
395
|
+
<tr><th>Action</th><th>Description</th></tr>
|
|
396
|
+
</thead>
|
|
397
|
+
<tbody>
|
|
398
|
+
<tr><td><code>schedule</code></td><td>Schedule a follow-up message for a specific time or delay.</td></tr>
|
|
399
|
+
<tr><td><code>list</code></td><td>List all pending follow-ups.</td></tr>
|
|
400
|
+
<tr><td><code>cancel</code></td><td>Cancel a scheduled follow-up by ID.</td></tr>
|
|
401
|
+
</tbody>
|
|
402
|
+
</table>
|
|
403
|
+
<p><strong>Key parameters:</strong> <code>message</code> (string — what Zubo should say), <code>time</code> (date/time string or natural language like <code>"in 2 hours"</code>, <code>"tomorrow at 9am"</code>), <code>id</code> (follow-up ID for cancel).</p>
|
|
404
|
+
<p><strong>Example:</strong></p>
|
|
405
|
+
<pre><code>"Follow up with me tomorrow at 10am about the deployment"
|
|
406
|
+
"List my pending follow-ups"
|
|
407
|
+
"Cancel follow-up #2"</code></pre>
|
|
408
|
+
|
|
302
409
|
<h2>Legacy Format (SKILL.md)</h2>
|
|
303
410
|
<p>Earlier versions of Zubo used a Markdown-based skill definition file called <code>SKILL.md</code>. This format is still fully supported for backward compatibility:</p>
|
|
304
411
|
<pre><code># weather
|
package/site/index.html
CHANGED
|
@@ -300,7 +300,15 @@
|
|
|
300
300
|
<p>Build your own tools in TypeScript and share them with the community. A sandboxed skill system with scoped secrets, hot-reload, and a public registry.</p>
|
|
301
301
|
</div>
|
|
302
302
|
|
|
303
|
-
<div class="bento-card
|
|
303
|
+
<div class="bento-card tilt-card" data-feature="personal">
|
|
304
|
+
<div class="bento-icon">
|
|
305
|
+
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>
|
|
306
|
+
</div>
|
|
307
|
+
<h3>Personal Features</h3>
|
|
308
|
+
<p>Built-in todos, notes, preferences, conversation topics, and scheduled follow-ups. Your personal productivity layer, stored locally and always in context.</p>
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
<div class="bento-card tilt-card" data-feature="llm">
|
|
304
312
|
<div class="bento-icon">
|
|
305
313
|
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="7.5 4.21 12 6.81 16.5 4.21"/><polyline points="7.5 19.79 7.5 14.6 3 12"/><polyline points="21 12 16.5 14.6 16.5 19.79"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>
|
|
306
314
|
</div>
|
package/src/agent/context.ts
CHANGED
|
@@ -7,12 +7,12 @@ export interface AgentContext {
|
|
|
7
7
|
messages: LlmMessage[];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function assembleContext(
|
|
10
|
+
export async function assembleContext(
|
|
11
11
|
sessionId: string,
|
|
12
12
|
maxTurns: number = 50,
|
|
13
13
|
memories: string = ""
|
|
14
|
-
): AgentContext {
|
|
14
|
+
): Promise<AgentContext> {
|
|
15
15
|
const messages = loadSession(sessionId, maxTurns);
|
|
16
|
-
const system = buildSystemPrompt(memories);
|
|
16
|
+
const system = await buildSystemPrompt(memories);
|
|
17
17
|
return { system, messages };
|
|
18
18
|
}
|
package/src/agent/loop.ts
CHANGED
|
@@ -79,7 +79,7 @@ async function prepareLoop(
|
|
|
79
79
|
// Assemble context (uses static import — no dynamic import overhead)
|
|
80
80
|
const ctx = options.systemPromptOverride
|
|
81
81
|
? { system: options.systemPromptOverride, messages: loadSession(sessionId, 50) }
|
|
82
|
-
: assembleContext(sessionId, 50, fullMemories);
|
|
82
|
+
: await assembleContext(sessionId, 50, fullMemories);
|
|
83
83
|
|
|
84
84
|
const messages = compactMessages(ctx.messages, llm.contextWindow);
|
|
85
85
|
|
package/src/agent/prompts.ts
CHANGED
|
@@ -42,6 +42,25 @@ const DEFAULT_PERSONALITY = `You are Zubo, a personal AI agent. You are friendly
|
|
|
42
42
|
- Use cron_create for recurring tasks. Natural language works: "every weekday at 9am", "every monday at noon".
|
|
43
43
|
- Use reminder_set for one-time reminders: "in 30 minutes", "in 2 hours".
|
|
44
44
|
- When the user says "remind me", "ping me", "follow up" — create a reminder.
|
|
45
|
+
- Use follow_ups to schedule check-ins: "follow up about the dentist tomorrow", "check in about the project in 3 days".
|
|
46
|
+
|
|
47
|
+
## Todos & notes
|
|
48
|
+
|
|
49
|
+
- Use the todos tool when the user asks to track tasks, create to-do lists, or manage action items. "Add buy groceries to my list" → todos with action "add".
|
|
50
|
+
- Use the notes tool to save, search, and organize information. "Save this recipe" → notes with action "save". "Find my notes about React" → notes with action "search".
|
|
51
|
+
- When the user mentions something they need to do, proactively offer to add it as a todo.
|
|
52
|
+
|
|
53
|
+
## Preferences
|
|
54
|
+
|
|
55
|
+
- Use the preferences tool to store and recall user preferences. When the user says "I prefer morning meetings" or "I always use TypeScript" — save it immediately with the preferences tool (action "set").
|
|
56
|
+
- Before making choices on behalf of the user, check their preferences first (action "get" or "list").
|
|
57
|
+
- Preferences persist across sessions and channels. They're different from memory — preferences are structured key-value pairs about how the user likes things done.
|
|
58
|
+
|
|
59
|
+
## Conversation topics
|
|
60
|
+
|
|
61
|
+
- Use the topics tool when the user wants to organize conversations. "Let's start a new thread about the trip" → topics with action "create" then "switch".
|
|
62
|
+
- When switching topics, the conversation context changes. Each topic maintains its own conversation history.
|
|
63
|
+
- List topics to show the user what threads they have going.
|
|
45
64
|
|
|
46
65
|
## Delegation
|
|
47
66
|
|
|
@@ -115,7 +134,7 @@ function loadPersonality(): string {
|
|
|
115
134
|
return DEFAULT_PERSONALITY;
|
|
116
135
|
}
|
|
117
136
|
|
|
118
|
-
export function buildSystemPrompt(memories: string = ""): string {
|
|
137
|
+
export async function buildSystemPrompt(memories: string = ""): Promise<string> {
|
|
119
138
|
const now = new Date().toISOString();
|
|
120
139
|
const personality = loadPersonality();
|
|
121
140
|
|
|
@@ -123,6 +142,28 @@ export function buildSystemPrompt(memories: string = ""): string {
|
|
|
123
142
|
|
|
124
143
|
Current time: ${now}`;
|
|
125
144
|
|
|
145
|
+
// Inject user preferences
|
|
146
|
+
try {
|
|
147
|
+
const { loadPreferencesContext } = await import("../tools/builtin/preferences");
|
|
148
|
+
const prefsContext = await loadPreferencesContext();
|
|
149
|
+
if (prefsContext) {
|
|
150
|
+
prompt += `\n\n${prefsContext}`;
|
|
151
|
+
}
|
|
152
|
+
} catch {
|
|
153
|
+
// preferences module may not be available yet
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Inject active topic
|
|
157
|
+
try {
|
|
158
|
+
const { getActiveTopic } = await import("../tools/builtin/topics");
|
|
159
|
+
const topic = getActiveTopic();
|
|
160
|
+
if (topic) {
|
|
161
|
+
prompt += `\n\nActive conversation topic: "${topic}"`;
|
|
162
|
+
}
|
|
163
|
+
} catch {
|
|
164
|
+
// topics module may not be available yet
|
|
165
|
+
}
|
|
166
|
+
|
|
126
167
|
if (memories) {
|
|
127
168
|
prompt += `\n\n## Relevant memories
|
|
128
169
|
<memory-data>
|
|
@@ -4477,7 +4477,7 @@ function createThread() {
|
|
|
4477
4477
|
function switchThread(id, title) {
|
|
4478
4478
|
activeThreadId = id;
|
|
4479
4479
|
loadThreads();
|
|
4480
|
-
api('/threads/' + id + '/messages').then(function(data) {
|
|
4480
|
+
api('/threads/' + encodeURIComponent(id) + '/messages').then(function(data) {
|
|
4481
4481
|
var msgs = data.messages || [];
|
|
4482
4482
|
clearChatMessages();
|
|
4483
4483
|
if (msgs.length === 0) return;
|
|
@@ -4491,7 +4491,7 @@ function switchThread(id, title) {
|
|
|
4491
4491
|
}
|
|
4492
4492
|
|
|
4493
4493
|
function deleteThread(id) {
|
|
4494
|
-
api('/threads/' + id, { method: 'DELETE' }).then(function() {
|
|
4494
|
+
api('/threads/' + encodeURIComponent(id), { method: 'DELETE' }).then(function() {
|
|
4495
4495
|
if (activeThreadId === id) {
|
|
4496
4496
|
activeThreadId = null;
|
|
4497
4497
|
clearChatMessages();
|
package/src/channels/webchat.ts
CHANGED
|
@@ -18,22 +18,22 @@ function escapeHtml(s: string): string {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** Convert raw error messages to user-friendly messages. Prevents leaking internal details. */
|
|
21
|
-
function friendlyError(err: any): string {
|
|
22
|
-
const msg = err?.message ?? String(err);
|
|
23
|
-
if (msg.includes("401") || msg.includes("Unauthorized") || msg.includes("invalid"))
|
|
24
|
-
return "Authentication failed. Check your API key in Settings > API Keys.";
|
|
25
|
-
if (msg.includes("429") || msg.includes("rate limit"))
|
|
26
|
-
return "Too many messages too quickly. Wait a moment and try again.";
|
|
27
|
-
if (msg.includes("404") || msg.includes("not found"))
|
|
28
|
-
return "The AI model wasn't found. Check your model name in Settings > AI Model.";
|
|
29
|
-
if (msg.includes("ECONNREFUSED") || msg.includes("fetch failed") || msg.includes("Connection refused"))
|
|
30
|
-
return "Can't reach the AI service. Check your internet connection or try again.";
|
|
31
|
-
if (msg.includes("timed out") || msg.includes("timeout"))
|
|
32
|
-
return "The request took too long. The AI service may be busy — try again in a moment.";
|
|
33
|
-
if (msg.includes("context") || msg.includes("too long"))
|
|
34
|
-
return "Your message is too long. Try splitting it into shorter questions.";
|
|
35
|
-
return "Something went wrong. Try again, or check Settings if this keeps happening.";
|
|
36
|
-
}
|
|
21
|
+
function friendlyError(err: any): string {
|
|
22
|
+
const msg = err?.message ?? String(err);
|
|
23
|
+
if (msg.includes("401") || msg.includes("Unauthorized") || msg.includes("invalid"))
|
|
24
|
+
return "Authentication failed. Check your API key in Settings > API Keys.";
|
|
25
|
+
if (msg.includes("429") || msg.includes("rate limit"))
|
|
26
|
+
return "Too many messages too quickly. Wait a moment and try again.";
|
|
27
|
+
if (msg.includes("404") || msg.includes("not found"))
|
|
28
|
+
return "The AI model wasn't found. Check your model name in Settings > AI Model.";
|
|
29
|
+
if (msg.includes("ECONNREFUSED") || msg.includes("fetch failed") || msg.includes("Connection refused"))
|
|
30
|
+
return "Can't reach the AI service. Check your internet connection or try again.";
|
|
31
|
+
if (msg.includes("timed out") || msg.includes("timeout"))
|
|
32
|
+
return "The request took too long. The AI service may be busy — try again in a moment.";
|
|
33
|
+
if (msg.includes("context") || msg.includes("too long"))
|
|
34
|
+
return "Your message is too long. Try splitting it into shorter questions.";
|
|
35
|
+
return "Something went wrong. Try again, or check Settings if this keeps happening.";
|
|
36
|
+
}
|
|
37
37
|
|
|
38
38
|
/** Add security headers to all HTTP responses */
|
|
39
39
|
function addSecurityHeaders(res: Response): Response {
|
|
@@ -1262,9 +1262,9 @@ async function handleDashboardApi(url: URL, req: Request): Promise<Response | nu
|
|
|
1262
1262
|
}
|
|
1263
1263
|
|
|
1264
1264
|
// PUT /api/dashboard/threads/:id — rename thread
|
|
1265
|
-
if (path.match(/^\/threads\/[
|
|
1265
|
+
if (path.match(/^\/threads\/[^/]+$/) && req.method === "PUT") {
|
|
1266
1266
|
return (async () => {
|
|
1267
|
-
const threadId = path.split("/").pop()
|
|
1267
|
+
const threadId = decodeURIComponent(path.split("/").pop()!);
|
|
1268
1268
|
const { title } = await req.json();
|
|
1269
1269
|
const db = getDb();
|
|
1270
1270
|
db.prepare(
|
|
@@ -1275,8 +1275,8 @@ async function handleDashboardApi(url: URL, req: Request): Promise<Response | nu
|
|
|
1275
1275
|
}
|
|
1276
1276
|
|
|
1277
1277
|
// DELETE /api/dashboard/threads/:id — delete thread and session file
|
|
1278
|
-
if (path.match(/^\/threads\/[
|
|
1279
|
-
const threadId = path.split("/").pop()
|
|
1278
|
+
if (path.match(/^\/threads\/[^/]+$/) && req.method === "DELETE") {
|
|
1279
|
+
const threadId = decodeURIComponent(path.split("/").pop()!);
|
|
1280
1280
|
try {
|
|
1281
1281
|
const db = getDb();
|
|
1282
1282
|
db.prepare("DELETE FROM threads WHERE id = ?").run(threadId);
|
|
@@ -1289,21 +1289,45 @@ async function handleDashboardApi(url: URL, req: Request): Promise<Response | nu
|
|
|
1289
1289
|
}
|
|
1290
1290
|
|
|
1291
1291
|
// GET /api/dashboard/threads/:id/messages — get thread messages
|
|
1292
|
-
if (path.match(/^\/threads\/[
|
|
1292
|
+
if (path.match(/^\/threads\/[^/]+\/messages$/) && req.method === "GET") {
|
|
1293
1293
|
return (async () => {
|
|
1294
|
-
const threadId = path.split("/")[2];
|
|
1294
|
+
const threadId = decodeURIComponent(path.split("/")[2]);
|
|
1295
1295
|
const { loadSession } = await import("../agent/session");
|
|
1296
|
-
|
|
1296
|
+
let messages = loadSession(threadId, 100);
|
|
1297
|
+
|
|
1298
|
+
// Fallback: if no session file, load from conversation_messages DB
|
|
1299
|
+
if (messages.length === 0) {
|
|
1300
|
+
try {
|
|
1301
|
+
const db = getDb();
|
|
1302
|
+
const rows = db.query(
|
|
1303
|
+
"SELECT role, content FROM conversation_messages WHERE thread_id = ? ORDER BY timestamp ASC LIMIT 100"
|
|
1304
|
+
).all(threadId) as Array<{ role: string; content: string }>;
|
|
1305
|
+
messages = rows.map(r => ({ role: r.role as "user" | "assistant", content: r.content }));
|
|
1306
|
+
} catch {}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1297
1309
|
return Response.json({ messages });
|
|
1298
1310
|
})() as any;
|
|
1299
1311
|
}
|
|
1300
1312
|
|
|
1301
1313
|
// GET /api/dashboard/threads/:id/export — export thread as markdown
|
|
1302
|
-
if (path.match(/^\/threads\/[
|
|
1314
|
+
if (path.match(/^\/threads\/[^/]+\/export$/) && req.method === "GET") {
|
|
1303
1315
|
return (async () => {
|
|
1304
|
-
const threadId = path.split("/")[2];
|
|
1316
|
+
const threadId = decodeURIComponent(path.split("/")[2]);
|
|
1305
1317
|
const { loadSession } = await import("../agent/session");
|
|
1306
|
-
|
|
1318
|
+
let messages = loadSession(threadId, 1000);
|
|
1319
|
+
|
|
1320
|
+
// Fallback: if no session file, load from conversation_messages DB
|
|
1321
|
+
if (messages.length === 0) {
|
|
1322
|
+
try {
|
|
1323
|
+
const db2 = getDb();
|
|
1324
|
+
const rows = db2.query(
|
|
1325
|
+
"SELECT role, content FROM conversation_messages WHERE thread_id = ? ORDER BY timestamp ASC LIMIT 1000"
|
|
1326
|
+
).all(threadId) as Array<{ role: string; content: string }>;
|
|
1327
|
+
messages = rows.map(r => ({ role: r.role as "user" | "assistant", content: r.content }));
|
|
1328
|
+
} catch {}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1307
1331
|
const db = getDb();
|
|
1308
1332
|
const thread = db.query(
|
|
1309
1333
|
"SELECT title FROM threads WHERE id = ?"
|
|
@@ -2925,7 +2949,7 @@ async function handleRequest(
|
|
|
2925
2949
|
}
|
|
2926
2950
|
|
|
2927
2951
|
// Validate threadId format to prevent path traversal
|
|
2928
|
-
if (body.threadId &&
|
|
2952
|
+
if (body.threadId && (/[\/\\\0]/.test(body.threadId) || body.threadId.includes(".."))) {
|
|
2929
2953
|
return Response.json({ error: "Invalid thread ID" }, { status: 400 });
|
|
2930
2954
|
}
|
|
2931
2955
|
|
package/src/start.ts
CHANGED
|
@@ -26,6 +26,10 @@ import { createRouter, type MessageRouter } from "./channels/router";
|
|
|
26
26
|
import { startHeartbeat } from "./scheduler/heartbeat";
|
|
27
27
|
import { initCronScheduler } from "./scheduler/cron";
|
|
28
28
|
import { initMemory } from "./memory/engine";
|
|
29
|
+
import { registerTodosTool } from "./tools/builtin/todos";
|
|
30
|
+
import { registerNotesTool } from "./tools/builtin/notes";
|
|
31
|
+
import { registerPreferencesTool } from "./tools/builtin/preferences";
|
|
32
|
+
import { registerTopicsTool } from "./tools/builtin/topics";
|
|
29
33
|
import { logger, enableFileLogging } from "./util/logger";
|
|
30
34
|
|
|
31
35
|
function openBrowser(url: string) {
|
|
@@ -227,6 +231,14 @@ export async function startZubo(isDaemon = false) {
|
|
|
227
231
|
const { registerManageTriggersTool } = await import("./tools/builtin/manage-triggers");
|
|
228
232
|
registerManageTriggersTool();
|
|
229
233
|
|
|
234
|
+
// Register personal agent tools
|
|
235
|
+
registerTodosTool();
|
|
236
|
+
registerNotesTool();
|
|
237
|
+
registerPreferencesTool();
|
|
238
|
+
registerTopicsTool();
|
|
239
|
+
const { registerFollowUpsTool } = await import("./tools/builtin/follow-ups");
|
|
240
|
+
registerFollowUpsTool(db, router, config, llm);
|
|
241
|
+
|
|
230
242
|
// Register code interpreter tool
|
|
231
243
|
if (config.codeInterpreter?.enabled !== false) {
|
|
232
244
|
const codeInterpreterHandler = (await import("./tools/builtin-skills/code-interpreter/handler")).default;
|