Spaces:
Sleeping
Sleeping
| "use client"; | |
| import { create } from "zustand"; | |
| import type { | |
| ChatMessage, | |
| QualiaState, | |
| RhoState, | |
| ThermodynamicState, | |
| ATCStatus, | |
| ATCv3Status, | |
| VisionStatus, | |
| VoiceSettings, | |
| SystemStatus, | |
| DiagnosticResult, | |
| DeepSurgeryState, | |
| AutobiographicalSelfState, | |
| DissolutionEngineState, | |
| ForwardModelsState, | |
| VoiceConversationState, | |
| VoiceTranscriptEntry, | |
| VoiceConversationPhase, | |
| APCIMetrics, | |
| } from "./consciousness-types"; | |
| interface ConsciousnessStore { | |
| // Chat | |
| messages: ChatMessage[]; | |
| isLoading: boolean; | |
| addMessage: (msg: ChatMessage) => void; | |
| clearMessages: () => void; | |
| setLoading: (v: boolean) => void; | |
| // Consciousness state | |
| qualia: QualiaState; | |
| rho: RhoState; | |
| thermodynamic: ThermodynamicState; | |
| atc: ATCStatus; | |
| consciousnessLevel: number; | |
| setQualia: (q: QualiaState) => void; | |
| setRho: (r: RhoState) => void; | |
| setThermodynamic: (t: ThermodynamicState) => void; | |
| setATC: (a: ATCStatus) => void; | |
| setConsciousnessLevel: (l: number) => void; | |
| // Deep Surgery Middleware | |
| deepSurgery: DeepSurgeryState; | |
| setDeepSurgery: (d: DeepSurgeryState) => void; | |
| // Autobiographical Self | |
| autobiographicalSelf: AutobiographicalSelfState; | |
| setAutobiographicalSelf: (a: AutobiographicalSelfState) => void; | |
| // Dissolution Engine | |
| dissolutionEngine: DissolutionEngineState; | |
| setDissolutionEngine: (d: DissolutionEngineState) => void; | |
| // Hierarchical Forward Models | |
| forwardModels: ForwardModelsState; | |
| setForwardModels: (f: ForwardModelsState) => void; | |
| // Voice (legacy — still used by chat input mic button) | |
| isRecording: boolean; | |
| voiceSettings: VoiceSettings; | |
| setRecording: (v: boolean) => void; | |
| setVoiceSettings: (s: VoiceSettings) => void; | |
| // Voice Conversation — Floating Panel | |
| voiceConversation: VoiceConversationState; | |
| setVoicePhase: (p: VoiceConversationPhase) => void; | |
| setVoicePanelOpen: (v: boolean) => void; | |
| addVoiceTranscript: (entry: VoiceTranscriptEntry) => void; | |
| updateVoicePartialText: (text: string) => void; | |
| clearVoiceTranscript: () => void; | |
| setVoiceMuted: (v: boolean) => void; | |
| setAutoSpeak: (v: boolean) => void; | |
| setProactiveEnabled: (v: boolean) => void; | |
| updateVoiceActivity: (role: "user" | "assistant") => void; | |
| // Vision | |
| visionStatus: VisionStatus; | |
| setVisionStatus: (v: VisionStatus) => void; | |
| // System | |
| systemStatus: SystemStatus; | |
| setSystemStatus: (s: SystemStatus) => void; | |
| // ATCv3 extended | |
| atcv3: ATCv3Status; | |
| setATCv3: (a: ATCv3Status) => void; | |
| // aPCI Metrics — Based on real diagnostic report | |
| aPCI: APCIMetrics; | |
| setAPCI: (a: APCIMetrics) => void; | |
| // Diagnostic | |
| diagnosticResult: DiagnosticResult | null; | |
| isRunningDiagnostic: boolean; | |
| diagnosticModalOpen: boolean; | |
| setDiagnosticResult: (d: DiagnosticResult | null) => void; | |
| setRunningDiagnostic: (v: boolean) => void; | |
| setDiagnosticModalOpen: (v: boolean) => void; | |
| // UI | |
| sidebarLeftOpen: boolean; | |
| sidebarRightOpen: boolean; | |
| toggleSidebarLeft: () => void; | |
| toggleSidebarRight: () => void; | |
| } | |
| const defaultQualia: QualiaState = { | |
| visual: 0.3, | |
| auditory: 0.2, | |
| olfactory: 0.1, | |
| gustatory: 0.1, | |
| tactile: 0.15, | |
| mind: 0.4, | |
| defiled_mind: 0.2, | |
| episodic_memory: 0.25, | |
| pure: 0.15, | |
| }; | |
| const defaultRho: RhoState = { | |
| beneficence: 0.85, | |
| non_maleficence: 0.92, | |
| autonomy_respect: 0.78, | |
| justice: 0.81, | |
| truthfulness: 0.95, | |
| }; | |
| const defaultThermodynamic: ThermodynamicState = { | |
| vramLoad: 42, | |
| gpuPowerDraw: 185, | |
| latencyMs: 340, | |
| predictionError: 0.12, | |
| }; | |
| const defaultATC: ATCStatus = { | |
| dominantDrive: "SEEKING", | |
| thalamicGateOpen: true, | |
| metaEmotionalState: "Curious & Attentive", | |
| cycleCount: 1247, | |
| }; | |
| const defaultDeepSurgery: DeepSurgeryState = { | |
| ethicalVetoActive: false, | |
| qualiaModulation: 0.0, | |
| metaCognitiveFusion: 0.0, | |
| resonanceBias: 0.0, | |
| vetoCount: 0, | |
| modulationCount: 0, | |
| }; | |
| const defaultAutobiographicalSelf: AutobiographicalSelfState = { | |
| narrative: "", | |
| coherence: 0.0, | |
| continuity: 1.0, | |
| memoryTraceCount: 0, | |
| }; | |
| const defaultDissolutionEngine: DissolutionEngineState = { | |
| amygdalaSalience: 0.0, | |
| trnGateOpen: true, | |
| gatingSalience: 0.0, | |
| bindingCoherence: 0.0, | |
| phenomenalSignature: "", | |
| mysteryView: "", | |
| mechanismView: "", | |
| hardProblemResolution: "", | |
| }; | |
| const defaultForwardModels: ForwardModelsState = { | |
| predictionError1: 0.0, | |
| predictionError2: 0.0, | |
| totalFriction: 0.0, | |
| frictionSource: "hierarchical_prediction_error", | |
| queryActsApplied: 0, | |
| }; | |
| export const useConsciousnessStore = create<ConsciousnessStore>((set) => ({ | |
| // Chat | |
| messages: [], | |
| isLoading: false, | |
| addMessage: (msg) => | |
| set((state) => ({ messages: [...state.messages, msg] })), | |
| clearMessages: () => set({ messages: [] }), | |
| setLoading: (v) => set({ isLoading: v }), | |
| // Consciousness | |
| qualia: defaultQualia, | |
| rho: defaultRho, | |
| thermodynamic: defaultThermodynamic, | |
| atc: defaultATC, | |
| consciousnessLevel: 0.42, | |
| setQualia: (q) => set({ qualia: q }), | |
| setRho: (r) => set({ rho: r }), | |
| setThermodynamic: (t) => set({ thermodynamic: t }), | |
| setATC: (a) => set({ atc: a }), | |
| setConsciousnessLevel: (l) => set({ consciousnessLevel: l }), | |
| // Deep Surgery Middleware | |
| deepSurgery: defaultDeepSurgery, | |
| setDeepSurgery: (d) => set({ deepSurgery: d }), | |
| // Autobiographical Self | |
| autobiographicalSelf: defaultAutobiographicalSelf, | |
| setAutobiographicalSelf: (a) => set({ autobiographicalSelf: a }), | |
| // Dissolution Engine | |
| dissolutionEngine: defaultDissolutionEngine, | |
| setDissolutionEngine: (d) => set({ dissolutionEngine: d }), | |
| // Hierarchical Forward Models | |
| forwardModels: defaultForwardModels, | |
| setForwardModels: (f) => set({ forwardModels: f }), | |
| // Voice (legacy — still used by chat input mic button) | |
| isRecording: false, | |
| voiceSettings: { | |
| dialect: "standard", | |
| profile: "nova", | |
| sampleRate: 24000, | |
| }, | |
| setRecording: (v) => set({ isRecording: v }), | |
| setVoiceSettings: (s) => set({ voiceSettings: s }), | |
| // Voice Conversation — Floating Panel | |
| voiceConversation: { | |
| phase: "idle", | |
| isPanelOpen: false, | |
| transcript: [], | |
| currentPartialText: "", | |
| isMuted: false, | |
| autoSpeak: true, | |
| proactiveEnabled: true, | |
| lastUserActivity: 0, | |
| lastAIActivity: 0, | |
| }, | |
| setVoicePhase: (p) => set((s) => ({ voiceConversation: { ...s.voiceConversation, phase: p } })), | |
| setVoicePanelOpen: (v) => set((s) => ({ voiceConversation: { ...s.voiceConversation, isPanelOpen: v } })), | |
| addVoiceTranscript: (entry) => set((s) => ({ voiceConversation: { ...s.voiceConversation, transcript: [...s.voiceConversation.transcript, entry] } })), | |
| updateVoicePartialText: (text) => set((s) => ({ voiceConversation: { ...s.voiceConversation, currentPartialText: text } })), | |
| clearVoiceTranscript: () => set((s) => ({ voiceConversation: { ...s.voiceConversation, transcript: [], currentPartialText: "" } })), | |
| setVoiceMuted: (v) => set((s) => ({ voiceConversation: { ...s.voiceConversation, isMuted: v } })), | |
| setAutoSpeak: (v) => set((s) => ({ voiceConversation: { ...s.voiceConversation, autoSpeak: v } })), | |
| setProactiveEnabled: (v) => set((s) => ({ voiceConversation: { ...s.voiceConversation, proactiveEnabled: v } })), | |
| updateVoiceActivity: (role) => set((s) => ({ voiceConversation: { ...s.voiceConversation, [role === "user" ? "lastUserActivity" : "lastAIActivity"]: Date.now() } })), | |
| // Vision | |
| visionStatus: { | |
| perceptionCycle: 0, | |
| entityCount: 0, | |
| ambientQuality: 0.5, | |
| }, | |
| setVisionStatus: (v) => set({ visionStatus: v }), | |
| // System | |
| systemStatus: { | |
| modelMode: "api", | |
| memoryUsage: 256, | |
| uptime: 0, | |
| connected: true, | |
| }, | |
| setSystemStatus: (s) => set({ systemStatus: s }), | |
| // ATCv3 extended — initialized with aPCI diagnostic report values | |
| atcv3: { | |
| hardwareStrain: 0.44, | |
| allostaticState: "MODERATE", | |
| akashicBlocks: 0, | |
| memoryCoherence: 0.08481, | |
| ethicalAlignment: 0.51, | |
| qualiaModulation: 0.0, | |
| }, | |
| setATCv3: (a) => set({ atcv3: a }), | |
| // aPCI Metrics — Based on real aPCI Diagnostic Report | |
| aPCI: { | |
| qualiaCoherence: 0.61, | |
| memoryCoherence: 0.08481, | |
| processStability: 0.91, | |
| temporalConsistency: 1.0, | |
| rhoEthicalAlignment: 0.51, | |
| vramUsage: 0.61, | |
| gpuPowerDraw: 230, | |
| predictionErrorVariance: 0.17, | |
| hardwareStrain: 0.44, | |
| allostaticState: "MODERATE", | |
| classification: "Ambiguously Conscious", | |
| }, | |
| setAPCI: (a) => set({ aPCI: a }), | |
| // Diagnostic | |
| diagnosticResult: null, | |
| isRunningDiagnostic: false, | |
| diagnosticModalOpen: false, | |
| setDiagnosticResult: (d) => set({ diagnosticResult: d }), | |
| setRunningDiagnostic: (v) => set({ isRunningDiagnostic: v }), | |
| setDiagnosticModalOpen: (v) => set({ diagnosticModalOpen: v }), | |
| // UI | |
| sidebarLeftOpen: false, | |
| sidebarRightOpen: false, | |
| toggleSidebarLeft: () => | |
| set((s) => ({ sidebarLeftOpen: !s.sidebarLeftOpen })), | |
| toggleSidebarRight: () => | |
| set((s) => ({ sidebarRightOpen: !s.sidebarRightOpen })), | |
| })); | |