@affectively/aeon 1.0.0 → 1.2.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 (62) hide show
  1. package/README.md +10 -0
  2. package/dist/compression/index.cjs +580 -0
  3. package/dist/compression/index.cjs.map +1 -0
  4. package/dist/compression/index.d.cts +189 -0
  5. package/dist/compression/index.d.ts +189 -0
  6. package/dist/compression/index.js +573 -0
  7. package/dist/compression/index.js.map +1 -0
  8. package/dist/core/index.d.cts +70 -5
  9. package/dist/core/index.d.ts +70 -5
  10. package/dist/crypto/index.cjs +100 -0
  11. package/dist/crypto/index.cjs.map +1 -0
  12. package/dist/crypto/index.d.cts +407 -0
  13. package/dist/crypto/index.d.ts +407 -0
  14. package/dist/crypto/index.js +96 -0
  15. package/dist/crypto/index.js.map +1 -0
  16. package/dist/distributed/index.cjs +420 -23
  17. package/dist/distributed/index.cjs.map +1 -1
  18. package/dist/distributed/index.d.cts +901 -2
  19. package/dist/distributed/index.d.ts +901 -2
  20. package/dist/distributed/index.js +420 -23
  21. package/dist/distributed/index.js.map +1 -1
  22. package/dist/index.cjs +1222 -55
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +11 -811
  25. package/dist/index.d.ts +11 -811
  26. package/dist/index.js +1221 -56
  27. package/dist/index.js.map +1 -1
  28. package/dist/offline/index.cjs +419 -0
  29. package/dist/offline/index.cjs.map +1 -0
  30. package/dist/offline/index.d.cts +148 -0
  31. package/dist/offline/index.d.ts +148 -0
  32. package/dist/offline/index.js +415 -0
  33. package/dist/offline/index.js.map +1 -0
  34. package/dist/optimization/index.cjs +797 -0
  35. package/dist/optimization/index.cjs.map +1 -0
  36. package/dist/optimization/index.d.cts +347 -0
  37. package/dist/optimization/index.d.ts +347 -0
  38. package/dist/optimization/index.js +787 -0
  39. package/dist/optimization/index.js.map +1 -0
  40. package/dist/persistence/index.cjs +145 -0
  41. package/dist/persistence/index.cjs.map +1 -0
  42. package/dist/persistence/index.d.cts +63 -0
  43. package/dist/persistence/index.d.ts +63 -0
  44. package/dist/persistence/index.js +142 -0
  45. package/dist/persistence/index.js.map +1 -0
  46. package/dist/presence/index.cjs +489 -0
  47. package/dist/presence/index.cjs.map +1 -0
  48. package/dist/presence/index.d.cts +283 -0
  49. package/dist/presence/index.d.ts +283 -0
  50. package/dist/presence/index.js +485 -0
  51. package/dist/presence/index.js.map +1 -0
  52. package/dist/types-CMxO7QF0.d.cts +33 -0
  53. package/dist/types-CMxO7QF0.d.ts +33 -0
  54. package/dist/versioning/index.cjs +296 -14
  55. package/dist/versioning/index.cjs.map +1 -1
  56. package/dist/versioning/index.d.cts +66 -1
  57. package/dist/versioning/index.d.ts +66 -1
  58. package/dist/versioning/index.js +296 -14
  59. package/dist/versioning/index.js.map +1 -1
  60. package/package.json +51 -1
  61. package/dist/index-C_4CMV5c.d.cts +0 -1207
  62. package/dist/index-C_4CMV5c.d.ts +0 -1207
@@ -0,0 +1,283 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+
3
+ /**
4
+ * Agent Presence Manager (Phase 14)
5
+ *
6
+ * Tracks real-time presence of all agents in a session.
7
+ * Provides status updates, cursor tracking, and activity monitoring.
8
+ */
9
+
10
+ interface AgentPresence {
11
+ agentId: string;
12
+ name: string;
13
+ role: 'user' | 'assistant' | 'monitor' | 'admin';
14
+ status: 'online' | 'away' | 'offline' | 'reconnecting';
15
+ joinedAt: string;
16
+ lastSeen: string;
17
+ cursorPosition?: {
18
+ x: number;
19
+ y: number;
20
+ path: string;
21
+ };
22
+ activeSection?: string;
23
+ focusNode?: string;
24
+ selectionRange?: AgentSelectionRange;
25
+ typingState?: AgentTypingState;
26
+ scrollState?: AgentScrollState;
27
+ viewport?: AgentViewportState;
28
+ inputState?: AgentInputState;
29
+ emotionState?: AgentEmotionState;
30
+ metadata?: Record<string, unknown>;
31
+ }
32
+ interface AgentSelectionRange {
33
+ start: number;
34
+ end: number;
35
+ direction?: 'forward' | 'backward' | 'none';
36
+ path?: string;
37
+ }
38
+ interface AgentTypingState {
39
+ isTyping: boolean;
40
+ field?: string;
41
+ isComposing?: boolean;
42
+ startedAt?: string;
43
+ stoppedAt?: string;
44
+ }
45
+ interface AgentScrollState {
46
+ depth: number;
47
+ y?: number;
48
+ viewportHeight?: number;
49
+ documentHeight?: number;
50
+ path?: string;
51
+ }
52
+ interface AgentViewportState {
53
+ width: number;
54
+ height: number;
55
+ }
56
+ interface AgentInputState {
57
+ field: string;
58
+ hasFocus: boolean;
59
+ valueLength?: number;
60
+ selectionStart?: number;
61
+ selectionEnd?: number;
62
+ isComposing?: boolean;
63
+ inputMode?: string;
64
+ }
65
+ interface AgentEmotionState {
66
+ primary?: string;
67
+ secondary?: string;
68
+ confidence?: number;
69
+ intensity?: number;
70
+ valence?: number;
71
+ arousal?: number;
72
+ dominance?: number;
73
+ source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
74
+ updatedAt?: string;
75
+ }
76
+ interface PresenceUpdate {
77
+ agentId: string;
78
+ changes: Partial<AgentPresence>;
79
+ timestamp: string;
80
+ }
81
+ interface PresenceEvents {
82
+ presence_updated: (data: {
83
+ agentId: string;
84
+ presence: AgentPresence;
85
+ }) => void;
86
+ agent_joined: (data: {
87
+ agentId: string;
88
+ presence: AgentPresence;
89
+ }) => void;
90
+ agent_left: (data: {
91
+ agentId: string;
92
+ presence: AgentPresence;
93
+ }) => void;
94
+ cursor_updated: (data: {
95
+ agentId: string;
96
+ cursorPosition: {
97
+ x: number;
98
+ y: number;
99
+ path: string;
100
+ };
101
+ }) => void;
102
+ section_updated: (data: {
103
+ agentId: string;
104
+ activeSection: string;
105
+ }) => void;
106
+ focus_updated: (data: {
107
+ agentId: string;
108
+ focusNode: string;
109
+ }) => void;
110
+ selection_updated: (data: {
111
+ agentId: string;
112
+ selectionRange: AgentSelectionRange;
113
+ }) => void;
114
+ typing_updated: (data: {
115
+ agentId: string;
116
+ typingState: AgentTypingState;
117
+ }) => void;
118
+ scroll_updated: (data: {
119
+ agentId: string;
120
+ scrollState: AgentScrollState;
121
+ }) => void;
122
+ viewport_updated: (data: {
123
+ agentId: string;
124
+ viewport: AgentViewportState;
125
+ }) => void;
126
+ input_state_updated: (data: {
127
+ agentId: string;
128
+ inputState?: AgentInputState;
129
+ }) => void;
130
+ emotion_updated: (data: {
131
+ agentId: string;
132
+ emotionState?: AgentEmotionState;
133
+ }) => void;
134
+ status_updated: (data: {
135
+ agentId: string;
136
+ status: AgentPresence['status'];
137
+ }) => void;
138
+ }
139
+ declare class AgentPresenceManager extends EventEmitter<PresenceEvents> {
140
+ private presences;
141
+ private sessionId;
142
+ private heartbeatInterval;
143
+ private heartbeatTimeout;
144
+ private inactivityThreshold;
145
+ constructor(sessionId: string);
146
+ /**
147
+ * Add or update agent presence
148
+ */
149
+ updatePresence(agentId: string, presence: Omit<AgentPresence, 'joinedAt' | 'lastSeen'>): void;
150
+ /**
151
+ * Agent joined
152
+ */
153
+ agentJoined(agentId: string, name: string, role?: AgentPresence['role'], metadata?: Record<string, unknown>): void;
154
+ /**
155
+ * Agent left
156
+ */
157
+ agentLeft(agentId: string): void;
158
+ /**
159
+ * Update cursor position
160
+ */
161
+ updateCursor(agentId: string, x: number, y: number, path: string): void;
162
+ /**
163
+ * Update active section
164
+ */
165
+ updateActiveSection(agentId: string, section: string): void;
166
+ /**
167
+ * Update focused node path
168
+ */
169
+ updateFocusNode(agentId: string, nodePath: string): void;
170
+ /**
171
+ * Update text selection range
172
+ */
173
+ updateSelection(agentId: string, selectionRange: AgentSelectionRange): void;
174
+ /**
175
+ * Update typing state
176
+ */
177
+ updateTyping(agentId: string, isTyping: boolean, field?: string, isComposing?: boolean): void;
178
+ /**
179
+ * Update scroll state
180
+ */
181
+ updateScroll(agentId: string, scrollState: AgentScrollState): void;
182
+ /**
183
+ * Update viewport size
184
+ */
185
+ updateViewport(agentId: string, width: number, height: number): void;
186
+ /**
187
+ * Update input state
188
+ */
189
+ updateInputState(agentId: string, inputState: AgentInputState): void;
190
+ /**
191
+ * Clear input state
192
+ */
193
+ clearInputState(agentId: string): void;
194
+ /**
195
+ * Update emotional state
196
+ */
197
+ updateEmotionState(agentId: string, emotionState: Omit<AgentEmotionState, 'updatedAt'>): void;
198
+ /**
199
+ * Clear emotional state
200
+ */
201
+ clearEmotionState(agentId: string): void;
202
+ /**
203
+ * Update status
204
+ */
205
+ updateStatus(agentId: string, status: AgentPresence['status']): void;
206
+ /**
207
+ * Heartbeat from agent (keeps them online)
208
+ */
209
+ heartbeat(agentId: string): void;
210
+ /**
211
+ * Get presence for agent
212
+ */
213
+ getPresence(agentId: string): AgentPresence | undefined;
214
+ /**
215
+ * Get all online agents
216
+ */
217
+ getOnlineAgents(): AgentPresence[];
218
+ /**
219
+ * Get all agents
220
+ */
221
+ getAllAgents(): AgentPresence[];
222
+ /**
223
+ * Get all presences
224
+ */
225
+ getAllPresences(): AgentPresence[];
226
+ /**
227
+ * Get agent count
228
+ */
229
+ getAgentCount(): Record<AgentPresence['status'], number>;
230
+ /**
231
+ * Get statistics
232
+ */
233
+ getStats(): {
234
+ totalAgents: number;
235
+ onlineAgents: number;
236
+ offlineAgents: number;
237
+ awayAgents: number;
238
+ reconnectingAgents: number;
239
+ };
240
+ /**
241
+ * Clear expired presences
242
+ */
243
+ clearExpiredPresences(maxAgeMs: number): void;
244
+ /**
245
+ * Get agents by role
246
+ */
247
+ getByRole(role: AgentPresence['role']): AgentPresence[];
248
+ /**
249
+ * Get agents in active section
250
+ */
251
+ getInSection(section: string): AgentPresence[];
252
+ /**
253
+ * Get presence timeline
254
+ */
255
+ getPresenceStats(): {
256
+ total: number;
257
+ online: number;
258
+ away: number;
259
+ offline: number;
260
+ reconnecting: number;
261
+ byRole: Record<string, number>;
262
+ };
263
+ /**
264
+ * Start heartbeat check (mark inactive agents as away)
265
+ */
266
+ private startHeartbeatCheck;
267
+ /**
268
+ * Stop heartbeat monitoring
269
+ */
270
+ stopHeartbeatMonitoring(): void;
271
+ /**
272
+ * Clear all presences
273
+ */
274
+ clear(): void;
275
+ /**
276
+ * Destroy the manager
277
+ */
278
+ destroy(): void;
279
+ }
280
+ declare function getAgentPresenceManager(sessionId: string): AgentPresenceManager;
281
+ declare function clearAgentPresenceManager(sessionId: string): void;
282
+
283
+ export { type AgentEmotionState, type AgentInputState, type AgentPresence, AgentPresenceManager, type AgentScrollState, type AgentSelectionRange, type AgentTypingState, type AgentViewportState, type PresenceEvents, type PresenceUpdate, clearAgentPresenceManager, getAgentPresenceManager };
@@ -0,0 +1,283 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+
3
+ /**
4
+ * Agent Presence Manager (Phase 14)
5
+ *
6
+ * Tracks real-time presence of all agents in a session.
7
+ * Provides status updates, cursor tracking, and activity monitoring.
8
+ */
9
+
10
+ interface AgentPresence {
11
+ agentId: string;
12
+ name: string;
13
+ role: 'user' | 'assistant' | 'monitor' | 'admin';
14
+ status: 'online' | 'away' | 'offline' | 'reconnecting';
15
+ joinedAt: string;
16
+ lastSeen: string;
17
+ cursorPosition?: {
18
+ x: number;
19
+ y: number;
20
+ path: string;
21
+ };
22
+ activeSection?: string;
23
+ focusNode?: string;
24
+ selectionRange?: AgentSelectionRange;
25
+ typingState?: AgentTypingState;
26
+ scrollState?: AgentScrollState;
27
+ viewport?: AgentViewportState;
28
+ inputState?: AgentInputState;
29
+ emotionState?: AgentEmotionState;
30
+ metadata?: Record<string, unknown>;
31
+ }
32
+ interface AgentSelectionRange {
33
+ start: number;
34
+ end: number;
35
+ direction?: 'forward' | 'backward' | 'none';
36
+ path?: string;
37
+ }
38
+ interface AgentTypingState {
39
+ isTyping: boolean;
40
+ field?: string;
41
+ isComposing?: boolean;
42
+ startedAt?: string;
43
+ stoppedAt?: string;
44
+ }
45
+ interface AgentScrollState {
46
+ depth: number;
47
+ y?: number;
48
+ viewportHeight?: number;
49
+ documentHeight?: number;
50
+ path?: string;
51
+ }
52
+ interface AgentViewportState {
53
+ width: number;
54
+ height: number;
55
+ }
56
+ interface AgentInputState {
57
+ field: string;
58
+ hasFocus: boolean;
59
+ valueLength?: number;
60
+ selectionStart?: number;
61
+ selectionEnd?: number;
62
+ isComposing?: boolean;
63
+ inputMode?: string;
64
+ }
65
+ interface AgentEmotionState {
66
+ primary?: string;
67
+ secondary?: string;
68
+ confidence?: number;
69
+ intensity?: number;
70
+ valence?: number;
71
+ arousal?: number;
72
+ dominance?: number;
73
+ source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
74
+ updatedAt?: string;
75
+ }
76
+ interface PresenceUpdate {
77
+ agentId: string;
78
+ changes: Partial<AgentPresence>;
79
+ timestamp: string;
80
+ }
81
+ interface PresenceEvents {
82
+ presence_updated: (data: {
83
+ agentId: string;
84
+ presence: AgentPresence;
85
+ }) => void;
86
+ agent_joined: (data: {
87
+ agentId: string;
88
+ presence: AgentPresence;
89
+ }) => void;
90
+ agent_left: (data: {
91
+ agentId: string;
92
+ presence: AgentPresence;
93
+ }) => void;
94
+ cursor_updated: (data: {
95
+ agentId: string;
96
+ cursorPosition: {
97
+ x: number;
98
+ y: number;
99
+ path: string;
100
+ };
101
+ }) => void;
102
+ section_updated: (data: {
103
+ agentId: string;
104
+ activeSection: string;
105
+ }) => void;
106
+ focus_updated: (data: {
107
+ agentId: string;
108
+ focusNode: string;
109
+ }) => void;
110
+ selection_updated: (data: {
111
+ agentId: string;
112
+ selectionRange: AgentSelectionRange;
113
+ }) => void;
114
+ typing_updated: (data: {
115
+ agentId: string;
116
+ typingState: AgentTypingState;
117
+ }) => void;
118
+ scroll_updated: (data: {
119
+ agentId: string;
120
+ scrollState: AgentScrollState;
121
+ }) => void;
122
+ viewport_updated: (data: {
123
+ agentId: string;
124
+ viewport: AgentViewportState;
125
+ }) => void;
126
+ input_state_updated: (data: {
127
+ agentId: string;
128
+ inputState?: AgentInputState;
129
+ }) => void;
130
+ emotion_updated: (data: {
131
+ agentId: string;
132
+ emotionState?: AgentEmotionState;
133
+ }) => void;
134
+ status_updated: (data: {
135
+ agentId: string;
136
+ status: AgentPresence['status'];
137
+ }) => void;
138
+ }
139
+ declare class AgentPresenceManager extends EventEmitter<PresenceEvents> {
140
+ private presences;
141
+ private sessionId;
142
+ private heartbeatInterval;
143
+ private heartbeatTimeout;
144
+ private inactivityThreshold;
145
+ constructor(sessionId: string);
146
+ /**
147
+ * Add or update agent presence
148
+ */
149
+ updatePresence(agentId: string, presence: Omit<AgentPresence, 'joinedAt' | 'lastSeen'>): void;
150
+ /**
151
+ * Agent joined
152
+ */
153
+ agentJoined(agentId: string, name: string, role?: AgentPresence['role'], metadata?: Record<string, unknown>): void;
154
+ /**
155
+ * Agent left
156
+ */
157
+ agentLeft(agentId: string): void;
158
+ /**
159
+ * Update cursor position
160
+ */
161
+ updateCursor(agentId: string, x: number, y: number, path: string): void;
162
+ /**
163
+ * Update active section
164
+ */
165
+ updateActiveSection(agentId: string, section: string): void;
166
+ /**
167
+ * Update focused node path
168
+ */
169
+ updateFocusNode(agentId: string, nodePath: string): void;
170
+ /**
171
+ * Update text selection range
172
+ */
173
+ updateSelection(agentId: string, selectionRange: AgentSelectionRange): void;
174
+ /**
175
+ * Update typing state
176
+ */
177
+ updateTyping(agentId: string, isTyping: boolean, field?: string, isComposing?: boolean): void;
178
+ /**
179
+ * Update scroll state
180
+ */
181
+ updateScroll(agentId: string, scrollState: AgentScrollState): void;
182
+ /**
183
+ * Update viewport size
184
+ */
185
+ updateViewport(agentId: string, width: number, height: number): void;
186
+ /**
187
+ * Update input state
188
+ */
189
+ updateInputState(agentId: string, inputState: AgentInputState): void;
190
+ /**
191
+ * Clear input state
192
+ */
193
+ clearInputState(agentId: string): void;
194
+ /**
195
+ * Update emotional state
196
+ */
197
+ updateEmotionState(agentId: string, emotionState: Omit<AgentEmotionState, 'updatedAt'>): void;
198
+ /**
199
+ * Clear emotional state
200
+ */
201
+ clearEmotionState(agentId: string): void;
202
+ /**
203
+ * Update status
204
+ */
205
+ updateStatus(agentId: string, status: AgentPresence['status']): void;
206
+ /**
207
+ * Heartbeat from agent (keeps them online)
208
+ */
209
+ heartbeat(agentId: string): void;
210
+ /**
211
+ * Get presence for agent
212
+ */
213
+ getPresence(agentId: string): AgentPresence | undefined;
214
+ /**
215
+ * Get all online agents
216
+ */
217
+ getOnlineAgents(): AgentPresence[];
218
+ /**
219
+ * Get all agents
220
+ */
221
+ getAllAgents(): AgentPresence[];
222
+ /**
223
+ * Get all presences
224
+ */
225
+ getAllPresences(): AgentPresence[];
226
+ /**
227
+ * Get agent count
228
+ */
229
+ getAgentCount(): Record<AgentPresence['status'], number>;
230
+ /**
231
+ * Get statistics
232
+ */
233
+ getStats(): {
234
+ totalAgents: number;
235
+ onlineAgents: number;
236
+ offlineAgents: number;
237
+ awayAgents: number;
238
+ reconnectingAgents: number;
239
+ };
240
+ /**
241
+ * Clear expired presences
242
+ */
243
+ clearExpiredPresences(maxAgeMs: number): void;
244
+ /**
245
+ * Get agents by role
246
+ */
247
+ getByRole(role: AgentPresence['role']): AgentPresence[];
248
+ /**
249
+ * Get agents in active section
250
+ */
251
+ getInSection(section: string): AgentPresence[];
252
+ /**
253
+ * Get presence timeline
254
+ */
255
+ getPresenceStats(): {
256
+ total: number;
257
+ online: number;
258
+ away: number;
259
+ offline: number;
260
+ reconnecting: number;
261
+ byRole: Record<string, number>;
262
+ };
263
+ /**
264
+ * Start heartbeat check (mark inactive agents as away)
265
+ */
266
+ private startHeartbeatCheck;
267
+ /**
268
+ * Stop heartbeat monitoring
269
+ */
270
+ stopHeartbeatMonitoring(): void;
271
+ /**
272
+ * Clear all presences
273
+ */
274
+ clear(): void;
275
+ /**
276
+ * Destroy the manager
277
+ */
278
+ destroy(): void;
279
+ }
280
+ declare function getAgentPresenceManager(sessionId: string): AgentPresenceManager;
281
+ declare function clearAgentPresenceManager(sessionId: string): void;
282
+
283
+ export { type AgentEmotionState, type AgentInputState, type AgentPresence, AgentPresenceManager, type AgentScrollState, type AgentSelectionRange, type AgentTypingState, type AgentViewportState, type PresenceEvents, type PresenceUpdate, clearAgentPresenceManager, getAgentPresenceManager };