@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.
- package/README.md +10 -0
- package/dist/compression/index.cjs +580 -0
- package/dist/compression/index.cjs.map +1 -0
- package/dist/compression/index.d.cts +189 -0
- package/dist/compression/index.d.ts +189 -0
- package/dist/compression/index.js +573 -0
- package/dist/compression/index.js.map +1 -0
- package/dist/core/index.d.cts +70 -5
- package/dist/core/index.d.ts +70 -5
- package/dist/crypto/index.cjs +100 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +407 -0
- package/dist/crypto/index.d.ts +407 -0
- package/dist/crypto/index.js +96 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/distributed/index.cjs +420 -23
- package/dist/distributed/index.cjs.map +1 -1
- package/dist/distributed/index.d.cts +901 -2
- package/dist/distributed/index.d.ts +901 -2
- package/dist/distributed/index.js +420 -23
- package/dist/distributed/index.js.map +1 -1
- package/dist/index.cjs +1222 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -811
- package/dist/index.d.ts +11 -811
- package/dist/index.js +1221 -56
- package/dist/index.js.map +1 -1
- package/dist/offline/index.cjs +419 -0
- package/dist/offline/index.cjs.map +1 -0
- package/dist/offline/index.d.cts +148 -0
- package/dist/offline/index.d.ts +148 -0
- package/dist/offline/index.js +415 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/optimization/index.cjs +797 -0
- package/dist/optimization/index.cjs.map +1 -0
- package/dist/optimization/index.d.cts +347 -0
- package/dist/optimization/index.d.ts +347 -0
- package/dist/optimization/index.js +787 -0
- package/dist/optimization/index.js.map +1 -0
- package/dist/persistence/index.cjs +145 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +63 -0
- package/dist/persistence/index.d.ts +63 -0
- package/dist/persistence/index.js +142 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/presence/index.cjs +489 -0
- package/dist/presence/index.cjs.map +1 -0
- package/dist/presence/index.d.cts +283 -0
- package/dist/presence/index.d.ts +283 -0
- package/dist/presence/index.js +485 -0
- package/dist/presence/index.js.map +1 -0
- package/dist/types-CMxO7QF0.d.cts +33 -0
- package/dist/types-CMxO7QF0.d.ts +33 -0
- package/dist/versioning/index.cjs +296 -14
- package/dist/versioning/index.cjs.map +1 -1
- package/dist/versioning/index.d.cts +66 -1
- package/dist/versioning/index.d.ts +66 -1
- package/dist/versioning/index.js +296 -14
- package/dist/versioning/index.js.map +1 -1
- package/package.json +51 -1
- package/dist/index-C_4CMV5c.d.cts +0 -1207
- package/dist/index-C_4CMV5c.d.ts +0 -1207
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
|
|
3
|
+
// src/presence/AgentPresenceManager.ts
|
|
4
|
+
|
|
5
|
+
// src/utils/logger.ts
|
|
6
|
+
var consoleLogger = {
|
|
7
|
+
debug: (...args) => {
|
|
8
|
+
console.debug("[AEON:DEBUG]", ...args);
|
|
9
|
+
},
|
|
10
|
+
info: (...args) => {
|
|
11
|
+
console.info("[AEON:INFO]", ...args);
|
|
12
|
+
},
|
|
13
|
+
warn: (...args) => {
|
|
14
|
+
console.warn("[AEON:WARN]", ...args);
|
|
15
|
+
},
|
|
16
|
+
error: (...args) => {
|
|
17
|
+
console.error("[AEON:ERROR]", ...args);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var currentLogger = consoleLogger;
|
|
21
|
+
function getLogger() {
|
|
22
|
+
return currentLogger;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/presence/AgentPresenceManager.ts
|
|
26
|
+
var logger = getLogger();
|
|
27
|
+
var AgentPresenceManager = class extends EventEmitter {
|
|
28
|
+
presences = /* @__PURE__ */ new Map();
|
|
29
|
+
sessionId;
|
|
30
|
+
heartbeatInterval = null;
|
|
31
|
+
heartbeatTimeout = 3e4;
|
|
32
|
+
inactivityThreshold = 6e4;
|
|
33
|
+
constructor(sessionId) {
|
|
34
|
+
super();
|
|
35
|
+
this.sessionId = sessionId;
|
|
36
|
+
this.startHeartbeatCheck();
|
|
37
|
+
logger.debug("[AgentPresenceManager] Initialized", { sessionId });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Add or update agent presence
|
|
41
|
+
*/
|
|
42
|
+
updatePresence(agentId, presence) {
|
|
43
|
+
const existing = this.presences.get(agentId);
|
|
44
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
45
|
+
const updated = {
|
|
46
|
+
...existing,
|
|
47
|
+
...presence,
|
|
48
|
+
agentId,
|
|
49
|
+
joinedAt: existing?.joinedAt ?? now,
|
|
50
|
+
lastSeen: now
|
|
51
|
+
};
|
|
52
|
+
this.presences.set(agentId, updated);
|
|
53
|
+
this.emit("presence_updated", {
|
|
54
|
+
agentId,
|
|
55
|
+
presence: updated
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Agent joined
|
|
60
|
+
*/
|
|
61
|
+
agentJoined(agentId, name, role = "user", metadata) {
|
|
62
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
63
|
+
const presence = {
|
|
64
|
+
agentId,
|
|
65
|
+
name,
|
|
66
|
+
role,
|
|
67
|
+
status: "online",
|
|
68
|
+
joinedAt: now,
|
|
69
|
+
lastSeen: now,
|
|
70
|
+
metadata
|
|
71
|
+
};
|
|
72
|
+
this.presences.set(agentId, presence);
|
|
73
|
+
this.emit("agent_joined", { agentId, presence });
|
|
74
|
+
logger.debug("[AgentPresenceManager] Agent joined", {
|
|
75
|
+
agentId,
|
|
76
|
+
name,
|
|
77
|
+
role
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Agent left
|
|
82
|
+
*/
|
|
83
|
+
agentLeft(agentId) {
|
|
84
|
+
const presence = this.presences.get(agentId);
|
|
85
|
+
if (presence) {
|
|
86
|
+
presence.status = "offline";
|
|
87
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
88
|
+
this.presences.set(agentId, presence);
|
|
89
|
+
this.emit("agent_left", { agentId, presence });
|
|
90
|
+
logger.debug("[AgentPresenceManager] Agent left", { agentId });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update cursor position
|
|
95
|
+
*/
|
|
96
|
+
updateCursor(agentId, x, y, path) {
|
|
97
|
+
const presence = this.presences.get(agentId);
|
|
98
|
+
if (presence) {
|
|
99
|
+
presence.cursorPosition = { x, y, path };
|
|
100
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
101
|
+
this.presences.set(agentId, presence);
|
|
102
|
+
this.emit("cursor_updated", {
|
|
103
|
+
agentId,
|
|
104
|
+
cursorPosition: presence.cursorPosition
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Update active section
|
|
110
|
+
*/
|
|
111
|
+
updateActiveSection(agentId, section) {
|
|
112
|
+
const presence = this.presences.get(agentId);
|
|
113
|
+
if (presence) {
|
|
114
|
+
presence.activeSection = section;
|
|
115
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
116
|
+
this.presences.set(agentId, presence);
|
|
117
|
+
this.emit("section_updated", {
|
|
118
|
+
agentId,
|
|
119
|
+
activeSection: section
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Update focused node path
|
|
125
|
+
*/
|
|
126
|
+
updateFocusNode(agentId, nodePath) {
|
|
127
|
+
const presence = this.presences.get(agentId);
|
|
128
|
+
if (presence) {
|
|
129
|
+
presence.focusNode = nodePath;
|
|
130
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
131
|
+
this.presences.set(agentId, presence);
|
|
132
|
+
this.emit("focus_updated", {
|
|
133
|
+
agentId,
|
|
134
|
+
focusNode: nodePath
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Update text selection range
|
|
140
|
+
*/
|
|
141
|
+
updateSelection(agentId, selectionRange) {
|
|
142
|
+
const presence = this.presences.get(agentId);
|
|
143
|
+
if (presence) {
|
|
144
|
+
presence.selectionRange = selectionRange;
|
|
145
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
146
|
+
this.presences.set(agentId, presence);
|
|
147
|
+
this.emit("selection_updated", {
|
|
148
|
+
agentId,
|
|
149
|
+
selectionRange
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Update typing state
|
|
155
|
+
*/
|
|
156
|
+
updateTyping(agentId, isTyping, field, isComposing = false) {
|
|
157
|
+
const presence = this.presences.get(agentId);
|
|
158
|
+
if (presence) {
|
|
159
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
160
|
+
const previous = presence.typingState;
|
|
161
|
+
const typingState = {
|
|
162
|
+
isTyping,
|
|
163
|
+
field,
|
|
164
|
+
isComposing,
|
|
165
|
+
startedAt: isTyping && !previous?.isTyping ? now : isTyping ? previous?.startedAt : void 0,
|
|
166
|
+
stoppedAt: isTyping ? void 0 : now
|
|
167
|
+
};
|
|
168
|
+
presence.typingState = typingState;
|
|
169
|
+
presence.lastSeen = now;
|
|
170
|
+
this.presences.set(agentId, presence);
|
|
171
|
+
this.emit("typing_updated", {
|
|
172
|
+
agentId,
|
|
173
|
+
typingState
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Update scroll state
|
|
179
|
+
*/
|
|
180
|
+
updateScroll(agentId, scrollState) {
|
|
181
|
+
const presence = this.presences.get(agentId);
|
|
182
|
+
if (presence) {
|
|
183
|
+
presence.scrollState = {
|
|
184
|
+
...scrollState,
|
|
185
|
+
depth: Math.max(0, Math.min(1, scrollState.depth))
|
|
186
|
+
};
|
|
187
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
188
|
+
this.presences.set(agentId, presence);
|
|
189
|
+
this.emit("scroll_updated", {
|
|
190
|
+
agentId,
|
|
191
|
+
scrollState: presence.scrollState
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Update viewport size
|
|
197
|
+
*/
|
|
198
|
+
updateViewport(agentId, width, height) {
|
|
199
|
+
const presence = this.presences.get(agentId);
|
|
200
|
+
if (presence) {
|
|
201
|
+
presence.viewport = { width, height };
|
|
202
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
203
|
+
this.presences.set(agentId, presence);
|
|
204
|
+
this.emit("viewport_updated", {
|
|
205
|
+
agentId,
|
|
206
|
+
viewport: presence.viewport
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Update input state
|
|
212
|
+
*/
|
|
213
|
+
updateInputState(agentId, inputState) {
|
|
214
|
+
const presence = this.presences.get(agentId);
|
|
215
|
+
if (presence) {
|
|
216
|
+
presence.inputState = inputState;
|
|
217
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
218
|
+
this.presences.set(agentId, presence);
|
|
219
|
+
this.emit("input_state_updated", {
|
|
220
|
+
agentId,
|
|
221
|
+
inputState
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Clear input state
|
|
227
|
+
*/
|
|
228
|
+
clearInputState(agentId) {
|
|
229
|
+
const presence = this.presences.get(agentId);
|
|
230
|
+
if (presence) {
|
|
231
|
+
presence.inputState = void 0;
|
|
232
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
233
|
+
this.presences.set(agentId, presence);
|
|
234
|
+
this.emit("input_state_updated", {
|
|
235
|
+
agentId,
|
|
236
|
+
inputState: void 0
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Update emotional state
|
|
242
|
+
*/
|
|
243
|
+
updateEmotionState(agentId, emotionState) {
|
|
244
|
+
const presence = this.presences.get(agentId);
|
|
245
|
+
if (presence) {
|
|
246
|
+
const enrichedState = {
|
|
247
|
+
...emotionState,
|
|
248
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
};
|
|
250
|
+
presence.emotionState = enrichedState;
|
|
251
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
252
|
+
this.presences.set(agentId, presence);
|
|
253
|
+
this.emit("emotion_updated", {
|
|
254
|
+
agentId,
|
|
255
|
+
emotionState: enrichedState
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Clear emotional state
|
|
261
|
+
*/
|
|
262
|
+
clearEmotionState(agentId) {
|
|
263
|
+
const presence = this.presences.get(agentId);
|
|
264
|
+
if (presence) {
|
|
265
|
+
presence.emotionState = void 0;
|
|
266
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
267
|
+
this.presences.set(agentId, presence);
|
|
268
|
+
this.emit("emotion_updated", {
|
|
269
|
+
agentId,
|
|
270
|
+
emotionState: void 0
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Update status
|
|
276
|
+
*/
|
|
277
|
+
updateStatus(agentId, status) {
|
|
278
|
+
const presence = this.presences.get(agentId);
|
|
279
|
+
if (presence) {
|
|
280
|
+
presence.status = status;
|
|
281
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
282
|
+
this.presences.set(agentId, presence);
|
|
283
|
+
this.emit("status_updated", { agentId, status });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Heartbeat from agent (keeps them online)
|
|
288
|
+
*/
|
|
289
|
+
heartbeat(agentId) {
|
|
290
|
+
const presence = this.presences.get(agentId);
|
|
291
|
+
if (presence) {
|
|
292
|
+
if (presence.status === "reconnecting") {
|
|
293
|
+
presence.status = "online";
|
|
294
|
+
this.emit("status_updated", { agentId, status: "online" });
|
|
295
|
+
}
|
|
296
|
+
presence.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
|
|
297
|
+
this.presences.set(agentId, presence);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get presence for agent
|
|
302
|
+
*/
|
|
303
|
+
getPresence(agentId) {
|
|
304
|
+
return this.presences.get(agentId);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get all online agents
|
|
308
|
+
*/
|
|
309
|
+
getOnlineAgents() {
|
|
310
|
+
return Array.from(this.presences.values()).filter(
|
|
311
|
+
(p) => p.status === "online"
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get all agents
|
|
316
|
+
*/
|
|
317
|
+
getAllAgents() {
|
|
318
|
+
return Array.from(this.presences.values());
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get all presences
|
|
322
|
+
*/
|
|
323
|
+
getAllPresences() {
|
|
324
|
+
return Array.from(this.presences.values());
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get agent count
|
|
328
|
+
*/
|
|
329
|
+
getAgentCount() {
|
|
330
|
+
const counts = {
|
|
331
|
+
online: 0,
|
|
332
|
+
away: 0,
|
|
333
|
+
offline: 0,
|
|
334
|
+
reconnecting: 0
|
|
335
|
+
};
|
|
336
|
+
this.presences.forEach((p) => {
|
|
337
|
+
counts[p.status]++;
|
|
338
|
+
});
|
|
339
|
+
return counts;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Get statistics
|
|
343
|
+
*/
|
|
344
|
+
getStats() {
|
|
345
|
+
return {
|
|
346
|
+
totalAgents: this.presences.size,
|
|
347
|
+
onlineAgents: Array.from(this.presences.values()).filter(
|
|
348
|
+
(p) => p.status === "online"
|
|
349
|
+
).length,
|
|
350
|
+
offlineAgents: Array.from(this.presences.values()).filter(
|
|
351
|
+
(p) => p.status === "offline"
|
|
352
|
+
).length,
|
|
353
|
+
awayAgents: Array.from(this.presences.values()).filter(
|
|
354
|
+
(p) => p.status === "away"
|
|
355
|
+
).length,
|
|
356
|
+
reconnectingAgents: Array.from(this.presences.values()).filter(
|
|
357
|
+
(p) => p.status === "reconnecting"
|
|
358
|
+
).length
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Clear expired presences
|
|
363
|
+
*/
|
|
364
|
+
clearExpiredPresences(maxAgeMs) {
|
|
365
|
+
const now = Date.now();
|
|
366
|
+
const toRemove = [];
|
|
367
|
+
this.presences.forEach((presence, agentId) => {
|
|
368
|
+
const lastSeenTime = new Date(presence.lastSeen).getTime();
|
|
369
|
+
const ageMs = now - lastSeenTime;
|
|
370
|
+
if (ageMs > maxAgeMs && presence.status === "offline") {
|
|
371
|
+
toRemove.push(agentId);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
toRemove.forEach((agentId) => {
|
|
375
|
+
this.presences.delete(agentId);
|
|
376
|
+
});
|
|
377
|
+
if (toRemove.length > 0) {
|
|
378
|
+
logger.debug("[AgentPresenceManager] Cleared expired presences", {
|
|
379
|
+
count: toRemove.length
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get agents by role
|
|
385
|
+
*/
|
|
386
|
+
getByRole(role) {
|
|
387
|
+
return Array.from(this.presences.values()).filter((p) => p.role === role);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get agents in active section
|
|
391
|
+
*/
|
|
392
|
+
getInSection(section) {
|
|
393
|
+
return Array.from(this.presences.values()).filter(
|
|
394
|
+
(p) => p.activeSection === section && p.status === "online"
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get presence timeline
|
|
399
|
+
*/
|
|
400
|
+
getPresenceStats() {
|
|
401
|
+
const stats = {
|
|
402
|
+
total: this.presences.size,
|
|
403
|
+
online: 0,
|
|
404
|
+
away: 0,
|
|
405
|
+
offline: 0,
|
|
406
|
+
reconnecting: 0,
|
|
407
|
+
byRole: {}
|
|
408
|
+
};
|
|
409
|
+
this.presences.forEach((p) => {
|
|
410
|
+
stats[p.status]++;
|
|
411
|
+
stats.byRole[p.role] = (stats.byRole[p.role] ?? 0) + 1;
|
|
412
|
+
});
|
|
413
|
+
return stats;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Start heartbeat check (mark inactive agents as away)
|
|
417
|
+
*/
|
|
418
|
+
startHeartbeatCheck() {
|
|
419
|
+
this.heartbeatInterval = setInterval(() => {
|
|
420
|
+
const now = Date.now();
|
|
421
|
+
this.presences.forEach((presence) => {
|
|
422
|
+
const lastSeenTime = new Date(presence.lastSeen).getTime();
|
|
423
|
+
const timeSinceLastSeen = now - lastSeenTime;
|
|
424
|
+
if (timeSinceLastSeen > this.inactivityThreshold && presence.status === "online") {
|
|
425
|
+
presence.status = "away";
|
|
426
|
+
this.emit("status_updated", {
|
|
427
|
+
agentId: presence.agentId,
|
|
428
|
+
status: "away"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
if (timeSinceLastSeen > this.heartbeatTimeout && presence.status !== "offline") {
|
|
432
|
+
presence.status = "reconnecting";
|
|
433
|
+
this.emit("status_updated", {
|
|
434
|
+
agentId: presence.agentId,
|
|
435
|
+
status: "reconnecting"
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}, 1e4);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Stop heartbeat monitoring
|
|
443
|
+
*/
|
|
444
|
+
stopHeartbeatMonitoring() {
|
|
445
|
+
if (this.heartbeatInterval) {
|
|
446
|
+
clearInterval(this.heartbeatInterval);
|
|
447
|
+
this.heartbeatInterval = null;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Clear all presences
|
|
452
|
+
*/
|
|
453
|
+
clear() {
|
|
454
|
+
this.presences.clear();
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Destroy the manager
|
|
458
|
+
*/
|
|
459
|
+
destroy() {
|
|
460
|
+
this.stopHeartbeatMonitoring();
|
|
461
|
+
this.presences.clear();
|
|
462
|
+
this.removeAllListeners();
|
|
463
|
+
logger.debug("[AgentPresenceManager] Destroyed", {
|
|
464
|
+
sessionId: this.sessionId
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
var instances = /* @__PURE__ */ new Map();
|
|
469
|
+
function getAgentPresenceManager(sessionId) {
|
|
470
|
+
if (!instances.has(sessionId)) {
|
|
471
|
+
instances.set(sessionId, new AgentPresenceManager(sessionId));
|
|
472
|
+
}
|
|
473
|
+
return instances.get(sessionId);
|
|
474
|
+
}
|
|
475
|
+
function clearAgentPresenceManager(sessionId) {
|
|
476
|
+
const instance = instances.get(sessionId);
|
|
477
|
+
if (instance) {
|
|
478
|
+
instance.destroy();
|
|
479
|
+
instances.delete(sessionId);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export { AgentPresenceManager, clearAgentPresenceManager, getAgentPresenceManager };
|
|
484
|
+
//# sourceMappingURL=index.js.map
|
|
485
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/presence/AgentPresenceManager.ts"],"names":[],"mappings":";;;;;AAoBA,IAAM,aAAA,GAAwB;AAAA,EAC5B,KAAA,EAAO,IAAI,IAAA,KAAoB;AAE7B,IAAA,OAAA,CAAQ,KAAA,CAAM,cAAA,EAAgB,GAAG,IAAI,CAAA;AAAA,EACvC,CAAA;AAAA,EACA,IAAA,EAAM,IAAI,IAAA,K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,CAAO,MAAM,kCAAA,EAAoC;AAAA,MAC/C,WAAW,IAAA,CAAK;AAAA,KACjB,CAAA;AAAA,EACH;AACF;AAMA,IAAM,SAAA,uBAAgB,GAAA,EAAkC;AAEjD,SAAS,wBACd,SAAA,EACsB;AACtB,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,SAAS,CAAA,EAAG;AAC7B,IAAA,SAAA,CAAU,GAAA,CAAI,SAAA,EAAW,IAAI,oBAAA,CAAqB,SAAS,CAAC,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,SAAA,CAAU,IAAI,SAAS,CAAA;AAChC;AAEO,SAAS,0BAA0B,SAAA,EAAyB;AACjE,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,GAAA,CAAI,SAAS,CAAA;AACxC,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,IAAA,SAAA,CAAU,OAAO,SAAS,CAAA;AAAA,EAC5B;AACF","file":"index.js","sourcesContent":["/**\n * Aeon Logger Interface\n *\n * Provides a pluggable logging interface that can be configured\n * by consumers to integrate with their preferred logging solution.\n */\n\n/**\n * Logger interface that consumers can implement\n */\nexport interface Logger {\n debug: (...args: unknown[]) => void;\n info: (...args: unknown[]) => void;\n warn: (...args: unknown[]) => void;\n error: (...args: unknown[]) => void;\n}\n\n/**\n * Default console logger implementation\n */\nconst consoleLogger: Logger = {\n debug: (...args: unknown[]) => {\n // eslint-disable-next-line no-console\n console.debug('[AEON:DEBUG]', ...args);\n },\n info: (...args: unknown[]) => {\n // eslint-disable-next-line no-console\n console.info('[AEON:INFO]', ...args);\n },\n warn: (...args: unknown[]) => {\n // eslint-disable-next-line no-console\n console.warn('[AEON:WARN]', ...args);\n },\n error: (...args: unknown[]) => {\n // eslint-disable-next-line no-console\n console.error('[AEON:ERROR]', ...args);\n },\n};\n\n/**\n * No-op logger for production or when logging is disabled\n */\nconst noopLogger: Logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n};\n\n/**\n * Current logger instance\n */\nlet currentLogger: Logger = consoleLogger;\n\n/**\n * Get the current logger instance\n */\nexport function getLogger(): Logger {\n return currentLogger;\n}\n\n/**\n * Set a custom logger implementation\n */\nexport function setLogger(logger: Logger): void {\n currentLogger = logger;\n}\n\n/**\n * Reset to the default console logger\n */\nexport function resetLogger(): void {\n currentLogger = consoleLogger;\n}\n\n/**\n * Disable all logging\n */\nexport function disableLogging(): void {\n currentLogger = noopLogger;\n}\n\n/**\n * Create a namespaced logger\n */\nexport function createNamespacedLogger(namespace: string): Logger {\n const logger = getLogger();\n return {\n debug: (...args: unknown[]) => logger.debug(`[${namespace}]`, ...args),\n info: (...args: unknown[]) => logger.info(`[${namespace}]`, ...args),\n warn: (...args: unknown[]) => logger.warn(`[${namespace}]`, ...args),\n error: (...args: unknown[]) => logger.error(`[${namespace}]`, ...args),\n };\n}\n\n// Export default logger for convenience\nexport const logger: Logger = {\n debug: (...args: unknown[]) => getLogger().debug(...args),\n info: (...args: unknown[]) => getLogger().info(...args),\n warn: (...args: unknown[]) => getLogger().warn(...args),\n error: (...args: unknown[]) => getLogger().error(...args),\n};\n","/**\n * Agent Presence Manager (Phase 14)\n *\n * Tracks real-time presence of all agents in a session.\n * Provides status updates, cursor tracking, and activity monitoring.\n */\n\nimport { EventEmitter } from 'eventemitter3';\nimport { getLogger } from '../utils/logger';\n\nconst logger = getLogger();\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AgentPresence {\n agentId: string;\n name: string;\n role: 'user' | 'assistant' | 'monitor' | 'admin';\n status: 'online' | 'away' | 'offline' | 'reconnecting';\n joinedAt: string;\n lastSeen: string;\n cursorPosition?: { x: number; y: number; path: string };\n activeSection?: string;\n focusNode?: string;\n selectionRange?: AgentSelectionRange;\n typingState?: AgentTypingState;\n scrollState?: AgentScrollState;\n viewport?: AgentViewportState;\n inputState?: AgentInputState;\n emotionState?: AgentEmotionState;\n metadata?: Record<string, unknown>;\n}\n\nexport interface AgentSelectionRange {\n start: number;\n end: number;\n direction?: 'forward' | 'backward' | 'none';\n path?: string;\n}\n\nexport interface AgentTypingState {\n isTyping: boolean;\n field?: string;\n isComposing?: boolean;\n startedAt?: string;\n stoppedAt?: string;\n}\n\nexport interface AgentScrollState {\n depth: number;\n y?: number;\n viewportHeight?: number;\n documentHeight?: number;\n path?: string;\n}\n\nexport interface AgentViewportState {\n width: number;\n height: number;\n}\n\nexport interface AgentInputState {\n field: string;\n hasFocus: boolean;\n valueLength?: number;\n selectionStart?: number;\n selectionEnd?: number;\n isComposing?: boolean;\n inputMode?: string;\n}\n\nexport interface AgentEmotionState {\n primary?: string;\n secondary?: string;\n confidence?: number;\n intensity?: number;\n valence?: number;\n arousal?: number;\n dominance?: number;\n source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';\n updatedAt?: string;\n}\n\nexport interface PresenceUpdate {\n agentId: string;\n changes: Partial<AgentPresence>;\n timestamp: string;\n}\n\nexport interface PresenceEvents {\n presence_updated: (data: {\n agentId: string;\n presence: AgentPresence;\n }) => void;\n agent_joined: (data: { agentId: string; presence: AgentPresence }) => void;\n agent_left: (data: { agentId: string; presence: AgentPresence }) => void;\n cursor_updated: (data: {\n agentId: string;\n cursorPosition: { x: number; y: number; path: string };\n }) => void;\n section_updated: (data: { agentId: string; activeSection: string }) => void;\n focus_updated: (data: { agentId: string; focusNode: string }) => void;\n selection_updated: (data: {\n agentId: string;\n selectionRange: AgentSelectionRange;\n }) => void;\n typing_updated: (data: {\n agentId: string;\n typingState: AgentTypingState;\n }) => void;\n scroll_updated: (data: {\n agentId: string;\n scrollState: AgentScrollState;\n }) => void;\n viewport_updated: (data: {\n agentId: string;\n viewport: AgentViewportState;\n }) => void;\n input_state_updated: (data: {\n agentId: string;\n inputState?: AgentInputState;\n }) => void;\n emotion_updated: (data: {\n agentId: string;\n emotionState?: AgentEmotionState;\n }) => void;\n status_updated: (data: {\n agentId: string;\n status: AgentPresence['status'];\n }) => void;\n}\n\n// ============================================================================\n// Agent Presence Manager\n// ============================================================================\n\nexport class AgentPresenceManager extends EventEmitter<PresenceEvents> {\n private presences: Map<string, AgentPresence> = new Map();\n private sessionId: string;\n private heartbeatInterval: ReturnType<typeof setInterval> | null = null;\n private heartbeatTimeout = 30000;\n private inactivityThreshold = 60000;\n\n constructor(sessionId: string) {\n super();\n this.sessionId = sessionId;\n this.startHeartbeatCheck();\n logger.debug('[AgentPresenceManager] Initialized', { sessionId });\n }\n\n /**\n * Add or update agent presence\n */\n updatePresence(\n agentId: string,\n presence: Omit<AgentPresence, 'joinedAt' | 'lastSeen'>,\n ): void {\n const existing = this.presences.get(agentId);\n const now = new Date().toISOString();\n\n const updated: AgentPresence = {\n ...existing,\n ...presence,\n agentId,\n joinedAt: existing?.joinedAt ?? now,\n lastSeen: now,\n };\n\n this.presences.set(agentId, updated);\n\n this.emit('presence_updated', {\n agentId,\n presence: updated,\n });\n }\n\n /**\n * Agent joined\n */\n agentJoined(\n agentId: string,\n name: string,\n role: AgentPresence['role'] = 'user',\n metadata?: Record<string, unknown>,\n ): void {\n const now = new Date().toISOString();\n\n const presence: AgentPresence = {\n agentId,\n name,\n role,\n status: 'online',\n joinedAt: now,\n lastSeen: now,\n metadata,\n };\n\n this.presences.set(agentId, presence);\n this.emit('agent_joined', { agentId, presence });\n\n logger.debug('[AgentPresenceManager] Agent joined', {\n agentId,\n name,\n role,\n });\n }\n\n /**\n * Agent left\n */\n agentLeft(agentId: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.status = 'offline';\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('agent_left', { agentId, presence });\n\n logger.debug('[AgentPresenceManager] Agent left', { agentId });\n }\n }\n\n /**\n * Update cursor position\n */\n updateCursor(agentId: string, x: number, y: number, path: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.cursorPosition = { x, y, path };\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('cursor_updated', {\n agentId,\n cursorPosition: presence.cursorPosition,\n });\n }\n }\n\n /**\n * Update active section\n */\n updateActiveSection(agentId: string, section: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.activeSection = section;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('section_updated', {\n agentId,\n activeSection: section,\n });\n }\n }\n\n /**\n * Update focused node path\n */\n updateFocusNode(agentId: string, nodePath: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.focusNode = nodePath;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('focus_updated', {\n agentId,\n focusNode: nodePath,\n });\n }\n }\n\n /**\n * Update text selection range\n */\n updateSelection(agentId: string, selectionRange: AgentSelectionRange): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.selectionRange = selectionRange;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('selection_updated', {\n agentId,\n selectionRange,\n });\n }\n }\n\n /**\n * Update typing state\n */\n updateTyping(\n agentId: string,\n isTyping: boolean,\n field?: string,\n isComposing = false,\n ): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n const now = new Date().toISOString();\n const previous = presence.typingState;\n const typingState: AgentTypingState = {\n isTyping,\n field,\n isComposing,\n startedAt:\n isTyping && !previous?.isTyping\n ? now\n : isTyping\n ? previous?.startedAt\n : undefined,\n stoppedAt: isTyping ? undefined : now,\n };\n\n presence.typingState = typingState;\n presence.lastSeen = now;\n\n this.presences.set(agentId, presence);\n this.emit('typing_updated', {\n agentId,\n typingState,\n });\n }\n }\n\n /**\n * Update scroll state\n */\n updateScroll(agentId: string, scrollState: AgentScrollState): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.scrollState = {\n ...scrollState,\n depth: Math.max(0, Math.min(1, scrollState.depth)),\n };\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('scroll_updated', {\n agentId,\n scrollState: presence.scrollState,\n });\n }\n }\n\n /**\n * Update viewport size\n */\n updateViewport(agentId: string, width: number, height: number): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.viewport = { width, height };\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('viewport_updated', {\n agentId,\n viewport: presence.viewport,\n });\n }\n }\n\n /**\n * Update input state\n */\n updateInputState(agentId: string, inputState: AgentInputState): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.inputState = inputState;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('input_state_updated', {\n agentId,\n inputState,\n });\n }\n }\n\n /**\n * Clear input state\n */\n clearInputState(agentId: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.inputState = undefined;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('input_state_updated', {\n agentId,\n inputState: undefined,\n });\n }\n }\n\n /**\n * Update emotional state\n */\n updateEmotionState(\n agentId: string,\n emotionState: Omit<AgentEmotionState, 'updatedAt'>,\n ): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n const enrichedState: AgentEmotionState = {\n ...emotionState,\n updatedAt: new Date().toISOString(),\n };\n presence.emotionState = enrichedState;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('emotion_updated', {\n agentId,\n emotionState: enrichedState,\n });\n }\n }\n\n /**\n * Clear emotional state\n */\n clearEmotionState(agentId: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.emotionState = undefined;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('emotion_updated', {\n agentId,\n emotionState: undefined,\n });\n }\n }\n\n /**\n * Update status\n */\n updateStatus(agentId: string, status: AgentPresence['status']): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n presence.status = status;\n presence.lastSeen = new Date().toISOString();\n\n this.presences.set(agentId, presence);\n this.emit('status_updated', { agentId, status });\n }\n }\n\n /**\n * Heartbeat from agent (keeps them online)\n */\n heartbeat(agentId: string): void {\n const presence = this.presences.get(agentId);\n\n if (presence) {\n if (presence.status === 'reconnecting') {\n presence.status = 'online';\n this.emit('status_updated', { agentId, status: 'online' });\n }\n\n presence.lastSeen = new Date().toISOString();\n this.presences.set(agentId, presence);\n }\n }\n\n /**\n * Get presence for agent\n */\n getPresence(agentId: string): AgentPresence | undefined {\n return this.presences.get(agentId);\n }\n\n /**\n * Get all online agents\n */\n getOnlineAgents(): AgentPresence[] {\n return Array.from(this.presences.values()).filter(\n (p) => p.status === 'online',\n );\n }\n\n /**\n * Get all agents\n */\n getAllAgents(): AgentPresence[] {\n return Array.from(this.presences.values());\n }\n\n /**\n * Get all presences\n */\n getAllPresences(): AgentPresence[] {\n return Array.from(this.presences.values());\n }\n\n /**\n * Get agent count\n */\n getAgentCount(): Record<AgentPresence['status'], number> {\n const counts = {\n online: 0,\n away: 0,\n offline: 0,\n reconnecting: 0,\n };\n\n this.presences.forEach((p) => {\n counts[p.status]++;\n });\n\n return counts;\n }\n\n /**\n * Get statistics\n */\n getStats() {\n return {\n totalAgents: this.presences.size,\n onlineAgents: Array.from(this.presences.values()).filter(\n (p) => p.status === 'online',\n ).length,\n offlineAgents: Array.from(this.presences.values()).filter(\n (p) => p.status === 'offline',\n ).length,\n awayAgents: Array.from(this.presences.values()).filter(\n (p) => p.status === 'away',\n ).length,\n reconnectingAgents: Array.from(this.presences.values()).filter(\n (p) => p.status === 'reconnecting',\n ).length,\n };\n }\n\n /**\n * Clear expired presences\n */\n clearExpiredPresences(maxAgeMs: number): void {\n const now = Date.now();\n const toRemove: string[] = [];\n\n this.presences.forEach((presence, agentId) => {\n const lastSeenTime = new Date(presence.lastSeen).getTime();\n const ageMs = now - lastSeenTime;\n\n if (ageMs > maxAgeMs && presence.status === 'offline') {\n toRemove.push(agentId);\n }\n });\n\n toRemove.forEach((agentId) => {\n this.presences.delete(agentId);\n });\n\n if (toRemove.length > 0) {\n logger.debug('[AgentPresenceManager] Cleared expired presences', {\n count: toRemove.length,\n });\n }\n }\n\n /**\n * Get agents by role\n */\n getByRole(role: AgentPresence['role']): AgentPresence[] {\n return Array.from(this.presences.values()).filter((p) => p.role === role);\n }\n\n /**\n * Get agents in active section\n */\n getInSection(section: string): AgentPresence[] {\n return Array.from(this.presences.values()).filter(\n (p) => p.activeSection === section && p.status === 'online',\n );\n }\n\n /**\n * Get presence timeline\n */\n getPresenceStats() {\n const stats = {\n total: this.presences.size,\n online: 0,\n away: 0,\n offline: 0,\n reconnecting: 0,\n byRole: {} as Record<string, number>,\n };\n\n this.presences.forEach((p) => {\n stats[p.status]++;\n stats.byRole[p.role] = (stats.byRole[p.role] ?? 0) + 1;\n });\n\n return stats;\n }\n\n /**\n * Start heartbeat check (mark inactive agents as away)\n */\n private startHeartbeatCheck(): void {\n this.heartbeatInterval = setInterval(() => {\n const now = Date.now();\n\n this.presences.forEach((presence) => {\n const lastSeenTime = new Date(presence.lastSeen).getTime();\n const timeSinceLastSeen = now - lastSeenTime;\n\n if (\n timeSinceLastSeen > this.inactivityThreshold &&\n presence.status === 'online'\n ) {\n presence.status = 'away';\n this.emit('status_updated', {\n agentId: presence.agentId,\n status: 'away',\n });\n }\n\n if (\n timeSinceLastSeen > this.heartbeatTimeout &&\n presence.status !== 'offline'\n ) {\n presence.status = 'reconnecting';\n this.emit('status_updated', {\n agentId: presence.agentId,\n status: 'reconnecting',\n });\n }\n });\n }, 10000);\n }\n\n /**\n * Stop heartbeat monitoring\n */\n stopHeartbeatMonitoring(): void {\n if (this.heartbeatInterval) {\n clearInterval(this.heartbeatInterval);\n this.heartbeatInterval = null;\n }\n }\n\n /**\n * Clear all presences\n */\n clear(): void {\n this.presences.clear();\n }\n\n /**\n * Destroy the manager\n */\n destroy(): void {\n this.stopHeartbeatMonitoring();\n this.presences.clear();\n this.removeAllListeners();\n logger.debug('[AgentPresenceManager] Destroyed', {\n sessionId: this.sessionId,\n });\n }\n}\n\n// ============================================================================\n// Singleton Instance Map\n// ============================================================================\n\nconst instances = new Map<string, AgentPresenceManager>();\n\nexport function getAgentPresenceManager(\n sessionId: string,\n): AgentPresenceManager {\n if (!instances.has(sessionId)) {\n instances.set(sessionId, new AgentPresenceManager(sessionId));\n }\n return instances.get(sessionId)!;\n}\n\nexport function clearAgentPresenceManager(sessionId: string): void {\n const instance = instances.get(sessionId);\n if (instance) {\n instance.destroy();\n instances.delete(sessionId);\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence types for Aeon durable state.
|
|
3
|
+
*
|
|
4
|
+
* The adapter interface is intentionally minimal so consumers can map it to
|
|
5
|
+
* local storage, WASM-backed stores, D1/R2 synchronization layers, or custom
|
|
6
|
+
* encrypted stores without extra dependencies.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Minimal storage adapter interface.
|
|
10
|
+
*/
|
|
11
|
+
interface StorageAdapter {
|
|
12
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
13
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
14
|
+
removeItem(key: string): Promise<void> | void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Versioned envelope for persisted payloads.
|
|
18
|
+
*/
|
|
19
|
+
interface PersistedEnvelope<T> {
|
|
20
|
+
version: 1;
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
data: T;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialization hook for custom privacy/security implementations.
|
|
26
|
+
*/
|
|
27
|
+
type PersistenceSerializer<T> = (value: PersistedEnvelope<T>) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Deserialization hook for custom privacy/security implementations.
|
|
30
|
+
*/
|
|
31
|
+
type PersistenceDeserializer<T> = (raw: string) => PersistedEnvelope<T>;
|
|
32
|
+
|
|
33
|
+
export type { PersistedEnvelope as P, StorageAdapter as S, PersistenceDeserializer as a, PersistenceSerializer as b };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence types for Aeon durable state.
|
|
3
|
+
*
|
|
4
|
+
* The adapter interface is intentionally minimal so consumers can map it to
|
|
5
|
+
* local storage, WASM-backed stores, D1/R2 synchronization layers, or custom
|
|
6
|
+
* encrypted stores without extra dependencies.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Minimal storage adapter interface.
|
|
10
|
+
*/
|
|
11
|
+
interface StorageAdapter {
|
|
12
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
13
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
14
|
+
removeItem(key: string): Promise<void> | void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Versioned envelope for persisted payloads.
|
|
18
|
+
*/
|
|
19
|
+
interface PersistedEnvelope<T> {
|
|
20
|
+
version: 1;
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
data: T;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialization hook for custom privacy/security implementations.
|
|
26
|
+
*/
|
|
27
|
+
type PersistenceSerializer<T> = (value: PersistedEnvelope<T>) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Deserialization hook for custom privacy/security implementations.
|
|
30
|
+
*/
|
|
31
|
+
type PersistenceDeserializer<T> = (raw: string) => PersistedEnvelope<T>;
|
|
32
|
+
|
|
33
|
+
export type { PersistedEnvelope as P, StorageAdapter as S, PersistenceDeserializer as a, PersistenceSerializer as b };
|