@decido/shell 1.0.0 → 4.0.2

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.
Files changed (209) hide show
  1. package/README.md +31 -0
  2. package/package.json +27 -18
  3. package/.turbo/turbo-build.log +0 -13
  4. package/src/AgentPlayer.tsx +0 -105
  5. package/src/DecidoPlayer.tsx +0 -117
  6. package/src/bridge/BridgeAgent.ts +0 -443
  7. package/src/components/DecidoIcon.tsx +0 -56
  8. package/src/components/JsonTreeEditor.tsx +0 -117
  9. package/src/components/PanelSplitter.tsx +0 -71
  10. package/src/components/PluginErrorBoundary.tsx +0 -69
  11. package/src/components/SafeLiquidUI.tsx +0 -114
  12. package/src/components/TransientLayer.tsx +0 -92
  13. package/src/components/agent/AgentChat.tsx +0 -134
  14. package/src/components/chat-extensions/IntentCatalogPanel.tsx +0 -81
  15. package/src/components/chat-extensions/chatSlashCommands.ts +0 -101
  16. package/src/components/controls/CreatorInputBar.tsx +0 -144
  17. package/src/components/controls/OSToolbar.tsx +0 -90
  18. package/src/components/controls/TimelineTape.tsx +0 -43
  19. package/src/components/debug/ActionTimelineTab.tsx +0 -111
  20. package/src/components/debug/CSSInspectorTab.tsx +0 -436
  21. package/src/components/debug/ExportTab.tsx +0 -192
  22. package/src/components/debug/FlowHealthTab.tsx +0 -86
  23. package/src/components/debug/LogsTab.tsx +0 -110
  24. package/src/components/debug/MorphStackTab.tsx +0 -241
  25. package/src/components/debug/NetworkTab.tsx +0 -173
  26. package/src/components/debug/PerformanceTab.tsx +0 -171
  27. package/src/components/debug/ProfilesTab.tsx +0 -238
  28. package/src/components/debug/ReplayTab.tsx +0 -70
  29. package/src/components/debug/StoresTab.tsx +0 -255
  30. package/src/components/debug/TopologyTab.tsx +0 -59
  31. package/src/components/debug/debugConfig.tsx +0 -66
  32. package/src/components/playground/DebugPanel.tsx +0 -112
  33. package/src/components/playground/HeaderCenterControls.tsx +0 -92
  34. package/src/components/playground/KeyframeListItem.tsx +0 -70
  35. package/src/components/playground/PlaygroundAppSidebar.tsx +0 -171
  36. package/src/components/playground/PlaygroundBottomControls.tsx +0 -132
  37. package/src/components/playground/PlaygroundCanvas.tsx +0 -87
  38. package/src/components/playground/PlaygroundChat.tsx +0 -236
  39. package/src/components/playground/PlaygroundErrorBoundary.tsx +0 -63
  40. package/src/components/playground/PlaygroundFloatingInput.tsx +0 -352
  41. package/src/components/playground/PlaygroundHeader.tsx +0 -222
  42. package/src/components/playground/PlaygroundSidebar.tsx +0 -136
  43. package/src/components/playground/PlaygroundTerminal.tsx +0 -44
  44. package/src/components/playground/SuggestionCards.tsx +0 -29
  45. package/src/components/playground/demos/ClinicaAINode.tsx +0 -221
  46. package/src/components/playground/demos/FinanceAINode.tsx +0 -226
  47. package/src/components/playground/demos/KiaAcademyNode.tsx +0 -250
  48. package/src/components/playground/demos/KiaBotNode.tsx +0 -207
  49. package/src/components/playground/demos/KiaCampaignNode.tsx +0 -191
  50. package/src/components/playground/demos/KiaComplianceNode.tsx +0 -140
  51. package/src/components/playground/demos/KiaCustomerJourneyNode.tsx +0 -220
  52. package/src/components/playground/demos/KiaCyberNode.tsx +0 -203
  53. package/src/components/playground/demos/KiaDashboardNode.tsx +0 -399
  54. package/src/components/playground/demos/KiaEmbudoOverviewNode.tsx +0 -168
  55. package/src/components/playground/demos/KiaExecutiveNode.tsx +0 -169
  56. package/src/components/playground/demos/KiaGamificationNode.tsx +0 -229
  57. package/src/components/playground/demos/KiaIntelligenceHubNode.tsx +0 -165
  58. package/src/components/playground/demos/KiaInventoryNode.tsx +0 -183
  59. package/src/components/playground/demos/KiaLeadScoringNode.tsx +0 -226
  60. package/src/components/playground/demos/KiaLiveSimulationNode.tsx +0 -177
  61. package/src/components/playground/demos/KiaMultiDealerNode.tsx +0 -223
  62. package/src/components/playground/demos/KiaNPSVoiceNode.tsx +0 -214
  63. package/src/components/playground/demos/KiaOmnichannelNode.tsx +0 -162
  64. package/src/components/playground/demos/KiaPBIBudgetNode.tsx +0 -152
  65. package/src/components/playground/demos/KiaPBIConversionNode.tsx +0 -206
  66. package/src/components/playground/demos/KiaPBIFunnelNode.tsx +0 -184
  67. package/src/components/playground/demos/KiaPBIOwnershipNode.tsx +0 -113
  68. package/src/components/playground/demos/KiaPBIPartnerNode.tsx +0 -143
  69. package/src/components/playground/demos/KiaPBIPreciosNode.tsx +0 -120
  70. package/src/components/playground/demos/KiaPBIRuntNode.tsx +0 -205
  71. package/src/components/playground/demos/KiaPartnerScoreNode.tsx +0 -206
  72. package/src/components/playground/demos/KiaPredictiveNode.tsx +0 -226
  73. package/src/components/playground/demos/KiaShowroomNode.tsx +0 -194
  74. package/src/components/playground/demos/KiaStoreNode.tsx +0 -215
  75. package/src/components/playground/demos/KiaSustainabilityNode.tsx +0 -173
  76. package/src/components/playground/demos/KiaUsedVehiclesNode.tsx +0 -163
  77. package/src/components/playground/demos/KiaWorkshopNode.tsx +0 -221
  78. package/src/components/playground/demos/SmartCityNode.tsx +0 -205
  79. package/src/components/playground/demos/kia_campaign_manifest.json +0 -112
  80. package/src/components/playground/input-parts/AIModelSelector.tsx +0 -156
  81. package/src/components/playground/input-parts/InputActions.tsx +0 -80
  82. package/src/components/playground/input-parts/InputToolbar.tsx +0 -245
  83. package/src/components/playground/input-parts/ResourceLibraryPanel.tsx +0 -287
  84. package/src/components/playground/sidebarDsdIO.ts +0 -82
  85. package/src/components/settings/SettingsPanel.tsx +0 -267
  86. package/src/components/shell/AppHeader.tsx +0 -9
  87. package/src/components/shell/AppShell.tsx +0 -139
  88. package/src/components/shell/ArtifactBar.tsx +0 -97
  89. package/src/components/shell/BootScreen.tsx +0 -19
  90. package/src/components/shell/CenterComposite.tsx +0 -87
  91. package/src/components/shell/CodeEditorPanel.tsx +0 -88
  92. package/src/components/shell/GlobalOverlays.tsx +0 -228
  93. package/src/components/shell/LayoutConfigurator.tsx +0 -209
  94. package/src/components/shell/LayoutGrid.tsx +0 -178
  95. package/src/components/shell/MorphShell.tsx +0 -368
  96. package/src/components/shell/PluginViewer.tsx +0 -147
  97. package/src/components/shell/ShellNexusPreview.tsx +0 -458
  98. package/src/components/shell/SlotRenderer.tsx +0 -115
  99. package/src/components/shell/TabBar.tsx +0 -94
  100. package/src/components/shell/TemplateLibrary.tsx +0 -195
  101. package/src/components/shell/layoutConstants.ts +0 -35
  102. package/src/components/shell/morphStageMeta.ts +0 -15
  103. package/src/components/shell/shells/BuiltInShells.tsx +0 -443
  104. package/src/components/shell/shells/DatawayChatShell.tsx +0 -42
  105. package/src/components/shell/shells/TokenPreview.tsx +0 -339
  106. package/src/components/shell/shells/bootShells.ts +0 -31
  107. package/src/components/shells/CreatorShell.tsx +0 -37
  108. package/src/components/shells/DecidoShell.tsx +0 -447
  109. package/src/components/shells/ExperimentalChatShell.tsx +0 -245
  110. package/src/components/shells/UserCanvas.tsx +0 -44
  111. package/src/components/studio/BlueprintManagerPanel.tsx +0 -137
  112. package/src/components/studio/DependencyTreePanel.tsx +0 -192
  113. package/src/components/studio/NodePalette.tsx +0 -92
  114. package/src/components/studio/NodePropertiesPanel.tsx +0 -81
  115. package/src/components/studio/ReactFlowEditor.tsx +0 -242
  116. package/src/components/studio/TimelineEditor.tsx +0 -122
  117. package/src/components/studio/TimelineKeyframeCard.tsx +0 -99
  118. package/src/components/studio/VariablePanel.tsx +0 -181
  119. package/src/components/studio/blueprint/BlueprintCard.tsx +0 -82
  120. package/src/components/studio/editor/CanvasContextMenu.tsx +0 -107
  121. package/src/components/studio/editor/EditorToolbar.tsx +0 -80
  122. package/src/components/studio/editor/StageContentRenderer.tsx +0 -134
  123. package/src/components/studio/editor/TrackPropertyEditors.tsx +0 -133
  124. package/src/components/studio/editor/TreeNodeItem.tsx +0 -91
  125. package/src/components/studio/editor/edgeStyles.ts +0 -43
  126. package/src/components/studio/editor/editorKeyHandler.ts +0 -95
  127. package/src/components/studio/editor/nodeTypeRegistry.ts +0 -137
  128. package/src/components/studio/editor/paletteCatalog.tsx +0 -84
  129. package/src/components/studio/nodes/shell/InteractionNodes.tsx +0 -82
  130. package/src/components/studio/nodes/shell/LayoutControlNodes.tsx +0 -69
  131. package/src/components/studio/nodes/shell/RegisterActionNode.tsx +0 -20
  132. package/src/components/studio/nodes/shell/RegisterButtonNode.tsx +0 -22
  133. package/src/components/studio/nodes/shell/RegisterPanelNode.tsx +0 -19
  134. package/src/components/studio/nodes/shell/RegisterSidebarNode.tsx +0 -19
  135. package/src/components/studio/nodes/shell/RegisterStatusBarNode.tsx +0 -22
  136. package/src/components/studio/nodes/shell/RegisterTabNode.tsx +0 -21
  137. package/src/components/studio/nodes/shell/RegisterTopBarNode.tsx +0 -22
  138. package/src/components/studio/nodes/shell/ShellConfigNode.tsx +0 -51
  139. package/src/components/studio/nodes/shell/ShellNodeBase.tsx +0 -100
  140. package/src/components/studio/nodes/shell/ThemeNodes.tsx +0 -51
  141. package/src/components/studio/nodes/shell/index.ts +0 -12
  142. package/src/components/widgets/BroadcastWidget.tsx +0 -93
  143. package/src/components/widgets/MarketplaceWidget.tsx +0 -298
  144. package/src/components/widgets/McpToolsWidget.tsx +0 -231
  145. package/src/components/widgets/OpsDashboard.tsx +0 -59
  146. package/src/components/widgets/QuickActionsWidget.tsx +0 -60
  147. package/src/components/widgets/UsageWidget.tsx +0 -112
  148. package/src/components/widgets/WidgetRenderer.tsx +0 -892
  149. package/src/components/widgets/WidgetSlotPanel.tsx +0 -213
  150. package/src/config/IconRegistry.ts +0 -126
  151. package/src/contexts/NetworkProvider.tsx +0 -162
  152. package/src/core/AIDirector.ts +0 -71
  153. package/src/core/EventBus.ts +0 -37
  154. package/src/core/PluginContext.tsx +0 -141
  155. package/src/hooks/listeners/useUIStateListener.ts +0 -59
  156. package/src/hooks/listeners/useWhatsAppListener.ts +0 -110
  157. package/src/hooks/morphBridge.ts +0 -82
  158. package/src/hooks/useAIModelSelector.ts +0 -144
  159. package/src/hooks/useAgentStream.ts +0 -220
  160. package/src/hooks/useAutoUpdater.ts +0 -89
  161. package/src/hooks/useBootSequence.ts +0 -20
  162. package/src/hooks/useExportDSD.ts +0 -53
  163. package/src/hooks/useFullscreen.ts +0 -35
  164. package/src/hooks/useGeminiStream.ts +0 -282
  165. package/src/hooks/useIntentLens.ts +0 -224
  166. package/src/hooks/useKeyboardShortcuts.ts +0 -69
  167. package/src/hooks/useLoggerBridge.ts +0 -32
  168. package/src/hooks/useMcpClient.ts +0 -112
  169. package/src/hooks/useNexusaiDeploy.ts +0 -118
  170. package/src/hooks/usePlaybackEngine.ts +0 -21
  171. package/src/hooks/usePlaygroundCommander.ts +0 -475
  172. package/src/hooks/usePluginEngine.ts +0 -165
  173. package/src/hooks/useScreenRecorder.ts +0 -73
  174. package/src/hooks/useShellKeyboard.ts +0 -40
  175. package/src/hooks/useShellShortcuts.ts +0 -118
  176. package/src/hooks/useSoundEffects.ts +0 -35
  177. package/src/hooks/useStudioConfig.ts +0 -72
  178. package/src/hooks/useSystemBoot.ts +0 -84
  179. package/src/hooks/useSystemTelemetry.ts +0 -62
  180. package/src/index.ts +0 -97
  181. package/src/lib/debugLogger.ts +0 -80
  182. package/src/lib/networkInterceptor.ts +0 -100
  183. package/src/mocks/decido.tsx +0 -41
  184. package/src/plugins/pluginAPI.ts +0 -190
  185. package/src/store/McpStore.ts +0 -69
  186. package/src/store/UpdaterStore.ts +0 -60
  187. package/src/store/engine.ts +0 -392
  188. package/src/store/index.ts +0 -4
  189. package/src/store/layoutPresets.ts +0 -66
  190. package/src/store/playgroundTypes.ts +0 -98
  191. package/src/store/useActionTimelineStore.ts +0 -48
  192. package/src/store/useDebugPanelStore.ts +0 -98
  193. package/src/store/useDebugProfileStore.ts +0 -130
  194. package/src/store/useLayoutStore.ts +0 -205
  195. package/src/store/useMorphInstanceStore.ts +0 -289
  196. package/src/store/useMorphologyStore.ts +0 -103
  197. package/src/store/usePlaygroundStore.ts +0 -236
  198. package/src/store/useShellRegistry.ts +0 -123
  199. package/src/store/useSuggestionsStore.ts +0 -57
  200. package/src/store/useThemeStore.ts +0 -399
  201. package/src/store/useUIComponentStore.ts +0 -179
  202. package/src/types/DecidoStoryDefinition.ts +0 -43
  203. package/src/utils/ai/ai-architect.ts +0 -92
  204. package/src/utils/ai/ai-code.ts +0 -187
  205. package/src/utils/ai/ai-core.ts +0 -50
  206. package/src/utils/ai/ai-media.ts +0 -292
  207. package/src/utils/layoutGraph.ts +0 -67
  208. package/tsconfig.json +0 -17
  209. package/tsconfig.tsbuildinfo +0 -1
@@ -1,100 +0,0 @@
1
- /**
2
- * networkInterceptor — Monkey-patches window.fetch to capture all network requests.
3
- * Sprint AP: All captured requests are stored in a global array accessible by NetworkTab.
4
- */
5
-
6
- export interface NetworkEntry {
7
- id: number;
8
- timestamp: string;
9
- method: string;
10
- url: string;
11
- status: number;
12
- duration: number; // ms
13
- requestBody?: string;
14
- responseBody?: string;
15
- size: number; // bytes approx
16
- error?: string;
17
- }
18
-
19
- let _networkId = 0;
20
- const MAX_ENTRIES = 200;
21
- const _entries: NetworkEntry[] = [];
22
- const _listeners = new Set<() => void>();
23
-
24
- function _getTimestamp(): string {
25
- const now = new Date();
26
- return `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
27
- }
28
-
29
- function _addEntry(entry: NetworkEntry) {
30
- _entries.push(entry);
31
- if (_entries.length > MAX_ENTRIES) _entries.shift();
32
- _listeners.forEach(fn => fn());
33
- }
34
-
35
- export function getNetworkEntries(): NetworkEntry[] {
36
- return _entries;
37
- }
38
-
39
- export function clearNetworkEntries() {
40
- _entries.length = 0;
41
- _listeners.forEach(fn => fn());
42
- }
43
-
44
- export function subscribeNetwork(cb: () => void): () => void {
45
- _listeners.add(cb);
46
- return () => _listeners.delete(cb);
47
- }
48
-
49
- let _installed = false;
50
-
51
- export function installNetworkInterceptor() {
52
- if (_installed) return;
53
- _installed = true;
54
-
55
- const _origFetch = window.fetch;
56
-
57
- window.fetch = async function (input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
58
- const method = init?.method?.toUpperCase() || 'GET';
59
- const url = typeof input === 'string' ? input : input instanceof URL ? input.toString() : (input as Request).url;
60
- const id = ++_networkId;
61
- const t0 = performance.now();
62
-
63
- let requestBody: string | undefined;
64
- try {
65
- if (init?.body) {
66
- requestBody = typeof init.body === 'string' ? init.body.slice(0, 2048) : '[binary]';
67
- }
68
- } catch { /* ignore */ }
69
-
70
- try {
71
- const res = await _origFetch.call(window, input, init);
72
- const duration = Math.round(performance.now() - t0);
73
-
74
- // Clone response to read body without consuming
75
- let responseBody: string | undefined;
76
- let size = 0;
77
- try {
78
- const clone = res.clone();
79
- const text = await clone.text();
80
- size = text.length;
81
- responseBody = text.slice(0, 2048);
82
- } catch { /* ignore */ }
83
-
84
- _addEntry({
85
- id, timestamp: _getTimestamp(), method, url,
86
- status: res.status, duration, requestBody, responseBody, size,
87
- });
88
-
89
- return res;
90
- } catch (err: any) {
91
- const duration = Math.round(performance.now() - t0);
92
- _addEntry({
93
- id, timestamp: _getTimestamp(), method, url,
94
- status: 0, duration, requestBody, size: 0,
95
- error: err.message,
96
- });
97
- throw err;
98
- }
99
- };
100
- }
@@ -1,41 +0,0 @@
1
- export const kernel = {
2
- askAI: async (prompt: string, type: string, mode: string) => {
3
- // Stub, logic moved
4
- return JSON.stringify({
5
- duration: 20,
6
- keyframes: [
7
- { t: 0, state: 'idle', canvas: false, speech: 'Modo sin servidor activo.' }
8
- ]
9
- });
10
- },
11
- onEvent: (cb: any) => {
12
- return () => { };
13
- }
14
- };
15
-
16
- export type UserRole = 'user' | 'admin' | 'developer';
17
- export type LicenseTarget = { id: string, name: string, type: string };
18
-
19
- export const useAuthStore = Object.assign(
20
- (selector: any) => {
21
- const state = {
22
- availableLicenses: [
23
- { id: '1', name: 'Decido Personal', type: 'personal' },
24
- { id: '2', name: 'Kúspide Corp', type: 'enterprise' },
25
- { id: '3', name: 'Madefront Ind', type: 'enterprise' }
26
- ]
27
- };
28
- return selector ? selector(state) : state;
29
- },
30
- {
31
- getState: () => ({
32
- availableLicenses: [
33
- { id: '1', name: 'Decido Personal', type: 'personal' },
34
- { id: '2', name: 'Kúspide Corp', type: 'enterprise' },
35
- { id: '3', name: 'Madefront Ind', type: 'enterprise' }
36
- ],
37
- login: (role?: string, context?: string, licenses?: any) => { },
38
- setActiveContext: (id?: string) => { }
39
- })
40
- }
41
- );
@@ -1,190 +0,0 @@
1
- /**
2
- * Plugin API — Public API for plugins to register shells, nodes, and extend Decido OS.
3
- *
4
- * Usage:
5
- * import { registerNodeType, registerShell, getNodeTypes } from '@decido/studio';
6
- *
7
- * registerNodeType({ type: 'my-node', component: MyNode, category: 'custom' });
8
- * registerShell('my-canvas', MyCanvasComponent);
9
- */
10
- import type { ComponentType } from 'react';
11
-
12
- // ═══════════════════════════════════════════
13
- // Node Type Registry
14
- // ═══════════════════════════════════════════
15
-
16
- export interface NodeTypeRegistration {
17
- /** Unique node type identifier */
18
- type: string;
19
- /** Display label */
20
- label: string;
21
- /** Category for grouping in context menu */
22
- category: 'automation' | 'logic' | 'ui' | 'data' | 'integration' | 'custom';
23
- /** React component to render the node */
24
- component: ComponentType<any>;
25
- /** Which canvas types this node is compatible with */
26
- compatibleWith?: ('flow-canvas' | 'dsd-editor' | 'all')[];
27
- /** Default node data */
28
- defaultData?: Record<string, any>;
29
- /** Handle definitions */
30
- handles?: {
31
- inputs?: string[];
32
- outputs?: string[];
33
- };
34
- /** Plugin ID that registered this node */
35
- pluginId?: string;
36
- /** Icon component or emoji */
37
- icon?: ComponentType<{ size?: number }> | string;
38
- }
39
-
40
- // In-memory registry
41
- const nodeTypeRegistry = new Map<string, NodeTypeRegistration>();
42
-
43
- /**
44
- * Register a custom node type that can be used in any compatible canvas.
45
- */
46
- export function registerNodeType(registration: NodeTypeRegistration): void {
47
- if (nodeTypeRegistry.has(registration.type)) {
48
- console.warn(`[PluginAPI] Node type "${registration.type}" already registered, overwriting.`);
49
- }
50
- nodeTypeRegistry.set(registration.type, {
51
- compatibleWith: ['all'],
52
- defaultData: {},
53
- handles: { inputs: ['default'], outputs: ['success'] },
54
- ...registration,
55
- });
56
- console.log(`[PluginAPI] 🧩 Node type registered: ${registration.type} (${registration.category})`);
57
- }
58
-
59
- /**
60
- * Get all registered node types, optionally filtered by canvas compatibility.
61
- */
62
- export function getRegisteredNodeTypes(
63
- canvasFilter?: 'flow-canvas' | 'dsd-editor' | 'all'
64
- ): NodeTypeRegistration[] {
65
- const all = Array.from(nodeTypeRegistry.values());
66
- if (!canvasFilter) return all;
67
- return all.filter(
68
- (n) => n.compatibleWith?.includes('all') || n.compatibleWith?.includes(canvasFilter)
69
- );
70
- }
71
-
72
- /**
73
- * Get React Flow nodeTypes map for a specific canvas type.
74
- * Merges built-in types with plugin-registered types.
75
- */
76
- export function getNodeTypesMap(
77
- canvasFilter?: 'flow-canvas' | 'dsd-editor' | 'all'
78
- ): Record<string, ComponentType<any>> {
79
- const filtered = getRegisteredNodeTypes(canvasFilter);
80
- const map: Record<string, ComponentType<any>> = {};
81
- for (const reg of filtered) {
82
- map[reg.type] = reg.component;
83
- }
84
- return map;
85
- }
86
-
87
- /**
88
- * Get context menu entries for registered node types.
89
- */
90
- export function getNodeTypeMenuEntries(
91
- canvasFilter?: 'flow-canvas' | 'dsd-editor' | 'all'
92
- ): Array<{ type: string; label: string; category: string; icon?: any }> {
93
- return getRegisteredNodeTypes(canvasFilter).map((reg) => ({
94
- type: reg.type,
95
- label: reg.label,
96
- category: reg.category,
97
- icon: reg.icon,
98
- }));
99
- }
100
-
101
- /**
102
- * Remove a registered node type.
103
- */
104
- export function unregisterNodeType(type: string): boolean {
105
- return nodeTypeRegistry.delete(type);
106
- }
107
-
108
- // ═══════════════════════════════════════════
109
- // Plugin Manifest
110
- // ═══════════════════════════════════════════
111
-
112
- export interface PluginManifest {
113
- /** Unique plugin ID */
114
- id: string;
115
- /** Display name */
116
- name: string;
117
- /** Version */
118
- version: string;
119
- /** Shells to register */
120
- shells?: Array<{
121
- type: string;
122
- component: ComponentType<any>;
123
- }>;
124
- /** Node types to register */
125
- nodeTypes?: NodeTypeRegistration[];
126
- /** Called when plugin is loaded */
127
- onLoad?: () => void;
128
- /** Called when plugin is unloaded */
129
- onUnload?: () => void;
130
- }
131
-
132
- // Plugin registry
133
- const pluginRegistry = new Map<string, PluginManifest>();
134
-
135
- /**
136
- * Load a plugin manifest — registers all shells and node types.
137
- */
138
- export async function loadPlugin(manifest: PluginManifest): Promise<void> {
139
- // Avoid re-loading
140
- if (pluginRegistry.has(manifest.id)) {
141
- console.warn(`[PluginAPI] Plugin "${manifest.id}" already loaded.`);
142
- return;
143
- }
144
-
145
- // Register shells
146
- if (manifest.shells) {
147
- const { registerShell } = await import('../store/useShellRegistry');
148
- for (const shell of manifest.shells) {
149
- registerShell(shell.type, shell.component);
150
- }
151
- }
152
-
153
- // Register node types
154
- if (manifest.nodeTypes) {
155
- for (const nodeType of manifest.nodeTypes) {
156
- registerNodeType({ ...nodeType, pluginId: manifest.id });
157
- }
158
- }
159
-
160
- // Lifecycle
161
- manifest.onLoad?.();
162
- pluginRegistry.set(manifest.id, manifest);
163
- console.log(`[PluginAPI] 📦 Plugin loaded: ${manifest.name} v${manifest.version}`);
164
- }
165
-
166
- /**
167
- * Unload a plugin — removes its shells and node types.
168
- */
169
- export function unloadPlugin(pluginId: string): void {
170
- const manifest = pluginRegistry.get(pluginId);
171
- if (!manifest) return;
172
-
173
- // Remove node types
174
- if (manifest.nodeTypes) {
175
- for (const nt of manifest.nodeTypes) {
176
- unregisterNodeType(nt.type);
177
- }
178
- }
179
-
180
- manifest.onUnload?.();
181
- pluginRegistry.delete(pluginId);
182
- console.log(`[PluginAPI] 📦 Plugin unloaded: ${manifest.name}`);
183
- }
184
-
185
- /**
186
- * Get all loaded plugins.
187
- */
188
- export function getLoadedPlugins(): PluginManifest[] {
189
- return Array.from(pluginRegistry.values());
190
- }
@@ -1,69 +0,0 @@
1
- import { create } from 'zustand';
2
-
3
- // ─── MCP Server Types ────────────────────────────────────────
4
- export interface McpServerConfig {
5
- name: string;
6
- command: string;
7
- args: string;
8
- isDefault: boolean;
9
- isConnected: boolean;
10
- }
11
-
12
- interface McpState {
13
- mcpServers: McpServerConfig[];
14
- addMcpServer: (server: Omit<McpServerConfig, 'isConnected'>) => void;
15
- removeMcpServer: (name: string) => void;
16
- setMcpServerStatus: (name: string, isConnected: boolean) => void;
17
- }
18
-
19
- const STORAGE_KEY = 'macia_mcp_servers';
20
-
21
- /**
22
- * Load MCP server configs from localStorage.
23
- * No hardcoded server entries — defaults are injected by the host app
24
- * via `useMcpStore.getState().addMcpServer(...)` during boot.
25
- */
26
- const loadPersistedServers = (): McpServerConfig[] => {
27
- try {
28
- const stored = localStorage.getItem(STORAGE_KEY);
29
- if (stored) {
30
- const parsed = JSON.parse(stored);
31
- if (Array.isArray(parsed)) return parsed;
32
- }
33
- } catch (e) {
34
- console.error('[McpStore] Failed to parse persisted MCP servers', e);
35
- }
36
- return [];
37
- };
38
-
39
- const persistServers = (servers: McpServerConfig[]) => {
40
- try {
41
- localStorage.setItem(STORAGE_KEY, JSON.stringify(servers));
42
- } catch (e) {
43
- console.error('[McpStore] Failed to persist MCP servers', e);
44
- }
45
- };
46
-
47
- // ─── Store ───────────────────────────────────────────────────
48
- export const useMcpStore = create<McpState>()((set) => ({
49
- mcpServers: loadPersistedServers(),
50
-
51
- addMcpServer: (server) => set((state) => {
52
- const next = [
53
- ...state.mcpServers.filter(s => s.name !== server.name),
54
- { ...server, isConnected: false },
55
- ];
56
- persistServers(next);
57
- return { mcpServers: next };
58
- }),
59
-
60
- removeMcpServer: (name) => set((state) => {
61
- const next = state.mcpServers.filter(s => s.name !== name || s.isDefault);
62
- persistServers(next);
63
- return { mcpServers: next };
64
- }),
65
-
66
- setMcpServerStatus: (name, isConnected) => set((state) => ({
67
- mcpServers: state.mcpServers.map(s => s.name === name ? { ...s, isConnected } : s),
68
- })),
69
- }));
@@ -1,60 +0,0 @@
1
- import { create } from 'zustand';
2
-
3
- export type UpdaterStatus = 'idle' | 'checking' | 'downloading' | 'installing' | 'rebooting' | 'error';
4
-
5
- interface UpdaterState {
6
- isUpdating: boolean;
7
- status: UpdaterStatus;
8
- progress: number; // 0 to 100
9
- downloadedBytes: number;
10
- totalBytes: number;
11
- version: string | null;
12
- error: string | null;
13
-
14
- // Actions
15
- setChecking: () => void;
16
- setDownloading: (version: string, totalBytes: number) => void;
17
- updateProgress: (downloadedBytes: number) => void;
18
- setInstalling: () => void;
19
- setRebooting: () => void;
20
- setError: (msg: string) => void;
21
- reset: () => void;
22
- }
23
-
24
- export const useUpdaterStore = create<UpdaterState>((set, get) => ({
25
- isUpdating: false,
26
- status: 'idle',
27
- progress: 0,
28
- downloadedBytes: 0,
29
- totalBytes: 0,
30
- version: null,
31
- error: null,
32
-
33
- setChecking: () => set({ status: 'checking', error: null }),
34
- setDownloading: (version, totalBytes) => set({
35
- isUpdating: true,
36
- status: 'downloading',
37
- version,
38
- totalBytes,
39
- downloadedBytes: 0,
40
- progress: 0
41
- }),
42
- updateProgress: (downloadedBytes) => {
43
- const total = get().totalBytes;
44
- const currentBytes = get().downloadedBytes + downloadedBytes;
45
- const progress = total > 0 ? Math.min(Math.round((currentBytes / total) * 100), 100) : 0;
46
- set({ downloadedBytes: currentBytes, progress });
47
- },
48
- setInstalling: () => set({ status: 'installing', progress: 100 }),
49
- setRebooting: () => set({ status: 'rebooting' }),
50
- setError: (msg) => set({ status: 'error', error: msg, isUpdating: false }),
51
- reset: () => set({
52
- isUpdating: false,
53
- status: 'idle',
54
- progress: 0,
55
- downloadedBytes: 0,
56
- totalBytes: 0,
57
- version: null,
58
- error: null
59
- })
60
- }));