@decido/kernel-bridge 1.0.0 → 4.0.1

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.
@@ -1,52 +0,0 @@
1
- import { kernel } from './kernel';
2
- import { decryptEvent } from './crypto';
3
- // Import store if needed, or rely on kernel dispatch.
4
- // We will broadcast locally to avoid tight coupling if we don't have direct access to the shell store here.
5
-
6
- export const StateRehydrationManager = {
7
- async rehydrate(swarmKey: string) {
8
- console.log("[Rehydration] 🔄 Iniciando recuperación de estado...");
9
-
10
- try {
11
- // Pedimos los últimos 100 eventos del stream persistente
12
- const history = await kernel.execute('get_stream_history', { limit: 100 });
13
-
14
- if (!Array.isArray(history)) {
15
- console.warn("[Rehydration] El historial devuelto no es un array válido.");
16
- return;
17
- }
18
-
19
- // Procesamos cronológicamente (de más viejo a más nuevo)
20
- const events = history.reverse();
21
-
22
- for (const rawEvent of events) {
23
- let event = rawEvent;
24
-
25
- // Si el evento viene cifrado (formato Secure Stream), lo desciframos
26
- if (typeof rawEvent === 'string') {
27
- try {
28
- event = await decryptEvent(rawEvent, swarmKey);
29
- } catch (e) {
30
- console.warn("[Rehydration] No se pudo descifrar un evento, saltando...");
31
- continue;
32
- }
33
- }
34
-
35
- // Distribuimos el evento a los sistemas interesados
36
- this.replayEvent(event);
37
- }
38
-
39
- console.log(`[Rehydration] ✅ Memoria restaurada: ${events.length} eventos procesados.`);
40
- } catch (error) {
41
- console.error("[Rehydration] Fallo crítico en la rehidratación:", error);
42
- }
43
- },
44
-
45
- replayEvent(event: any) {
46
- try {
47
- kernel.injectEvent({ ...event, is_rehydration: true });
48
- } catch (e) {
49
- console.warn("[Rehydration] Error inyectando evento de historial", e);
50
- }
51
- }
52
- };
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "strict": true,
5
- "baseUrl": ".",
6
- "paths": {
7
- "~/*": [
8
- "./src/*"
9
- ],
10
- "@decido/contracts": [
11
- "../contracts/src"
12
- ]
13
- }
14
- },
15
- "include": [
16
- "src"
17
- ]
18
- }