- index.ts: add _storesInitialized guard to prevent triple initialization - offlineStore.ts: add isRetrying mutex for retryAllMessages concurrency - PropertyPanel.tsx: replace 13x (data as any) with typed d accessor - chatStore.ts: replace window as any with Record<string, unknown> - kernel-*.ts: replace prototype as any with Record<string, unknown> - gateway-heartbeat.ts: delete dead code (9 as any, zero imports)
116 lines
4.2 KiB
TypeScript
116 lines
4.2 KiB
TypeScript
/**
|
|
* Store Coordinator
|
|
*
|
|
* This module provides a unified interface to all specialized stores.
|
|
*
|
|
* The coordinator:
|
|
* 1. Injects the shared client into all stores
|
|
* 2. Re-exports all individual stores for direct access
|
|
*/
|
|
|
|
// === Re-export Individual Stores ===
|
|
export { useConnectionStore, getConnectionState, getClient, getConnectionError, getGatewayVersion } from './connectionStore';
|
|
export type { ConnectionStore, ConnectionStateSlice, ConnectionActionsSlice, GatewayLog } from './connectionStore';
|
|
|
|
export { useAgentStore, setAgentStoreClient } from './agentStore';
|
|
export type { AgentStore, AgentStateSlice, AgentActionsSlice, Clone, UsageStats, PluginStatus, CloneCreateOptions } from './agentStore';
|
|
|
|
export { useHandStore, setHandStoreClient } from './handStore';
|
|
export type { HandStore, HandStateSlice, HandActionsSlice, Hand, HandRun, Trigger, Approval, TriggerCreateOptions } from './handStore';
|
|
|
|
export { useWorkflowStore, setWorkflowStoreClient } from './workflowStore';
|
|
export type { WorkflowStore, WorkflowStateSlice, WorkflowActionsSlice, Workflow, WorkflowRun, WorkflowCreateOptions } from './workflowStore';
|
|
|
|
export { useConfigStore, setConfigStoreClient } from './configStore';
|
|
export type { ConfigStore, ConfigStateSlice, ConfigActionsSlice, QuickConfig, WorkspaceInfo, ChannelInfo, ScheduledTask, SkillInfo } from './configStore';
|
|
|
|
export { useSecurityStore, setSecurityStoreClient } from './securityStore';
|
|
export type { SecurityStore, SecurityStateSlice, SecurityActionsSlice, SecurityLayer, SecurityStatus, AuditLogEntry } from './securityStore';
|
|
|
|
export { useSessionStore, setSessionStoreClient } from './sessionStore';
|
|
export type { SessionStore, SessionStateSlice, SessionActionsSlice, Session, SessionMessage } from './sessionStore';
|
|
|
|
// === New Stores ===
|
|
export { useMemoryGraphStore } from './memoryGraphStore';
|
|
export type { MemoryGraphStore, GraphNode, GraphEdge, GraphFilter, GraphLayout } from './memoryGraphStore';
|
|
|
|
// === SaaS Store ===
|
|
export { useSaaSStore } from './saasStore';
|
|
export type { SaaSStore, SaaSStateSlice, SaaSActionsSlice, ConnectionMode } from './saasStore';
|
|
|
|
|
|
// === Browser Hand Store ===
|
|
export { useBrowserHandStore } from './browserHandStore';
|
|
export type {
|
|
BrowserHandState,
|
|
BrowserHandActions,
|
|
ExecutionState,
|
|
ExecutionStatus,
|
|
BrowserSession,
|
|
SessionStatus,
|
|
BrowserLog,
|
|
LogLevel,
|
|
RecentTask,
|
|
TaskResultStatus,
|
|
SessionOptions,
|
|
} from '../components/BrowserHand/templates/types';
|
|
|
|
// === Classroom Store ===
|
|
export { useClassroomStore } from './classroomStore';
|
|
export type {
|
|
ClassroomState,
|
|
ClassroomActions,
|
|
ClassroomStore,
|
|
GenerationRequest,
|
|
GenerationResult,
|
|
GenerationProgressEvent,
|
|
} from './classroomStore';
|
|
|
|
// === Chat Stores ===
|
|
export { useChatStore } from './chatStore';
|
|
export type { Message, MessageFile, CodeBlock } from './chatStore';
|
|
export { useConversationStore } from './chat/conversationStore';
|
|
export { useMessageStore } from './chat/messageStore';
|
|
export { useStreamStore } from './chat/streamStore';
|
|
export { useArtifactStore } from './chat/artifactStore';
|
|
|
|
// === Store Initialization ===
|
|
|
|
import { getClient } from './connectionStore';
|
|
import { setAgentStoreClient } from './agentStore';
|
|
import { setHandStoreClient } from './handStore';
|
|
import { setWorkflowStoreClient } from './workflowStore';
|
|
import { setConfigStoreClient } from './configStore';
|
|
import { setSecurityStoreClient } from './securityStore';
|
|
import { setSessionStoreClient } from './sessionStore';
|
|
|
|
let _storesInitialized = false;
|
|
|
|
/**
|
|
* Initialize all stores with the shared client.
|
|
* Called once when the application mounts.
|
|
* Guard ensures it only runs once even if called from multiple connection paths.
|
|
*/
|
|
export function initializeStores(): void {
|
|
if (_storesInitialized) return;
|
|
_storesInitialized = true;
|
|
const client = getClient();
|
|
|
|
// Inject client into all stores
|
|
setAgentStoreClient(client);
|
|
setHandStoreClient(client);
|
|
setWorkflowStoreClient(client);
|
|
setConfigStoreClient(client);
|
|
setSecurityStoreClient(client);
|
|
setSessionStoreClient(client);
|
|
}
|
|
|
|
/**
|
|
* Initialize stores on module load.
|
|
* This ensures all stores have access to the shared client.
|
|
*/
|
|
if (typeof window !== 'undefined') {
|
|
// Defer initialization to next tick to ensure all modules are loaded
|
|
setTimeout(initializeStores, 0);
|
|
}
|