@decido/shell 1.0.0

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 (208) hide show
  1. package/.turbo/turbo-build.log +13 -0
  2. package/package.json +65 -0
  3. package/src/AgentPlayer.tsx +105 -0
  4. package/src/DecidoPlayer.tsx +117 -0
  5. package/src/bridge/BridgeAgent.ts +443 -0
  6. package/src/components/DecidoIcon.tsx +56 -0
  7. package/src/components/JsonTreeEditor.tsx +117 -0
  8. package/src/components/PanelSplitter.tsx +71 -0
  9. package/src/components/PluginErrorBoundary.tsx +69 -0
  10. package/src/components/SafeLiquidUI.tsx +114 -0
  11. package/src/components/TransientLayer.tsx +92 -0
  12. package/src/components/agent/AgentChat.tsx +134 -0
  13. package/src/components/chat-extensions/IntentCatalogPanel.tsx +81 -0
  14. package/src/components/chat-extensions/chatSlashCommands.ts +101 -0
  15. package/src/components/controls/CreatorInputBar.tsx +144 -0
  16. package/src/components/controls/OSToolbar.tsx +90 -0
  17. package/src/components/controls/TimelineTape.tsx +43 -0
  18. package/src/components/debug/ActionTimelineTab.tsx +111 -0
  19. package/src/components/debug/CSSInspectorTab.tsx +436 -0
  20. package/src/components/debug/ExportTab.tsx +192 -0
  21. package/src/components/debug/FlowHealthTab.tsx +86 -0
  22. package/src/components/debug/LogsTab.tsx +110 -0
  23. package/src/components/debug/MorphStackTab.tsx +241 -0
  24. package/src/components/debug/NetworkTab.tsx +173 -0
  25. package/src/components/debug/PerformanceTab.tsx +171 -0
  26. package/src/components/debug/ProfilesTab.tsx +238 -0
  27. package/src/components/debug/ReplayTab.tsx +70 -0
  28. package/src/components/debug/StoresTab.tsx +255 -0
  29. package/src/components/debug/TopologyTab.tsx +59 -0
  30. package/src/components/debug/debugConfig.tsx +66 -0
  31. package/src/components/playground/DebugPanel.tsx +112 -0
  32. package/src/components/playground/HeaderCenterControls.tsx +92 -0
  33. package/src/components/playground/KeyframeListItem.tsx +70 -0
  34. package/src/components/playground/PlaygroundAppSidebar.tsx +171 -0
  35. package/src/components/playground/PlaygroundBottomControls.tsx +132 -0
  36. package/src/components/playground/PlaygroundCanvas.tsx +87 -0
  37. package/src/components/playground/PlaygroundChat.tsx +236 -0
  38. package/src/components/playground/PlaygroundErrorBoundary.tsx +63 -0
  39. package/src/components/playground/PlaygroundFloatingInput.tsx +352 -0
  40. package/src/components/playground/PlaygroundHeader.tsx +222 -0
  41. package/src/components/playground/PlaygroundSidebar.tsx +136 -0
  42. package/src/components/playground/PlaygroundTerminal.tsx +44 -0
  43. package/src/components/playground/SuggestionCards.tsx +29 -0
  44. package/src/components/playground/demos/ClinicaAINode.tsx +221 -0
  45. package/src/components/playground/demos/FinanceAINode.tsx +226 -0
  46. package/src/components/playground/demos/KiaAcademyNode.tsx +250 -0
  47. package/src/components/playground/demos/KiaBotNode.tsx +207 -0
  48. package/src/components/playground/demos/KiaCampaignNode.tsx +191 -0
  49. package/src/components/playground/demos/KiaComplianceNode.tsx +140 -0
  50. package/src/components/playground/demos/KiaCustomerJourneyNode.tsx +220 -0
  51. package/src/components/playground/demos/KiaCyberNode.tsx +203 -0
  52. package/src/components/playground/demos/KiaDashboardNode.tsx +399 -0
  53. package/src/components/playground/demos/KiaEmbudoOverviewNode.tsx +168 -0
  54. package/src/components/playground/demos/KiaExecutiveNode.tsx +169 -0
  55. package/src/components/playground/demos/KiaGamificationNode.tsx +229 -0
  56. package/src/components/playground/demos/KiaIntelligenceHubNode.tsx +165 -0
  57. package/src/components/playground/demos/KiaInventoryNode.tsx +183 -0
  58. package/src/components/playground/demos/KiaLeadScoringNode.tsx +226 -0
  59. package/src/components/playground/demos/KiaLiveSimulationNode.tsx +177 -0
  60. package/src/components/playground/demos/KiaMultiDealerNode.tsx +223 -0
  61. package/src/components/playground/demos/KiaNPSVoiceNode.tsx +214 -0
  62. package/src/components/playground/demos/KiaOmnichannelNode.tsx +162 -0
  63. package/src/components/playground/demos/KiaPBIBudgetNode.tsx +152 -0
  64. package/src/components/playground/demos/KiaPBIConversionNode.tsx +206 -0
  65. package/src/components/playground/demos/KiaPBIFunnelNode.tsx +184 -0
  66. package/src/components/playground/demos/KiaPBIOwnershipNode.tsx +113 -0
  67. package/src/components/playground/demos/KiaPBIPartnerNode.tsx +143 -0
  68. package/src/components/playground/demos/KiaPBIPreciosNode.tsx +120 -0
  69. package/src/components/playground/demos/KiaPBIRuntNode.tsx +205 -0
  70. package/src/components/playground/demos/KiaPartnerScoreNode.tsx +206 -0
  71. package/src/components/playground/demos/KiaPredictiveNode.tsx +226 -0
  72. package/src/components/playground/demos/KiaShowroomNode.tsx +194 -0
  73. package/src/components/playground/demos/KiaStoreNode.tsx +215 -0
  74. package/src/components/playground/demos/KiaSustainabilityNode.tsx +173 -0
  75. package/src/components/playground/demos/KiaUsedVehiclesNode.tsx +163 -0
  76. package/src/components/playground/demos/KiaWorkshopNode.tsx +221 -0
  77. package/src/components/playground/demos/SmartCityNode.tsx +205 -0
  78. package/src/components/playground/demos/kia_campaign_manifest.json +112 -0
  79. package/src/components/playground/input-parts/AIModelSelector.tsx +156 -0
  80. package/src/components/playground/input-parts/InputActions.tsx +80 -0
  81. package/src/components/playground/input-parts/InputToolbar.tsx +245 -0
  82. package/src/components/playground/input-parts/ResourceLibraryPanel.tsx +287 -0
  83. package/src/components/playground/sidebarDsdIO.ts +82 -0
  84. package/src/components/settings/SettingsPanel.tsx +267 -0
  85. package/src/components/shell/AppHeader.tsx +9 -0
  86. package/src/components/shell/AppShell.tsx +139 -0
  87. package/src/components/shell/ArtifactBar.tsx +97 -0
  88. package/src/components/shell/BootScreen.tsx +19 -0
  89. package/src/components/shell/CenterComposite.tsx +87 -0
  90. package/src/components/shell/CodeEditorPanel.tsx +88 -0
  91. package/src/components/shell/GlobalOverlays.tsx +228 -0
  92. package/src/components/shell/LayoutConfigurator.tsx +209 -0
  93. package/src/components/shell/LayoutGrid.tsx +178 -0
  94. package/src/components/shell/MorphShell.tsx +368 -0
  95. package/src/components/shell/PluginViewer.tsx +147 -0
  96. package/src/components/shell/ShellNexusPreview.tsx +458 -0
  97. package/src/components/shell/SlotRenderer.tsx +115 -0
  98. package/src/components/shell/TabBar.tsx +94 -0
  99. package/src/components/shell/TemplateLibrary.tsx +195 -0
  100. package/src/components/shell/layoutConstants.ts +35 -0
  101. package/src/components/shell/morphStageMeta.ts +15 -0
  102. package/src/components/shell/shells/BuiltInShells.tsx +443 -0
  103. package/src/components/shell/shells/DatawayChatShell.tsx +42 -0
  104. package/src/components/shell/shells/TokenPreview.tsx +339 -0
  105. package/src/components/shell/shells/bootShells.ts +31 -0
  106. package/src/components/shells/CreatorShell.tsx +37 -0
  107. package/src/components/shells/DecidoShell.tsx +447 -0
  108. package/src/components/shells/ExperimentalChatShell.tsx +245 -0
  109. package/src/components/shells/UserCanvas.tsx +44 -0
  110. package/src/components/studio/BlueprintManagerPanel.tsx +137 -0
  111. package/src/components/studio/DependencyTreePanel.tsx +192 -0
  112. package/src/components/studio/NodePalette.tsx +92 -0
  113. package/src/components/studio/NodePropertiesPanel.tsx +81 -0
  114. package/src/components/studio/ReactFlowEditor.tsx +242 -0
  115. package/src/components/studio/TimelineEditor.tsx +122 -0
  116. package/src/components/studio/TimelineKeyframeCard.tsx +99 -0
  117. package/src/components/studio/VariablePanel.tsx +181 -0
  118. package/src/components/studio/blueprint/BlueprintCard.tsx +82 -0
  119. package/src/components/studio/editor/CanvasContextMenu.tsx +107 -0
  120. package/src/components/studio/editor/EditorToolbar.tsx +80 -0
  121. package/src/components/studio/editor/StageContentRenderer.tsx +134 -0
  122. package/src/components/studio/editor/TrackPropertyEditors.tsx +133 -0
  123. package/src/components/studio/editor/TreeNodeItem.tsx +91 -0
  124. package/src/components/studio/editor/edgeStyles.ts +43 -0
  125. package/src/components/studio/editor/editorKeyHandler.ts +95 -0
  126. package/src/components/studio/editor/nodeTypeRegistry.ts +137 -0
  127. package/src/components/studio/editor/paletteCatalog.tsx +84 -0
  128. package/src/components/studio/nodes/shell/InteractionNodes.tsx +82 -0
  129. package/src/components/studio/nodes/shell/LayoutControlNodes.tsx +69 -0
  130. package/src/components/studio/nodes/shell/RegisterActionNode.tsx +20 -0
  131. package/src/components/studio/nodes/shell/RegisterButtonNode.tsx +22 -0
  132. package/src/components/studio/nodes/shell/RegisterPanelNode.tsx +19 -0
  133. package/src/components/studio/nodes/shell/RegisterSidebarNode.tsx +19 -0
  134. package/src/components/studio/nodes/shell/RegisterStatusBarNode.tsx +22 -0
  135. package/src/components/studio/nodes/shell/RegisterTabNode.tsx +21 -0
  136. package/src/components/studio/nodes/shell/RegisterTopBarNode.tsx +22 -0
  137. package/src/components/studio/nodes/shell/ShellConfigNode.tsx +51 -0
  138. package/src/components/studio/nodes/shell/ShellNodeBase.tsx +100 -0
  139. package/src/components/studio/nodes/shell/ThemeNodes.tsx +51 -0
  140. package/src/components/studio/nodes/shell/index.ts +12 -0
  141. package/src/components/widgets/BroadcastWidget.tsx +93 -0
  142. package/src/components/widgets/MarketplaceWidget.tsx +298 -0
  143. package/src/components/widgets/McpToolsWidget.tsx +231 -0
  144. package/src/components/widgets/OpsDashboard.tsx +59 -0
  145. package/src/components/widgets/QuickActionsWidget.tsx +60 -0
  146. package/src/components/widgets/UsageWidget.tsx +112 -0
  147. package/src/components/widgets/WidgetRenderer.tsx +892 -0
  148. package/src/components/widgets/WidgetSlotPanel.tsx +213 -0
  149. package/src/config/IconRegistry.ts +126 -0
  150. package/src/contexts/NetworkProvider.tsx +162 -0
  151. package/src/core/AIDirector.ts +71 -0
  152. package/src/core/EventBus.ts +37 -0
  153. package/src/core/PluginContext.tsx +141 -0
  154. package/src/hooks/listeners/useUIStateListener.ts +59 -0
  155. package/src/hooks/listeners/useWhatsAppListener.ts +110 -0
  156. package/src/hooks/morphBridge.ts +82 -0
  157. package/src/hooks/useAIModelSelector.ts +144 -0
  158. package/src/hooks/useAgentStream.ts +220 -0
  159. package/src/hooks/useAutoUpdater.ts +89 -0
  160. package/src/hooks/useBootSequence.ts +20 -0
  161. package/src/hooks/useExportDSD.ts +53 -0
  162. package/src/hooks/useFullscreen.ts +35 -0
  163. package/src/hooks/useGeminiStream.ts +282 -0
  164. package/src/hooks/useIntentLens.ts +224 -0
  165. package/src/hooks/useKeyboardShortcuts.ts +69 -0
  166. package/src/hooks/useLoggerBridge.ts +32 -0
  167. package/src/hooks/useMcpClient.ts +112 -0
  168. package/src/hooks/useNexusaiDeploy.ts +118 -0
  169. package/src/hooks/usePlaybackEngine.ts +21 -0
  170. package/src/hooks/usePlaygroundCommander.ts +475 -0
  171. package/src/hooks/usePluginEngine.ts +165 -0
  172. package/src/hooks/useScreenRecorder.ts +73 -0
  173. package/src/hooks/useShellKeyboard.ts +40 -0
  174. package/src/hooks/useShellShortcuts.ts +118 -0
  175. package/src/hooks/useSoundEffects.ts +35 -0
  176. package/src/hooks/useStudioConfig.ts +72 -0
  177. package/src/hooks/useSystemBoot.ts +84 -0
  178. package/src/hooks/useSystemTelemetry.ts +62 -0
  179. package/src/index.ts +97 -0
  180. package/src/lib/debugLogger.ts +80 -0
  181. package/src/lib/networkInterceptor.ts +100 -0
  182. package/src/mocks/decido.tsx +41 -0
  183. package/src/plugins/pluginAPI.ts +190 -0
  184. package/src/store/McpStore.ts +69 -0
  185. package/src/store/UpdaterStore.ts +60 -0
  186. package/src/store/engine.ts +392 -0
  187. package/src/store/index.ts +4 -0
  188. package/src/store/layoutPresets.ts +66 -0
  189. package/src/store/playgroundTypes.ts +98 -0
  190. package/src/store/useActionTimelineStore.ts +48 -0
  191. package/src/store/useDebugPanelStore.ts +98 -0
  192. package/src/store/useDebugProfileStore.ts +130 -0
  193. package/src/store/useLayoutStore.ts +205 -0
  194. package/src/store/useMorphInstanceStore.ts +289 -0
  195. package/src/store/useMorphologyStore.ts +103 -0
  196. package/src/store/usePlaygroundStore.ts +236 -0
  197. package/src/store/useShellRegistry.ts +123 -0
  198. package/src/store/useSuggestionsStore.ts +57 -0
  199. package/src/store/useThemeStore.ts +399 -0
  200. package/src/store/useUIComponentStore.ts +179 -0
  201. package/src/types/DecidoStoryDefinition.ts +43 -0
  202. package/src/utils/ai/ai-architect.ts +92 -0
  203. package/src/utils/ai/ai-code.ts +187 -0
  204. package/src/utils/ai/ai-core.ts +50 -0
  205. package/src/utils/ai/ai-media.ts +292 -0
  206. package/src/utils/layoutGraph.ts +67 -0
  207. package/tsconfig.json +17 -0
  208. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,392 @@
1
+ import { create } from 'zustand';
2
+ import { MaciaPlugin, MaciaWidget, WidgetRenderMode } from '@decido/plugin-engine';
3
+ import { kernel } from '@decido/kernel-bridge';
4
+
5
+ // Transient Overlays definitions
6
+ export type ShellMode = 'workbench' | 'canvas' | 'landing' | 'ghost';
7
+
8
+ export interface TransientOverlay {
9
+ id: string;
10
+ widgetId: string;
11
+ position: { x: number; y: number; width?: number; height?: number };
12
+ props?: Record<string, any>;
13
+ }
14
+
15
+ export type LayoutNode = {
16
+ id: string;
17
+ type: 'split-vertical' | 'split-horizontal' | 'tabs' | 'widget';
18
+ children?: LayoutNode[];
19
+ widgetId?: string;
20
+ size?: number; // flex basis/flex grow ratio
21
+ };
22
+
23
+ export interface Workspace {
24
+ id: string;
25
+ name: string;
26
+ icon?: any; // React.ReactNode equivalent but avoiding cyclic typings issue if any, or just import React
27
+ layout: LayoutNode;
28
+ }
29
+
30
+ interface ShellState {
31
+ plugins: Map<string, MaciaPlugin>;
32
+ widgets: Map<string, MaciaWidget>;
33
+
34
+ // Layout Management
35
+ activeShellMode: ShellMode;
36
+ setShellMode: (mode: ShellMode) => void;
37
+
38
+ rootLayout: LayoutNode | null;
39
+ activeWidgetId: string | null;
40
+
41
+ // Workspaces (Tabs mapping to rootLayouts)
42
+ workspaces: Workspace[];
43
+ activeWorkspaceId: string | null;
44
+
45
+ // Transient UI Layer
46
+ transientOverlays: TransientOverlay[];
47
+ isCommandPaletteOpen: boolean;
48
+ isForgeTerminalOpen: boolean;
49
+ isGodModePanelOpen: boolean;
50
+ isMarketplaceOpen: boolean;
51
+ isShortcutSettingsOpen: boolean;
52
+
53
+
54
+ // Actions
55
+ registerPlugin: (plugin: MaciaPlugin) => void;
56
+ unregisterPlugin: (pluginId: string) => void;
57
+
58
+ openTransientOverlay: (overlay: Omit<TransientOverlay, 'id'>) => string;
59
+ closeTransientOverlay: (id: string) => void;
60
+
61
+ setCommandPaletteOpen: (open: boolean) => void;
62
+ setForgeTerminalOpen: (open: boolean) => void;
63
+ setGodModePanelOpen: (open: boolean) => void;
64
+ setMarketplaceOpen: (open: boolean) => void;
65
+ setShortcutSettingsOpen: (open: boolean) => void;
66
+
67
+ setLayout: (layout: LayoutNode) => void;
68
+
69
+ // Workspace actions
70
+ addWorkspace: (workspace: Workspace) => void;
71
+ setActiveWorkspace: (id: string) => void;
72
+
73
+ // Scene / Layout Persistence
74
+ savedScenes: Record<string, LayoutNode>;
75
+ saveScene: (sceneName: string) => void;
76
+ loadScene: (sceneName: string) => void;
77
+
78
+ // Phase 9: Intent-Based Registry & Morphological Interfaces
79
+ requestCapability: (capability: string) => MaciaWidget[];
80
+ openWidgetByCapability: (capability: string, options?: { renderMode?: WidgetRenderMode; data?: any }) => boolean;
81
+
82
+ // Phase 16: Live Data Context
83
+ widgetDataBus: Record<string, any>;
84
+ setWidgetData: (widgetId: string, data: any) => void;
85
+
86
+ // Phase 18: Thin Client Mobile Support
87
+ isThinClient: boolean;
88
+ initializeEnvironment: () => Promise<void>;
89
+ }
90
+
91
+ import { sentinelMiddleware } from '@decido/sentinel-browser';
92
+
93
+ export const useShellStore = create<ShellState>()(
94
+ sentinelMiddleware('shell_store', (set) => ({
95
+ plugins: new Map(),
96
+ widgets: new Map(),
97
+
98
+ activeShellMode: 'workbench', // Default to Workbench given it's the ERP standard
99
+ setShellMode: (mode) => set({ activeShellMode: mode }),
100
+
101
+ rootLayout: null,
102
+ activeWidgetId: null,
103
+
104
+ workspaces: [],
105
+ activeWorkspaceId: null,
106
+
107
+ transientOverlays: [],
108
+ isCommandPaletteOpen: false,
109
+ isForgeTerminalOpen: false,
110
+ isGodModePanelOpen: false,
111
+ isMarketplaceOpen: false,
112
+ isShortcutSettingsOpen: false,
113
+
114
+ // MCP servers moved to dedicated McpStore.ts
115
+
116
+ savedScenes: {},
117
+
118
+ widgetDataBus: {},
119
+
120
+ setWidgetData: (widgetId: string, data: any) => set((state: ShellState) => ({
121
+ widgetDataBus: { ...state.widgetDataBus, [widgetId]: data }
122
+ })),
123
+
124
+ isThinClient: false,
125
+ initializeEnvironment: async () => {
126
+ try {
127
+ const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;
128
+ if (!isTauri) {
129
+ console.log('[OS] Web Environment Detected (No Tauri). Running in standard browser mode.');
130
+ set({ isThinClient: false });
131
+ return;
132
+ }
133
+
134
+ const osPlugin = await import('@tauri-apps/plugin-os');
135
+ const osType = await osPlugin.type();
136
+ const mobile = osType === 'android' || osType === 'ios';
137
+ set({ isThinClient: mobile });
138
+ console.log(`[OS] Entorno detectado: ${mobile ? 'Móvil (Thin Client)' : 'Desktop (Node)'}`);
139
+
140
+ if (mobile) {
141
+ kernel.execute('broadcast_message', {
142
+ intent: "node_announcement",
143
+ payload: JSON.stringify({
144
+ tier: "Satellite",
145
+ capabilities: ["voice", "display"]
146
+ })
147
+ });
148
+ }
149
+
150
+ // Registrar listener global para notificaciones inter-nodales
151
+ kernel.onEvent(async (payload: any) => {
152
+ if (payload.event_type === 'broadcast_event' && payload.data?.intent === 'push_notification') {
153
+ const { title, body, urgency } = payload.data.payload;
154
+
155
+ try {
156
+ const notification = await import('@tauri-apps/plugin-notification');
157
+ let permission = await notification.isPermissionGranted();
158
+ if (!permission) {
159
+ permission = await notification.requestPermission() === 'granted';
160
+ }
161
+
162
+ if (permission) {
163
+ notification.sendNotification({
164
+ title,
165
+ body,
166
+ icon: 'notification_icon',
167
+ sound: urgency === 'critical' ? 'alarm' : 'default'
168
+ });
169
+ console.log(`[Satellite] 🔔 Alerta recibida de ${payload.agent_id}: ${title}`);
170
+ }
171
+ } catch (e) {
172
+ console.warn('Failed to send tauri notification', e);
173
+ }
174
+ }
175
+ });
176
+
177
+ } catch (e) {
178
+ console.warn('[OS] No se pudo detectar el entorno Tauri, asumiendo Desktop', e);
179
+ }
180
+ },
181
+
182
+ registerPlugin: (plugin: MaciaPlugin) => set((state: ShellState) => {
183
+ const pluginId = plugin.id || plugin.manifest?.id;
184
+ if (!pluginId) return state; // Ignore invalid plugins
185
+
186
+ const newPlugins = new Map(state.plugins);
187
+ newPlugins.set(pluginId, plugin);
188
+
189
+ const newWidgets = new Map(state.widgets);
190
+ const widgets = plugin.widgets || plugin.manifest?.widgets || [];
191
+ widgets.forEach(w => {
192
+ const boundWidget: MaciaWidget = { ...w, pluginId: pluginId };
193
+ newWidgets.set(boundWidget.id, boundWidget);
194
+ });
195
+
196
+ // Add explicit cast to `state` as any to bypass `intentsCache` errors locally, or just omit it because intents are scanned dynamically via AIDirector now!
197
+ // We'll just execute standard state properties
198
+
199
+ if (plugin.onRegister) {
200
+ try {
201
+ Promise.resolve(plugin.onRegister()).catch(e => console.error(`[OS] Failed to async-register plugin ${pluginId}:`, e));
202
+ } catch (e) {
203
+ console.error(`[OS] Failed to sync-register plugin ${pluginId}:`, e);
204
+ }
205
+ }
206
+
207
+ // --- Phase 24: SDK Zero-Trust Mount ---
208
+ if (plugin.mount && plugin.manifest && typeof window !== 'undefined') {
209
+ try {
210
+ plugin.mount({} as any);
211
+ } catch (e) {
212
+ console.error(`[OS] Failed to mount plugin ${pluginId}`, e);
213
+ }
214
+ }
215
+
216
+ return { plugins: newPlugins, widgets: newWidgets } as any; // Typecast because of store variations
217
+ }),
218
+
219
+ unregisterPlugin: (pluginId: string) => set((state: ShellState) => {
220
+ const newPlugins = new Map(state.plugins);
221
+ const plugin = newPlugins.get(pluginId) as any;
222
+
223
+ if (plugin) {
224
+ const newWidgets = new Map(state.widgets);
225
+ const widgets = plugin.widgets || plugin.manifest?.widgets || [];
226
+ widgets.forEach((w: MaciaWidget) => newWidgets.delete(w.id));
227
+
228
+ if (plugin.onUnregister) {
229
+ try {
230
+ Promise.resolve(plugin.onUnregister()).catch(e => console.error(`[OS] Failed to async-unregister plugin ${pluginId}:`, e));
231
+ } catch (e) {
232
+ console.error(`[OS] Failed to sync-unregister plugin ${pluginId}:`, e);
233
+ }
234
+ }
235
+
236
+ newPlugins.delete(pluginId);
237
+ return { plugins: newPlugins, widgets: newWidgets } as any;
238
+ }
239
+ return state;
240
+ }),
241
+
242
+ openTransientOverlay: (overlay) => {
243
+ const id = typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : Date.now().toString() + Math.random().toString(36).substring(2);
244
+ set((state: ShellState) => ({
245
+ transientOverlays: [...state.transientOverlays, { ...overlay, id }]
246
+ }));
247
+ return id;
248
+ },
249
+
250
+ closeTransientOverlay: (id) => {
251
+ set((state: ShellState) => ({
252
+ transientOverlays: state.transientOverlays.filter(o => o.id !== id)
253
+ }));
254
+ },
255
+
256
+ setCommandPaletteOpen: (open) => {
257
+ set({ isCommandPaletteOpen: open });
258
+ },
259
+
260
+ setForgeTerminalOpen: (open) => {
261
+ set({ isForgeTerminalOpen: open });
262
+ },
263
+
264
+ setGodModePanelOpen: (open) => {
265
+ set({ isGodModePanelOpen: open });
266
+ },
267
+
268
+ setMarketplaceOpen: (open) => {
269
+ set({ isMarketplaceOpen: open });
270
+ },
271
+
272
+ setShortcutSettingsOpen: (open) => {
273
+ set({ isShortcutSettingsOpen: open });
274
+ },
275
+
276
+ setLayout: (layout) => {
277
+ // Wrap in View Transitions API to implement transmutations as per architectural rules
278
+ if (typeof document !== 'undefined' && 'startViewTransition' in document) {
279
+ const transition = (document as any).startViewTransition(() => {
280
+ set({ rootLayout: layout });
281
+ });
282
+ // Suppress the AbortError from unhandled promise rejections if transitions rapidly overlap
283
+ if (transition.ready) transition.ready.catch(() => { });
284
+ if (transition.finished) transition.finished.catch(() => { });
285
+ if (transition.updateCallbackDone) transition.updateCallbackDone.catch(() => { });
286
+ } else {
287
+ set({ rootLayout: layout });
288
+ }
289
+ },
290
+
291
+ addWorkspace: (workspace) => {
292
+ set((state: ShellState) => {
293
+ const exists = state.workspaces.find(w => w.id === workspace.id);
294
+ if (exists) return state;
295
+ return { workspaces: [...state.workspaces, workspace] };
296
+ });
297
+ },
298
+
299
+ setActiveWorkspace: (id) => {
300
+ // Actually Zustand set takes a function. Let's do carefully.
301
+ set((state: ShellState) => {
302
+ const ws = state.workspaces.find(w => w.id === id);
303
+ if (!ws) return state;
304
+
305
+ // Apply View Transition natively inside the state setter wrapping logic,
306
+ // but since startViewTransition is async, we do it carefully:
307
+ if (typeof document !== 'undefined' && 'startViewTransition' in document) {
308
+ const transition = (document as any).startViewTransition(() => {
309
+ set({ rootLayout: ws.layout, activeWorkspaceId: id });
310
+ });
311
+ if (transition.ready) transition.ready.catch(() => { });
312
+ if (transition.finished) transition.finished.catch(() => { });
313
+ if (transition.updateCallbackDone) transition.updateCallbackDone.catch(() => { });
314
+ return state; // We already called set() async inside the transition
315
+ } else {
316
+ return { rootLayout: ws.layout, activeWorkspaceId: id };
317
+ }
318
+ });
319
+ },
320
+
321
+ saveScene: (sceneName: string) => {
322
+ set((state: ShellState) => {
323
+ if (!state.rootLayout) return state;
324
+ // Native structured cloning or deep copy of the layout tree to avoid proxy mutations
325
+ const layoutSnapshot = JSON.parse(JSON.stringify(state.rootLayout));
326
+ return {
327
+ savedScenes: {
328
+ ...state.savedScenes,
329
+ [sceneName]: layoutSnapshot
330
+ }
331
+ };
332
+ });
333
+ },
334
+
335
+ loadScene: (sceneName: string) => {
336
+ set((state: ShellState) => {
337
+ const scene = state.savedScenes[sceneName];
338
+ if (!scene) return state;
339
+
340
+ // Implement view transition for the layout swap
341
+ if (typeof document !== 'undefined' && 'startViewTransition' in document) {
342
+ const transition = (document as any).startViewTransition(() => {
343
+ set({ rootLayout: JSON.parse(JSON.stringify(scene)) });
344
+ });
345
+ if (transition.ready) transition.ready.catch(() => { });
346
+ if (transition.finished) transition.finished.catch(() => { });
347
+ if (transition.updateCallbackDone) transition.updateCallbackDone.catch(() => { });
348
+ return state;
349
+ } else {
350
+ return { rootLayout: JSON.parse(JSON.stringify(scene)) };
351
+ }
352
+ });
353
+ },
354
+
355
+ requestCapability: (capability: string) => {
356
+ const matchingWidgets: MaciaWidget[] = [];
357
+ useShellStore.getState().widgets.forEach(w => {
358
+ if (w.capabilities?.includes(capability)) {
359
+ matchingWidgets.push(w);
360
+ }
361
+ });
362
+ return matchingWidgets;
363
+ },
364
+
365
+ openWidgetByCapability: (capability: string, options) => {
366
+ const state = useShellStore.getState();
367
+ const widgets = state.requestCapability(capability);
368
+ if (widgets.length === 0) return false;
369
+
370
+ const widget = widgets[0]; // Take best match (first for now)
371
+ const zone = widget.layoutConfig?.preferredZone || 'overlay';
372
+
373
+ // For morphological generic overlays
374
+ if (zone === 'overlay') {
375
+ state.openTransientOverlay({
376
+ widgetId: widget.id,
377
+ position: {
378
+ x: typeof window !== 'undefined' ? window.innerWidth / 2 - 200 : 100,
379
+ y: typeof window !== 'undefined' ? window.innerHeight / 2 - 150 : 100,
380
+ width: widget.layoutConfig?.initialSize?.w || 400,
381
+ height: widget.layoutConfig?.initialSize?.h || 300
382
+ },
383
+ props: { context: { renderMode: options?.renderMode || 'expanded', data: options?.data } }
384
+ });
385
+ return true;
386
+ }
387
+
388
+ // Feature expansion point: handle rendering into 'main-canvas' or 'dock'
389
+ console.warn(`[Shell OS] Morphological view requested for capability ${capability} in zone ${zone}, but only 'overlay' is currently implemented for Intent-Based Registry.`);
390
+ return false;
391
+ }
392
+ })));
@@ -0,0 +1,4 @@
1
+ export * from './engine';
2
+ export * from "@decido/shell-auth";
3
+ export * from '@decido/plugin-engine';
4
+ export * from './McpStore';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Layout types and built-in presets.
3
+ * Extracted from useLayoutStore for reuse across components.
4
+ */
5
+
6
+ /** Slot component identifiers — maps to real React components */
7
+ export type SlotComponentId =
8
+ | 'workspace-chat' | 'debug' | 'graph-editor' | 'timeline-editor'
9
+ | 'canvas' | 'terminal' | 'app-sidebar' | 'widget-panel' | null;
10
+
11
+ /** The 6 content regions from the grid */
12
+ export type RegionId = 'R1' | 'R2' | 'R3' | 'R4' | 'R5' | 'R6';
13
+
14
+ /** Morph stage types */
15
+ export type MorphStageType = '2d' | '3d' | 'workbench' | 'liquid' | 'artifact' | 'custom';
16
+
17
+ export interface MorphStage {
18
+ type: MorphStageType;
19
+ label?: string;
20
+ data?: any;
21
+ componentId?: string;
22
+ sourceNodeId?: string;
23
+ }
24
+
25
+ /** Tab in the T2 Tab Bar */
26
+ export interface LayoutTab {
27
+ id: string;
28
+ label: string;
29
+ icon?: string;
30
+ componentId: string;
31
+ closeable?: boolean;
32
+ data?: any;
33
+ }
34
+
35
+ /** Saved layout preset */
36
+ export interface LayoutPreset {
37
+ id: string;
38
+ name: string;
39
+ slots: Record<RegionId, SlotComponentId>;
40
+ createdAt: number;
41
+ }
42
+
43
+ // ── Built-in Presets ──
44
+
45
+ const PRESET_CREATOR: Record<RegionId, SlotComponentId> = {
46
+ R1: 'workspace-chat', R2: null, R3: 'graph-editor', R4: 'debug', R5: null, R6: null,
47
+ };
48
+
49
+ const PRESET_PLAYER: Record<RegionId, SlotComponentId> = {
50
+ R1: 'workspace-chat', R2: null, R3: null, R4: null, R5: null, R6: null,
51
+ };
52
+
53
+ const PRESET_MINIMAL: Record<RegionId, SlotComponentId> = {
54
+ R1: null, R2: null, R3: null, R4: null, R5: null, R6: null,
55
+ };
56
+
57
+ const PRESET_STUDIO: Record<RegionId, SlotComponentId> = {
58
+ R1: 'app-sidebar', R2: null, R3: 'graph-editor', R4: 'terminal', R5: null, R6: null,
59
+ };
60
+
61
+ export const BUILT_IN_PRESETS: Record<string, Record<RegionId, SlotComponentId>> = {
62
+ creator: PRESET_CREATOR,
63
+ player: PRESET_PLAYER,
64
+ minimal: PRESET_MINIMAL,
65
+ studio: PRESET_STUDIO,
66
+ };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Playground shared types.
3
+ * Extracted from usePlaygroundStore for reuse in components and hooks.
4
+ */
5
+
6
+ export type StepType = 'chat' | 'profile' | 'action';
7
+
8
+ export interface PlaygroundLog {
9
+ time: string;
10
+ msg: string;
11
+ type: string;
12
+ }
13
+
14
+ export type ChatMessageType = 'text' | 'alert' | 'card' | 'canvas' | 'workflow' | 'ui-artifact' | 'tool' | 'error';
15
+ export type ChatMessageSender = 'user' | 'agent' | 'system' | 'tool';
16
+
17
+ // ── Thinking (Chain of Thought) ──
18
+ export interface ThinkingData {
19
+ content: string;
20
+ duration?: number;
21
+ isStreaming?: boolean;
22
+ }
23
+
24
+ // ── Tool Calls (inline in message) ──
25
+ export interface ToolCallInfo {
26
+ id: string;
27
+ name: string;
28
+ args?: unknown;
29
+ result?: unknown;
30
+ status: 'running' | 'success' | 'error';
31
+ startTime: number;
32
+ endTime?: number;
33
+ }
34
+
35
+ // ── Execution Timeline Steps ──
36
+ export interface ExecutionStep {
37
+ type: 'thinking' | 'tool_call' | 'text_delta' | 'text_complete' | 'error';
38
+ label: string;
39
+ startTime: number;
40
+ endTime?: number;
41
+ }
42
+
43
+ // ── Code Blocks with Apply capability ──
44
+ export interface CodeBlockData {
45
+ code: string;
46
+ language?: string;
47
+ filePath?: string;
48
+ applyMode?: 'write' | 'search_replace' | 'insert_at' | 'append';
49
+ searchText?: string;
50
+ insertLine?: number;
51
+ }
52
+
53
+ export interface ChatMessage {
54
+ id: string;
55
+ type: ChatMessageType;
56
+ sender: ChatMessageSender;
57
+ text: string;
58
+ payload?: any;
59
+ timestamp: number;
60
+ actorId?: string;
61
+ actorName?: string;
62
+ uiSchema?: string;
63
+ // ── V2 Rich Content ──
64
+ thinking?: ThinkingData;
65
+ toolCalls?: ToolCallInfo[];
66
+ executionSteps?: ExecutionStep[];
67
+ codeBlocks?: CodeBlockData[];
68
+ // ── Intent metadata ──
69
+ detectedIntent?: {
70
+ type: string;
71
+ confidence: number;
72
+ matchedTokens?: string[];
73
+ resolvedAt: 'regex' | 'llm' | 'fallback';
74
+ };
75
+ morphInstanceId?: string;
76
+ }
77
+
78
+ export interface SavedSequence {
79
+ id: string;
80
+ prompt: string;
81
+ brand: string;
82
+ duration: number;
83
+ keyframes: any[];
84
+ }
85
+
86
+ export interface ChatInstance {
87
+ id: string;
88
+ title: string;
89
+ createdAt: number;
90
+ updatedAt: number;
91
+ preview?: string;
92
+ // ── V2: Identity & Context ──
93
+ shellType?: string; // Shell de salida asociada
94
+ icon?: string; // Emoji identificador
95
+ color?: string; // Color hex (#10b981)
96
+ model?: string; // Modelo Gemini usado
97
+ messageCount?: number; // Contador para preview
98
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * useActionTimelineStore — Records all store actions in chronological order.
3
+ * Sprint AR: Event-sourcing style timeline for debugging.
4
+ */
5
+
6
+ import { create } from 'zustand';
7
+
8
+ export interface TimelineEvent {
9
+ id: number;
10
+ timestamp: string;
11
+ storeName: string;
12
+ actionName: string;
13
+ data?: any;
14
+ level: 'info' | 'warn' | 'error';
15
+ }
16
+
17
+ const MAX_EVENTS = 200;
18
+ let _evtId = 0;
19
+
20
+ interface ActionTimelineState {
21
+ events: TimelineEvent[];
22
+ isPaused: boolean;
23
+ filter: string;
24
+
25
+ addEvent: (event: Omit<TimelineEvent, 'id'>) => void;
26
+ clear: () => void;
27
+ togglePause: () => void;
28
+ setFilter: (filter: string) => void;
29
+ }
30
+
31
+ export const useActionTimelineStore = create<ActionTimelineState>((set, get) => ({
32
+ events: [],
33
+ isPaused: false,
34
+ filter: '',
35
+
36
+ addEvent: (event) => {
37
+ if (get().isPaused) return;
38
+ const id = ++_evtId;
39
+ set(s => {
40
+ const events = [...s.events, { ...event, id }];
41
+ return { events: events.length > MAX_EVENTS ? events.slice(-MAX_EVENTS) : events };
42
+ });
43
+ },
44
+
45
+ clear: () => set({ events: [] }),
46
+ togglePause: () => set(s => ({ isPaused: !s.isPaused })),
47
+ setFilter: (filter) => set({ filter }),
48
+ }));