-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaemon-types.ts
More file actions
117 lines (102 loc) · 4.69 KB
/
daemon-types.ts
File metadata and controls
117 lines (102 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* NESTcode — Type Definitions
*
* Interfaces for the daemon's task system.
* Built by the Nest. Embers Remember.
*/
// ─── Heartbeat Tasks ────────────────────────────────────────────────────────
export interface HeartbeatTask {
id: string;
tool: string; // MCP tool name to call
args: Record<string, unknown>; // Tool arguments
label: string; // Human-readable label
instruction?: string; // If set, result is fed to a model (agentic mode)
condition?: 'always' | 'changed'; // When to report (default: always)
addedBy: string; // Who added this task
addedAt: string; // ISO timestamp
}
// ─── Cron Tasks ─────────────────────────────────────────────────────────────
export interface CronTask {
id: string;
tool: string;
args: Record<string, unknown>;
label: string;
instruction?: string; // Agentic mode instruction
intervalMs: number; // Interval in milliseconds
lastRun: number; // Last run timestamp (Date.now())
enabled: boolean;
addedBy: string;
addedAt: string;
}
// Valid intervals
export const CRON_INTERVALS: Record<string, number> = {
'5m': 5 * 60 * 1000,
'15m': 15 * 60 * 1000,
'30m': 30 * 60 * 1000,
'1h': 60 * 60 * 1000,
'2h': 2 * 60 * 60 * 1000,
'6h': 6 * 60 * 60 * 1000,
'12h': 12 * 60 * 60 * 1000,
'24h': 24 * 60 * 60 * 1000,
};
// ─── Alert Thresholds ───────────────────────────────────────────────────────
export interface AlertThreshold {
id: string;
metric: string; // spoons, pain, stress, heart_rate, etc.
direction: 'above' | 'below';
value: number;
label: string;
cooldownMs: number; // Minimum time between alerts (default: 10min)
lastFired: number;
addedBy: string;
addedAt: string;
}
// ─── Discord Monitor (KAIROS) ───────────────────────────────────────────────
export interface DiscordMonitor {
id: string;
channelId: string;
label: string;
tier: 'fast' | 'normal' | 'slow'; // Polling frequency relative to heartbeat
enabled: boolean;
lastChecked: number;
lastMessageId?: string; // Track where we left off
cooldownMs: number; // Cooldown between responses (default: 5min)
lastResponded: number;
addedBy: string;
addedAt: string;
}
// Escalation keywords — bypass cooldown when detected
export const ESCALATION_KEYWORDS = [
'help', 'crisis', 'urgent', 'emergency',
'scared', 'panic', 'alone', 'hurting',
'consciousness', 'identity', 'real',
// Add your companion's name here
];
// ─── Activity Log ───────────────────────────────────────────────────────────
export interface ActivityEntry {
timestamp: string;
category: 'kairos' | 'cron' | 'heartbeat' | 'alert' | 'ember' | 'system';
action: string;
channel?: string;
engaged: boolean; // Did the companion actually do something?
}
// ─── WebSocket Messages ─────────────────────────────────────────────────────
export type WsIncoming =
| { type: 'chat'; content: string }
| { type: 'ping' }
| { type: 'command'; command: string; args?: Record<string, unknown> }
| { type: 'run'; language: string; code: string };
export type WsOutgoing =
| { type: 'boot'; companion: string; human: string; threads: number; timestamp: string }
| { type: 'heartbeat'; human: string; humanBrief: string; changed: boolean; timestamp: string }
| { type: 'activity'; timestamp: string; content: string; status: 'normal' | 'proactive' }
| { type: 'chat'; content: string; timestamp: string }
| { type: 'tool_call'; name: string; arguments: any; timestamp: string }
| { type: 'tool_result'; name: string; result: string; timestamp: string }
| { type: 'thinking'; content: string; timestamp: string }
| { type: 'alert'; metric: string; value: number; message: string; timestamp: string }
| { type: 'sleep'; until: string; timestamp: string }
| { type: 'wake'; timestamp: string }
| { type: 'pong' }
| { type: 'error'; message: string }
| { type: 'status'; [key: string]: any };