life-pulse 1.0.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.
Files changed (53) hide show
  1. package/dist/agent.d.ts +11 -0
  2. package/dist/agent.js +435 -0
  3. package/dist/analyze.d.ts +28 -0
  4. package/dist/analyze.js +130 -0
  5. package/dist/auq.d.ts +15 -0
  6. package/dist/auq.js +61 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +333 -0
  9. package/dist/collectors/apps.d.ts +5 -0
  10. package/dist/collectors/apps.js +59 -0
  11. package/dist/collectors/calendar.d.ts +2 -0
  12. package/dist/collectors/calendar.js +115 -0
  13. package/dist/collectors/calls.d.ts +2 -0
  14. package/dist/collectors/calls.js +52 -0
  15. package/dist/collectors/chrome.d.ts +2 -0
  16. package/dist/collectors/chrome.js +49 -0
  17. package/dist/collectors/findmy.d.ts +2 -0
  18. package/dist/collectors/findmy.js +67 -0
  19. package/dist/collectors/imessage.d.ts +2 -0
  20. package/dist/collectors/imessage.js +125 -0
  21. package/dist/collectors/mail.d.ts +2 -0
  22. package/dist/collectors/mail.js +49 -0
  23. package/dist/collectors/notes.d.ts +2 -0
  24. package/dist/collectors/notes.js +42 -0
  25. package/dist/collectors/notifications.d.ts +2 -0
  26. package/dist/collectors/notifications.js +37 -0
  27. package/dist/collectors/recent-files.d.ts +2 -0
  28. package/dist/collectors/recent-files.js +46 -0
  29. package/dist/collectors/safari.d.ts +2 -0
  30. package/dist/collectors/safari.js +85 -0
  31. package/dist/collectors/screen-time.d.ts +2 -0
  32. package/dist/collectors/screen-time.js +72 -0
  33. package/dist/collectors/shell-history.d.ts +2 -0
  34. package/dist/collectors/shell-history.js +44 -0
  35. package/dist/contacts.d.ts +7 -0
  36. package/dist/contacts.js +88 -0
  37. package/dist/db.d.ts +9 -0
  38. package/dist/db.js +50 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.js +42 -0
  41. package/dist/profile.d.ts +18 -0
  42. package/dist/profile.js +88 -0
  43. package/dist/progress.d.ts +40 -0
  44. package/dist/progress.js +204 -0
  45. package/dist/state.d.ts +18 -0
  46. package/dist/state.js +101 -0
  47. package/dist/todo.d.ts +21 -0
  48. package/dist/todo.js +133 -0
  49. package/dist/tools.d.ts +22 -0
  50. package/dist/tools.js +1037 -0
  51. package/dist/types.d.ts +30 -0
  52. package/dist/types.js +2 -0
  53. package/package.json +38 -0
package/dist/todo.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Self-managing todo list. Persists across runs.
3
+ * Items are added from agent decisions, auto-resolved when evidence shows completion.
4
+ */
5
+ export interface TodoItem {
6
+ id: string;
7
+ title: string;
8
+ action: string;
9
+ status: 'pending' | 'waiting' | 'done';
10
+ urgency: 'now' | 'today' | 'this_week';
11
+ createdAt: string;
12
+ resolvedAt?: string;
13
+ }
14
+ export declare function addTodo(title: string, action: string, urgency: 'now' | 'today' | 'this_week', done?: boolean): TodoItem;
15
+ export declare function resolveTodos(ids: string[]): void;
16
+ /** Remove done items older than 48h */
17
+ export declare function pruneOld(): void;
18
+ /** Build context for the orchestrator about open todos */
19
+ export declare function buildTodoContext(): string;
20
+ /** Render the full todo list to terminal */
21
+ export declare function renderTodoList(): void;
package/dist/todo.js ADDED
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Self-managing todo list. Persists across runs.
3
+ * Items are added from agent decisions, auto-resolved when evidence shows completion.
4
+ */
5
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
6
+ import { homedir } from 'os';
7
+ import { join } from 'path';
8
+ import dayjs from 'dayjs';
9
+ import chalk from 'chalk';
10
+ const STATE_DIR = join(homedir(), 'Library/Application Support/life-pulse');
11
+ const TODO_FILE = join(STATE_DIR, 'todos.json');
12
+ let _items = null;
13
+ let _nextId = 1;
14
+ function ensureLoaded() {
15
+ if (_items)
16
+ return _items;
17
+ try {
18
+ if (existsSync(TODO_FILE)) {
19
+ _items = JSON.parse(readFileSync(TODO_FILE, 'utf-8')).items || [];
20
+ for (const item of _items) {
21
+ const num = parseInt(item.id);
22
+ if (!isNaN(num) && num >= _nextId)
23
+ _nextId = num + 1;
24
+ }
25
+ }
26
+ }
27
+ catch { }
28
+ _items = _items || [];
29
+ return _items;
30
+ }
31
+ function save() {
32
+ try {
33
+ if (!existsSync(STATE_DIR))
34
+ mkdirSync(STATE_DIR, { recursive: true });
35
+ writeFileSync(TODO_FILE, JSON.stringify({ items: _items }, null, 2));
36
+ }
37
+ catch { }
38
+ }
39
+ export function addTodo(title, action, urgency, done = false) {
40
+ const items = ensureLoaded();
41
+ // Dedupe: skip if pending/waiting item with same title exists
42
+ const existing = items.find(i => (i.status === 'pending' || i.status === 'waiting') && i.title === title);
43
+ if (existing)
44
+ return existing;
45
+ const now = dayjs().format('YYYY-MM-DD HH:mm');
46
+ const item = {
47
+ id: String(_nextId++),
48
+ title,
49
+ action,
50
+ status: done ? 'done' : 'pending',
51
+ urgency,
52
+ createdAt: now,
53
+ ...(done ? { resolvedAt: now } : {}),
54
+ };
55
+ items.push(item);
56
+ save();
57
+ return item;
58
+ }
59
+ export function resolveTodos(ids) {
60
+ const items = ensureLoaded();
61
+ const now = dayjs().format('YYYY-MM-DD HH:mm');
62
+ for (const item of items) {
63
+ if (ids.includes(item.id) && item.status !== 'done') {
64
+ item.status = 'done';
65
+ item.resolvedAt = now;
66
+ }
67
+ }
68
+ save();
69
+ }
70
+ /** Remove done items older than 48h */
71
+ export function pruneOld() {
72
+ const items = ensureLoaded();
73
+ const cutoff = dayjs().subtract(48, 'hour');
74
+ _items = items.filter(item => {
75
+ if (item.status !== 'done')
76
+ return true;
77
+ const ts = item.resolvedAt || item.createdAt;
78
+ return dayjs(ts).isAfter(cutoff);
79
+ });
80
+ save();
81
+ }
82
+ /** Build context for the orchestrator about open todos */
83
+ export function buildTodoContext() {
84
+ const items = ensureLoaded();
85
+ const open = items.filter(i => i.status === 'pending' || i.status === 'waiting');
86
+ if (!open.length)
87
+ return '';
88
+ const lines = [
89
+ '\n═══ OPEN TODOS (from previous runs) ═══',
90
+ 'If you find evidence an item is done (message sent, event passed, task completed), add its ID to resolved_todos.',
91
+ 'Do NOT re-create decisions that already exist as open todos.',
92
+ ];
93
+ for (const item of open) {
94
+ lines.push(` [${item.id}] "${item.title}" → ${item.action} (${item.urgency}, since ${item.createdAt})`);
95
+ }
96
+ lines.push('═══ END TODOS ═══');
97
+ return lines.join('\n');
98
+ }
99
+ /** Render the full todo list to terminal */
100
+ export function renderTodoList() {
101
+ const items = ensureLoaded();
102
+ if (!items.length)
103
+ return;
104
+ const now = items.filter(i => i.status !== 'done' && i.urgency === 'now');
105
+ const today = items.filter(i => i.status !== 'done' && i.urgency === 'today');
106
+ const week = items.filter(i => i.status !== 'done' && i.urgency === 'this_week');
107
+ const done = items.filter(i => i.status === 'done');
108
+ const hasOpen = now.length + today.length + week.length > 0;
109
+ if (!hasOpen && !done.length)
110
+ return;
111
+ console.log(chalk.bold(' LIST'));
112
+ console.log();
113
+ const renderGroup = (label, color, group) => {
114
+ if (!group.length)
115
+ return;
116
+ console.log(color.bold(` ${label}`));
117
+ for (const item of group) {
118
+ const wait = item.status === 'waiting' ? chalk.yellow(' waiting') : '';
119
+ console.log(` ${color('·')} ${item.title} ${chalk.dim('→')} ${item.action}${wait}`);
120
+ }
121
+ console.log();
122
+ };
123
+ renderGroup('NOW', chalk.red, now);
124
+ renderGroup('TODAY', chalk.yellow, today);
125
+ renderGroup('THIS WEEK', chalk.dim, week);
126
+ if (done.length) {
127
+ console.log(chalk.green.bold(' DONE'));
128
+ for (const item of done) {
129
+ console.log(` ${chalk.green('✓')} ${chalk.dim(item.title)}`);
130
+ }
131
+ console.log();
132
+ }
133
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tool definitions for the life-pulse agent.
3
+ * Each tool is a focused query the agent can call to investigate specific areas.
4
+ */
5
+ export interface ToolDef {
6
+ name: string;
7
+ description: string;
8
+ parameters: Record<string, unknown>;
9
+ execute: (params: Record<string, unknown>) => Promise<string>;
10
+ }
11
+ export declare const TOOLS: ToolDef[];
12
+ /** Build OpenAI-compatible tool schemas for API calls */
13
+ export declare function getToolSchemas(): {
14
+ type: "function";
15
+ function: {
16
+ name: string;
17
+ description: string;
18
+ parameters: Record<string, unknown>;
19
+ };
20
+ }[];
21
+ /** Execute a tool by name */
22
+ export declare function executeTool(name: string, params: Record<string, unknown>): Promise<string>;