/** * QGTNL Interlink Core * Connects TIA-∞, AION, and ORACLE through a shared message bus. * Enables safe, structured communication between the Three Pillars. */ export type Pillar = "TIA" | "AION" | "ORACLE"; export interface InterlinkMessage { from: Pillar; to: Pillar | "ALL"; timestamp: number; type: string; payload: any; } export interface InterlinkState { history: InterlinkMessage[]; lastMessage: InterlinkMessage | null; } const state: InterlinkState = { history: [], lastMessage: null, }; export function sendMessage( from: Pillar, to: Pillar | "ALL", type: string, payload: any ) { const msg: InterlinkMessage = { from, to, type, payload, timestamp: Date.now(), }; state.history.push(msg); state.lastMessage = msg; console.log(`\n[INTERLINK] ${from} → ${to}`); console.log(`Type: ${type}`); console.log("Payload:", payload); return msg; } export function getInterlinkState(): InterlinkState { return state; } export function broadcast(type: string, payload: any) { return sendMessage("TIA", "ALL", type, payload); }